This repository was archived by the owner on Oct 7, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path__init__.py
More file actions
60 lines (53 loc) · 2.48 KB
/
Copy path__init__.py
File metadata and controls
60 lines (53 loc) · 2.48 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
bl_info = {
"name": "Timeline buttons in dopesheet",
"author": "Splits285",
"blender": (2, 80, 0),
"version": (0, 0, 4),
"description": "Adds the timeline's current frame, frame-start-end(+preview) sliders, auto-key toggle, and a neat FPS slider to the dopesheet.",
"doc_url": "https://github.com/Splits285/TimelineButtonsInDopesheet",
"tracker_url": "https://github.com/Splits285/TimelineButtonsInDopesheet/issues",
"category": "Dope Sheet",
"support": "COMMUNITY",
}
import bpy
#Read all about it @ https://docs.blender.org/api/current/bpy.types.UILayout.html
#Create the thing
class CUSTOM_PT_slider_panel(bpy.types.Panel):
bl_label = "Custom Slider Panel"
bl_space_type = 'DOPESHEET_EDITOR'
bl_region_type = 'HEADER'
def draw(self, context):
layout = self.layout
##Current frame slider
row = layout.row()
row.ui_units_x = 3.2
row.prop(context.scene, "frame_current", text="")
##Auto keying toggle radio button, somehow toggles its icon to filled on its own
row = layout.row()
row.prop(context.scene.tool_settings, "use_keyframe_insert_auto", icon='RADIOBUT_OFF', icon_only=True)
##Preview range toggle button
row = layout.row(align=True)
row.ui_units_x = 7.5
row.prop(context.scene, "use_preview_range", icon='PREVIEW_RANGE', icon_only=True)
##Frame range sliders, preview being active controls which slider is shown just as in the timeline window
if context.scene.use_preview_range:
row.prop(context.scene, "frame_preview_start", text="Start")
row.prop(context.scene, "frame_preview_end", text="End")
else:
row.prop(context.scene, "frame_start", text="Start")
row.prop(context.scene, "frame_end", text="End")
##FPS slider
row = layout.row()
row.ui_units_x = 2.7
row.prop(context.scene.render, "fps", text="FPS")
#Add our elements. They could be .prepend-ed as well but that looks weird being ahead of the window type button.
def register():
bpy.utils.register_class(CUSTOM_PT_slider_panel)
bpy.types.DOPESHEET_HT_header.append(CUSTOM_PT_slider_panel.draw)
#Remove them.
def unregister():
bpy.types.DOPESHEET_HT_header.remove(CUSTOM_PT_slider_panel.draw)
bpy.utils.unregister_class(CUSTOM_PT_slider_panel)
#Spawn automatically if we're __main__.py I guess.
if __name__ == "__main__":
register()