From 828905190e12432228d88563e0dcb74054b488a9 Mon Sep 17 00:00:00 2001 From: Julian Eisel Date: Mon, 9 Sep 2019 16:34:16 +0200 Subject: 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 --- source/blender/editors/interface/interface_ops.c | 29 ++++++++++++++++++++++++ 1 file changed, 29 insertions(+) (limited to 'source/blender/editors/interface/interface_ops.c') 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 @@ -1589,6 +1589,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); -- cgit v1.2.3