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': 'https://developer.blender.org/T22011',
35 'category': 'Development'}
41 def create_icon_list_all():
42 icons
= bpy
.types
.UILayout
.bl_rna
.functions
['prop'].parameters
['icon'].\
50 def create_icon_list():
51 icons
= create_icon_list_all()
52 search
= bpy
.context
.scene
.icon_props
.search
.lower()
57 icons
= [key
for key
in icons
if search
in key
.lower()]
62 class WM_OT_icon_info(bpy
.types
.Operator
):
63 bl_idname
= "wm.icon_info"
64 bl_label
= "Icon Info"
65 bl_description
= "Click to copy this icon name to the clipboard"
66 icon
= bpy
.props
.StringProperty()
67 icon_scroll
= bpy
.props
.IntProperty()
69 def invoke(self
, context
, event
):
70 bpy
.data
.window_managers
['WinMan'].clipboard
= self
.icon
71 self
.report({'INFO'}, "Icon ID: %s" % self
.icon
)
75 class OBJECT_PT_icons(bpy
.types
.Panel
):
76 bl_space_type
= "TEXT_EDITOR"
78 bl_label
= "All icons"
82 self
.icon_list
= create_icon_list()
84 def draw(self
, context
):
85 props
= context
.scene
.icon_props
87 if props
.search
!= CONSOLE_HT_icons
._search
_old
:
88 self
.icon_list
= create_icon_list()
89 # adjusting max value of scroller
90 # IconProps.scroll = bpy.props.IntProperty(default=1, min=1,
91 # max=max(1, len(self.icon_list) - self.amount + 1),
92 # description="Drag to scroll icons")
94 box
= self
.layout
.box()
99 toprow
.prop(props
, "expand", icon
="TRIA_RIGHT", icon_only
=True,
100 text
="", emboss
=False) # icon_only broken?
102 row
= toprow
.row(align
=True)
103 row
.prop(props
, "search", icon
="VIEWZOOM", text
="")
106 row
.active
= props
.bl_rna
.scroll
[1]['max'] > 1
107 row
.prop(props
, "scroll")
110 row
= box
.row(align
=True)
111 if len(self
.icon_list
) == 0:
112 row
.label("No icons found")
114 for icon
in self
.icon_list
[props
.scroll
- 1:
115 props
.scroll
- 1 + self
.amount
]:
116 row
.operator("wm.icon_info", text
=" ", icon
=icon
,
117 emboss
=False).icon
= icon
118 if len(self
.icon_list
) < self
.amount
:
119 for i
in range(self
.amount
- len(self
.icon_list
) \
127 toprow
.prop(props
, "expand", icon
="TRIA_DOWN", icon_only
=True,
128 text
="", emboss
=False)
130 row
= toprow
.row(align
=True)
131 row
.prop(props
, "search", icon
="VIEWZOOM", text
="")
135 row
.prop(props
, "scroll")
138 col
= box
.column(align
=True)
139 if len(self
.icon_list
) == 0:
140 col
.label("No icons found")
142 for i
, icon
in enumerate(self
.icon_list
):
143 if i
% self
.amount
== 0:
144 row
= col
.row(align
=True)
145 row
.operator("wm.icon_info", text
=" ", icon
=icon
,
146 emboss
=False).icon
= icon
147 for i
in range(self
.amount
- len(self
.icon_list
) \
152 class CONSOLE_HT_icons(bpy
.types
.Header
):
153 bl_space_type
= 'CONSOLE'
158 self
.icon_list
= create_icon_list()
160 def draw(self
, context
):
161 props
= context
.scene
.icon_props
162 # polling for updates
163 if props
.search
!= self
.__class
__._search
_old
:
164 self
.__class
__._search
_old
= props
.search
165 self
.icon_list
= create_icon_list()
166 # adjusting max value of scroller
167 # IconProps.scroll = bpy.props.IntProperty(default=1, min=1,
168 # max=max(1, len(self.icon_list) - self.amount + 1),
169 # description="Drag to scroll icons")
177 row
.prop(props
, "search", icon
="VIEWZOOM")
180 row
.active
= props
.bl_rna
.scroll
[1]['max'] > 1
181 row
.prop(props
, "scroll")
184 row
= layout
.row(align
=True)
185 if len(self
.icon_list
) == 0:
186 row
.label("No icons found")
188 for icon
in self
.icon_list
[props
.scroll
- 1:
189 props
.scroll
- 1 + self
.amount
]:
190 row
.operator("wm.icon_info", text
="", icon
=icon
,
191 emboss
=False).icon
= icon
194 def menu_func(self
, context
):
195 self
.layout
.prop(bpy
.context
.scene
.icon_props
, 'console')
201 icons_total
= len(create_icon_list_all())
204 class IconProps(bpy
.types
.PropertyGroup
):
206 Fake module like class
207 bpy.context.scene.icon_props
209 console
= bpy
.props
.BoolProperty(name
='Show System Icons',
210 description
='Display the Icons in the console header',
212 expand
= bpy
.props
.BoolProperty(name
="Expand",
213 description
="Expand, to display all icons at once",
215 search
= bpy
.props
.StringProperty(name
="Search",
216 description
="Search for icons by name",
218 scroll
= bpy
.props
.IntProperty(name
="Scroll",
219 description
="Drag to scroll icons",
220 default
=1, min=1, max=max(1, icons_total
- icons_per_row
+ 1))
222 bpy
.utils
.register_module(__name__
)
223 bpy
.types
.Scene
.icon_props
= bpy
.props
.PointerProperty(type=IconProps
)
224 bpy
.types
.CONSOLE_MT_console
.append(menu_func
)
228 if bpy
.context
.scene
.get('icon_props') != None:
229 del bpy
.context
.scene
['icon_props']
231 del bpy
.types
.Scene
.icon_props
232 bpy
.types
.CONSOLE_MT_console
.remove(menu_func
)
235 if __name__
== "__main__":
236 # unregistering is only done automatically when run as addon
237 bpy
.utils
.unregister_class(OBJECT_PT_icons
)
238 bpy
.utils
.unregister_class(CONSOLE_HT_icons
)
240 bpy
.utils
.unregister_module(__name__
)
243 if __name__
== "__main__":