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(0);
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(0);
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 color)
937 statusbar->show_message(message, 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();
1239 mwindow->cut_selected_edits(0, collapse);
1245 if( !ctrl_down() || alt_down() ) break;
1246 mwindow->cut_selected_edits(1, collapse);
1251 if( !alt_down() || shift_down() ) break;
1252 if( !mwindow->select_asset(get_keypress()-'1',1) )
1257 if( !ctrl_down() ) {
1259 stop_transport("MWindowGUI::keypress_event 1");
1260 mwindow->prev_edit_handle(shift_down());
1263 mwindow->move_left();
1269 if( !ctrl_down() && !alt_down() ) {
1270 mwindow->move_left();
1276 if( !ctrl_down() ) {
1278 stop_transport("MWindowGUI::keypress_event 2");
1279 mwindow->next_edit_handle(shift_down());
1282 mwindow->move_right();
1288 if( !ctrl_down() && !alt_down() ) {
1289 mwindow->move_right();
1295 if( ctrl_down() && !alt_down() )
1296 mwindow->expand_y();
1297 else if( !ctrl_down() && alt_down() )
1298 mwindow->expand_autos(0,1,1);
1299 else if( ctrl_down() && alt_down() )
1300 mwindow->expand_autos(1,1,1);
1302 mwindow->expand_sample();
1307 if( ctrl_down() && !alt_down() )
1308 mwindow->zoom_in_y();
1309 else if( !ctrl_down() && alt_down() )
1310 mwindow->shrink_autos(0,1,1);
1311 else if( ctrl_down() && alt_down() )
1312 mwindow->shrink_autos(1,1,1);
1314 mwindow->zoom_in_sample();
1322 mwindow->expand_t();
1328 mwindow->move_down();
1330 mwindow->zoom_in_t();
1336 for( int i=0; i<TOTAL_PANES; ++i ) {
1337 if( !pane[i] ) continue;
1338 if( (this_track = pane[i]->over_track()) != 0 ) break;
1339 if( (this_track = pane[i]->over_patchbay()) != 0 ) break;
1342 if( get_keypress() == TAB ) { // Switch the record button
1344 this_track->record = !this_track->record ? 1 : 0;
1347 int total_selected = mwindow->edl->tracks->total_of(Tracks::RECORD);
1348 // all selected if nothing previously selected or
1349 // if this patch was previously the only one selected and armed
1350 int selected = !total_selected || (total_selected == 1 &&
1351 this_track && this_track->record ) ? 1 : 0;
1352 mwindow->edl->tracks->select_all(Tracks::RECORD, selected);
1353 if( !selected && this_track ) this_track->record = 1;
1356 update(0, NORMAL_DRAW, 0, 0, 1, 0, 1);
1358 mwindow->cwindow->update(0, 1, 1);
1359 lock_window("MWindowGUI::keypress_event 3");
1364 case KEY_F1 ... KEY_F12:
1365 resend_event(mwindow->cwindow->gui);
1369 // since things under cursor have changed...
1371 cursor_motion_event();
1376 int MWindowGUI::keyboard_listener(BC_WindowBase *wp)
1378 return key_listener(wp->get_keypress());
1381 int MWindowGUI::key_listener(int key)
1386 if( !record->running() )
1389 record->record_gui->interrupt_thread->start(0);
1396 channel_info->toggle_scan();
1400 if( !remote_control->deactivate() )
1401 remote_control->activate();
1411 void MWindowGUI::use_android_remote(int on)
1414 delete android_control;
1415 android_control = 0;
1418 if( android_control ) return;
1419 android_control = new AndroidControl(this);
1422 int MWindowGUI::close_event()
1428 void MWindowGUI::stop_drawing()
1430 resource_thread->stop_draw(1);
1433 int MWindowGUI::menu_w()
1435 return mainmenu->get_w();
1438 int MWindowGUI::menu_h()
1440 return mainmenu->get_h();
1443 void MWindowGUI::start_x_pane_drag()
1447 x_pane_drag = new BC_Popup(this,
1448 get_abs_cursor_x(0) - mwindow->theme->pane_w,
1449 BC_DisplayInfo::get_top_border() +
1451 mwindow->theme->mcanvas_y,
1452 mwindow->theme->pane_w,
1453 mwindow->theme->mcanvas_h,
1454 mwindow->theme->drag_pane_color);
1455 x_pane_drag->draw_3segmentv(0,
1457 x_pane_drag->get_h(),
1458 mwindow->theme->get_image_set("xpane")[BUTTON_DOWNHI]);
1459 x_pane_drag->flash(1);
1464 void MWindowGUI::start_y_pane_drag()
1468 //printf("MWindowGUI::start_y_pane_drag %d %d %d\n", __LINE__, get_x(), get_y());
1469 y_pane_drag = new BC_Popup(this,
1470 BC_DisplayInfo::get_left_border() +
1472 mwindow->theme->mcanvas_x,
1473 get_abs_cursor_y(0) - mwindow->theme->pane_h,
1474 mwindow->theme->mcanvas_w,
1475 mwindow->theme->pane_h,
1476 mwindow->theme->drag_pane_color);
1477 y_pane_drag->draw_3segmenth(0,
1479 y_pane_drag->get_w(),
1480 mwindow->theme->get_image_set("ypane")[BUTTON_DOWNHI]);
1481 y_pane_drag->flash(1);
1486 void MWindowGUI::handle_pane_drag()
1492 x_pane_drag->reposition_window(
1493 get_abs_cursor_x(0) - mwindow->theme->pane_w,
1494 x_pane_drag->get_y());
1499 y_pane_drag->reposition_window(
1500 y_pane_drag->get_x(),
1501 get_abs_cursor_y(0) - mwindow->theme->pane_h);
1507 void MWindowGUI::create_x_pane(int cursor_x)
1509 if(total_panes() == 1)
1511 // create a horizontal pane
1512 // do this 1st so the resize_event knows there are 2 panes
1513 mwindow->edl->local_session->view_start[TOP_RIGHT_PANE] =
1514 mwindow->edl->local_session->view_start[TOP_LEFT_PANE] +
1516 mwindow->theme->patchbay_w;
1517 pane[TOP_RIGHT_PANE] = new TimelinePane(mwindow,
1519 mwindow->theme->mcanvas_x +
1521 mwindow->theme->mcanvas_y,
1522 mwindow->theme->mcanvas_x +
1523 mwindow->theme->mcanvas_w -
1525 mwindow->theme->mcanvas_h);
1526 pane[TOP_LEFT_PANE]->resize_event(
1527 mwindow->theme->mcanvas_x,
1528 mwindow->theme->mcanvas_y,
1529 cursor_x - mwindow->theme->pane_w,
1530 mwindow->theme->mcanvas_h);
1531 pane[TOP_RIGHT_PANE]->create_objects();
1534 if(vertical_panes())
1536 // create 2 horizontal panes
1537 mwindow->edl->local_session->track_start[TOP_RIGHT_PANE] =
1538 mwindow->edl->local_session->track_start[TOP_LEFT_PANE];
1539 mwindow->edl->local_session->track_start[BOTTOM_RIGHT_PANE] =
1540 mwindow->edl->local_session->track_start[BOTTOM_LEFT_PANE];
1541 mwindow->edl->local_session->view_start[TOP_RIGHT_PANE] =
1542 mwindow->edl->local_session->view_start[BOTTOM_RIGHT_PANE] =
1543 mwindow->edl->local_session->view_start[TOP_LEFT_PANE] +
1545 mwindow->theme->patchbay_w;
1546 pane[TOP_RIGHT_PANE] = new TimelinePane(mwindow,
1548 mwindow->theme->mcanvas_x +
1550 pane[TOP_LEFT_PANE]->y,
1551 mwindow->theme->mcanvas_x +
1552 mwindow->theme->mcanvas_w -
1554 pane[TOP_LEFT_PANE]->h);
1555 pane[BOTTOM_RIGHT_PANE] = new TimelinePane(mwindow,
1557 mwindow->theme->mcanvas_x +
1559 pane[BOTTOM_LEFT_PANE]->y,
1560 mwindow->theme->mcanvas_x +
1561 mwindow->theme->mcanvas_w -
1563 pane[BOTTOM_LEFT_PANE]->h);
1564 pane[TOP_LEFT_PANE]->resize_event(
1565 pane[TOP_LEFT_PANE]->x,
1566 pane[TOP_LEFT_PANE]->y,
1567 cursor_x - mwindow->theme->pane_w,
1568 pane[TOP_LEFT_PANE]->h);
1569 pane[BOTTOM_LEFT_PANE]->resize_event(
1570 pane[BOTTOM_LEFT_PANE]->x,
1571 pane[BOTTOM_LEFT_PANE]->y,
1572 cursor_x - mwindow->theme->pane_w,
1573 pane[BOTTOM_LEFT_PANE]->h);
1574 pane[TOP_RIGHT_PANE]->create_objects();
1575 pane[BOTTOM_RIGHT_PANE]->create_objects();
1578 if(horizontal_panes())
1580 // resize a horizontal pane
1581 mwindow->edl->local_session->view_start[TOP_RIGHT_PANE] +=
1583 pane[TOP_RIGHT_PANE]->x;
1584 if(mwindow->edl->local_session->view_start[TOP_RIGHT_PANE] < 0)
1585 mwindow->edl->local_session->view_start[TOP_RIGHT_PANE] = 0;
1586 pane[TOP_LEFT_PANE]->resize_event(
1587 mwindow->theme->mcanvas_x,
1588 mwindow->theme->mcanvas_y,
1589 cursor_x - mwindow->theme->pane_w,
1590 mwindow->theme->mcanvas_h);
1591 pane[TOP_RIGHT_PANE]->resize_event(
1592 mwindow->theme->mcanvas_x +
1594 pane[TOP_RIGHT_PANE]->y,
1595 mwindow->theme->mcanvas_x +
1596 mwindow->theme->mcanvas_w -
1598 mwindow->theme->mcanvas_h);
1602 // resize 2 horizontal panes
1603 mwindow->edl->local_session->view_start[TOP_RIGHT_PANE] +=
1605 pane[TOP_RIGHT_PANE]->x;
1606 if(mwindow->edl->local_session->view_start[TOP_RIGHT_PANE] < 0)
1607 mwindow->edl->local_session->view_start[TOP_RIGHT_PANE] = 0;
1608 mwindow->edl->local_session->view_start[BOTTOM_RIGHT_PANE] =
1609 mwindow->edl->local_session->view_start[TOP_RIGHT_PANE];
1611 pane[TOP_LEFT_PANE]->resize_event(
1612 mwindow->theme->mcanvas_x,
1613 pane[TOP_LEFT_PANE]->y,
1614 cursor_x - mwindow->theme->pane_w,
1615 pane[TOP_LEFT_PANE]->h);
1616 pane[TOP_RIGHT_PANE]->resize_event(
1617 mwindow->theme->mcanvas_x +
1619 pane[TOP_RIGHT_PANE]->y,
1620 mwindow->theme->mcanvas_x +
1621 mwindow->theme->mcanvas_w -
1623 pane[TOP_RIGHT_PANE]->h);
1624 pane[BOTTOM_LEFT_PANE]->resize_event(
1625 mwindow->theme->mcanvas_x,
1626 pane[BOTTOM_LEFT_PANE]->y,
1627 cursor_x - mwindow->theme->pane_w,
1628 pane[BOTTOM_LEFT_PANE]->h);
1629 pane[BOTTOM_RIGHT_PANE]->resize_event(
1630 mwindow->theme->mcanvas_x +
1632 pane[BOTTOM_RIGHT_PANE]->y,
1633 mwindow->theme->mcanvas_x +
1634 mwindow->theme->mcanvas_w -
1636 pane[BOTTOM_RIGHT_PANE]->h);
1642 void MWindowGUI::delete_x_pane(int cursor_x)
1644 // give left panes coordinates of right pane
1645 if(cursor_x < mwindow->theme->patchbay_w + PANE_DRAG_MARGIN &&
1646 pane[TOP_RIGHT_PANE])
1648 mwindow->edl->local_session->view_start[TOP_LEFT_PANE] =
1649 mwindow->edl->local_session->view_start[TOP_RIGHT_PANE] -
1650 pane[TOP_RIGHT_PANE]->x + mwindow->theme->patchbay_w;
1651 if(mwindow->edl->local_session->view_start[TOP_LEFT_PANE] < 0)
1652 mwindow->edl->local_session->view_start[TOP_LEFT_PANE] = 0;
1653 mwindow->edl->local_session->view_start[BOTTOM_LEFT_PANE] =
1654 mwindow->edl->local_session->view_start[TOP_LEFT_PANE];
1657 switch(total_panes())
1660 if(pane[TOP_LEFT_PANE] && pane[TOP_RIGHT_PANE])
1662 // delete right pane
1663 delete pane[TOP_RIGHT_PANE];
1664 pane[TOP_RIGHT_PANE] = 0;
1665 pane[TOP_LEFT_PANE]->resize_event(
1666 mwindow->theme->mcanvas_x,
1667 mwindow->theme->mcanvas_y,
1668 mwindow->theme->mcanvas_w,
1669 mwindow->theme->mcanvas_h);
1675 // delete right panes
1676 delete pane[TOP_RIGHT_PANE];
1677 pane[TOP_RIGHT_PANE] = 0;
1678 delete pane[BOTTOM_RIGHT_PANE];
1679 pane[BOTTOM_RIGHT_PANE] = 0;
1680 pane[TOP_LEFT_PANE]->resize_event(
1681 mwindow->theme->mcanvas_x,
1682 pane[TOP_LEFT_PANE]->y,
1683 mwindow->theme->mcanvas_w,
1684 pane[TOP_LEFT_PANE]->h);
1685 pane[BOTTOM_LEFT_PANE]->resize_event(
1686 mwindow->theme->mcanvas_x,
1687 pane[BOTTOM_LEFT_PANE]->y,
1688 mwindow->theme->mcanvas_w,
1689 pane[BOTTOM_LEFT_PANE]->h);
1694 void MWindowGUI::create_y_pane(int cursor_y)
1696 if(total_panes() == 1)
1698 mwindow->edl->local_session->view_start[BOTTOM_LEFT_PANE] =
1699 mwindow->edl->local_session->view_start[TOP_LEFT_PANE];
1700 mwindow->edl->local_session->track_start[BOTTOM_LEFT_PANE] =
1701 mwindow->edl->local_session->track_start[TOP_LEFT_PANE] +
1703 mwindow->theme->mtimebar_h;
1704 // do this 1st so the resize_event knows there are 2 panes
1705 pane[BOTTOM_LEFT_PANE] = new TimelinePane(mwindow,
1707 mwindow->theme->mcanvas_x,
1708 mwindow->theme->mcanvas_y +
1710 mwindow->theme->mcanvas_w,
1711 mwindow->theme->mcanvas_h -
1713 pane[TOP_LEFT_PANE]->resize_event(
1714 mwindow->theme->mcanvas_x,
1715 mwindow->theme->mcanvas_y,
1716 mwindow->theme->mcanvas_w,
1717 pane[BOTTOM_LEFT_PANE]->y -
1718 mwindow->theme->mcanvas_y -
1719 mwindow->theme->pane_h);
1720 pane[BOTTOM_LEFT_PANE]->create_objects();
1723 if(horizontal_panes())
1726 mwindow->edl->local_session->view_start[BOTTOM_LEFT_PANE] =
1727 mwindow->edl->local_session->view_start[TOP_LEFT_PANE];
1728 mwindow->edl->local_session->view_start[BOTTOM_RIGHT_PANE] =
1729 mwindow->edl->local_session->view_start[TOP_RIGHT_PANE];
1730 mwindow->edl->local_session->track_start[BOTTOM_LEFT_PANE] =
1731 mwindow->edl->local_session->track_start[BOTTOM_RIGHT_PANE] =
1732 mwindow->edl->local_session->track_start[TOP_LEFT_PANE] +
1734 mwindow->theme->mtimebar_h;
1736 pane[BOTTOM_LEFT_PANE] = new TimelinePane(mwindow,
1738 pane[TOP_LEFT_PANE]->x,
1739 mwindow->theme->mcanvas_y +
1741 pane[TOP_LEFT_PANE]->w,
1742 mwindow->theme->mcanvas_h -
1744 pane[BOTTOM_RIGHT_PANE] = new TimelinePane(mwindow,
1746 pane[TOP_RIGHT_PANE]->x,
1747 mwindow->theme->mcanvas_y +
1749 pane[TOP_RIGHT_PANE]->w,
1750 mwindow->theme->mcanvas_h -
1753 pane[TOP_LEFT_PANE]->resize_event(
1754 pane[TOP_LEFT_PANE]->x,
1755 pane[TOP_LEFT_PANE]->y,
1756 pane[TOP_LEFT_PANE]->w,
1757 pane[BOTTOM_LEFT_PANE]->y -
1758 mwindow->theme->mcanvas_y -
1759 mwindow->theme->pane_h);
1760 pane[TOP_RIGHT_PANE]->resize_event(
1761 pane[TOP_RIGHT_PANE]->x,
1762 pane[TOP_RIGHT_PANE]->y,
1763 pane[TOP_RIGHT_PANE]->w,
1764 pane[BOTTOM_RIGHT_PANE]->y -
1765 mwindow->theme->mcanvas_y -
1766 mwindow->theme->pane_h);
1768 pane[BOTTOM_LEFT_PANE]->create_objects();
1769 pane[BOTTOM_RIGHT_PANE]->create_objects();
1772 if(vertical_panes())
1775 mwindow->edl->local_session->track_start[BOTTOM_LEFT_PANE] +=
1777 (pane[BOTTOM_LEFT_PANE]->y - mwindow->theme->mcanvas_y);
1778 if(mwindow->edl->local_session->track_start[BOTTOM_LEFT_PANE] < 0)
1779 mwindow->edl->local_session->track_start[BOTTOM_LEFT_PANE] = 0;
1780 pane[TOP_LEFT_PANE]->resize_event(
1781 mwindow->theme->mcanvas_x,
1782 mwindow->theme->mcanvas_y,
1783 mwindow->theme->mcanvas_w,
1784 cursor_y - mwindow->theme->pane_h);
1785 pane[BOTTOM_LEFT_PANE]->resize_event(
1786 pane[BOTTOM_LEFT_PANE]->x,
1788 mwindow->theme->mcanvas_y,
1789 mwindow->theme->mcanvas_w,
1790 mwindow->theme->mcanvas_h -
1796 mwindow->edl->local_session->track_start[BOTTOM_LEFT_PANE] +=
1798 (pane[BOTTOM_LEFT_PANE]->y - mwindow->theme->mcanvas_y);
1799 if(mwindow->edl->local_session->track_start[BOTTOM_LEFT_PANE] < 0)
1800 mwindow->edl->local_session->track_start[BOTTOM_LEFT_PANE] = 0;
1801 mwindow->edl->local_session->track_start[BOTTOM_RIGHT_PANE] =
1802 mwindow->edl->local_session->track_start[BOTTOM_LEFT_PANE];
1803 pane[TOP_LEFT_PANE]->resize_event(
1804 pane[TOP_LEFT_PANE]->x,
1805 pane[TOP_LEFT_PANE]->y,
1806 pane[TOP_LEFT_PANE]->w,
1807 cursor_y - mwindow->theme->pane_h);
1808 pane[BOTTOM_LEFT_PANE]->resize_event(
1809 pane[BOTTOM_LEFT_PANE]->x,
1811 mwindow->theme->mcanvas_y,
1812 pane[BOTTOM_LEFT_PANE]->w,
1813 mwindow->theme->mcanvas_h -
1815 pane[TOP_RIGHT_PANE]->resize_event(
1816 pane[TOP_RIGHT_PANE]->x,
1817 pane[TOP_RIGHT_PANE]->y,
1818 pane[TOP_RIGHT_PANE]->w,
1819 cursor_y - mwindow->theme->pane_h);
1820 pane[BOTTOM_RIGHT_PANE]->resize_event(
1821 pane[BOTTOM_RIGHT_PANE]->x,
1823 mwindow->theme->mcanvas_y,
1824 pane[BOTTOM_RIGHT_PANE]->w,
1825 mwindow->theme->mcanvas_h -
1830 void MWindowGUI::delete_y_pane(int cursor_y)
1832 if(cursor_y < mwindow->theme->mtimebar_h +
1834 pane[BOTTOM_LEFT_PANE])
1836 // give top pane coordinates of bottom pane
1837 mwindow->edl->local_session->track_start[TOP_LEFT_PANE] =
1838 mwindow->edl->local_session->track_start[BOTTOM_LEFT_PANE] -
1839 pane[BOTTOM_LEFT_PANE]->y;
1840 if(mwindow->edl->local_session->track_start[TOP_LEFT_PANE] < 0)
1841 mwindow->edl->local_session->track_start[TOP_LEFT_PANE] = 0;
1842 mwindow->edl->local_session->track_start[TOP_RIGHT_PANE] =
1843 mwindow->edl->local_session->track_start[TOP_LEFT_PANE];
1847 switch(total_panes())
1850 delete pane[BOTTOM_LEFT_PANE];
1851 pane[BOTTOM_LEFT_PANE] = 0;
1852 pane[TOP_LEFT_PANE]->resize_event(
1853 mwindow->theme->mcanvas_x,
1854 mwindow->theme->mcanvas_y,
1855 mwindow->theme->mcanvas_w,
1856 mwindow->theme->mcanvas_h);
1860 // delete bottom 2 panes
1862 delete pane[BOTTOM_LEFT_PANE];
1863 pane[BOTTOM_LEFT_PANE] = 0;
1864 delete pane[BOTTOM_RIGHT_PANE];
1865 pane[BOTTOM_RIGHT_PANE] = 0;
1866 pane[TOP_LEFT_PANE]->resize_event(
1867 pane[TOP_LEFT_PANE]->x,
1868 mwindow->theme->mcanvas_y,
1869 pane[TOP_LEFT_PANE]->w,
1870 mwindow->theme->mcanvas_h);
1871 pane[TOP_RIGHT_PANE]->resize_event(
1872 pane[TOP_RIGHT_PANE]->x,
1873 mwindow->theme->mcanvas_y,
1874 pane[TOP_RIGHT_PANE]->w,
1875 mwindow->theme->mcanvas_h);
1880 void MWindowGUI::stop_pane_drag()
1883 resource_thread->stop_draw(0);
1887 // cursor position relative to canvas
1888 int cursor_x = x_pane_drag->get_x() -
1890 BC_DisplayInfo::get_left_border() -
1891 mwindow->theme->mcanvas_x +
1892 mwindow->theme->pane_w;
1897 if(cursor_x >= mwindow->theme->patchbay_w + PANE_DRAG_MARGIN &&
1898 cursor_x < mwindow->theme->mcanvas_w -
1899 BC_ScrollBar::get_span(SCROLL_VERT) -
1902 create_x_pane(cursor_x);
1903 mwindow->edl->local_session->x_pane = cursor_x;
1908 delete_x_pane(cursor_x);
1909 mwindow->edl->local_session->x_pane = -1;
1917 // cursor position relative to canvas
1918 int cursor_y = y_pane_drag->get_y() -
1920 BC_DisplayInfo::get_top_border() -
1921 mwindow->theme->mcanvas_y +
1922 mwindow->theme->pane_h;
1928 if(cursor_y >= mwindow->theme->mtimebar_h +
1930 cursor_y < mwindow->theme->mcanvas_h -
1931 BC_ScrollBar::get_span(SCROLL_HORIZ) -
1934 create_y_pane(cursor_y);
1935 mwindow->edl->local_session->y_pane = cursor_y;
1939 delete_y_pane(cursor_y);
1940 mwindow->edl->local_session->y_pane = -1;
1944 update_pane_dividers();
1946 // required to get new widgets to appear
1948 resource_thread->start_draw();
1951 // create panes from EDL
1952 void MWindowGUI::load_panes()
1954 int need_x_panes = 0;
1955 int need_y_panes = 0;
1956 // use names from create functions
1957 int cursor_x = mwindow->edl->local_session->x_pane;
1958 int cursor_y = mwindow->edl->local_session->y_pane;
1960 resource_thread->stop_draw(1);
1962 mwindow->theme->patchbay_w + PANE_DRAG_MARGIN &&
1964 mwindow->theme->mcanvas_w -
1965 BC_ScrollBar::get_span(SCROLL_VERT) -
1972 mwindow->theme->mtimebar_h + PANE_DRAG_MARGIN &&
1974 mwindow->theme->mcanvas_h -
1975 BC_ScrollBar::get_span(SCROLL_HORIZ) -
1981 //printf("MWindowGUI::load_panes %d %d %d\n", __LINE__, need_x_panes, need_y_panes);
1989 if(total_panes() == 1)
1992 //printf("MWindowGUI::load_panes %d\n", __LINE__);
1993 pane[TOP_RIGHT_PANE] = new TimelinePane(mwindow,
1995 mwindow->theme->mcanvas_x +
1997 mwindow->theme->mcanvas_y,
1998 mwindow->theme->mcanvas_x +
1999 mwindow->theme->mcanvas_w -
2001 cursor_y - mwindow->theme->pane_h);
2002 pane[BOTTOM_LEFT_PANE] = new TimelinePane(mwindow,
2004 mwindow->theme->mcanvas_x,
2005 mwindow->theme->mcanvas_y +
2007 cursor_x - mwindow->theme->pane_w,
2008 mwindow->theme->mcanvas_h -
2010 pane[BOTTOM_RIGHT_PANE] = new TimelinePane(mwindow,
2012 pane[TOP_RIGHT_PANE]->x,
2013 mwindow->theme->mcanvas_y +
2015 pane[TOP_RIGHT_PANE]->w,
2016 mwindow->theme->mcanvas_h -
2018 pane[TOP_LEFT_PANE]->resize_event(
2019 pane[TOP_LEFT_PANE]->x,
2020 pane[TOP_LEFT_PANE]->y,
2021 cursor_x - mwindow->theme->pane_w,
2022 cursor_y - mwindow->theme->pane_h);
2023 pane[TOP_RIGHT_PANE]->create_objects();
2024 pane[BOTTOM_LEFT_PANE]->create_objects();
2025 pane[BOTTOM_RIGHT_PANE]->create_objects();
2028 if(horizontal_panes())
2030 // create vertical panes
2031 //printf("MWindowGUI::load_panes %d\n", __LINE__);
2032 pane[BOTTOM_LEFT_PANE] = new TimelinePane(mwindow,
2034 mwindow->theme->mcanvas_x,
2035 mwindow->theme->mcanvas_y +
2037 cursor_x - mwindow->theme->pane_w,
2038 mwindow->theme->mcanvas_h -
2040 pane[BOTTOM_RIGHT_PANE] = new TimelinePane(mwindow,
2042 pane[TOP_RIGHT_PANE]->x,
2043 mwindow->theme->mcanvas_y +
2045 pane[TOP_RIGHT_PANE]->w,
2046 mwindow->theme->mcanvas_h -
2048 pane[TOP_LEFT_PANE]->resize_event(
2049 pane[TOP_LEFT_PANE]->x,
2050 pane[TOP_LEFT_PANE]->y,
2051 cursor_x - mwindow->theme->pane_w,
2052 cursor_y - mwindow->theme->pane_h);
2053 pane[TOP_RIGHT_PANE]->resize_event(
2054 mwindow->theme->mcanvas_x +
2056 mwindow->theme->mcanvas_y,
2057 mwindow->theme->mcanvas_x +
2058 mwindow->theme->mcanvas_w -
2060 cursor_y - mwindow->theme->pane_h);
2061 pane[BOTTOM_LEFT_PANE]->create_objects();
2062 pane[BOTTOM_RIGHT_PANE]->create_objects();
2065 if(vertical_panes())
2067 // create horizontal panes
2068 //printf("MWindowGUI::load_panes %d\n", __LINE__);
2069 pane[TOP_RIGHT_PANE] = new TimelinePane(mwindow,
2071 mwindow->theme->mcanvas_x +
2073 mwindow->theme->mcanvas_y,
2074 mwindow->theme->mcanvas_x +
2075 mwindow->theme->mcanvas_w -
2077 cursor_y - mwindow->theme->pane_h);
2078 pane[BOTTOM_RIGHT_PANE] = new TimelinePane(mwindow,
2080 pane[TOP_RIGHT_PANE]->x,
2081 mwindow->theme->mcanvas_y +
2083 pane[TOP_RIGHT_PANE]->w,
2084 mwindow->theme->mcanvas_h -
2086 pane[TOP_LEFT_PANE]->resize_event(
2087 pane[TOP_LEFT_PANE]->x,
2088 pane[TOP_LEFT_PANE]->y,
2089 cursor_x - mwindow->theme->pane_w,
2090 cursor_y - mwindow->theme->pane_h);
2091 pane[BOTTOM_LEFT_PANE]->resize_event(
2092 pane[TOP_LEFT_PANE]->x,
2093 mwindow->theme->mcanvas_y +
2095 mwindow->theme->mcanvas_x +
2096 mwindow->theme->mcanvas_w -
2097 cursor_x - mwindow->theme->pane_w,
2098 mwindow->theme->mcanvas_h -
2100 pane[TOP_RIGHT_PANE]->create_objects();
2101 pane[BOTTOM_RIGHT_PANE]->create_objects();
2108 //printf("MWindowGUI::load_panes %d\n", __LINE__);
2109 pane[TOP_LEFT_PANE]->resize_event(
2110 pane[TOP_LEFT_PANE]->x,
2111 pane[TOP_LEFT_PANE]->y,
2112 cursor_x - mwindow->theme->pane_w,
2113 cursor_y - mwindow->theme->pane_h);
2114 pane[TOP_RIGHT_PANE]->resize_event(
2115 mwindow->theme->mcanvas_x +
2117 mwindow->theme->mcanvas_y,
2118 mwindow->theme->mcanvas_x +
2119 mwindow->theme->mcanvas_w -
2121 cursor_y - mwindow->theme->pane_h);
2122 pane[BOTTOM_LEFT_PANE]->resize_event(
2123 pane[TOP_LEFT_PANE]->x,
2124 mwindow->theme->mcanvas_y +
2126 mwindow->theme->mcanvas_x +
2127 mwindow->theme->mcanvas_w -
2128 cursor_x - mwindow->theme->pane_w,
2129 mwindow->theme->mcanvas_h -
2131 pane[BOTTOM_RIGHT_PANE]->resize_event(
2132 pane[TOP_RIGHT_PANE]->x,
2133 mwindow->theme->mcanvas_y +
2135 pane[TOP_RIGHT_PANE]->w,
2136 mwindow->theme->mcanvas_h -
2145 if(pane[BOTTOM_LEFT_PANE]) delete pane[BOTTOM_LEFT_PANE];
2146 if(pane[BOTTOM_RIGHT_PANE]) delete pane[BOTTOM_RIGHT_PANE];
2147 pane[BOTTOM_LEFT_PANE] = 0;
2148 pane[BOTTOM_RIGHT_PANE] = 0;
2150 if(!pane[TOP_RIGHT_PANE])
2152 pane[TOP_RIGHT_PANE] = new TimelinePane(mwindow,
2154 mwindow->theme->mcanvas_x +
2156 mwindow->theme->mcanvas_y,
2157 mwindow->theme->mcanvas_x +
2158 mwindow->theme->mcanvas_w -
2160 mwindow->theme->mcanvas_h);
2161 pane[TOP_LEFT_PANE]->resize_event(
2162 mwindow->theme->mcanvas_x,
2163 mwindow->theme->mcanvas_y,
2164 cursor_x - mwindow->theme->pane_w,
2165 mwindow->theme->mcanvas_h);
2166 pane[TOP_RIGHT_PANE]->create_objects();
2170 pane[TOP_LEFT_PANE]->resize_event(
2171 mwindow->theme->mcanvas_x,
2172 mwindow->theme->mcanvas_y,
2173 cursor_x - mwindow->theme->pane_w,
2174 mwindow->theme->mcanvas_h);
2175 pane[TOP_RIGHT_PANE]->resize_event(
2176 mwindow->theme->mcanvas_x +
2178 pane[TOP_RIGHT_PANE]->y,
2179 mwindow->theme->mcanvas_x +
2180 mwindow->theme->mcanvas_w -
2182 mwindow->theme->mcanvas_h);
2190 if(pane[TOP_RIGHT_PANE]) delete pane[TOP_RIGHT_PANE];
2191 if(pane[BOTTOM_RIGHT_PANE]) delete pane[BOTTOM_RIGHT_PANE];
2192 pane[TOP_RIGHT_PANE] = 0;
2193 pane[BOTTOM_RIGHT_PANE] = 0;
2195 if(!pane[BOTTOM_LEFT_PANE])
2197 //printf("MWindowGUI::load_panes %d\n", __LINE__);
2198 pane[BOTTOM_LEFT_PANE] = new TimelinePane(mwindow,
2200 mwindow->theme->mcanvas_x,
2201 mwindow->theme->mcanvas_y +
2203 mwindow->theme->mcanvas_w,
2204 mwindow->theme->mcanvas_h -
2206 pane[TOP_LEFT_PANE]->resize_event(
2207 mwindow->theme->mcanvas_x,
2208 mwindow->theme->mcanvas_y,
2209 mwindow->theme->mcanvas_w,
2210 pane[BOTTOM_LEFT_PANE]->y -
2211 mwindow->theme->mcanvas_y -
2212 mwindow->theme->pane_h);
2213 pane[BOTTOM_LEFT_PANE]->create_objects();
2217 pane[TOP_LEFT_PANE]->resize_event(
2218 mwindow->theme->mcanvas_x,
2219 mwindow->theme->mcanvas_y,
2220 mwindow->theme->mcanvas_w,
2221 cursor_y - mwindow->theme->pane_h);
2222 pane[BOTTOM_LEFT_PANE]->resize_event(
2223 pane[BOTTOM_LEFT_PANE]->x,
2225 mwindow->theme->mcanvas_y,
2226 mwindow->theme->mcanvas_w,
2227 mwindow->theme->mcanvas_h -
2234 if(pane[TOP_RIGHT_PANE]) delete pane[TOP_RIGHT_PANE];
2235 if(pane[BOTTOM_RIGHT_PANE]) delete pane[BOTTOM_RIGHT_PANE];
2236 if(pane[BOTTOM_LEFT_PANE]) delete pane[BOTTOM_LEFT_PANE];
2237 pane[TOP_RIGHT_PANE] = 0;
2238 pane[BOTTOM_RIGHT_PANE] = 0;
2239 pane[BOTTOM_LEFT_PANE] = 0;
2240 pane[TOP_LEFT_PANE]->resize_event(
2241 mwindow->theme->mcanvas_x,
2242 mwindow->theme->mcanvas_y,
2243 mwindow->theme->mcanvas_w,
2244 mwindow->theme->mcanvas_h);
2247 update_pane_dividers();
2250 resource_thread->start_draw();
2253 void MWindowGUI::update_pane_dividers()
2256 if(horizontal_panes() || total_panes() == 4)
2258 int x = pane[TOP_RIGHT_PANE]->x - mwindow->theme->pane_w;
2259 int y = mwindow->theme->mcanvas_y;
2260 int h = mwindow->theme->mcanvas_h;
2264 add_subwindow(x_divider = new PaneDivider(
2265 mwindow, x, y, h, 1));
2266 x_divider->create_objects();
2270 x_divider->reposition_window(x, y, h);
2283 if(vertical_panes() || total_panes() == 4)
2285 int x = mwindow->theme->mcanvas_x;
2286 int y = pane[BOTTOM_LEFT_PANE]->y -
2287 mwindow->theme->pane_h;
2288 int w = mwindow->theme->mcanvas_w;
2291 add_subwindow(y_divider = new PaneDivider(
2292 mwindow, x, y, w, 0));
2293 y_divider->create_objects();
2297 y_divider->reposition_window(x, y, w);
2311 void MWindowGUI::draw_samplemovement()
2318 update_scrollbars(1);
2321 void MWindowGUI::draw_trackmovement()
2323 update_scrollbars(0);
2330 void MWindowGUI::update_mixers(Track *track, int v)
2332 for( int i=0; i<TOTAL_PANES; ++i ) {
2333 if( !pane[i] ) continue;
2334 PatchBay *patchbay = pane[i]->patchbay;
2335 if( !patchbay ) continue;
2336 for( int j=0; j<patchbay->patches.total; ++j ) {
2337 PatchGUI *patchgui = patchbay->patches.values[j];
2338 if( !patchgui->mix ) continue;
2339 if( !track || patchgui->track == track ) {
2340 patchgui->mix->update(v>=0 ? v :
2341 mwindow->mixer_track_active(patchgui->track));
2347 void MWindowGUI::stop_transport(const char *lock_msg)
2349 if( !mbuttons->transport->is_stopped() ) {
2350 if( lock_msg ) unlock_window();
2351 mbuttons->transport->handle_transport(STOP, 1, 0, 0);
2352 if( lock_msg ) lock_window(lock_msg);
2356 PaneButton::PaneButton(MWindow *mwindow, int x, int y)
2357 : BC_Button(x, y, mwindow->theme->get_image_set("pane"))
2359 this->mwindow = mwindow;
2362 int PaneButton::cursor_motion_event()
2364 if(get_top_level()->get_button_down() &&
2366 get_status() == BUTTON_DOWNHI &&
2369 // printf("PaneButton::cursor_motion_event %d\n", __LINE__);
2371 if(get_cursor_x() < 0 && !mwindow->gui->dragging_pane)
2373 mwindow->gui->start_x_pane_drag();
2376 if(get_cursor_y() < 0 && !mwindow->gui->dragging_pane)
2378 mwindow->gui->start_y_pane_drag();
2382 mwindow->gui->handle_pane_drag();
2384 int result = BC_Button::cursor_motion_event();
2388 int PaneButton::button_release_event()
2390 if( get_buttonpress() != WHEEL_DOWN && get_buttonpress() != WHEEL_UP )
2391 mwindow->gui->stop_pane_drag();
2392 int result = BC_Button::button_release_event();
2397 FFMpegToggle::FFMpegToggle(MWindow *mwindow, MButtons *mbuttons, int x, int y)
2398 : BC_Toggle(x, y, mwindow->theme->ffmpeg_toggle,
2399 mwindow->preferences->get_file_probe_armed("FFMPEG_Early") > 0 ? 1 : 0)
2401 this->mwindow = mwindow;
2402 this->mbuttons = mbuttons;
2403 set_tooltip(get_value() ? FFMPEG_EARLY_TIP : FFMPEG_LATE_TIP);
2406 FFMpegToggle::~FFMpegToggle()
2410 int FFMpegToggle::handle_event()
2412 int ffmpeg_early_probe = get_value();
2413 set_tooltip(ffmpeg_early_probe ? FFMPEG_EARLY_TIP : FFMPEG_LATE_TIP);
2414 mwindow->preferences->set_file_probe_armed("FFMPEG_Early", ffmpeg_early_probe);
2415 mwindow->preferences->set_file_probe_armed("FFMPEG_Late", !ffmpeg_early_probe);
2417 mwindow->show_warning(&mwindow->preferences->warn_indexes,
2418 _("Changing the base codecs may require rebuilding indexes."));
2423 ProxyToggle::ProxyToggle(MWindow *mwindow, MButtons *mbuttons, int x, int y)
2424 : BC_Toggle(x, y, ( !mwindow->edl->session->proxy_use_scaler ?
2425 mwindow->theme->proxy_p_toggle :
2426 mwindow->theme->proxy_s_toggle ),
2427 mwindow->edl->session->proxy_disabled_scale != 1)
2429 this->mwindow = mwindow;
2430 this->mbuttons = mbuttons;
2431 scaler_images = mwindow->edl->session->proxy_use_scaler;
2432 set_tooltip(mwindow->edl->session->proxy_disabled_scale==1 ?
2433 _("Disable proxy") : _("Enable proxy"));
2436 void ProxyToggle::show()
2438 int use_scaler = mwindow->edl->session->proxy_use_scaler;
2439 if( scaler_images != use_scaler )
2440 set_images(!(scaler_images=use_scaler) ?
2441 mwindow->theme->proxy_p_toggle :
2442 mwindow->theme->proxy_s_toggle );
2448 void ProxyToggle::hide()
2454 ProxyToggle::~ProxyToggle()
2458 int ProxyToggle::handle_event()
2460 int disabled = get_value();
2461 mwindow->gui->unlock_window();
2463 mwindow->disable_proxy();
2465 mwindow->enable_proxy();
2466 mwindow->gui->lock_window("ProxyToggle::handle_event");
2467 set_tooltip(!disabled ? _("Disable proxy") : _("Enable proxy"));
2471 int ProxyToggle::keypress_event()
2473 if( ctrl_down() && !shift_down() && !alt_down() ) {
2474 int key = get_keypress();
2476 int value = get_value() ? 0 : 1;
2478 return handle_event();