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 <julian@blender.org>2020-09-18 21:26:02 +0300
committerJulian Eisel <julian@blender.org>2020-09-18 21:38:45 +0300
commit9d528381b552c37d53126f997c5e61979c3b20ba (patch)
treef08ce1523cf495c8799b48ff1e1c0867946971d5 /source/blender/editors/interface
parentaacf8d75f5cbf8db5ac6feec7e49eac7c296ad96 (diff)
UI: Support interacting with superimposed icons while editing
For example you can now start entering text in the Properties or Outliner search, and press the 'x' while the button is still in text-edit mode. This way you don't have to exit text editing first, before being able to quickly clear the string with a mouse click. So this is a small improvement for convenience. It also works for the eyedropper (change to picking an object while text editing) or the '+' and '-' icons in the file saving dialog.
Diffstat (limited to 'source/blender/editors/interface')
-rw-r--r--source/blender/editors/interface/interface_handlers.c36
1 files changed, 30 insertions, 6 deletions
diff --git a/source/blender/editors/interface/interface_handlers.c b/source/blender/editors/interface/interface_handlers.c
index a5e275c27b5..cd78b61b8c5 100644
--- a/source/blender/editors/interface/interface_handlers.c
+++ b/source/blender/editors/interface/interface_handlers.c
@@ -469,6 +469,13 @@ static void ui_handle_button_activate(bContext *C,
ARegion *region,
uiBut *but,
uiButtonActivateType type);
+static bool ui_do_but_extra_operator_icon(bContext *C,
+ uiBut *but,
+ uiHandleButtonData *data,
+ const wmEvent *event);
+static void ui_do_but_extra_operator_icons_mousemove(uiBut *but,
+ uiHandleButtonData *data,
+ const wmEvent *event);
#ifdef USE_DRAG_MULTINUM
static void ui_multibut_restore(bContext *C, uiHandleButtonData *data, uiBlock *block);
@@ -3517,6 +3524,7 @@ static void ui_do_but_textedit(
ui_searchbox_event(C, data->searchbox, but, data->region, event);
#endif
}
+ ui_do_but_extra_operator_icons_mousemove(but, data, event);
break;
case RIGHTMOUSE:
@@ -3545,6 +3553,11 @@ static void ui_do_but_textedit(
}
break;
case LEFTMOUSE: {
+ /* Allow clicks on extra icons while editing. */
+ if (ui_do_but_extra_operator_icon(C, but, data, event)) {
+ break;
+ }
+
const bool had_selection = but->selsta != but->selend;
/* exit on LMB only on RELEASE for searchbox, to mimic other popups,
@@ -3993,6 +4006,10 @@ static void ui_numedit_apply(bContext *C, uiBlock *block, uiBut *but, uiHandleBu
static void ui_but_extra_operator_icon_apply(bContext *C, uiBut *but, uiButExtraOpIcon *op_icon)
{
+ if (but->active->interactive) {
+ ui_apply_but(C, but->block, but, but->active, true);
+ }
+ button_activate_state(C, but, BUTTON_STATE_EXIT);
WM_operator_name_call_ptr(C,
op_icon->optype_params->optype,
op_icon->optype_params->opcontext,
@@ -4182,16 +4199,23 @@ static bool ui_do_but_extra_operator_icon(bContext *C,
{
uiButExtraOpIcon *op_icon = ui_but_extra_operator_icon_mouse_over_get(but, data, event);
- if (op_icon) {
- ED_region_tag_redraw(data->region);
- button_tooltip_timer_reset(C, but);
+ if (!op_icon) {
+ return false;
+ }
- ui_but_extra_operator_icon_apply(C, but, op_icon);
- /* Note: 'but', 'data' may now be freed, don't access. */
+ /* Only act on release, avoids some glitches. */
+ if (event->val != KM_RELEASE) {
+ /* Still swallow events on the icon. */
return true;
}
- return false;
+ ED_region_tag_redraw(data->region);
+ button_tooltip_timer_reset(C, but);
+
+ ui_but_extra_operator_icon_apply(C, but, op_icon);
+ /* Note: 'but', 'data' may now be freed, don't access. */
+
+ return true;
}
static void ui_do_but_extra_operator_icons_mousemove(uiBut *but,