[Bf-blender-cvs] [354dbdde011] blender2.8: UI: hide toolbar text when narrow

Campbell Barton noreply at git.blender.org
Tue Apr 24 16:34:43 CEST 2018


Commit: 354dbdde0119122624a480ceab7daa164a637f0c
Author: Campbell Barton
Date:   Tue Apr 24 16:33:38 2018 +0200
Branches: blender2.8
https://developer.blender.org/rB354dbdde0119122624a480ceab7daa164a637f0c

UI: hide toolbar text when narrow

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

M	release/scripts/startup/bl_ui/space_toolsystem_common.py

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

diff --git a/release/scripts/startup/bl_ui/space_toolsystem_common.py b/release/scripts/startup/bl_ui/space_toolsystem_common.py
index 2e4bbc8674b..3d0a21b26d3 100644
--- a/release/scripts/startup/bl_ui/space_toolsystem_common.py
+++ b/release/scripts/startup/bl_ui/space_toolsystem_common.py
@@ -181,6 +181,15 @@ class ToolSelectPanelHelper:
 
         scale_y = 2.0
 
+        # TODO(campbell): expose ui_scale.
+        view2d = context.region.view2d
+        ui_scale = (
+            view2d.region_to_view(1.0, 0.0)[0] -
+            view2d.region_to_view(0.0, 0.0)[0]
+        )
+        show_text = (context.region.width / ui_scale) > 100.0
+        del view2d, ui_scale
+
         for tool_items in self.tools_from_context(context):
             if tool_items:
                 col = layout.column(align=True)
@@ -222,7 +231,7 @@ class ToolSelectPanelHelper:
                     if use_menu:
                         props = col.operator_menu_hold(
                             "wm.tool_set",
-                            text=item[0],
+                            text=item[0] if show_text else "",
                             depress=is_active,
                             menu="WM_MT_toolsystem_submenu",
                             icon_value=icon_value,
@@ -230,7 +239,7 @@ class ToolSelectPanelHelper:
                     else:
                         props = col.operator(
                             "wm.tool_set",
-                            text=item[0],
+                            text=item[0] if show_text else "",
                             depress=is_active,
                             icon_value=icon_value,
                         )



More information about the Bf-blender-cvs mailing list