diff options
author | Julian Eisel <eiseljulian@gmail.com> | 2019-09-09 17:34:16 +0300 |
---|---|---|
committer | Julian Eisel <eiseljulian@gmail.com> | 2019-09-09 17:37:47 +0300 |
commit | 828905190e12432228d88563e0dcb74054b488a9 (patch) | |
tree | f75e765cdbc5b31ca0b88eff0bf5c3b886b29682 /source/blender/editors/interface/interface_ops.c | |
parent | 9b6233b27ceda18e6c3f582259b9da6a3207aa2d (diff) |
UI: Refactor and improve buttton extra icons
Without this patch there could only be one superimposed icon
and the operators were hard coded for the button types.
This keeps the previous, sort of predefined extra icons working in a
rather generic way, but allows adding specific ones for specific case
through `UI_but_extra_operator_icon_set()`.
Reviewed by: Campbell Barton
Differential Revision: https://developer.blender.org/D5730
Diffstat (limited to 'source/blender/editors/interface/interface_ops.c')
-rw-r--r-- | source/blender/editors/interface/interface_ops.c | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/source/blender/editors/interface/interface_ops.c b/source/blender/editors/interface/interface_ops.c index 68d21e88211..b3c46dda4c3 100644 --- a/source/blender/editors/interface/interface_ops.c +++ b/source/blender/editors/interface/interface_ops.c @@ -1590,6 +1590,34 @@ static void UI_OT_button_execute(wmOperatorType *ot) /** \} */ /* -------------------------------------------------------------------- */ +/** \name Text Button Clear Operator + * \{ */ + +static int button_string_clear_exec(bContext *C, wmOperator *UNUSED(op)) +{ + uiBut *but = UI_context_active_but_get(C); + + if (but) { + ui_but_active_string_clear_and_exit(C, but); + } + + return OPERATOR_FINISHED; +} + +static void UI_OT_button_string_clear(wmOperatorType *ot) +{ + ot->name = "Clear Button String"; + ot->idname = "UI_OT_button_string_clear"; + ot->description = "Unsets the text of the active button"; + + ot->poll = ED_operator_regionactive; + ot->exec = button_string_clear_exec; + ot->flag = OPTYPE_UNDO | OPTYPE_INTERNAL; +} + +/** \} */ + +/* -------------------------------------------------------------------- */ /** \name Drop Color Operator * \{ */ @@ -1714,6 +1742,7 @@ void ED_operatortypes_ui(void) #endif WM_operatortype_append(UI_OT_reloadtranslation); WM_operatortype_append(UI_OT_button_execute); + WM_operatortype_append(UI_OT_button_string_clear); /* external */ WM_operatortype_append(UI_OT_eyedropper_color); |