Commit: c2d7d4764e86d8a133168ff8ea9aedbd78b5cd72 Author: Julian Eisel Date: Mon Sep 19 02:25:59 2016 +0200 Branches: master https://developer.blender.org/rBc2d7d4764e86d8a133168ff8ea9aedbd78b5cd72
Various cleanups related to button locking * Rename uiBut.lockstr to disabled_info * Remove unreachable code * Replace duplicated check with assert * Replace overly ambitious check with assert * Add comments =================================================================== M source/blender/editors/include/UI_interface.h M source/blender/editors/interface/interface.c M source/blender/editors/interface/interface_handlers.c M source/blender/editors/interface/interface_intern.h M source/blender/editors/interface/interface_layout.c M source/blender/editors/interface/interface_regions.c =================================================================== diff --git a/source/blender/editors/include/UI_interface.h b/source/blender/editors/include/UI_interface.h index 26a6fdd..ad4066f 100644 --- a/source/blender/editors/include/UI_interface.h +++ b/source/blender/editors/include/UI_interface.h @@ -161,13 +161,13 @@ enum { UI_BUT_NODE_LINK = (1 << 8), UI_BUT_NODE_ACTIVE = (1 << 9), UI_BUT_DRAG_LOCK = (1 << 10), - UI_BUT_DISABLED = (1 << 11), + UI_BUT_DISABLED = (1 << 11), /* grayed out and uneditable */ UI_BUT_COLOR_LOCK = (1 << 12), UI_BUT_ANIMATED = (1 << 13), UI_BUT_ANIMATED_KEY = (1 << 14), UI_BUT_DRIVEN = (1 << 15), UI_BUT_REDALERT = (1 << 16), - UI_BUT_INACTIVE = (1 << 17), + UI_BUT_INACTIVE = (1 << 17), /* grayed out but still editable */ UI_BUT_LAST_ACTIVE = (1 << 18), UI_BUT_UNDO = (1 << 19), UI_BUT_IMMEDIATE = (1 << 20), diff --git a/source/blender/editors/interface/interface.c b/source/blender/editors/interface/interface.c index 6d4c8f0..aca1070 100644 --- a/source/blender/editors/interface/interface.c +++ b/source/blender/editors/interface/interface.c @@ -3121,7 +3121,7 @@ static uiBut *ui_def_but( but->a2 = a2; but->tip = tip; - but->lockstr = block->lockstr; + but->disabled_info = block->lockstr; but->dt = block->dt; but->pie_dir = UI_RADIAL_NONE; @@ -3218,7 +3218,7 @@ void ui_def_but_icon(uiBut *but, const int icon, const int flag) static void ui_def_but_rna__disable(uiBut *but) { but->flag |= UI_BUT_DISABLED; - but->lockstr = ""; + but->disabled_info = ""; } static void ui_def_but_rna__menu(bContext *UNUSED(C), uiLayout *layout, void *but_p) @@ -3543,7 +3543,7 @@ static uiBut *ui_def_but_operator_ptr(uiBlock *block, int type, wmOperatorType * if (!ot) { but->flag |= UI_BUT_DISABLED; - but->lockstr = ""; + but->disabled_info = ""; } return but; diff --git a/source/blender/editors/interface/interface_handlers.c b/source/blender/editors/interface/interface_handlers.c index 5e9fc53..933beaf 100644 --- a/source/blender/editors/interface/interface_handlers.c +++ b/source/blender/editors/interface/interface_handlers.c @@ -2248,9 +2248,7 @@ static void ui_but_copy_paste(bContext *C, uiBut *but, uiHandleButtonData *data, bool buf_paste_alloc = false; bool show_report = false; /* use to display errors parsing paste input */ - if (mode == 'v' && (but->flag & UI_BUT_DISABLED)) { - return; - } + BLI_assert((but->flag & UI_BUT_DISABLED) == 0); /* caller should check */ if (mode == 'c') { /* disallow copying from any passwords */ @@ -6974,6 +6972,9 @@ static int ui_do_button(bContext *C, uiBlock *block, uiBut *but, const wmEvent * if (but->flag & UI_BUT_DISABLED) return WM_UI_HANDLER_CONTINUE; + /* if but->pointype is set, but->poin should be too */ + BLI_assert(!but->pointype || but->poin); + if ((data->state == BUTTON_STATE_HIGHLIGHT) || (event->type == EVT_DROP)) { /* handle copy-paste */ if (ELEM(event->type, CKEY, VKEY) && event->val == KM_PRESS && @@ -7098,23 +7099,6 @@ static int ui_do_button(bContext *C, uiBlock *block, uiBut *but, const wmEvent * } } - /* verify if we can edit this button */ - if (ELEM(event->type, LEFTMOUSE, RETKEY)) { - if (but->flag & UI_BUT_DISABLED) { - if (but->lockstr) { - WM_report(RPT_INFO, but->lockstr); - button_activate_state(C, but, BUTTON_STATE_EXIT); - return WM_UI_HANDLER_BREAK; - } - } - else if (but->pointype && but->poin == NULL) { - /* there's a pointer needed */ - BKE_reportf(NULL, RPT_WARNING, "DoButton pointer error: %s", but->str); - button_activate_state(C, but, BUTTON_STATE_EXIT); - return WM_UI_HANDLER_BREAK; - } - } - switch (but->type) { case UI_BTYPE_BUT: retval = ui_do_but_BUT(C, but, data, event); diff --git a/source/blender/editors/interface/interface_intern.h b/source/blender/editors/interface/interface_intern.h index c274210..418d98e 100644 --- a/source/blender/editors/interface/interface_intern.h +++ b/source/blender/editors/interface/interface_intern.h @@ -271,7 +271,8 @@ struct uiBut { uiButToolTipFunc tip_func; void *tip_argN; - const char *lockstr; + /* info on why button is disabled, displayed in tooltip */ + const char *disabled_info; BIFIconID icon; char dt; /* drawtype: UI_EMBOSS, UI_EMBOSS_NONE ... etc, copied from the block */ diff --git a/source/blender/editors/interface/interface_layout.c b/source/blender/editors/interface/interface_layout.c index 672bd74..976b5ed 100644 --- a/source/blender/editors/interface/interface_layout.c +++ b/source/blender/editors/interface/interface_layout.c @@ -745,7 +745,7 @@ static void ui_item_disabled(uiLayout *layout, const char *name) but = uiDefBut(block, UI_BTYPE_LABEL, 0, name, 0, 0, w, UI_UNIT_Y, NULL, 0.0, 0.0, 0, 0, ""); but->flag |= UI_BUT_DISABLED; - but->lockstr = ""; + but->disabled_info = ""; } /* operator items */ diff --git a/source/blender/editors/interface/interface_regions.c b/source/blender/editors/interface/interface_regions.c index 8073fb3..b7f9216 100644 --- a/source/blender/editors/interface/interface_regions.c +++ b/source/blender/editors/interface/interface_regions.c @@ -466,8 +466,8 @@ static uiTooltipData *ui_tooltip_data_from_button(bContext *C, uiBut *but) disabled_msg = CTX_wm_operator_poll_msg_get(C); } /* alternatively, buttons can store some reasoning too */ - else if (but->lockstr) { - disabled_msg = but->lockstr; + else if (but->disabled_info) { + disabled_msg = but->disabled_info; } if (disabled_msg && disabled_msg[0]) { _______________________________________________ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org https://lists.blender.org/mailman/listinfo/bf-blender-cvs