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:
authorCampbell Barton <ideasman42@gmail.com>2018-06-06 09:31:31 +0300
committerCampbell Barton <ideasman42@gmail.com>2018-06-06 09:32:25 +0300
commit1889eec918196527aaa7deb3064129e448568d06 (patch)
treed150568d1529d8abac587a104252c5b85f9c276d
parentc1a880bc5e919da044f6c9599cec4653f88c29d9 (diff)
UI: use regular size icons for toolbar popup
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.
-rw-r--r--release/scripts/startup/bl_operators/wm.py2
-rw-r--r--release/scripts/startup/bl_ui/space_toolsystem_common.py21
-rw-r--r--source/blender/editors/interface/interface_widgets.c15
3 files changed, 24 insertions, 14 deletions
diff --git a/release/scripts/startup/bl_operators/wm.py b/release/scripts/startup/bl_operators/wm.py
index ee101bb3cc6..e62a1f071a9 100644
--- a/release/scripts/startup/bl_operators/wm.py
+++ b/release/scripts/startup/bl_operators/wm.py
@@ -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'}
diff --git a/release/scripts/startup/bl_ui/space_toolsystem_common.py b/release/scripts/startup/bl_ui/space_toolsystem_common.py
index a909dad1ff3..2b9d4207272 100644
--- a/release/scripts/startup/bl_ui/space_toolsystem_common.py
+++ b/release/scripts/startup/bl_ui/space_toolsystem_common.py
@@ -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
diff --git a/source/blender/editors/interface/interface_widgets.c b/source/blender/editors/interface/interface_widgets.c
index 928ac8c9171..b20fe3c62dd 100644
--- a/source/blender/editors/interface/interface_widgets.c
+++ b/source/blender/editors/interface/interface_widgets.c
@@ -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) {