diff options
-rw-r--r-- | release/scripts/ui/properties_object_constraint.py | 4 | ||||
-rw-r--r-- | source/blender/editors/include/UI_interface.h | 2 | ||||
-rw-r--r-- | source/blender/editors/interface/interface_templates.c | 46 | ||||
-rw-r--r-- | source/blender/editors/object/object_constraint.c | 4 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_constraint.c | 7 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_ui_api.c | 1 |
6 files changed, 42 insertions, 22 deletions
diff --git a/release/scripts/ui/properties_object_constraint.py b/release/scripts/ui/properties_object_constraint.py index 6288b51020a..0f55c78c1fa 100644 --- a/release/scripts/ui/properties_object_constraint.py +++ b/release/scripts/ui/properties_object_constraint.py @@ -20,6 +20,7 @@ import bpy narrowui = bpy.context.user_preferences.view.properties_width_check +narrowcon = 260 class ConstraintButtonsPanel(bpy.types.Panel): @@ -30,8 +31,9 @@ class ConstraintButtonsPanel(bpy.types.Panel): def draw_constraint(self, context, con): layout = self.layout - box = layout.template_constraint(con) wide_ui = context.region.width > narrowui + compact_con = context.region.width < narrowcon + box = layout.template_constraint(con, compact = compact_con) if box: # match enum type to our functions, avoids a lookup table. diff --git a/source/blender/editors/include/UI_interface.h b/source/blender/editors/include/UI_interface.h index db479b45472..35531a2a029 100644 --- a/source/blender/editors/include/UI_interface.h +++ b/source/blender/editors/include/UI_interface.h @@ -676,7 +676,7 @@ void uiTemplateAnyID(uiLayout *layout, struct bContext *C, struct PointerRNA *pt void uiTemplatePathBuilder(uiLayout *layout, struct bContext *C, struct PointerRNA *ptr, char *propname, struct PointerRNA *root_ptr, char *text); uiLayout *uiTemplateModifier(uiLayout *layout, struct bContext *C, struct PointerRNA *ptr, int compact); -uiLayout *uiTemplateConstraint(uiLayout *layout, struct PointerRNA *ptr); +uiLayout *uiTemplateConstraint(uiLayout *layout, struct PointerRNA *ptr, int compact); void uiTemplatePreview(uiLayout *layout, struct ID *id, struct ID *parent, struct MTex *slot); void uiTemplateColorRamp(uiLayout *layout, struct PointerRNA *ptr, char *propname, int expand); void uiTemplateHistogram(uiLayout *layout, struct PointerRNA *ptr, char *propname, int expand); diff --git a/source/blender/editors/interface/interface_templates.c b/source/blender/editors/interface/interface_templates.c index 52772aaf0e5..865a4ec8af9 100644 --- a/source/blender/editors/interface/interface_templates.c +++ b/source/blender/editors/interface/interface_templates.c @@ -944,12 +944,12 @@ static void constraint_active_func(bContext *C, void *ob_v, void *con_v) } /* draw panel showing settings for a constraint */ -static uiLayout *draw_constraint(uiLayout *layout, Object *ob, bConstraint *con) +static uiLayout *draw_constraint(uiLayout *layout, Object *ob, bConstraint *con, int compact) { bPoseChannel *pchan= get_active_posechannel(ob); bConstraintTypeInfo *cti; uiBlock *block; - uiLayout *result= NULL, *col, *box, *row, *subrow; + uiLayout *result= NULL, *col, *col1, *col2, *box, *row, *subrow, *split; PointerRNA ptr; char typestr[32]; short width = 265; @@ -985,13 +985,15 @@ static uiLayout *draw_constraint(uiLayout *layout, Object *ob, bConstraint *con) uiLayoutSetContextPointer(col, "constraint", &ptr); box= uiLayoutBox(col); - row= uiLayoutRow(box, 0); + split = uiLayoutSplit(box, 0.35, 0); + + col1= uiLayoutColumn(split, 0); + col2= uiLayoutColumn(split, 0); + row = uiLayoutRow(col1, 0); + subrow = uiLayoutRow(col2, 0); block= uiLayoutGetBlock(box); - subrow= uiLayoutRow(row, 0); - //uiLayoutSetAlignment(subrow, UI_LAYOUT_ALIGN_LEFT); - /* Draw constraint header */ uiBlockSetEmboss(block, UI_EMBOSSN); @@ -999,7 +1001,7 @@ static uiLayout *draw_constraint(uiLayout *layout, Object *ob, bConstraint *con) rb_col= (con->flag & CONSTRAINT_ACTIVE)?50:20; /* open/close */ - uiItemR(subrow, &ptr, "expanded", UI_ITEM_R_ICON_ONLY, "", 0); + uiItemR(row, &ptr, "expanded", UI_ITEM_R_ICON_ONLY, "", 0); /* name */ uiBlockSetEmboss(block, UI_EMBOSS); @@ -1008,15 +1010,12 @@ static uiLayout *draw_constraint(uiLayout *layout, Object *ob, bConstraint *con) uiBlockSetCol(block, TH_REDALERT);*/ uiDefBut(block, LABEL, B_CONSTRAINT_TEST, typestr, xco+10, yco, 100, 18, NULL, 0.0, 0.0, 0.0, 0.0, ""); - + if(proxy_protected == 0) { uiItemR(subrow, &ptr, "name", 0, "", 0); } else uiItemL(subrow, con->name, 0); - - subrow= uiLayoutRow(row, 0); - //uiLayoutSetAlignment(subrow, UI_LAYOUT_ALIGN_RIGHT); /* proxy-protected constraints cannot be edited, so hide up/down + close buttons */ if (proxy_protected) { @@ -1051,23 +1050,36 @@ static uiLayout *draw_constraint(uiLayout *layout, Object *ob, bConstraint *con) show_upbut= ((prev_proxylock == 0) && (con->prev)); show_downbut= (con->next) ? 1 : 0; + uiLayoutSetOperatorContext(subrow, WM_OP_INVOKE_DEFAULT); + + if (compact) { + /* Draw "Delete" Button in first row, before splitting */ + uiBlockSetEmboss(block, UI_EMBOSSN); + uiItemO(subrow, "", ICON_X, "CONSTRAINT_OT_delete"); + uiBlockSetEmboss(block, UI_EMBOSS); + + subrow = uiLayoutRow(col2, 0); + } + if (show_upbut || show_downbut) { uiBlockBeginAlign(block); uiBlockSetEmboss(block, UI_EMBOSS); if (show_upbut) - uiDefIconButO(block, BUT, "CONSTRAINT_OT_move_up", WM_OP_INVOKE_DEFAULT, ICON_TRIA_UP, xco+width-50, yco, 16, 18, "Move constraint up in constraint stack"); + uiItemO(subrow, "", ICON_TRIA_UP, "CONSTRAINT_OT_move_up"); if (show_downbut) - uiDefIconButO(block, BUT, "CONSTRAINT_OT_move_down", WM_OP_INVOKE_DEFAULT, ICON_TRIA_DOWN, xco+width-50+18, yco, 16, 18, "Move constraint down in constraint stack"); + uiItemO(subrow, "", ICON_TRIA_DOWN, "CONSTRAINT_OT_move_down"); uiBlockEndAlign(block); } /* Close 'button' - emboss calls here disable drawing of 'button' behind X */ uiBlockSetEmboss(block, UI_EMBOSSN); - uiDefIconButBitS(block, ICONTOGN, CONSTRAINT_OFF, B_CONSTRAINT_TEST, ICON_CHECKBOX_DEHLT, xco+243, yco, 19, 19, &con->flag, 0.0, 0.0, 0.0, 0.0, "enable/disable constraint"); + uiItemR(subrow, &ptr, "enabled", 0, "", 0); - uiDefIconButO(block, BUT, "CONSTRAINT_OT_delete", WM_OP_INVOKE_DEFAULT, ICON_X, xco+262, yco, 19, 19, "Delete constraint"); + if (!compact) { + uiItemO(subrow, "", ICON_X, "CONSTRAINT_OT_delete"); + } uiBlockSetEmboss(block, UI_EMBOSS); } @@ -1093,7 +1105,7 @@ static uiLayout *draw_constraint(uiLayout *layout, Object *ob, bConstraint *con) return result; } -uiLayout *uiTemplateConstraint(uiLayout *layout, PointerRNA *ptr) +uiLayout *uiTemplateConstraint(uiLayout *layout, PointerRNA *ptr, int compact) { Object *ob; bConstraint *con; @@ -1121,7 +1133,7 @@ uiLayout *uiTemplateConstraint(uiLayout *layout, PointerRNA *ptr) return NULL; } - return draw_constraint(layout, ob, con); + return draw_constraint(layout, ob, con, compact); } diff --git a/source/blender/editors/object/object_constraint.c b/source/blender/editors/object/object_constraint.c index 7b61d8de43f..b1dc41531ef 100644 --- a/source/blender/editors/object/object_constraint.c +++ b/source/blender/editors/object/object_constraint.c @@ -866,7 +866,7 @@ void CONSTRAINT_OT_move_down (wmOperatorType *ot) /* identifiers */ ot->name= "Move Constraint Down"; ot->idname= "CONSTRAINT_OT_move_down"; - ot->description= "Move constraint down constraint stack"; + ot->description= "Move constraint down in constraint stack"; /* callbacks */ ot->exec= constraint_move_down_exec; @@ -913,7 +913,7 @@ void CONSTRAINT_OT_move_up (wmOperatorType *ot) /* identifiers */ ot->name= "Move Constraint Up"; ot->idname= "CONSTRAINT_OT_move_up"; - ot->description= "Move constraint up constraint stack"; + ot->description= "Move constraint up in constraint stack"; /* callbacks */ ot->exec= constraint_move_up_exec; diff --git a/source/blender/makesrna/intern/rna_constraint.c b/source/blender/makesrna/intern/rna_constraint.c index d126f8543c6..a7f2761526e 100644 --- a/source/blender/makesrna/intern/rna_constraint.c +++ b/source/blender/makesrna/intern/rna_constraint.c @@ -1937,11 +1937,16 @@ void RNA_def_constraint(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Target Space", "Space that target is evaluated in"); /* flags */ + prop= RNA_def_property(srna, "enabled", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_negative_sdna(prop, NULL, "flag", CONSTRAINT_OFF); + RNA_def_property_ui_text(prop, "Enabled", "Enable/Disable Constraint"); + RNA_def_property_ui_icon(prop, ICON_CHECKBOX_DEHLT, 1); + prop= RNA_def_property(srna, "expanded", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", CONSTRAINT_EXPAND); RNA_def_property_ui_text(prop, "Expanded", "Constraint's panel is expanded in UI"); RNA_def_property_ui_icon(prop, ICON_TRIA_RIGHT, 1); - + // XXX this is really an internal flag, but it may be useful for some tools to be able to access this... prop= RNA_def_property(srna, "disabled", PROP_BOOLEAN, PROP_NONE); RNA_def_property_clear_flag(prop, PROP_EDITABLE); diff --git a/source/blender/makesrna/intern/rna_ui_api.c b/source/blender/makesrna/intern/rna_ui_api.c index 29d871dd66e..16864985289 100644 --- a/source/blender/makesrna/intern/rna_ui_api.c +++ b/source/blender/makesrna/intern/rna_ui_api.c @@ -317,6 +317,7 @@ void RNA_api_ui_layout(StructRNA *srna) RNA_def_property_flag(parm, PROP_REQUIRED|PROP_RNAPTR|PROP_NEVER_NULL); parm= RNA_def_pointer(func, "layout", "UILayout", "", "Sub-layout to put items in."); RNA_def_function_return(func, parm); + RNA_def_boolean(func, "compact", 0, "", "Show a smaller version of the template, split on two lines."); func= RNA_def_function(srna, "template_preview", "uiTemplatePreview"); parm= RNA_def_pointer(func, "id", "ID", "", "ID datablock."); |