Skip to content
Snippets Groups Projects
Commit 9653e002 authored by Bart Crouch's avatar Bart Crouch
Browse files

Version 1.5.1

Fixes for api changes.
Max value of scroll isn't updated anymore, needs property callbacks to make it work again.
parent d1b70c20
No related branches found
No related tags found
No related merge requests found
...@@ -22,9 +22,9 @@ ...@@ -22,9 +22,9 @@
bl_info = { bl_info = {
'name': 'Icons', 'name': 'Icons',
'author': 'Crouch, N.tox, PKHG, Campbell Barton, Dany Lebel', 'author': 'Crouch, N.tox, PKHG, Campbell Barton, Dany Lebel',
'version': (1, 5, 0), 'version': (1, 5, 1),
"blender": (2, 5, 7), "blender": (2, 5, 7),
"api": 35622, "api": 35850,
'location': 'Text Editor > Properties or '\ 'location': 'Text Editor > Properties or '\
'Console > Console Menu', 'Console > Console Menu',
'warning': '', 'warning': '',
...@@ -43,21 +43,21 @@ import bpy ...@@ -43,21 +43,21 @@ import bpy
def create_icon_list_all(): def create_icon_list_all():
icons = bpy.types.UILayout.bl_rna.functions['prop'].parameters['icon'].\ icons = bpy.types.UILayout.bl_rna.functions['prop'].parameters['icon'].\
enum_items.keys() enum_items.keys()
icons.remove("NONE") icons.remove("NONE")
return icons return icons
def create_icon_list(): def create_icon_list():
icons = create_icon_list_all() icons = create_icon_list_all()
search = bpy.context.scene.icon_props.search.lower() search = bpy.context.scene.icon_props.search.lower()
if search == "": if search == "":
pass pass
else: else:
icons = [key for key in icons if search in key.lower()] icons = [key for key in icons if search in key.lower()]
return icons return icons
...@@ -67,7 +67,7 @@ class WM_OT_icon_info(bpy.types.Operator): ...@@ -67,7 +67,7 @@ class WM_OT_icon_info(bpy.types.Operator):
bl_description = "Click to copy this icon name to the clipboard" bl_description = "Click to copy this icon name to the clipboard"
icon = bpy.props.StringProperty() icon = bpy.props.StringProperty()
icon_scroll = bpy.props.IntProperty() icon_scroll = bpy.props.IntProperty()
def invoke(self, context, event): def invoke(self, context, event):
bpy.data.window_managers['WinMan'].clipboard = self.icon bpy.data.window_managers['WinMan'].clipboard = self.icon
self.report({'INFO'}, "Icon ID: %s" % self.icon) self.report({'INFO'}, "Icon ID: %s" % self.icon)
...@@ -78,21 +78,21 @@ class OBJECT_PT_icons(bpy.types.Panel): ...@@ -78,21 +78,21 @@ class OBJECT_PT_icons(bpy.types.Panel):
bl_space_type = "TEXT_EDITOR" bl_space_type = "TEXT_EDITOR"
bl_region_type = "UI" bl_region_type = "UI"
bl_label = "All icons" bl_label = "All icons"
def __init__(self): def __init__(self):
self.amount = 10 self.amount = 10
self.icon_list = create_icon_list() self.icon_list = create_icon_list()
def draw(self, context): def draw(self, context):
props = context.scene.icon_props props = context.scene.icon_props
# polling for updates # polling for updates
if props.search != CONSOLE_HT_icons._search_old: if props.search != CONSOLE_HT_icons._search_old:
self.icon_list = create_icon_list() self.icon_list = create_icon_list()
# adjusting max value of scroller # adjusting max value of scroller
IconProps.scroll = bpy.props.IntProperty(default=1, min=1, # IconProps.scroll = bpy.props.IntProperty(default=1, min=1,
max=max(1, len(self.icon_list) - self.amount + 1), # max=max(1, len(self.icon_list) - self.amount + 1),
description="Drag to scroll icons") # description="Drag to scroll icons")
box = self.layout.box() box = self.layout.box()
# scroll view # scroll view
if not props.expand: if not props.expand:
...@@ -107,7 +107,7 @@ class OBJECT_PT_icons(bpy.types.Panel): ...@@ -107,7 +107,7 @@ class OBJECT_PT_icons(bpy.types.Panel):
row = toprow.row() row = toprow.row()
row.active = props.bl_rna.scroll[1]['max'] > 1 row.active = props.bl_rna.scroll[1]['max'] > 1
row.prop(props, "scroll") row.prop(props, "scroll")
# icons # icons
row = box.row(align=True) row = box.row(align=True)
if len(self.icon_list) == 0: if len(self.icon_list) == 0:
...@@ -121,7 +121,7 @@ class OBJECT_PT_icons(bpy.types.Panel): ...@@ -121,7 +121,7 @@ class OBJECT_PT_icons(bpy.types.Panel):
for i in range(self.amount - len(self.icon_list) \ for i in range(self.amount - len(self.icon_list) \
% self.amount): % self.amount):
row.label("") row.label("")
# expanded view # expanded view
else: else:
# expand button # expand button
...@@ -135,11 +135,11 @@ class OBJECT_PT_icons(bpy.types.Panel): ...@@ -135,11 +135,11 @@ class OBJECT_PT_icons(bpy.types.Panel):
row = toprow.row() row = toprow.row()
row.active = False row.active = False
row.prop(props, "scroll") row.prop(props, "scroll")
# icons # icons
col = box.column(align=True) col = box.column(align=True)
if len(self.icon_list) == 0: if len(self.icon_list) == 0:
row.label("No icons found") col.label("No icons found")
else: else:
for i, icon in enumerate(self.icon_list): for i, icon in enumerate(self.icon_list):
if i % self.amount == 0: if i % self.amount == 0:
...@@ -154,11 +154,11 @@ class OBJECT_PT_icons(bpy.types.Panel): ...@@ -154,11 +154,11 @@ class OBJECT_PT_icons(bpy.types.Panel):
class CONSOLE_HT_icons(bpy.types.Header): class CONSOLE_HT_icons(bpy.types.Header):
bl_space_type = 'CONSOLE' bl_space_type = 'CONSOLE'
_search_old = "" _search_old = ""
def __init__(self): def __init__(self):
self.amount = 10 self.amount = 10
self.icon_list = create_icon_list() self.icon_list = create_icon_list()
def draw(self, context): def draw(self, context):
props = context.scene.icon_props props = context.scene.icon_props
# polling for updates # polling for updates
...@@ -166,10 +166,10 @@ class CONSOLE_HT_icons(bpy.types.Header): ...@@ -166,10 +166,10 @@ class CONSOLE_HT_icons(bpy.types.Header):
__class__._search_old = props.search __class__._search_old = props.search
self.icon_list = create_icon_list() self.icon_list = create_icon_list()
# adjusting max value of scroller # adjusting max value of scroller
IconProps.scroll = bpy.props.IntProperty(default=1, min=1, # IconProps.scroll = bpy.props.IntProperty(default=1, min=1,
max=max(1, len(self.icon_list) - self.amount + 1), # max=max(1, len(self.icon_list) - self.amount + 1),
description="Drag to scroll icons") # description="Drag to scroll icons")
# scroll view # scroll view
if props.console: if props.console:
layout = self.layout layout = self.layout
...@@ -181,7 +181,7 @@ class CONSOLE_HT_icons(bpy.types.Header): ...@@ -181,7 +181,7 @@ class CONSOLE_HT_icons(bpy.types.Header):
row = layout.row() row = layout.row()
row.active = props.bl_rna.scroll[1]['max'] > 1 row.active = props.bl_rna.scroll[1]['max'] > 1
row.prop(props, "scroll") row.prop(props, "scroll")
# icons # icons
row = layout.row(align=True) row = layout.row(align=True)
if len(self.icon_list) == 0: if len(self.icon_list) == 0:
...@@ -199,10 +199,10 @@ def menu_func(self, context): ...@@ -199,10 +199,10 @@ def menu_func(self, context):
def register(): def register():
global IconProps global IconProps
icons_total = len(create_icon_list_all()) icons_total = len(create_icon_list_all())
icons_per_row = 10 icons_per_row = 10
class IconProps(bpy.types.PropertyGroup): class IconProps(bpy.types.PropertyGroup):
""" """
Fake module like class Fake module like class
...@@ -217,16 +217,13 @@ def register(): ...@@ -217,16 +217,13 @@ def register():
scroll = bpy.props.IntProperty(default=1, min=1, scroll = bpy.props.IntProperty(default=1, min=1,
max=max(1, icons_total - icons_per_row + 1), max=max(1, icons_total - icons_per_row + 1),
description="Drag to scroll icons") description="Drag to scroll icons")
bpy.utils.register_module(__name__) bpy.utils.register_module(__name__)
bpy.types.Scene.icon_props = bpy.props.PointerProperty(type=IconProps) bpy.types.Scene.icon_props = bpy.props.PointerProperty(type=IconProps)
bpy.types.CONSOLE_MT_console.append(menu_func) bpy.types.CONSOLE_MT_console.append(menu_func)
def unregister(): def unregister():
if bpy.context.scene.get('icon_props') != None: if bpy.context.scene.get('icon_props') != None:
del bpy.context.scene['icon_props'] del bpy.context.scene['icon_props']
try: try:
...@@ -238,8 +235,9 @@ def unregister(): ...@@ -238,8 +235,9 @@ def unregister():
# unregistering is only done automatically when run as add-on # unregistering is only done automatically when run as add-on
bpy.utils.unregister_class(OBJECT_PT_icons) bpy.utils.unregister_class(OBJECT_PT_icons)
bpy.utils.unregister_class(CONSOLE_HT_icons) bpy.utils.unregister_class(CONSOLE_HT_icons)
bpy.utils.unregister_module(__name__) bpy.utils.unregister_module(__name__)
if __name__ == "__main__": if __name__ == "__main__":
register() register()
\ No newline at end of file
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