4 * Copyright (C) 1997-2014 Adam Williams <broadcast at earthling dot net>
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 #include "androidcontrol.h"
23 #include "awindowgui.h"
25 #include "bcdisplayinfo.h"
27 #include "bcsignals.h"
29 #include "cwindowgui.h"
31 #include "channelinfo.h"
34 #include "editpopup.h"
37 #include "edlsession.h"
38 #include "filesystem.h"
40 #include "keyframepopup.h"
43 #include "localsession.h"
44 #include "mainclock.h"
45 #include "maincursor.h"
47 #include "mainsession.h"
51 #include "mwindowgui.h"
53 #include "panedividers.h"
56 #include "pluginpopup.h"
57 #include "pluginset.h"
58 #include "preferences.h"
60 #include "recordgui.h"
61 #include "renderengine.h"
62 #include "resourcethread.h"
63 #include "samplescroll.h"
64 #include "shbtnprefs.h"
65 #include "statusbar.h"
68 #include "trackcanvas.h"
69 #include "trackpopup.h"
70 #include "trackscroll.h"
72 #include "transitionpopup.h"
73 #include "vwindowgui.h"
77 #define PANE_DRAG_MARGIN MAX(mwindow->theme->pane_w, mwindow->theme->pane_h)
80 // the main window uses its own private colormap for video
81 MWindowGUI::MWindowGUI(MWindow *mwindow)
82 : BC_Window(_(PROGRAM_NAME ": Program"),
83 mwindow->session->mwindow_x,
84 mwindow->session->mwindow_y,
85 mwindow->session->mwindow_w,
86 mwindow->session->mwindow_h,
93 this->mwindow = mwindow;
100 focused_pane = TOP_LEFT_PANE;
109 for(int i = 0; i < TOTAL_PANES; i++)
129 cwindow_remote_handler = 0;
130 record_remote_handler = 0;
135 MWindowGUI::~MWindowGUI()
137 delete android_control;
138 delete cwindow_remote_handler;
139 delete record_remote_handler;
140 delete remote_control;
141 delete keyvalue_popup;
142 // delete samplescroll;
143 // delete trackscroll;
144 for(int i = 0; i < TOTAL_PANES; i++)
145 if(pane[i]) delete pane[i];
147 delete render_engine;
148 delete resource_thread;
149 resource_pixmaps.remove_all_objects();
160 void MWindowGUI::get_scrollbars(int flush)
162 //int64_t h_needed = mwindow->edl->get_tracks_height(mwindow->theme);
163 //int64_t w_needed = mwindow->edl->get_tracks_width();
164 int need_xscroll = 0;
165 int need_yscroll = 0;
166 view_w = mwindow->theme->mcanvas_w;
167 view_h = mwindow->theme->mcanvas_h;
169 // Scrollbars are constitutive
170 need_xscroll = need_yscroll = 1;
171 view_h = mwindow->theme->mcanvas_h;
172 view_w = mwindow->theme->mcanvas_w;
174 // for(int i = 0; i < 2; i++)
176 // if(w_needed > view_w)
179 // view_h = mwindow->theme->mcanvas_h - SCROLL_SPAN;
184 // if(h_needed > view_h)
187 // view_w = mwindow->theme->mcanvas_w - SCROLL_SPAN;
192 //printf("MWindowGUI::get_scrollbars 1\n");
194 if(canvas && (view_w != canvas->get_w() || view_h != canvas->get_h()))
196 canvas->reposition_window(mwindow->theme->mcanvas_x,
197 mwindow->theme->mcanvas_y,
205 add_subwindow(samplescroll = new SampleScroll(mwindow,
207 mwindow->theme->mhscroll_x,
208 mwindow->theme->mhscroll_y,
209 mwindow->theme->mhscroll_w));
211 samplescroll->resize_event();
213 samplescroll->set_position(0);
217 if(samplescroll) delete samplescroll;
219 mwindow->edl->local_session->view_start = 0;
225 //printf("MWindowGUI::get_scrollbars 1.1 %p %p\n", this, canvas);
227 add_subwindow(trackscroll = new TrackScroll(mwindow,
229 mwindow->theme->mvscroll_x,
230 mwindow->theme->mvscroll_y,
231 mwindow->theme->mvscroll_h));
233 trackscroll->resize_event();
236 //printf("MWindowGUI::get_scrollbars 1.2\n");
237 trackscroll->update_length(mwindow->edl->get_tracks_height(mwindow->theme),
238 mwindow->edl->local_session->track_start,
241 //printf("MWindowGUI::get_scrollbars 1.3\n");
245 if(trackscroll) delete trackscroll;
247 mwindow->edl->local_session->track_start = 0;
250 if(flush) this->flush();
255 void MWindowGUI::create_objects()
257 lock_window("MWindowGUI::create_objects");
260 resource_thread = new ResourceThread(mwindow, this);
261 resource_thread->create_objects();
264 if(debug) printf("MWindowGUI::create_objects %d\n", __LINE__);
265 set_icon(mwindow->theme->get_image("mwindow_icon"));
266 remote_control = new RemoteControl(this);
267 cwindow_remote_handler = new CWindowRemoteHandler(remote_control);
268 record_remote_handler = new RecordRemoteHandler(remote_control);
269 mwindow->reset_android_remote();
271 if(debug) printf("MWindowGUI::create_objects %d\n", __LINE__);
273 int x = get_w() - MainShBtns::calculate_w(-1, 0, -1);
274 add_subwindow(mainmenu = new MainMenu(mwindow, this, x));
275 mainmenu->create_objects();
276 add_subwindow(mainshbtns = new MainShBtns(mwindow, x, -1));
277 mainshbtns->load(mwindow->preferences);
278 mwindow->theme->get_mwindow_sizes(this, get_w(), get_h());
279 mwindow->theme->draw_mwindow_bg(this);
280 if(debug) printf("MWindowGUI::create_objects %d\n", __LINE__);
282 add_subwindow(mbuttons = new MButtons(mwindow, this));
283 mbuttons->create_objects();
284 int x1 = mbuttons->get_x() + mbuttons->get_w(), y1 = mbuttons->get_y()+2;
285 add_subwindow(proxy_toggle = new ProxyToggle(mwindow, mbuttons, x1, y1));
286 x1 += proxy_toggle->get_w() + 3;
287 add_subwindow(ffmpeg_toggle = new FFMpegToggle(mwindow, mbuttons, x1, y1));
289 pane[TOP_LEFT_PANE] = new TimelinePane(mwindow,
291 mwindow->theme->mcanvas_x,
292 mwindow->theme->mcanvas_y,
293 mwindow->theme->mcanvas_w,
294 mwindow->theme->mcanvas_h);
295 pane[TOP_LEFT_PANE]->create_objects();
297 // add_subwindow(timebar = new MTimeBar(mwindow,
299 // mwindow->theme->mtimebar_x,
300 // mwindow->theme->mtimebar_y,
301 // mwindow->theme->mtimebar_w,
302 // mwindow->theme->mtimebar_h));
303 // timebar->create_objects();
305 // if(debug) printf("MWindowGUI::create_objects %d\n", __LINE__);
306 // add_subwindow(patchbay = new PatchBay(mwindow, this));
307 // patchbay->create_objects();
309 // if(debug) printf("MWindowGUI::create_objects %d\n", __LINE__);
310 // get_scrollbars(0);
312 // if(debug) printf("MWindowGUI::create_objects %d\n", __LINE__);
313 // mwindow->gui->add_subwindow(canvas = new TrackCanvas(mwindow, this));
314 // canvas->create_objects();
317 if(debug) printf("MWindowGUI::create_objects %d\n", __LINE__);
318 add_subwindow(zoombar = new ZoomBar(mwindow, this));
319 zoombar->create_objects();
322 if(debug) printf("MWindowGUI::create_objects %d\n", __LINE__);
323 add_subwindow(statusbar = new StatusBar(mwindow, this));
324 statusbar->create_objects();
328 if(debug) printf("MWindowGUI::create_objects %d\n", __LINE__);
329 add_subwindow(mainclock = new MainClock(mwindow,
330 mwindow->theme->mclock_x, mwindow->theme->mclock_y,
331 mwindow->theme->mclock_w));
332 if(debug) printf("MWindowGUI::create_objects %d\n", __LINE__);
333 mainclock->update(0);
337 // if(debug) printf("MWindowGUI::create_objects %d\n", __LINE__);
338 // cursor = new MainCursor(mwindow, this);
339 // cursor->create_objects();
342 if(debug) printf("MWindowGUI::create_objects %d\n", __LINE__);
343 add_subwindow(track_menu = new TrackPopup(mwindow, this));
344 track_menu->create_objects();
345 if(debug) printf("MWindowGUI::create_objects %d\n", __LINE__);
346 add_subwindow(edit_menu = new EditPopup(mwindow, this));
347 edit_menu->create_objects();
350 if(debug) printf("MWindowGUI::create_objects %d\n", __LINE__);
351 add_subwindow(plugin_menu = new PluginPopup(mwindow, this));
352 plugin_menu->create_objects();
355 if(debug) printf("MWindowGUI::create_objects %d\n", __LINE__);
356 add_subwindow(keyframe_menu = new KeyframePopup(mwindow, this));
357 keyframe_menu->create_objects();
358 add_subwindow(keyframe_hide = new KeyframeHidePopup(mwindow, this));
359 keyframe_hide->create_objects();
362 if(debug) printf("MWindowGUI::create_objects %d\n", __LINE__);
363 add_subwindow(transition_menu = new TransitionPopup(mwindow, this));
364 transition_menu->create_objects();
367 channel_info = new ChannelInfo(mwindow);
369 #ifdef HAVE_COMMERCIAL
370 db_window = new DbWindow(mwindow);
372 swindow = new SWindow(mwindow);
374 if(debug) printf("MWindowGUI::create_objects %d\n", __LINE__);
376 add_subwindow(pane_button = new PaneButton(mwindow,
377 get_w() - mwindow->theme->get_image_set("pane")[0]->get_w(),
378 mwindow->theme->mzoom_y + 1 - mwindow->theme->get_image_set("pane")[0]->get_h()));
380 pane[TOP_LEFT_PANE]->canvas->activate();
382 if(debug) printf("MWindowGUI::create_objects %d\n", __LINE__);
386 void MWindowGUI::redraw_time_dependancies()
388 zoombar->redraw_time_dependancies();
389 for(int i = 0; i < TOTAL_PANES; i++)
390 if(pane[i] && pane[i]->timebar) pane[i]->timebar->update(0);
391 mainclock->update(mwindow->edl->local_session->get_selectionstart(1));
394 int MWindowGUI::focus_in_event()
396 for(int i = 0; i < TOTAL_PANES; i++)
397 if(pane[i]) pane[i]->cursor->focus_in_event();
401 int MWindowGUI::focus_out_event()
403 for(int i = 0; i < TOTAL_PANES; i++)
404 if(pane[i]) pane[i]->cursor->focus_out_event();
409 int MWindowGUI::resize_event(int w, int h)
411 //printf("MWindowGUI::resize_event %d\n", __LINE__);
412 mwindow->session->mwindow_w = w;
413 mwindow->session->mwindow_h = h;
414 int x = w - MainShBtns::calculate_w(-1, 0, -1);
415 mainmenu->resize_event(x, mainmenu->get_h());
416 mainshbtns->reposition_window(x, -1);
417 mwindow->theme->get_mwindow_sizes(this, w, h);
418 mwindow->theme->draw_mwindow_bg(this);
419 mbuttons->resize_event();
420 int x1 = mbuttons->get_x() + mbuttons->get_w(), y1 = mbuttons->get_y()+2;
421 proxy_toggle->reposition_window(x1, y1);
422 x1 += proxy_toggle->get_w() + 3;
423 ffmpeg_toggle->reposition_window(x1, y1);
424 statusbar->resize_event();
425 zoombar->resize_event();
427 resource_thread->stop_draw(1);
429 if(total_panes() > 1)
431 if(horizontal_panes())
433 // printf("MWindowGUI::resize_event %d %d %d\n",
435 // pane[TOP_RIGHT_PANE]->x,
436 // mwindow->theme->mcanvas_w -
437 // BC_ScrollBar::get_span(SCROLL_VERT) -
438 // PANE_DRAG_MARGIN);
439 if(pane[TOP_RIGHT_PANE]->x >= mwindow->theme->mcanvas_w -
440 BC_ScrollBar::get_span(SCROLL_VERT) -
443 delete_x_pane(pane[TOP_RIGHT_PANE]->x);
444 mwindow->edl->local_session->x_pane = -1;
450 if(pane[BOTTOM_LEFT_PANE]->y >= mwindow->theme->mzoom_y -
451 BC_ScrollBar::get_span(SCROLL_HORIZ) -
454 delete_y_pane(pane[BOTTOM_LEFT_PANE]->y);
455 mwindow->edl->local_session->y_pane = -1;
460 if(pane[TOP_RIGHT_PANE]->x >= mwindow->theme->mcanvas_w -
461 BC_ScrollBar::get_span(SCROLL_VERT) -
464 delete_x_pane(pane[TOP_RIGHT_PANE]->x);
465 mwindow->edl->local_session->x_pane = -1;
468 if(pane[BOTTOM_LEFT_PANE]->y >= mwindow->theme->mzoom_y -
469 BC_ScrollBar::get_span(SCROLL_HORIZ) -
472 delete_y_pane(pane[BOTTOM_LEFT_PANE]->y);
473 mwindow->edl->local_session->y_pane = -1;
478 if(total_panes() == 1)
480 pane[TOP_LEFT_PANE]->resize_event(
481 mwindow->theme->mcanvas_x,
482 mwindow->theme->mcanvas_y,
483 mwindow->theme->mcanvas_w,
484 mwindow->theme->mcanvas_h);
487 if(horizontal_panes())
489 pane[TOP_LEFT_PANE]->resize_event(
490 pane[TOP_LEFT_PANE]->x,
491 pane[TOP_LEFT_PANE]->y,
492 pane[TOP_LEFT_PANE]->w,
493 mwindow->theme->mcanvas_h);
494 pane[TOP_RIGHT_PANE]->resize_event(
495 pane[TOP_RIGHT_PANE]->x,
496 pane[TOP_RIGHT_PANE]->y,
497 mwindow->theme->mcanvas_w - pane[TOP_RIGHT_PANE]->x,
498 mwindow->theme->mcanvas_h);
503 pane[TOP_LEFT_PANE]->resize_event(
504 pane[TOP_LEFT_PANE]->x,
505 pane[TOP_LEFT_PANE]->y,
506 mwindow->theme->mcanvas_w,
507 pane[TOP_LEFT_PANE]->h);
508 pane[BOTTOM_LEFT_PANE]->resize_event(
509 pane[BOTTOM_LEFT_PANE]->x,
510 pane[BOTTOM_LEFT_PANE]->y,
511 mwindow->theme->mcanvas_w,
512 mwindow->theme->mcanvas_y +
513 mwindow->theme->mcanvas_h -
514 pane[BOTTOM_LEFT_PANE]->y);
518 pane[TOP_LEFT_PANE]->resize_event(
519 pane[TOP_LEFT_PANE]->x,
520 pane[TOP_LEFT_PANE]->y,
521 pane[TOP_LEFT_PANE]->w,
522 pane[TOP_LEFT_PANE]->h);
523 pane[TOP_RIGHT_PANE]->resize_event(
524 pane[TOP_RIGHT_PANE]->x,
525 pane[TOP_RIGHT_PANE]->y,
526 mwindow->theme->mcanvas_w - pane[TOP_RIGHT_PANE]->x,
527 pane[TOP_RIGHT_PANE]->h);
528 pane[BOTTOM_LEFT_PANE]->resize_event(
529 pane[BOTTOM_LEFT_PANE]->x,
530 pane[BOTTOM_LEFT_PANE]->y,
531 pane[BOTTOM_LEFT_PANE]->w,
532 mwindow->theme->mcanvas_y +
533 mwindow->theme->mcanvas_h -
534 pane[BOTTOM_LEFT_PANE]->y);
535 pane[BOTTOM_RIGHT_PANE]->resize_event(
536 pane[BOTTOM_RIGHT_PANE]->x,
537 pane[BOTTOM_RIGHT_PANE]->y,
538 mwindow->theme->mcanvas_w -
539 pane[BOTTOM_RIGHT_PANE]->x,
540 mwindow->theme->mcanvas_y +
541 mwindow->theme->mcanvas_h -
542 pane[BOTTOM_RIGHT_PANE]->y);
545 update_pane_dividers();
546 pane_button->reposition_window(w - mwindow->theme->get_image_set("pane")[0]->get_w(),
547 mwindow->theme->mzoom_y + 1 - mwindow->theme->get_image_set("pane")[0]->get_h());
548 resource_thread->start_draw();
554 int MWindowGUI::total_panes()
557 for(int i = 0; i < TOTAL_PANES; i++)
562 int MWindowGUI::vertical_panes()
564 return total_panes() == 2 &&
565 pane[TOP_LEFT_PANE] &&
566 pane[BOTTOM_LEFT_PANE];
569 int MWindowGUI::horizontal_panes()
571 return total_panes() == 2 &&
572 pane[TOP_LEFT_PANE] &&
573 pane[TOP_RIGHT_PANE];
576 TimelinePane* MWindowGUI::get_focused_pane()
578 if(pane[focused_pane]) return pane[focused_pane];
579 for(int i = 0; i < TOTAL_PANES; i++)
581 if(pane[i]) return pane[i];
586 void MWindowGUI::activate_timeline()
588 if(pane[focused_pane])
590 pane[focused_pane]->activate();
594 for(int i = 0; i < TOTAL_PANES; i++)
605 void MWindowGUI::deactivate_timeline()
607 for(int i = 0; i < TOTAL_PANES; i++)
611 pane[i]->canvas->deactivate();
616 void MWindowGUI::update_title(char *path)
619 char filename[BCTEXTLEN], string[BCTEXTLEN];
620 fs.extract_name(filename, path);
621 sprintf(string, _(PROGRAM_NAME ": %s"), filename);
623 //printf("MWindowGUI::update_title %s\n", string);
627 void MWindowGUI::draw_overlays(int flash_it)
629 for(int i = 0; i < TOTAL_PANES; i++)
633 pane[i]->canvas->draw_overlays();
634 if(flash_it) pane[i]->canvas->flash();
639 void MWindowGUI::update_timebar(int flush_it)
641 for(int i = 0; i < TOTAL_PANES; i++)
643 if(pane[i] && pane[i]->timebar)
645 pane[i]->timebar->update(flush_it);
650 void MWindowGUI::update_timebar_highlights()
652 for(int i = 0; i < TOTAL_PANES; i++)
654 if(pane[i] && pane[i]->timebar)
656 pane[i]->timebar->update_highlights();
662 void MWindowGUI::update_patchbay()
664 for(int i = 0; i < TOTAL_PANES; i++)
666 if(pane[i] && pane[i]->patchbay)
668 pane[i]->patchbay->update();
673 void MWindowGUI::update_proxy_toggle()
675 int value = mwindow->edl->session->proxy_scale == 1 ? 1 : 0;
676 proxy_toggle->set_value(value);
677 if( mwindow->edl->session->proxy_scale == 1 &&
678 mwindow->edl->session->proxy_disabled_scale == 1 )
679 proxy_toggle->hide();
681 proxy_toggle->show();
684 void MWindowGUI::update_plugintoggles()
686 for(int i = 0; i < TOTAL_PANES; i++)
690 pane[i]->canvas->refresh_plugintoggles();
696 void MWindowGUI::draw_indexes(Indexable *indexable)
698 for(int i = 0; i < TOTAL_PANES; i++)
702 pane[i]->canvas->draw_indexes(indexable);
707 void MWindowGUI::draw_canvas(int redraw, int hide_cursor)
709 resource_thread->stop_draw(0);
711 int mode = redraw ? FORCE_REDRAW : NORMAL_DRAW;
712 for(int i = 0; i < TOTAL_PANES; i++) {
714 pane[i]->canvas->draw(mode, hide_cursor);
717 resource_thread->start_draw();
720 void MWindowGUI::flash_canvas(int flush)
722 for(int i = 0; i < TOTAL_PANES; i++)
726 pane[i]->canvas->flash(flush);
731 int MWindowGUI::show_window(int flush)
733 int ret = BC_WindowBase::show_window(flush);
734 update_proxy_toggle();
738 void MWindowGUI::draw_cursor(int do_plugintoggles)
740 for(int i = 0; i < TOTAL_PANES; i++)
744 pane[i]->cursor->draw(do_plugintoggles);
749 void MWindowGUI::show_cursor(int do_plugintoggles)
751 for(int i = 0; i < TOTAL_PANES; i++)
755 pane[i]->cursor->show(do_plugintoggles);
760 void MWindowGUI::hide_cursor(int do_plugintoggles)
762 for(int i = 0; i < TOTAL_PANES; i++)
766 pane[i]->cursor->hide(do_plugintoggles);
771 void MWindowGUI::update_cursor()
773 for(int i = 0; i < TOTAL_PANES; i++)
777 pane[i]->cursor->update();
782 void MWindowGUI::set_playing_back(int value)
784 for(int i = 0; i < TOTAL_PANES; i++)
788 pane[i]->cursor->playing_back = value;
793 void MWindowGUI::update_scrollbars(int flush)
795 for(int i = 0; i < TOTAL_PANES; i++)
799 pane[i]->update(1, NO_DRAW, 0, 0);
802 if(flush) this->flush();
805 void MWindowGUI::reset_meters()
807 for(int i = 0; i < TOTAL_PANES; i++)
809 if(pane[i] && pane[i]->patchbay)
811 pane[i]->patchbay->reset_meters();
816 void MWindowGUI::stop_meters()
818 for(int i = 0; i < TOTAL_PANES; i++)
820 if(pane[i] && pane[i]->patchbay)
822 pane[i]->patchbay->stop_meters();
827 void MWindowGUI::update_meters(ArrayList<double> *module_levels)
829 for(int i = 0; i < TOTAL_PANES; i++)
831 if(pane[i] && pane[i]->patchbay)
833 pane[i]->patchbay->update_meters(module_levels);
838 void MWindowGUI::set_editing_mode(int flush)
840 for(int i = 0; i < TOTAL_PANES; i++)
844 pane[i]->canvas->update_cursor(flush);
849 void MWindowGUI::set_meter_format(int mode, int min, int max)
851 for(int i = 0; i < TOTAL_PANES; i++)
853 if(pane[i] && pane[i]->patchbay)
855 pane[i]->patchbay->set_meter_format(mode, min, max);
860 void MWindowGUI::update(int scrollbars,
869 if(debug) PRINT_TRACE
873 mwindow->edl->tracks->update_y_pixels(mwindow->theme);
875 if( do_canvas != NO_DRAW && do_canvas != IGNORE_THREAD )
876 resource_thread->stop_draw(1);
878 for(int i = 0; i < TOTAL_PANES; i++)
880 if(pane[i]) pane[i]->update(scrollbars,
886 if( do_canvas != NO_DRAW && do_canvas != IGNORE_THREAD )
887 resource_thread->start_draw();
889 // if(scrollbars) this->get_scrollbars(0);
890 // if(timebar) this->timebar->update(0);
891 if(zoombar) this->zoombar->update();
892 // if(patchbay) this->patchbay->update();
893 if(clock) this->mainclock->update(
894 mwindow->edl->local_session->get_selectionstart(1));
895 if(debug) PRINT_TRACE
901 // this->canvas->draw(do_canvas);
902 // this->cursor->show();
903 // this->canvas->flash(0);
904 // Activate causes the menubar to deactivate. Don't want this for
906 // if(canvas != IGNORE_THREAD) this->canvas->activate();
908 if(debug) PRINT_TRACE
912 if(buttonbar) mbuttons->update();
913 if(debug) PRINT_TRACE
915 // Can't age if the cache called this to draw missing picons
916 // or the GUI is updating the status of the draw toggle.
917 if( do_canvas != FORCE_REDRAW && do_canvas != IGNORE_THREAD ) {
919 mwindow->age_caches();
920 lock_window("MWindowGUI::update");
924 if(debug) PRINT_TRACE
927 int MWindowGUI::visible(int64_t x1, int64_t x2, int64_t view_x1, int64_t view_x2)
929 return (x1 >= view_x1 && x1 < view_x2) ||
930 (x2 > view_x1 && x2 <= view_x2) ||
931 (x1 <= view_x1 && x2 >= view_x2);
935 void MWindowGUI::show_message(const char *message, int msg_color, int bar_color)
937 statusbar->show_message(message, msg_color, bar_color);
940 void MWindowGUI::update_default_message()
942 statusbar->update_default_message();
945 void MWindowGUI::reset_default_message()
947 statusbar->reset_default_message();
950 void MWindowGUI::default_message()
952 statusbar->default_message();
955 // Drag motion called from other window
956 int MWindowGUI::drag_motion()
958 if(get_hidden()) return 0;
960 Track *over_track = 0;
962 PluginSet *over_pluginset = 0;
963 Plugin *over_plugin = 0;
968 drag_popup->cursor_motion_event();
972 // there's no point in drawing highlights has until drag operation has been set
973 if (!mwindow->session->current_operation)
976 for(int i = 0; i < TOTAL_PANES; i++)
978 if(pane[i]) pane[i]->canvas->drag_motion(
985 if(mwindow->session->track_highlighted != over_track)
987 mwindow->session->track_highlighted = over_track;
991 if(mwindow->session->edit_highlighted != over_edit)
993 mwindow->session->edit_highlighted = over_edit;
997 if(mwindow->session->pluginset_highlighted != over_pluginset)
999 mwindow->session->pluginset_highlighted = over_pluginset;
1003 if(mwindow->session->plugin_highlighted != over_plugin)
1005 mwindow->session->plugin_highlighted = over_plugin;
1009 if( mwindow->session->current_operation == DRAG_ASSET ||
1010 mwindow->session->current_operation == DRAG_EDIT ||
1011 mwindow->session->current_operation == DRAG_GROUP ||
1012 mwindow->session->current_operation == DRAG_AEFFECT_COPY ||
1013 mwindow->session->current_operation == DRAG_VEFFECT_COPY )
1019 // printf("drag_motion %d %d over_track=%p over_edit=%p\n",
1026 lock_window("MWindowGUI::drag_motion");
1033 int MWindowGUI::drag_stop()
1035 if(get_hidden()) return 0;
1036 int result = 0, redraw = 0;
1038 for(int i = 0; i < TOTAL_PANES; i++)
1040 if(pane[i]) result |= pane[i]->canvas->drag_stop(
1043 mwindow->edl->optimize();
1045 // since we don't have subwindows we have to terminate any drag operation
1048 if (mwindow->session->track_highlighted
1049 || mwindow->session->edit_highlighted
1050 || mwindow->session->plugin_highlighted
1051 || mwindow->session->pluginset_highlighted)
1053 mwindow->session->track_highlighted = 0;
1054 mwindow->session->edit_highlighted = 0;
1055 mwindow->session->plugin_highlighted = 0;
1056 mwindow->session->pluginset_highlighted = 0;
1057 mwindow->session->current_operation = NO_OPERATION;
1061 //printf("MWindowGUI::drag_stop %d %d\n", redraw, mwindow->session->current_operation);
1064 mwindow->edl->tracks->update_y_pixels(mwindow->theme);
1065 update_scrollbars(0);
1080 void MWindowGUI::default_positions()
1082 //printf("MWindowGUI::default_positions 1\n");
1083 VWindow *vwindow = mwindow->vwindows.size() > DEFAULT_VWINDOW ?
1084 mwindow->vwindows.get(DEFAULT_VWINDOW) : 0;
1085 if( vwindow && !vwindow->is_running() ) vwindow = 0;
1086 if( vwindow ) vwindow->gui->lock_window("MWindowGUI::default_positions");
1087 mwindow->cwindow->gui->lock_window("MWindowGUI::default_positions");
1088 mwindow->awindow->gui->lock_window("MWindowGUI::default_positions");
1090 // printf("MWindowGUI::default_positions 1 %d %d %d %d\n", mwindow->session->vwindow_x,
1091 // mwindow->session->vwindow_y,
1092 // mwindow->session->vwindow_w,
1093 // mwindow->session->vwindow_h);
1094 reposition_window(mwindow->session->mwindow_x,
1095 mwindow->session->mwindow_y,
1096 mwindow->session->mwindow_w,
1097 mwindow->session->mwindow_h);
1098 if( vwindow ) vwindow->gui->reposition_window(mwindow->session->vwindow_x,
1099 mwindow->session->vwindow_y,
1100 mwindow->session->vwindow_w,
1101 mwindow->session->vwindow_h);
1102 mwindow->cwindow->gui->reposition_window(mwindow->session->cwindow_x,
1103 mwindow->session->cwindow_y,
1104 mwindow->session->cwindow_w,
1105 mwindow->session->cwindow_h);
1106 mwindow->awindow->gui->reposition_window(mwindow->session->awindow_x,
1107 mwindow->session->awindow_y,
1108 mwindow->session->awindow_w,
1109 mwindow->session->awindow_h);
1110 //printf("MWindowGUI::default_positions 1\n");
1112 resize_event(mwindow->session->mwindow_w,
1113 mwindow->session->mwindow_h);
1114 //printf("MWindowGUI::default_positions 1\n");
1115 if( vwindow ) vwindow->gui->resize_event(mwindow->session->vwindow_w,
1116 mwindow->session->vwindow_h);
1117 //printf("MWindowGUI::default_positions 1\n");
1118 mwindow->cwindow->gui->resize_event(mwindow->session->cwindow_w,
1119 mwindow->session->cwindow_h);
1120 //printf("MWindowGUI::default_positions 1\n");
1121 mwindow->awindow->gui->resize_event(mwindow->session->awindow_w,
1122 mwindow->session->awindow_h);
1124 //printf("MWindowGUI::default_positions 1\n");
1127 if( vwindow ) vwindow->gui->flush();
1128 mwindow->cwindow->gui->flush();
1129 mwindow->awindow->gui->flush();
1131 if( vwindow ) vwindow->gui->unlock_window();
1132 mwindow->cwindow->gui->unlock_window();
1133 mwindow->awindow->gui->unlock_window();
1134 //printf("MWindowGUI::default_positions 2\n");
1138 int MWindowGUI::repeat_event(int64_t duration)
1140 // if(duration == 100)
1141 // mwindow->sync_parameters(CHANGE_ALL);
1143 for(int i = 0; i < TOTAL_PANES; i++)
1145 if(pane[i]) result = pane[i]->cursor->repeat_event(duration);
1151 int MWindowGUI::translation_event()
1153 //printf("MWindowGUI::translation_event 1 %d %d\n", get_x(), get_y());
1154 mwindow->session->mwindow_x = get_x();
1155 mwindow->session->mwindow_y = get_y();
1160 int MWindowGUI::save_defaults(BC_Hash *defaults)
1162 defaults->update("MWINDOWWIDTH", get_w());
1163 defaults->update("MWINDOWHEIGHT", get_h());
1164 mainmenu->save_defaults(defaults);
1165 BC_WindowBase::save_defaults(defaults);
1169 int MWindowGUI::keypress_event()
1171 //printf("MWindowGUI::keypress_event 1 %d\n", get_keypress());
1172 int result = mbuttons->keypress_event();
1173 if( result ) return result;
1175 Track *this_track = 0, *first_track = 0;
1176 int collapse = 0, packed = 0, overwrite = 0, plugins = 0;
1177 double position = 0;
1179 switch( get_keypress() ) {
1181 if( !ctrl_down() || !shift_down() || alt_down() ) break;
1182 mwindow->edl->tracks->clear_selected_edits();
1187 mwindow->toggle_editing_mode();
1192 if( alt_down() ) break;
1193 stop_transport("MWindowGUI::keypress_event 1");
1194 mwindow->nearest_plugin_keyframe(shift_down(),
1195 !ctrl_down() ? PLAY_FORWARD : PLAY_REVERSE);
1202 if( !ctrl_down() || alt_down() ) break;
1203 mwindow->selected_edits_to_clipboard(packed);
1209 overwrite = -1; // fall thru
1211 if( !ctrl_down() || alt_down() ) break;
1212 if( mwindow->session->current_operation == DROP_TARGETING ) {
1213 mwindow->session->current_operation = NO_OPERATION;
1214 mwindow->gui->set_editing_mode(1);
1216 for( ; pane_no<TOTAL_PANES; ++pane_no ) {
1217 if( !pane[pane_no] ) continue;
1218 first_track = pane[pane_no]->over_track();
1219 if( first_track ) break;
1222 int cursor_x = pane[pane_no]->canvas->get_relative_cursor_x();
1223 position = mwindow->edl->get_cursor_position(cursor_x, pane_no);
1227 position = mwindow->edl->local_session->get_selectionstart();
1229 mwindow->paste(position, first_track, 0, overwrite);
1231 mwindow->paste_clipboard(first_track, position, 1, 0, 1, 1, 1);
1232 mwindow->edl->tracks->clear_selected_edits();
1240 mwindow->cut_selected_edits(0, collapse);
1246 if( !ctrl_down() || alt_down() ) break;
1247 mwindow->cut_selected_edits(1, collapse);
1252 if( !alt_down() || shift_down() ) break;
1253 if( !mwindow->select_asset(get_keypress()-'1',1) )
1258 if( !ctrl_down() ) {
1260 stop_transport("MWindowGUI::keypress_event 1");
1261 mwindow->prev_edit_handle(shift_down());
1264 mwindow->move_left();
1270 if( !ctrl_down() && !alt_down() ) {
1271 mwindow->move_left();
1277 if( !ctrl_down() ) {
1279 stop_transport("MWindowGUI::keypress_event 2");
1280 mwindow->next_edit_handle(shift_down());
1283 mwindow->move_right();
1289 if( !ctrl_down() && !alt_down() ) {
1290 mwindow->move_right();
1296 if( ctrl_down() && !alt_down() )
1297 mwindow->expand_y();
1298 else if( !ctrl_down() && alt_down() )
1299 mwindow->expand_autos(0,1,1);
1300 else if( ctrl_down() && alt_down() )
1301 mwindow->expand_autos(1,1,1);
1303 mwindow->expand_sample();
1308 if( ctrl_down() && !alt_down() )
1309 mwindow->zoom_in_y();
1310 else if( !ctrl_down() && alt_down() )
1311 mwindow->shrink_autos(0,1,1);
1312 else if( ctrl_down() && alt_down() )
1313 mwindow->shrink_autos(1,1,1);
1315 mwindow->zoom_in_sample();
1323 mwindow->expand_t();
1329 mwindow->move_down();
1331 mwindow->zoom_in_t();
1337 for( int i=0; i<TOTAL_PANES; ++i ) {
1338 if( !pane[i] ) continue;
1339 if( (this_track = pane[i]->over_track()) != 0 ) break;
1340 if( (this_track = pane[i]->over_patchbay()) != 0 ) break;
1343 if( get_keypress() == TAB ) { // Switch the record button
1345 this_track->record = !this_track->record ? 1 : 0;
1348 int total_selected = mwindow->edl->tracks->total_of(Tracks::RECORD);
1349 // all selected if nothing previously selected or
1350 // if this patch was previously the only one selected and armed
1351 int selected = !total_selected || (total_selected == 1 &&
1352 this_track && this_track->record ) ? 1 : 0;
1353 mwindow->edl->tracks->select_all(Tracks::RECORD, selected);
1354 if( !selected && this_track ) this_track->record = 1;
1357 update(0, NORMAL_DRAW, 0, 0, 1, 0, 1);
1359 mwindow->cwindow->update(0, 1, 1);
1360 lock_window("MWindowGUI::keypress_event 3");
1365 case KEY_F1 ... KEY_F12:
1366 resend_event(mwindow->cwindow->gui);
1370 // since things under cursor have changed...
1372 cursor_motion_event();
1377 int MWindowGUI::keyboard_listener(BC_WindowBase *wp)
1379 return key_listener(wp->get_keypress());
1382 int MWindowGUI::key_listener(int key)
1387 if( !record->running() )
1390 record->record_gui->interrupt_thread->start(0);
1397 channel_info->toggle_scan();
1401 if( !remote_control->deactivate() )
1402 remote_control->activate();
1412 void MWindowGUI::use_android_remote(int on)
1415 delete android_control;
1416 android_control = 0;
1419 if( android_control ) return;
1420 android_control = new AndroidControl(this);
1423 int MWindowGUI::close_event()
1429 void MWindowGUI::stop_drawing()
1431 resource_thread->stop_draw(1);
1434 int MWindowGUI::menu_w()
1436 return mainmenu->get_w();
1439 int MWindowGUI::menu_h()
1441 return mainmenu->get_h();
1444 void MWindowGUI::start_x_pane_drag()
1448 x_pane_drag = new BC_Popup(this,
1449 get_abs_cursor_x(0) - mwindow->theme->pane_w,
1450 BC_DisplayInfo::get_top_border() +
1452 mwindow->theme->mcanvas_y,
1453 mwindow->theme->pane_w,
1454 mwindow->theme->mcanvas_h,
1455 mwindow->theme->drag_pane_color);
1456 x_pane_drag->draw_3segmentv(0,
1458 x_pane_drag->get_h(),
1459 mwindow->theme->get_image_set("xpane")[BUTTON_DOWNHI]);
1460 x_pane_drag->flash(1);
1465 void MWindowGUI::start_y_pane_drag()
1469 //printf("MWindowGUI::start_y_pane_drag %d %d %d\n", __LINE__, get_x(), get_y());
1470 y_pane_drag = new BC_Popup(this,
1471 BC_DisplayInfo::get_left_border() +
1473 mwindow->theme->mcanvas_x,
1474 get_abs_cursor_y(0) - mwindow->theme->pane_h,
1475 mwindow->theme->mcanvas_w,
1476 mwindow->theme->pane_h,
1477 mwindow->theme->drag_pane_color);
1478 y_pane_drag->draw_3segmenth(0,
1480 y_pane_drag->get_w(),
1481 mwindow->theme->get_image_set("ypane")[BUTTON_DOWNHI]);
1482 y_pane_drag->flash(1);
1487 void MWindowGUI::handle_pane_drag()
1493 x_pane_drag->reposition_window(
1494 get_abs_cursor_x(0) - mwindow->theme->pane_w,
1495 x_pane_drag->get_y());
1500 y_pane_drag->reposition_window(
1501 y_pane_drag->get_x(),
1502 get_abs_cursor_y(0) - mwindow->theme->pane_h);
1508 void MWindowGUI::create_x_pane(int cursor_x)
1510 if(total_panes() == 1)
1512 // create a horizontal pane
1513 // do this 1st so the resize_event knows there are 2 panes
1514 mwindow->edl->local_session->view_start[TOP_RIGHT_PANE] =
1515 mwindow->edl->local_session->view_start[TOP_LEFT_PANE] +
1517 mwindow->theme->patchbay_w;
1518 pane[TOP_RIGHT_PANE] = new TimelinePane(mwindow,
1520 mwindow->theme->mcanvas_x +
1522 mwindow->theme->mcanvas_y,
1523 mwindow->theme->mcanvas_x +
1524 mwindow->theme->mcanvas_w -
1526 mwindow->theme->mcanvas_h);
1527 pane[TOP_LEFT_PANE]->resize_event(
1528 mwindow->theme->mcanvas_x,
1529 mwindow->theme->mcanvas_y,
1530 cursor_x - mwindow->theme->pane_w,
1531 mwindow->theme->mcanvas_h);
1532 pane[TOP_RIGHT_PANE]->create_objects();
1535 if(vertical_panes())
1537 // create 2 horizontal panes
1538 mwindow->edl->local_session->track_start[TOP_RIGHT_PANE] =
1539 mwindow->edl->local_session->track_start[TOP_LEFT_PANE];
1540 mwindow->edl->local_session->track_start[BOTTOM_RIGHT_PANE] =
1541 mwindow->edl->local_session->track_start[BOTTOM_LEFT_PANE];
1542 mwindow->edl->local_session->view_start[TOP_RIGHT_PANE] =
1543 mwindow->edl->local_session->view_start[BOTTOM_RIGHT_PANE] =
1544 mwindow->edl->local_session->view_start[TOP_LEFT_PANE] +
1546 mwindow->theme->patchbay_w;
1547 pane[TOP_RIGHT_PANE] = new TimelinePane(mwindow,
1549 mwindow->theme->mcanvas_x +
1551 pane[TOP_LEFT_PANE]->y,
1552 mwindow->theme->mcanvas_x +
1553 mwindow->theme->mcanvas_w -
1555 pane[TOP_LEFT_PANE]->h);
1556 pane[BOTTOM_RIGHT_PANE] = new TimelinePane(mwindow,
1558 mwindow->theme->mcanvas_x +
1560 pane[BOTTOM_LEFT_PANE]->y,
1561 mwindow->theme->mcanvas_x +
1562 mwindow->theme->mcanvas_w -
1564 pane[BOTTOM_LEFT_PANE]->h);
1565 pane[TOP_LEFT_PANE]->resize_event(
1566 pane[TOP_LEFT_PANE]->x,
1567 pane[TOP_LEFT_PANE]->y,
1568 cursor_x - mwindow->theme->pane_w,
1569 pane[TOP_LEFT_PANE]->h);
1570 pane[BOTTOM_LEFT_PANE]->resize_event(
1571 pane[BOTTOM_LEFT_PANE]->x,
1572 pane[BOTTOM_LEFT_PANE]->y,
1573 cursor_x - mwindow->theme->pane_w,
1574 pane[BOTTOM_LEFT_PANE]->h);
1575 pane[TOP_RIGHT_PANE]->create_objects();
1576 pane[BOTTOM_RIGHT_PANE]->create_objects();
1579 if(horizontal_panes())
1581 // resize a horizontal pane
1582 mwindow->edl->local_session->view_start[TOP_RIGHT_PANE] +=
1584 pane[TOP_RIGHT_PANE]->x;
1585 if(mwindow->edl->local_session->view_start[TOP_RIGHT_PANE] < 0)
1586 mwindow->edl->local_session->view_start[TOP_RIGHT_PANE] = 0;
1587 pane[TOP_LEFT_PANE]->resize_event(
1588 mwindow->theme->mcanvas_x,
1589 mwindow->theme->mcanvas_y,
1590 cursor_x - mwindow->theme->pane_w,
1591 mwindow->theme->mcanvas_h);
1592 pane[TOP_RIGHT_PANE]->resize_event(
1593 mwindow->theme->mcanvas_x +
1595 pane[TOP_RIGHT_PANE]->y,
1596 mwindow->theme->mcanvas_x +
1597 mwindow->theme->mcanvas_w -
1599 mwindow->theme->mcanvas_h);
1603 // resize 2 horizontal panes
1604 mwindow->edl->local_session->view_start[TOP_RIGHT_PANE] +=
1606 pane[TOP_RIGHT_PANE]->x;
1607 if(mwindow->edl->local_session->view_start[TOP_RIGHT_PANE] < 0)
1608 mwindow->edl->local_session->view_start[TOP_RIGHT_PANE] = 0;
1609 mwindow->edl->local_session->view_start[BOTTOM_RIGHT_PANE] =
1610 mwindow->edl->local_session->view_start[TOP_RIGHT_PANE];
1612 pane[TOP_LEFT_PANE]->resize_event(
1613 mwindow->theme->mcanvas_x,
1614 pane[TOP_LEFT_PANE]->y,
1615 cursor_x - mwindow->theme->pane_w,
1616 pane[TOP_LEFT_PANE]->h);
1617 pane[TOP_RIGHT_PANE]->resize_event(
1618 mwindow->theme->mcanvas_x +
1620 pane[TOP_RIGHT_PANE]->y,
1621 mwindow->theme->mcanvas_x +
1622 mwindow->theme->mcanvas_w -
1624 pane[TOP_RIGHT_PANE]->h);
1625 pane[BOTTOM_LEFT_PANE]->resize_event(
1626 mwindow->theme->mcanvas_x,
1627 pane[BOTTOM_LEFT_PANE]->y,
1628 cursor_x - mwindow->theme->pane_w,
1629 pane[BOTTOM_LEFT_PANE]->h);
1630 pane[BOTTOM_RIGHT_PANE]->resize_event(
1631 mwindow->theme->mcanvas_x +
1633 pane[BOTTOM_RIGHT_PANE]->y,
1634 mwindow->theme->mcanvas_x +
1635 mwindow->theme->mcanvas_w -
1637 pane[BOTTOM_RIGHT_PANE]->h);
1643 void MWindowGUI::delete_x_pane(int cursor_x)
1645 // give left panes coordinates of right pane
1646 if(cursor_x < mwindow->theme->patchbay_w + PANE_DRAG_MARGIN &&
1647 pane[TOP_RIGHT_PANE])
1649 mwindow->edl->local_session->view_start[TOP_LEFT_PANE] =
1650 mwindow->edl->local_session->view_start[TOP_RIGHT_PANE] -
1651 pane[TOP_RIGHT_PANE]->x + mwindow->theme->patchbay_w;
1652 if(mwindow->edl->local_session->view_start[TOP_LEFT_PANE] < 0)
1653 mwindow->edl->local_session->view_start[TOP_LEFT_PANE] = 0;
1654 mwindow->edl->local_session->view_start[BOTTOM_LEFT_PANE] =
1655 mwindow->edl->local_session->view_start[TOP_LEFT_PANE];
1658 switch(total_panes())
1661 if(pane[TOP_LEFT_PANE] && pane[TOP_RIGHT_PANE])
1663 // delete right pane
1664 delete pane[TOP_RIGHT_PANE];
1665 pane[TOP_RIGHT_PANE] = 0;
1666 pane[TOP_LEFT_PANE]->resize_event(
1667 mwindow->theme->mcanvas_x,
1668 mwindow->theme->mcanvas_y,
1669 mwindow->theme->mcanvas_w,
1670 mwindow->theme->mcanvas_h);
1676 // delete right panes
1677 delete pane[TOP_RIGHT_PANE];
1678 pane[TOP_RIGHT_PANE] = 0;
1679 delete pane[BOTTOM_RIGHT_PANE];
1680 pane[BOTTOM_RIGHT_PANE] = 0;
1681 pane[TOP_LEFT_PANE]->resize_event(
1682 mwindow->theme->mcanvas_x,
1683 pane[TOP_LEFT_PANE]->y,
1684 mwindow->theme->mcanvas_w,
1685 pane[TOP_LEFT_PANE]->h);
1686 pane[BOTTOM_LEFT_PANE]->resize_event(
1687 mwindow->theme->mcanvas_x,
1688 pane[BOTTOM_LEFT_PANE]->y,
1689 mwindow->theme->mcanvas_w,
1690 pane[BOTTOM_LEFT_PANE]->h);
1695 void MWindowGUI::create_y_pane(int cursor_y)
1697 if(total_panes() == 1)
1699 mwindow->edl->local_session->view_start[BOTTOM_LEFT_PANE] =
1700 mwindow->edl->local_session->view_start[TOP_LEFT_PANE];
1701 mwindow->edl->local_session->track_start[BOTTOM_LEFT_PANE] =
1702 mwindow->edl->local_session->track_start[TOP_LEFT_PANE] +
1704 mwindow->theme->mtimebar_h;
1705 // do this 1st so the resize_event knows there are 2 panes
1706 pane[BOTTOM_LEFT_PANE] = new TimelinePane(mwindow,
1708 mwindow->theme->mcanvas_x,
1709 mwindow->theme->mcanvas_y +
1711 mwindow->theme->mcanvas_w,
1712 mwindow->theme->mcanvas_h -
1714 pane[TOP_LEFT_PANE]->resize_event(
1715 mwindow->theme->mcanvas_x,
1716 mwindow->theme->mcanvas_y,
1717 mwindow->theme->mcanvas_w,
1718 pane[BOTTOM_LEFT_PANE]->y -
1719 mwindow->theme->mcanvas_y -
1720 mwindow->theme->pane_h);
1721 pane[BOTTOM_LEFT_PANE]->create_objects();
1724 if(horizontal_panes())
1727 mwindow->edl->local_session->view_start[BOTTOM_LEFT_PANE] =
1728 mwindow->edl->local_session->view_start[TOP_LEFT_PANE];
1729 mwindow->edl->local_session->view_start[BOTTOM_RIGHT_PANE] =
1730 mwindow->edl->local_session->view_start[TOP_RIGHT_PANE];
1731 mwindow->edl->local_session->track_start[BOTTOM_LEFT_PANE] =
1732 mwindow->edl->local_session->track_start[BOTTOM_RIGHT_PANE] =
1733 mwindow->edl->local_session->track_start[TOP_LEFT_PANE] +
1735 mwindow->theme->mtimebar_h;
1737 pane[BOTTOM_LEFT_PANE] = new TimelinePane(mwindow,
1739 pane[TOP_LEFT_PANE]->x,
1740 mwindow->theme->mcanvas_y +
1742 pane[TOP_LEFT_PANE]->w,
1743 mwindow->theme->mcanvas_h -
1745 pane[BOTTOM_RIGHT_PANE] = new TimelinePane(mwindow,
1747 pane[TOP_RIGHT_PANE]->x,
1748 mwindow->theme->mcanvas_y +
1750 pane[TOP_RIGHT_PANE]->w,
1751 mwindow->theme->mcanvas_h -
1754 pane[TOP_LEFT_PANE]->resize_event(
1755 pane[TOP_LEFT_PANE]->x,
1756 pane[TOP_LEFT_PANE]->y,
1757 pane[TOP_LEFT_PANE]->w,
1758 pane[BOTTOM_LEFT_PANE]->y -
1759 mwindow->theme->mcanvas_y -
1760 mwindow->theme->pane_h);
1761 pane[TOP_RIGHT_PANE]->resize_event(
1762 pane[TOP_RIGHT_PANE]->x,
1763 pane[TOP_RIGHT_PANE]->y,
1764 pane[TOP_RIGHT_PANE]->w,
1765 pane[BOTTOM_RIGHT_PANE]->y -
1766 mwindow->theme->mcanvas_y -
1767 mwindow->theme->pane_h);
1769 pane[BOTTOM_LEFT_PANE]->create_objects();
1770 pane[BOTTOM_RIGHT_PANE]->create_objects();
1773 if(vertical_panes())
1776 mwindow->edl->local_session->track_start[BOTTOM_LEFT_PANE] +=
1778 (pane[BOTTOM_LEFT_PANE]->y - mwindow->theme->mcanvas_y);
1779 if(mwindow->edl->local_session->track_start[BOTTOM_LEFT_PANE] < 0)
1780 mwindow->edl->local_session->track_start[BOTTOM_LEFT_PANE] = 0;
1781 pane[TOP_LEFT_PANE]->resize_event(
1782 mwindow->theme->mcanvas_x,
1783 mwindow->theme->mcanvas_y,
1784 mwindow->theme->mcanvas_w,
1785 cursor_y - mwindow->theme->pane_h);
1786 pane[BOTTOM_LEFT_PANE]->resize_event(
1787 pane[BOTTOM_LEFT_PANE]->x,
1789 mwindow->theme->mcanvas_y,
1790 mwindow->theme->mcanvas_w,
1791 mwindow->theme->mcanvas_h -
1797 mwindow->edl->local_session->track_start[BOTTOM_LEFT_PANE] +=
1799 (pane[BOTTOM_LEFT_PANE]->y - mwindow->theme->mcanvas_y);
1800 if(mwindow->edl->local_session->track_start[BOTTOM_LEFT_PANE] < 0)
1801 mwindow->edl->local_session->track_start[BOTTOM_LEFT_PANE] = 0;
1802 mwindow->edl->local_session->track_start[BOTTOM_RIGHT_PANE] =
1803 mwindow->edl->local_session->track_start[BOTTOM_LEFT_PANE];
1804 pane[TOP_LEFT_PANE]->resize_event(
1805 pane[TOP_LEFT_PANE]->x,
1806 pane[TOP_LEFT_PANE]->y,
1807 pane[TOP_LEFT_PANE]->w,
1808 cursor_y - mwindow->theme->pane_h);
1809 pane[BOTTOM_LEFT_PANE]->resize_event(
1810 pane[BOTTOM_LEFT_PANE]->x,
1812 mwindow->theme->mcanvas_y,
1813 pane[BOTTOM_LEFT_PANE]->w,
1814 mwindow->theme->mcanvas_h -
1816 pane[TOP_RIGHT_PANE]->resize_event(
1817 pane[TOP_RIGHT_PANE]->x,
1818 pane[TOP_RIGHT_PANE]->y,
1819 pane[TOP_RIGHT_PANE]->w,
1820 cursor_y - mwindow->theme->pane_h);
1821 pane[BOTTOM_RIGHT_PANE]->resize_event(
1822 pane[BOTTOM_RIGHT_PANE]->x,
1824 mwindow->theme->mcanvas_y,
1825 pane[BOTTOM_RIGHT_PANE]->w,
1826 mwindow->theme->mcanvas_h -
1831 void MWindowGUI::delete_y_pane(int cursor_y)
1833 if(cursor_y < mwindow->theme->mtimebar_h +
1835 pane[BOTTOM_LEFT_PANE])
1837 // give top pane coordinates of bottom pane
1838 mwindow->edl->local_session->track_start[TOP_LEFT_PANE] =
1839 mwindow->edl->local_session->track_start[BOTTOM_LEFT_PANE] -
1840 pane[BOTTOM_LEFT_PANE]->y;
1841 if(mwindow->edl->local_session->track_start[TOP_LEFT_PANE] < 0)
1842 mwindow->edl->local_session->track_start[TOP_LEFT_PANE] = 0;
1843 mwindow->edl->local_session->track_start[TOP_RIGHT_PANE] =
1844 mwindow->edl->local_session->track_start[TOP_LEFT_PANE];
1848 switch(total_panes())
1851 delete pane[BOTTOM_LEFT_PANE];
1852 pane[BOTTOM_LEFT_PANE] = 0;
1853 pane[TOP_LEFT_PANE]->resize_event(
1854 mwindow->theme->mcanvas_x,
1855 mwindow->theme->mcanvas_y,
1856 mwindow->theme->mcanvas_w,
1857 mwindow->theme->mcanvas_h);
1861 // delete bottom 2 panes
1863 delete pane[BOTTOM_LEFT_PANE];
1864 pane[BOTTOM_LEFT_PANE] = 0;
1865 delete pane[BOTTOM_RIGHT_PANE];
1866 pane[BOTTOM_RIGHT_PANE] = 0;
1867 pane[TOP_LEFT_PANE]->resize_event(
1868 pane[TOP_LEFT_PANE]->x,
1869 mwindow->theme->mcanvas_y,
1870 pane[TOP_LEFT_PANE]->w,
1871 mwindow->theme->mcanvas_h);
1872 pane[TOP_RIGHT_PANE]->resize_event(
1873 pane[TOP_RIGHT_PANE]->x,
1874 mwindow->theme->mcanvas_y,
1875 pane[TOP_RIGHT_PANE]->w,
1876 mwindow->theme->mcanvas_h);
1881 void MWindowGUI::stop_pane_drag()
1884 resource_thread->stop_draw(0);
1888 // cursor position relative to canvas
1889 int cursor_x = x_pane_drag->get_x() -
1891 BC_DisplayInfo::get_left_border() -
1892 mwindow->theme->mcanvas_x +
1893 mwindow->theme->pane_w;
1898 if(cursor_x >= mwindow->theme->patchbay_w + PANE_DRAG_MARGIN &&
1899 cursor_x < mwindow->theme->mcanvas_w -
1900 BC_ScrollBar::get_span(SCROLL_VERT) -
1903 create_x_pane(cursor_x);
1904 mwindow->edl->local_session->x_pane = cursor_x;
1909 delete_x_pane(cursor_x);
1910 mwindow->edl->local_session->x_pane = -1;
1918 // cursor position relative to canvas
1919 int cursor_y = y_pane_drag->get_y() -
1921 BC_DisplayInfo::get_top_border() -
1922 mwindow->theme->mcanvas_y +
1923 mwindow->theme->pane_h;
1929 if(cursor_y >= mwindow->theme->mtimebar_h +
1931 cursor_y < mwindow->theme->mcanvas_h -
1932 BC_ScrollBar::get_span(SCROLL_HORIZ) -
1935 create_y_pane(cursor_y);
1936 mwindow->edl->local_session->y_pane = cursor_y;
1940 delete_y_pane(cursor_y);
1941 mwindow->edl->local_session->y_pane = -1;
1945 update_pane_dividers();
1947 // required to get new widgets to appear
1949 resource_thread->start_draw();
1952 // create panes from EDL
1953 void MWindowGUI::load_panes()
1955 int need_x_panes = 0;
1956 int need_y_panes = 0;
1957 // use names from create functions
1958 int cursor_x = mwindow->edl->local_session->x_pane;
1959 int cursor_y = mwindow->edl->local_session->y_pane;
1961 resource_thread->stop_draw(1);
1963 mwindow->theme->patchbay_w + PANE_DRAG_MARGIN &&
1965 mwindow->theme->mcanvas_w -
1966 BC_ScrollBar::get_span(SCROLL_VERT) -
1973 mwindow->theme->mtimebar_h + PANE_DRAG_MARGIN &&
1975 mwindow->theme->mcanvas_h -
1976 BC_ScrollBar::get_span(SCROLL_HORIZ) -
1982 //printf("MWindowGUI::load_panes %d %d %d\n", __LINE__, need_x_panes, need_y_panes);
1990 if(total_panes() == 1)
1993 //printf("MWindowGUI::load_panes %d\n", __LINE__);
1994 pane[TOP_RIGHT_PANE] = new TimelinePane(mwindow,
1996 mwindow->theme->mcanvas_x +
1998 mwindow->theme->mcanvas_y,
1999 mwindow->theme->mcanvas_x +
2000 mwindow->theme->mcanvas_w -
2002 cursor_y - mwindow->theme->pane_h);
2003 pane[BOTTOM_LEFT_PANE] = new TimelinePane(mwindow,
2005 mwindow->theme->mcanvas_x,
2006 mwindow->theme->mcanvas_y +
2008 cursor_x - mwindow->theme->pane_w,
2009 mwindow->theme->mcanvas_h -
2011 pane[BOTTOM_RIGHT_PANE] = new TimelinePane(mwindow,
2013 pane[TOP_RIGHT_PANE]->x,
2014 mwindow->theme->mcanvas_y +
2016 pane[TOP_RIGHT_PANE]->w,
2017 mwindow->theme->mcanvas_h -
2019 pane[TOP_LEFT_PANE]->resize_event(
2020 pane[TOP_LEFT_PANE]->x,
2021 pane[TOP_LEFT_PANE]->y,
2022 cursor_x - mwindow->theme->pane_w,
2023 cursor_y - mwindow->theme->pane_h);
2024 pane[TOP_RIGHT_PANE]->create_objects();
2025 pane[BOTTOM_LEFT_PANE]->create_objects();
2026 pane[BOTTOM_RIGHT_PANE]->create_objects();
2029 if(horizontal_panes())
2031 // create vertical panes
2032 //printf("MWindowGUI::load_panes %d\n", __LINE__);
2033 pane[BOTTOM_LEFT_PANE] = new TimelinePane(mwindow,
2035 mwindow->theme->mcanvas_x,
2036 mwindow->theme->mcanvas_y +
2038 cursor_x - mwindow->theme->pane_w,
2039 mwindow->theme->mcanvas_h -
2041 pane[BOTTOM_RIGHT_PANE] = new TimelinePane(mwindow,
2043 pane[TOP_RIGHT_PANE]->x,
2044 mwindow->theme->mcanvas_y +
2046 pane[TOP_RIGHT_PANE]->w,
2047 mwindow->theme->mcanvas_h -
2049 pane[TOP_LEFT_PANE]->resize_event(
2050 pane[TOP_LEFT_PANE]->x,
2051 pane[TOP_LEFT_PANE]->y,
2052 cursor_x - mwindow->theme->pane_w,
2053 cursor_y - mwindow->theme->pane_h);
2054 pane[TOP_RIGHT_PANE]->resize_event(
2055 mwindow->theme->mcanvas_x +
2057 mwindow->theme->mcanvas_y,
2058 mwindow->theme->mcanvas_x +
2059 mwindow->theme->mcanvas_w -
2061 cursor_y - mwindow->theme->pane_h);
2062 pane[BOTTOM_LEFT_PANE]->create_objects();
2063 pane[BOTTOM_RIGHT_PANE]->create_objects();
2066 if(vertical_panes())
2068 // create horizontal panes
2069 //printf("MWindowGUI::load_panes %d\n", __LINE__);
2070 pane[TOP_RIGHT_PANE] = new TimelinePane(mwindow,
2072 mwindow->theme->mcanvas_x +
2074 mwindow->theme->mcanvas_y,
2075 mwindow->theme->mcanvas_x +
2076 mwindow->theme->mcanvas_w -
2078 cursor_y - mwindow->theme->pane_h);
2079 pane[BOTTOM_RIGHT_PANE] = new TimelinePane(mwindow,
2081 pane[TOP_RIGHT_PANE]->x,
2082 mwindow->theme->mcanvas_y +
2084 pane[TOP_RIGHT_PANE]->w,
2085 mwindow->theme->mcanvas_h -
2087 pane[TOP_LEFT_PANE]->resize_event(
2088 pane[TOP_LEFT_PANE]->x,
2089 pane[TOP_LEFT_PANE]->y,
2090 cursor_x - mwindow->theme->pane_w,
2091 cursor_y - mwindow->theme->pane_h);
2092 pane[BOTTOM_LEFT_PANE]->resize_event(
2093 pane[TOP_LEFT_PANE]->x,
2094 mwindow->theme->mcanvas_y +
2096 mwindow->theme->mcanvas_x +
2097 mwindow->theme->mcanvas_w -
2098 cursor_x - mwindow->theme->pane_w,
2099 mwindow->theme->mcanvas_h -
2101 pane[TOP_RIGHT_PANE]->create_objects();
2102 pane[BOTTOM_RIGHT_PANE]->create_objects();
2109 //printf("MWindowGUI::load_panes %d\n", __LINE__);
2110 pane[TOP_LEFT_PANE]->resize_event(
2111 pane[TOP_LEFT_PANE]->x,
2112 pane[TOP_LEFT_PANE]->y,
2113 cursor_x - mwindow->theme->pane_w,
2114 cursor_y - mwindow->theme->pane_h);
2115 pane[TOP_RIGHT_PANE]->resize_event(
2116 mwindow->theme->mcanvas_x +
2118 mwindow->theme->mcanvas_y,
2119 mwindow->theme->mcanvas_x +
2120 mwindow->theme->mcanvas_w -
2122 cursor_y - mwindow->theme->pane_h);
2123 pane[BOTTOM_LEFT_PANE]->resize_event(
2124 pane[TOP_LEFT_PANE]->x,
2125 mwindow->theme->mcanvas_y +
2127 mwindow->theme->mcanvas_x +
2128 mwindow->theme->mcanvas_w -
2129 cursor_x - mwindow->theme->pane_w,
2130 mwindow->theme->mcanvas_h -
2132 pane[BOTTOM_RIGHT_PANE]->resize_event(
2133 pane[TOP_RIGHT_PANE]->x,
2134 mwindow->theme->mcanvas_y +
2136 pane[TOP_RIGHT_PANE]->w,
2137 mwindow->theme->mcanvas_h -
2146 if(pane[BOTTOM_LEFT_PANE]) delete pane[BOTTOM_LEFT_PANE];
2147 if(pane[BOTTOM_RIGHT_PANE]) delete pane[BOTTOM_RIGHT_PANE];
2148 pane[BOTTOM_LEFT_PANE] = 0;
2149 pane[BOTTOM_RIGHT_PANE] = 0;
2151 if(!pane[TOP_RIGHT_PANE])
2153 pane[TOP_RIGHT_PANE] = new TimelinePane(mwindow,
2155 mwindow->theme->mcanvas_x +
2157 mwindow->theme->mcanvas_y,
2158 mwindow->theme->mcanvas_x +
2159 mwindow->theme->mcanvas_w -
2161 mwindow->theme->mcanvas_h);
2162 pane[TOP_LEFT_PANE]->resize_event(
2163 mwindow->theme->mcanvas_x,
2164 mwindow->theme->mcanvas_y,
2165 cursor_x - mwindow->theme->pane_w,
2166 mwindow->theme->mcanvas_h);
2167 pane[TOP_RIGHT_PANE]->create_objects();
2171 pane[TOP_LEFT_PANE]->resize_event(
2172 mwindow->theme->mcanvas_x,
2173 mwindow->theme->mcanvas_y,
2174 cursor_x - mwindow->theme->pane_w,
2175 mwindow->theme->mcanvas_h);
2176 pane[TOP_RIGHT_PANE]->resize_event(
2177 mwindow->theme->mcanvas_x +
2179 pane[TOP_RIGHT_PANE]->y,
2180 mwindow->theme->mcanvas_x +
2181 mwindow->theme->mcanvas_w -
2183 mwindow->theme->mcanvas_h);
2191 if(pane[TOP_RIGHT_PANE]) delete pane[TOP_RIGHT_PANE];
2192 if(pane[BOTTOM_RIGHT_PANE]) delete pane[BOTTOM_RIGHT_PANE];
2193 pane[TOP_RIGHT_PANE] = 0;
2194 pane[BOTTOM_RIGHT_PANE] = 0;
2196 if(!pane[BOTTOM_LEFT_PANE])
2198 //printf("MWindowGUI::load_panes %d\n", __LINE__);
2199 pane[BOTTOM_LEFT_PANE] = new TimelinePane(mwindow,
2201 mwindow->theme->mcanvas_x,
2202 mwindow->theme->mcanvas_y +
2204 mwindow->theme->mcanvas_w,
2205 mwindow->theme->mcanvas_h -
2207 pane[TOP_LEFT_PANE]->resize_event(
2208 mwindow->theme->mcanvas_x,
2209 mwindow->theme->mcanvas_y,
2210 mwindow->theme->mcanvas_w,
2211 pane[BOTTOM_LEFT_PANE]->y -
2212 mwindow->theme->mcanvas_y -
2213 mwindow->theme->pane_h);
2214 pane[BOTTOM_LEFT_PANE]->create_objects();
2218 pane[TOP_LEFT_PANE]->resize_event(
2219 mwindow->theme->mcanvas_x,
2220 mwindow->theme->mcanvas_y,
2221 mwindow->theme->mcanvas_w,
2222 cursor_y - mwindow->theme->pane_h);
2223 pane[BOTTOM_LEFT_PANE]->resize_event(
2224 pane[BOTTOM_LEFT_PANE]->x,
2226 mwindow->theme->mcanvas_y,
2227 mwindow->theme->mcanvas_w,
2228 mwindow->theme->mcanvas_h -
2235 if(pane[TOP_RIGHT_PANE]) delete pane[TOP_RIGHT_PANE];
2236 if(pane[BOTTOM_RIGHT_PANE]) delete pane[BOTTOM_RIGHT_PANE];
2237 if(pane[BOTTOM_LEFT_PANE]) delete pane[BOTTOM_LEFT_PANE];
2238 pane[TOP_RIGHT_PANE] = 0;
2239 pane[BOTTOM_RIGHT_PANE] = 0;
2240 pane[BOTTOM_LEFT_PANE] = 0;
2241 pane[TOP_LEFT_PANE]->resize_event(
2242 mwindow->theme->mcanvas_x,
2243 mwindow->theme->mcanvas_y,
2244 mwindow->theme->mcanvas_w,
2245 mwindow->theme->mcanvas_h);
2248 update_pane_dividers();
2251 resource_thread->start_draw();
2254 void MWindowGUI::update_pane_dividers()
2257 if(horizontal_panes() || total_panes() == 4)
2259 int x = pane[TOP_RIGHT_PANE]->x - mwindow->theme->pane_w;
2260 int y = mwindow->theme->mcanvas_y;
2261 int h = mwindow->theme->mcanvas_h;
2265 add_subwindow(x_divider = new PaneDivider(
2266 mwindow, x, y, h, 1));
2267 x_divider->create_objects();
2271 x_divider->reposition_window(x, y, h);
2284 if(vertical_panes() || total_panes() == 4)
2286 int x = mwindow->theme->mcanvas_x;
2287 int y = pane[BOTTOM_LEFT_PANE]->y -
2288 mwindow->theme->pane_h;
2289 int w = mwindow->theme->mcanvas_w;
2292 add_subwindow(y_divider = new PaneDivider(
2293 mwindow, x, y, w, 0));
2294 y_divider->create_objects();
2298 y_divider->reposition_window(x, y, w);
2312 void MWindowGUI::draw_samplemovement()
2319 update_scrollbars(1);
2322 void MWindowGUI::draw_trackmovement()
2324 update_scrollbars(0);
2331 void MWindowGUI::update_mixers(Track *track, int v)
2333 for( int i=0; i<TOTAL_PANES; ++i ) {
2334 if( !pane[i] ) continue;
2335 PatchBay *patchbay = pane[i]->patchbay;
2336 if( !patchbay ) continue;
2337 for( int j=0; j<patchbay->patches.total; ++j ) {
2338 PatchGUI *patchgui = patchbay->patches.values[j];
2339 if( !patchgui->mix ) continue;
2340 if( !track || patchgui->track == track ) {
2341 patchgui->mix->update(v>=0 ? v :
2342 mwindow->mixer_track_active(patchgui->track));
2348 void MWindowGUI::stop_transport(const char *lock_msg)
2350 if( !mbuttons->transport->is_stopped() ) {
2351 if( lock_msg ) unlock_window();
2352 mbuttons->transport->handle_transport(STOP, 1);
2353 if( lock_msg ) lock_window(lock_msg);
2357 PaneButton::PaneButton(MWindow *mwindow, int x, int y)
2358 : BC_Button(x, y, mwindow->theme->get_image_set("pane"))
2360 this->mwindow = mwindow;
2363 int PaneButton::cursor_motion_event()
2365 if(get_top_level()->get_button_down() &&
2367 get_status() == BUTTON_DOWNHI &&
2370 // printf("PaneButton::cursor_motion_event %d\n", __LINE__);
2372 if(get_cursor_x() < 0 && !mwindow->gui->dragging_pane)
2374 mwindow->gui->start_x_pane_drag();
2377 if(get_cursor_y() < 0 && !mwindow->gui->dragging_pane)
2379 mwindow->gui->start_y_pane_drag();
2383 mwindow->gui->handle_pane_drag();
2385 int result = BC_Button::cursor_motion_event();
2389 int PaneButton::button_release_event()
2391 if( get_buttonpress() != WHEEL_DOWN && get_buttonpress() != WHEEL_UP )
2392 mwindow->gui->stop_pane_drag();
2393 int result = BC_Button::button_release_event();
2398 FFMpegToggle::FFMpegToggle(MWindow *mwindow, MButtons *mbuttons, int x, int y)
2399 : BC_Toggle(x, y, mwindow->theme->ffmpeg_toggle,
2400 mwindow->preferences->get_file_probe_armed("FFMPEG_Early") > 0 ? 1 : 0)
2402 this->mwindow = mwindow;
2403 this->mbuttons = mbuttons;
2404 set_tooltip(get_value() ? FFMPEG_EARLY_TIP : FFMPEG_LATE_TIP);
2407 FFMpegToggle::~FFMpegToggle()
2411 int FFMpegToggle::handle_event()
2413 int ffmpeg_early_probe = get_value();
2414 set_tooltip(ffmpeg_early_probe ? FFMPEG_EARLY_TIP : FFMPEG_LATE_TIP);
2415 mwindow->preferences->set_file_probe_armed("FFMPEG_Early", ffmpeg_early_probe);
2416 mwindow->preferences->set_file_probe_armed("FFMPEG_Late", !ffmpeg_early_probe);
2418 mwindow->show_warning(&mwindow->preferences->warn_indexes,
2419 _("Changing the base codecs may require rebuilding indexes."));
2424 ProxyToggle::ProxyToggle(MWindow *mwindow, MButtons *mbuttons, int x, int y)
2425 : BC_Toggle(x, y, ( !mwindow->edl->session->proxy_use_scaler ?
2426 mwindow->theme->proxy_p_toggle :
2427 mwindow->theme->proxy_s_toggle ),
2428 mwindow->edl->session->proxy_disabled_scale != 1)
2430 this->mwindow = mwindow;
2431 this->mbuttons = mbuttons;
2432 scaler_images = mwindow->edl->session->proxy_use_scaler;
2433 set_tooltip(mwindow->edl->session->proxy_disabled_scale==1 ?
2434 _("Disable proxy") : _("Enable proxy"));
2437 void ProxyToggle::show()
2439 int use_scaler = mwindow->edl->session->proxy_use_scaler;
2440 if( scaler_images != use_scaler )
2441 set_images(!(scaler_images=use_scaler) ?
2442 mwindow->theme->proxy_p_toggle :
2443 mwindow->theme->proxy_s_toggle );
2449 void ProxyToggle::hide()
2455 ProxyToggle::~ProxyToggle()
2459 int ProxyToggle::handle_event()
2461 int disabled = get_value();
2462 mwindow->gui->unlock_window();
2464 mwindow->disable_proxy();
2466 mwindow->enable_proxy();
2467 mwindow->gui->lock_window("ProxyToggle::handle_event");
2468 set_tooltip(!disabled ? _("Disable proxy") : _("Enable proxy"));
2472 int ProxyToggle::keypress_event()
2474 if( ctrl_down() && !shift_down() && !alt_down() ) {
2475 int key = get_keypress();
2477 int value = get_value() ? 0 : 1;
2479 return handle_event();