5 #include "edlsession.h"
6 #include "filesystem.h"
8 #include "localsession.h"
11 #include "mwindowgui.h"
12 #include "playbackengine.h"
14 #include "transportque.h"
15 #include "vplayback.h"
17 #include "vtracking.h"
19 #include "vwindowgui.h"
22 #define _(String) gettext(String)
23 #define gettext_noop(String) String
24 #define N_(String) gettext_noop (String)
27 VWindow::VWindow(MWindow *mwindow) : Thread()
29 this->mwindow = mwindow;
37 //printf("VWindow::~VWindow 1\n");
38 delete playback_engine;
39 //printf("VWindow::~VWindow 1\n");
40 delete playback_cursor;
43 //printf("VWindow::~VWindow 2\n");
46 void VWindow::delete_edl()
48 //printf("VWindow::delete_edl 1\n");
49 if(mwindow->edl->vwindow_edl)
51 delete mwindow->edl->vwindow_edl;
52 mwindow->edl->vwindow_edl = 0;
55 if(asset) delete asset;
62 void VWindow::load_defaults()
66 int VWindow::create_objects()
68 //printf("VWindow::create_objects 1\n");
69 gui = new VWindowGUI(mwindow, this);
70 //printf("VWindow::create_objects 1\n");
71 gui->create_objects();
72 //printf("VWindow::create_objects 1\n");
74 playback_engine = new VPlayback(mwindow, this, gui->canvas);
75 //printf("VWindow::create_objects 1\n");
78 playback_engine->create_objects();
79 //printf("VWindow::create_objects 1\n");
80 gui->transport->set_engine(playback_engine);
81 //printf("VWindow::create_objects 1\n");
82 playback_cursor = new VTracking(mwindow, this);
83 //printf("VWindow::create_objects 1\n");
84 playback_cursor->create_objects();
85 //printf("VWindow::create_objects 2\n");
87 clip_edit = new ClipEdit(mwindow, 0, this);
96 EDL* VWindow::get_edl()
98 //printf("VWindow::get_edl 1 %p\n", edl);
102 Asset* VWindow::get_asset()
107 void VWindow::change_source()
109 //printf("VWindow::change_source() 1 %p\n", mwindow->edl->vwindow_edl);
110 if(mwindow->edl->vwindow_edl)
112 this->edl = mwindow->edl->vwindow_edl;
113 gui->change_source(edl, "");
114 update_position(CHANGE_ALL, 1, 1);
118 if(asset) delete asset;
125 void VWindow::change_source(Asset *asset)
127 //printf("VWindow::change_source 1\n");
128 // if(asset && this->asset &&
129 // asset->id == this->asset->id &&
130 // asset == this->asset) return;
132 //printf("VWindow::change_source(Asset *asset) 1\n");
134 char title[BCTEXTLEN];
136 fs.extract_name(title, asset->path);
137 //printf("VWindow::change_source 1\n");
140 //printf("VWindow::change_source 1\n");
142 // Generate EDL off of main EDL for cutting
143 this->asset = new Asset;
144 *this->asset = *asset;
145 edl = mwindow->edl->vwindow_edl = new EDL(mwindow->edl);
147 edl->create_objects();
148 mwindow->asset_to_edl(edl, asset);
149 //printf("VWindow::change_source 1 %d %d\n", edl->local_session->loop_playback, mwindow->edl->local_session->loop_playback);
153 gui->change_source(edl, title);
154 update_position(CHANGE_ALL, 1, 1);
157 // Update master session
158 strcpy(mwindow->edl->session->vwindow_folder, MEDIA_FOLDER);
159 mwindow->edl->session->vwindow_source = 0;
161 for(Asset *current = mwindow->edl->assets->first;
165 if(this->asset->equivalent(*current, 0, 0))
167 mwindow->edl->session->vwindow_source = i;
173 //printf("VWindow::change_source 2\n");
176 void VWindow::change_source(EDL *edl)
178 //printf("VWindow::change_source(EDL *edl) 1\n");
179 //printf("VWindow::change_source %p\n", edl);
180 // EDLs are identical
181 if(edl && mwindow->edl->vwindow_edl &&
182 edl->id == mwindow->edl->vwindow_edl->id) return;
191 //printf("VWindow::change_source 1\n");
193 //printf("VWindow::change_source 2\n");
196 gui->change_source(edl, edl->local_session->clip_title);
197 update_position(CHANGE_ALL, 1, 1);
199 // Update master session
200 strcpy(mwindow->edl->session->vwindow_folder, CLIP_FOLDER);
201 mwindow->edl->session->vwindow_source =
202 mwindow->edl->clips.number_of(edl);
205 gui->change_source(edl, _("Viewer"));
209 void VWindow::remove_source()
212 gui->change_source(0, _("Viewer"));
215 void VWindow::change_source(char *folder, int item)
217 //printf("VWindow::change_source(char *folder, int item) 1\n");
220 if(!strcasecmp(folder, CLIP_FOLDER))
222 if(item < mwindow->edl->clips.total)
224 change_source(mwindow->edl->clips.values[item]);
230 if(!strcasecmp(folder, MEDIA_FOLDER))
232 if(item < mwindow->edl->assets->total())
234 change_source(mwindow->edl->assets->get_item_number(item));
239 // Search extra clip folders
252 void VWindow::goto_start()
256 edl->local_session->selectionstart =
257 edl->local_session->selectionend = 0;
258 update_position(CHANGE_NONE,
264 void VWindow::goto_end()
268 edl->local_session->selectionstart =
269 edl->local_session->selectionend =
270 edl->tracks->total_length();
271 update_position(CHANGE_NONE,
277 void VWindow::update(int do_timebar)
280 gui->timebar->update();
283 void VWindow::update_position(int change_type,
287 EDL *edl = get_edl();
292 edl->local_session->selectionstart =
293 edl->local_session->selectionend =
294 gui->slider->get_value();
299 gui->slider->set_position();
302 playback_engine->que->send_command(CURRENT_FRAME,
307 gui->clock->update(edl->local_session->selectionstart);
311 void VWindow::set_inpoint()
313 EDL *edl = get_edl();
316 edl->set_inpoint(edl->local_session->selectionstart);
317 gui->timebar->update();
321 void VWindow::set_outpoint()
323 EDL *edl = get_edl();
326 edl->set_outpoint(edl->local_session->selectionstart);
327 gui->timebar->update();
331 void VWindow::clear_inpoint()
333 EDL *edl = get_edl();
336 edl->local_session->in_point = -1;
337 gui->timebar->update();
341 void VWindow::clear_outpoint()
343 EDL *edl = get_edl();
346 edl->local_session->out_point = -1;
347 gui->timebar->update();
353 EDL *edl = get_edl();
356 double start = edl->local_session->get_selectionstart();
357 double end = edl->local_session->get_selectionend();
368 mwindow->gui->lock_window();
369 mwindow->gui->get_clipboard()->to_clipboard(file.string,
371 SECONDARY_SELECTION);
372 mwindow->gui->unlock_window();
376 void VWindow::splice_selection()
380 void VWindow::overwrite_selection()