Merge branch 'blender2.7'
authorSergey Sharybin <sergey.vfx@gmail.com>
Tue, 2 Apr 2019 15:51:44 +0000 (17:51 +0200)
committerSergey Sharybin <sergey.vfx@gmail.com>
Tue, 2 Apr 2019 15:51:44 +0000 (17:51 +0200)
1  2 
source/blender/editors/interface/interface_templates.c
source/blender/makesrna/intern/rna_constraint.c

  #include "BLF_api.h"
  #include "BLT_translation.h"
  
+ #include "BKE_action.h"
  #include "BKE_colorband.h"
  #include "BKE_colortools.h"
+ #include "BKE_constraint.h"
  #include "BKE_context.h"
 -#include "BKE_depsgraph.h"
  #include "BKE_global.h"
 +#include "BKE_gpencil_modifier.h"
  #include "BKE_idcode.h"
  #include "BKE_idprop.h"
 +#include "BKE_layer.h"
  #include "BKE_library.h"
 +#include "BKE_library_override.h"
  #include "BKE_linestyle.h"
  #include "BKE_main.h"
  #include "BKE_modifier.h"
@@@ -1622,371 -1165,8 +1625,322 @@@ uiLayout *uiTemplateModifier(uiLayout *
        return NULL;
  }
  
 +/************************ Grease Pencil Modifier Template *************************/
 +
 +static uiLayout *gpencil_draw_modifier(
 +        uiLayout *layout, Object *ob,
 +        GpencilModifierData *md)
 +{
 +      const GpencilModifierTypeInfo *mti = BKE_gpencil_modifierType_getInfo(md->type);
 +      PointerRNA ptr;
 +      uiBlock *block;
 +      uiLayout *box, *column, *row, *sub;
 +      uiLayout *result = NULL;
 +
 +      /* create RNA pointer */
 +      RNA_pointer_create(&ob->id, &RNA_GpencilModifier, md, &ptr);
 +
 +      column = uiLayoutColumn(layout, true);
 +      uiLayoutSetContextPointer(column, "modifier", &ptr);
 +
 +      /* rounded header ------------------------------------------------------------------- */
 +      box = uiLayoutBox(column);
 +
 +      row = uiLayoutRow(box, false);
 +      block = uiLayoutGetBlock(row);
 +
 +      UI_block_emboss_set(block, UI_EMBOSS_NONE);
 +      /* Open/Close .................................  */
 +      uiItemR(row, &ptr, "show_expanded", 0, "", ICON_NONE);
 +
 +      /* modifier-type icon */
 +      uiItemL(row, "", RNA_struct_ui_icon(ptr.type));
 +      UI_block_emboss_set(block, UI_EMBOSS);
 +
 +      /* modifier name */
 +      if (mti->isDisabled && mti->isDisabled(md, 0)) {
 +              uiLayoutSetRedAlert(row, true);
 +      }
 +      uiItemR(row, &ptr, "name", 0, "", ICON_NONE);
 +      uiLayoutSetRedAlert(row, false);
 +
 +      /* mode enabling buttons */
 +      UI_block_align_begin(block);
 +      uiItemR(row, &ptr, "show_render", 0, "", ICON_NONE);
 +      uiItemR(row, &ptr, "show_viewport", 0, "", ICON_NONE);
 +
 +      if (mti->flags & eGpencilModifierTypeFlag_SupportsEditmode) {
 +              sub = uiLayoutRow(row, true);
 +              uiLayoutSetActive(sub, false);
 +              uiItemR(sub, &ptr, "show_in_editmode", 0, "", ICON_NONE);
 +      }
 +
 +      UI_block_align_end(block);
 +
 +      /* Up/Down + Delete ........................... */
 +      UI_block_align_begin(block);
 +      uiItemO(row, "", ICON_TRIA_UP, "OBJECT_OT_gpencil_modifier_move_up");
 +      uiItemO(row, "", ICON_TRIA_DOWN, "OBJECT_OT_gpencil_modifier_move_down");
 +      UI_block_align_end(block);
 +
 +      UI_block_emboss_set(block, UI_EMBOSS_NONE);
 +      uiItemO(row, "", ICON_X, "OBJECT_OT_gpencil_modifier_remove");
 +      UI_block_emboss_set(block, UI_EMBOSS);
 +
 +      /* modifier settings (under the header) --------------------------------------------------- */
 +      if (md->mode & eGpencilModifierMode_Expanded) {
 +              /* apply/convert/copy */
 +              box = uiLayoutBox(column);
 +              row = uiLayoutRow(box, false);
 +
 +              /* only here obdata, the rest of modifiers is ob level */
 +              UI_block_lock_set(block, BKE_object_obdata_is_libdata(ob), ERROR_LIBDATA_MESSAGE);
 +
 +              uiLayoutSetOperatorContext(row, WM_OP_INVOKE_DEFAULT);
 +
 +              sub = uiLayoutRow(row, false);
 +              if (mti->flags & eGpencilModifierTypeFlag_NoApply) {
 +                      uiLayoutSetEnabled(sub, false);
 +              }
 +              uiItemEnumO(sub, "OBJECT_OT_gpencil_modifier_apply", CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Apply"),
 +                          0, "apply_as", MODIFIER_APPLY_DATA);
 +              uiItemO(row, CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Copy"), ICON_NONE,
 +                      "OBJECT_OT_gpencil_modifier_copy");
 +
 +              /* result is the layout block inside the box,
 +               * that we return so that modifier settings can be drawn */
 +              result = uiLayoutColumn(box, false);
 +              block = uiLayoutAbsoluteBlock(box);
 +      }
 +
 +      /* error messages */
 +      if (md->error) {
 +              box = uiLayoutBox(column);
 +              row = uiLayoutRow(box, false);
 +              uiItemL(row, md->error, ICON_ERROR);
 +      }
 +
 +      return result;
 +}
 +
 +uiLayout *uiTemplateGpencilModifier(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
 +{
 +      Object *ob;
 +      GpencilModifierData *md, *vmd;
 +      int i;
 +
 +      /* verify we have valid data */
 +      if (!RNA_struct_is_a(ptr->type, &RNA_GpencilModifier)) {
 +              RNA_warning("Expected modifier on object");
 +              return NULL;
 +      }
 +
 +      ob = ptr->id.data;
 +      md = ptr->data;
 +
 +      if (!ob || !(GS(ob->id.name) == ID_OB)) {
 +              RNA_warning("Expected modifier on object");
 +              return NULL;
 +      }
 +
 +      UI_block_lock_set(uiLayoutGetBlock(layout), (ob && ID_IS_LINKED(ob)), ERROR_LIBDATA_MESSAGE);
 +
 +      /* find modifier and draw it */
 +      vmd = ob->greasepencil_modifiers.first;
 +      for (i = 0; vmd; i++, vmd = vmd->next) {
 +              if (md == vmd) {
 +                      return gpencil_draw_modifier(layout, ob, md);
 +              }
 +      }
 +
 +      return NULL;
 +}
 +
 +/************************ Shader FX Template *************************/
 +
 +static uiLayout *gpencil_draw_shaderfx(
 +        uiLayout *layout, Object *ob,
 +        ShaderFxData *md)
 +{
 +      const ShaderFxTypeInfo *mti = BKE_shaderfxType_getInfo(md->type);
 +      PointerRNA ptr;
 +      uiBlock *block;
 +      uiLayout *box, *column, *row, *sub;
 +      uiLayout *result = NULL;
 +
 +      /* create RNA pointer */
 +      RNA_pointer_create(&ob->id, &RNA_ShaderFx, md, &ptr);
 +
 +      column = uiLayoutColumn(layout, true);
 +      uiLayoutSetContextPointer(column, "shaderfx", &ptr);
 +
 +      /* rounded header ------------------------------------------------------------------- */
 +      box = uiLayoutBox(column);
 +
 +      row = uiLayoutRow(box, false);
 +      block = uiLayoutGetBlock(row);
 +
 +      UI_block_emboss_set(block, UI_EMBOSS_NONE);
 +      /* Open/Close .................................  */
 +      uiItemR(row, &ptr, "show_expanded", 0, "", ICON_NONE);
 +
 +      /* shader-type icon */
 +      uiItemL(row, "", RNA_struct_ui_icon(ptr.type));
 +      UI_block_emboss_set(block, UI_EMBOSS);
 +
 +      /* effect name */
 +      if (mti->isDisabled && mti->isDisabled(md, 0)) {
 +              uiLayoutSetRedAlert(row, true);
 +      }
 +      uiItemR(row, &ptr, "name", 0, "", ICON_NONE);
 +      uiLayoutSetRedAlert(row, false);
 +
 +      /* mode enabling buttons */
 +      UI_block_align_begin(block);
 +      uiItemR(row, &ptr, "show_render", 0, "", ICON_NONE);
 +      uiItemR(row, &ptr, "show_viewport", 0, "", ICON_NONE);
 +
 +      if (mti->flags & eShaderFxTypeFlag_SupportsEditmode) {
 +              sub = uiLayoutRow(row, true);
 +              uiLayoutSetActive(sub, false);
 +              uiItemR(sub, &ptr, "show_in_editmode", 0, "", ICON_NONE);
 +      }
 +
 +      UI_block_align_end(block);
 +
 +      /* Up/Down + Delete ........................... */
 +      UI_block_align_begin(block);
 +      uiItemO(row, "", ICON_TRIA_UP, "OBJECT_OT_shaderfx_move_up");
 +      uiItemO(row, "", ICON_TRIA_DOWN, "OBJECT_OT_shaderfx_move_down");
 +      UI_block_align_end(block);
 +
 +      UI_block_emboss_set(block, UI_EMBOSS_NONE);
 +      uiItemO(row, "", ICON_X, "OBJECT_OT_shaderfx_remove");
 +      UI_block_emboss_set(block, UI_EMBOSS);
 +
 +      /* effect settings (under the header) --------------------------------------------------- */
 +      if (md->mode & eShaderFxMode_Expanded) {
 +              /* apply/convert/copy */
 +              box = uiLayoutBox(column);
 +              row = uiLayoutRow(box, false);
 +
 +              /* only here obdata, the rest of effect is ob level */
 +              UI_block_lock_set(block, BKE_object_obdata_is_libdata(ob), ERROR_LIBDATA_MESSAGE);
 +
 +              /* result is the layout block inside the box,
 +               * that we return so that effect settings can be drawn */
 +              result = uiLayoutColumn(box, false);
 +              block = uiLayoutAbsoluteBlock(box);
 +      }
 +
 +      /* error messages */
 +      if (md->error) {
 +              box = uiLayoutBox(column);
 +              row = uiLayoutRow(box, false);
 +              uiItemL(row, md->error, ICON_ERROR);
 +      }
 +
 +      return result;
 +}
 +
 +uiLayout *uiTemplateShaderFx(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
 +{
 +      Object *ob;
 +      ShaderFxData *fx, *vfx;
 +      int i;
 +
 +      /* verify we have valid data */
 +      if (!RNA_struct_is_a(ptr->type, &RNA_ShaderFx)) {
 +              RNA_warning("Expected shader fx on object");
 +              return NULL;
 +      }
 +
 +      ob = ptr->id.data;
 +      fx = ptr->data;
 +
 +      if (!ob || !(GS(ob->id.name) == ID_OB)) {
 +              RNA_warning("Expected shader fx on object");
 +              return NULL;
 +      }
 +
 +      UI_block_lock_set(uiLayoutGetBlock(layout), (ob && ID_IS_LINKED(ob)), ERROR_LIBDATA_MESSAGE);
 +
 +      /* find modifier and draw it */
 +      vfx = ob->shader_fx.first;
 +      for (i = 0; vfx; i++, vfx = vfx->next) {
 +              if (fx == vfx) {
 +                      return gpencil_draw_shaderfx(layout, ob, fx);
 +              }
 +      }
 +
 +      return NULL;
 +}
 +
 +/************************ Redo Buttons Template *************************/
 +
 +static void template_operator_redo_property_buts_draw(
 +        const bContext *C, wmOperator *op,
 +        uiLayout *layout, int layout_flags,
 +        bool *r_has_advanced)
 +{
 +      if (op->type->flag & OPTYPE_MACRO) {
 +              for (wmOperator *macro_op = op->macro.first; macro_op; macro_op = macro_op->next) {
 +                      template_operator_redo_property_buts_draw(C, macro_op, layout, layout_flags, r_has_advanced);
 +              }
 +      }
 +      else {
 +              /* Might want to make label_align adjustable somehow. */
 +              eAutoPropButsReturn return_info = uiTemplateOperatorPropertyButs(
 +                      C, layout, op,
 +                      UI_BUT_LABEL_ALIGN_NONE,
 +                      layout_flags);
 +              if (return_info & UI_PROP_BUTS_ANY_FAILED_CHECK) {
 +                      if (r_has_advanced) {
 +                              *r_has_advanced = true;
 +                      }
 +              }
 +      }
 +}
 +
 +void uiTemplateOperatorRedoProperties(uiLayout *layout, const bContext *C)
 +{
 +      wmOperator *op = WM_operator_last_redo(C);
 +      uiBlock *block = uiLayoutGetBlock(layout);
 +
 +      if (op == NULL) {
 +              return;
 +      }
 +
 +      /* Disable for now, doesn't fit well in popover. */
 +#if 0
 +      /* Repeat button with operator name as text. */
 +      uiItemFullO(layout, "SCREEN_OT_repeat_last", RNA_struct_ui_name(op->type->srna),
 +                  ICON_NONE, NULL, WM_OP_INVOKE_DEFAULT, 0, NULL);
 +#endif
 +
 +      if (WM_operator_repeat_check(C, op)) {
 +              int layout_flags = 0;
 +              if (block->panel == NULL) {
 +                      layout_flags = UI_TEMPLATE_OP_PROPS_SHOW_TITLE;
 +              }
 +#if 0
 +              bool has_advanced = false;
 +#endif
 +
 +              UI_block_func_handle_set(block, ED_undo_operator_repeat_cb_evt, op);
 +              template_operator_redo_property_buts_draw(C, op, layout, layout_flags, NULL /* &has_advanced */ );
 +              /* Warning! this leaves the handle function for any other users of this block. */
 +
 +#if 0
 +              if (has_advanced) {
 +                      uiItemO(layout, IFACE_("More..."), ICON_NONE, "SCREEN_OT_redo_last");
 +              }
 +#endif
 +      }
 +}
 +
  /************************ Constraint Template *************************/
  
- #include "DNA_constraint_types.h"
- #include "BKE_action.h"
- #include "BKE_constraint.h"
- #define B_CONSTRAINT_TEST           5
- // #define B_CONSTRAINT_CHANGETARGET   6
- static void do_constraint_panels(bContext *C, void *ob_pt, int event)
- {
-       Object *ob = (Object *)ob_pt;
-       switch (event) {
-               case B_CONSTRAINT_TEST:
-                       break; /* no handling */
- #if 0 /* UNUSED */
-               case B_CONSTRAINT_CHANGETARGET:
-               {
-                       Main *bmain = CTX_data_main(C);
-                       if (ob->pose) {
-                               BKE_pose_tag_recalc(bmain, ob->pose); /* checks & sorts pose channels */
-                       }
-                       DEG_relations_tag_update(bmain);
-                       break;
-               }
- #endif
-               default:
-                       break;
-       }
-       /* note: RNA updates now call this, commenting else it gets called twice.
-        * if there are problems because of this, then rna needs changed update functions. */
- #if 0
-       object_test_constraints(ob);
-       if (ob->pose) {
-               BKE_pose_update_constraint_flags(ob->pose);
-       }
- #endif
-       if (ob->type == OB_ARMATURE) {
-               DEG_id_tag_update(&ob->id, ID_RECALC_GEOMETRY | ID_RECALC_TRANSFORM);
-       }
-       else {
-               DEG_id_tag_update(&ob->id, ID_RECALC_TRANSFORM);
-       }
-       WM_event_add_notifier(C, NC_OBJECT | ND_CONSTRAINT, ob);
- }
  static void constraint_active_func(bContext *UNUSED(C), void *ob_v, void *con_v)
  {
        ED_object_constraint_set_active(ob_v, con_v);
@@@ -2044,12 -1220,11 +1997,12 @@@ static uiLayout *draw_constraint(uiLayo
        UI_block_emboss_set(block, UI_EMBOSS);
  
        /* name */
-       uiDefBut(block, UI_BTYPE_LABEL, B_CONSTRAINT_TEST, typestr,
+       uiDefBut(block, UI_BTYPE_LABEL, 0, typestr,
                 xco + 0.5f * UI_UNIT_X, yco, 5 * UI_UNIT_X, 0.9f * UI_UNIT_Y, NULL, 0.0, 0.0, 0.0, 0.0, "");
  
 -      if (con->flag & CONSTRAINT_DISABLE)
 +      if (con->flag & CONSTRAINT_DISABLE) {
                uiLayoutSetRedAlert(row, true);
 +      }
  
        if (proxy_protected == 0) {
                uiItemR(row, &ptr, "name", 0, "", ICON_NONE);
        if (proxy_protected) {
                UI_block_emboss_set(block, UI_EMBOSS_NONE);
  
 -              /* draw a ghost icon (for proxy) and also a lock beside it, to show that constraint is "proxy locked" */
 -              uiDefIconBut(block, UI_BTYPE_BUT, 0, ICON_GHOST, xco + 12.2f * UI_UNIT_X, yco, 0.95f * UI_UNIT_X, 0.95f * UI_UNIT_Y,
 +              /* draw a ghost icon (for proxy) and also a lock beside it,
 +               * to show that constraint is "proxy locked" */
-               uiDefIconBut(block, UI_BTYPE_BUT, B_CONSTRAINT_TEST, ICON_GHOST_ENABLED, xco + 12.2f * UI_UNIT_X, yco, 0.95f * UI_UNIT_X, 0.95f * UI_UNIT_Y,
++              uiDefIconBut(block, UI_BTYPE_BUT, 0, ICON_GHOST_ENABLED, xco + 12.2f * UI_UNIT_X, yco, 0.95f * UI_UNIT_X, 0.95f * UI_UNIT_Y,
                             NULL, 0.0, 0.0, 0.0, 0.0, TIP_("Proxy Protected"));
-               uiDefIconBut(block, UI_BTYPE_BUT, B_CONSTRAINT_TEST, ICON_LOCKED, xco + 13.1f * UI_UNIT_X, yco, 0.95f * UI_UNIT_X, 0.95f * UI_UNIT_Y,
+               uiDefIconBut(block, UI_BTYPE_BUT, 0, ICON_LOCKED, xco + 13.1f * UI_UNIT_X, yco, 0.95f * UI_UNIT_X, 0.95f * UI_UNIT_Y,
                             NULL, 0.0, 0.0, 0.0, 0.0, TIP_("Proxy Protected"));
  
                UI_block_emboss_set(block, UI_EMBOSS);