1 # ##### BEGIN GPL LICENSE BLOCK #####
3 # This program is free software; you can redistribute it and/or
4 # modify it under the terms of the GNU General Public License
5 # as published by the Free Software Foundation; either version 2
6 # of the License, or (at your option) any later version.
8 # This program is distributed in the hope that it will be useful,
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 # GNU General Public License for more details.
13 # You should have received a copy of the GNU General Public License
14 # along with this program; if not, write to the Free Software Foundation,
15 # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17 # ##### END GPL LICENSE BLOCK #####
24 'author': 'Crouch, N.tox, PKHG, Campbell Barton, Dany Lebel',
26 "blender": (2, 57, 0),
27 'location': 'Text Editor > Properties or '\
28 'Console > Console Menu',
30 'description': 'Click an icon to display its name and copy it '\
32 'wiki_url': 'http://wiki.blender.org/index.php/Extensions:2.6/'\
33 'Py/Scripts/System/Display_All_Icons',
34 'tracker_url': 'http://projects.blender.org/tracker/index.php?'\
35 'func=detail&aid=22011',
36 'category': 'Development'}
42 def create_icon_list_all():
43 icons
= bpy
.types
.UILayout
.bl_rna
.functions
['prop'].parameters
['icon'].\
51 def create_icon_list():
52 icons
= create_icon_list_all()
53 search
= bpy
.context
.scene
.icon_props
.search
.lower()
58 icons
= [key
for key
in icons
if search
in key
.lower()]
63 class WM_OT_icon_info(bpy
.types
.Operator
):
64 bl_idname
= "wm.icon_info"
65 bl_label
= "Icon Info"
66 bl_description
= "Click to copy this icon name to the clipboard"
67 icon
= bpy
.props
.StringProperty()
68 icon_scroll
= bpy
.props
.IntProperty()
70 def invoke(self
, context
, event
):
71 bpy
.data
.window_managers
['WinMan'].clipboard
= self
.icon
72 self
.report({'INFO'}, "Icon ID: %s" % self
.icon
)
76 class OBJECT_PT_icons(bpy
.types
.Panel
):
77 bl_space_type
= "TEXT_EDITOR"
79 bl_label
= "All icons"
83 self
.icon_list
= create_icon_list()
85 def draw(self
, context
):
86 props
= context
.scene
.icon_props
88 if props
.search
!= CONSOLE_HT_icons
._search
_old
:
89 self
.icon_list
= create_icon_list()
90 # adjusting max value of scroller
91 # IconProps.scroll = bpy.props.IntProperty(default=1, min=1,
92 # max=max(1, len(self.icon_list) - self.amount + 1),
93 # description="Drag to scroll icons")
95 box
= self
.layout
.box()
100 toprow
.prop(props
, "expand", icon
="TRIA_RIGHT", icon_only
=True,
101 text
="", emboss
=False) # icon_only broken?
103 row
= toprow
.row(align
=True)
104 row
.prop(props
, "search", icon
="VIEWZOOM", text
="")
107 row
.active
= props
.bl_rna
.scroll
[1]['max'] > 1
108 row
.prop(props
, "scroll")
111 row
= box
.row(align
=True)
112 if len(self
.icon_list
) == 0:
113 row
.label("No icons found")
115 for icon
in self
.icon_list
[props
.scroll
- 1:
116 props
.scroll
- 1 + self
.amount
]:
117 row
.operator("wm.icon_info", text
=" ", icon
=icon
,
118 emboss
=False).icon
= icon
119 if len(self
.icon_list
) < self
.amount
:
120 for i
in range(self
.amount
- len(self
.icon_list
) \
128 toprow
.prop(props
, "expand", icon
="TRIA_DOWN", icon_only
=True,
129 text
="", emboss
=False)
131 row
= toprow
.row(align
=True)
132 row
.prop(props
, "search", icon
="VIEWZOOM", text
="")
136 row
.prop(props
, "scroll")
139 col
= box
.column(align
=True)
140 if len(self
.icon_list
) == 0:
141 col
.label("No icons found")
143 for i
, icon
in enumerate(self
.icon_list
):
144 if i
% self
.amount
== 0:
145 row
= col
.row(align
=True)
146 row
.operator("wm.icon_info", text
=" ", icon
=icon
,
147 emboss
=False).icon
= icon
148 for i
in range(self
.amount
- len(self
.icon_list
) \
153 class CONSOLE_HT_icons(bpy
.types
.Header
):
154 bl_space_type
= 'CONSOLE'
159 self
.icon_list
= create_icon_list()
161 def draw(self
, context
):
162 props
= context
.scene
.icon_props
163 # polling for updates
164 if props
.search
!= self
.__class
__._search
_old
:
165 self
.__class
__._search
_old
= props
.search
166 self
.icon_list
= create_icon_list()
167 # adjusting max value of scroller
168 # IconProps.scroll = bpy.props.IntProperty(default=1, min=1,
169 # max=max(1, len(self.icon_list) - self.amount + 1),
170 # description="Drag to scroll icons")
178 row
.prop(props
, "search", icon
="VIEWZOOM")
181 row
.active
= props
.bl_rna
.scroll
[1]['max'] > 1
182 row
.prop(props
, "scroll")
185 row
= layout
.row(align
=True)
186 if len(self
.icon_list
) == 0:
187 row
.label("No icons found")
189 for icon
in self
.icon_list
[props
.scroll
- 1:
190 props
.scroll
- 1 + self
.amount
]:
191 row
.operator("wm.icon_info", text
="", icon
=icon
,
192 emboss
=False).icon
= icon
195 def menu_func(self
, context
):
196 self
.layout
.prop(bpy
.context
.scene
.icon_props
, 'console')
202 icons_total
= len(create_icon_list_all())
205 class IconProps(bpy
.types
.PropertyGroup
):
207 Fake module like class
208 bpy.context.scene.icon_props
210 console
= bpy
.props
.BoolProperty(name
='Show System Icons',
211 description
='Display the Icons in the console header',
213 expand
= bpy
.props
.BoolProperty(name
="Expand",
214 description
="Expand, to display all icons at once",
216 search
= bpy
.props
.StringProperty(name
="Search",
217 description
="Search for icons by name",
219 scroll
= bpy
.props
.IntProperty(name
="Scroll",
220 description
="Drag to scroll icons",
221 default
=1, min=1, max=max(1, icons_total
- icons_per_row
+ 1))
223 bpy
.utils
.register_module(__name__
)
224 bpy
.types
.Scene
.icon_props
= bpy
.props
.PointerProperty(type=IconProps
)
225 bpy
.types
.CONSOLE_MT_console
.append(menu_func
)
229 if bpy
.context
.scene
.get('icon_props') != None:
230 del bpy
.context
.scene
['icon_props']
232 del bpy
.types
.Scene
.icon_props
233 bpy
.types
.CONSOLE_MT_console
.remove(menu_func
)
236 if __name__
== "__main__":
237 # unregistering is only done automatically when run as addon
238 bpy
.utils
.unregister_class(OBJECT_PT_icons
)
239 bpy
.utils
.unregister_class(CONSOLE_HT_icons
)
241 bpy
.utils
.unregister_module(__name__
)
244 if __name__
== "__main__":