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 && !mwindow->edl->vwindow_edl_shared)
47 delete mwindow->edl->vwindow_edl;
48 mwindow->edl->vwindow_edl = 0;
49 mwindow->edl->vwindow_edl_shared = 0;
52 if(asset) Garbage::delete_object(asset);
57 void VWindow::load_defaults()
61 int VWindow::create_objects()
63 //printf("VWindow::create_objects 1\n");
64 gui = new VWindowGUI(mwindow, this);
65 //printf("VWindow::create_objects 1\n");
66 gui->create_objects();
67 //printf("VWindow::create_objects 1\n");
69 playback_engine = new VPlayback(mwindow, this, gui->canvas);
70 //printf("VWindow::create_objects 1\n");
73 playback_engine->create_objects();
74 //printf("VWindow::create_objects 1\n");
75 gui->transport->set_engine(playback_engine);
76 //printf("VWindow::create_objects 1\n");
77 playback_cursor = new VTracking(mwindow, this);
78 //printf("VWindow::create_objects 1\n");
79 playback_cursor->create_objects();
80 //printf("VWindow::create_objects 2\n");
82 clip_edit = new ClipEdit(mwindow, 0, this);
91 EDL* VWindow::get_edl()
93 //printf("VWindow::get_edl 1 %p\n", edl);
94 return mwindow->edl->vwindow_edl;
97 Asset* VWindow::get_asset()
102 void VWindow::change_source()
104 //printf("VWindow::change_source() 1 %p\n", mwindow->edl->vwindow_edl);
105 if(mwindow->edl->vwindow_edl)
107 gui->change_source(get_edl(), get_edl()->local_session->clip_title);
108 update_position(CHANGE_ALL, 1, 1);
112 if(asset) Garbage::delete_object(asset);
114 mwindow->edl->vwindow_edl_shared = 0;
118 void VWindow::change_source(Asset *asset)
120 //printf("VWindow::change_source 1\n");
121 // if(asset && this->asset &&
122 // asset->id == this->asset->id &&
123 // asset == this->asset) return;
125 //printf("VWindow::change_source(Asset *asset) 1\n");
127 char title[BCTEXTLEN];
129 fs.extract_name(title, asset->path);
130 //printf("VWindow::change_source 1\n");
133 //printf("VWindow::change_source 1\n");
135 // Generate EDL off of main EDL for cutting
136 this->asset = new Asset;
137 *this->asset = *asset;
138 mwindow->edl->vwindow_edl = new EDL(mwindow->edl);
139 mwindow->edl->vwindow_edl_shared = 0;
140 mwindow->edl->vwindow_edl->create_objects();
141 mwindow->asset_to_edl(mwindow->edl->vwindow_edl, asset);
142 //printf("VWindow::change_source 1 %d %d\n", edl->local_session->loop_playback, mwindow->edl->local_session->loop_playback);
146 gui->change_source(mwindow->edl->vwindow_edl, title);
147 update_position(CHANGE_ALL, 1, 1);
150 // Update master session
151 strcpy(mwindow->edl->session->vwindow_folder, MEDIA_FOLDER);
152 mwindow->edl->session->vwindow_source = 0;
154 for(Asset *current = mwindow->edl->assets->first;
158 if(this->asset->equivalent(*current, 0, 0))
160 mwindow->edl->session->vwindow_source = i;
166 //printf("VWindow::change_source 2\n");
169 void VWindow::change_source(EDL *edl)
171 //printf("VWindow::change_source(EDL *edl) 1\n");
172 //printf("VWindow::change_source %p\n", edl);
173 // EDLs are identical
174 if(edl && mwindow->edl->vwindow_edl &&
175 edl->id == mwindow->edl->vwindow_edl->id) return;
182 mwindow->edl->vwindow_edl = edl;
183 // in order not to later delete edl if it is shared
184 mwindow->edl->vwindow_edl_shared = 1;
187 gui->change_source(edl, edl->local_session->clip_title);
188 update_position(CHANGE_ALL, 1, 1);
190 // Update master session
191 strcpy(mwindow->edl->session->vwindow_folder, CLIP_FOLDER);
192 mwindow->edl->session->vwindow_source =
193 mwindow->edl->clips.number_of(edl);
196 gui->change_source(edl, _("Viewer"));
200 void VWindow::remove_source()
203 gui->change_source(0, _("Viewer"));
206 void VWindow::change_source(char *folder, int item)
208 //printf("VWindow::change_source(char *folder, int item) 1\n");
211 if(!strcasecmp(folder, CLIP_FOLDER))
213 if(item < mwindow->edl->clips.total)
215 change_source(mwindow->edl->clips.values[item]);
221 if(!strcasecmp(folder, MEDIA_FOLDER))
223 if(item < mwindow->edl->assets->total())
225 change_source(mwindow->edl->assets->get_item_number(item));
230 // Search extra clip folders
243 void VWindow::goto_start()
247 get_edl()->local_session->set_selectionstart(0);
248 get_edl()->local_session->set_selectionend(0);
249 update_position(CHANGE_NONE,
255 void VWindow::goto_end()
259 double position = get_edl()->tracks->total_length();
260 get_edl()->local_session->set_selectionstart(position);
261 get_edl()->local_session->set_selectionend(position);
262 update_position(CHANGE_NONE,
268 void VWindow::update(int do_timebar)
271 gui->timebar->update();
274 void VWindow::update_position(int change_type,
278 EDL *edl = get_edl();
281 Asset *asset = edl->assets->first;
284 edl->local_session->set_selectionstart(gui->slider->get_value());
285 edl->local_session->set_selectionend(gui->slider->get_value());
290 gui->slider->set_position();
293 playback_engine->que->send_command(CURRENT_FRAME,
298 gui->clock->update(edl->local_session->get_selectionstart(1) +
300 (asset->video_data ? asset->frame_rate : asset->sample_rate));
304 void VWindow::set_inpoint()
306 EDL *edl = get_edl();
309 edl->set_inpoint(edl->local_session->get_selectionstart(1));
310 gui->timebar->update();
314 void VWindow::set_outpoint()
316 EDL *edl = get_edl();
319 edl->set_outpoint(edl->local_session->get_selectionstart(1));
320 gui->timebar->update();
324 void VWindow::clear_inpoint()
326 EDL *edl = get_edl();
329 edl->local_session->unset_inpoint();
330 gui->timebar->update();
334 void VWindow::clear_outpoint()
336 EDL *edl = get_edl();
339 edl->local_session->unset_outpoint();
340 gui->timebar->update();
346 EDL *edl = get_edl();
349 double start = edl->local_session->get_selectionstart();
350 double end = edl->local_session->get_selectionend();
361 mwindow->gui->lock_window();
362 mwindow->gui->get_clipboard()->to_clipboard(file.string,
364 SECONDARY_SELECTION);
365 mwindow->gui->unlock_window();
369 void VWindow::splice_selection()
373 void VWindow::overwrite_selection()