2 #include "awindowgui.h"
4 #include "cwindowgui.h"
8 #include "edlsession.h"
9 #include "filesystem.h"
11 #include "localsession.h"
12 #include "mainclock.h"
14 #include "samplescroll.h"
16 #include "maincursor.h"
20 #include "mwindowgui.h"
22 #include "pluginpopup.h"
23 #include "mainsession.h"
24 #include "statusbar.h"
27 #include "trackcanvas.h"
29 #include "trackscroll.h"
30 #include "transitionpopup.h"
32 #include "vwindowgui.h"
35 #define _(String) gettext(String)
36 #define gettext_noop(String) String
37 #define N_(String) gettext_noop (String)
39 // the main window uses its own private colormap for video
40 MWindowGUI::MWindowGUI(MWindow *mwindow)
41 : BC_Window(PROGRAM_NAME ": Program",
42 mwindow->session->mwindow_x,
43 mwindow->session->mwindow_y,
44 mwindow->session->mwindow_w,
45 mwindow->session->mwindow_h,
52 this->mwindow = mwindow;
60 MWindowGUI::~MWindowGUI()
65 if(samplescroll) delete samplescroll;
66 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()
167 //printf("MWindowGUI::create_objects 1\n");
168 set_icon(mwindow->theme->mwindow_icon);
170 //printf("MWindowGUI::create_objects 1\n");
173 add_subwindow(mainmenu = new MainMenu(mwindow, this));
174 //printf("MWindowGUI::create_objects 1\n");
176 mwindow->theme->get_mwindow_sizes(this, get_w(), get_h());
177 mwindow->theme->draw_mwindow_bg(this);
178 mainmenu->create_objects();
179 //printf("MWindowGUI::create_objects 1\n");
181 add_subwindow(mbuttons = new MButtons(mwindow, this));
182 mbuttons->create_objects();
183 //printf("MWindowGUI::create_objects 1\n");
185 add_subwindow(mwindow->timebar = timebar = new MTimeBar(mwindow,
187 mwindow->theme->mtimebar_x,
188 mwindow->theme->mtimebar_y,
189 mwindow->theme->mtimebar_w,
190 mwindow->theme->mtimebar_h));
191 timebar->create_objects();
192 //printf("MWindowGUI::create_objects 2\n");
194 add_subwindow(mwindow->patches = patchbay = new PatchBay(mwindow, this));
195 patchbay->create_objects();
196 //printf("MWindowGUI::create_objects 1\n");
200 //printf("MWindowGUI::create_objects 1\n");
201 mwindow->gui->add_subwindow(canvas = new TrackCanvas(mwindow, this));
202 canvas->create_objects();
203 //printf("MWindowGUI::create_objects 1\n");
205 add_subwindow(zoombar = new ZoomBar(mwindow, this));
206 zoombar->create_objects();
207 //printf("MWindowGUI::create_objects 1\n");
209 add_subwindow(statusbar = new StatusBar(mwindow, this));
210 statusbar->create_objects();
211 //printf("MWindowGUI::create_objects 1\n");
213 add_subwindow(mainclock = new MainClock(mwindow,
214 mwindow->theme->mclock_x,
215 mwindow->theme->mclock_y,
216 mwindow->theme->mclock_w));
217 mainclock->update(0);
219 //printf("MWindowGUI::create_objects 1\n");
221 cursor = new MainCursor(mwindow, this);
222 cursor->create_objects();
223 //printf("MWindowGUI::create_objects 1\n");
225 add_subwindow(edit_menu = new EditPopup(mwindow, this));
226 edit_menu->create_objects();
227 //printf("MWindowGUI::create_objects 1\n");
229 add_subwindow(plugin_menu = new PluginPopup(mwindow, this));
230 plugin_menu->create_objects();
231 //printf("MWindowGUI::create_objects 1\n");
233 add_subwindow(transition_menu = new TransitionPopup(mwindow, this));
234 transition_menu->create_objects();
235 //printf("MWindowGUI::create_objects 1\n");
238 //printf("MWindowGUI::create_objects 1\n");
242 void MWindowGUI::update_title(char *path)
245 char filename[BCTEXTLEN], string[BCTEXTLEN];
246 fs.extract_name(filename, path);
247 sprintf(string, PROGRAM_NAME ": %s", filename);
249 //printf("MWindowGUI::update_title %s\n", string);
253 void MWindowGUI::redraw_time_dependancies()
255 zoombar->redraw_time_dependancies();
257 mainclock->update(mwindow->edl->local_session->selectionstart);
260 int MWindowGUI::resize_event(int w, int h)
262 mwindow->session->mwindow_w = w;
263 mwindow->session->mwindow_h = h;
264 mwindow->theme->get_mwindow_sizes(this, w, h);
265 mwindow->theme->draw_mwindow_bg(this);
267 mainmenu->reposition_window(0, 0, w, mainmenu->get_h());
268 mbuttons->resize_event();
269 statusbar->resize_event();
270 timebar->resize_event();
271 patchbay->resize_event();
272 zoombar->resize_event();
274 canvas->resize_event();
279 void MWindowGUI::update(int scrollbars,
287 mwindow->edl->tracks->update_y_pixels(mwindow->theme);
288 if(scrollbars) this->get_scrollbars();
289 if(timebar) this->timebar->update();
290 if(zoombar) this->zoombar->update();
291 if(patchbay) this->patchbay->update();
292 if(clock) this->mainclock->update(mwindow->edl->local_session->selectionstart);
295 this->canvas->draw(canvas == 2);
296 this->cursor->show();
297 this->canvas->flash();
298 this->canvas->activate();
300 if(buttonbar) mbuttons->update();
303 int MWindowGUI::visible(int64_t x1, int64_t x2, int64_t view_x1, int64_t view_x2)
305 return (x1 >= view_x1 && x1 < view_x2) ||
306 (x2 > view_x1 && x2 <= view_x2) ||
307 (x1 <= view_x1 && x2 >= view_x2);
311 int MWindowGUI::show_message(char *message, int color)
313 //printf("MWindowGUI::show_message %s %d\n", message, color);
314 statusbar->status_text->set_color(color);
315 statusbar->status_text->update(message);
319 // Drag motion called from other window
320 int MWindowGUI::drag_motion()
322 if(get_hidden()) return 0;
324 canvas->drag_motion();
328 int MWindowGUI::drag_stop()
330 if(get_hidden()) return 0;
332 int result = canvas->drag_stop();
336 void MWindowGUI::default_positions()
338 //printf("MWindowGUI::default_positions 1\n");
339 mwindow->vwindow->gui->lock_window();
340 mwindow->cwindow->gui->lock_window();
341 mwindow->awindow->gui->lock_window();
343 // printf("MWindowGUI::default_positions 1 %d %d %d %d\n", mwindow->session->vwindow_x,
344 // mwindow->session->vwindow_y,
345 // mwindow->session->vwindow_w,
346 // mwindow->session->vwindow_h);
347 reposition_window(mwindow->session->mwindow_x,
348 mwindow->session->mwindow_y,
349 mwindow->session->mwindow_w,
350 mwindow->session->mwindow_h);
351 mwindow->vwindow->gui->reposition_window(mwindow->session->vwindow_x,
352 mwindow->session->vwindow_y,
353 mwindow->session->vwindow_w,
354 mwindow->session->vwindow_h);
355 mwindow->cwindow->gui->reposition_window(mwindow->session->cwindow_x,
356 mwindow->session->cwindow_y,
357 mwindow->session->cwindow_w,
358 mwindow->session->cwindow_h);
359 mwindow->awindow->gui->reposition_window(mwindow->session->awindow_x,
360 mwindow->session->awindow_y,
361 mwindow->session->awindow_w,
362 mwindow->session->awindow_h);
363 //printf("MWindowGUI::default_positions 1\n");
365 resize_event(mwindow->session->mwindow_w,
366 mwindow->session->mwindow_h);
367 //printf("MWindowGUI::default_positions 1\n");
368 mwindow->vwindow->gui->resize_event(mwindow->session->vwindow_w,
369 mwindow->session->vwindow_h);
370 //printf("MWindowGUI::default_positions 1\n");
371 mwindow->cwindow->gui->resize_event(mwindow->session->cwindow_w,
372 mwindow->session->cwindow_h);
373 //printf("MWindowGUI::default_positions 1\n");
374 mwindow->awindow->gui->resize_event(mwindow->session->awindow_w,
375 mwindow->session->awindow_h);
377 //printf("MWindowGUI::default_positions 1\n");
380 mwindow->vwindow->gui->flush();
381 mwindow->cwindow->gui->flush();
382 mwindow->awindow->gui->flush();
384 mwindow->vwindow->gui->unlock_window();
385 mwindow->cwindow->gui->unlock_window();
386 mwindow->awindow->gui->unlock_window();
387 //printf("MWindowGUI::default_positions 2\n");
406 int MWindowGUI::repeat_event(int64_t duration)
408 return cursor->repeat_event(duration);
412 int MWindowGUI::translation_event()
414 //printf("MWindowGUI::translation_event 1 %d %d\n", get_x(), get_y());
415 mwindow->session->mwindow_x = get_x();
416 mwindow->session->mwindow_y = get_y();
421 int MWindowGUI::save_defaults(Defaults *defaults)
423 defaults->update("MWINDOWWIDTH", get_w());
424 defaults->update("MWINDOWHEIGHT", get_h());
425 mainmenu->save_defaults(defaults);
426 BC_WindowBase::save_defaults(defaults);
429 int MWindowGUI::keypress_event()
431 //printf("MWindowGUI::keypress_event 1 %d\n", get_keypress());
433 result = mbuttons->keypress_event();
438 int MWindowGUI::close_event()
443 int MWindowGUI::menu_h()
445 return mainmenu->get_h();