5 #include "localsession.h"
11 LocalSession::LocalSession(EDL *edl)
15 selectionstart = selectionend = 0;
16 in_point = out_point = -1;
17 strcpy(folder, CLIP_FOLDER);
18 sprintf(clip_title, "Program");
19 strcpy(clip_notes, "Hello world");
21 preview_start = preview_end = 0;
32 red = green = blue = 0;
35 LocalSession::~LocalSession()
39 void LocalSession::copy_from(LocalSession *that)
41 strcpy(clip_title, that->clip_title);
42 strcpy(clip_notes, that->clip_notes);
43 strcpy(folder, that->folder);
44 in_point = that->in_point;
45 loop_playback = that->loop_playback;
46 loop_start = that->loop_start;
47 loop_end = that->loop_end;
48 out_point = that->out_point;
49 selectionend = that->selectionend;
50 selectionstart = that->selectionstart;
51 track_start = that->track_start;
52 view_start = that->view_start;
53 zoom_sample = that->zoom_sample;
54 zoom_y = that->zoom_y;
55 zoom_track = that->zoom_track;
56 preview_start = that->preview_start;
57 preview_end = that->preview_end;
60 automation_min = that->automation_min;
61 automation_max = that->automation_max;
65 void LocalSession::save_xml(FileXML *file, double start)
67 file->tag.set_title("LOCALSESSION");
69 file->tag.set_property("IN_POINT", in_point - start);
70 file->tag.set_property("LOOP_PLAYBACK", loop_playback);
71 file->tag.set_property("LOOP_START", loop_start - start);
72 file->tag.set_property("LOOP_END", loop_end - start);
73 file->tag.set_property("OUT_POINT", out_point - start);
74 file->tag.set_property("SELECTION_START", selectionstart - start);
75 file->tag.set_property("SELECTION_END", selectionend - start);
76 file->tag.set_property("CLIP_TITLE", clip_title);
77 file->tag.set_property("CLIP_NOTES", clip_notes);
78 file->tag.set_property("FOLDER", folder);
79 file->tag.set_property("TRACK_START", track_start);
80 file->tag.set_property("VIEW_START", view_start);
81 file->tag.set_property("ZOOM_SAMPLE", zoom_sample);
82 //printf("EDLSession::save_session 1\n");
83 file->tag.set_property("ZOOMY", zoom_y);
84 //printf("EDLSession::save_session 1 %d\n", zoom_track);
85 file->tag.set_property("ZOOM_TRACK", zoom_track);
87 double preview_start = this->preview_start - start;
88 if(preview_start < 0) preview_start = 0;
89 double preview_end = this->preview_end - start;
90 if(preview_end < 0) preview_end = 0;
92 file->tag.set_property("PREVIEW_START", preview_start);
93 file->tag.set_property("PREVIEW_END", preview_end);
94 file->tag.set_property("RED", red);
95 file->tag.set_property("GREEN", green);
96 file->tag.set_property("BLUE", blue);
97 file->tag.set_property("AUTOMATION_MIN", automation_min);
98 file->tag.set_property("AUTOMATION_MAX", automation_max);
100 file->tag.set_title("/LOCALSESSION");
102 file->append_newline();
103 file->append_newline();
106 void LocalSession::synchronize_params(LocalSession *that)
108 loop_playback = that->loop_playback;
109 loop_start = that->loop_start;
110 loop_end = that->loop_end;
111 preview_start = that->preview_start;
112 preview_end = that->preview_end;
119 void LocalSession::load_xml(FileXML *file, unsigned long load_flags)
121 if(load_flags & LOAD_SESSION)
123 clipboard_length = 0;
124 // Overwritten by MWindow::load_filenames
125 file->tag.get_property("CLIP_TITLE", clip_title);
126 file->tag.get_property("CLIP_NOTES", clip_notes);
127 file->tag.get_property("FOLDER", folder);
128 loop_playback = file->tag.get_property("LOOP_PLAYBACK", 0);
129 loop_start = file->tag.get_property("LOOP_START", (double)0);
130 loop_end = file->tag.get_property("LOOP_END", (double)0);
131 selectionstart = file->tag.get_property("SELECTION_START", (double)0);
132 selectionend = file->tag.get_property("SELECTION_END", (double)0);
133 track_start = file->tag.get_property("TRACK_START", track_start);
134 view_start = file->tag.get_property("VIEW_START", view_start);
135 zoom_sample = file->tag.get_property("ZOOM_SAMPLE", zoom_sample);
136 zoom_y = file->tag.get_property("ZOOMY", zoom_y);
137 zoom_track = file->tag.get_property("ZOOM_TRACK", zoom_track);
138 preview_start = file->tag.get_property("PREVIEW_START", preview_start);
139 preview_end = file->tag.get_property("PREVIEW_END", preview_end);
140 red = file->tag.get_property("RED", red);
141 green = file->tag.get_property("GREEN", green);
142 blue = file->tag.get_property("BLUE", blue);
143 automation_min = file->tag.get_property("AUTOMATION_MIN", automation_min);
144 automation_max = file->tag.get_property("AUTOMATION_MAX", automation_max);
148 // on operations like cut, paste, slice, clear... we should also undo the cursor position as users
149 // expect - this is additionally important in keyboard-only editing in viewer window
150 if(load_flags & LOAD_SESSION || load_flags & LOAD_TIMEBAR)
152 selectionstart = file->tag.get_property("SELECTION_START", (double)0);
153 selectionend = file->tag.get_property("SELECTION_END", (double)0);
158 if(load_flags & LOAD_TIMEBAR)
160 in_point = file->tag.get_property("IN_POINT", (double)-1);
161 out_point = file->tag.get_property("OUT_POINT", (double)-1);
165 void LocalSession::boundaries()
167 zoom_sample = MAX(1, zoom_sample);
170 int LocalSession::load_defaults(Defaults *defaults)
172 loop_playback = defaults->get("LOOP_PLAYBACK", 0);
173 loop_start = defaults->get("LOOP_START", (double)0);
174 loop_end = defaults->get("LOOP_END", (double)0);
175 selectionstart = defaults->get("SELECTIONSTART", selectionstart);
176 selectionend = defaults->get("SELECTIONEND", selectionend);
177 // track_start = defaults->get("TRACK_START", 0);
178 // view_start = defaults->get("VIEW_START", 0);
179 zoom_sample = defaults->get("ZOOM_SAMPLE", 1);
180 zoom_y = defaults->get("ZOOMY", 64);
181 zoom_track = defaults->get("ZOOM_TRACK", 64);
182 red = defaults->get("RED", 0.0);
183 green = defaults->get("GREEN", 0.0);
184 blue = defaults->get("BLUE", 0.0);
185 automation_min = defaults->get("AUTOMATION_MIN", automation_min);
186 automation_max = defaults->get("AUTOMATION_MAX", automation_max);
190 int LocalSession::save_defaults(Defaults *defaults)
192 defaults->update("LOOP_PLAYBACK", loop_playback);
193 defaults->update("LOOP_START", loop_start);
194 defaults->update("LOOP_END", loop_end);
195 defaults->update("SELECTIONSTART", selectionstart);
196 defaults->update("SELECTIONEND", selectionend);
197 defaults->update("TRACK_START", track_start);
198 defaults->update("VIEW_START", view_start);
199 defaults->update("ZOOM_SAMPLE", zoom_sample);
200 defaults->update("ZOOMY", zoom_y);
201 defaults->update("ZOOM_TRACK", zoom_track);
202 defaults->update("RED", red);
203 defaults->update("GREEN", green);
204 defaults->update("BLUE", blue);
205 defaults->update("AUTOMATION_MIN", automation_min);
206 defaults->update("AUTOMATION_MAX", automation_max);
210 void LocalSession::set_selectionstart(double value)
212 this->selectionstart = value;
215 void LocalSession::set_selectionend(double value)
217 this->selectionend = value;
220 void LocalSession::set_inpoint(double value)
225 void LocalSession::set_outpoint(double value)
230 void LocalSession::unset_inpoint()
235 void LocalSession::unset_outpoint()
242 double LocalSession::get_selectionstart(int highlight_only)
244 if(highlight_only || !EQUIV(selectionstart, selectionend))
245 return selectionstart;
253 return selectionstart;
256 double LocalSession::get_selectionend(int highlight_only)
258 if(highlight_only || !EQUIV(selectionstart, selectionend))
270 double LocalSession::get_inpoint()
275 double LocalSession::get_outpoint()
280 int LocalSession::inpoint_valid()
282 return in_point >= 0;
285 int LocalSession::outpoint_valid()
287 return out_point >= 0;