6 #include "edlsession.h"
7 #include "filesystem.h"
10 #include "localsession.h"
11 #include "mainclock.h"
13 #include "mwindowgui.h"
14 #include "playbackengine.h"
16 #include "transportque.h"
17 #include "vplayback.h"
19 #include "vtracking.h"
21 #include "vwindowgui.h"
24 VWindow::VWindow(MWindow *mwindow) : Thread()
26 this->mwindow = mwindow;
33 //printf("VWindow::~VWindow 1\n");
34 delete playback_engine;
35 //printf("VWindow::~VWindow 1\n");
36 delete playback_cursor;
39 //printf("VWindow::~VWindow 2\n");
42 void VWindow::delete_edl()
44 //printf("VWindow::delete_edl 1\n");
45 if(mwindow->edl->vwindow_edl)
48 delete mwindow->edl->vwindow_edl;
49 mwindow->edl->vwindow_edl = 0;
52 if(asset) delete asset;
58 void VWindow::load_defaults()
62 int VWindow::create_objects()
64 //printf("VWindow::create_objects 1\n");
65 gui = new VWindowGUI(mwindow, this);
66 //printf("VWindow::create_objects 1\n");
67 gui->create_objects();
68 //printf("VWindow::create_objects 1\n");
70 playback_engine = new VPlayback(mwindow, this, gui->canvas);
71 //printf("VWindow::create_objects 1\n");
74 playback_engine->create_objects();
75 //printf("VWindow::create_objects 1\n");
76 gui->transport->set_engine(playback_engine);
77 //printf("VWindow::create_objects 1\n");
78 playback_cursor = new VTracking(mwindow, this);
79 //printf("VWindow::create_objects 1\n");
80 playback_cursor->create_objects();
81 //printf("VWindow::create_objects 2\n");
83 clip_edit = new ClipEdit(mwindow, 0, this);
92 EDL* VWindow::get_edl()
94 //printf("VWindow::get_edl 1 %p\n", edl);
95 return mwindow->edl->vwindow_edl;
98 Asset* VWindow::get_asset()
103 void VWindow::change_source()
105 //printf("VWindow::change_source() 1 %p\n", mwindow->edl->vwindow_edl);
106 if(mwindow->edl->vwindow_edl)
108 gui->change_source(get_edl(), get_edl()->local_session->clip_title);
109 update_position(CHANGE_ALL, 1, 1);
113 if(asset) delete asset;
119 void VWindow::change_source(Asset *asset)
121 //printf("VWindow::change_source 1\n");
122 // if(asset && this->asset &&
123 // asset->id == this->asset->id &&
124 // asset == this->asset) return;
126 //printf("VWindow::change_source(Asset *asset) 1\n");
128 char title[BCTEXTLEN];
130 fs.extract_name(title, asset->path);
131 //printf("VWindow::change_source 1\n");
134 //printf("VWindow::change_source 1\n");
136 // Generate EDL off of main EDL for cutting
137 this->asset = new Asset;
138 *this->asset = *asset;
139 mwindow->edl->vwindow_edl = new EDL(mwindow->edl);
141 mwindow->edl->vwindow_edl->create_objects();
142 mwindow->asset_to_edl(mwindow->edl->vwindow_edl, asset);
143 //printf("VWindow::change_source 1 %d %d\n", edl->local_session->loop_playback, mwindow->edl->local_session->loop_playback);
147 gui->change_source(mwindow->edl->vwindow_edl, title);
148 update_position(CHANGE_ALL, 1, 1);
151 // Update master session
152 strcpy(mwindow->edl->session->vwindow_folder, MEDIA_FOLDER);
153 mwindow->edl->session->vwindow_source = 0;
155 for(Asset *current = mwindow->edl->assets->first;
159 if(this->asset->equivalent(*current, 0, 0))
161 mwindow->edl->session->vwindow_source = i;
167 //printf("VWindow::change_source 2\n");
170 void VWindow::change_source(EDL *edl)
172 //printf("VWindow::change_source(EDL *edl) 1\n");
173 //printf("VWindow::change_source %p\n", edl);
174 // EDLs are identical
175 if(edl && mwindow->edl->vwindow_edl &&
176 edl->id == mwindow->edl->vwindow_edl->id) return;
183 mwindow->edl->vwindow_edl = edl;
184 // in order not to later delete edl if it is shared
186 //printf("VWindow::change_source 1\n");
188 //printf("VWindow::change_source 2\n");
191 gui->change_source(edl, edl->local_session->clip_title);
192 update_position(CHANGE_ALL, 1, 1);
194 // Update master session
195 strcpy(mwindow->edl->session->vwindow_folder, CLIP_FOLDER);
196 mwindow->edl->session->vwindow_source =
197 mwindow->edl->clips.number_of(edl);
200 gui->change_source(edl, _("Viewer"));
204 void VWindow::remove_source()
207 gui->change_source(0, _("Viewer"));
210 void VWindow::change_source(char *folder, int item)
212 //printf("VWindow::change_source(char *folder, int item) 1\n");
215 if(!strcasecmp(folder, CLIP_FOLDER))
217 if(item < mwindow->edl->clips.total)
219 change_source(mwindow->edl->clips.values[item]);
225 if(!strcasecmp(folder, MEDIA_FOLDER))
227 if(item < mwindow->edl->assets->total())
229 change_source(mwindow->edl->assets->get_item_number(item));
234 // Search extra clip folders
247 void VWindow::goto_start()
251 get_edl()->local_session->selectionstart =
252 get_edl()->local_session->selectionend = 0;
253 update_position(CHANGE_NONE,
259 void VWindow::goto_end()
263 get_edl()->local_session->selectionstart =
264 get_edl()->local_session->selectionend =
265 get_edl()->tracks->total_length();
266 update_position(CHANGE_NONE,
272 void VWindow::update(int do_timebar)
275 gui->timebar->update();
278 void VWindow::update_position(int change_type,
282 EDL *edl = get_edl();
285 Asset *asset = edl->assets->first;
288 edl->local_session->selectionstart =
289 edl->local_session->selectionend =
290 gui->slider->get_value();
295 gui->slider->set_position();
298 playback_engine->que->send_command(CURRENT_FRAME,
303 gui->clock->update(edl->local_session->selectionstart +
305 (asset->video_data ? asset->frame_rate : asset->sample_rate));
309 void VWindow::set_inpoint()
311 EDL *edl = get_edl();
314 edl->set_inpoint(edl->local_session->selectionstart);
315 gui->timebar->update();
319 void VWindow::set_outpoint()
321 EDL *edl = get_edl();
324 edl->set_outpoint(edl->local_session->selectionstart);
325 gui->timebar->update();
329 void VWindow::clear_inpoint()
331 EDL *edl = get_edl();
334 edl->local_session->in_point = -1;
335 gui->timebar->update();
339 void VWindow::clear_outpoint()
341 EDL *edl = get_edl();
344 edl->local_session->out_point = -1;
345 gui->timebar->update();
351 EDL *edl = get_edl();
354 double start = edl->local_session->get_selectionstart();
355 double end = edl->local_session->get_selectionend();
366 mwindow->gui->lock_window();
367 mwindow->gui->get_clipboard()->to_clipboard(file.string,
369 SECONDARY_SELECTION);
370 mwindow->gui->unlock_window();
374 void VWindow::splice_selection()
378 void VWindow::overwrite_selection()