[Bf-extensions-cvs] [9159fac] master: Support new UserPreferencesView.ui_scale property

raa noreply at git.blender.org
Tue Mar 28 16:59:58 CEST 2017


Commit: 9159fac1f5a9f4f29a625feea16b9824a33c59ce
Author: raa
Date:   Tue Mar 28 17:59:42 2017 +0300
Branches: master
https://developer.blender.org/rBA9159fac1f5a9f4f29a625feea16b9824a33c59ce

Support new UserPreferencesView.ui_scale property

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

M	development_icon_get.py

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

diff --git a/development_icon_get.py b/development_icon_get.py
index 020acd6..c467dfd 100644
--- a/development_icon_get.py
+++ b/development_icon_get.py
@@ -23,7 +23,7 @@ bl_info = {
     "name": "Icon Viewer",
     "description": "Click an icon to copy its name to the clipboard",
     "author": "roaoao",
-    "version": (1, 3, 1),
+    "version": (1, 3, 2),
     "blender": (2, 75, 0),
     "location": "Spacebar > Icon Viewer, Text Editor > Properties",
     "wiki_url": (
@@ -44,6 +44,9 @@ HISTORY = []
 
 
 def ui_scale():
+    if hasattr(bpy.context.user_preferences.view, "ui_scale"):
+        return bpy.context.user_preferences.view.ui_scale
+
     ret = bpy.context.user_preferences.system.dpi / DPI
     if bpy.context.user_preferences.system.virtual_pixel_mode == 'DOUBLE':
         ret *= 2
@@ -195,10 +198,10 @@ class IV_Preferences(bpy.types.AddonPreferences):
         description="Auto focus input field", default=True)
     show_panel = bpy.props.BoolProperty(
         name="Show Panel",
-        description="Show the panel in Text Editor", default=True)
+        description="Show the panel in the Text Editor", default=True)
     show_header = bpy.props.BoolProperty(
         name="Show Header",
-        description="Show the header in Python Console",
+        description="Show the header in the Python Console",
         default=True)
 
     def draw(self, context):
@@ -421,14 +424,16 @@ class IV_OT_icons_show(bpy.types.Operator):
         col = self.layout
         self.draw_header(col)
 
+        history_num_cols = int(
+            (self.width - POPUP_PADDING) / (ui_scale() * ICON_SIZE))
         num_cols = min(
             self.get_num_cols(len(pr.popup_icons.filtered_icons)),
-            int((self.width - POPUP_PADDING) / (ui_scale() * ICON_SIZE)))
+            history_num_cols)
 
         subcol = col.column(True)
 
         if HISTORY and pr.show_history:
-            pr.popup_icons.draw(subcol.box(), num_cols, HISTORY)
+            pr.popup_icons.draw(subcol.box(), history_num_cols, HISTORY)
 
         pr.popup_icons.draw(subcol.box(), num_cols)
 
@@ -472,8 +477,14 @@ class IV_OT_icons_show(bpy.types.Operator):
 
 
 def register():
+    if bpy.app.background:
+        return
+
     bpy.utils.register_module(__name__)
 
 
 def unregister():
+    if bpy.app.background:
+        return
+
     bpy.utils.unregister_module(__name__)



More information about the Bf-extensions-cvs mailing list