From ce94f52dbc1f18b805436313d26cdcef804622e9 Mon Sep 17 00:00:00 2001 From: Thomas Dinges Date: Sun, 4 Jul 2010 09:42:00 +0000 Subject: Fix for [#22714] Constraints stack : move up and move down buttons problem * Constraint template now uses 2 rows as well, when the area width is small. * UI Code could use some code/layout cleanup still, will look into that soon. --- source/blender/editors/include/UI_interface.h | 2 +- .../editors/interface/interface_templates.c | 46 ++++++++++++++-------- source/blender/editors/object/object_constraint.c | 4 +- 3 files changed, 32 insertions(+), 20 deletions(-) (limited to 'source/blender/editors') 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; -- cgit v1.2.3