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;
56 void VWindow::load_defaults()
60 int VWindow::create_objects()
62 //printf("VWindow::create_objects 1\n");
63 gui = new VWindowGUI(mwindow, this);
64 //printf("VWindow::create_objects 1\n");
65 gui->create_objects();
66 //printf("VWindow::create_objects 1\n");
68 playback_engine = new VPlayback(mwindow, this, gui->canvas);
69 //printf("VWindow::create_objects 1\n");
72 playback_engine->create_objects();
73 //printf("VWindow::create_objects 1\n");
74 gui->transport->set_engine(playback_engine);
75 //printf("VWindow::create_objects 1\n");
76 playback_cursor = new VTracking(mwindow, this);
77 //printf("VWindow::create_objects 1\n");
78 playback_cursor->create_objects();
79 //printf("VWindow::create_objects 2\n");
81 clip_edit = new ClipEdit(mwindow, 0, this);
90 EDL* VWindow::get_edl()
92 //printf("VWindow::get_edl 1 %p\n", edl);
93 return mwindow->edl->vwindow_edl;
96 Asset_GC VWindow::get_asset()
101 void VWindow::change_source()
103 //printf("VWindow::change_source() 1 %p\n", mwindow->edl->vwindow_edl);
104 if(mwindow->edl->vwindow_edl)
106 gui->change_source(get_edl(), get_edl()->local_session->clip_title);
107 update_position(CHANGE_ALL, 1, 1);
112 mwindow->edl->vwindow_edl_shared = 0;
116 void VWindow::change_source(Asset_GC asset)
118 //printf("VWindow::change_source 1\n");
119 // if(asset && this->asset &&
120 // asset->id == this->asset->id &&
121 // asset == this->asset) return;
123 //printf("VWindow::change_source(Asset_GC asset) 1\n");
125 char title[BCTEXTLEN];
127 fs.extract_name(title, asset->path);
128 //printf("VWindow::change_source 1\n");
131 //printf("VWindow::change_source 1\n");
133 // Generate EDL off of main EDL for cutting
134 this->asset = Asset_GC(new Asset);
135 *this->asset = *asset;
136 mwindow->edl->vwindow_edl = new EDL(mwindow->edl);
137 mwindow->edl->vwindow_edl_shared = 0;
138 mwindow->edl->vwindow_edl->create_objects();
139 mwindow->asset_to_edl(mwindow->edl->vwindow_edl, asset);
140 //printf("VWindow::change_source 1 %d %d\n", edl->local_session->loop_playback, mwindow->edl->local_session->loop_playback);
144 gui->change_source(mwindow->edl->vwindow_edl, title);
145 update_position(CHANGE_ALL, 1, 1);
148 // Update master session
149 strcpy(mwindow->edl->session->vwindow_folder, MEDIA_FOLDER);
150 mwindow->edl->session->vwindow_source = 0;
152 for(Assets_list::iterator current = mwindow->edl->assets->begin();
153 current == mwindow->edl->assets->end();
156 if(this->asset->equivalent(**current, 0, 0))
158 mwindow->edl->session->vwindow_source = i;
164 //printf("VWindow::change_source 2\n");
167 void VWindow::change_source(EDL *edl)
169 //printf("VWindow::change_source(EDL *edl) 1\n");
170 //printf("VWindow::change_source %p\n", edl);
171 // EDLs are identical
172 if(edl && mwindow->edl->vwindow_edl &&
173 edl->id == mwindow->edl->vwindow_edl->id) return;
180 mwindow->edl->vwindow_edl = edl;
181 // in order not to later delete edl if it is shared
182 mwindow->edl->vwindow_edl_shared = 1;
185 gui->change_source(edl, edl->local_session->clip_title);
186 update_position(CHANGE_ALL, 1, 1);
188 // Update master session
189 strcpy(mwindow->edl->session->vwindow_folder, CLIP_FOLDER);
190 mwindow->edl->session->vwindow_source =
191 mwindow->edl->clips.number_of(edl);
194 gui->change_source(edl, _("Viewer"));
198 void VWindow::remove_source()
201 gui->change_source(0, _("Viewer"));
204 void VWindow::change_source(char *folder, int item)
206 //printf("VWindow::change_source(char *folder, int item) 1\n");
209 if(!strcasecmp(folder, CLIP_FOLDER))
211 if(item < mwindow->edl->clips.total)
213 change_source(mwindow->edl->clips.values[item]);
219 if(!strcasecmp(folder, MEDIA_FOLDER))
221 if(item < mwindow->edl->assets->size())
223 Assets_list::iterator asset = mwindow->edl->assets->begin();
225 change_source(*asset);
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_GC asset = *edl->assets->begin();
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()
382 // c-file-style: "linux"