[Bf-blender-cvs] [9d528381b55] master: UI: Support interacting with superimposed icons while editing

Julian Eisel noreply at git.blender.org
Fri Sep 18 20:39:17 CEST 2020


Commit: 9d528381b552c37d53126f997c5e61979c3b20ba
Author: Julian Eisel
Date:   Fri Sep 18 20:26:02 2020 +0200
Branches: master
https://developer.blender.org/rB9d528381b552c37d53126f997c5e61979c3b20ba

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.

===================================================================

M	source/blender/editors/interface/interface_handlers.c

===================================================================

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,



More information about the Bf-blender-cvs mailing list