-
Notifications
You must be signed in to change notification settings - Fork 24
Expand file tree
/
Copy pathapp.h
More file actions
170 lines (146 loc) · 5.2 KB
/
app.h
File metadata and controls
170 lines (146 loc) · 5.2 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
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
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include "imgui.h"
#include "imgui_internal.h"
#include <opentimelineio/timeline.h>
#include <opentimelineio/serializableObjectWithMetadata.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 data specific to individual tabs.
struct TabData {
// This holds the main Schema object. Pretty much everything drills into
// this one entry point.
otio::SerializableObject::Retainer<otio::SerializableObjectWithMetadata> root;
bool opened = true; // Is the tab still open?
float scale = 100.0f; // Zoom scale, measured in pixels per second.
std::string file_path; // What file did we load?
bool set_tab_active = false; // When we close a tab, go to the tab where this is true.
otio::TimeRange
playhead_limit; // Min/max limit for moving the playhead, auto-calculated.
otio::RationalTime playhead;
bool first_frame = true; // The timeline drawing code has to be drawn across
// two frames so we keep track of that here
};
// Struct that holds the application's state
struct AppState {
std::vector<TabData*> tabs;
TabData* active_tab;
// Timeline display settings
float timeline_width = 100.0f; // automatically calculated (pixels)
float default_track_height = 30.0f; // (pixels)
float track_height = 30.0f; // current track height (pixels)
bool scroll_to_playhead = false; // temporary flag, only true until next frame
bool scroll_key = false; // temporary flag, only true until next frame
bool scroll_up_down; // temporary flag, only true until next frame
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
bool message_is_error = false;
// Store the currently selected MediaReference index for the inspector.
int selected_reference_index = -1;
// 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, ...);
void ErrorMessage(const char* format, ...);
std::string Format(const char* format, ...);
void LoadString(std::string json);
bool LoadRoot(otio::SerializableObjectWithMetadata* root);
otio::SerializableObjectWithMetadata* GetActiveRoot();
void CloseTab(TabData* tab);
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();