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 #####
22 "name": "UI Animation Render",
23 "author": "Luca Rood",
24 "description": "Render animations of the Blender UI.",
25 "blender": (2, 80, 0),
27 "location": "View3D > Sidebar > View Tab and Ctrl+Shift+F12",
35 def draw_ui(prefs
, layout
):
36 layout
.prop(prefs
, "delay")
38 col
= layout
.column(align
=True)
39 col
.label(text
="Animation Highlight:")
42 row
.prop(prefs
, "anim_highlight", expand
=True)
44 if prefs
.anim_highlight
== "replace":
45 split
= col
.split(factor
=0.2)
46 split
.label(text
="Color")
47 row
= split
.row(align
=True)
48 row
.prop(prefs
, "highlight_color", text
="")
49 row
.prop(prefs
, "highlight_blend", text
="Blend")
52 class UIAnimationRenderPreferences(bpy
.types
.AddonPreferences
):
55 delay
: bpy
.props
.FloatProperty(
57 description
="How much time to wait (seconds) before capturing each frame, to allow the viewport to clean up",
61 anim_highlight
: bpy
.props
.EnumProperty(
62 name
="Animation Highlight",
63 description
="What to do with the animated field highlight color",
64 items
=[("keep", "Keep", "Keep the animated field highlight", 0),
65 ("hide", "Hide", "Hide the animated field highlight", 1),
66 ("replace", "Replace", "Replace the animated field highlight", 2)],
70 highlight_color
: bpy
.props
.FloatVectorProperty(
71 name
="Highlight Color",
72 description
="Color to use for animated field highlights",
74 default
=(1.0, 1.0, 1.0)
77 highlight_blend
: bpy
.props
.FloatProperty(
78 name
="Highlight Blend",
79 description
="How much the highlight color influences the field color",
83 def draw(self
, context
):
84 draw_ui(self
, self
.layout
)
87 class RenderScreen(bpy
.types
.Operator
):
88 bl_idname
= "render.render_screen"
89 bl_label
= "Render Screen"
90 bl_description
= "Capture the screen for each animation frame and write to the render output path"
95 _theme_key
= (0, 0, 0)
96 _theme_key_sel
= (0, 0, 0)
97 _theme_anim
= (0, 0, 0)
98 _theme_anim_sel
= (0, 0, 0)
99 _theme_driven
= (0, 0, 0)
100 _theme_driven_sel
= (0, 0, 0)
102 def modal(self
, context
, event
):
103 if event
.type in {'RIGHTMOUSE', 'ESC'}:
107 if event
.type == 'TIMER':
108 scene
= context
.scene
109 f_curr
= scene
.frame_current
111 bpy
.ops
.screen
.screenshot(filepath
=context
.scene
.render
.frame_path(frame
=f_curr
))
113 if f_curr
< scene
.frame_end
:
114 scene
.frame_set(f_curr
+ 1)
119 return {'RUNNING_MODAL'}
121 def execute(self
, context
):
122 # Adjust animation highlight (theme)
123 prefs
= context
.preferences
124 addon_prefs
= prefs
.addons
[__name__
].preferences
125 theme
= prefs
.themes
[0].user_interface
.wcol_state
127 if addon_prefs
.anim_highlight
== "hide":
128 self
._theme
_blend
= theme
.blend
130 elif addon_prefs
.anim_highlight
== "replace":
131 self
._theme
_blend
= theme
.blend
132 self
._theme
_key
= theme
.inner_key
.copy()
133 self
._theme
_key
_sel
= theme
.inner_key_sel
.copy()
134 self
._theme
_anim
= theme
.inner_anim
.copy()
135 self
._theme
_anim
_sel
= theme
.inner_anim_sel
.copy()
136 self
._theme
_driven
= theme
.inner_driven
.copy()
137 self
._theme
_driven
_sel
= theme
.inner_driven_sel
.copy()
139 theme
.blend
= addon_prefs
.highlight_blend
140 theme
.inner_key
= addon_prefs
.highlight_color
141 theme
.inner_key_sel
= addon_prefs
.highlight_color
142 theme
.inner_anim
= addon_prefs
.highlight_color
143 theme
.inner_anim_sel
= addon_prefs
.highlight_color
144 theme
.inner_driven
= addon_prefs
.highlight_color
145 theme
.inner_driven_sel
= addon_prefs
.highlight_color
148 scene
= context
.scene
149 self
._f
_initial
= scene
.frame_current
150 scene
.frame_set(scene
.frame_start
)
153 wm
= context
.window_manager
154 self
._timer
= wm
.event_timer_add(addon_prefs
.delay
, window
=context
.window
)
155 wm
.modal_handler_add(self
)
156 return {'RUNNING_MODAL'}
158 def stop(self
, context
):
160 wm
= context
.window_manager
161 wm
.event_timer_remove(self
._timer
)
164 context
.scene
.frame_set(self
._f
_initial
)
167 prefs
= context
.preferences
168 addon_prefs
= prefs
.addons
[__name__
].preferences
169 theme
= prefs
.themes
[0].user_interface
.wcol_state
171 if addon_prefs
.anim_highlight
== "hide":
172 theme
.blend
= self
._theme
_blend
173 elif addon_prefs
.anim_highlight
== "replace":
174 theme
.blend
= self
._theme
_blend
175 theme
.inner_key
= self
._theme
_key
176 theme
.inner_key_sel
= self
._theme
_key
_sel
177 theme
.inner_anim
= self
._theme
_anim
178 theme
.inner_anim_sel
= self
._theme
_anim
_sel
179 theme
.inner_driven
= self
._theme
_driven
180 theme
.inner_driven_sel
= self
._theme
_driven
_sel
183 class VIEW3D_PT_ui_animation_render(bpy
.types
.Panel
):
184 bl_space_type
= 'VIEW_3D'
185 bl_region_type
= 'UI'
187 bl_label
= "UI Animation Render"
188 bl_options
= {'DEFAULT_CLOSED'}
190 def draw(self
, context
):
192 layout
.use_property_split
= False
194 prefs
= context
.preferences
195 addon_prefs
= prefs
.addons
[__name__
].preferences
197 layout
.operator(RenderScreen
.bl_idname
)
198 draw_ui(addon_prefs
, layout
)
204 bpy
.utils
.register_class(UIAnimationRenderPreferences
)
205 bpy
.utils
.register_class(RenderScreen
)
206 bpy
.utils
.register_class(VIEW3D_PT_ui_animation_render
)
208 wm
= bpy
.context
.window_manager
209 km
= wm
.keyconfigs
.addon
.keymaps
.new(name
='Screen', space_type
='EMPTY')
210 km
.keymap_items
.new('render.render_screen', 'F12', 'PRESS', shift
=True, ctrl
=True)
216 bpy
.utils
.unregister_class(UIAnimationRenderPreferences
)
217 bpy
.utils
.unregister_class(RenderScreen
)
218 bpy
.utils
.unregister_class(VIEW3D_PT_ui_animation_render
)
221 wm
= bpy
.context
.window_manager
222 wm
.keyconfigs
.addon
.keymaps
.remove(km
)