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"
39 #include "keyframepopup.h"
42 #include "localsession.h"
43 #include "mainclock.h"
44 #include "maincursor.h"
46 #include "mainsession.h"
50 #include "mwindowgui.h"
52 #include "panedividers.h"
55 #include "pluginpopup.h"
56 #include "pluginset.h"
57 #include "preferences.h"
59 #include "recordgui.h"
60 #include "renderengine.h"
61 #include "resourcethread.h"
62 #include "samplescroll.h"
63 #include "shbtnprefs.h"
64 #include "statusbar.h"
67 #include "trackcanvas.h"
68 #include "trackpopup.h"
69 #include "trackscroll.h"
71 #include "transitionpopup.h"
72 #include "vwindowgui.h"
76 #define PANE_DRAG_MARGIN MAX(mwindow->theme->pane_w, mwindow->theme->pane_h)
79 // the main window uses its own private colormap for video
80 MWindowGUI::MWindowGUI(MWindow *mwindow)
81 : BC_Window(_(PROGRAM_NAME ": Program"),
82 mwindow->session->mwindow_x,
83 mwindow->session->mwindow_y,
84 mwindow->session->mwindow_w,
85 mwindow->session->mwindow_h,
92 this->mwindow = mwindow;
99 focused_pane = TOP_LEFT_PANE;
108 for(int i = 0; i < TOTAL_PANES; i++)
128 cwindow_remote_handler = 0;
129 record_remote_handler = 0;
134 MWindowGUI::~MWindowGUI()
136 delete android_control;
137 delete cwindow_remote_handler;
138 delete record_remote_handler;
139 delete remote_control;
140 delete keyvalue_popup;
141 // delete samplescroll;
142 // delete trackscroll;
143 for(int i = 0; i < TOTAL_PANES; i++)
144 if(pane[i]) delete pane[i];
146 delete render_engine;
147 delete resource_thread;
148 resource_pixmaps.remove_all_objects();
159 void MWindowGUI::get_scrollbars(int flush)
161 //int64_t h_needed = mwindow->edl->get_tracks_height(mwindow->theme);
162 //int64_t w_needed = mwindow->edl->get_tracks_width();
163 int need_xscroll = 0;
164 int need_yscroll = 0;
165 view_w = mwindow->theme->mcanvas_w;
166 view_h = mwindow->theme->mcanvas_h;
168 // Scrollbars are constitutive
169 need_xscroll = need_yscroll = 1;
170 view_h = mwindow->theme->mcanvas_h;
171 view_w = mwindow->theme->mcanvas_w;
173 // for(int i = 0; i < 2; i++)
175 // if(w_needed > view_w)
178 // view_h = mwindow->theme->mcanvas_h - SCROLL_SPAN;
183 // if(h_needed > view_h)
186 // view_w = mwindow->theme->mcanvas_w - SCROLL_SPAN;
191 //printf("MWindowGUI::get_scrollbars 1\n");
193 if(canvas && (view_w != canvas->get_w() || view_h != canvas->get_h()))
195 canvas->reposition_window(mwindow->theme->mcanvas_x,
196 mwindow->theme->mcanvas_y,
204 add_subwindow(samplescroll = new SampleScroll(mwindow,
206 mwindow->theme->mhscroll_x,
207 mwindow->theme->mhscroll_y,
208 mwindow->theme->mhscroll_w));
210 samplescroll->resize_event();
212 samplescroll->set_position(0);
216 if(samplescroll) delete samplescroll;
218 mwindow->edl->local_session->view_start = 0;
224 //printf("MWindowGUI::get_scrollbars 1.1 %p %p\n", this, canvas);
226 add_subwindow(trackscroll = new TrackScroll(mwindow,
228 mwindow->theme->mvscroll_x,
229 mwindow->theme->mvscroll_y,
230 mwindow->theme->mvscroll_h));
232 trackscroll->resize_event();
235 //printf("MWindowGUI::get_scrollbars 1.2\n");
236 trackscroll->update_length(mwindow->edl->get_tracks_height(mwindow->theme),
237 mwindow->edl->local_session->track_start,
240 //printf("MWindowGUI::get_scrollbars 1.3\n");
244 if(trackscroll) delete trackscroll;
246 mwindow->edl->local_session->track_start = 0;
249 if(flush) this->flush();
254 void MWindowGUI::create_objects()
256 lock_window("MWindowGUI::create_objects");
259 resource_thread = new ResourceThread(mwindow, this);
260 resource_thread->create_objects();
263 if(debug) printf("MWindowGUI::create_objects %d\n", __LINE__);
264 set_icon(mwindow->theme->get_image("mwindow_icon"));
265 remote_control = new RemoteControl(this);
266 cwindow_remote_handler = new CWindowRemoteHandler(remote_control);
267 record_remote_handler = new RecordRemoteHandler(remote_control);
268 mwindow->reset_android_remote();
270 if(debug) printf("MWindowGUI::create_objects %d\n", __LINE__);
272 int x = get_w() - MainShBtns::calculate_w(0);
273 add_subwindow(mainmenu = new MainMenu(mwindow, this, x));
274 mainmenu->create_objects();
275 add_subwindow(mainshbtns = new MainShBtns(mwindow, x, -1));
276 mainshbtns->load(mwindow->preferences);
277 mwindow->theme->get_mwindow_sizes(this, get_w(), get_h());
278 mwindow->theme->draw_mwindow_bg(this);
279 if(debug) printf("MWindowGUI::create_objects %d\n", __LINE__);
281 add_subwindow(mbuttons = new MButtons(mwindow, this));
282 mbuttons->create_objects();
283 int x1 = mbuttons->get_x() + mbuttons->get_w(), y1 = mbuttons->get_y()+2;
284 add_subwindow(proxy_toggle = new ProxyToggle(mwindow, mbuttons, x1, y1));
285 x1 += proxy_toggle->get_w() + 3;
286 add_subwindow(ffmpeg_toggle = new FFMpegToggle(mwindow, mbuttons, x1, y1));
288 pane[TOP_LEFT_PANE] = new TimelinePane(mwindow,
290 mwindow->theme->mcanvas_x,
291 mwindow->theme->mcanvas_y,
292 mwindow->theme->mcanvas_w,
293 mwindow->theme->mcanvas_h);
294 pane[TOP_LEFT_PANE]->create_objects();
296 // add_subwindow(timebar = new MTimeBar(mwindow,
298 // mwindow->theme->mtimebar_x,
299 // mwindow->theme->mtimebar_y,
300 // mwindow->theme->mtimebar_w,
301 // mwindow->theme->mtimebar_h));
302 // timebar->create_objects();
304 // if(debug) printf("MWindowGUI::create_objects %d\n", __LINE__);
305 // add_subwindow(patchbay = new PatchBay(mwindow, this));
306 // patchbay->create_objects();
308 // if(debug) printf("MWindowGUI::create_objects %d\n", __LINE__);
309 // get_scrollbars(0);
311 // if(debug) printf("MWindowGUI::create_objects %d\n", __LINE__);
312 // mwindow->gui->add_subwindow(canvas = new TrackCanvas(mwindow, this));
313 // canvas->create_objects();
316 if(debug) printf("MWindowGUI::create_objects %d\n", __LINE__);
317 add_subwindow(zoombar = new ZoomBar(mwindow, this));
318 zoombar->create_objects();
321 if(debug) printf("MWindowGUI::create_objects %d\n", __LINE__);
322 add_subwindow(statusbar = new StatusBar(mwindow, this));
323 statusbar->create_objects();
327 if(debug) printf("MWindowGUI::create_objects %d\n", __LINE__);
328 add_subwindow(mainclock = new MainClock(mwindow,
329 mwindow->theme->mclock_x, mwindow->theme->mclock_y,
330 mwindow->theme->mclock_w));
331 if(debug) printf("MWindowGUI::create_objects %d\n", __LINE__);
332 mainclock->update(0);
336 // if(debug) printf("MWindowGUI::create_objects %d\n", __LINE__);
337 // cursor = new MainCursor(mwindow, this);
338 // cursor->create_objects();
341 if(debug) printf("MWindowGUI::create_objects %d\n", __LINE__);
342 add_subwindow(track_menu = new TrackPopup(mwindow, this));
343 track_menu->create_objects();
344 if(debug) printf("MWindowGUI::create_objects %d\n", __LINE__);
345 add_subwindow(edit_menu = new EditPopup(mwindow, this));
346 edit_menu->create_objects();
349 if(debug) printf("MWindowGUI::create_objects %d\n", __LINE__);
350 add_subwindow(plugin_menu = new PluginPopup(mwindow, this));
351 plugin_menu->create_objects();
354 if(debug) printf("MWindowGUI::create_objects %d\n", __LINE__);
355 add_subwindow(keyframe_menu = new KeyframePopup(mwindow, this));
356 keyframe_menu->create_objects();
357 add_subwindow(keyframe_hide = new KeyframeHidePopup(mwindow, this));
358 keyframe_hide->create_objects();
361 if(debug) printf("MWindowGUI::create_objects %d\n", __LINE__);
362 add_subwindow(transition_menu = new TransitionPopup(mwindow, this));
363 transition_menu->create_objects();
366 channel_info = new ChannelInfo(mwindow);
368 #ifdef HAVE_COMMERCIAL
369 db_window = new DbWindow(mwindow);
371 swindow = new SWindow(mwindow);
373 if(debug) printf("MWindowGUI::create_objects %d\n", __LINE__);
375 add_subwindow(pane_button = new PaneButton(mwindow,
376 get_w() - mwindow->theme->get_image_set("pane")[0]->get_w(),
377 mwindow->theme->mzoom_y + 1 - mwindow->theme->get_image_set("pane")[0]->get_h()));
379 pane[TOP_LEFT_PANE]->canvas->activate();
381 if(debug) printf("MWindowGUI::create_objects %d\n", __LINE__);
385 void MWindowGUI::redraw_time_dependancies()
387 zoombar->redraw_time_dependancies();
388 for(int i = 0; i < TOTAL_PANES; i++)
389 if(pane[i] && pane[i]->timebar) pane[i]->timebar->update(0);
390 mainclock->update(mwindow->edl->local_session->get_selectionstart(1));
393 int MWindowGUI::focus_in_event()
395 for(int i = 0; i < TOTAL_PANES; i++)
396 if(pane[i]) pane[i]->cursor->focus_in_event();
400 int MWindowGUI::focus_out_event()
402 for(int i = 0; i < TOTAL_PANES; i++)
403 if(pane[i]) pane[i]->cursor->focus_out_event();
408 int MWindowGUI::resize_event(int w, int h)
410 //printf("MWindowGUI::resize_event %d\n", __LINE__);
411 mwindow->session->mwindow_w = w;
412 mwindow->session->mwindow_h = h;
413 int x = w - MainShBtns::calculate_w(0);
414 mainmenu->resize_event(x, mainmenu->get_h());
415 mainshbtns->reposition_window(x, -1);
416 mwindow->theme->get_mwindow_sizes(this, w, h);
417 mwindow->theme->draw_mwindow_bg(this);
418 mbuttons->resize_event();
419 int x1 = mbuttons->get_x() + mbuttons->get_w(), y1 = mbuttons->get_y()+2;
420 proxy_toggle->reposition_window(x1, y1);
421 x1 += proxy_toggle->get_w() + 3;
422 ffmpeg_toggle->reposition_window(x1, y1);
423 statusbar->resize_event();
424 zoombar->resize_event();
426 resource_thread->stop_draw(1);
428 if(total_panes() > 1)
430 if(horizontal_panes())
432 // printf("MWindowGUI::resize_event %d %d %d\n",
434 // pane[TOP_RIGHT_PANE]->x,
435 // mwindow->theme->mcanvas_w -
436 // BC_ScrollBar::get_span(SCROLL_VERT) -
437 // PANE_DRAG_MARGIN);
438 if(pane[TOP_RIGHT_PANE]->x >= mwindow->theme->mcanvas_w -
439 BC_ScrollBar::get_span(SCROLL_VERT) -
442 delete_x_pane(pane[TOP_RIGHT_PANE]->x);
443 mwindow->edl->local_session->x_pane = -1;
449 if(pane[BOTTOM_LEFT_PANE]->y >= mwindow->theme->mzoom_y -
450 BC_ScrollBar::get_span(SCROLL_HORIZ) -
453 delete_y_pane(pane[BOTTOM_LEFT_PANE]->y);
454 mwindow->edl->local_session->y_pane = -1;
459 if(pane[TOP_RIGHT_PANE]->x >= mwindow->theme->mcanvas_w -
460 BC_ScrollBar::get_span(SCROLL_VERT) -
463 delete_x_pane(pane[TOP_RIGHT_PANE]->x);
464 mwindow->edl->local_session->x_pane = -1;
467 if(pane[BOTTOM_LEFT_PANE]->y >= mwindow->theme->mzoom_y -
468 BC_ScrollBar::get_span(SCROLL_HORIZ) -
471 delete_y_pane(pane[BOTTOM_LEFT_PANE]->y);
472 mwindow->edl->local_session->y_pane = -1;
477 if(total_panes() == 1)
479 pane[TOP_LEFT_PANE]->resize_event(
480 mwindow->theme->mcanvas_x,
481 mwindow->theme->mcanvas_y,
482 mwindow->theme->mcanvas_w,
483 mwindow->theme->mcanvas_h);
486 if(horizontal_panes())
488 pane[TOP_LEFT_PANE]->resize_event(
489 pane[TOP_LEFT_PANE]->x,
490 pane[TOP_LEFT_PANE]->y,
491 pane[TOP_LEFT_PANE]->w,
492 mwindow->theme->mcanvas_h);
493 pane[TOP_RIGHT_PANE]->resize_event(
494 pane[TOP_RIGHT_PANE]->x,
495 pane[TOP_RIGHT_PANE]->y,
496 mwindow->theme->mcanvas_w - pane[TOP_RIGHT_PANE]->x,
497 mwindow->theme->mcanvas_h);
502 pane[TOP_LEFT_PANE]->resize_event(
503 pane[TOP_LEFT_PANE]->x,
504 pane[TOP_LEFT_PANE]->y,
505 mwindow->theme->mcanvas_w,
506 pane[TOP_LEFT_PANE]->h);
507 pane[BOTTOM_LEFT_PANE]->resize_event(
508 pane[BOTTOM_LEFT_PANE]->x,
509 pane[BOTTOM_LEFT_PANE]->y,
510 mwindow->theme->mcanvas_w,
511 mwindow->theme->mcanvas_y +
512 mwindow->theme->mcanvas_h -
513 pane[BOTTOM_LEFT_PANE]->y);
517 pane[TOP_LEFT_PANE]->resize_event(
518 pane[TOP_LEFT_PANE]->x,
519 pane[TOP_LEFT_PANE]->y,
520 pane[TOP_LEFT_PANE]->w,
521 pane[TOP_LEFT_PANE]->h);
522 pane[TOP_RIGHT_PANE]->resize_event(
523 pane[TOP_RIGHT_PANE]->x,
524 pane[TOP_RIGHT_PANE]->y,
525 mwindow->theme->mcanvas_w - pane[TOP_RIGHT_PANE]->x,
526 pane[TOP_RIGHT_PANE]->h);
527 pane[BOTTOM_LEFT_PANE]->resize_event(
528 pane[BOTTOM_LEFT_PANE]->x,
529 pane[BOTTOM_LEFT_PANE]->y,
530 pane[BOTTOM_LEFT_PANE]->w,
531 mwindow->theme->mcanvas_y +
532 mwindow->theme->mcanvas_h -
533 pane[BOTTOM_LEFT_PANE]->y);
534 pane[BOTTOM_RIGHT_PANE]->resize_event(
535 pane[BOTTOM_RIGHT_PANE]->x,
536 pane[BOTTOM_RIGHT_PANE]->y,
537 mwindow->theme->mcanvas_w -
538 pane[BOTTOM_RIGHT_PANE]->x,
539 mwindow->theme->mcanvas_y +
540 mwindow->theme->mcanvas_h -
541 pane[BOTTOM_RIGHT_PANE]->y);
544 update_pane_dividers();
545 pane_button->reposition_window(w - mwindow->theme->get_image_set("pane")[0]->get_w(),
546 mwindow->theme->mzoom_y + 1 - mwindow->theme->get_image_set("pane")[0]->get_h());
547 resource_thread->start_draw();
553 int MWindowGUI::total_panes()
556 for(int i = 0; i < TOTAL_PANES; i++)
561 int MWindowGUI::vertical_panes()
563 return total_panes() == 2 &&
564 pane[TOP_LEFT_PANE] &&
565 pane[BOTTOM_LEFT_PANE];
568 int MWindowGUI::horizontal_panes()
570 return total_panes() == 2 &&
571 pane[TOP_LEFT_PANE] &&
572 pane[TOP_RIGHT_PANE];
575 TimelinePane* MWindowGUI::get_focused_pane()
577 if(pane[focused_pane]) return pane[focused_pane];
578 for(int i = 0; i < TOTAL_PANES; i++)
580 if(pane[i]) return pane[i];
585 void MWindowGUI::activate_timeline()
587 if(pane[focused_pane])
589 pane[focused_pane]->activate();
593 for(int i = 0; i < TOTAL_PANES; i++)
604 void MWindowGUI::deactivate_timeline()
606 for(int i = 0; i < TOTAL_PANES; i++)
610 pane[i]->canvas->deactivate();
615 void MWindowGUI::update_title(char *path)
618 char filename[BCTEXTLEN], string[BCTEXTLEN];
619 fs.extract_name(filename, path);
620 sprintf(string, _(PROGRAM_NAME ": %s"), filename);
622 //printf("MWindowGUI::update_title %s\n", string);
626 void MWindowGUI::draw_overlays(int flash_it)
628 for(int i = 0; i < TOTAL_PANES; i++)
632 pane[i]->canvas->draw_overlays();
633 if(flash_it) pane[i]->canvas->flash();
638 void MWindowGUI::update_timebar(int flush_it)
640 for(int i = 0; i < TOTAL_PANES; i++)
642 if(pane[i] && pane[i]->timebar)
644 pane[i]->timebar->update(flush_it);
649 void MWindowGUI::update_timebar_highlights()
651 for(int i = 0; i < TOTAL_PANES; i++)
653 if(pane[i] && pane[i]->timebar)
655 pane[i]->timebar->update_highlights();
661 void MWindowGUI::update_patchbay()
663 for(int i = 0; i < TOTAL_PANES; i++)
665 if(pane[i] && pane[i]->patchbay)
667 pane[i]->patchbay->update();
672 void MWindowGUI::update_proxy_toggle()
674 int value = mwindow->edl->session->proxy_scale == 1 ? 1 : 0;
675 proxy_toggle->set_value(value);
676 if( mwindow->edl->session->proxy_scale == 1 &&
677 mwindow->edl->session->proxy_disabled_scale == 1 )
678 proxy_toggle->hide();
680 proxy_toggle->show();
683 void MWindowGUI::update_plugintoggles()
685 for(int i = 0; i < TOTAL_PANES; i++)
689 pane[i]->canvas->refresh_plugintoggles();
695 void MWindowGUI::draw_indexes(Indexable *indexable)
697 for(int i = 0; i < TOTAL_PANES; i++)
701 pane[i]->canvas->draw_indexes(indexable);
706 void MWindowGUI::draw_canvas(int redraw, int hide_cursor)
708 resource_thread->stop_draw(0);
710 int mode = redraw ? FORCE_REDRAW : NORMAL_DRAW;
711 for(int i = 0; i < TOTAL_PANES; i++) {
713 pane[i]->canvas->draw(mode, hide_cursor);
716 resource_thread->start_draw();
719 void MWindowGUI::flash_canvas(int flush)
721 for(int i = 0; i < TOTAL_PANES; i++)
725 pane[i]->canvas->flash(flush);
730 int MWindowGUI::show_window(int flush)
732 int ret = BC_WindowBase::show_window(flush);
733 update_proxy_toggle();
737 void MWindowGUI::draw_cursor(int do_plugintoggles)
739 for(int i = 0; i < TOTAL_PANES; i++)
743 pane[i]->cursor->draw(do_plugintoggles);
748 void MWindowGUI::show_cursor(int do_plugintoggles)
750 for(int i = 0; i < TOTAL_PANES; i++)
754 pane[i]->cursor->show(do_plugintoggles);
759 void MWindowGUI::hide_cursor(int do_plugintoggles)
761 for(int i = 0; i < TOTAL_PANES; i++)
765 pane[i]->cursor->hide(do_plugintoggles);
770 void MWindowGUI::update_cursor()
772 for(int i = 0; i < TOTAL_PANES; i++)
776 pane[i]->cursor->update();
781 void MWindowGUI::set_playing_back(int value)
783 for(int i = 0; i < TOTAL_PANES; i++)
787 pane[i]->cursor->playing_back = value;
792 void MWindowGUI::update_scrollbars(int flush)
794 for(int i = 0; i < TOTAL_PANES; i++)
798 pane[i]->update(1, NO_DRAW, 0, 0);
801 if(flush) this->flush();
804 void MWindowGUI::reset_meters()
806 for(int i = 0; i < TOTAL_PANES; i++)
808 if(pane[i] && pane[i]->patchbay)
810 pane[i]->patchbay->reset_meters();
815 void MWindowGUI::stop_meters()
817 for(int i = 0; i < TOTAL_PANES; i++)
819 if(pane[i] && pane[i]->patchbay)
821 pane[i]->patchbay->stop_meters();
826 void MWindowGUI::update_meters(ArrayList<double> *module_levels)
828 for(int i = 0; i < TOTAL_PANES; i++)
830 if(pane[i] && pane[i]->patchbay)
832 pane[i]->patchbay->update_meters(module_levels);
837 void MWindowGUI::set_editing_mode(int flush)
839 for(int i = 0; i < TOTAL_PANES; i++)
843 pane[i]->canvas->update_cursor(flush);
848 void MWindowGUI::set_meter_format(int mode, int min, int max)
850 for(int i = 0; i < TOTAL_PANES; i++)
852 if(pane[i] && pane[i]->patchbay)
854 pane[i]->patchbay->set_meter_format(mode, min, max);
859 void MWindowGUI::update(int scrollbars,
868 if(debug) PRINT_TRACE
872 mwindow->edl->tracks->update_y_pixels(mwindow->theme);
874 if( do_canvas != NO_DRAW && do_canvas != IGNORE_THREAD )
875 resource_thread->stop_draw(1);
877 for(int i = 0; i < TOTAL_PANES; i++)
879 if(pane[i]) pane[i]->update(scrollbars,
885 if( do_canvas != NO_DRAW && do_canvas != IGNORE_THREAD )
886 resource_thread->start_draw();
888 // if(scrollbars) this->get_scrollbars(0);
889 // if(timebar) this->timebar->update(0);
890 if(zoombar) this->zoombar->update();
891 // if(patchbay) this->patchbay->update();
892 if(clock) this->mainclock->update(
893 mwindow->edl->local_session->get_selectionstart(1));
894 if(debug) PRINT_TRACE
900 // this->canvas->draw(do_canvas);
901 // this->cursor->show();
902 // this->canvas->flash(0);
903 // Activate causes the menubar to deactivate. Don't want this for
905 // if(canvas != IGNORE_THREAD) this->canvas->activate();
907 if(debug) PRINT_TRACE
911 if(buttonbar) mbuttons->update();
912 if(debug) PRINT_TRACE
914 // Can't age if the cache called this to draw missing picons
915 // or the GUI is updating the status of the draw toggle.
916 if( do_canvas != FORCE_REDRAW && do_canvas != IGNORE_THREAD ) {
918 mwindow->age_caches();
919 lock_window("MWindowGUI::update");
923 if(debug) PRINT_TRACE
926 int MWindowGUI::visible(int64_t x1, int64_t x2, int64_t view_x1, int64_t view_x2)
928 return (x1 >= view_x1 && x1 < view_x2) ||
929 (x2 > view_x1 && x2 <= view_x2) ||
930 (x1 <= view_x1 && x2 >= view_x2);
934 void MWindowGUI::show_message(const char *message, int color)
936 statusbar->show_message(message, color);
939 void MWindowGUI::update_default_message()
941 statusbar->update_default_message();
944 void MWindowGUI::reset_default_message()
946 statusbar->reset_default_message();
949 void MWindowGUI::default_message()
951 statusbar->default_message();
954 // Drag motion called from other window
955 int MWindowGUI::drag_motion()
957 if(get_hidden()) return 0;
959 Track *over_track = 0;
961 PluginSet *over_pluginset = 0;
962 Plugin *over_plugin = 0;
967 drag_popup->cursor_motion_event();
971 // there's no point in drawing highlights has until drag operation has been set
972 if (!mwindow->session->current_operation)
975 for(int i = 0; i < TOTAL_PANES; i++)
977 if(pane[i]) pane[i]->canvas->drag_motion(
984 if(mwindow->session->track_highlighted != over_track)
986 mwindow->session->track_highlighted = over_track;
990 if(mwindow->session->edit_highlighted != over_edit)
992 mwindow->session->edit_highlighted = over_edit;
996 if(mwindow->session->pluginset_highlighted != over_pluginset)
998 mwindow->session->pluginset_highlighted = over_pluginset;
1002 if(mwindow->session->plugin_highlighted != over_plugin)
1004 mwindow->session->plugin_highlighted = over_plugin;
1008 if( mwindow->session->current_operation == DRAG_ASSET ||
1009 mwindow->session->current_operation == DRAG_EDIT ||
1010 mwindow->session->current_operation == DRAG_AEFFECT_COPY ||
1011 mwindow->session->current_operation == DRAG_VEFFECT_COPY )
1017 // printf("drag_motion %d %d over_track=%p over_edit=%p\n",
1024 lock_window("MWindowGUI::drag_motion");
1031 int MWindowGUI::drag_stop()
1033 if(get_hidden()) return 0;
1034 int result = 0, redraw = 0;
1036 for(int i = 0; i < TOTAL_PANES; i++)
1038 if(pane[i]) result |= pane[i]->canvas->drag_stop(
1041 mwindow->edl->optimize();
1043 // since we don't have subwindows we have to terminate any drag operation
1046 if (mwindow->session->track_highlighted
1047 || mwindow->session->edit_highlighted
1048 || mwindow->session->plugin_highlighted
1049 || mwindow->session->pluginset_highlighted)
1051 mwindow->session->track_highlighted = 0;
1052 mwindow->session->edit_highlighted = 0;
1053 mwindow->session->plugin_highlighted = 0;
1054 mwindow->session->pluginset_highlighted = 0;
1055 mwindow->session->current_operation = NO_OPERATION;
1059 //printf("MWindowGUI::drag_stop %d %d\n", redraw, mwindow->session->current_operation);
1062 mwindow->edl->tracks->update_y_pixels(mwindow->theme);
1063 update_scrollbars(0);
1078 void MWindowGUI::default_positions()
1080 //printf("MWindowGUI::default_positions 1\n");
1081 VWindow *vwindow = mwindow->vwindows.size() > DEFAULT_VWINDOW ?
1082 mwindow->vwindows.get(DEFAULT_VWINDOW) : 0;
1083 if( vwindow && !vwindow->is_running() ) vwindow = 0;
1084 if( vwindow ) vwindow->gui->lock_window("MWindowGUI::default_positions");
1085 mwindow->cwindow->gui->lock_window("MWindowGUI::default_positions");
1086 mwindow->awindow->gui->lock_window("MWindowGUI::default_positions");
1088 // printf("MWindowGUI::default_positions 1 %d %d %d %d\n", mwindow->session->vwindow_x,
1089 // mwindow->session->vwindow_y,
1090 // mwindow->session->vwindow_w,
1091 // mwindow->session->vwindow_h);
1092 reposition_window(mwindow->session->mwindow_x,
1093 mwindow->session->mwindow_y,
1094 mwindow->session->mwindow_w,
1095 mwindow->session->mwindow_h);
1096 if( vwindow ) vwindow->gui->reposition_window(mwindow->session->vwindow_x,
1097 mwindow->session->vwindow_y,
1098 mwindow->session->vwindow_w,
1099 mwindow->session->vwindow_h);
1100 mwindow->cwindow->gui->reposition_window(mwindow->session->cwindow_x,
1101 mwindow->session->cwindow_y,
1102 mwindow->session->cwindow_w,
1103 mwindow->session->cwindow_h);
1104 mwindow->awindow->gui->reposition_window(mwindow->session->awindow_x,
1105 mwindow->session->awindow_y,
1106 mwindow->session->awindow_w,
1107 mwindow->session->awindow_h);
1108 //printf("MWindowGUI::default_positions 1\n");
1110 resize_event(mwindow->session->mwindow_w,
1111 mwindow->session->mwindow_h);
1112 //printf("MWindowGUI::default_positions 1\n");
1113 if( vwindow ) vwindow->gui->resize_event(mwindow->session->vwindow_w,
1114 mwindow->session->vwindow_h);
1115 //printf("MWindowGUI::default_positions 1\n");
1116 mwindow->cwindow->gui->resize_event(mwindow->session->cwindow_w,
1117 mwindow->session->cwindow_h);
1118 //printf("MWindowGUI::default_positions 1\n");
1119 mwindow->awindow->gui->resize_event(mwindow->session->awindow_w,
1120 mwindow->session->awindow_h);
1122 //printf("MWindowGUI::default_positions 1\n");
1125 if( vwindow ) vwindow->gui->flush();
1126 mwindow->cwindow->gui->flush();
1127 mwindow->awindow->gui->flush();
1129 if( vwindow ) vwindow->gui->unlock_window();
1130 mwindow->cwindow->gui->unlock_window();
1131 mwindow->awindow->gui->unlock_window();
1132 //printf("MWindowGUI::default_positions 2\n");
1136 int MWindowGUI::repeat_event(int64_t duration)
1138 // if(duration == 100)
1139 // mwindow->sync_parameters(CHANGE_ALL);
1141 for(int i = 0; i < TOTAL_PANES; i++)
1143 if(pane[i]) result = pane[i]->cursor->repeat_event(duration);
1149 int MWindowGUI::translation_event()
1151 //printf("MWindowGUI::translation_event 1 %d %d\n", get_x(), get_y());
1152 mwindow->session->mwindow_x = get_x();
1153 mwindow->session->mwindow_y = get_y();
1158 int MWindowGUI::save_defaults(BC_Hash *defaults)
1160 defaults->update("MWINDOWWIDTH", get_w());
1161 defaults->update("MWINDOWHEIGHT", get_h());
1162 mainmenu->save_defaults(defaults);
1163 BC_WindowBase::save_defaults(defaults);
1167 int MWindowGUI::keypress_event()
1169 //printf("MWindowGUI::keypress_event 1 %d\n", get_keypress());
1170 int result = mbuttons->keypress_event();
1171 if( result ) return result;
1173 Track *this_track = 0, *first_track = 0;
1174 int collapse = 0, packed = 0, overwrite = 0;
1175 double position = 0;
1177 switch( get_keypress() ) {
1179 if( !ctrl_down() || !shift_down() || alt_down() ) break;
1180 mwindow->edl->tracks->clear_selected_edits();
1185 mwindow->toggle_editing_mode();
1190 if( alt_down() ) break;
1191 stop_transport("MWindowGUI::keypress_event 1");
1192 mwindow->nearest_plugin_keyframe(shift_down(),
1193 !ctrl_down() ? PLAY_FORWARD : PLAY_REVERSE);
1200 if( !ctrl_down() || alt_down() ) break;
1201 mwindow->selected_to_clipboard(packed);
1205 overwrite = -1; // fall thru
1207 if( !ctrl_down() || alt_down() ) break;
1208 if( mwindow->session->current_operation == DROP_TARGETING ) {
1209 mwindow->session->current_operation = NO_OPERATION;
1210 mwindow->gui->set_editing_mode(1);
1212 for( ; pane_no<TOTAL_PANES; ++pane_no ) {
1213 if( !pane[pane_no] ) continue;
1214 first_track = pane[pane_no]->over_track();
1215 if( first_track ) break;
1218 int cursor_x = pane[pane_no]->canvas->get_relative_cursor_x();
1219 position = mwindow->edl->get_cursor_position(cursor_x, pane_no);
1223 position = mwindow->edl->local_session->get_selectionstart();
1224 mwindow->paste(position, first_track, 0, overwrite);
1225 mwindow->edl->tracks->clear_selected_edits();
1232 mwindow->cut_selected_edits(0, collapse);
1238 if( !ctrl_down() || alt_down() ) break;
1239 mwindow->cut_selected_edits(1, collapse);
1243 case '1': case '2': case '3': case '4':
1244 case '5': case '6': case '7': case '8':
1245 if( !alt_down() || shift_down() ) break;
1246 if( !mwindow->select_asset(get_keypress()-'1',1) )
1251 if( !ctrl_down() ) {
1253 stop_transport("MWindowGUI::keypress_event 1");
1254 mwindow->prev_edit_handle(shift_down());
1257 mwindow->move_left();
1263 if( !ctrl_down() && !alt_down() ) {
1264 mwindow->move_left();
1270 if( !ctrl_down() ) {
1272 stop_transport("MWindowGUI::keypress_event 2");
1273 mwindow->next_edit_handle(shift_down());
1276 mwindow->move_right();
1282 if( !ctrl_down() && !alt_down() ) {
1283 mwindow->move_right();
1289 if( ctrl_down() && !alt_down() )
1290 mwindow->expand_y();
1291 else if( !ctrl_down() && alt_down() )
1292 mwindow->expand_autos(0,1,1);
1293 else if( ctrl_down() && alt_down() )
1294 mwindow->expand_autos(1,1,1);
1296 mwindow->expand_sample();
1301 if( ctrl_down() && !alt_down() )
1302 mwindow->zoom_in_y();
1303 else if( !ctrl_down() && alt_down() )
1304 mwindow->shrink_autos(0,1,1);
1305 else if( ctrl_down() && alt_down() )
1306 mwindow->shrink_autos(1,1,1);
1308 mwindow->zoom_in_sample();
1316 mwindow->expand_t();
1322 mwindow->move_down();
1324 mwindow->zoom_in_t();
1330 for( int i=0; i<TOTAL_PANES; ++i ) {
1331 if( !pane[i] ) continue;
1332 if( (this_track = pane[i]->over_track()) != 0 ) break;
1333 if( (this_track = pane[i]->over_patchbay()) != 0 ) break;
1336 if( get_keypress() == TAB ) { // Switch the record button
1338 this_track->record = !this_track->record ? 1 : 0;
1341 int total_selected = mwindow->edl->tracks->total_of(Tracks::RECORD);
1342 // all selected if nothing previously selected or
1343 // if this patch was previously the only one selected and armed
1344 int selected = !total_selected || (total_selected == 1 &&
1345 this_track && this_track->record ) ? 1 : 0;
1346 mwindow->edl->tracks->select_all(Tracks::RECORD, selected);
1347 if( !selected && this_track ) this_track->record = 1;
1350 update(0, NORMAL_DRAW, 0, 0, 1, 0, 1);
1352 mwindow->cwindow->update(0, 1, 1);
1353 lock_window("MWindowGUI::keypress_event 3");
1370 resend_event(mwindow->cwindow->gui);
1374 // since things under cursor have changed...
1376 cursor_motion_event();
1381 int MWindowGUI::keyboard_listener(BC_WindowBase *wp)
1383 return key_listener(wp->get_keypress());
1386 int MWindowGUI::key_listener(int key)
1391 if( !record->running() )
1394 record->record_gui->interrupt_thread->start(0);
1401 channel_info->toggle_scan();
1405 if( !remote_control->deactivate() )
1406 remote_control->activate();
1416 void MWindowGUI::use_android_remote(int on)
1419 delete android_control;
1420 android_control = 0;
1423 if( android_control ) return;
1424 android_control = new AndroidControl(this);
1427 int MWindowGUI::close_event()
1433 void MWindowGUI::stop_drawing()
1435 resource_thread->stop_draw(1);
1438 int MWindowGUI::menu_w()
1440 return mainmenu->get_w();
1443 int MWindowGUI::menu_h()
1445 return mainmenu->get_h();
1448 void MWindowGUI::start_x_pane_drag()
1452 x_pane_drag = new BC_Popup(this,
1453 get_abs_cursor_x(0) - mwindow->theme->pane_w,
1454 BC_DisplayInfo::get_top_border() +
1456 mwindow->theme->mcanvas_y,
1457 mwindow->theme->pane_w,
1458 mwindow->theme->mcanvas_h,
1459 mwindow->theme->drag_pane_color);
1460 x_pane_drag->draw_3segmentv(0,
1462 x_pane_drag->get_h(),
1463 mwindow->theme->get_image_set("xpane")[BUTTON_DOWNHI]);
1464 x_pane_drag->flash(1);
1469 void MWindowGUI::start_y_pane_drag()
1473 //printf("MWindowGUI::start_y_pane_drag %d %d %d\n", __LINE__, get_x(), get_y());
1474 y_pane_drag = new BC_Popup(this,
1475 BC_DisplayInfo::get_left_border() +
1477 mwindow->theme->mcanvas_x,
1478 get_abs_cursor_y(0) - mwindow->theme->pane_h,
1479 mwindow->theme->mcanvas_w,
1480 mwindow->theme->pane_h,
1481 mwindow->theme->drag_pane_color);
1482 y_pane_drag->draw_3segmenth(0,
1484 y_pane_drag->get_w(),
1485 mwindow->theme->get_image_set("ypane")[BUTTON_DOWNHI]);
1486 y_pane_drag->flash(1);
1491 void MWindowGUI::handle_pane_drag()
1497 x_pane_drag->reposition_window(
1498 get_abs_cursor_x(0) - mwindow->theme->pane_w,
1499 x_pane_drag->get_y());
1504 y_pane_drag->reposition_window(
1505 y_pane_drag->get_x(),
1506 get_abs_cursor_y(0) - mwindow->theme->pane_h);
1512 void MWindowGUI::create_x_pane(int cursor_x)
1514 if(total_panes() == 1)
1516 // create a horizontal pane
1517 // do this 1st so the resize_event knows there are 2 panes
1518 mwindow->edl->local_session->view_start[TOP_RIGHT_PANE] =
1519 mwindow->edl->local_session->view_start[TOP_LEFT_PANE] +
1521 mwindow->theme->patchbay_w;
1522 pane[TOP_RIGHT_PANE] = new TimelinePane(mwindow,
1524 mwindow->theme->mcanvas_x +
1526 mwindow->theme->mcanvas_y,
1527 mwindow->theme->mcanvas_x +
1528 mwindow->theme->mcanvas_w -
1530 mwindow->theme->mcanvas_h);
1531 pane[TOP_LEFT_PANE]->resize_event(
1532 mwindow->theme->mcanvas_x,
1533 mwindow->theme->mcanvas_y,
1534 cursor_x - mwindow->theme->pane_w,
1535 mwindow->theme->mcanvas_h);
1536 pane[TOP_RIGHT_PANE]->create_objects();
1539 if(vertical_panes())
1541 // create 2 horizontal panes
1542 mwindow->edl->local_session->track_start[TOP_RIGHT_PANE] =
1543 mwindow->edl->local_session->track_start[TOP_LEFT_PANE];
1544 mwindow->edl->local_session->track_start[BOTTOM_RIGHT_PANE] =
1545 mwindow->edl->local_session->track_start[BOTTOM_LEFT_PANE];
1546 mwindow->edl->local_session->view_start[TOP_RIGHT_PANE] =
1547 mwindow->edl->local_session->view_start[BOTTOM_RIGHT_PANE] =
1548 mwindow->edl->local_session->view_start[TOP_LEFT_PANE] +
1550 mwindow->theme->patchbay_w;
1551 pane[TOP_RIGHT_PANE] = new TimelinePane(mwindow,
1553 mwindow->theme->mcanvas_x +
1555 pane[TOP_LEFT_PANE]->y,
1556 mwindow->theme->mcanvas_x +
1557 mwindow->theme->mcanvas_w -
1559 pane[TOP_LEFT_PANE]->h);
1560 pane[BOTTOM_RIGHT_PANE] = new TimelinePane(mwindow,
1562 mwindow->theme->mcanvas_x +
1564 pane[BOTTOM_LEFT_PANE]->y,
1565 mwindow->theme->mcanvas_x +
1566 mwindow->theme->mcanvas_w -
1568 pane[BOTTOM_LEFT_PANE]->h);
1569 pane[TOP_LEFT_PANE]->resize_event(
1570 pane[TOP_LEFT_PANE]->x,
1571 pane[TOP_LEFT_PANE]->y,
1572 cursor_x - mwindow->theme->pane_w,
1573 pane[TOP_LEFT_PANE]->h);
1574 pane[BOTTOM_LEFT_PANE]->resize_event(
1575 pane[BOTTOM_LEFT_PANE]->x,
1576 pane[BOTTOM_LEFT_PANE]->y,
1577 cursor_x - mwindow->theme->pane_w,
1578 pane[BOTTOM_LEFT_PANE]->h);
1579 pane[TOP_RIGHT_PANE]->create_objects();
1580 pane[BOTTOM_RIGHT_PANE]->create_objects();
1583 if(horizontal_panes())
1585 // resize a horizontal pane
1586 mwindow->edl->local_session->view_start[TOP_RIGHT_PANE] +=
1588 pane[TOP_RIGHT_PANE]->x;
1589 if(mwindow->edl->local_session->view_start[TOP_RIGHT_PANE] < 0)
1590 mwindow->edl->local_session->view_start[TOP_RIGHT_PANE] = 0;
1591 pane[TOP_LEFT_PANE]->resize_event(
1592 mwindow->theme->mcanvas_x,
1593 mwindow->theme->mcanvas_y,
1594 cursor_x - mwindow->theme->pane_w,
1595 mwindow->theme->mcanvas_h);
1596 pane[TOP_RIGHT_PANE]->resize_event(
1597 mwindow->theme->mcanvas_x +
1599 pane[TOP_RIGHT_PANE]->y,
1600 mwindow->theme->mcanvas_x +
1601 mwindow->theme->mcanvas_w -
1603 mwindow->theme->mcanvas_h);
1607 // resize 2 horizontal panes
1608 mwindow->edl->local_session->view_start[TOP_RIGHT_PANE] +=
1610 pane[TOP_RIGHT_PANE]->x;
1611 if(mwindow->edl->local_session->view_start[TOP_RIGHT_PANE] < 0)
1612 mwindow->edl->local_session->view_start[TOP_RIGHT_PANE] = 0;
1613 mwindow->edl->local_session->view_start[BOTTOM_RIGHT_PANE] =
1614 mwindow->edl->local_session->view_start[TOP_RIGHT_PANE];
1616 pane[TOP_LEFT_PANE]->resize_event(
1617 mwindow->theme->mcanvas_x,
1618 pane[TOP_LEFT_PANE]->y,
1619 cursor_x - mwindow->theme->pane_w,
1620 pane[TOP_LEFT_PANE]->h);
1621 pane[TOP_RIGHT_PANE]->resize_event(
1622 mwindow->theme->mcanvas_x +
1624 pane[TOP_RIGHT_PANE]->y,
1625 mwindow->theme->mcanvas_x +
1626 mwindow->theme->mcanvas_w -
1628 pane[TOP_RIGHT_PANE]->h);
1629 pane[BOTTOM_LEFT_PANE]->resize_event(
1630 mwindow->theme->mcanvas_x,
1631 pane[BOTTOM_LEFT_PANE]->y,
1632 cursor_x - mwindow->theme->pane_w,
1633 pane[BOTTOM_LEFT_PANE]->h);
1634 pane[BOTTOM_RIGHT_PANE]->resize_event(
1635 mwindow->theme->mcanvas_x +
1637 pane[BOTTOM_RIGHT_PANE]->y,
1638 mwindow->theme->mcanvas_x +
1639 mwindow->theme->mcanvas_w -
1641 pane[BOTTOM_RIGHT_PANE]->h);
1647 void MWindowGUI::delete_x_pane(int cursor_x)
1649 // give left panes coordinates of right pane
1650 if(cursor_x < mwindow->theme->patchbay_w + PANE_DRAG_MARGIN &&
1651 pane[TOP_RIGHT_PANE])
1653 mwindow->edl->local_session->view_start[TOP_LEFT_PANE] =
1654 mwindow->edl->local_session->view_start[TOP_RIGHT_PANE] -
1655 pane[TOP_RIGHT_PANE]->x + mwindow->theme->patchbay_w;
1656 if(mwindow->edl->local_session->view_start[TOP_LEFT_PANE] < 0)
1657 mwindow->edl->local_session->view_start[TOP_LEFT_PANE] = 0;
1658 mwindow->edl->local_session->view_start[BOTTOM_LEFT_PANE] =
1659 mwindow->edl->local_session->view_start[TOP_LEFT_PANE];
1662 switch(total_panes())
1665 if(pane[TOP_LEFT_PANE] && pane[TOP_RIGHT_PANE])
1667 // delete right pane
1668 delete pane[TOP_RIGHT_PANE];
1669 pane[TOP_RIGHT_PANE] = 0;
1670 pane[TOP_LEFT_PANE]->resize_event(
1671 mwindow->theme->mcanvas_x,
1672 mwindow->theme->mcanvas_y,
1673 mwindow->theme->mcanvas_w,
1674 mwindow->theme->mcanvas_h);
1680 // delete right panes
1681 delete pane[TOP_RIGHT_PANE];
1682 pane[TOP_RIGHT_PANE] = 0;
1683 delete pane[BOTTOM_RIGHT_PANE];
1684 pane[BOTTOM_RIGHT_PANE] = 0;
1685 pane[TOP_LEFT_PANE]->resize_event(
1686 mwindow->theme->mcanvas_x,
1687 pane[TOP_LEFT_PANE]->y,
1688 mwindow->theme->mcanvas_w,
1689 pane[TOP_LEFT_PANE]->h);
1690 pane[BOTTOM_LEFT_PANE]->resize_event(
1691 mwindow->theme->mcanvas_x,
1692 pane[BOTTOM_LEFT_PANE]->y,
1693 mwindow->theme->mcanvas_w,
1694 pane[BOTTOM_LEFT_PANE]->h);
1699 void MWindowGUI::create_y_pane(int cursor_y)
1701 if(total_panes() == 1)
1703 mwindow->edl->local_session->view_start[BOTTOM_LEFT_PANE] =
1704 mwindow->edl->local_session->view_start[TOP_LEFT_PANE];
1705 mwindow->edl->local_session->track_start[BOTTOM_LEFT_PANE] =
1706 mwindow->edl->local_session->track_start[TOP_LEFT_PANE] +
1708 mwindow->theme->mtimebar_h;
1709 // do this 1st so the resize_event knows there are 2 panes
1710 pane[BOTTOM_LEFT_PANE] = new TimelinePane(mwindow,
1712 mwindow->theme->mcanvas_x,
1713 mwindow->theme->mcanvas_y +
1715 mwindow->theme->mcanvas_w,
1716 mwindow->theme->mcanvas_h -
1718 pane[TOP_LEFT_PANE]->resize_event(
1719 mwindow->theme->mcanvas_x,
1720 mwindow->theme->mcanvas_y,
1721 mwindow->theme->mcanvas_w,
1722 pane[BOTTOM_LEFT_PANE]->y -
1723 mwindow->theme->mcanvas_y -
1724 mwindow->theme->pane_h);
1725 pane[BOTTOM_LEFT_PANE]->create_objects();
1728 if(horizontal_panes())
1731 mwindow->edl->local_session->view_start[BOTTOM_LEFT_PANE] =
1732 mwindow->edl->local_session->view_start[TOP_LEFT_PANE];
1733 mwindow->edl->local_session->view_start[BOTTOM_RIGHT_PANE] =
1734 mwindow->edl->local_session->view_start[TOP_RIGHT_PANE];
1735 mwindow->edl->local_session->track_start[BOTTOM_LEFT_PANE] =
1736 mwindow->edl->local_session->track_start[BOTTOM_RIGHT_PANE] =
1737 mwindow->edl->local_session->track_start[TOP_LEFT_PANE] +
1739 mwindow->theme->mtimebar_h;
1741 pane[BOTTOM_LEFT_PANE] = new TimelinePane(mwindow,
1743 pane[TOP_LEFT_PANE]->x,
1744 mwindow->theme->mcanvas_y +
1746 pane[TOP_LEFT_PANE]->w,
1747 mwindow->theme->mcanvas_h -
1749 pane[BOTTOM_RIGHT_PANE] = new TimelinePane(mwindow,
1751 pane[TOP_RIGHT_PANE]->x,
1752 mwindow->theme->mcanvas_y +
1754 pane[TOP_RIGHT_PANE]->w,
1755 mwindow->theme->mcanvas_h -
1758 pane[TOP_LEFT_PANE]->resize_event(
1759 pane[TOP_LEFT_PANE]->x,
1760 pane[TOP_LEFT_PANE]->y,
1761 pane[TOP_LEFT_PANE]->w,
1762 pane[BOTTOM_LEFT_PANE]->y -
1763 mwindow->theme->mcanvas_y -
1764 mwindow->theme->pane_h);
1765 pane[TOP_RIGHT_PANE]->resize_event(
1766 pane[TOP_RIGHT_PANE]->x,
1767 pane[TOP_RIGHT_PANE]->y,
1768 pane[TOP_RIGHT_PANE]->w,
1769 pane[BOTTOM_RIGHT_PANE]->y -
1770 mwindow->theme->mcanvas_y -
1771 mwindow->theme->pane_h);
1773 pane[BOTTOM_LEFT_PANE]->create_objects();
1774 pane[BOTTOM_RIGHT_PANE]->create_objects();
1777 if(vertical_panes())
1780 mwindow->edl->local_session->track_start[BOTTOM_LEFT_PANE] +=
1782 (pane[BOTTOM_LEFT_PANE]->y - mwindow->theme->mcanvas_y);
1783 if(mwindow->edl->local_session->track_start[BOTTOM_LEFT_PANE] < 0)
1784 mwindow->edl->local_session->track_start[BOTTOM_LEFT_PANE] = 0;
1785 pane[TOP_LEFT_PANE]->resize_event(
1786 mwindow->theme->mcanvas_x,
1787 mwindow->theme->mcanvas_y,
1788 mwindow->theme->mcanvas_w,
1789 cursor_y - mwindow->theme->pane_h);
1790 pane[BOTTOM_LEFT_PANE]->resize_event(
1791 pane[BOTTOM_LEFT_PANE]->x,
1793 mwindow->theme->mcanvas_y,
1794 mwindow->theme->mcanvas_w,
1795 mwindow->theme->mcanvas_h -
1801 mwindow->edl->local_session->track_start[BOTTOM_LEFT_PANE] +=
1803 (pane[BOTTOM_LEFT_PANE]->y - mwindow->theme->mcanvas_y);
1804 if(mwindow->edl->local_session->track_start[BOTTOM_LEFT_PANE] < 0)
1805 mwindow->edl->local_session->track_start[BOTTOM_LEFT_PANE] = 0;
1806 mwindow->edl->local_session->track_start[BOTTOM_RIGHT_PANE] =
1807 mwindow->edl->local_session->track_start[BOTTOM_LEFT_PANE];
1808 pane[TOP_LEFT_PANE]->resize_event(
1809 pane[TOP_LEFT_PANE]->x,
1810 pane[TOP_LEFT_PANE]->y,
1811 pane[TOP_LEFT_PANE]->w,
1812 cursor_y - mwindow->theme->pane_h);
1813 pane[BOTTOM_LEFT_PANE]->resize_event(
1814 pane[BOTTOM_LEFT_PANE]->x,
1816 mwindow->theme->mcanvas_y,
1817 pane[BOTTOM_LEFT_PANE]->w,
1818 mwindow->theme->mcanvas_h -
1820 pane[TOP_RIGHT_PANE]->resize_event(
1821 pane[TOP_RIGHT_PANE]->x,
1822 pane[TOP_RIGHT_PANE]->y,
1823 pane[TOP_RIGHT_PANE]->w,
1824 cursor_y - mwindow->theme->pane_h);
1825 pane[BOTTOM_RIGHT_PANE]->resize_event(
1826 pane[BOTTOM_RIGHT_PANE]->x,
1828 mwindow->theme->mcanvas_y,
1829 pane[BOTTOM_RIGHT_PANE]->w,
1830 mwindow->theme->mcanvas_h -
1835 void MWindowGUI::delete_y_pane(int cursor_y)
1837 if(cursor_y < mwindow->theme->mtimebar_h +
1839 pane[BOTTOM_LEFT_PANE])
1841 // give top pane coordinates of bottom pane
1842 mwindow->edl->local_session->track_start[TOP_LEFT_PANE] =
1843 mwindow->edl->local_session->track_start[BOTTOM_LEFT_PANE] -
1844 pane[BOTTOM_LEFT_PANE]->y;
1845 if(mwindow->edl->local_session->track_start[TOP_LEFT_PANE] < 0)
1846 mwindow->edl->local_session->track_start[TOP_LEFT_PANE] = 0;
1847 mwindow->edl->local_session->track_start[TOP_RIGHT_PANE] =
1848 mwindow->edl->local_session->track_start[TOP_LEFT_PANE];
1852 switch(total_panes())
1855 delete pane[BOTTOM_LEFT_PANE];
1856 pane[BOTTOM_LEFT_PANE] = 0;
1857 pane[TOP_LEFT_PANE]->resize_event(
1858 mwindow->theme->mcanvas_x,
1859 mwindow->theme->mcanvas_y,
1860 mwindow->theme->mcanvas_w,
1861 mwindow->theme->mcanvas_h);
1865 // delete bottom 2 panes
1867 delete pane[BOTTOM_LEFT_PANE];
1868 pane[BOTTOM_LEFT_PANE] = 0;
1869 delete pane[BOTTOM_RIGHT_PANE];
1870 pane[BOTTOM_RIGHT_PANE] = 0;
1871 pane[TOP_LEFT_PANE]->resize_event(
1872 pane[TOP_LEFT_PANE]->x,
1873 mwindow->theme->mcanvas_y,
1874 pane[TOP_LEFT_PANE]->w,
1875 mwindow->theme->mcanvas_h);
1876 pane[TOP_RIGHT_PANE]->resize_event(
1877 pane[TOP_RIGHT_PANE]->x,
1878 mwindow->theme->mcanvas_y,
1879 pane[TOP_RIGHT_PANE]->w,
1880 mwindow->theme->mcanvas_h);
1885 void MWindowGUI::stop_pane_drag()
1888 resource_thread->stop_draw(0);
1892 // cursor position relative to canvas
1893 int cursor_x = x_pane_drag->get_x() -
1895 BC_DisplayInfo::get_left_border() -
1896 mwindow->theme->mcanvas_x +
1897 mwindow->theme->pane_w;
1902 if(cursor_x >= mwindow->theme->patchbay_w + PANE_DRAG_MARGIN &&
1903 cursor_x < mwindow->theme->mcanvas_w -
1904 BC_ScrollBar::get_span(SCROLL_VERT) -
1907 create_x_pane(cursor_x);
1908 mwindow->edl->local_session->x_pane = cursor_x;
1913 delete_x_pane(cursor_x);
1914 mwindow->edl->local_session->x_pane = -1;
1922 // cursor position relative to canvas
1923 int cursor_y = y_pane_drag->get_y() -
1925 BC_DisplayInfo::get_top_border() -
1926 mwindow->theme->mcanvas_y +
1927 mwindow->theme->pane_h;
1933 if(cursor_y >= mwindow->theme->mtimebar_h +
1935 cursor_y < mwindow->theme->mcanvas_h -
1936 BC_ScrollBar::get_span(SCROLL_HORIZ) -
1939 create_y_pane(cursor_y);
1940 mwindow->edl->local_session->y_pane = cursor_y;
1944 delete_y_pane(cursor_y);
1945 mwindow->edl->local_session->y_pane = -1;
1949 update_pane_dividers();
1951 // required to get new widgets to appear
1953 resource_thread->start_draw();
1956 // create panes from EDL
1957 void MWindowGUI::load_panes()
1959 int need_x_panes = 0;
1960 int need_y_panes = 0;
1961 // use names from create functions
1962 int cursor_x = mwindow->edl->local_session->x_pane;
1963 int cursor_y = mwindow->edl->local_session->y_pane;
1965 resource_thread->stop_draw(1);
1967 mwindow->theme->patchbay_w + PANE_DRAG_MARGIN &&
1969 mwindow->theme->mcanvas_w -
1970 BC_ScrollBar::get_span(SCROLL_VERT) -
1977 mwindow->theme->mtimebar_h + PANE_DRAG_MARGIN &&
1979 mwindow->theme->mcanvas_h -
1980 BC_ScrollBar::get_span(SCROLL_HORIZ) -
1986 //printf("MWindowGUI::load_panes %d %d %d\n", __LINE__, need_x_panes, need_y_panes);
1994 if(total_panes() == 1)
1997 //printf("MWindowGUI::load_panes %d\n", __LINE__);
1998 pane[TOP_RIGHT_PANE] = new TimelinePane(mwindow,
2000 mwindow->theme->mcanvas_x +
2002 mwindow->theme->mcanvas_y,
2003 mwindow->theme->mcanvas_x +
2004 mwindow->theme->mcanvas_w -
2006 cursor_y - mwindow->theme->pane_h);
2007 pane[BOTTOM_LEFT_PANE] = new TimelinePane(mwindow,
2009 mwindow->theme->mcanvas_x,
2010 mwindow->theme->mcanvas_y +
2012 cursor_x - mwindow->theme->pane_w,
2013 mwindow->theme->mcanvas_h -
2015 pane[BOTTOM_RIGHT_PANE] = new TimelinePane(mwindow,
2017 pane[TOP_RIGHT_PANE]->x,
2018 mwindow->theme->mcanvas_y +
2020 pane[TOP_RIGHT_PANE]->w,
2021 mwindow->theme->mcanvas_h -
2023 pane[TOP_LEFT_PANE]->resize_event(
2024 pane[TOP_LEFT_PANE]->x,
2025 pane[TOP_LEFT_PANE]->y,
2026 cursor_x - mwindow->theme->pane_w,
2027 cursor_y - mwindow->theme->pane_h);
2028 pane[TOP_RIGHT_PANE]->create_objects();
2029 pane[BOTTOM_LEFT_PANE]->create_objects();
2030 pane[BOTTOM_RIGHT_PANE]->create_objects();
2033 if(horizontal_panes())
2035 // create vertical panes
2036 //printf("MWindowGUI::load_panes %d\n", __LINE__);
2037 pane[BOTTOM_LEFT_PANE] = new TimelinePane(mwindow,
2039 mwindow->theme->mcanvas_x,
2040 mwindow->theme->mcanvas_y +
2042 cursor_x - mwindow->theme->pane_w,
2043 mwindow->theme->mcanvas_h -
2045 pane[BOTTOM_RIGHT_PANE] = new TimelinePane(mwindow,
2047 pane[TOP_RIGHT_PANE]->x,
2048 mwindow->theme->mcanvas_y +
2050 pane[TOP_RIGHT_PANE]->w,
2051 mwindow->theme->mcanvas_h -
2053 pane[TOP_LEFT_PANE]->resize_event(
2054 pane[TOP_LEFT_PANE]->x,
2055 pane[TOP_LEFT_PANE]->y,
2056 cursor_x - mwindow->theme->pane_w,
2057 cursor_y - mwindow->theme->pane_h);
2058 pane[TOP_RIGHT_PANE]->resize_event(
2059 mwindow->theme->mcanvas_x +
2061 mwindow->theme->mcanvas_y,
2062 mwindow->theme->mcanvas_x +
2063 mwindow->theme->mcanvas_w -
2065 cursor_y - mwindow->theme->pane_h);
2066 pane[BOTTOM_LEFT_PANE]->create_objects();
2067 pane[BOTTOM_RIGHT_PANE]->create_objects();
2070 if(vertical_panes())
2072 // create horizontal panes
2073 //printf("MWindowGUI::load_panes %d\n", __LINE__);
2074 pane[TOP_RIGHT_PANE] = new TimelinePane(mwindow,
2076 mwindow->theme->mcanvas_x +
2078 mwindow->theme->mcanvas_y,
2079 mwindow->theme->mcanvas_x +
2080 mwindow->theme->mcanvas_w -
2082 cursor_y - mwindow->theme->pane_h);
2083 pane[BOTTOM_RIGHT_PANE] = new TimelinePane(mwindow,
2085 pane[TOP_RIGHT_PANE]->x,
2086 mwindow->theme->mcanvas_y +
2088 pane[TOP_RIGHT_PANE]->w,
2089 mwindow->theme->mcanvas_h -
2091 pane[TOP_LEFT_PANE]->resize_event(
2092 pane[TOP_LEFT_PANE]->x,
2093 pane[TOP_LEFT_PANE]->y,
2094 cursor_x - mwindow->theme->pane_w,
2095 cursor_y - mwindow->theme->pane_h);
2096 pane[BOTTOM_LEFT_PANE]->resize_event(
2097 pane[TOP_LEFT_PANE]->x,
2098 mwindow->theme->mcanvas_y +
2100 mwindow->theme->mcanvas_x +
2101 mwindow->theme->mcanvas_w -
2102 cursor_x - mwindow->theme->pane_w,
2103 mwindow->theme->mcanvas_h -
2105 pane[TOP_RIGHT_PANE]->create_objects();
2106 pane[BOTTOM_RIGHT_PANE]->create_objects();
2113 //printf("MWindowGUI::load_panes %d\n", __LINE__);
2114 pane[TOP_LEFT_PANE]->resize_event(
2115 pane[TOP_LEFT_PANE]->x,
2116 pane[TOP_LEFT_PANE]->y,
2117 cursor_x - mwindow->theme->pane_w,
2118 cursor_y - mwindow->theme->pane_h);
2119 pane[TOP_RIGHT_PANE]->resize_event(
2120 mwindow->theme->mcanvas_x +
2122 mwindow->theme->mcanvas_y,
2123 mwindow->theme->mcanvas_x +
2124 mwindow->theme->mcanvas_w -
2126 cursor_y - mwindow->theme->pane_h);
2127 pane[BOTTOM_LEFT_PANE]->resize_event(
2128 pane[TOP_LEFT_PANE]->x,
2129 mwindow->theme->mcanvas_y +
2131 mwindow->theme->mcanvas_x +
2132 mwindow->theme->mcanvas_w -
2133 cursor_x - mwindow->theme->pane_w,
2134 mwindow->theme->mcanvas_h -
2136 pane[BOTTOM_RIGHT_PANE]->resize_event(
2137 pane[TOP_RIGHT_PANE]->x,
2138 mwindow->theme->mcanvas_y +
2140 pane[TOP_RIGHT_PANE]->w,
2141 mwindow->theme->mcanvas_h -
2150 if(pane[BOTTOM_LEFT_PANE]) delete pane[BOTTOM_LEFT_PANE];
2151 if(pane[BOTTOM_RIGHT_PANE]) delete pane[BOTTOM_RIGHT_PANE];
2152 pane[BOTTOM_LEFT_PANE] = 0;
2153 pane[BOTTOM_RIGHT_PANE] = 0;
2155 if(!pane[TOP_RIGHT_PANE])
2157 pane[TOP_RIGHT_PANE] = new TimelinePane(mwindow,
2159 mwindow->theme->mcanvas_x +
2161 mwindow->theme->mcanvas_y,
2162 mwindow->theme->mcanvas_x +
2163 mwindow->theme->mcanvas_w -
2165 mwindow->theme->mcanvas_h);
2166 pane[TOP_LEFT_PANE]->resize_event(
2167 mwindow->theme->mcanvas_x,
2168 mwindow->theme->mcanvas_y,
2169 cursor_x - mwindow->theme->pane_w,
2170 mwindow->theme->mcanvas_h);
2171 pane[TOP_RIGHT_PANE]->create_objects();
2175 pane[TOP_LEFT_PANE]->resize_event(
2176 mwindow->theme->mcanvas_x,
2177 mwindow->theme->mcanvas_y,
2178 cursor_x - mwindow->theme->pane_w,
2179 mwindow->theme->mcanvas_h);
2180 pane[TOP_RIGHT_PANE]->resize_event(
2181 mwindow->theme->mcanvas_x +
2183 pane[TOP_RIGHT_PANE]->y,
2184 mwindow->theme->mcanvas_x +
2185 mwindow->theme->mcanvas_w -
2187 mwindow->theme->mcanvas_h);
2195 if(pane[TOP_RIGHT_PANE]) delete pane[TOP_RIGHT_PANE];
2196 if(pane[BOTTOM_RIGHT_PANE]) delete pane[BOTTOM_RIGHT_PANE];
2197 pane[TOP_RIGHT_PANE] = 0;
2198 pane[BOTTOM_RIGHT_PANE] = 0;
2200 if(!pane[BOTTOM_LEFT_PANE])
2202 //printf("MWindowGUI::load_panes %d\n", __LINE__);
2203 pane[BOTTOM_LEFT_PANE] = new TimelinePane(mwindow,
2205 mwindow->theme->mcanvas_x,
2206 mwindow->theme->mcanvas_y +
2208 mwindow->theme->mcanvas_w,
2209 mwindow->theme->mcanvas_h -
2211 pane[TOP_LEFT_PANE]->resize_event(
2212 mwindow->theme->mcanvas_x,
2213 mwindow->theme->mcanvas_y,
2214 mwindow->theme->mcanvas_w,
2215 pane[BOTTOM_LEFT_PANE]->y -
2216 mwindow->theme->mcanvas_y -
2217 mwindow->theme->pane_h);
2218 pane[BOTTOM_LEFT_PANE]->create_objects();
2222 pane[TOP_LEFT_PANE]->resize_event(
2223 mwindow->theme->mcanvas_x,
2224 mwindow->theme->mcanvas_y,
2225 mwindow->theme->mcanvas_w,
2226 cursor_y - mwindow->theme->pane_h);
2227 pane[BOTTOM_LEFT_PANE]->resize_event(
2228 pane[BOTTOM_LEFT_PANE]->x,
2230 mwindow->theme->mcanvas_y,
2231 mwindow->theme->mcanvas_w,
2232 mwindow->theme->mcanvas_h -
2239 if(pane[TOP_RIGHT_PANE]) delete pane[TOP_RIGHT_PANE];
2240 if(pane[BOTTOM_RIGHT_PANE]) delete pane[BOTTOM_RIGHT_PANE];
2241 if(pane[BOTTOM_LEFT_PANE]) delete pane[BOTTOM_LEFT_PANE];
2242 pane[TOP_RIGHT_PANE] = 0;
2243 pane[BOTTOM_RIGHT_PANE] = 0;
2244 pane[BOTTOM_LEFT_PANE] = 0;
2245 pane[TOP_LEFT_PANE]->resize_event(
2246 mwindow->theme->mcanvas_x,
2247 mwindow->theme->mcanvas_y,
2248 mwindow->theme->mcanvas_w,
2249 mwindow->theme->mcanvas_h);
2252 update_pane_dividers();
2255 resource_thread->start_draw();
2258 void MWindowGUI::update_pane_dividers()
2261 if(horizontal_panes() || total_panes() == 4)
2263 int x = pane[TOP_RIGHT_PANE]->x - mwindow->theme->pane_w;
2264 int y = mwindow->theme->mcanvas_y;
2265 int h = mwindow->theme->mcanvas_h;
2269 add_subwindow(x_divider = new PaneDivider(
2270 mwindow, x, y, h, 1));
2271 x_divider->create_objects();
2275 x_divider->reposition_window(x, y, h);
2288 if(vertical_panes() || total_panes() == 4)
2290 int x = mwindow->theme->mcanvas_x;
2291 int y = pane[BOTTOM_LEFT_PANE]->y -
2292 mwindow->theme->pane_h;
2293 int w = mwindow->theme->mcanvas_w;
2296 add_subwindow(y_divider = new PaneDivider(
2297 mwindow, x, y, w, 0));
2298 y_divider->create_objects();
2302 y_divider->reposition_window(x, y, w);
2316 void MWindowGUI::draw_samplemovement()
2323 update_scrollbars(1);
2326 void MWindowGUI::draw_trackmovement()
2328 update_scrollbars(0);
2335 void MWindowGUI::update_mixers(Track *track, int v)
2337 for( int i=0; i<TOTAL_PANES; ++i ) {
2338 if( !pane[i] ) continue;
2339 PatchBay *patchbay = pane[i]->patchbay;
2340 if( !patchbay ) continue;
2341 for( int j=0; j<patchbay->patches.total; ++j ) {
2342 PatchGUI *patchgui = patchbay->patches.values[j];
2343 if( !patchgui->mix ) continue;
2344 if( !track || patchgui->track == track ) {
2345 patchgui->mix->update(v>=0 ? v :
2346 mwindow->mixer_track_active(patchgui->track));
2352 void MWindowGUI::stop_transport(const char *lock_msg)
2354 if( !mbuttons->transport->is_stopped() ) {
2355 if( lock_msg ) unlock_window();
2356 mbuttons->transport->handle_transport(STOP, 1, 0, 0);
2357 if( lock_msg ) lock_window(lock_msg);
2361 PaneButton::PaneButton(MWindow *mwindow, int x, int y)
2362 : BC_Button(x, y, mwindow->theme->get_image_set("pane"))
2364 this->mwindow = mwindow;
2367 int PaneButton::cursor_motion_event()
2369 if(get_top_level()->get_button_down() &&
2371 get_status() == BUTTON_DOWNHI &&
2374 // printf("PaneButton::cursor_motion_event %d\n", __LINE__);
2376 if(get_cursor_x() < 0 && !mwindow->gui->dragging_pane)
2378 mwindow->gui->start_x_pane_drag();
2381 if(get_cursor_y() < 0 && !mwindow->gui->dragging_pane)
2383 mwindow->gui->start_y_pane_drag();
2387 mwindow->gui->handle_pane_drag();
2389 int result = BC_Button::cursor_motion_event();
2393 int PaneButton::button_release_event()
2395 if( get_buttonpress() != WHEEL_DOWN && get_buttonpress() != WHEEL_UP )
2396 mwindow->gui->stop_pane_drag();
2397 int result = BC_Button::button_release_event();
2402 FFMpegToggle::FFMpegToggle(MWindow *mwindow, MButtons *mbuttons, int x, int y)
2403 : BC_Toggle(x, y, mwindow->theme->ffmpeg_toggle,
2404 mwindow->preferences->get_file_probe_armed("FFMPEG_Early") > 0 ? 1 : 0)
2406 this->mwindow = mwindow;
2407 this->mbuttons = mbuttons;
2408 set_tooltip(get_value() ? FFMPEG_EARLY_TIP : FFMPEG_LATE_TIP);
2411 FFMpegToggle::~FFMpegToggle()
2415 int FFMpegToggle::handle_event()
2417 int ffmpeg_early_probe = get_value();
2418 set_tooltip(ffmpeg_early_probe ? FFMPEG_EARLY_TIP : FFMPEG_LATE_TIP);
2419 mwindow->preferences->set_file_probe_armed("FFMPEG_Early", ffmpeg_early_probe);
2420 mwindow->preferences->set_file_probe_armed("FFMPEG_Late", !ffmpeg_early_probe);
2422 mwindow->show_warning(&mwindow->preferences->warn_indexes,
2423 _("Changing the base codecs may require rebuilding indexes."));
2428 ProxyToggle::ProxyToggle(MWindow *mwindow, MButtons *mbuttons, int x, int y)
2429 : BC_Toggle(x, y, ( !mwindow->edl->session->proxy_use_scaler ?
2430 mwindow->theme->proxy_p_toggle :
2431 mwindow->theme->proxy_s_toggle ),
2432 mwindow->edl->session->proxy_disabled_scale != 1)
2434 this->mwindow = mwindow;
2435 this->mbuttons = mbuttons;
2436 scaler_images = mwindow->edl->session->proxy_use_scaler;
2437 set_tooltip(mwindow->edl->session->proxy_disabled_scale==1 ?
2438 _("Disable proxy") : _("Enable proxy"));
2441 void ProxyToggle::show()
2443 int use_scaler = mwindow->edl->session->proxy_use_scaler;
2444 if( scaler_images != use_scaler )
2445 set_images(!(scaler_images=use_scaler) ?
2446 mwindow->theme->proxy_p_toggle :
2447 mwindow->theme->proxy_s_toggle );
2453 void ProxyToggle::hide()
2459 ProxyToggle::~ProxyToggle()
2463 int ProxyToggle::handle_event()
2465 int disabled = get_value();
2466 mwindow->gui->unlock_window();
2468 mwindow->disable_proxy();
2470 mwindow->enable_proxy();
2471 mwindow->gui->lock_window("ProxyToggle::handle_event");
2472 set_tooltip(!disabled ? _("Disable proxy") : _("Enable proxy"));
2476 int ProxyToggle::keypress_event()
2478 if( ctrl_down() && !shift_down() && !alt_down() ) {
2479 int key = get_keypress();
2481 int value = get_value() ? 0 : 1;
2483 return handle_event();