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 = {
"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__)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment