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 LocalSession::~LocalSession()
36 void LocalSession::copy_from(LocalSession *that)
38 strcpy(clip_title, that->clip_title);
39 strcpy(clip_notes, that->clip_notes);
40 strcpy(folder, that->folder);
41 in_point = that->in_point;
42 loop_playback = that->loop_playback;
43 loop_start = that->loop_start;
44 loop_end = that->loop_end;
45 out_point = that->out_point;
46 selectionend = that->selectionend;
47 selectionstart = that->selectionstart;
48 track_start = that->track_start;
49 view_start = that->view_start;
50 zoom_sample = that->zoom_sample;
51 zoom_y = that->zoom_y;
52 zoom_track = that->zoom_track;
53 preview_start = that->preview_start;
54 preview_end = that->preview_end;
57 void LocalSession::save_xml(FileXML *file, double start)
59 file->tag.set_title("LOCALSESSION");
61 file->tag.set_property("IN_POINT", in_point - start);
62 file->tag.set_property("LOOP_PLAYBACK", loop_playback);
63 file->tag.set_property("LOOP_START", loop_start - start);
64 file->tag.set_property("LOOP_END", loop_end - start);
65 file->tag.set_property("OUT_POINT", out_point - start);
66 file->tag.set_property("SELECTION_START", selectionstart - start);
67 file->tag.set_property("SELECTION_END", selectionend - start);
68 file->tag.set_property("CLIP_TITLE", clip_title);
69 file->tag.set_property("CLIP_NOTES", clip_notes);
70 file->tag.set_property("FOLDER", folder);
71 file->tag.set_property("TRACK_START", track_start);
72 file->tag.set_property("VIEW_START", view_start);
73 file->tag.set_property("ZOOM_SAMPLE", zoom_sample);
74 //printf("EDLSession::save_session 1\n");
75 file->tag.set_property("ZOOMY", zoom_y);
76 //printf("EDLSession::save_session 1 %d\n", zoom_track);
77 file->tag.set_property("ZOOM_TRACK", zoom_track);
79 double preview_start = this->preview_start - start;
80 if(preview_start < 0) preview_start = 0;
81 double preview_end = this->preview_end - start;
82 if(preview_end < 0) preview_end = 0;
84 file->tag.set_property("PREVIEW_START", preview_start);
85 file->tag.set_property("PREVIEW_END", preview_end);
87 file->tag.set_title("/LOCALSESSION");
89 file->append_newline();
90 file->append_newline();
93 void LocalSession::synchronize_params(LocalSession *that)
95 loop_playback = that->loop_playback;
96 loop_start = that->loop_start;
97 loop_end = that->loop_end;
98 preview_start = that->preview_start;
99 preview_end = that->preview_end;
103 void LocalSession::load_xml(FileXML *file, unsigned long load_flags)
105 if(load_flags & LOAD_SESSION)
107 clipboard_length = 0;
108 // Overwritten by MWindow::load_filenames
109 file->tag.get_property("CLIP_TITLE", clip_title);
110 file->tag.get_property("CLIP_NOTES", clip_notes);
111 file->tag.get_property("FOLDER", folder);
112 loop_playback = file->tag.get_property("LOOP_PLAYBACK", 0);
113 loop_start = file->tag.get_property("LOOP_START", (double)0);
114 loop_end = file->tag.get_property("LOOP_END", (double)0);
115 selectionstart = file->tag.get_property("SELECTION_START", (double)0);
116 selectionend = file->tag.get_property("SELECTION_END", (double)0);
117 track_start = file->tag.get_property("TRACK_START", track_start);
118 view_start = file->tag.get_property("VIEW_START", view_start);
119 zoom_sample = file->tag.get_property("ZOOM_SAMPLE", zoom_sample);
120 zoom_y = file->tag.get_property("ZOOMY", zoom_y);
121 zoom_track = file->tag.get_property("ZOOM_TRACK", zoom_track);
122 preview_start = file->tag.get_property("PREVIEW_START", preview_start);
123 preview_end = file->tag.get_property("PREVIEW_END", preview_end);
125 // on operations like cut, paste, slice, clear... we should also undo the cursor position as users
126 // expect - this is additionally important in keyboard-only editing in viewer window
127 if(load_flags & LOAD_SESSION || load_flags & LOAD_TIMEBAR)
129 selectionstart = file->tag.get_property("SELECTION_START", (double)0);
130 selectionend = file->tag.get_property("SELECTION_END", (double)0);
132 if(load_flags & LOAD_TIMEBAR)
134 in_point = file->tag.get_property("IN_POINT", (double)-1);
135 out_point = file->tag.get_property("OUT_POINT", (double)-1);
139 void LocalSession::boundaries()
141 zoom_sample = MAX(1, zoom_sample);
144 int LocalSession::load_defaults(Defaults *defaults)
146 loop_playback = defaults->get("LOOP_PLAYBACK", 0);
147 loop_start = defaults->get("LOOP_START", (double)0);
148 loop_end = defaults->get("LOOP_END", (double)0);
149 selectionstart = defaults->get("SELECTIONSTART", selectionstart);
150 selectionend = defaults->get("SELECTIONEND", selectionend);
151 // track_start = defaults->get("TRACK_START", 0);
152 // view_start = defaults->get("VIEW_START", 0);
153 zoom_sample = defaults->get("ZOOM_SAMPLE", 1);
154 zoom_y = defaults->get("ZOOMY", 64);
155 zoom_track = defaults->get("ZOOM_TRACK", 64);
159 int LocalSession::save_defaults(Defaults *defaults)
161 defaults->update("LOOP_PLAYBACK", loop_playback);
162 defaults->update("LOOP_START", loop_start);
163 defaults->update("LOOP_END", loop_end);
164 defaults->update("SELECTIONSTART", selectionstart);
165 defaults->update("SELECTIONEND", selectionend);
166 defaults->update("TRACK_START", track_start);
167 defaults->update("VIEW_START", view_start);
168 defaults->update("ZOOM_SAMPLE", zoom_sample);
169 defaults->update("ZOOMY", zoom_y);
170 defaults->update("ZOOM_TRACK", zoom_track);
171 // defaults->update("PREVIEW_START", preview_start);
172 // defaults->update("PREVIEW_END", preview_end);
177 // prefer a complete current selection over in/out points
178 double LocalSession::get_selectionstart()
180 if (selectionstart >= 0 &&
182 selectionstart != selectionend) {
183 return selectionstart;
194 return selectionstart;
197 double LocalSession::get_selectionend()
199 if (selectionstart >= 0 &&
201 selectionstart != selectionend) {