1 #include "awindowgui.h"
4 #include "cwindowgui.h"
9 #include "edlsession.h"
10 #include "filesystem.h"
11 #include "keyframepopup.h"
14 #include "localsession.h"
15 #include "mainclock.h"
16 #include "maincursor.h"
18 #include "mainsession.h"
22 #include "mwindowgui.h"
25 #include "pluginpopup.h"
26 #include "samplescroll.h"
27 #include "statusbar.h"
29 #include "trackcanvas.h"
30 #include "trackscroll.h"
32 #include "transitionpopup.h"
33 #include "vwindowgui.h"
37 // the main window uses its own private colormap for video
38 MWindowGUI::MWindowGUI(MWindow *mwindow)
39 : BC_Window(PROGRAM_NAME ": Program",
40 mwindow->session->mwindow_x,
41 mwindow->session->mwindow_y,
42 mwindow->session->mwindow_w,
43 mwindow->session->mwindow_h,
50 this->mwindow = mwindow;
58 MWindowGUI::~MWindowGUI()
63 if(samplescroll) delete samplescroll;
64 if(trackscroll) delete trackscroll;
72 delete transition_menu;
75 void MWindowGUI::get_scrollbars()
77 //printf("MWindowGUI::get_scrollbars 1\n");
78 int64_t h_needed = mwindow->edl->get_tracks_height(mwindow->theme);
79 int64_t w_needed = mwindow->edl->get_tracks_width();
82 view_w = mwindow->theme->mcanvas_w;
83 view_h = mwindow->theme->mcanvas_h;
84 //printf("MWindowGUI::get_scrollbars 1\n");
86 // Scrollbars are constitutive
87 need_xscroll = need_yscroll = 1;
88 view_h = mwindow->theme->mcanvas_h - BC_ScrollBar::get_span(SCROLL_VERT);
89 view_w = mwindow->theme->mcanvas_w - BC_ScrollBar::get_span(SCROLL_HORIZ);
91 // for(int i = 0; i < 2; i++)
93 // if(w_needed > view_w)
96 // view_h = mwindow->theme->mcanvas_h - SCROLL_SPAN;
101 // if(h_needed > view_h)
104 // view_w = mwindow->theme->mcanvas_w - SCROLL_SPAN;
109 //printf("MWindowGUI::get_scrollbars 1\n");
111 if(canvas && (view_w != canvas->get_w() || view_h != canvas->get_h()))
113 canvas->reposition_window(mwindow->theme->mcanvas_x,
114 mwindow->theme->mcanvas_y,
118 //printf("MWindowGUI::get_scrollbars 1\n");
123 add_subwindow(samplescroll = new SampleScroll(mwindow,
127 samplescroll->resize_event();
129 samplescroll->set_position();
133 if(samplescroll) delete samplescroll;
135 mwindow->edl->local_session->view_start = 0;
137 //printf("MWindowGUI::get_scrollbars 1\n");
141 //printf("MWindowGUI::get_scrollbars 1.1 %p %p\n", this, canvas);
143 add_subwindow(trackscroll = new TrackScroll(mwindow,
147 trackscroll->resize_event();
150 //printf("MWindowGUI::get_scrollbars 1.2\n");
151 trackscroll->update_length(mwindow->edl->get_tracks_height(mwindow->theme),
152 mwindow->edl->local_session->track_start,
154 //printf("MWindowGUI::get_scrollbars 1.3\n");
158 if(trackscroll) delete trackscroll;
160 mwindow->edl->local_session->track_start = 0;
162 //printf("get_scrollbars 2 %d %d\n", need_xscroll, w_needed);
165 int MWindowGUI::create_objects()
169 //printf("MWindowGUI::create_objects 1\n");
170 set_icon(mwindow->theme->mwindow_icon);
172 //printf("MWindowGUI::create_objects 1\n");
175 add_subwindow(mainmenu = new MainMenu(mwindow, this));
176 //printf("MWindowGUI::create_objects 1\n");
178 mwindow->theme->get_mwindow_sizes(this, get_w(), get_h());
179 mwindow->theme->draw_mwindow_bg(this);
180 mainmenu->create_objects();
181 //printf("MWindowGUI::create_objects 1\n");
183 add_subwindow(mbuttons = new MButtons(mwindow, this));
184 mbuttons->create_objects();
185 //printf("MWindowGUI::create_objects 1\n");
187 add_subwindow(mwindow->timebar = timebar = new MTimeBar(mwindow,
189 mwindow->theme->mtimebar_x,
190 mwindow->theme->mtimebar_y,
191 mwindow->theme->mtimebar_w,
192 mwindow->theme->mtimebar_h));
193 timebar->create_objects();
194 //printf("MWindowGUI::create_objects 2\n");
196 add_subwindow(mwindow->patches = patchbay = new PatchBay(mwindow, this));
197 patchbay->create_objects();
198 //printf("MWindowGUI::create_objects 1\n");
202 //printf("MWindowGUI::create_objects 1\n");
203 mwindow->gui->add_subwindow(canvas = new TrackCanvas(mwindow, this));
204 canvas->create_objects();
205 //printf("MWindowGUI::create_objects 1\n");
207 add_subwindow(zoombar = new ZoomBar(mwindow, this));
208 zoombar->create_objects();
209 //printf("MWindowGUI::create_objects 1\n");
211 add_subwindow(statusbar = new StatusBar(mwindow, this));
212 statusbar->create_objects();
213 //printf("MWindowGUI::create_objects 1\n");
215 add_subwindow(mainclock = new MainClock(mwindow,
216 mwindow->theme->mclock_x,
217 mwindow->theme->mclock_y,
218 mwindow->theme->mclock_w));
219 mainclock->set_frame_offset( (double)
220 (mwindow->edl->session->get_frame_offset() /
221 mwindow->edl->session->frame_rate));
222 mainclock->update(0);
224 //printf("MWindowGUI::create_objects 1\n");
226 cursor = new MainCursor(mwindow, this);
227 cursor->create_objects();
228 //printf("MWindowGUI::create_objects 1\n");
230 add_subwindow(edit_menu = new EditPopup(mwindow, this));
231 edit_menu->create_objects();
232 //printf("MWindowGUI::create_objects 1\n");
234 add_subwindow(plugin_menu = new PluginPopup(mwindow, this));
235 plugin_menu->create_objects();
236 //printf("MWindowGUI::create_objects 1\n");
238 add_subwindow(keyframe_menu = new KeyframePopup(mwindow, this));
239 keyframe_menu->create_objects();
241 add_subwindow(transition_menu = new TransitionPopup(mwindow, this));
242 transition_menu->create_objects();
243 //printf("MWindowGUI::create_objects 1\n");
246 //printf("MWindowGUI::create_objects 1\n");
250 void MWindowGUI::update_title(char *path)
253 char filename[BCTEXTLEN], string[BCTEXTLEN];
254 fs.extract_name(filename, path);
255 sprintf(string, PROGRAM_NAME ": %s", filename);
257 //printf("MWindowGUI::update_title %s\n", string);
261 void MWindowGUI::redraw_time_dependancies()
263 zoombar->redraw_time_dependancies();
265 mainclock->update(mwindow->edl->local_session->selectionstart);
268 int MWindowGUI::focus_in_event()
270 cursor->focus_in_event();
274 int MWindowGUI::focus_out_event()
276 cursor->focus_out_event();
281 int MWindowGUI::resize_event(int w, int h)
283 mwindow->session->mwindow_w = w;
284 mwindow->session->mwindow_h = h;
285 mwindow->theme->get_mwindow_sizes(this, w, h);
286 mwindow->theme->draw_mwindow_bg(this);
288 mainmenu->reposition_window(0, 0, w, mainmenu->get_h());
289 mbuttons->resize_event();
290 statusbar->resize_event();
291 timebar->resize_event();
292 patchbay->resize_event();
293 zoombar->resize_event();
295 canvas->resize_event();
300 void MWindowGUI::update(int scrollbars,
308 //TRACE("MWindowGUI::update 1");
309 mwindow->edl->tracks->update_y_pixels(mwindow->theme);
310 //TRACE("MWindowGUI::update 1");
311 if(scrollbars) this->get_scrollbars();
312 //TRACE("MWindowGUI::update 1");
313 if(timebar) this->timebar->update();
314 //TRACE("MWindowGUI::update 1");
315 if(zoombar) this->zoombar->update();
316 //TRACE("MWindowGUI::update 1");
317 if(patchbay) this->patchbay->update();
318 //TRACE("MWindowGUI::update 1");
319 if(clock) this->mainclock->update(mwindow->edl->local_session->selectionstart);
320 //TRACE("MWindowGUI::update 1");
323 this->canvas->draw(canvas == 2);
324 this->cursor->show();
325 this->canvas->flash();
326 this->canvas->activate();
328 //TRACE("MWindowGUI::update 1");
329 if(buttonbar) mbuttons->update();
330 //TRACE("MWindowGUI::update 100");
333 int MWindowGUI::visible(int64_t x1, int64_t x2, int64_t view_x1, int64_t view_x2)
335 return (x1 >= view_x1 && x1 < view_x2) ||
336 (x2 > view_x1 && x2 <= view_x2) ||
337 (x1 <= view_x1 && x2 >= view_x2);
341 int MWindowGUI::show_message(char *message, int color)
343 //printf("MWindowGUI::show_message %s %d\n", message, color);
344 statusbar->status_text->set_color(color);
345 statusbar->status_text->update(message);
349 // Drag motion called from other window
350 int MWindowGUI::drag_motion()
352 if(get_hidden()) return 0;
354 canvas->drag_motion();
358 int MWindowGUI::drag_stop()
360 if(get_hidden()) return 0;
362 int result = canvas->drag_stop();
366 void MWindowGUI::default_positions()
368 //printf("MWindowGUI::default_positions 1\n");
369 mwindow->vwindow->gui->lock_window("MWindowGUI::default_positions");
370 mwindow->cwindow->gui->lock_window("MWindowGUI::default_positions");
371 mwindow->awindow->gui->lock_window("MWindowGUI::default_positions");
373 // printf("MWindowGUI::default_positions 1 %d %d %d %d\n", mwindow->session->vwindow_x,
374 // mwindow->session->vwindow_y,
375 // mwindow->session->vwindow_w,
376 // mwindow->session->vwindow_h);
377 reposition_window(mwindow->session->mwindow_x,
378 mwindow->session->mwindow_y,
379 mwindow->session->mwindow_w,
380 mwindow->session->mwindow_h);
381 mwindow->vwindow->gui->reposition_window(mwindow->session->vwindow_x,
382 mwindow->session->vwindow_y,
383 mwindow->session->vwindow_w,
384 mwindow->session->vwindow_h);
385 mwindow->cwindow->gui->reposition_window(mwindow->session->cwindow_x,
386 mwindow->session->cwindow_y,
387 mwindow->session->cwindow_w,
388 mwindow->session->cwindow_h);
389 mwindow->awindow->gui->reposition_window(mwindow->session->awindow_x,
390 mwindow->session->awindow_y,
391 mwindow->session->awindow_w,
392 mwindow->session->awindow_h);
393 //printf("MWindowGUI::default_positions 1\n");
395 resize_event(mwindow->session->mwindow_w,
396 mwindow->session->mwindow_h);
397 //printf("MWindowGUI::default_positions 1\n");
398 mwindow->vwindow->gui->resize_event(mwindow->session->vwindow_w,
399 mwindow->session->vwindow_h);
400 //printf("MWindowGUI::default_positions 1\n");
401 mwindow->cwindow->gui->resize_event(mwindow->session->cwindow_w,
402 mwindow->session->cwindow_h);
403 //printf("MWindowGUI::default_positions 1\n");
404 mwindow->awindow->gui->resize_event(mwindow->session->awindow_w,
405 mwindow->session->awindow_h);
407 //printf("MWindowGUI::default_positions 1\n");
410 mwindow->vwindow->gui->flush();
411 mwindow->cwindow->gui->flush();
412 mwindow->awindow->gui->flush();
414 mwindow->vwindow->gui->unlock_window();
415 mwindow->cwindow->gui->unlock_window();
416 mwindow->awindow->gui->unlock_window();
417 //printf("MWindowGUI::default_positions 2\n");
436 int MWindowGUI::repeat_event(int64_t duration)
438 // if(duration == 100)
439 // mwindow->sync_parameters(CHANGE_ALL);
440 return cursor->repeat_event(duration);
444 int MWindowGUI::translation_event()
446 //printf("MWindowGUI::translation_event 1 %d %d\n", get_x(), get_y());
447 mwindow->session->mwindow_x = get_x();
448 mwindow->session->mwindow_y = get_y();
453 int MWindowGUI::save_defaults(Defaults *defaults)
455 defaults->update("MWINDOWWIDTH", get_w());
456 defaults->update("MWINDOWHEIGHT", get_h());
457 mainmenu->save_defaults(defaults);
458 BC_WindowBase::save_defaults(defaults);
461 int MWindowGUI::keypress_event()
463 //printf("MWindowGUI::keypress_event 1 %d\n", get_keypress());
465 result = mbuttons->keypress_event();
470 int MWindowGUI::close_event()
475 int MWindowGUI::menu_h()
477 return mainmenu->get_h();