-
Notifications
You must be signed in to change notification settings - Fork 22
/
app.h
147 lines (128 loc) · 4.2 KB
/
app.h
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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include "imgui.h"
#include "imgui_internal.h"
#include <opentimelineio/timeline.h>
namespace otio = opentimelineio::OPENTIMELINEIO_VERSION;
enum AppThemeCol_ {
AppThemeCol_Background,
AppThemeCol_Label,
AppThemeCol_TickMajor,
AppThemeCol_TickMinor,
AppThemeCol_GapHovered,
AppThemeCol_GapSelected,
AppThemeCol_Item,
AppThemeCol_ItemHovered,
AppThemeCol_ItemSelected,
AppThemeCol_Transition,
AppThemeCol_TransitionLine,
AppThemeCol_TransitionHovered,
AppThemeCol_TransitionSelected,
AppThemeCol_Effect,
AppThemeCol_EffectHovered,
AppThemeCol_EffectSelected,
AppThemeCol_Playhead,
AppThemeCol_PlayheadLine,
AppThemeCol_PlayheadHovered,
AppThemeCol_PlayheadSelected,
AppThemeCol_MarkerHovered,
AppThemeCol_MarkerSelected,
AppThemeCol_Track,
AppThemeCol_TrackHovered,
AppThemeCol_TrackSelected,
AppThemeCol_COUNT
};
extern const char* AppThemeColor_Names[];
#ifdef DEFINE_APP_THEME_NAMES
const char* AppThemeColor_Names[] = {
"Background",
"Label",
"Tick Major",
"Tick Minor",
"Gap Hovered",
"Gap Selected",
"Item",
"Item Hovered",
"Item Selected",
"Transition",
"Transition Line",
"Transition Hovered",
"Transition Selected",
"Effect",
"Effect Hovered",
"Effect Selected",
"Playhead",
"Playhead Line",
"Playhead Hovered",
"Playhead Selected",
"Marker Hovered",
"Marker Selected",
"Track",
"Track Hovered",
"Track Selected",
"Invalid"
};
#endif
struct AppTheme {
ImU32 colors[AppThemeCol_COUNT];
};
// Struct that holds the application's state
struct AppState {
// What file did we load?
std::string file_path;
// This holds the main timeline object.
// Pretty much everything drills into this one entry point.
otio::SerializableObject::Retainer<otio::Timeline> timeline;
// Timeline display settings
float timeline_width = 100.0f; // automatically calculated (pixels)
float scale = 100.0f; // zoom scale, measured in pixels per second
float default_track_height = 30.0f; // (pixels)
float track_height = 30.0f; // current track height (pixels)
otio::RationalTime playhead;
bool scroll_to_playhead = false; // temporary flag, only true until next frame
otio::TimeRange
playhead_limit; // min/max limit for moving the playhead, auto-calculated
float zebra_factor = 0.1; // opacity of the per-frame zebra stripes
bool snap_to_frames = true; // user preference to snap the playhead, times,
// ranges, etc. to frames
bool display_timecode = true;
bool display_frames = false;
bool display_seconds = false;
bool display_rate = false;
opentime::IsDropFrameRate drop_frame_mode = opentime::InferFromRate;
// Selection.
otio::SerializableObject* selected_object; // maybe NULL
otio::SerializableObject*
selected_context; // often NULL, parent to the selected object for OTIO
// objects which don't track their parent
std::string selected_text; // displayed in the JSON inspector
char message[1024]; // single-line message displayed in main window
// Toggles for Dear ImGui windows
bool show_main_window = true;
bool show_style_editor = false;
bool show_demo_window = false;
bool show_metrics = false;
bool show_implot_demo_window = false;
};
extern AppState appState;
extern AppTheme appTheme;
extern ImFont* gFont;
void Log(const char* format, ...);
void Message(const char* format, ...);
std::string Format(const char* format, ...);
void LoadString(std::string json);
std::string otio_error_string(otio::ErrorStatus const& error_status);
void SelectObject(
otio::SerializableObject* object,
otio::SerializableObject* context = NULL);
void SeekPlayhead(double seconds);
void SnapPlayhead();
void DetectPlayheadLimits();
void FitZoomWholeTimeline();
float CalculateDynamicHeight();
std::string FormattedStringFromTime(otio::RationalTime time, bool allow_rate = true);
std::string TimecodeStringFromTime(otio::RationalTime);
std::string FramesStringFromTime(otio::RationalTime);
std::string SecondsStringFromTime(otio::RationalTime);
void UpdateJSONInspector();