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 "trackscroll.h"
70 #include "transitionpopup.h"
71 #include "vwindowgui.h"
75 #define PANE_DRAG_MARGIN MAX(mwindow->theme->pane_w, mwindow->theme->pane_h)
78 // the main window uses its own private colormap for video
79 MWindowGUI::MWindowGUI(MWindow *mwindow)
80 : BC_Window(_(PROGRAM_NAME ": Program"),
81 mwindow->session->mwindow_x,
82 mwindow->session->mwindow_y,
83 mwindow->session->mwindow_w,
84 mwindow->session->mwindow_h,
91 this->mwindow = mwindow;
98 focused_pane = TOP_LEFT_PANE;
107 for(int i = 0; i < TOTAL_PANES; i++)
126 cwindow_remote_handler = 0;
127 record_remote_handler = 0;
132 MWindowGUI::~MWindowGUI()
134 delete android_control;
135 delete cwindow_remote_handler;
136 delete record_remote_handler;
137 delete remote_control;
138 delete keyvalue_popup;
139 // delete samplescroll;
140 // delete trackscroll;
141 for(int i = 0; i < TOTAL_PANES; i++)
142 if(pane[i]) delete pane[i];
144 delete render_engine;
145 delete resource_thread;
146 resource_pixmaps.remove_all_objects();
157 void MWindowGUI::get_scrollbars(int flush)
159 //int64_t h_needed = mwindow->edl->get_tracks_height(mwindow->theme);
160 //int64_t w_needed = mwindow->edl->get_tracks_width();
161 int need_xscroll = 0;
162 int need_yscroll = 0;
163 view_w = mwindow->theme->mcanvas_w;
164 view_h = mwindow->theme->mcanvas_h;
166 // Scrollbars are constitutive
167 need_xscroll = need_yscroll = 1;
168 view_h = mwindow->theme->mcanvas_h;
169 view_w = mwindow->theme->mcanvas_w;
171 // for(int i = 0; i < 2; i++)
173 // if(w_needed > view_w)
176 // view_h = mwindow->theme->mcanvas_h - SCROLL_SPAN;
181 // if(h_needed > view_h)
184 // view_w = mwindow->theme->mcanvas_w - SCROLL_SPAN;
189 //printf("MWindowGUI::get_scrollbars 1\n");
191 if(canvas && (view_w != canvas->get_w() || view_h != canvas->get_h()))
193 canvas->reposition_window(mwindow->theme->mcanvas_x,
194 mwindow->theme->mcanvas_y,
202 add_subwindow(samplescroll = new SampleScroll(mwindow,
204 mwindow->theme->mhscroll_x,
205 mwindow->theme->mhscroll_y,
206 mwindow->theme->mhscroll_w));
208 samplescroll->resize_event();
210 samplescroll->set_position(0);
214 if(samplescroll) delete samplescroll;
216 mwindow->edl->local_session->view_start = 0;
222 //printf("MWindowGUI::get_scrollbars 1.1 %p %p\n", this, canvas);
224 add_subwindow(trackscroll = new TrackScroll(mwindow,
226 mwindow->theme->mvscroll_x,
227 mwindow->theme->mvscroll_y,
228 mwindow->theme->mvscroll_h));
230 trackscroll->resize_event();
233 //printf("MWindowGUI::get_scrollbars 1.2\n");
234 trackscroll->update_length(mwindow->edl->get_tracks_height(mwindow->theme),
235 mwindow->edl->local_session->track_start,
238 //printf("MWindowGUI::get_scrollbars 1.3\n");
242 if(trackscroll) delete trackscroll;
244 mwindow->edl->local_session->track_start = 0;
247 if(flush) this->flush();
252 void MWindowGUI::create_objects()
256 resource_thread = new ResourceThread(mwindow, this);
257 resource_thread->create_objects();
260 if(debug) printf("MWindowGUI::create_objects %d\n", __LINE__);
261 set_icon(mwindow->theme->get_image("mwindow_icon"));
262 remote_control = new RemoteControl(this);
263 cwindow_remote_handler = new CWindowRemoteHandler(remote_control);
264 record_remote_handler = new RecordRemoteHandler(remote_control);
265 mwindow->reset_android_remote();
267 if(debug) printf("MWindowGUI::create_objects %d\n", __LINE__);
269 int x = get_w() - MainShBtns::calculate_w(0);
270 add_subwindow(mainmenu = new MainMenu(mwindow, this, x));
271 mainmenu->create_objects();
272 add_subwindow(mainshbtns = new MainShBtns(mwindow, x, -1));
273 mainshbtns->load(mwindow->preferences);
274 mwindow->theme->get_mwindow_sizes(this, get_w(), get_h());
275 mwindow->theme->draw_mwindow_bg(this);
276 if(debug) printf("MWindowGUI::create_objects %d\n", __LINE__);
278 add_subwindow(mbuttons = new MButtons(mwindow, this));
279 mbuttons->create_objects();
280 int x1 = mbuttons->get_x() + mbuttons->get_w(), y1 = mbuttons->get_y()+2;
281 add_subwindow(proxy_toggle = new ProxyToggle(mwindow, mbuttons, x1, y1));
282 x1 += proxy_toggle->get_w() + 3;
283 add_subwindow(ffmpeg_toggle = new FFMpegToggle(mwindow, mbuttons, x1, y1));
285 pane[TOP_LEFT_PANE] = new TimelinePane(mwindow,
287 mwindow->theme->mcanvas_x,
288 mwindow->theme->mcanvas_y,
289 mwindow->theme->mcanvas_w,
290 mwindow->theme->mcanvas_h);
291 pane[TOP_LEFT_PANE]->create_objects();
293 // add_subwindow(timebar = new MTimeBar(mwindow,
295 // mwindow->theme->mtimebar_x,
296 // mwindow->theme->mtimebar_y,
297 // mwindow->theme->mtimebar_w,
298 // mwindow->theme->mtimebar_h));
299 // timebar->create_objects();
301 // if(debug) printf("MWindowGUI::create_objects %d\n", __LINE__);
302 // add_subwindow(patchbay = new PatchBay(mwindow, this));
303 // patchbay->create_objects();
305 // if(debug) printf("MWindowGUI::create_objects %d\n", __LINE__);
306 // get_scrollbars(0);
308 // if(debug) printf("MWindowGUI::create_objects %d\n", __LINE__);
309 // mwindow->gui->add_subwindow(canvas = new TrackCanvas(mwindow, this));
310 // canvas->create_objects();
313 if(debug) printf("MWindowGUI::create_objects %d\n", __LINE__);
314 add_subwindow(zoombar = new ZoomBar(mwindow, this));
315 zoombar->create_objects();
318 if(debug) printf("MWindowGUI::create_objects %d\n", __LINE__);
319 add_subwindow(statusbar = new StatusBar(mwindow, this));
320 statusbar->create_objects();
324 if(debug) printf("MWindowGUI::create_objects %d\n", __LINE__);
325 add_subwindow(mainclock = new MainClock(mwindow,
326 mwindow->theme->mclock_x, mwindow->theme->mclock_y,
327 mwindow->theme->mclock_w));
328 if(debug) printf("MWindowGUI::create_objects %d\n", __LINE__);
329 mainclock->update(0);
333 // if(debug) printf("MWindowGUI::create_objects %d\n", __LINE__);
334 // cursor = new MainCursor(mwindow, this);
335 // cursor->create_objects();
338 if(debug) printf("MWindowGUI::create_objects %d\n", __LINE__);
339 add_subwindow(edit_menu = new EditPopup(mwindow, this));
340 edit_menu->create_objects();
343 if(debug) printf("MWindowGUI::create_objects %d\n", __LINE__);
344 add_subwindow(plugin_menu = new PluginPopup(mwindow, this));
345 plugin_menu->create_objects();
348 if(debug) printf("MWindowGUI::create_objects %d\n", __LINE__);
349 add_subwindow(keyframe_menu = new KeyframePopup(mwindow, this));
350 keyframe_menu->create_objects();
351 add_subwindow(keyframe_hide = new KeyframeHidePopup(mwindow, this));
352 keyframe_hide->create_objects();
355 if(debug) printf("MWindowGUI::create_objects %d\n", __LINE__);
356 add_subwindow(transition_menu = new TransitionPopup(mwindow, this));
357 transition_menu->create_objects();
360 channel_info = new ChannelInfo(mwindow);
362 #ifdef HAVE_COMMERCIAL
363 db_window = new DbWindow(mwindow);
365 swindow = new SWindow(mwindow);
367 if(debug) printf("MWindowGUI::create_objects %d\n", __LINE__);
369 add_subwindow(pane_button = new PaneButton(mwindow,
370 get_w() - mwindow->theme->get_image_set("pane")[0]->get_w(),
371 mwindow->theme->mzoom_y + 1 - mwindow->theme->get_image_set("pane")[0]->get_h()));
373 pane[TOP_LEFT_PANE]->canvas->activate();
375 if(debug) printf("MWindowGUI::create_objects %d\n", __LINE__);
378 void MWindowGUI::redraw_time_dependancies()
380 zoombar->redraw_time_dependancies();
381 for(int i = 0; i < TOTAL_PANES; i++)
382 if(pane[i] && pane[i]->timebar) pane[i]->timebar->update(0);
383 mainclock->update(mwindow->edl->local_session->get_selectionstart(1));
386 int MWindowGUI::focus_in_event()
388 for(int i = 0; i < TOTAL_PANES; i++)
389 if(pane[i]) pane[i]->cursor->focus_in_event();
393 int MWindowGUI::focus_out_event()
395 for(int i = 0; i < TOTAL_PANES; i++)
396 if(pane[i]) pane[i]->cursor->focus_out_event();
401 int MWindowGUI::resize_event(int w, int h)
403 //printf("MWindowGUI::resize_event %d\n", __LINE__);
404 mwindow->session->mwindow_w = w;
405 mwindow->session->mwindow_h = h;
406 int x = w - MainShBtns::calculate_w(0);
407 mainmenu->resize_event(x, mainmenu->get_h());
408 mainshbtns->reposition_window(x, -1);
409 mwindow->theme->get_mwindow_sizes(this, w, h);
410 mwindow->theme->draw_mwindow_bg(this);
411 mbuttons->resize_event();
412 int x1 = mbuttons->get_x() + mbuttons->get_w(), y1 = mbuttons->get_y()+2;
413 proxy_toggle->reposition_window(x1, y1);
414 x1 += proxy_toggle->get_w() + 3;
415 ffmpeg_toggle->reposition_window(x1, y1);
416 statusbar->resize_event();
417 zoombar->resize_event();
419 resource_thread->stop_draw(1);
421 if(total_panes() > 1)
423 if(horizontal_panes())
425 // printf("MWindowGUI::resize_event %d %d %d\n",
427 // pane[TOP_RIGHT_PANE]->x,
428 // mwindow->theme->mcanvas_w -
429 // BC_ScrollBar::get_span(SCROLL_VERT) -
430 // PANE_DRAG_MARGIN);
431 if(pane[TOP_RIGHT_PANE]->x >= mwindow->theme->mcanvas_w -
432 BC_ScrollBar::get_span(SCROLL_VERT) -
435 delete_x_pane(pane[TOP_RIGHT_PANE]->x);
436 mwindow->edl->local_session->x_pane = -1;
442 if(pane[BOTTOM_LEFT_PANE]->y >= mwindow->theme->mzoom_y -
443 BC_ScrollBar::get_span(SCROLL_HORIZ) -
446 delete_y_pane(pane[BOTTOM_LEFT_PANE]->y);
447 mwindow->edl->local_session->y_pane = -1;
452 if(pane[TOP_RIGHT_PANE]->x >= mwindow->theme->mcanvas_w -
453 BC_ScrollBar::get_span(SCROLL_VERT) -
456 delete_x_pane(pane[TOP_RIGHT_PANE]->x);
457 mwindow->edl->local_session->x_pane = -1;
460 if(pane[BOTTOM_LEFT_PANE]->y >= mwindow->theme->mzoom_y -
461 BC_ScrollBar::get_span(SCROLL_HORIZ) -
464 delete_y_pane(pane[BOTTOM_LEFT_PANE]->y);
465 mwindow->edl->local_session->y_pane = -1;
470 if(total_panes() == 1)
472 pane[TOP_LEFT_PANE]->resize_event(
473 mwindow->theme->mcanvas_x,
474 mwindow->theme->mcanvas_y,
475 mwindow->theme->mcanvas_w,
476 mwindow->theme->mcanvas_h);
479 if(horizontal_panes())
481 pane[TOP_LEFT_PANE]->resize_event(
482 pane[TOP_LEFT_PANE]->x,
483 pane[TOP_LEFT_PANE]->y,
484 pane[TOP_LEFT_PANE]->w,
485 mwindow->theme->mcanvas_h);
486 pane[TOP_RIGHT_PANE]->resize_event(
487 pane[TOP_RIGHT_PANE]->x,
488 pane[TOP_RIGHT_PANE]->y,
489 mwindow->theme->mcanvas_w - pane[TOP_RIGHT_PANE]->x,
490 mwindow->theme->mcanvas_h);
495 pane[TOP_LEFT_PANE]->resize_event(
496 pane[TOP_LEFT_PANE]->x,
497 pane[TOP_LEFT_PANE]->y,
498 mwindow->theme->mcanvas_w,
499 pane[TOP_LEFT_PANE]->h);
500 pane[BOTTOM_LEFT_PANE]->resize_event(
501 pane[BOTTOM_LEFT_PANE]->x,
502 pane[BOTTOM_LEFT_PANE]->y,
503 mwindow->theme->mcanvas_w,
504 mwindow->theme->mcanvas_y +
505 mwindow->theme->mcanvas_h -
506 pane[BOTTOM_LEFT_PANE]->y);
510 pane[TOP_LEFT_PANE]->resize_event(
511 pane[TOP_LEFT_PANE]->x,
512 pane[TOP_LEFT_PANE]->y,
513 pane[TOP_LEFT_PANE]->w,
514 pane[TOP_LEFT_PANE]->h);
515 pane[TOP_RIGHT_PANE]->resize_event(
516 pane[TOP_RIGHT_PANE]->x,
517 pane[TOP_RIGHT_PANE]->y,
518 mwindow->theme->mcanvas_w - pane[TOP_RIGHT_PANE]->x,
519 pane[TOP_RIGHT_PANE]->h);
520 pane[BOTTOM_LEFT_PANE]->resize_event(
521 pane[BOTTOM_LEFT_PANE]->x,
522 pane[BOTTOM_LEFT_PANE]->y,
523 pane[BOTTOM_LEFT_PANE]->w,
524 mwindow->theme->mcanvas_y +
525 mwindow->theme->mcanvas_h -
526 pane[BOTTOM_LEFT_PANE]->y);
527 pane[BOTTOM_RIGHT_PANE]->resize_event(
528 pane[BOTTOM_RIGHT_PANE]->x,
529 pane[BOTTOM_RIGHT_PANE]->y,
530 mwindow->theme->mcanvas_w -
531 pane[BOTTOM_RIGHT_PANE]->x,
532 mwindow->theme->mcanvas_y +
533 mwindow->theme->mcanvas_h -
534 pane[BOTTOM_RIGHT_PANE]->y);
537 update_pane_dividers();
538 pane_button->reposition_window(w - mwindow->theme->get_image_set("pane")[0]->get_w(),
539 mwindow->theme->mzoom_y + 1 - mwindow->theme->get_image_set("pane")[0]->get_h());
540 resource_thread->start_draw();
546 int MWindowGUI::total_panes()
549 for(int i = 0; i < TOTAL_PANES; i++)
554 int MWindowGUI::vertical_panes()
556 return total_panes() == 2 &&
557 pane[TOP_LEFT_PANE] &&
558 pane[BOTTOM_LEFT_PANE];
561 int MWindowGUI::horizontal_panes()
563 return total_panes() == 2 &&
564 pane[TOP_LEFT_PANE] &&
565 pane[TOP_RIGHT_PANE];
568 TimelinePane* MWindowGUI::get_focused_pane()
570 if(pane[focused_pane]) return pane[focused_pane];
571 for(int i = 0; i < TOTAL_PANES; i++)
573 if(pane[i]) return pane[i];
578 void MWindowGUI::activate_timeline()
580 if(pane[focused_pane])
582 pane[focused_pane]->activate();
586 for(int i = 0; i < TOTAL_PANES; i++)
597 void MWindowGUI::deactivate_timeline()
599 for(int i = 0; i < TOTAL_PANES; i++)
603 pane[i]->canvas->deactivate();
608 void MWindowGUI::update_title(char *path)
611 char filename[BCTEXTLEN], string[BCTEXTLEN];
612 fs.extract_name(filename, path);
613 sprintf(string, _(PROGRAM_NAME ": %s"), filename);
615 //printf("MWindowGUI::update_title %s\n", string);
619 void MWindowGUI::draw_overlays(int flash_it)
621 for(int i = 0; i < TOTAL_PANES; i++)
625 pane[i]->canvas->draw_overlays();
626 if(flash_it) pane[i]->canvas->flash();
631 void MWindowGUI::update_timebar(int flush_it)
633 for(int i = 0; i < TOTAL_PANES; i++)
635 if(pane[i] && pane[i]->timebar)
637 pane[i]->timebar->update(flush_it);
642 void MWindowGUI::update_timebar_highlights()
644 for(int i = 0; i < TOTAL_PANES; i++)
646 if(pane[i] && pane[i]->timebar)
648 pane[i]->timebar->update_highlights();
654 void MWindowGUI::update_patchbay()
656 for(int i = 0; i < TOTAL_PANES; i++)
658 if(pane[i] && pane[i]->patchbay)
660 pane[i]->patchbay->update();
665 void MWindowGUI::draw_indexes(Indexable *indexable)
667 for(int i = 0; i < TOTAL_PANES; i++)
671 pane[i]->canvas->draw_indexes(indexable);
676 void MWindowGUI::draw_canvas(int mode /* = 0 */, int hide_cursor /* = 1 */)
678 if(mode != IGNORE_THREAD)
680 resource_thread->stop_draw(1);
684 for(int i = 0; i < TOTAL_PANES; i++)
688 pane[i]->canvas->draw(mode, hide_cursor);
693 if(mode != IGNORE_THREAD)
695 resource_thread->start_draw();
700 void MWindowGUI::flash_canvas(int flush)
702 for(int i = 0; i < TOTAL_PANES; i++)
706 pane[i]->canvas->flash(flush);
711 int MWindowGUI::show_window(int flush)
713 int ret = BC_WindowBase::show_window(flush);
714 if( mwindow->edl->session->proxy_scale == 1 &&
715 mwindow->edl->session->proxy_disabled_scale == 1 )
716 proxy_toggle->hide_window();
718 proxy_toggle->show_window();
722 void MWindowGUI::draw_cursor(int do_plugintoggles)
724 for(int i = 0; i < TOTAL_PANES; i++)
728 pane[i]->cursor->draw(do_plugintoggles);
733 void MWindowGUI::show_cursor(int do_plugintoggles)
735 for(int i = 0; i < TOTAL_PANES; i++)
739 pane[i]->cursor->show(do_plugintoggles);
744 void MWindowGUI::hide_cursor(int do_plugintoggles)
746 for(int i = 0; i < TOTAL_PANES; i++)
750 pane[i]->cursor->hide(do_plugintoggles);
755 void MWindowGUI::update_cursor()
757 for(int i = 0; i < TOTAL_PANES; i++)
761 pane[i]->cursor->update();
766 void MWindowGUI::set_playing_back(int value)
768 for(int i = 0; i < TOTAL_PANES; i++)
772 pane[i]->cursor->playing_back = value;
777 void MWindowGUI::update_plugintoggles()
779 for(int i = 0; i < TOTAL_PANES; i++)
783 pane[i]->canvas->refresh_plugintoggles();
789 void MWindowGUI::update_scrollbars(int flush)
791 for(int i = 0; i < TOTAL_PANES; i++)
795 pane[i]->update(1, 0, 0, 0);
798 if(flush) this->flush();
801 void MWindowGUI::reset_meters()
803 for(int i = 0; i < TOTAL_PANES; i++)
805 if(pane[i] && pane[i]->patchbay)
807 pane[i]->patchbay->reset_meters();
812 void MWindowGUI::stop_meters()
814 for(int i = 0; i < TOTAL_PANES; i++)
816 if(pane[i] && pane[i]->patchbay)
818 pane[i]->patchbay->stop_meters();
823 void MWindowGUI::update_meters(ArrayList<double> *module_levels)
825 for(int i = 0; i < TOTAL_PANES; i++)
827 if(pane[i] && pane[i]->patchbay)
829 pane[i]->patchbay->update_meters(module_levels);
834 void MWindowGUI::set_editing_mode(int flush)
836 for(int i = 0; i < TOTAL_PANES; i++)
840 pane[i]->canvas->update_cursor(flush);
845 void MWindowGUI::set_meter_format(int mode, int min, int max)
847 for(int i = 0; i < TOTAL_PANES; i++)
849 if(pane[i] && pane[i]->patchbay)
851 pane[i]->patchbay->set_meter_format(mode, min, max);
856 void MWindowGUI::update(int scrollbars,
865 if(debug) PRINT_TRACE
869 mwindow->edl->tracks->update_y_pixels(mwindow->theme);
871 if(do_canvas && do_canvas != IGNORE_THREAD)
873 resource_thread->stop_draw(1);
876 for(int i = 0; i < TOTAL_PANES; i++)
878 if(pane[i]) pane[i]->update(scrollbars,
884 if(do_canvas && do_canvas != IGNORE_THREAD)
886 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)
920 mwindow->age_caches();
921 lock_window("MWindowGUI::update");
925 if(debug) PRINT_TRACE
928 int MWindowGUI::visible(int64_t x1, int64_t x2, int64_t view_x1, int64_t view_x2)
930 return (x1 >= view_x1 && x1 < view_x2) ||
931 (x2 > view_x1 && x2 <= view_x2) ||
932 (x1 <= view_x1 && x2 >= view_x2);
936 void MWindowGUI::show_message(const char *message, int color)
938 statusbar->show_message(message, color);
941 void MWindowGUI::update_default_message()
943 statusbar->update_default_message();
946 void MWindowGUI::reset_default_message()
948 statusbar->reset_default_message();
951 void MWindowGUI::default_message()
953 statusbar->default_message();
956 // Drag motion called from other window
957 int MWindowGUI::drag_motion()
959 if(get_hidden()) return 0;
961 Track *over_track = 0;
963 PluginSet *over_pluginset = 0;
964 Plugin *over_plugin = 0;
969 drag_popup->cursor_motion_event();
973 // there's no point in drawing highlights has until drag operation has been set
974 if (!mwindow->session->current_operation)
977 for(int i = 0; i < TOTAL_PANES; i++)
979 if(pane[i]) pane[i]->canvas->drag_motion(
986 if(mwindow->session->track_highlighted != over_track)
988 mwindow->session->track_highlighted = over_track;
992 if(mwindow->session->edit_highlighted != over_edit)
994 mwindow->session->edit_highlighted = over_edit;
998 if(mwindow->session->pluginset_highlighted != over_pluginset)
1000 mwindow->session->pluginset_highlighted = over_pluginset;
1004 if(mwindow->session->plugin_highlighted != over_plugin)
1006 mwindow->session->plugin_highlighted = over_plugin;
1010 if( mwindow->session->current_operation == DRAG_ASSET ||
1011 mwindow->session->current_operation == DRAG_EDIT ||
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::button_release_event()
1140 if( keyvalue_popup ) {
1141 delete keyvalue_popup; keyvalue_popup = 0;
1147 int MWindowGUI::repeat_event(int64_t duration)
1149 // if(duration == 100)
1150 // mwindow->sync_parameters(CHANGE_ALL);
1152 for(int i = 0; i < TOTAL_PANES; i++)
1154 if(pane[i]) result = pane[i]->cursor->repeat_event(duration);
1160 int MWindowGUI::translation_event()
1162 //printf("MWindowGUI::translation_event 1 %d %d\n", get_x(), get_y());
1163 mwindow->session->mwindow_x = get_x();
1164 mwindow->session->mwindow_y = get_y();
1169 int MWindowGUI::save_defaults(BC_Hash *defaults)
1171 defaults->update("MWINDOWWIDTH", get_w());
1172 defaults->update("MWINDOWHEIGHT", get_h());
1173 mainmenu->save_defaults(defaults);
1174 BC_WindowBase::save_defaults(defaults);
1178 int MWindowGUI::keypress_event()
1180 //printf("MWindowGUI::keypress_event 1 %d\n", get_keypress());
1181 int result = mbuttons->keypress_event();
1182 if( result ) return result;
1184 Track *this_track = 0;
1186 switch(get_keypress()) {
1188 mwindow->toggle_editing_mode();
1193 if( alt_down() ) break;
1194 stop_transport("MWindowGUI::keypress_event 1");
1195 mwindow->nearest_plugin_keyframe(shift_down(),
1196 !ctrl_down() ? PLAY_FORWARD : PLAY_REVERSE);
1200 case '1': case '2': case '3': case '4':
1201 case '5': case '6': case '7': case '8':
1202 if( !alt_down() || shift_down() ) break;
1203 if( !mwindow->select_asset(get_keypress()-'1',1) )
1208 if( !ctrl_down() ) {
1210 stop_transport("MWindowGUI::keypress_event 1");
1211 mwindow->prev_edit_handle(shift_down());
1214 mwindow->move_left();
1220 if( !ctrl_down() && !alt_down() ) {
1221 mwindow->move_left();
1227 if( !ctrl_down() ) {
1229 stop_transport("MWindowGUI::keypress_event 2");
1230 mwindow->next_edit_handle(shift_down());
1233 mwindow->move_right();
1239 if( !ctrl_down() && !alt_down() ) {
1240 mwindow->move_right();
1246 if( ctrl_down() && !alt_down() )
1247 mwindow->expand_y();
1248 else if( !ctrl_down() && alt_down() )
1249 mwindow->expand_autos(0,1,1);
1250 else if( ctrl_down() && alt_down() )
1251 mwindow->expand_autos(1,1,1);
1253 mwindow->expand_sample();
1258 if( ctrl_down() && !alt_down() )
1259 mwindow->zoom_in_y();
1260 else if( !ctrl_down() && alt_down() )
1261 mwindow->shrink_autos(0,1,1);
1262 else if( ctrl_down() && alt_down() )
1263 mwindow->shrink_autos(1,1,1);
1265 mwindow->zoom_in_sample();
1273 mwindow->expand_t();
1279 mwindow->move_down();
1281 mwindow->zoom_in_t();
1287 for( int i=0; i<TOTAL_PANES; ++i ) {
1288 if( !pane[i] ) continue;
1289 if( (this_track = pane[i]->over_track()) != 0 ) break;
1290 if( (this_track = pane[i]->over_patchbay()) != 0 ) break;
1293 if( get_keypress() == TAB ) { // Switch the record button
1295 this_track->record = !this_track->record ? 1 : 0;
1298 int total_selected = mwindow->edl->tracks->total_of(Tracks::RECORD);
1299 // all selected if nothing previously selected or
1300 // if this patch was previously the only one selected and armed
1301 int selected = !total_selected || (total_selected == 1 &&
1302 this_track && this_track->record ) ? 1 : 0;
1303 mwindow->edl->tracks->select_all(Tracks::RECORD, selected);
1304 if( !selected && this_track ) this_track->record = 1;
1307 update(0, 1, 0, 0, 1, 0, 1);
1309 mwindow->cwindow->update(0, 1, 1);
1310 lock_window("MWindowGUI::keypress_event 3");
1327 resend_event(mwindow->cwindow->gui);
1331 // since things under cursor have changed...
1333 cursor_motion_event();
1338 int MWindowGUI::keyboard_listener(BC_WindowBase *wp)
1340 return key_listener(wp->get_keypress());
1343 int MWindowGUI::key_listener(int key)
1348 if( !record->running() )
1351 record->record_gui->interrupt_thread->start(0);
1358 channel_info->toggle_scan();
1362 if( !remote_control->deactivate() )
1363 remote_control->activate();
1373 void MWindowGUI::use_android_remote(int on)
1376 delete android_control;
1377 android_control = 0;
1380 if( android_control ) return;
1381 android_control = new AndroidControl(this);
1384 int MWindowGUI::close_event()
1390 void MWindowGUI::stop_drawing()
1392 resource_thread->stop_draw(1);
1395 int MWindowGUI::menu_w()
1397 return mainmenu->get_w();
1400 int MWindowGUI::menu_h()
1402 return mainmenu->get_h();
1405 int MWindowGUI::mbuttons_w()
1408 w -= mwindow->theme->ffmpeg_toggle[0]->get_w()+2;
1409 w -= mwindow->theme->ffmpeg_toggle[0]->get_w()+2;
1413 void MWindowGUI::start_x_pane_drag()
1417 x_pane_drag = new BC_Popup(this,
1418 get_abs_cursor_x(0) - mwindow->theme->pane_w,
1419 BC_DisplayInfo::get_top_border() +
1421 mwindow->theme->mcanvas_y,
1422 mwindow->theme->pane_w,
1423 mwindow->theme->mcanvas_h,
1424 mwindow->theme->drag_pane_color);
1425 x_pane_drag->draw_3segmentv(0,
1427 x_pane_drag->get_h(),
1428 mwindow->theme->get_image_set("xpane")[BUTTON_DOWNHI]);
1429 x_pane_drag->flash(1);
1434 void MWindowGUI::start_y_pane_drag()
1438 //printf("MWindowGUI::start_y_pane_drag %d %d %d\n", __LINE__, get_x(), get_y());
1439 y_pane_drag = new BC_Popup(this,
1440 BC_DisplayInfo::get_left_border() +
1442 mwindow->theme->mcanvas_x,
1443 get_abs_cursor_y(0) - mwindow->theme->pane_h,
1444 mwindow->theme->mcanvas_w,
1445 mwindow->theme->pane_h,
1446 mwindow->theme->drag_pane_color);
1447 y_pane_drag->draw_3segmenth(0,
1449 y_pane_drag->get_w(),
1450 mwindow->theme->get_image_set("ypane")[BUTTON_DOWNHI]);
1451 y_pane_drag->flash(1);
1456 void MWindowGUI::handle_pane_drag()
1462 x_pane_drag->reposition_window(
1463 get_abs_cursor_x(0) - mwindow->theme->pane_w,
1464 x_pane_drag->get_y());
1469 y_pane_drag->reposition_window(
1470 y_pane_drag->get_x(),
1471 get_abs_cursor_y(0) - mwindow->theme->pane_h);
1477 void MWindowGUI::create_x_pane(int cursor_x)
1479 if(total_panes() == 1)
1481 // create a horizontal pane
1482 // do this 1st so the resize_event knows there are 2 panes
1483 mwindow->edl->local_session->view_start[TOP_RIGHT_PANE] =
1484 mwindow->edl->local_session->view_start[TOP_LEFT_PANE] +
1486 mwindow->theme->patchbay_w;
1487 pane[TOP_RIGHT_PANE] = new TimelinePane(mwindow,
1489 mwindow->theme->mcanvas_x +
1491 mwindow->theme->mcanvas_y,
1492 mwindow->theme->mcanvas_x +
1493 mwindow->theme->mcanvas_w -
1495 mwindow->theme->mcanvas_h);
1496 pane[TOP_LEFT_PANE]->resize_event(
1497 mwindow->theme->mcanvas_x,
1498 mwindow->theme->mcanvas_y,
1499 cursor_x - mwindow->theme->pane_w,
1500 mwindow->theme->mcanvas_h);
1501 pane[TOP_RIGHT_PANE]->create_objects();
1504 if(vertical_panes())
1506 // create 2 horizontal panes
1507 mwindow->edl->local_session->track_start[TOP_RIGHT_PANE] =
1508 mwindow->edl->local_session->track_start[TOP_LEFT_PANE];
1509 mwindow->edl->local_session->track_start[BOTTOM_RIGHT_PANE] =
1510 mwindow->edl->local_session->track_start[BOTTOM_LEFT_PANE];
1511 mwindow->edl->local_session->view_start[TOP_RIGHT_PANE] =
1512 mwindow->edl->local_session->view_start[BOTTOM_RIGHT_PANE] =
1513 mwindow->edl->local_session->view_start[TOP_LEFT_PANE] +
1515 mwindow->theme->patchbay_w;
1516 pane[TOP_RIGHT_PANE] = new TimelinePane(mwindow,
1518 mwindow->theme->mcanvas_x +
1520 pane[TOP_LEFT_PANE]->y,
1521 mwindow->theme->mcanvas_x +
1522 mwindow->theme->mcanvas_w -
1524 pane[TOP_LEFT_PANE]->h);
1525 pane[BOTTOM_RIGHT_PANE] = new TimelinePane(mwindow,
1527 mwindow->theme->mcanvas_x +
1529 pane[BOTTOM_LEFT_PANE]->y,
1530 mwindow->theme->mcanvas_x +
1531 mwindow->theme->mcanvas_w -
1533 pane[BOTTOM_LEFT_PANE]->h);
1534 pane[TOP_LEFT_PANE]->resize_event(
1535 pane[TOP_LEFT_PANE]->x,
1536 pane[TOP_LEFT_PANE]->y,
1537 cursor_x - mwindow->theme->pane_w,
1538 pane[TOP_LEFT_PANE]->h);
1539 pane[BOTTOM_LEFT_PANE]->resize_event(
1540 pane[BOTTOM_LEFT_PANE]->x,
1541 pane[BOTTOM_LEFT_PANE]->y,
1542 cursor_x - mwindow->theme->pane_w,
1543 pane[BOTTOM_LEFT_PANE]->h);
1544 pane[TOP_RIGHT_PANE]->create_objects();
1545 pane[BOTTOM_RIGHT_PANE]->create_objects();
1548 if(horizontal_panes())
1550 // resize a horizontal pane
1551 mwindow->edl->local_session->view_start[TOP_RIGHT_PANE] +=
1553 pane[TOP_RIGHT_PANE]->x;
1554 if(mwindow->edl->local_session->view_start[TOP_RIGHT_PANE] < 0)
1555 mwindow->edl->local_session->view_start[TOP_RIGHT_PANE] = 0;
1556 pane[TOP_LEFT_PANE]->resize_event(
1557 mwindow->theme->mcanvas_x,
1558 mwindow->theme->mcanvas_y,
1559 cursor_x - mwindow->theme->pane_w,
1560 mwindow->theme->mcanvas_h);
1561 pane[TOP_RIGHT_PANE]->resize_event(
1562 mwindow->theme->mcanvas_x +
1564 pane[TOP_RIGHT_PANE]->y,
1565 mwindow->theme->mcanvas_x +
1566 mwindow->theme->mcanvas_w -
1568 mwindow->theme->mcanvas_h);
1572 // resize 2 horizontal panes
1573 mwindow->edl->local_session->view_start[TOP_RIGHT_PANE] +=
1575 pane[TOP_RIGHT_PANE]->x;
1576 if(mwindow->edl->local_session->view_start[TOP_RIGHT_PANE] < 0)
1577 mwindow->edl->local_session->view_start[TOP_RIGHT_PANE] = 0;
1578 mwindow->edl->local_session->view_start[BOTTOM_RIGHT_PANE] =
1579 mwindow->edl->local_session->view_start[TOP_RIGHT_PANE];
1581 pane[TOP_LEFT_PANE]->resize_event(
1582 mwindow->theme->mcanvas_x,
1583 pane[TOP_LEFT_PANE]->y,
1584 cursor_x - mwindow->theme->pane_w,
1585 pane[TOP_LEFT_PANE]->h);
1586 pane[TOP_RIGHT_PANE]->resize_event(
1587 mwindow->theme->mcanvas_x +
1589 pane[TOP_RIGHT_PANE]->y,
1590 mwindow->theme->mcanvas_x +
1591 mwindow->theme->mcanvas_w -
1593 pane[TOP_RIGHT_PANE]->h);
1594 pane[BOTTOM_LEFT_PANE]->resize_event(
1595 mwindow->theme->mcanvas_x,
1596 pane[BOTTOM_LEFT_PANE]->y,
1597 cursor_x - mwindow->theme->pane_w,
1598 pane[BOTTOM_LEFT_PANE]->h);
1599 pane[BOTTOM_RIGHT_PANE]->resize_event(
1600 mwindow->theme->mcanvas_x +
1602 pane[BOTTOM_RIGHT_PANE]->y,
1603 mwindow->theme->mcanvas_x +
1604 mwindow->theme->mcanvas_w -
1606 pane[BOTTOM_RIGHT_PANE]->h);
1612 void MWindowGUI::delete_x_pane(int cursor_x)
1614 // give left panes coordinates of right pane
1615 if(cursor_x < mwindow->theme->patchbay_w + PANE_DRAG_MARGIN &&
1616 pane[TOP_RIGHT_PANE])
1618 mwindow->edl->local_session->view_start[TOP_LEFT_PANE] =
1619 mwindow->edl->local_session->view_start[TOP_RIGHT_PANE] -
1620 pane[TOP_RIGHT_PANE]->x + mwindow->theme->patchbay_w;
1621 if(mwindow->edl->local_session->view_start[TOP_LEFT_PANE] < 0)
1622 mwindow->edl->local_session->view_start[TOP_LEFT_PANE] = 0;
1623 mwindow->edl->local_session->view_start[BOTTOM_LEFT_PANE] =
1624 mwindow->edl->local_session->view_start[TOP_LEFT_PANE];
1627 switch(total_panes())
1630 if(pane[TOP_LEFT_PANE] && pane[TOP_RIGHT_PANE])
1632 // delete right pane
1633 delete pane[TOP_RIGHT_PANE];
1634 pane[TOP_RIGHT_PANE] = 0;
1635 pane[TOP_LEFT_PANE]->resize_event(
1636 mwindow->theme->mcanvas_x,
1637 mwindow->theme->mcanvas_y,
1638 mwindow->theme->mcanvas_w,
1639 mwindow->theme->mcanvas_h);
1645 // delete right panes
1646 delete pane[TOP_RIGHT_PANE];
1647 pane[TOP_RIGHT_PANE] = 0;
1648 delete pane[BOTTOM_RIGHT_PANE];
1649 pane[BOTTOM_RIGHT_PANE] = 0;
1650 pane[TOP_LEFT_PANE]->resize_event(
1651 mwindow->theme->mcanvas_x,
1652 pane[TOP_LEFT_PANE]->y,
1653 mwindow->theme->mcanvas_w,
1654 pane[TOP_LEFT_PANE]->h);
1655 pane[BOTTOM_LEFT_PANE]->resize_event(
1656 mwindow->theme->mcanvas_x,
1657 pane[BOTTOM_LEFT_PANE]->y,
1658 mwindow->theme->mcanvas_w,
1659 pane[BOTTOM_LEFT_PANE]->h);
1664 void MWindowGUI::create_y_pane(int cursor_y)
1666 if(total_panes() == 1)
1668 mwindow->edl->local_session->view_start[BOTTOM_LEFT_PANE] =
1669 mwindow->edl->local_session->view_start[TOP_LEFT_PANE];
1670 mwindow->edl->local_session->track_start[BOTTOM_LEFT_PANE] =
1671 mwindow->edl->local_session->track_start[TOP_LEFT_PANE] +
1673 mwindow->theme->mtimebar_h;
1674 // do this 1st so the resize_event knows there are 2 panes
1675 pane[BOTTOM_LEFT_PANE] = new TimelinePane(mwindow,
1677 mwindow->theme->mcanvas_x,
1678 mwindow->theme->mcanvas_y +
1680 mwindow->theme->mcanvas_w,
1681 mwindow->theme->mcanvas_h -
1683 pane[TOP_LEFT_PANE]->resize_event(
1684 mwindow->theme->mcanvas_x,
1685 mwindow->theme->mcanvas_y,
1686 mwindow->theme->mcanvas_w,
1687 pane[BOTTOM_LEFT_PANE]->y -
1688 mwindow->theme->mcanvas_y -
1689 mwindow->theme->pane_h);
1690 pane[BOTTOM_LEFT_PANE]->create_objects();
1693 if(horizontal_panes())
1696 mwindow->edl->local_session->view_start[BOTTOM_LEFT_PANE] =
1697 mwindow->edl->local_session->view_start[TOP_LEFT_PANE];
1698 mwindow->edl->local_session->view_start[BOTTOM_RIGHT_PANE] =
1699 mwindow->edl->local_session->view_start[TOP_RIGHT_PANE];
1700 mwindow->edl->local_session->track_start[BOTTOM_LEFT_PANE] =
1701 mwindow->edl->local_session->track_start[BOTTOM_RIGHT_PANE] =
1702 mwindow->edl->local_session->track_start[TOP_LEFT_PANE] +
1704 mwindow->theme->mtimebar_h;
1706 pane[BOTTOM_LEFT_PANE] = new TimelinePane(mwindow,
1708 pane[TOP_LEFT_PANE]->x,
1709 mwindow->theme->mcanvas_y +
1711 pane[TOP_LEFT_PANE]->w,
1712 mwindow->theme->mcanvas_h -
1714 pane[BOTTOM_RIGHT_PANE] = new TimelinePane(mwindow,
1716 pane[TOP_RIGHT_PANE]->x,
1717 mwindow->theme->mcanvas_y +
1719 pane[TOP_RIGHT_PANE]->w,
1720 mwindow->theme->mcanvas_h -
1723 pane[TOP_LEFT_PANE]->resize_event(
1724 pane[TOP_LEFT_PANE]->x,
1725 pane[TOP_LEFT_PANE]->y,
1726 pane[TOP_LEFT_PANE]->w,
1727 pane[BOTTOM_LEFT_PANE]->y -
1728 mwindow->theme->mcanvas_y -
1729 mwindow->theme->pane_h);
1730 pane[TOP_RIGHT_PANE]->resize_event(
1731 pane[TOP_RIGHT_PANE]->x,
1732 pane[TOP_RIGHT_PANE]->y,
1733 pane[TOP_RIGHT_PANE]->w,
1734 pane[BOTTOM_RIGHT_PANE]->y -
1735 mwindow->theme->mcanvas_y -
1736 mwindow->theme->pane_h);
1738 pane[BOTTOM_LEFT_PANE]->create_objects();
1739 pane[BOTTOM_RIGHT_PANE]->create_objects();
1742 if(vertical_panes())
1745 mwindow->edl->local_session->track_start[BOTTOM_LEFT_PANE] +=
1747 (pane[BOTTOM_LEFT_PANE]->y - mwindow->theme->mcanvas_y);
1748 if(mwindow->edl->local_session->track_start[BOTTOM_LEFT_PANE] < 0)
1749 mwindow->edl->local_session->track_start[BOTTOM_LEFT_PANE] = 0;
1750 pane[TOP_LEFT_PANE]->resize_event(
1751 mwindow->theme->mcanvas_x,
1752 mwindow->theme->mcanvas_y,
1753 mwindow->theme->mcanvas_w,
1754 cursor_y - mwindow->theme->pane_h);
1755 pane[BOTTOM_LEFT_PANE]->resize_event(
1756 pane[BOTTOM_LEFT_PANE]->x,
1758 mwindow->theme->mcanvas_y,
1759 mwindow->theme->mcanvas_w,
1760 mwindow->theme->mcanvas_h -
1766 mwindow->edl->local_session->track_start[BOTTOM_LEFT_PANE] +=
1768 (pane[BOTTOM_LEFT_PANE]->y - mwindow->theme->mcanvas_y);
1769 if(mwindow->edl->local_session->track_start[BOTTOM_LEFT_PANE] < 0)
1770 mwindow->edl->local_session->track_start[BOTTOM_LEFT_PANE] = 0;
1771 mwindow->edl->local_session->track_start[BOTTOM_RIGHT_PANE] =
1772 mwindow->edl->local_session->track_start[BOTTOM_LEFT_PANE];
1773 pane[TOP_LEFT_PANE]->resize_event(
1774 pane[TOP_LEFT_PANE]->x,
1775 pane[TOP_LEFT_PANE]->y,
1776 pane[TOP_LEFT_PANE]->w,
1777 cursor_y - mwindow->theme->pane_h);
1778 pane[BOTTOM_LEFT_PANE]->resize_event(
1779 pane[BOTTOM_LEFT_PANE]->x,
1781 mwindow->theme->mcanvas_y,
1782 pane[BOTTOM_LEFT_PANE]->w,
1783 mwindow->theme->mcanvas_h -
1785 pane[TOP_RIGHT_PANE]->resize_event(
1786 pane[TOP_RIGHT_PANE]->x,
1787 pane[TOP_RIGHT_PANE]->y,
1788 pane[TOP_RIGHT_PANE]->w,
1789 cursor_y - mwindow->theme->pane_h);
1790 pane[BOTTOM_RIGHT_PANE]->resize_event(
1791 pane[BOTTOM_RIGHT_PANE]->x,
1793 mwindow->theme->mcanvas_y,
1794 pane[BOTTOM_RIGHT_PANE]->w,
1795 mwindow->theme->mcanvas_h -
1800 void MWindowGUI::delete_y_pane(int cursor_y)
1802 if(cursor_y < mwindow->theme->mtimebar_h +
1804 pane[BOTTOM_LEFT_PANE])
1806 // give top pane coordinates of bottom pane
1807 mwindow->edl->local_session->track_start[TOP_LEFT_PANE] =
1808 mwindow->edl->local_session->track_start[BOTTOM_LEFT_PANE] -
1809 pane[BOTTOM_LEFT_PANE]->y;
1810 if(mwindow->edl->local_session->track_start[TOP_LEFT_PANE] < 0)
1811 mwindow->edl->local_session->track_start[TOP_LEFT_PANE] = 0;
1812 mwindow->edl->local_session->track_start[TOP_RIGHT_PANE] =
1813 mwindow->edl->local_session->track_start[TOP_LEFT_PANE];
1817 switch(total_panes())
1820 delete pane[BOTTOM_LEFT_PANE];
1821 pane[BOTTOM_LEFT_PANE] = 0;
1822 pane[TOP_LEFT_PANE]->resize_event(
1823 mwindow->theme->mcanvas_x,
1824 mwindow->theme->mcanvas_y,
1825 mwindow->theme->mcanvas_w,
1826 mwindow->theme->mcanvas_h);
1830 // delete bottom 2 panes
1832 delete pane[BOTTOM_LEFT_PANE];
1833 pane[BOTTOM_LEFT_PANE] = 0;
1834 delete pane[BOTTOM_RIGHT_PANE];
1835 pane[BOTTOM_RIGHT_PANE] = 0;
1836 pane[TOP_LEFT_PANE]->resize_event(
1837 pane[TOP_LEFT_PANE]->x,
1838 mwindow->theme->mcanvas_y,
1839 pane[TOP_LEFT_PANE]->w,
1840 mwindow->theme->mcanvas_h);
1841 pane[TOP_RIGHT_PANE]->resize_event(
1842 pane[TOP_RIGHT_PANE]->x,
1843 mwindow->theme->mcanvas_y,
1844 pane[TOP_RIGHT_PANE]->w,
1845 mwindow->theme->mcanvas_h);
1850 void MWindowGUI::stop_pane_drag()
1853 resource_thread->stop_draw(1);
1857 // cursor position relative to canvas
1858 int cursor_x = x_pane_drag->get_x() -
1860 BC_DisplayInfo::get_left_border() -
1861 mwindow->theme->mcanvas_x +
1862 mwindow->theme->pane_w;
1867 if(cursor_x >= mwindow->theme->patchbay_w + PANE_DRAG_MARGIN &&
1868 cursor_x < mwindow->theme->mcanvas_w -
1869 BC_ScrollBar::get_span(SCROLL_VERT) -
1872 create_x_pane(cursor_x);
1873 mwindow->edl->local_session->x_pane = cursor_x;
1878 delete_x_pane(cursor_x);
1879 mwindow->edl->local_session->x_pane = -1;
1887 // cursor position relative to canvas
1888 int cursor_y = y_pane_drag->get_y() -
1890 BC_DisplayInfo::get_top_border() -
1891 mwindow->theme->mcanvas_y +
1892 mwindow->theme->pane_h;
1898 if(cursor_y >= mwindow->theme->mtimebar_h +
1900 cursor_y < mwindow->theme->mcanvas_h -
1901 BC_ScrollBar::get_span(SCROLL_HORIZ) -
1904 create_y_pane(cursor_y);
1905 mwindow->edl->local_session->y_pane = cursor_y;
1909 delete_y_pane(cursor_y);
1910 mwindow->edl->local_session->y_pane = -1;
1914 update_pane_dividers();
1916 // required to get new widgets to appear
1918 resource_thread->start_draw();
1921 // create panes from EDL
1922 void MWindowGUI::load_panes()
1924 int need_x_panes = 0;
1925 int need_y_panes = 0;
1926 // use names from create functions
1927 int cursor_x = mwindow->edl->local_session->x_pane;
1928 int cursor_y = mwindow->edl->local_session->y_pane;
1930 resource_thread->stop_draw(1);
1932 mwindow->theme->patchbay_w + PANE_DRAG_MARGIN &&
1934 mwindow->theme->mcanvas_w -
1935 BC_ScrollBar::get_span(SCROLL_VERT) -
1942 mwindow->theme->mtimebar_h + PANE_DRAG_MARGIN &&
1944 mwindow->theme->mcanvas_h -
1945 BC_ScrollBar::get_span(SCROLL_HORIZ) -
1951 //printf("MWindowGUI::load_panes %d %d %d\n", __LINE__, need_x_panes, need_y_panes);
1959 if(total_panes() == 1)
1962 //printf("MWindowGUI::load_panes %d\n", __LINE__);
1963 pane[TOP_RIGHT_PANE] = new TimelinePane(mwindow,
1965 mwindow->theme->mcanvas_x +
1967 mwindow->theme->mcanvas_y,
1968 mwindow->theme->mcanvas_x +
1969 mwindow->theme->mcanvas_w -
1971 cursor_y - mwindow->theme->pane_h);
1972 pane[BOTTOM_LEFT_PANE] = new TimelinePane(mwindow,
1974 mwindow->theme->mcanvas_x,
1975 mwindow->theme->mcanvas_y +
1977 cursor_x - mwindow->theme->pane_w,
1978 mwindow->theme->mcanvas_h -
1980 pane[BOTTOM_RIGHT_PANE] = new TimelinePane(mwindow,
1982 pane[TOP_RIGHT_PANE]->x,
1983 mwindow->theme->mcanvas_y +
1985 pane[TOP_RIGHT_PANE]->w,
1986 mwindow->theme->mcanvas_h -
1988 pane[TOP_LEFT_PANE]->resize_event(
1989 pane[TOP_LEFT_PANE]->x,
1990 pane[TOP_LEFT_PANE]->y,
1991 cursor_x - mwindow->theme->pane_w,
1992 cursor_y - mwindow->theme->pane_h);
1993 pane[TOP_RIGHT_PANE]->create_objects();
1994 pane[BOTTOM_LEFT_PANE]->create_objects();
1995 pane[BOTTOM_RIGHT_PANE]->create_objects();
1998 if(horizontal_panes())
2000 // create vertical panes
2001 //printf("MWindowGUI::load_panes %d\n", __LINE__);
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]->resize_event(
2024 mwindow->theme->mcanvas_x +
2026 mwindow->theme->mcanvas_y,
2027 mwindow->theme->mcanvas_x +
2028 mwindow->theme->mcanvas_w -
2030 cursor_y - mwindow->theme->pane_h);
2031 pane[BOTTOM_LEFT_PANE]->create_objects();
2032 pane[BOTTOM_RIGHT_PANE]->create_objects();
2035 if(vertical_panes())
2037 // create horizontal panes
2038 //printf("MWindowGUI::load_panes %d\n", __LINE__);
2039 pane[TOP_RIGHT_PANE] = new TimelinePane(mwindow,
2041 mwindow->theme->mcanvas_x +
2043 mwindow->theme->mcanvas_y,
2044 mwindow->theme->mcanvas_x +
2045 mwindow->theme->mcanvas_w -
2047 cursor_y - mwindow->theme->pane_h);
2048 pane[BOTTOM_RIGHT_PANE] = new TimelinePane(mwindow,
2050 pane[TOP_RIGHT_PANE]->x,
2051 mwindow->theme->mcanvas_y +
2053 pane[TOP_RIGHT_PANE]->w,
2054 mwindow->theme->mcanvas_h -
2056 pane[TOP_LEFT_PANE]->resize_event(
2057 pane[TOP_LEFT_PANE]->x,
2058 pane[TOP_LEFT_PANE]->y,
2059 cursor_x - mwindow->theme->pane_w,
2060 cursor_y - mwindow->theme->pane_h);
2061 pane[BOTTOM_LEFT_PANE]->resize_event(
2062 pane[TOP_LEFT_PANE]->x,
2063 mwindow->theme->mcanvas_y +
2065 mwindow->theme->mcanvas_x +
2066 mwindow->theme->mcanvas_w -
2067 cursor_x - mwindow->theme->pane_w,
2068 mwindow->theme->mcanvas_h -
2070 pane[TOP_RIGHT_PANE]->create_objects();
2071 pane[BOTTOM_RIGHT_PANE]->create_objects();
2078 //printf("MWindowGUI::load_panes %d\n", __LINE__);
2079 pane[TOP_LEFT_PANE]->resize_event(
2080 pane[TOP_LEFT_PANE]->x,
2081 pane[TOP_LEFT_PANE]->y,
2082 cursor_x - mwindow->theme->pane_w,
2083 cursor_y - mwindow->theme->pane_h);
2084 pane[TOP_RIGHT_PANE]->resize_event(
2085 mwindow->theme->mcanvas_x +
2087 mwindow->theme->mcanvas_y,
2088 mwindow->theme->mcanvas_x +
2089 mwindow->theme->mcanvas_w -
2091 cursor_y - mwindow->theme->pane_h);
2092 pane[BOTTOM_LEFT_PANE]->resize_event(
2093 pane[TOP_LEFT_PANE]->x,
2094 mwindow->theme->mcanvas_y +
2096 mwindow->theme->mcanvas_x +
2097 mwindow->theme->mcanvas_w -
2098 cursor_x - mwindow->theme->pane_w,
2099 mwindow->theme->mcanvas_h -
2101 pane[BOTTOM_RIGHT_PANE]->resize_event(
2102 pane[TOP_RIGHT_PANE]->x,
2103 mwindow->theme->mcanvas_y +
2105 pane[TOP_RIGHT_PANE]->w,
2106 mwindow->theme->mcanvas_h -
2115 if(pane[BOTTOM_LEFT_PANE]) delete pane[BOTTOM_LEFT_PANE];
2116 if(pane[BOTTOM_RIGHT_PANE]) delete pane[BOTTOM_RIGHT_PANE];
2117 pane[BOTTOM_LEFT_PANE] = 0;
2118 pane[BOTTOM_RIGHT_PANE] = 0;
2120 if(!pane[TOP_RIGHT_PANE])
2122 pane[TOP_RIGHT_PANE] = new TimelinePane(mwindow,
2124 mwindow->theme->mcanvas_x +
2126 mwindow->theme->mcanvas_y,
2127 mwindow->theme->mcanvas_x +
2128 mwindow->theme->mcanvas_w -
2130 mwindow->theme->mcanvas_h);
2131 pane[TOP_LEFT_PANE]->resize_event(
2132 mwindow->theme->mcanvas_x,
2133 mwindow->theme->mcanvas_y,
2134 cursor_x - mwindow->theme->pane_w,
2135 mwindow->theme->mcanvas_h);
2136 pane[TOP_RIGHT_PANE]->create_objects();
2140 pane[TOP_LEFT_PANE]->resize_event(
2141 mwindow->theme->mcanvas_x,
2142 mwindow->theme->mcanvas_y,
2143 cursor_x - mwindow->theme->pane_w,
2144 mwindow->theme->mcanvas_h);
2145 pane[TOP_RIGHT_PANE]->resize_event(
2146 mwindow->theme->mcanvas_x +
2148 pane[TOP_RIGHT_PANE]->y,
2149 mwindow->theme->mcanvas_x +
2150 mwindow->theme->mcanvas_w -
2152 mwindow->theme->mcanvas_h);
2160 if(pane[TOP_RIGHT_PANE]) delete pane[TOP_RIGHT_PANE];
2161 if(pane[BOTTOM_RIGHT_PANE]) delete pane[BOTTOM_RIGHT_PANE];
2162 pane[TOP_RIGHT_PANE] = 0;
2163 pane[BOTTOM_RIGHT_PANE] = 0;
2165 if(!pane[BOTTOM_LEFT_PANE])
2167 //printf("MWindowGUI::load_panes %d\n", __LINE__);
2168 pane[BOTTOM_LEFT_PANE] = new TimelinePane(mwindow,
2170 mwindow->theme->mcanvas_x,
2171 mwindow->theme->mcanvas_y +
2173 mwindow->theme->mcanvas_w,
2174 mwindow->theme->mcanvas_h -
2176 pane[TOP_LEFT_PANE]->resize_event(
2177 mwindow->theme->mcanvas_x,
2178 mwindow->theme->mcanvas_y,
2179 mwindow->theme->mcanvas_w,
2180 pane[BOTTOM_LEFT_PANE]->y -
2181 mwindow->theme->mcanvas_y -
2182 mwindow->theme->pane_h);
2183 pane[BOTTOM_LEFT_PANE]->create_objects();
2187 pane[TOP_LEFT_PANE]->resize_event(
2188 mwindow->theme->mcanvas_x,
2189 mwindow->theme->mcanvas_y,
2190 mwindow->theme->mcanvas_w,
2191 cursor_y - mwindow->theme->pane_h);
2192 pane[BOTTOM_LEFT_PANE]->resize_event(
2193 pane[BOTTOM_LEFT_PANE]->x,
2195 mwindow->theme->mcanvas_y,
2196 mwindow->theme->mcanvas_w,
2197 mwindow->theme->mcanvas_h -
2204 if(pane[TOP_RIGHT_PANE]) delete pane[TOP_RIGHT_PANE];
2205 if(pane[BOTTOM_RIGHT_PANE]) delete pane[BOTTOM_RIGHT_PANE];
2206 if(pane[BOTTOM_LEFT_PANE]) delete pane[BOTTOM_LEFT_PANE];
2207 pane[TOP_RIGHT_PANE] = 0;
2208 pane[BOTTOM_RIGHT_PANE] = 0;
2209 pane[BOTTOM_LEFT_PANE] = 0;
2210 pane[TOP_LEFT_PANE]->resize_event(
2211 mwindow->theme->mcanvas_x,
2212 mwindow->theme->mcanvas_y,
2213 mwindow->theme->mcanvas_w,
2214 mwindow->theme->mcanvas_h);
2217 update_pane_dividers();
2220 resource_thread->start_draw();
2223 void MWindowGUI::update_pane_dividers()
2226 if(horizontal_panes() || total_panes() == 4)
2228 int x = pane[TOP_RIGHT_PANE]->x - mwindow->theme->pane_w;
2229 int y = mwindow->theme->mcanvas_y;
2230 int h = mwindow->theme->mcanvas_h;
2234 add_subwindow(x_divider = new PaneDivider(
2235 mwindow, x, y, h, 1));
2236 x_divider->create_objects();
2240 x_divider->reposition_window(x, y, h);
2253 if(vertical_panes() || total_panes() == 4)
2255 int x = mwindow->theme->mcanvas_x;
2256 int y = pane[BOTTOM_LEFT_PANE]->y -
2257 mwindow->theme->pane_h;
2258 int w = mwindow->theme->mcanvas_w;
2261 add_subwindow(y_divider = new PaneDivider(
2262 mwindow, x, y, w, 0));
2263 y_divider->create_objects();
2267 y_divider->reposition_window(x, y, w);
2281 void MWindowGUI::draw_samplemovement()
2288 update_scrollbars(1);
2291 void MWindowGUI::draw_trackmovement()
2293 update_scrollbars(0);
2300 void MWindowGUI::update_mixers(Track *track, int v)
2302 for( int i=0; i<TOTAL_PANES; ++i ) {
2303 if( !pane[i] ) continue;
2304 PatchBay *patchbay = pane[i]->patchbay;
2305 if( !patchbay ) continue;
2306 for( int j=0; j<patchbay->patches.total; ++j ) {
2307 PatchGUI *patchgui = patchbay->patches.values[j];
2308 if( !patchgui->mix ) continue;
2309 if( !track || patchgui->track == track ) {
2310 patchgui->mix->update(v>=0 ? v :
2311 mwindow->mixer_track_active(patchgui->track));
2317 void MWindowGUI::stop_transport(const char *lock_msg)
2319 if( !mbuttons->transport->is_stopped() ) {
2320 if( lock_msg ) unlock_window();
2321 mbuttons->transport->handle_transport(STOP, 1, 0, 0);
2322 if( lock_msg ) lock_window(lock_msg);
2326 PaneButton::PaneButton(MWindow *mwindow, int x, int y)
2327 : BC_Button(x, y, mwindow->theme->get_image_set("pane"))
2329 this->mwindow = mwindow;
2332 int PaneButton::cursor_motion_event()
2334 if(get_top_level()->get_button_down() &&
2336 get_status() == BUTTON_DOWNHI &&
2339 // printf("PaneButton::cursor_motion_event %d\n", __LINE__);
2341 if(get_cursor_x() < 0 && !mwindow->gui->dragging_pane)
2343 mwindow->gui->start_x_pane_drag();
2346 if(get_cursor_y() < 0 && !mwindow->gui->dragging_pane)
2348 mwindow->gui->start_y_pane_drag();
2352 mwindow->gui->handle_pane_drag();
2354 int result = BC_Button::cursor_motion_event();
2358 int PaneButton::button_release_event()
2360 if( get_buttonpress() != WHEEL_DOWN && get_buttonpress() != WHEEL_UP )
2361 mwindow->gui->stop_pane_drag();
2362 int result = BC_Button::button_release_event();
2367 FFMpegToggle::FFMpegToggle(MWindow *mwindow, MButtons *mbuttons, int x, int y)
2368 : BC_Toggle(x, y, mwindow->theme->ffmpeg_toggle,
2369 mwindow->preferences->get_file_probe_armed("FFMPEG_Early") > 0 ? 1 : 0)
2371 this->mwindow = mwindow;
2372 this->mbuttons = mbuttons;
2373 set_tooltip(get_value() ? FFMPEG_EARLY_TIP : FFMPEG_LATE_TIP);
2376 FFMpegToggle::~FFMpegToggle()
2380 int FFMpegToggle::handle_event()
2382 int ffmpeg_early_probe = get_value();
2383 set_tooltip(ffmpeg_early_probe ? FFMPEG_EARLY_TIP : FFMPEG_LATE_TIP);
2384 mwindow->preferences->set_file_probe_armed("FFMPEG_Early", ffmpeg_early_probe);
2385 mwindow->preferences->set_file_probe_armed("FFMPEG_Late", !ffmpeg_early_probe);
2387 mwindow->show_warning(&mwindow->preferences->warn_indexes,
2388 _("Changing the base codecs may require rebuilding indexes."));
2393 ProxyToggle::ProxyToggle(MWindow *mwindow, MButtons *mbuttons, int x, int y)
2394 : BC_Toggle(x, y, mwindow->theme->proxy_toggle,
2395 mwindow->edl->session->proxy_disabled_scale != 1)
2397 this->mwindow = mwindow;
2398 this->mbuttons = mbuttons;
2399 set_tooltip(mwindow->edl->session->proxy_disabled_scale==1 ?
2400 _("Disable proxy") : _("Enable proxy"));
2403 ProxyToggle::~ProxyToggle()
2407 int ProxyToggle::handle_event()
2409 int disabled = get_value();
2411 mwindow->disable_proxy();
2413 mwindow->enable_proxy();
2414 set_tooltip(!disabled ? _("Disable proxy") : _("Enable proxy"));
2418 int ProxyToggle::keypress_event()
2420 if( ctrl_down() && !shift_down() && !alt_down() ) {
2421 int key = get_keypress();
2423 int value = get_value() ? 0 : 1;
2425 return handle_event();