Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJulian Eisel <eiseljulian@gmail.com>2016-09-19 03:25:59 +0300
committerJulian Eisel <eiseljulian@gmail.com>2016-09-19 03:41:10 +0300
commitc2d7d4764e86d8a133168ff8ea9aedbd78b5cd72 (patch)
tree421fef350fcdcbb8f0bc25f26390951cc9ee2121
parent976e591e93dd97de2c8f5be639a78c22e6505bae (diff)
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
-rw-r--r--source/blender/editors/include/UI_interface.h4
-rw-r--r--source/blender/editors/interface/interface.c6
-rw-r--r--source/blender/editors/interface/interface_handlers.c24
-rw-r--r--source/blender/editors/interface/interface_intern.h3
-rw-r--r--source/blender/editors/interface/interface_layout.c2
-rw-r--r--source/blender/editors/interface/interface_regions.c4
6 files changed, 14 insertions, 29 deletions
diff --git a/source/blender/editors/include/UI_interface.h b/source/blender/editors/include/UI_interface.h
index 26a6fdd7d1f..ad4066fb31c 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 6d4c8f0ab98..aca107013ac 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 5e9fc53de16..933beaf6afb 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 c274210e52a..418d98e8e4a 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 672bd74745d..976b5ed1193 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 8073fb3552f..b7f921624d9 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]) {