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 add_subwindow(ffmpeg_toggle = new FFMpegToggle(mwindow, mbuttons, menu_w(), menu_h()+2));
282 pane[TOP_LEFT_PANE] = new TimelinePane(mwindow,
284 mwindow->theme->mcanvas_x,
285 mwindow->theme->mcanvas_y,
286 mwindow->theme->mcanvas_w,
287 mwindow->theme->mcanvas_h);
288 pane[TOP_LEFT_PANE]->create_objects();
290 // add_subwindow(timebar = new MTimeBar(mwindow,
292 // mwindow->theme->mtimebar_x,
293 // mwindow->theme->mtimebar_y,
294 // mwindow->theme->mtimebar_w,
295 // mwindow->theme->mtimebar_h));
296 // timebar->create_objects();
298 // if(debug) printf("MWindowGUI::create_objects %d\n", __LINE__);
299 // add_subwindow(patchbay = new PatchBay(mwindow, this));
300 // patchbay->create_objects();
302 // if(debug) printf("MWindowGUI::create_objects %d\n", __LINE__);
303 // get_scrollbars(0);
305 // if(debug) printf("MWindowGUI::create_objects %d\n", __LINE__);
306 // mwindow->gui->add_subwindow(canvas = new TrackCanvas(mwindow, this));
307 // canvas->create_objects();
310 if(debug) printf("MWindowGUI::create_objects %d\n", __LINE__);
311 add_subwindow(zoombar = new ZoomBar(mwindow, this));
312 zoombar->create_objects();
315 if(debug) printf("MWindowGUI::create_objects %d\n", __LINE__);
316 add_subwindow(statusbar = new StatusBar(mwindow, this));
317 statusbar->create_objects();
321 if(debug) printf("MWindowGUI::create_objects %d\n", __LINE__);
322 add_subwindow(mainclock = new MainClock(mwindow,
323 mwindow->theme->mclock_x, mwindow->theme->mclock_y,
324 mwindow->theme->mclock_w));
325 if(debug) printf("MWindowGUI::create_objects %d\n", __LINE__);
326 mainclock->update(0);
330 // if(debug) printf("MWindowGUI::create_objects %d\n", __LINE__);
331 // cursor = new MainCursor(mwindow, this);
332 // cursor->create_objects();
335 if(debug) printf("MWindowGUI::create_objects %d\n", __LINE__);
336 add_subwindow(edit_menu = new EditPopup(mwindow, this));
337 edit_menu->create_objects();
340 if(debug) printf("MWindowGUI::create_objects %d\n", __LINE__);
341 add_subwindow(plugin_menu = new PluginPopup(mwindow, this));
342 plugin_menu->create_objects();
345 if(debug) printf("MWindowGUI::create_objects %d\n", __LINE__);
346 add_subwindow(keyframe_menu = new KeyframePopup(mwindow, this));
347 keyframe_menu->create_objects();
348 add_subwindow(keyframe_hide = new KeyframeHidePopup(mwindow, this));
349 keyframe_hide->create_objects();
352 if(debug) printf("MWindowGUI::create_objects %d\n", __LINE__);
353 add_subwindow(transition_menu = new TransitionPopup(mwindow, this));
354 transition_menu->create_objects();
357 channel_info = new ChannelInfo(mwindow);
359 db_window = new DbWindow(mwindow);
360 swindow = new SWindow(mwindow);
362 if(debug) printf("MWindowGUI::create_objects %d\n", __LINE__);
364 add_subwindow(pane_button = new PaneButton(mwindow,
365 get_w() - mwindow->theme->get_image_set("pane")[0]->get_w(),
366 mwindow->theme->mzoom_y + 1 - mwindow->theme->get_image_set("pane")[0]->get_h()));
368 pane[TOP_LEFT_PANE]->canvas->activate();
370 if(debug) printf("MWindowGUI::create_objects %d\n", __LINE__);
373 void MWindowGUI::redraw_time_dependancies()
375 zoombar->redraw_time_dependancies();
376 for(int i = 0; i < TOTAL_PANES; i++)
377 if(pane[i] && pane[i]->timebar) pane[i]->timebar->update(0);
378 mainclock->update(mwindow->edl->local_session->get_selectionstart(1));
381 int MWindowGUI::focus_in_event()
383 for(int i = 0; i < TOTAL_PANES; i++)
384 if(pane[i]) pane[i]->cursor->focus_in_event();
388 int MWindowGUI::focus_out_event()
390 for(int i = 0; i < TOTAL_PANES; i++)
391 if(pane[i]) pane[i]->cursor->focus_out_event();
396 int MWindowGUI::resize_event(int w, int h)
398 //printf("MWindowGUI::resize_event %d\n", __LINE__);
399 mwindow->session->mwindow_w = w;
400 mwindow->session->mwindow_h = h;
401 int x = w - MainShBtns::calculate_w(0);
402 mainmenu->resize_event(x, mainmenu->get_h());
403 mainshbtns->reposition_window(x, -1);
404 ffmpeg_toggle->reposition_window(menu_w(), menu_h()+2);
405 mwindow->theme->get_mwindow_sizes(this, w, h);
406 mwindow->theme->draw_mwindow_bg(this);
407 mbuttons->resize_event();
408 statusbar->resize_event();
409 zoombar->resize_event();
411 resource_thread->stop_draw(1);
413 if(total_panes() > 1)
415 if(horizontal_panes())
417 // printf("MWindowGUI::resize_event %d %d %d\n",
419 // pane[TOP_RIGHT_PANE]->x,
420 // mwindow->theme->mcanvas_w -
421 // BC_ScrollBar::get_span(SCROLL_VERT) -
422 // PANE_DRAG_MARGIN);
423 if(pane[TOP_RIGHT_PANE]->x >= mwindow->theme->mcanvas_w -
424 BC_ScrollBar::get_span(SCROLL_VERT) -
427 delete_x_pane(pane[TOP_RIGHT_PANE]->x);
428 mwindow->edl->local_session->x_pane = -1;
434 if(pane[BOTTOM_LEFT_PANE]->y >= mwindow->theme->mzoom_y -
435 BC_ScrollBar::get_span(SCROLL_HORIZ) -
438 delete_y_pane(pane[BOTTOM_LEFT_PANE]->y);
439 mwindow->edl->local_session->y_pane = -1;
444 if(pane[TOP_RIGHT_PANE]->x >= mwindow->theme->mcanvas_w -
445 BC_ScrollBar::get_span(SCROLL_VERT) -
448 delete_x_pane(pane[TOP_RIGHT_PANE]->x);
449 mwindow->edl->local_session->x_pane = -1;
452 if(pane[BOTTOM_LEFT_PANE]->y >= mwindow->theme->mzoom_y -
453 BC_ScrollBar::get_span(SCROLL_HORIZ) -
456 delete_y_pane(pane[BOTTOM_LEFT_PANE]->y);
457 mwindow->edl->local_session->y_pane = -1;
462 if(total_panes() == 1)
464 pane[TOP_LEFT_PANE]->resize_event(
465 mwindow->theme->mcanvas_x,
466 mwindow->theme->mcanvas_y,
467 mwindow->theme->mcanvas_w,
468 mwindow->theme->mcanvas_h);
471 if(horizontal_panes())
473 pane[TOP_LEFT_PANE]->resize_event(
474 pane[TOP_LEFT_PANE]->x,
475 pane[TOP_LEFT_PANE]->y,
476 pane[TOP_LEFT_PANE]->w,
477 mwindow->theme->mcanvas_h);
478 pane[TOP_RIGHT_PANE]->resize_event(
479 pane[TOP_RIGHT_PANE]->x,
480 pane[TOP_RIGHT_PANE]->y,
481 mwindow->theme->mcanvas_w - pane[TOP_RIGHT_PANE]->x,
482 mwindow->theme->mcanvas_h);
487 pane[TOP_LEFT_PANE]->resize_event(
488 pane[TOP_LEFT_PANE]->x,
489 pane[TOP_LEFT_PANE]->y,
490 mwindow->theme->mcanvas_w,
491 pane[TOP_LEFT_PANE]->h);
492 pane[BOTTOM_LEFT_PANE]->resize_event(
493 pane[BOTTOM_LEFT_PANE]->x,
494 pane[BOTTOM_LEFT_PANE]->y,
495 mwindow->theme->mcanvas_w,
496 mwindow->theme->mcanvas_y +
497 mwindow->theme->mcanvas_h -
498 pane[BOTTOM_LEFT_PANE]->y);
502 pane[TOP_LEFT_PANE]->resize_event(
503 pane[TOP_LEFT_PANE]->x,
504 pane[TOP_LEFT_PANE]->y,
505 pane[TOP_LEFT_PANE]->w,
506 pane[TOP_LEFT_PANE]->h);
507 pane[TOP_RIGHT_PANE]->resize_event(
508 pane[TOP_RIGHT_PANE]->x,
509 pane[TOP_RIGHT_PANE]->y,
510 mwindow->theme->mcanvas_w - pane[TOP_RIGHT_PANE]->x,
511 pane[TOP_RIGHT_PANE]->h);
512 pane[BOTTOM_LEFT_PANE]->resize_event(
513 pane[BOTTOM_LEFT_PANE]->x,
514 pane[BOTTOM_LEFT_PANE]->y,
515 pane[BOTTOM_LEFT_PANE]->w,
516 mwindow->theme->mcanvas_y +
517 mwindow->theme->mcanvas_h -
518 pane[BOTTOM_LEFT_PANE]->y);
519 pane[BOTTOM_RIGHT_PANE]->resize_event(
520 pane[BOTTOM_RIGHT_PANE]->x,
521 pane[BOTTOM_RIGHT_PANE]->y,
522 mwindow->theme->mcanvas_w -
523 pane[BOTTOM_RIGHT_PANE]->x,
524 mwindow->theme->mcanvas_y +
525 mwindow->theme->mcanvas_h -
526 pane[BOTTOM_RIGHT_PANE]->y);
529 update_pane_dividers();
530 pane_button->reposition_window(w - mwindow->theme->get_image_set("pane")[0]->get_w(),
531 mwindow->theme->mzoom_y + 1 - mwindow->theme->get_image_set("pane")[0]->get_h());
532 resource_thread->start_draw();
538 int MWindowGUI::total_panes()
541 for(int i = 0; i < TOTAL_PANES; i++)
546 int MWindowGUI::vertical_panes()
548 return total_panes() == 2 &&
549 pane[TOP_LEFT_PANE] &&
550 pane[BOTTOM_LEFT_PANE];
553 int MWindowGUI::horizontal_panes()
555 return total_panes() == 2 &&
556 pane[TOP_LEFT_PANE] &&
557 pane[TOP_RIGHT_PANE];
560 TimelinePane* MWindowGUI::get_focused_pane()
562 if(pane[focused_pane]) return pane[focused_pane];
563 for(int i = 0; i < TOTAL_PANES; i++)
565 if(pane[i]) return pane[i];
570 void MWindowGUI::activate_timeline()
572 if(pane[focused_pane])
574 pane[focused_pane]->activate();
578 for(int i = 0; i < TOTAL_PANES; i++)
589 void MWindowGUI::deactivate_timeline()
591 for(int i = 0; i < TOTAL_PANES; i++)
595 pane[i]->canvas->deactivate();
600 void MWindowGUI::update_title(char *path)
603 char filename[BCTEXTLEN], string[BCTEXTLEN];
604 fs.extract_name(filename, path);
605 sprintf(string, _(PROGRAM_NAME ": %s"), filename);
607 //printf("MWindowGUI::update_title %s\n", string);
611 void MWindowGUI::draw_overlays(int flash_it)
613 for(int i = 0; i < TOTAL_PANES; i++)
617 pane[i]->canvas->draw_overlays();
618 if(flash_it) pane[i]->canvas->flash();
623 void MWindowGUI::update_timebar(int flush_it)
625 for(int i = 0; i < TOTAL_PANES; i++)
627 if(pane[i] && pane[i]->timebar)
629 pane[i]->timebar->update(flush_it);
634 void MWindowGUI::update_timebar_highlights()
636 for(int i = 0; i < TOTAL_PANES; i++)
638 if(pane[i] && pane[i]->timebar)
640 pane[i]->timebar->update_highlights();
646 void MWindowGUI::update_patchbay()
648 for(int i = 0; i < TOTAL_PANES; i++)
650 if(pane[i] && pane[i]->patchbay)
652 pane[i]->patchbay->update();
657 void MWindowGUI::draw_indexes(Indexable *indexable)
659 for(int i = 0; i < TOTAL_PANES; i++)
663 pane[i]->canvas->draw_indexes(indexable);
668 void MWindowGUI::draw_canvas(int mode /* = 0 */, int hide_cursor /* = 1 */)
670 if(mode != IGNORE_THREAD)
672 resource_thread->stop_draw(1);
676 for(int i = 0; i < TOTAL_PANES; i++)
680 pane[i]->canvas->draw(mode, hide_cursor);
685 if(mode != IGNORE_THREAD)
687 resource_thread->start_draw();
692 void MWindowGUI::flash_canvas(int flush)
694 for(int i = 0; i < TOTAL_PANES; i++)
698 pane[i]->canvas->flash(flush);
703 void MWindowGUI::draw_cursor(int do_plugintoggles)
705 for(int i = 0; i < TOTAL_PANES; i++)
709 pane[i]->cursor->draw(do_plugintoggles);
714 void MWindowGUI::show_cursor(int do_plugintoggles)
716 for(int i = 0; i < TOTAL_PANES; i++)
720 pane[i]->cursor->show(do_plugintoggles);
725 void MWindowGUI::hide_cursor(int do_plugintoggles)
727 for(int i = 0; i < TOTAL_PANES; i++)
731 pane[i]->cursor->hide(do_plugintoggles);
736 void MWindowGUI::update_cursor()
738 for(int i = 0; i < TOTAL_PANES; i++)
742 pane[i]->cursor->update();
747 void MWindowGUI::set_playing_back(int value)
749 for(int i = 0; i < TOTAL_PANES; i++)
753 pane[i]->cursor->playing_back = value;
758 void MWindowGUI::update_plugintoggles()
760 for(int i = 0; i < TOTAL_PANES; i++)
764 pane[i]->canvas->refresh_plugintoggles();
770 void MWindowGUI::update_scrollbars(int flush)
772 for(int i = 0; i < TOTAL_PANES; i++)
776 pane[i]->update(1, 0, 0, 0);
779 if(flush) this->flush();
782 void MWindowGUI::reset_meters()
784 for(int i = 0; i < TOTAL_PANES; i++)
786 if(pane[i] && pane[i]->patchbay)
788 pane[i]->patchbay->reset_meters();
793 void MWindowGUI::stop_meters()
795 for(int i = 0; i < TOTAL_PANES; i++)
797 if(pane[i] && pane[i]->patchbay)
799 pane[i]->patchbay->stop_meters();
804 void MWindowGUI::update_meters(ArrayList<double> *module_levels)
806 for(int i = 0; i < TOTAL_PANES; i++)
808 if(pane[i] && pane[i]->patchbay)
810 pane[i]->patchbay->update_meters(module_levels);
815 void MWindowGUI::set_editing_mode(int flush)
817 for(int i = 0; i < TOTAL_PANES; i++)
821 pane[i]->canvas->update_cursor(flush);
826 void MWindowGUI::set_meter_format(int mode, int min, int max)
828 for(int i = 0; i < TOTAL_PANES; i++)
830 if(pane[i] && pane[i]->patchbay)
832 pane[i]->patchbay->set_meter_format(mode, min, max);
837 void MWindowGUI::update(int scrollbars,
846 if(debug) PRINT_TRACE
850 mwindow->edl->tracks->update_y_pixels(mwindow->theme);
852 if(do_canvas && do_canvas != IGNORE_THREAD)
854 resource_thread->stop_draw(1);
857 for(int i = 0; i < TOTAL_PANES; i++)
859 if(pane[i]) pane[i]->update(scrollbars,
865 if(do_canvas && do_canvas != IGNORE_THREAD)
867 resource_thread->start_draw();
870 // if(scrollbars) this->get_scrollbars(0);
871 // if(timebar) this->timebar->update(0);
872 if(zoombar) this->zoombar->update();
873 // if(patchbay) this->patchbay->update();
874 if(clock) this->mainclock->update(
875 mwindow->edl->local_session->get_selectionstart(1));
876 if(debug) PRINT_TRACE
882 // this->canvas->draw(do_canvas);
883 // this->cursor->show();
884 // this->canvas->flash(0);
885 // Activate causes the menubar to deactivate. Don't want this for
887 // if(canvas != IGNORE_THREAD) this->canvas->activate();
889 if(debug) PRINT_TRACE
893 if(buttonbar) mbuttons->update();
894 if(debug) PRINT_TRACE
896 // Can't age if the cache called this to draw missing picons
897 // or the GUI is updating the status of the draw toggle.
898 if(do_canvas != FORCE_REDRAW && do_canvas != IGNORE_THREAD)
901 mwindow->age_caches();
902 lock_window("MWindowGUI::update");
906 if(debug) PRINT_TRACE
909 int MWindowGUI::visible(int64_t x1, int64_t x2, int64_t view_x1, int64_t view_x2)
911 return (x1 >= view_x1 && x1 < view_x2) ||
912 (x2 > view_x1 && x2 <= view_x2) ||
913 (x1 <= view_x1 && x2 >= view_x2);
917 void MWindowGUI::show_message(const char *message, int color)
919 statusbar->show_message(message, color);
922 void MWindowGUI::update_default_message()
924 statusbar->update_default_message();
927 void MWindowGUI::reset_default_message()
929 statusbar->reset_default_message();
932 void MWindowGUI::default_message()
934 statusbar->default_message();
937 // Drag motion called from other window
938 int MWindowGUI::drag_motion()
940 if(get_hidden()) return 0;
942 Track *over_track = 0;
944 PluginSet *over_pluginset = 0;
945 Plugin *over_plugin = 0;
950 drag_popup->cursor_motion_event();
954 // there's no point in drawing highlights has until drag operation has been set
955 if (!mwindow->session->current_operation)
958 for(int i = 0; i < TOTAL_PANES; i++)
960 if(pane[i]) pane[i]->canvas->drag_motion(
967 if(mwindow->session->track_highlighted != over_track)
969 mwindow->session->track_highlighted = over_track;
973 if(mwindow->session->edit_highlighted != over_edit)
975 mwindow->session->edit_highlighted = over_edit;
979 if(mwindow->session->pluginset_highlighted != over_pluginset)
981 mwindow->session->pluginset_highlighted = over_pluginset;
985 if(mwindow->session->plugin_highlighted != over_plugin)
987 mwindow->session->plugin_highlighted = over_plugin;
991 if( mwindow->session->current_operation == DRAG_ASSET ||
992 mwindow->session->current_operation == DRAG_EDIT ||
993 mwindow->session->current_operation == DRAG_AEFFECT_COPY ||
994 mwindow->session->current_operation == DRAG_VEFFECT_COPY )
1000 // printf("drag_motion %d %d over_track=%p over_edit=%p\n",
1007 lock_window("MWindowGUI::drag_motion");
1014 int MWindowGUI::drag_stop()
1016 if(get_hidden()) return 0;
1017 int result = 0, redraw = 0;
1019 for(int i = 0; i < TOTAL_PANES; i++)
1021 if(pane[i]) result |= pane[i]->canvas->drag_stop(
1024 mwindow->edl->optimize();
1026 // since we don't have subwindows we have to terminate any drag operation
1029 if (mwindow->session->track_highlighted
1030 || mwindow->session->edit_highlighted
1031 || mwindow->session->plugin_highlighted
1032 || mwindow->session->pluginset_highlighted)
1034 mwindow->session->track_highlighted = 0;
1035 mwindow->session->edit_highlighted = 0;
1036 mwindow->session->plugin_highlighted = 0;
1037 mwindow->session->pluginset_highlighted = 0;
1038 mwindow->session->current_operation = NO_OPERATION;
1042 //printf("TrackCanvas::drag_stop %d %d\n", redraw, mwindow->session->current_operation);
1045 mwindow->edl->tracks->update_y_pixels(mwindow->theme);
1046 update_scrollbars(0);
1061 void MWindowGUI::default_positions()
1063 //printf("MWindowGUI::default_positions 1\n");
1064 VWindow *vwindow = mwindow->vwindows.size() > DEFAULT_VWINDOW ?
1065 mwindow->vwindows.get(DEFAULT_VWINDOW) : 0;
1066 if( vwindow && !vwindow->is_running() ) vwindow = 0;
1067 if( vwindow ) vwindow->gui->lock_window("MWindowGUI::default_positions");
1068 mwindow->cwindow->gui->lock_window("MWindowGUI::default_positions");
1069 mwindow->awindow->gui->lock_window("MWindowGUI::default_positions");
1071 // printf("MWindowGUI::default_positions 1 %d %d %d %d\n", mwindow->session->vwindow_x,
1072 // mwindow->session->vwindow_y,
1073 // mwindow->session->vwindow_w,
1074 // mwindow->session->vwindow_h);
1075 reposition_window(mwindow->session->mwindow_x,
1076 mwindow->session->mwindow_y,
1077 mwindow->session->mwindow_w,
1078 mwindow->session->mwindow_h);
1079 if( vwindow ) vwindow->gui->reposition_window(mwindow->session->vwindow_x,
1080 mwindow->session->vwindow_y,
1081 mwindow->session->vwindow_w,
1082 mwindow->session->vwindow_h);
1083 mwindow->cwindow->gui->reposition_window(mwindow->session->cwindow_x,
1084 mwindow->session->cwindow_y,
1085 mwindow->session->cwindow_w,
1086 mwindow->session->cwindow_h);
1087 mwindow->awindow->gui->reposition_window(mwindow->session->awindow_x,
1088 mwindow->session->awindow_y,
1089 mwindow->session->awindow_w,
1090 mwindow->session->awindow_h);
1091 //printf("MWindowGUI::default_positions 1\n");
1093 resize_event(mwindow->session->mwindow_w,
1094 mwindow->session->mwindow_h);
1095 //printf("MWindowGUI::default_positions 1\n");
1096 if( vwindow ) vwindow->gui->resize_event(mwindow->session->vwindow_w,
1097 mwindow->session->vwindow_h);
1098 //printf("MWindowGUI::default_positions 1\n");
1099 mwindow->cwindow->gui->resize_event(mwindow->session->cwindow_w,
1100 mwindow->session->cwindow_h);
1101 //printf("MWindowGUI::default_positions 1\n");
1102 mwindow->awindow->gui->resize_event(mwindow->session->awindow_w,
1103 mwindow->session->awindow_h);
1105 //printf("MWindowGUI::default_positions 1\n");
1108 if( vwindow ) vwindow->gui->flush();
1109 mwindow->cwindow->gui->flush();
1110 mwindow->awindow->gui->flush();
1112 if( vwindow ) vwindow->gui->unlock_window();
1113 mwindow->cwindow->gui->unlock_window();
1114 mwindow->awindow->gui->unlock_window();
1115 //printf("MWindowGUI::default_positions 2\n");
1119 int MWindowGUI::button_release_event()
1121 if( keyvalue_popup ) {
1122 delete keyvalue_popup; keyvalue_popup = 0;
1128 int MWindowGUI::repeat_event(int64_t duration)
1130 // if(duration == 100)
1131 // mwindow->sync_parameters(CHANGE_ALL);
1133 for(int i = 0; i < TOTAL_PANES; i++)
1135 if(pane[i]) result = pane[i]->cursor->repeat_event(duration);
1141 int MWindowGUI::translation_event()
1143 //printf("MWindowGUI::translation_event 1 %d %d\n", get_x(), get_y());
1144 mwindow->session->mwindow_x = get_x();
1145 mwindow->session->mwindow_y = get_y();
1150 int MWindowGUI::save_defaults(BC_Hash *defaults)
1152 defaults->update("MWINDOWWIDTH", get_w());
1153 defaults->update("MWINDOWHEIGHT", get_h());
1154 mainmenu->save_defaults(defaults);
1155 BC_WindowBase::save_defaults(defaults);
1159 int MWindowGUI::keypress_event()
1161 //printf("MWindowGUI::keypress_event 1 %d\n", get_keypress());
1162 int result = mbuttons->keypress_event();
1163 if( result ) return result;
1165 switch(get_keypress()) {
1167 mwindow->toggle_editing_mode();
1172 if( alt_down() ) break;
1173 stop_transport("MWindowGUI::keypress_event 1");
1174 mwindow->nearest_plugin_keyframe(shift_down(),
1175 !ctrl_down() ? PLAY_FORWARD : PLAY_REVERSE);
1179 case '1': case '2': case '3': case '4':
1180 case '5': case '6': case '7': case '8':
1181 if( !alt_down() || shift_down() ) break;
1182 if( !mwindow->select_asset(get_keypress()-'1',1) )
1187 if( !ctrl_down() ) {
1189 stop_transport("MWindowGUI::keypress_event 1");
1190 mwindow->prev_edit_handle(shift_down());
1193 mwindow->move_left();
1199 if( !ctrl_down() && !alt_down() ) {
1200 mwindow->move_left();
1206 if( !ctrl_down() ) {
1208 stop_transport("MWindowGUI::keypress_event 2");
1209 mwindow->next_edit_handle(shift_down());
1212 mwindow->move_right();
1218 if( !ctrl_down() && !alt_down() ) {
1219 mwindow->move_right();
1225 if( ctrl_down() && !alt_down() )
1226 mwindow->expand_y();
1227 else if( !ctrl_down() && alt_down() )
1228 mwindow->expand_autos(0,1,1);
1229 else if( ctrl_down() && alt_down() )
1230 mwindow->expand_autos(1,1,1);
1232 mwindow->expand_sample();
1237 if( ctrl_down() && !alt_down() )
1238 mwindow->zoom_in_y();
1239 else if( !ctrl_down() && alt_down() )
1240 mwindow->shrink_autos(0,1,1);
1241 else if( ctrl_down() && alt_down() )
1242 mwindow->shrink_autos(1,1,1);
1244 mwindow->zoom_in_sample();
1252 mwindow->expand_t();
1258 mwindow->move_down();
1260 mwindow->zoom_in_t();
1266 Track *this_track = 0;
1267 for( int i=0; i<TOTAL_PANES; ++i ) {
1268 if( !pane[i] ) continue;
1269 if( (this_track = pane[i]->over_track()) != 0 ) break;
1270 if( (this_track = pane[i]->over_patchbay()) != 0 ) break;
1273 if( get_keypress() == TAB ) { // Switch the record button
1275 this_track->record = !this_track->record ? 1 : 0;
1278 int total_selected = mwindow->edl->tracks->total_of(Tracks::RECORD);
1279 // all selected if nothing previously selected or
1280 // if this patch was previously the only one selected and armed
1281 int selected = !total_selected || (total_selected == 1 &&
1282 this_track && this_track->record ) ? 1 : 0;
1283 mwindow->edl->tracks->select_all(Tracks::RECORD, selected);
1284 if( !selected && this_track ) this_track->record = 1;
1287 update(0, 1, 0, 0, 1, 0, 1);
1289 mwindow->cwindow->update(0, 1, 1);
1290 lock_window("TrackCanvas::keypress_event 3");
1296 // since things under cursor have changed...
1298 cursor_motion_event();
1303 int MWindowGUI::keyboard_listener(BC_WindowBase *wp)
1305 return key_listener(wp->get_keypress());
1308 int MWindowGUI::key_listener(int key)
1313 if( !record->running() )
1316 record->record_gui->interrupt_thread->start(0);
1323 channel_info->toggle_scan();
1327 if( !remote_control->deactivate() )
1328 remote_control->activate();
1338 void MWindowGUI::use_android_remote(int on)
1341 delete android_control;
1342 android_control = 0;
1345 if( android_control ) return;
1346 android_control = new AndroidControl(this);
1349 int MWindowGUI::close_event()
1355 void MWindowGUI::stop_drawing()
1357 resource_thread->stop_draw(1);
1360 int MWindowGUI::menu_w()
1362 return mainmenu->get_w();
1365 int MWindowGUI::menu_h()
1367 return mainmenu->get_h();
1370 void MWindowGUI::start_x_pane_drag()
1374 x_pane_drag = new BC_Popup(this,
1375 get_abs_cursor_x(0) - mwindow->theme->pane_w,
1376 BC_DisplayInfo::get_top_border() +
1378 mwindow->theme->mcanvas_y,
1379 mwindow->theme->pane_w,
1380 mwindow->theme->mcanvas_h,
1381 mwindow->theme->drag_pane_color);
1382 x_pane_drag->draw_3segmentv(0,
1384 x_pane_drag->get_h(),
1385 mwindow->theme->get_image_set("xpane")[BUTTON_DOWNHI]);
1386 x_pane_drag->flash(1);
1391 void MWindowGUI::start_y_pane_drag()
1395 //printf("MWindowGUI::start_y_pane_drag %d %d %d\n", __LINE__, get_x(), get_y());
1396 y_pane_drag = new BC_Popup(this,
1397 BC_DisplayInfo::get_left_border() +
1399 mwindow->theme->mcanvas_x,
1400 get_abs_cursor_y(0) - mwindow->theme->pane_h,
1401 mwindow->theme->mcanvas_w,
1402 mwindow->theme->pane_h,
1403 mwindow->theme->drag_pane_color);
1404 y_pane_drag->draw_3segmenth(0,
1406 y_pane_drag->get_w(),
1407 mwindow->theme->get_image_set("ypane")[BUTTON_DOWNHI]);
1408 y_pane_drag->flash(1);
1413 void MWindowGUI::handle_pane_drag()
1419 x_pane_drag->reposition_window(
1420 get_abs_cursor_x(0) - mwindow->theme->pane_w,
1421 x_pane_drag->get_y());
1426 y_pane_drag->reposition_window(
1427 y_pane_drag->get_x(),
1428 get_abs_cursor_y(0) - mwindow->theme->pane_h);
1434 void MWindowGUI::create_x_pane(int cursor_x)
1436 if(total_panes() == 1)
1438 // create a horizontal pane
1439 // do this 1st so the resize_event knows there are 2 panes
1440 mwindow->edl->local_session->view_start[TOP_RIGHT_PANE] =
1441 mwindow->edl->local_session->view_start[TOP_LEFT_PANE] +
1443 mwindow->theme->patchbay_w;
1444 pane[TOP_RIGHT_PANE] = new TimelinePane(mwindow,
1446 mwindow->theme->mcanvas_x +
1448 mwindow->theme->mcanvas_y,
1449 mwindow->theme->mcanvas_x +
1450 mwindow->theme->mcanvas_w -
1452 mwindow->theme->mcanvas_h);
1453 pane[TOP_LEFT_PANE]->resize_event(
1454 mwindow->theme->mcanvas_x,
1455 mwindow->theme->mcanvas_y,
1456 cursor_x - mwindow->theme->pane_w,
1457 mwindow->theme->mcanvas_h);
1458 pane[TOP_RIGHT_PANE]->create_objects();
1461 if(vertical_panes())
1463 // create 2 horizontal panes
1464 mwindow->edl->local_session->track_start[TOP_RIGHT_PANE] =
1465 mwindow->edl->local_session->track_start[TOP_LEFT_PANE];
1466 mwindow->edl->local_session->track_start[BOTTOM_RIGHT_PANE] =
1467 mwindow->edl->local_session->track_start[BOTTOM_LEFT_PANE];
1468 mwindow->edl->local_session->view_start[TOP_RIGHT_PANE] =
1469 mwindow->edl->local_session->view_start[BOTTOM_RIGHT_PANE] =
1470 mwindow->edl->local_session->view_start[TOP_LEFT_PANE] +
1472 mwindow->theme->patchbay_w;
1473 pane[TOP_RIGHT_PANE] = new TimelinePane(mwindow,
1475 mwindow->theme->mcanvas_x +
1477 pane[TOP_LEFT_PANE]->y,
1478 mwindow->theme->mcanvas_x +
1479 mwindow->theme->mcanvas_w -
1481 pane[TOP_LEFT_PANE]->h);
1482 pane[BOTTOM_RIGHT_PANE] = new TimelinePane(mwindow,
1484 mwindow->theme->mcanvas_x +
1486 pane[BOTTOM_LEFT_PANE]->y,
1487 mwindow->theme->mcanvas_x +
1488 mwindow->theme->mcanvas_w -
1490 pane[BOTTOM_LEFT_PANE]->h);
1491 pane[TOP_LEFT_PANE]->resize_event(
1492 pane[TOP_LEFT_PANE]->x,
1493 pane[TOP_LEFT_PANE]->y,
1494 cursor_x - mwindow->theme->pane_w,
1495 pane[TOP_LEFT_PANE]->h);
1496 pane[BOTTOM_LEFT_PANE]->resize_event(
1497 pane[BOTTOM_LEFT_PANE]->x,
1498 pane[BOTTOM_LEFT_PANE]->y,
1499 cursor_x - mwindow->theme->pane_w,
1500 pane[BOTTOM_LEFT_PANE]->h);
1501 pane[TOP_RIGHT_PANE]->create_objects();
1502 pane[BOTTOM_RIGHT_PANE]->create_objects();
1505 if(horizontal_panes())
1507 // resize a horizontal pane
1508 mwindow->edl->local_session->view_start[TOP_RIGHT_PANE] +=
1510 pane[TOP_RIGHT_PANE]->x;
1511 if(mwindow->edl->local_session->view_start[TOP_RIGHT_PANE] < 0)
1512 mwindow->edl->local_session->view_start[TOP_RIGHT_PANE] = 0;
1513 pane[TOP_LEFT_PANE]->resize_event(
1514 mwindow->theme->mcanvas_x,
1515 mwindow->theme->mcanvas_y,
1516 cursor_x - mwindow->theme->pane_w,
1517 mwindow->theme->mcanvas_h);
1518 pane[TOP_RIGHT_PANE]->resize_event(
1519 mwindow->theme->mcanvas_x +
1521 pane[TOP_RIGHT_PANE]->y,
1522 mwindow->theme->mcanvas_x +
1523 mwindow->theme->mcanvas_w -
1525 mwindow->theme->mcanvas_h);
1529 // resize 2 horizontal panes
1530 mwindow->edl->local_session->view_start[TOP_RIGHT_PANE] +=
1532 pane[TOP_RIGHT_PANE]->x;
1533 if(mwindow->edl->local_session->view_start[TOP_RIGHT_PANE] < 0)
1534 mwindow->edl->local_session->view_start[TOP_RIGHT_PANE] = 0;
1535 mwindow->edl->local_session->view_start[BOTTOM_RIGHT_PANE] =
1536 mwindow->edl->local_session->view_start[TOP_RIGHT_PANE];
1538 pane[TOP_LEFT_PANE]->resize_event(
1539 mwindow->theme->mcanvas_x,
1540 pane[TOP_LEFT_PANE]->y,
1541 cursor_x - mwindow->theme->pane_w,
1542 pane[TOP_LEFT_PANE]->h);
1543 pane[TOP_RIGHT_PANE]->resize_event(
1544 mwindow->theme->mcanvas_x +
1546 pane[TOP_RIGHT_PANE]->y,
1547 mwindow->theme->mcanvas_x +
1548 mwindow->theme->mcanvas_w -
1550 pane[TOP_RIGHT_PANE]->h);
1551 pane[BOTTOM_LEFT_PANE]->resize_event(
1552 mwindow->theme->mcanvas_x,
1553 pane[BOTTOM_LEFT_PANE]->y,
1554 cursor_x - mwindow->theme->pane_w,
1555 pane[BOTTOM_LEFT_PANE]->h);
1556 pane[BOTTOM_RIGHT_PANE]->resize_event(
1557 mwindow->theme->mcanvas_x +
1559 pane[BOTTOM_RIGHT_PANE]->y,
1560 mwindow->theme->mcanvas_x +
1561 mwindow->theme->mcanvas_w -
1563 pane[BOTTOM_RIGHT_PANE]->h);
1569 void MWindowGUI::delete_x_pane(int cursor_x)
1571 // give left panes coordinates of right pane
1572 if(cursor_x < mwindow->theme->patchbay_w + PANE_DRAG_MARGIN &&
1573 pane[TOP_RIGHT_PANE])
1575 mwindow->edl->local_session->view_start[TOP_LEFT_PANE] =
1576 mwindow->edl->local_session->view_start[TOP_RIGHT_PANE] -
1577 pane[TOP_RIGHT_PANE]->x + mwindow->theme->patchbay_w;
1578 if(mwindow->edl->local_session->view_start[TOP_LEFT_PANE] < 0)
1579 mwindow->edl->local_session->view_start[TOP_LEFT_PANE] = 0;
1580 mwindow->edl->local_session->view_start[BOTTOM_LEFT_PANE] =
1581 mwindow->edl->local_session->view_start[TOP_LEFT_PANE];
1584 switch(total_panes())
1587 if(pane[TOP_LEFT_PANE] && pane[TOP_RIGHT_PANE])
1589 // delete right pane
1590 delete pane[TOP_RIGHT_PANE];
1591 pane[TOP_RIGHT_PANE] = 0;
1592 pane[TOP_LEFT_PANE]->resize_event(
1593 mwindow->theme->mcanvas_x,
1594 mwindow->theme->mcanvas_y,
1595 mwindow->theme->mcanvas_w,
1596 mwindow->theme->mcanvas_h);
1602 // delete right panes
1603 delete pane[TOP_RIGHT_PANE];
1604 pane[TOP_RIGHT_PANE] = 0;
1605 delete pane[BOTTOM_RIGHT_PANE];
1606 pane[BOTTOM_RIGHT_PANE] = 0;
1607 pane[TOP_LEFT_PANE]->resize_event(
1608 mwindow->theme->mcanvas_x,
1609 pane[TOP_LEFT_PANE]->y,
1610 mwindow->theme->mcanvas_w,
1611 pane[TOP_LEFT_PANE]->h);
1612 pane[BOTTOM_LEFT_PANE]->resize_event(
1613 mwindow->theme->mcanvas_x,
1614 pane[BOTTOM_LEFT_PANE]->y,
1615 mwindow->theme->mcanvas_w,
1616 pane[BOTTOM_LEFT_PANE]->h);
1621 void MWindowGUI::create_y_pane(int cursor_y)
1623 if(total_panes() == 1)
1625 mwindow->edl->local_session->view_start[BOTTOM_LEFT_PANE] =
1626 mwindow->edl->local_session->view_start[TOP_LEFT_PANE];
1627 mwindow->edl->local_session->track_start[BOTTOM_LEFT_PANE] =
1628 mwindow->edl->local_session->track_start[TOP_LEFT_PANE] +
1630 mwindow->theme->mtimebar_h;
1631 // do this 1st so the resize_event knows there are 2 panes
1632 pane[BOTTOM_LEFT_PANE] = new TimelinePane(mwindow,
1634 mwindow->theme->mcanvas_x,
1635 mwindow->theme->mcanvas_y +
1637 mwindow->theme->mcanvas_w,
1638 mwindow->theme->mcanvas_h -
1640 pane[TOP_LEFT_PANE]->resize_event(
1641 mwindow->theme->mcanvas_x,
1642 mwindow->theme->mcanvas_y,
1643 mwindow->theme->mcanvas_w,
1644 pane[BOTTOM_LEFT_PANE]->y -
1645 mwindow->theme->mcanvas_y -
1646 mwindow->theme->pane_h);
1647 pane[BOTTOM_LEFT_PANE]->create_objects();
1650 if(horizontal_panes())
1653 mwindow->edl->local_session->view_start[BOTTOM_LEFT_PANE] =
1654 mwindow->edl->local_session->view_start[TOP_LEFT_PANE];
1655 mwindow->edl->local_session->view_start[BOTTOM_RIGHT_PANE] =
1656 mwindow->edl->local_session->view_start[TOP_RIGHT_PANE];
1657 mwindow->edl->local_session->track_start[BOTTOM_LEFT_PANE] =
1658 mwindow->edl->local_session->track_start[BOTTOM_RIGHT_PANE] =
1659 mwindow->edl->local_session->track_start[TOP_LEFT_PANE] +
1661 mwindow->theme->mtimebar_h;
1663 pane[BOTTOM_LEFT_PANE] = new TimelinePane(mwindow,
1665 pane[TOP_LEFT_PANE]->x,
1666 mwindow->theme->mcanvas_y +
1668 pane[TOP_LEFT_PANE]->w,
1669 mwindow->theme->mcanvas_h -
1671 pane[BOTTOM_RIGHT_PANE] = new TimelinePane(mwindow,
1673 pane[TOP_RIGHT_PANE]->x,
1674 mwindow->theme->mcanvas_y +
1676 pane[TOP_RIGHT_PANE]->w,
1677 mwindow->theme->mcanvas_h -
1680 pane[TOP_LEFT_PANE]->resize_event(
1681 pane[TOP_LEFT_PANE]->x,
1682 pane[TOP_LEFT_PANE]->y,
1683 pane[TOP_LEFT_PANE]->w,
1684 pane[BOTTOM_LEFT_PANE]->y -
1685 mwindow->theme->mcanvas_y -
1686 mwindow->theme->pane_h);
1687 pane[TOP_RIGHT_PANE]->resize_event(
1688 pane[TOP_RIGHT_PANE]->x,
1689 pane[TOP_RIGHT_PANE]->y,
1690 pane[TOP_RIGHT_PANE]->w,
1691 pane[BOTTOM_RIGHT_PANE]->y -
1692 mwindow->theme->mcanvas_y -
1693 mwindow->theme->pane_h);
1695 pane[BOTTOM_LEFT_PANE]->create_objects();
1696 pane[BOTTOM_RIGHT_PANE]->create_objects();
1699 if(vertical_panes())
1702 mwindow->edl->local_session->track_start[BOTTOM_LEFT_PANE] +=
1704 (pane[BOTTOM_LEFT_PANE]->y - mwindow->theme->mcanvas_y);
1705 if(mwindow->edl->local_session->track_start[BOTTOM_LEFT_PANE] < 0)
1706 mwindow->edl->local_session->track_start[BOTTOM_LEFT_PANE] = 0;
1707 pane[TOP_LEFT_PANE]->resize_event(
1708 mwindow->theme->mcanvas_x,
1709 mwindow->theme->mcanvas_y,
1710 mwindow->theme->mcanvas_w,
1711 cursor_y - mwindow->theme->pane_h);
1712 pane[BOTTOM_LEFT_PANE]->resize_event(
1713 pane[BOTTOM_LEFT_PANE]->x,
1715 mwindow->theme->mcanvas_y,
1716 mwindow->theme->mcanvas_w,
1717 mwindow->theme->mcanvas_h -
1723 mwindow->edl->local_session->track_start[BOTTOM_LEFT_PANE] +=
1725 (pane[BOTTOM_LEFT_PANE]->y - mwindow->theme->mcanvas_y);
1726 if(mwindow->edl->local_session->track_start[BOTTOM_LEFT_PANE] < 0)
1727 mwindow->edl->local_session->track_start[BOTTOM_LEFT_PANE] = 0;
1728 mwindow->edl->local_session->track_start[BOTTOM_RIGHT_PANE] =
1729 mwindow->edl->local_session->track_start[BOTTOM_LEFT_PANE];
1730 pane[TOP_LEFT_PANE]->resize_event(
1731 pane[TOP_LEFT_PANE]->x,
1732 pane[TOP_LEFT_PANE]->y,
1733 pane[TOP_LEFT_PANE]->w,
1734 cursor_y - mwindow->theme->pane_h);
1735 pane[BOTTOM_LEFT_PANE]->resize_event(
1736 pane[BOTTOM_LEFT_PANE]->x,
1738 mwindow->theme->mcanvas_y,
1739 pane[BOTTOM_LEFT_PANE]->w,
1740 mwindow->theme->mcanvas_h -
1742 pane[TOP_RIGHT_PANE]->resize_event(
1743 pane[TOP_RIGHT_PANE]->x,
1744 pane[TOP_RIGHT_PANE]->y,
1745 pane[TOP_RIGHT_PANE]->w,
1746 cursor_y - mwindow->theme->pane_h);
1747 pane[BOTTOM_RIGHT_PANE]->resize_event(
1748 pane[BOTTOM_RIGHT_PANE]->x,
1750 mwindow->theme->mcanvas_y,
1751 pane[BOTTOM_RIGHT_PANE]->w,
1752 mwindow->theme->mcanvas_h -
1757 void MWindowGUI::delete_y_pane(int cursor_y)
1759 if(cursor_y < mwindow->theme->mtimebar_h +
1761 pane[BOTTOM_LEFT_PANE])
1763 // give top pane coordinates of bottom pane
1764 mwindow->edl->local_session->track_start[TOP_LEFT_PANE] =
1765 mwindow->edl->local_session->track_start[BOTTOM_LEFT_PANE] -
1766 pane[BOTTOM_LEFT_PANE]->y;
1767 if(mwindow->edl->local_session->track_start[TOP_LEFT_PANE] < 0)
1768 mwindow->edl->local_session->track_start[TOP_LEFT_PANE] = 0;
1769 mwindow->edl->local_session->track_start[TOP_RIGHT_PANE] =
1770 mwindow->edl->local_session->track_start[TOP_LEFT_PANE];
1774 switch(total_panes())
1777 delete pane[BOTTOM_LEFT_PANE];
1778 pane[BOTTOM_LEFT_PANE] = 0;
1779 pane[TOP_LEFT_PANE]->resize_event(
1780 mwindow->theme->mcanvas_x,
1781 mwindow->theme->mcanvas_y,
1782 mwindow->theme->mcanvas_w,
1783 mwindow->theme->mcanvas_h);
1787 // delete bottom 2 panes
1789 delete pane[BOTTOM_LEFT_PANE];
1790 pane[BOTTOM_LEFT_PANE] = 0;
1791 delete pane[BOTTOM_RIGHT_PANE];
1792 pane[BOTTOM_RIGHT_PANE] = 0;
1793 pane[TOP_LEFT_PANE]->resize_event(
1794 pane[TOP_LEFT_PANE]->x,
1795 mwindow->theme->mcanvas_y,
1796 pane[TOP_LEFT_PANE]->w,
1797 mwindow->theme->mcanvas_h);
1798 pane[TOP_RIGHT_PANE]->resize_event(
1799 pane[TOP_RIGHT_PANE]->x,
1800 mwindow->theme->mcanvas_y,
1801 pane[TOP_RIGHT_PANE]->w,
1802 mwindow->theme->mcanvas_h);
1807 void MWindowGUI::stop_pane_drag()
1810 resource_thread->stop_draw(1);
1814 // cursor position relative to canvas
1815 int cursor_x = x_pane_drag->get_x() -
1817 BC_DisplayInfo::get_left_border() -
1818 mwindow->theme->mcanvas_x +
1819 mwindow->theme->pane_w;
1824 if(cursor_x >= mwindow->theme->patchbay_w + PANE_DRAG_MARGIN &&
1825 cursor_x < mwindow->theme->mcanvas_w -
1826 BC_ScrollBar::get_span(SCROLL_VERT) -
1829 create_x_pane(cursor_x);
1830 mwindow->edl->local_session->x_pane = cursor_x;
1835 delete_x_pane(cursor_x);
1836 mwindow->edl->local_session->x_pane = -1;
1844 // cursor position relative to canvas
1845 int cursor_y = y_pane_drag->get_y() -
1847 BC_DisplayInfo::get_top_border() -
1848 mwindow->theme->mcanvas_y +
1849 mwindow->theme->pane_h;
1855 if(cursor_y >= mwindow->theme->mtimebar_h +
1857 cursor_y < mwindow->theme->mcanvas_h -
1858 BC_ScrollBar::get_span(SCROLL_HORIZ) -
1861 create_y_pane(cursor_y);
1862 mwindow->edl->local_session->y_pane = cursor_y;
1866 delete_y_pane(cursor_y);
1867 mwindow->edl->local_session->y_pane = -1;
1871 update_pane_dividers();
1873 // required to get new widgets to appear
1875 resource_thread->start_draw();
1878 // create panes from EDL
1879 void MWindowGUI::load_panes()
1881 int need_x_panes = 0;
1882 int need_y_panes = 0;
1883 // use names from create functions
1884 int cursor_x = mwindow->edl->local_session->x_pane;
1885 int cursor_y = mwindow->edl->local_session->y_pane;
1887 resource_thread->stop_draw(1);
1889 mwindow->theme->patchbay_w + PANE_DRAG_MARGIN &&
1891 mwindow->theme->mcanvas_w -
1892 BC_ScrollBar::get_span(SCROLL_VERT) -
1899 mwindow->theme->mtimebar_h + PANE_DRAG_MARGIN &&
1901 mwindow->theme->mcanvas_h -
1902 BC_ScrollBar::get_span(SCROLL_HORIZ) -
1908 //printf("MWindowGUI::load_panes %d %d %d\n", __LINE__, need_x_panes, need_y_panes);
1916 if(total_panes() == 1)
1919 //printf("MWindowGUI::load_panes %d\n", __LINE__);
1920 pane[TOP_RIGHT_PANE] = new TimelinePane(mwindow,
1922 mwindow->theme->mcanvas_x +
1924 mwindow->theme->mcanvas_y,
1925 mwindow->theme->mcanvas_x +
1926 mwindow->theme->mcanvas_w -
1928 cursor_y - mwindow->theme->pane_h);
1929 pane[BOTTOM_LEFT_PANE] = new TimelinePane(mwindow,
1931 mwindow->theme->mcanvas_x,
1932 mwindow->theme->mcanvas_y +
1934 cursor_x - mwindow->theme->pane_w,
1935 mwindow->theme->mcanvas_h -
1937 pane[BOTTOM_RIGHT_PANE] = new TimelinePane(mwindow,
1939 pane[TOP_RIGHT_PANE]->x,
1940 mwindow->theme->mcanvas_y +
1942 pane[TOP_RIGHT_PANE]->w,
1943 mwindow->theme->mcanvas_h -
1945 pane[TOP_LEFT_PANE]->resize_event(
1946 pane[TOP_LEFT_PANE]->x,
1947 pane[TOP_LEFT_PANE]->y,
1948 cursor_x - mwindow->theme->pane_w,
1949 cursor_y - mwindow->theme->pane_h);
1950 pane[TOP_RIGHT_PANE]->create_objects();
1951 pane[BOTTOM_LEFT_PANE]->create_objects();
1952 pane[BOTTOM_RIGHT_PANE]->create_objects();
1955 if(horizontal_panes())
1957 // create vertical panes
1958 //printf("MWindowGUI::load_panes %d\n", __LINE__);
1959 pane[BOTTOM_LEFT_PANE] = new TimelinePane(mwindow,
1961 mwindow->theme->mcanvas_x,
1962 mwindow->theme->mcanvas_y +
1964 cursor_x - mwindow->theme->pane_w,
1965 mwindow->theme->mcanvas_h -
1967 pane[BOTTOM_RIGHT_PANE] = new TimelinePane(mwindow,
1969 pane[TOP_RIGHT_PANE]->x,
1970 mwindow->theme->mcanvas_y +
1972 pane[TOP_RIGHT_PANE]->w,
1973 mwindow->theme->mcanvas_h -
1975 pane[TOP_LEFT_PANE]->resize_event(
1976 pane[TOP_LEFT_PANE]->x,
1977 pane[TOP_LEFT_PANE]->y,
1978 cursor_x - mwindow->theme->pane_w,
1979 cursor_y - mwindow->theme->pane_h);
1980 pane[TOP_RIGHT_PANE]->resize_event(
1981 mwindow->theme->mcanvas_x +
1983 mwindow->theme->mcanvas_y,
1984 mwindow->theme->mcanvas_x +
1985 mwindow->theme->mcanvas_w -
1987 cursor_y - mwindow->theme->pane_h);
1988 pane[BOTTOM_LEFT_PANE]->create_objects();
1989 pane[BOTTOM_RIGHT_PANE]->create_objects();
1992 if(vertical_panes())
1994 // create horizontal panes
1995 //printf("MWindowGUI::load_panes %d\n", __LINE__);
1996 pane[TOP_RIGHT_PANE] = new TimelinePane(mwindow,
1998 mwindow->theme->mcanvas_x +
2000 mwindow->theme->mcanvas_y,
2001 mwindow->theme->mcanvas_x +
2002 mwindow->theme->mcanvas_w -
2004 cursor_y - mwindow->theme->pane_h);
2005 pane[BOTTOM_RIGHT_PANE] = new TimelinePane(mwindow,
2007 pane[TOP_RIGHT_PANE]->x,
2008 mwindow->theme->mcanvas_y +
2010 pane[TOP_RIGHT_PANE]->w,
2011 mwindow->theme->mcanvas_h -
2013 pane[TOP_LEFT_PANE]->resize_event(
2014 pane[TOP_LEFT_PANE]->x,
2015 pane[TOP_LEFT_PANE]->y,
2016 cursor_x - mwindow->theme->pane_w,
2017 cursor_y - mwindow->theme->pane_h);
2018 pane[BOTTOM_LEFT_PANE]->resize_event(
2019 pane[TOP_LEFT_PANE]->x,
2020 mwindow->theme->mcanvas_y +
2022 mwindow->theme->mcanvas_x +
2023 mwindow->theme->mcanvas_w -
2024 cursor_x - mwindow->theme->pane_w,
2025 mwindow->theme->mcanvas_h -
2027 pane[TOP_RIGHT_PANE]->create_objects();
2028 pane[BOTTOM_RIGHT_PANE]->create_objects();
2035 //printf("MWindowGUI::load_panes %d\n", __LINE__);
2036 pane[TOP_LEFT_PANE]->resize_event(
2037 pane[TOP_LEFT_PANE]->x,
2038 pane[TOP_LEFT_PANE]->y,
2039 cursor_x - mwindow->theme->pane_w,
2040 cursor_y - mwindow->theme->pane_h);
2041 pane[TOP_RIGHT_PANE]->resize_event(
2042 mwindow->theme->mcanvas_x +
2044 mwindow->theme->mcanvas_y,
2045 mwindow->theme->mcanvas_x +
2046 mwindow->theme->mcanvas_w -
2048 cursor_y - mwindow->theme->pane_h);
2049 pane[BOTTOM_LEFT_PANE]->resize_event(
2050 pane[TOP_LEFT_PANE]->x,
2051 mwindow->theme->mcanvas_y +
2053 mwindow->theme->mcanvas_x +
2054 mwindow->theme->mcanvas_w -
2055 cursor_x - mwindow->theme->pane_w,
2056 mwindow->theme->mcanvas_h -
2058 pane[BOTTOM_RIGHT_PANE]->resize_event(
2059 pane[TOP_RIGHT_PANE]->x,
2060 mwindow->theme->mcanvas_y +
2062 pane[TOP_RIGHT_PANE]->w,
2063 mwindow->theme->mcanvas_h -
2072 if(pane[BOTTOM_LEFT_PANE]) delete pane[BOTTOM_LEFT_PANE];
2073 if(pane[BOTTOM_RIGHT_PANE]) delete pane[BOTTOM_RIGHT_PANE];
2074 pane[BOTTOM_LEFT_PANE] = 0;
2075 pane[BOTTOM_RIGHT_PANE] = 0;
2077 if(!pane[TOP_RIGHT_PANE])
2079 pane[TOP_RIGHT_PANE] = new TimelinePane(mwindow,
2081 mwindow->theme->mcanvas_x +
2083 mwindow->theme->mcanvas_y,
2084 mwindow->theme->mcanvas_x +
2085 mwindow->theme->mcanvas_w -
2087 mwindow->theme->mcanvas_h);
2088 pane[TOP_LEFT_PANE]->resize_event(
2089 mwindow->theme->mcanvas_x,
2090 mwindow->theme->mcanvas_y,
2091 cursor_x - mwindow->theme->pane_w,
2092 mwindow->theme->mcanvas_h);
2093 pane[TOP_RIGHT_PANE]->create_objects();
2097 pane[TOP_LEFT_PANE]->resize_event(
2098 mwindow->theme->mcanvas_x,
2099 mwindow->theme->mcanvas_y,
2100 cursor_x - mwindow->theme->pane_w,
2101 mwindow->theme->mcanvas_h);
2102 pane[TOP_RIGHT_PANE]->resize_event(
2103 mwindow->theme->mcanvas_x +
2105 pane[TOP_RIGHT_PANE]->y,
2106 mwindow->theme->mcanvas_x +
2107 mwindow->theme->mcanvas_w -
2109 mwindow->theme->mcanvas_h);
2117 if(pane[TOP_RIGHT_PANE]) delete pane[TOP_RIGHT_PANE];
2118 if(pane[BOTTOM_RIGHT_PANE]) delete pane[BOTTOM_RIGHT_PANE];
2119 pane[TOP_RIGHT_PANE] = 0;
2120 pane[BOTTOM_RIGHT_PANE] = 0;
2122 if(!pane[BOTTOM_LEFT_PANE])
2124 //printf("MWindowGUI::load_panes %d\n", __LINE__);
2125 pane[BOTTOM_LEFT_PANE] = new TimelinePane(mwindow,
2127 mwindow->theme->mcanvas_x,
2128 mwindow->theme->mcanvas_y +
2130 mwindow->theme->mcanvas_w,
2131 mwindow->theme->mcanvas_h -
2133 pane[TOP_LEFT_PANE]->resize_event(
2134 mwindow->theme->mcanvas_x,
2135 mwindow->theme->mcanvas_y,
2136 mwindow->theme->mcanvas_w,
2137 pane[BOTTOM_LEFT_PANE]->y -
2138 mwindow->theme->mcanvas_y -
2139 mwindow->theme->pane_h);
2140 pane[BOTTOM_LEFT_PANE]->create_objects();
2144 pane[TOP_LEFT_PANE]->resize_event(
2145 mwindow->theme->mcanvas_x,
2146 mwindow->theme->mcanvas_y,
2147 mwindow->theme->mcanvas_w,
2148 cursor_y - mwindow->theme->pane_h);
2149 pane[BOTTOM_LEFT_PANE]->resize_event(
2150 pane[BOTTOM_LEFT_PANE]->x,
2152 mwindow->theme->mcanvas_y,
2153 mwindow->theme->mcanvas_w,
2154 mwindow->theme->mcanvas_h -
2161 if(pane[TOP_RIGHT_PANE]) delete pane[TOP_RIGHT_PANE];
2162 if(pane[BOTTOM_RIGHT_PANE]) delete pane[BOTTOM_RIGHT_PANE];
2163 if(pane[BOTTOM_LEFT_PANE]) delete pane[BOTTOM_LEFT_PANE];
2164 pane[TOP_RIGHT_PANE] = 0;
2165 pane[BOTTOM_RIGHT_PANE] = 0;
2166 pane[BOTTOM_LEFT_PANE] = 0;
2167 pane[TOP_LEFT_PANE]->resize_event(
2168 mwindow->theme->mcanvas_x,
2169 mwindow->theme->mcanvas_y,
2170 mwindow->theme->mcanvas_w,
2171 mwindow->theme->mcanvas_h);
2174 update_pane_dividers();
2177 resource_thread->start_draw();
2180 void MWindowGUI::update_pane_dividers()
2183 if(horizontal_panes() || total_panes() == 4)
2185 int x = pane[TOP_RIGHT_PANE]->x - mwindow->theme->pane_w;
2186 int y = mwindow->theme->mcanvas_y;
2187 int h = mwindow->theme->mcanvas_h;
2191 add_subwindow(x_divider = new PaneDivider(
2192 mwindow, x, y, h, 1));
2193 x_divider->create_objects();
2197 x_divider->reposition_window(x, y, h);
2210 if(vertical_panes() || total_panes() == 4)
2212 int x = mwindow->theme->mcanvas_x;
2213 int y = pane[BOTTOM_LEFT_PANE]->y -
2214 mwindow->theme->pane_h;
2215 int w = mwindow->theme->mcanvas_w;
2218 add_subwindow(y_divider = new PaneDivider(
2219 mwindow, x, y, w, 0));
2220 y_divider->create_objects();
2224 y_divider->reposition_window(x, y, w);
2238 void MWindowGUI::draw_samplemovement()
2245 update_scrollbars(1);
2248 void MWindowGUI::draw_trackmovement()
2250 update_scrollbars(0);
2257 void MWindowGUI::update_mixers(Track *track, int v)
2259 for( int i=0; i<TOTAL_PANES; ++i ) {
2260 if( !pane[i] ) continue;
2261 PatchBay *patchbay = pane[i]->patchbay;
2262 if( !patchbay ) continue;
2263 for( int j=0; j<patchbay->patches.total; ++j ) {
2264 PatchGUI *patchgui = patchbay->patches.values[j];
2265 if( !patchgui->mix ) continue;
2266 if( !track || patchgui->track == track ) {
2267 patchgui->mix->update(v>=0 ? v :
2268 mwindow->mixer_track_active(patchgui->track));
2274 void MWindowGUI::stop_transport(const char *lock_msg)
2276 if( !mbuttons->transport->is_stopped() ) {
2277 if( lock_msg ) unlock_window();
2278 mbuttons->transport->handle_transport(STOP, 1, 0, 0);
2279 if( lock_msg ) lock_window(lock_msg);
2283 PaneButton::PaneButton(MWindow *mwindow, int x, int y)
2284 : BC_Button(x, y, mwindow->theme->get_image_set("pane"))
2286 this->mwindow = mwindow;
2289 int PaneButton::cursor_motion_event()
2291 if(get_top_level()->get_button_down() &&
2293 get_status() == BUTTON_DOWNHI &&
2296 // printf("PaneButton::cursor_motion_event %d\n", __LINE__);
2298 if(get_cursor_x() < 0 && !mwindow->gui->dragging_pane)
2300 mwindow->gui->start_x_pane_drag();
2303 if(get_cursor_y() < 0 && !mwindow->gui->dragging_pane)
2305 mwindow->gui->start_y_pane_drag();
2309 mwindow->gui->handle_pane_drag();
2311 int result = BC_Button::cursor_motion_event();
2315 int PaneButton::button_release_event()
2317 mwindow->gui->stop_pane_drag();
2318 int result = BC_Button::button_release_event();
2323 FFMpegToggle::FFMpegToggle(MWindow *mwindow, MButtons *mbuttons, int x, int y)
2324 : BC_Toggle(x, y, mwindow->theme->ffmpeg_toggle,
2325 mwindow->preferences->get_file_probe_armed("FFMPEG_Early") > 0 ? 1 : 0)
2327 this->mwindow = mwindow;
2328 this->mbuttons = mbuttons;
2329 set_tooltip(get_value() ? FFMPEG_EARLY_TIP : FFMPEG_LATE_TIP);
2332 FFMpegToggle::~FFMpegToggle()
2336 int FFMpegToggle::handle_event()
2338 int ffmpeg_early_probe = get_value();
2339 set_tooltip(ffmpeg_early_probe ? FFMPEG_EARLY_TIP : FFMPEG_LATE_TIP);
2340 mwindow->preferences->set_file_probe_armed("FFMPEG_Early", ffmpeg_early_probe);
2341 mwindow->preferences->set_file_probe_armed("FFMPEG_Late", !ffmpeg_early_probe);
2343 mwindow->show_warning(&mwindow->preferences->warn_indexes,
2344 _("Changing the base codecs may require rebuilding indexes."));