UI: use regular size icons for toolbar popup
authorCampbell Barton <ideasman42@gmail.com>
Wed, 6 Jun 2018 06:31:31 +0000 (08:31 +0200)
committerCampbell Barton <ideasman42@gmail.com>
Wed, 6 Jun 2018 06:32:25 +0000 (08:32 +0200)
Test this since the popup feels disruptive/flashing when its too large
when set smaller it looks closer to a menu w/ key-accelerators which is
the intention in this case.

It's also more likely the active tool can be placed under the cursor.

release/scripts/startup/bl_operators/wm.py
release/scripts/startup/bl_ui/space_toolsystem_common.py
source/blender/editors/interface/interface_widgets.c

index ee101bb3cc6e1d3ed398dd7c943f1d50a3466a67..e62a1f071a95c8e77a50a3c23eacfe988bd5dcd2 100644 (file)
@@ -2394,7 +2394,7 @@ class WM_OT_toolbar(Operator):
 
         def draw_menu(popover, context):
             layout = popover.layout
-            cls.draw_cls(layout, context, detect_layout=False)
+            cls.draw_cls(layout, context, detect_layout=False, scale_y=1.0)
 
         wm.popover(draw_menu, keymap=keymap)
         return {'FINISHED'}
index a909dad1ff3a8100cb0ab1d77080bacfbc55b70e..2b9d420727282b697c89244077f04df442ecdf16 100644 (file)
@@ -339,9 +339,7 @@ class ToolSelectPanelHelper:
     # - None: Signal to finish (complete any final operations, e.g. add padding).
 
     @staticmethod
-    def _layout_generator_single_column(layout):
-        scale_y = 2.0
-
+    def _layout_generator_single_column(layout, scale_y):
         col = layout.column(align=True)
         col.scale_y = scale_y
         is_sep = False
@@ -355,9 +353,8 @@ class ToolSelectPanelHelper:
             is_sep = yield col
 
     @staticmethod
-    def _layout_generator_multi_columns(layout, column_count):
-        scale_y = 2.0
-        scale_x = 2.2
+    def _layout_generator_multi_columns(layout, column_count, scale_y):
+        scale_x = scale_y * 1.1
         column_last = column_count - 1
 
         col = layout.column(align=True)
@@ -394,7 +391,7 @@ class ToolSelectPanelHelper:
             column_index += 1
 
     @staticmethod
-    def _layout_generator_detect_from_region(layout, region):
+    def _layout_generator_detect_from_region(layout, region, scale_y):
         """
         Choose an appropriate layout for the toolbar.
         """
@@ -421,14 +418,14 @@ class ToolSelectPanelHelper:
                 column_count = 1
 
         if column_count == 1:
-            ui_gen = ToolSelectPanelHelper._layout_generator_single_column(layout)
+            ui_gen = ToolSelectPanelHelper._layout_generator_single_column(layout, scale_y=scale_y)
         else:
-            ui_gen = ToolSelectPanelHelper._layout_generator_multi_columns(layout, column_count=column_count)
+            ui_gen = ToolSelectPanelHelper._layout_generator_multi_columns(layout, column_count=column_count, scale_y=scale_y)
 
         return ui_gen, show_text
 
     @classmethod
-    def draw_cls(cls, layout, context, detect_layout=True):
+    def draw_cls(cls, layout, context, detect_layout=True, scale_y=2.0):
         # Use a classmethod so it can be called outside of a panel context.
 
         # XXX, this UI isn't very nice.
@@ -444,9 +441,9 @@ class ToolSelectPanelHelper:
         )
 
         if detect_layout:
-            ui_gen, show_text = cls._layout_generator_detect_from_region(layout, context.region)
+            ui_gen, show_text = cls._layout_generator_detect_from_region(layout, context.region, scale_y)
         else:
-            ui_gen = ToolSelectPanelHelper._layout_generator_single_column(layout)
+            ui_gen = ToolSelectPanelHelper._layout_generator_single_column(layout, scale_y)
             show_text = True
 
         # Start iteration
index 928ac8c91716c6f06ad72f01d8506c76df12d973..b20fe3c62dd6fc4fe8e38e4d33b0fbdc1d872b46 100644 (file)
@@ -2008,6 +2008,15 @@ static void widget_draw_text_icon(uiFontStyle *fstyle, uiWidgetColors *wcol, uiB
        else if (but->flag & UI_HAS_ICON || show_menu_icon) {
                const bool is_tool = UI_but_is_tool(but);
 
+               /* XXX add way to draw icons at a different size!
+                * Use small icons for popup. */
+#ifdef USE_TOOLBAR_HACK
+               const float aspect_orig = but->block->aspect;
+               if (is_tool && (but->block->flag & UI_BLOCK_POPOVER)) {
+                       but->block->aspect *= 2.0f;
+               }
+#endif
+               
                const BIFIconID icon = (but->flag & UI_HAS_ICON) ? but->icon + but->iconadd : ICON_NONE;
                int icon_size_init = is_tool ? ICON_DEFAULT_HEIGHT_TOOLBAR : ICON_DEFAULT_HEIGHT;
                const float icon_size = icon_size_init / (but->block->aspect / UI_DPI_FAC);
@@ -2031,9 +2040,13 @@ static void widget_draw_text_icon(uiFontStyle *fstyle, uiWidgetColors *wcol, uiB
                }
                else if (ui_block_is_menu(but->block))
                        rect->xmin += 0.3f * U.widget_unit;
-
+               
                widget_draw_icon(but, icon, alpha, rect, show_menu_icon);
 
+#ifdef USE_TOOLBAR_HACK
+               but->block->aspect = aspect_orig;
+#endif
+               
                rect->xmin += icon_size;
                /* without this menu keybindings will overlap the arrow icon [#38083] */
                if (show_menu_icon) {