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 " "Console > Console Menu",
29 "description": "Click an icon to display its name and "
30 "copy it to the clipboard",
31 "wiki_url": "http://wiki.blender.org/index.php/Extensions:2.6/"
32 "Py/Scripts/System/Display_All_Icons",
33 "category": "Development",
40 def create_icon_list_all():
41 icons
= bpy
.types
.UILayout
.bl_rna
.functions
['prop'].parameters
['icon'].\
49 def create_icon_list():
50 icons
= create_icon_list_all()
51 search
= bpy
.context
.scene
.icon_props
.search
.lower()
56 icons
= [key
for key
in icons
if search
in key
.lower()]
61 class WM_OT_icon_info(bpy
.types
.Operator
):
62 bl_idname
= "wm.icon_info"
63 bl_label
= "Icon Info"
64 bl_description
= "Click to copy this icon name to the clipboard"
65 icon
= bpy
.props
.StringProperty()
66 icon_scroll
= bpy
.props
.IntProperty()
68 def invoke(self
, context
, event
):
69 bpy
.data
.window_managers
['WinMan'].clipboard
= self
.icon
70 self
.report({'INFO'}, "Icon ID: %s" % self
.icon
)
74 class OBJECT_PT_icons(bpy
.types
.Panel
):
75 bl_space_type
= "TEXT_EDITOR"
77 bl_label
= "All icons"
81 self
.icon_list
= create_icon_list()
83 def draw(self
, context
):
84 props
= context
.scene
.icon_props
86 if props
.search
!= CONSOLE_HT_icons
._search
_old
:
87 self
.icon_list
= create_icon_list()
88 # adjusting max value of scroller
89 # IconProps.scroll = bpy.props.IntProperty(default=1, min=1,
90 # max=max(1, len(self.icon_list) - self.amount + 1),
91 # description="Drag to scroll icons")
93 box
= self
.layout
.box()
98 toprow
.prop(props
, "expand", icon
="TRIA_RIGHT", icon_only
=True,
99 text
="", emboss
=False) # icon_only broken?
101 row
= toprow
.row(align
=True)
102 row
.prop(props
, "search", icon
="VIEWZOOM", text
="")
105 row
.active
= props
.bl_rna
.scroll
[1]['max'] > 1
106 row
.prop(props
, "scroll")
109 row
= box
.row(align
=True)
110 if len(self
.icon_list
) == 0:
111 row
.label("No icons found")
113 for icon
in self
.icon_list
[props
.scroll
- 1:
114 props
.scroll
- 1 + self
.amount
]:
115 row
.operator("wm.icon_info", text
=" ", icon
=icon
,
116 emboss
=False).icon
= icon
117 if len(self
.icon_list
) < self
.amount
:
118 for i
in range(self
.amount
- len(self
.icon_list
) \
126 toprow
.prop(props
, "expand", icon
="TRIA_DOWN", icon_only
=True,
127 text
="", emboss
=False)
129 row
= toprow
.row(align
=True)
130 row
.prop(props
, "search", icon
="VIEWZOOM", text
="")
134 row
.prop(props
, "scroll")
137 col
= box
.column(align
=True)
138 if len(self
.icon_list
) == 0:
139 col
.label("No icons found")
141 for i
, icon
in enumerate(self
.icon_list
):
142 if i
% self
.amount
== 0:
143 row
= col
.row(align
=True)
144 row
.operator("wm.icon_info", text
=" ", icon
=icon
,
145 emboss
=False).icon
= icon
146 for i
in range(self
.amount
- len(self
.icon_list
) \
151 class CONSOLE_HT_icons(bpy
.types
.Header
):
152 bl_space_type
= 'CONSOLE'
157 self
.icon_list
= create_icon_list()
159 def draw(self
, context
):
160 props
= context
.scene
.icon_props
161 # polling for updates
162 if props
.search
!= self
.__class
__._search
_old
:
163 self
.__class
__._search
_old
= props
.search
164 self
.icon_list
= create_icon_list()
165 # adjusting max value of scroller
166 # IconProps.scroll = bpy.props.IntProperty(default=1, min=1,
167 # max=max(1, len(self.icon_list) - self.amount + 1),
168 # description="Drag to scroll icons")
176 row
.prop(props
, "search", icon
="VIEWZOOM")
179 row
.active
= props
.bl_rna
.scroll
[1]['max'] > 1
180 row
.prop(props
, "scroll")
183 row
= layout
.row(align
=True)
184 if len(self
.icon_list
) == 0:
185 row
.label("No icons found")
187 for icon
in self
.icon_list
[props
.scroll
- 1:
188 props
.scroll
- 1 + self
.amount
]:
189 row
.operator("wm.icon_info", text
="", icon
=icon
,
190 emboss
=False).icon
= icon
193 def menu_func(self
, context
):
194 self
.layout
.prop(bpy
.context
.scene
.icon_props
, 'console')
200 icons_total
= len(create_icon_list_all())
203 class IconProps(bpy
.types
.PropertyGroup
):
205 Fake module like class
206 bpy.context.scene.icon_props
208 console
= bpy
.props
.BoolProperty(name
='Show System Icons',
209 description
='Display the Icons in the console header',
211 expand
= bpy
.props
.BoolProperty(name
="Expand",
212 description
="Expand, to display all icons at once",
214 search
= bpy
.props
.StringProperty(name
="Search",
215 description
="Search for icons by name",
217 scroll
= bpy
.props
.IntProperty(name
="Scroll",
218 description
="Drag to scroll icons",
219 default
=1, min=1, max=max(1, icons_total
- icons_per_row
+ 1))
221 bpy
.utils
.register_module(__name__
)
222 bpy
.types
.Scene
.icon_props
= bpy
.props
.PointerProperty(type=IconProps
)
223 bpy
.types
.CONSOLE_MT_console
.append(menu_func
)
227 if bpy
.context
.scene
.get('icon_props') != None:
228 del bpy
.context
.scene
['icon_props']
230 del bpy
.types
.Scene
.icon_props
231 bpy
.types
.CONSOLE_MT_console
.remove(menu_func
)
234 if __name__
== "__main__":
235 # unregistering is only done automatically when run as addon
236 bpy
.utils
.unregister_class(OBJECT_PT_icons
)
237 bpy
.utils
.unregister_class(CONSOLE_HT_icons
)
239 bpy
.utils
.unregister_module(__name__
)
242 if __name__
== "__main__":