Skip to content
Snippets Groups Projects
Commit 9159fac1 authored by raa's avatar raa
Browse files

Support new UserPreferencesView.ui_scale property

parent 6448cdbc
No related branches found
No related tags found
No related merge requests found
...@@ -23,7 +23,7 @@ bl_info = { ...@@ -23,7 +23,7 @@ bl_info = {
"name": "Icon Viewer", "name": "Icon Viewer",
"description": "Click an icon to copy its name to the clipboard", "description": "Click an icon to copy its name to the clipboard",
"author": "roaoao", "author": "roaoao",
"version": (1, 3, 1), "version": (1, 3, 2),
"blender": (2, 75, 0), "blender": (2, 75, 0),
"location": "Spacebar > Icon Viewer, Text Editor > Properties", "location": "Spacebar > Icon Viewer, Text Editor > Properties",
"wiki_url": ( "wiki_url": (
...@@ -44,6 +44,9 @@ HISTORY = [] ...@@ -44,6 +44,9 @@ HISTORY = []
def ui_scale(): 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 ret = bpy.context.user_preferences.system.dpi / DPI
if bpy.context.user_preferences.system.virtual_pixel_mode == 'DOUBLE': if bpy.context.user_preferences.system.virtual_pixel_mode == 'DOUBLE':
ret *= 2 ret *= 2
...@@ -195,10 +198,10 @@ class IV_Preferences(bpy.types.AddonPreferences): ...@@ -195,10 +198,10 @@ class IV_Preferences(bpy.types.AddonPreferences):
description="Auto focus input field", default=True) description="Auto focus input field", default=True)
show_panel = bpy.props.BoolProperty( show_panel = bpy.props.BoolProperty(
name="Show Panel", 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( show_header = bpy.props.BoolProperty(
name="Show Header", name="Show Header",
description="Show the header in Python Console", description="Show the header in the Python Console",
default=True) default=True)
def draw(self, context): def draw(self, context):
...@@ -421,14 +424,16 @@ class IV_OT_icons_show(bpy.types.Operator): ...@@ -421,14 +424,16 @@ class IV_OT_icons_show(bpy.types.Operator):
col = self.layout col = self.layout
self.draw_header(col) self.draw_header(col)
history_num_cols = int(
(self.width - POPUP_PADDING) / (ui_scale() * ICON_SIZE))
num_cols = min( num_cols = min(
self.get_num_cols(len(pr.popup_icons.filtered_icons)), 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) subcol = col.column(True)
if HISTORY and pr.show_history: 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) pr.popup_icons.draw(subcol.box(), num_cols)
...@@ -472,8 +477,14 @@ class IV_OT_icons_show(bpy.types.Operator): ...@@ -472,8 +477,14 @@ class IV_OT_icons_show(bpy.types.Operator):
def register(): def register():
if bpy.app.background:
return
bpy.utils.register_module(__name__) bpy.utils.register_module(__name__)
def unregister(): def unregister():
if bpy.app.background:
return
bpy.utils.unregister_module(__name__) bpy.utils.unregister_module(__name__)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment