[Bf-blender-cvs] [d6ca724a0e5] topbar: Refactor operator settings drawing to support operator-macros
Julian Eisel
noreply at git.blender.org
Fri Oct 27 17:14:38 CEST 2017
Commit: d6ca724a0e57791d969e55f057c76ecfc565d184
Author: Julian Eisel
Date: Fri Oct 27 17:13:11 2017 +0200
Branches: topbar
https://developer.blender.org/rBd6ca724a0e57791d969e55f057c76ecfc565d184
Refactor operator settings drawing to support operator-macros
Settings of operator-macros wouldn't be shown in the top-bar.
===================================================================
M source/blender/editors/include/UI_interface.h
M source/blender/editors/interface/interface_templates.c
===================================================================
diff --git a/source/blender/editors/include/UI_interface.h b/source/blender/editors/include/UI_interface.h
index 580be265b22..21b5bc33833 100644
--- a/source/blender/editors/include/UI_interface.h
+++ b/source/blender/editors/include/UI_interface.h
@@ -840,14 +840,10 @@ void UI_exit(void);
/* uiLayoutOperatorButs flags */
enum {
UI_TEMPLATE_OP_PROPS_SHOW_TITLE = (1 << 0),
- UI_TEMPLATE_OP_PROPS_SHOW_REDO_BUT = (UI_TEMPLATE_OP_PROPS_SHOW_TITLE | (1 << 1)),
- UI_TEMPLATE_OP_PROPS_SHOW_EMPTY = (1 << 2),
- UI_TEMPLATE_OP_PROPS_COMPACT = (1 << 3),
- /* Don't show the "Redo Unsupported" label */
- UI_TEMPLATE_OP_PROPS_HIDE_UNSUPPORTED = (1 << 4),
- /* Only show non-advanced op-properties by default and add a "More" button invoking
- * redo popup with all properties. If all properties are advanced, show the first 2. */
- UI_TEMPLATE_OP_PROPS_SPLIT_ADVANCED = (1 << 5),
+ UI_TEMPLATE_OP_PROPS_SHOW_EMPTY = (1 << 1),
+ UI_TEMPLATE_OP_PROPS_COMPACT = (1 << 2),
+ /* Don't show advanced properties */
+ UI_TEMPLATE_OP_PROPS_SKIP_ADVANCED = (1 << 3),
};
/* used for transp checkers */
diff --git a/source/blender/editors/interface/interface_templates.c b/source/blender/editors/interface/interface_templates.c
index 863752d78e7..e99c38b7dbb 100644
--- a/source/blender/editors/interface/interface_templates.c
+++ b/source/blender/editors/interface/interface_templates.c
@@ -1411,16 +1411,38 @@ uiLayout *uiTemplateModifier(uiLayout *layout, bContext *C, PointerRNA *ptr)
/************************ Redo Buttons Template *************************/
+static void template_operator_redo_property_buts_draw(
+ const bContext *C, wmOperator *op,
+ uiLayout *layout, int layout_flags)
+{
+ 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);
+ }
+ }
+ else {
+ uiTemplateOperatorPropertyButs(C, layout, op, NULL, '\0', layout_flags);
+ }
+}
+
void uiTemplateOperatorRedo(uiLayout *layout, bContext *C)
{
wmOperator *op = WM_operator_last_redo(C);
+ uiBlock *block = uiLayoutGetBlock(layout);
+ const int layout_flags = (UI_TEMPLATE_OP_PROPS_COMPACT | UI_TEMPLATE_OP_PROPS_SKIP_ADVANCED);
if (op) {
- uiBlock *block = uiLayoutGetBlock(layout);
- int layout_flags = (UI_TEMPLATE_OP_PROPS_SHOW_REDO_BUT | UI_TEMPLATE_OP_PROPS_COMPACT |
- UI_TEMPLATE_OP_PROPS_HIDE_UNSUPPORTED | UI_TEMPLATE_OP_PROPS_SPLIT_ADVANCED);
+ /* 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);
+
+ template_operator_redo_property_buts_draw(C, op, layout, layout_flags);
+
+ /* TODO check whether there are hidden advanced properties at all */
+ if (WM_operator_repeat_check(C, op)) {
+ uiItemO(layout, IFACE_("More..."), ICON_NONE, "SCREEN_OT_redo_last");
+ }
- uiTemplateOperatorPropertyButs(C, layout, op, NULL, '\0', layout_flags);
UI_block_func_handle_set(block, ED_undo_operator_repeat_cb_evt, op);
}
}
@@ -3784,24 +3806,14 @@ void uiTemplateOperatorPropertyButs(
const char label_align, const short flag)
{
uiBlock *block = uiLayoutGetBlock(layout);
- const char *op_title = RNA_struct_ui_name(op->type->srna);
- bool can_repeat;
if (!op->properties) {
IDPropertyTemplate val = {0};
op->properties = IDP_New(IDP_GROUP, &val, "wmOperatorProperties");
}
- can_repeat = WM_operator_repeat_check(C, op);
- if (!can_repeat && (flag & UI_TEMPLATE_OP_PROPS_HIDE_UNSUPPORTED)) {
- return;
- }
-
- if ((flag & UI_TEMPLATE_OP_PROPS_SHOW_REDO_BUT) == UI_TEMPLATE_OP_PROPS_SHOW_REDO_BUT) {
- uiItemFullO(layout, "SCREEN_OT_repeat_last", op_title, ICON_NONE, NULL, WM_OP_INVOKE_DEFAULT, 0);
- }
- else if (flag & UI_TEMPLATE_OP_PROPS_SHOW_TITLE) {
- uiItemL(layout, op_title, ICON_NONE);
+ if (flag & UI_TEMPLATE_OP_PROPS_SHOW_TITLE) {
+ uiItemL(layout, RNA_struct_ui_name(op->type->srna), ICON_NONE);
}
/* poll() on this operator may still fail, at the moment there is no nice feedback when this happens
@@ -3895,10 +3907,6 @@ void uiTemplateOperatorPropertyButs(
}
}
}
-
- if (flag & UI_TEMPLATE_OP_PROPS_SPLIT_ADVANCED) {
- uiItemO(layout, IFACE_("More..."), ICON_NONE, "SCREEN_OT_redo_last");
- }
}
/************************* Running Jobs Template **************************/
More information about the Bf-blender-cvs
mailing list