UI: Improve Modifier Panel Header Menu

This makes a few changes to the modifier panel header:
  1. Adds "move to top" and "move to bottom" buttons.
  2. Adds a checkmark icon for "apply"
  3. Makes it narrower, the text is closer to the dropdown icon.
     (Requires the change in ui_block_func_POPUP)

Differential Revision: https://developer.blender.org/D8040
This commit is contained in:
Hans Goudey
2020-06-17 14:09:17 -04:00
parent 4cfdd10c2b
commit bcb2b8ab57
2 changed files with 57 additions and 4 deletions

View File

@@ -184,7 +184,12 @@ static uiBlock *ui_block_func_POPUP(bContext *C, uiPopupBlockHandle *handle, voi
pup->block->handle = NULL;
}
if (pup->but) {
/* Find block minimum width. */
if (uiLayoutGetUnitsX(pup->layout) != 0.0f) {
/* Use the minimum width from the layout if it's set. */
minwidth = uiLayoutGetUnitsX(pup->layout) * UI_UNIT_X;
}
else if (pup->but) {
/* minimum width to enforece */
if (pup->but->drawstr[0]) {
minwidth = BLI_rctf_size_x(&pup->but->rect);
@@ -193,7 +198,13 @@ static uiBlock *ui_block_func_POPUP(bContext *C, uiPopupBlockHandle *handle, voi
/* For buttons with no text, use the minimum (typically icon only). */
minwidth = UI_MENU_WIDTH_MIN;
}
}
else {
minwidth = UI_MENU_WIDTH_MIN;
}
/* Find block direction. */
if (pup->but) {
if (pup->block->direction != 0) {
/* allow overriding the direction from menu_func */
direction = pup->block->direction;
@@ -203,7 +214,6 @@ static uiBlock *ui_block_func_POPUP(bContext *C, uiPopupBlockHandle *handle, voi
}
}
else {
minwidth = UI_MENU_WIDTH_MIN;
direction = UI_DIR_DOWN;
}

View File

@@ -222,19 +222,29 @@ static bool modifier_can_delete(ModifierData *md)
return true;
}
static void modifier_ops_extra_draw(bContext *UNUSED(C), uiLayout *layout, void *md_v)
static void modifier_ops_extra_draw(bContext *C, uiLayout *layout, void *md_v)
{
PointerRNA op_ptr;
uiLayout *row;
ModifierData *md = (ModifierData *)md_v;
PointerRNA ptr;
Object *ob = get_modifier_object(C);
RNA_pointer_create(&ob->id, &RNA_Modifier, md, &ptr);
uiLayoutSetContextPointer(layout, "modifier", &ptr);
uiLayoutSetOperatorContext(layout, WM_OP_INVOKE_DEFAULT);
uiLayoutSetUnitsX(layout, 4.0f);
/* Apply. */
uiItemEnumO(layout,
"OBJECT_OT_modifier_apply",
CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Apply"),
0,
ICON_CHECKMARK,
"apply_as",
MODIFIER_APPLY_DATA);
/* Apply as shapekey. */
if (BKE_modifier_is_same_topology(md) && !BKE_modifier_is_non_geometrical(md)) {
uiItemEnumO(layout,
"OBJECT_OT_modifier_apply",
@@ -244,6 +254,7 @@ static void modifier_ops_extra_draw(bContext *UNUSED(C), uiLayout *layout, void
MODIFIER_APPLY_SHAPE);
}
/* Duplicate. */
if (!ELEM(md->type,
eModifierType_Fluidsim,
eModifierType_Softbody,
@@ -255,6 +266,38 @@ static void modifier_ops_extra_draw(bContext *UNUSED(C), uiLayout *layout, void
ICON_DUPLICATE,
"OBJECT_OT_modifier_copy");
}
uiItemS(layout);
/* Move to first. */
row = uiLayoutColumn(layout, false);
uiItemFullO(row,
"OBJECT_OT_modifier_move_to_index",
IFACE_("Move to First"),
ICON_TRIA_UP,
NULL,
WM_OP_EXEC_DEFAULT,
0,
&op_ptr);
RNA_int_set(&op_ptr, "index", 0);
if (!md->prev) {
uiLayoutSetEnabled(row, false);
}
/* Move to last. */
row = uiLayoutColumn(layout, false);
uiItemFullO(row,
"OBJECT_OT_modifier_move_to_index",
IFACE_("Move to Last"),
ICON_TRIA_DOWN,
NULL,
WM_OP_EXEC_DEFAULT,
0,
&op_ptr);
RNA_int_set(&op_ptr, "index", BLI_listbase_count(&ob->modifiers) - 1);
if (!md->next) {
uiLayoutSetEnabled(row, false);
}
}
static void modifier_panel_header(const bContext *C, Panel *panel)