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 #ifdef HAVE_COMMERCIAL
360 db_window = new DbWindow(mwindow);
362 swindow = new SWindow(mwindow);
364 if(debug) printf("MWindowGUI::create_objects %d\n", __LINE__);
366 add_subwindow(pane_button = new PaneButton(mwindow,
367 get_w() - mwindow->theme->get_image_set("pane")[0]->get_w(),
368 mwindow->theme->mzoom_y + 1 - mwindow->theme->get_image_set("pane")[0]->get_h()));
370 pane[TOP_LEFT_PANE]->canvas->activate();
372 if(debug) printf("MWindowGUI::create_objects %d\n", __LINE__);
375 void MWindowGUI::redraw_time_dependancies()
377 zoombar->redraw_time_dependancies();
378 for(int i = 0; i < TOTAL_PANES; i++)
379 if(pane[i] && pane[i]->timebar) pane[i]->timebar->update(0);
380 mainclock->update(mwindow->edl->local_session->get_selectionstart(1));
383 int MWindowGUI::focus_in_event()
385 for(int i = 0; i < TOTAL_PANES; i++)
386 if(pane[i]) pane[i]->cursor->focus_in_event();
390 int MWindowGUI::focus_out_event()
392 for(int i = 0; i < TOTAL_PANES; i++)
393 if(pane[i]) pane[i]->cursor->focus_out_event();
398 int MWindowGUI::resize_event(int w, int h)
400 //printf("MWindowGUI::resize_event %d\n", __LINE__);
401 mwindow->session->mwindow_w = w;
402 mwindow->session->mwindow_h = h;
403 int x = w - MainShBtns::calculate_w(0);
404 mainmenu->resize_event(x, mainmenu->get_h());
405 mainshbtns->reposition_window(x, -1);
406 ffmpeg_toggle->reposition_window(menu_w(), menu_h()+2);
407 mwindow->theme->get_mwindow_sizes(this, w, h);
408 mwindow->theme->draw_mwindow_bg(this);
409 mbuttons->resize_event();
410 statusbar->resize_event();
411 zoombar->resize_event();
413 resource_thread->stop_draw(1);
415 if(total_panes() > 1)
417 if(horizontal_panes())
419 // printf("MWindowGUI::resize_event %d %d %d\n",
421 // pane[TOP_RIGHT_PANE]->x,
422 // mwindow->theme->mcanvas_w -
423 // BC_ScrollBar::get_span(SCROLL_VERT) -
424 // PANE_DRAG_MARGIN);
425 if(pane[TOP_RIGHT_PANE]->x >= mwindow->theme->mcanvas_w -
426 BC_ScrollBar::get_span(SCROLL_VERT) -
429 delete_x_pane(pane[TOP_RIGHT_PANE]->x);
430 mwindow->edl->local_session->x_pane = -1;
436 if(pane[BOTTOM_LEFT_PANE]->y >= mwindow->theme->mzoom_y -
437 BC_ScrollBar::get_span(SCROLL_HORIZ) -
440 delete_y_pane(pane[BOTTOM_LEFT_PANE]->y);
441 mwindow->edl->local_session->y_pane = -1;
446 if(pane[TOP_RIGHT_PANE]->x >= mwindow->theme->mcanvas_w -
447 BC_ScrollBar::get_span(SCROLL_VERT) -
450 delete_x_pane(pane[TOP_RIGHT_PANE]->x);
451 mwindow->edl->local_session->x_pane = -1;
454 if(pane[BOTTOM_LEFT_PANE]->y >= mwindow->theme->mzoom_y -
455 BC_ScrollBar::get_span(SCROLL_HORIZ) -
458 delete_y_pane(pane[BOTTOM_LEFT_PANE]->y);
459 mwindow->edl->local_session->y_pane = -1;
464 if(total_panes() == 1)
466 pane[TOP_LEFT_PANE]->resize_event(
467 mwindow->theme->mcanvas_x,
468 mwindow->theme->mcanvas_y,
469 mwindow->theme->mcanvas_w,
470 mwindow->theme->mcanvas_h);
473 if(horizontal_panes())
475 pane[TOP_LEFT_PANE]->resize_event(
476 pane[TOP_LEFT_PANE]->x,
477 pane[TOP_LEFT_PANE]->y,
478 pane[TOP_LEFT_PANE]->w,
479 mwindow->theme->mcanvas_h);
480 pane[TOP_RIGHT_PANE]->resize_event(
481 pane[TOP_RIGHT_PANE]->x,
482 pane[TOP_RIGHT_PANE]->y,
483 mwindow->theme->mcanvas_w - pane[TOP_RIGHT_PANE]->x,
484 mwindow->theme->mcanvas_h);
489 pane[TOP_LEFT_PANE]->resize_event(
490 pane[TOP_LEFT_PANE]->x,
491 pane[TOP_LEFT_PANE]->y,
492 mwindow->theme->mcanvas_w,
493 pane[TOP_LEFT_PANE]->h);
494 pane[BOTTOM_LEFT_PANE]->resize_event(
495 pane[BOTTOM_LEFT_PANE]->x,
496 pane[BOTTOM_LEFT_PANE]->y,
497 mwindow->theme->mcanvas_w,
498 mwindow->theme->mcanvas_y +
499 mwindow->theme->mcanvas_h -
500 pane[BOTTOM_LEFT_PANE]->y);
504 pane[TOP_LEFT_PANE]->resize_event(
505 pane[TOP_LEFT_PANE]->x,
506 pane[TOP_LEFT_PANE]->y,
507 pane[TOP_LEFT_PANE]->w,
508 pane[TOP_LEFT_PANE]->h);
509 pane[TOP_RIGHT_PANE]->resize_event(
510 pane[TOP_RIGHT_PANE]->x,
511 pane[TOP_RIGHT_PANE]->y,
512 mwindow->theme->mcanvas_w - pane[TOP_RIGHT_PANE]->x,
513 pane[TOP_RIGHT_PANE]->h);
514 pane[BOTTOM_LEFT_PANE]->resize_event(
515 pane[BOTTOM_LEFT_PANE]->x,
516 pane[BOTTOM_LEFT_PANE]->y,
517 pane[BOTTOM_LEFT_PANE]->w,
518 mwindow->theme->mcanvas_y +
519 mwindow->theme->mcanvas_h -
520 pane[BOTTOM_LEFT_PANE]->y);
521 pane[BOTTOM_RIGHT_PANE]->resize_event(
522 pane[BOTTOM_RIGHT_PANE]->x,
523 pane[BOTTOM_RIGHT_PANE]->y,
524 mwindow->theme->mcanvas_w -
525 pane[BOTTOM_RIGHT_PANE]->x,
526 mwindow->theme->mcanvas_y +
527 mwindow->theme->mcanvas_h -
528 pane[BOTTOM_RIGHT_PANE]->y);
531 update_pane_dividers();
532 pane_button->reposition_window(w - mwindow->theme->get_image_set("pane")[0]->get_w(),
533 mwindow->theme->mzoom_y + 1 - mwindow->theme->get_image_set("pane")[0]->get_h());
534 resource_thread->start_draw();
540 int MWindowGUI::total_panes()
543 for(int i = 0; i < TOTAL_PANES; i++)
548 int MWindowGUI::vertical_panes()
550 return total_panes() == 2 &&
551 pane[TOP_LEFT_PANE] &&
552 pane[BOTTOM_LEFT_PANE];
555 int MWindowGUI::horizontal_panes()
557 return total_panes() == 2 &&
558 pane[TOP_LEFT_PANE] &&
559 pane[TOP_RIGHT_PANE];
562 TimelinePane* MWindowGUI::get_focused_pane()
564 if(pane[focused_pane]) return pane[focused_pane];
565 for(int i = 0; i < TOTAL_PANES; i++)
567 if(pane[i]) return pane[i];
572 void MWindowGUI::activate_timeline()
574 if(pane[focused_pane])
576 pane[focused_pane]->activate();
580 for(int i = 0; i < TOTAL_PANES; i++)
591 void MWindowGUI::deactivate_timeline()
593 for(int i = 0; i < TOTAL_PANES; i++)
597 pane[i]->canvas->deactivate();
602 void MWindowGUI::update_title(char *path)
605 char filename[BCTEXTLEN], string[BCTEXTLEN];
606 fs.extract_name(filename, path);
607 sprintf(string, _(PROGRAM_NAME ": %s"), filename);
609 //printf("MWindowGUI::update_title %s\n", string);
613 void MWindowGUI::draw_overlays(int flash_it)
615 for(int i = 0; i < TOTAL_PANES; i++)
619 pane[i]->canvas->draw_overlays();
620 if(flash_it) pane[i]->canvas->flash();
625 void MWindowGUI::update_timebar(int flush_it)
627 for(int i = 0; i < TOTAL_PANES; i++)
629 if(pane[i] && pane[i]->timebar)
631 pane[i]->timebar->update(flush_it);
636 void MWindowGUI::update_timebar_highlights()
638 for(int i = 0; i < TOTAL_PANES; i++)
640 if(pane[i] && pane[i]->timebar)
642 pane[i]->timebar->update_highlights();
648 void MWindowGUI::update_patchbay()
650 for(int i = 0; i < TOTAL_PANES; i++)
652 if(pane[i] && pane[i]->patchbay)
654 pane[i]->patchbay->update();
659 void MWindowGUI::draw_indexes(Indexable *indexable)
661 for(int i = 0; i < TOTAL_PANES; i++)
665 pane[i]->canvas->draw_indexes(indexable);
670 void MWindowGUI::draw_canvas(int mode /* = 0 */, int hide_cursor /* = 1 */)
672 if(mode != IGNORE_THREAD)
674 resource_thread->stop_draw(1);
678 for(int i = 0; i < TOTAL_PANES; i++)
682 pane[i]->canvas->draw(mode, hide_cursor);
687 if(mode != IGNORE_THREAD)
689 resource_thread->start_draw();
694 void MWindowGUI::flash_canvas(int flush)
696 for(int i = 0; i < TOTAL_PANES; i++)
700 pane[i]->canvas->flash(flush);
705 void MWindowGUI::draw_cursor(int do_plugintoggles)
707 for(int i = 0; i < TOTAL_PANES; i++)
711 pane[i]->cursor->draw(do_plugintoggles);
716 void MWindowGUI::show_cursor(int do_plugintoggles)
718 for(int i = 0; i < TOTAL_PANES; i++)
722 pane[i]->cursor->show(do_plugintoggles);
727 void MWindowGUI::hide_cursor(int do_plugintoggles)
729 for(int i = 0; i < TOTAL_PANES; i++)
733 pane[i]->cursor->hide(do_plugintoggles);
738 void MWindowGUI::update_cursor()
740 for(int i = 0; i < TOTAL_PANES; i++)
744 pane[i]->cursor->update();
749 void MWindowGUI::set_playing_back(int value)
751 for(int i = 0; i < TOTAL_PANES; i++)
755 pane[i]->cursor->playing_back = value;
760 void MWindowGUI::update_plugintoggles()
762 for(int i = 0; i < TOTAL_PANES; i++)
766 pane[i]->canvas->refresh_plugintoggles();
772 void MWindowGUI::update_scrollbars(int flush)
774 for(int i = 0; i < TOTAL_PANES; i++)
778 pane[i]->update(1, 0, 0, 0);
781 if(flush) this->flush();
784 void MWindowGUI::reset_meters()
786 for(int i = 0; i < TOTAL_PANES; i++)
788 if(pane[i] && pane[i]->patchbay)
790 pane[i]->patchbay->reset_meters();
795 void MWindowGUI::stop_meters()
797 for(int i = 0; i < TOTAL_PANES; i++)
799 if(pane[i] && pane[i]->patchbay)
801 pane[i]->patchbay->stop_meters();
806 void MWindowGUI::update_meters(ArrayList<double> *module_levels)
808 for(int i = 0; i < TOTAL_PANES; i++)
810 if(pane[i] && pane[i]->patchbay)
812 pane[i]->patchbay->update_meters(module_levels);
817 void MWindowGUI::set_editing_mode(int flush)
819 for(int i = 0; i < TOTAL_PANES; i++)
823 pane[i]->canvas->update_cursor(flush);
828 void MWindowGUI::set_meter_format(int mode, int min, int max)
830 for(int i = 0; i < TOTAL_PANES; i++)
832 if(pane[i] && pane[i]->patchbay)
834 pane[i]->patchbay->set_meter_format(mode, min, max);
839 void MWindowGUI::update(int scrollbars,
848 if(debug) PRINT_TRACE
852 mwindow->edl->tracks->update_y_pixels(mwindow->theme);
854 if(do_canvas && do_canvas != IGNORE_THREAD)
856 resource_thread->stop_draw(1);
859 for(int i = 0; i < TOTAL_PANES; i++)
861 if(pane[i]) pane[i]->update(scrollbars,
867 if(do_canvas && do_canvas != IGNORE_THREAD)
869 resource_thread->start_draw();
872 // if(scrollbars) this->get_scrollbars(0);
873 // if(timebar) this->timebar->update(0);
874 if(zoombar) this->zoombar->update();
875 // if(patchbay) this->patchbay->update();
876 if(clock) this->mainclock->update(
877 mwindow->edl->local_session->get_selectionstart(1));
878 if(debug) PRINT_TRACE
884 // this->canvas->draw(do_canvas);
885 // this->cursor->show();
886 // this->canvas->flash(0);
887 // Activate causes the menubar to deactivate. Don't want this for
889 // if(canvas != IGNORE_THREAD) this->canvas->activate();
891 if(debug) PRINT_TRACE
895 if(buttonbar) mbuttons->update();
896 if(debug) PRINT_TRACE
898 // Can't age if the cache called this to draw missing picons
899 // or the GUI is updating the status of the draw toggle.
900 if(do_canvas != FORCE_REDRAW && do_canvas != IGNORE_THREAD)
903 mwindow->age_caches();
904 lock_window("MWindowGUI::update");
908 if(debug) PRINT_TRACE
911 int MWindowGUI::visible(int64_t x1, int64_t x2, int64_t view_x1, int64_t view_x2)
913 return (x1 >= view_x1 && x1 < view_x2) ||
914 (x2 > view_x1 && x2 <= view_x2) ||
915 (x1 <= view_x1 && x2 >= view_x2);
919 void MWindowGUI::show_message(const char *message, int color)
921 statusbar->show_message(message, color);
924 void MWindowGUI::update_default_message()
926 statusbar->update_default_message();
929 void MWindowGUI::reset_default_message()
931 statusbar->reset_default_message();
934 void MWindowGUI::default_message()
936 statusbar->default_message();
939 // Drag motion called from other window
940 int MWindowGUI::drag_motion()
942 if(get_hidden()) return 0;
944 Track *over_track = 0;
946 PluginSet *over_pluginset = 0;
947 Plugin *over_plugin = 0;
952 drag_popup->cursor_motion_event();
956 // there's no point in drawing highlights has until drag operation has been set
957 if (!mwindow->session->current_operation)
960 for(int i = 0; i < TOTAL_PANES; i++)
962 if(pane[i]) pane[i]->canvas->drag_motion(
969 if(mwindow->session->track_highlighted != over_track)
971 mwindow->session->track_highlighted = over_track;
975 if(mwindow->session->edit_highlighted != over_edit)
977 mwindow->session->edit_highlighted = over_edit;
981 if(mwindow->session->pluginset_highlighted != over_pluginset)
983 mwindow->session->pluginset_highlighted = over_pluginset;
987 if(mwindow->session->plugin_highlighted != over_plugin)
989 mwindow->session->plugin_highlighted = over_plugin;
993 if( mwindow->session->current_operation == DRAG_ASSET ||
994 mwindow->session->current_operation == DRAG_EDIT ||
995 mwindow->session->current_operation == DRAG_AEFFECT_COPY ||
996 mwindow->session->current_operation == DRAG_VEFFECT_COPY )
1002 // printf("drag_motion %d %d over_track=%p over_edit=%p\n",
1009 lock_window("MWindowGUI::drag_motion");
1016 int MWindowGUI::drag_stop()
1018 if(get_hidden()) return 0;
1019 int result = 0, redraw = 0;
1021 for(int i = 0; i < TOTAL_PANES; i++)
1023 if(pane[i]) result |= pane[i]->canvas->drag_stop(
1026 mwindow->edl->optimize();
1028 // since we don't have subwindows we have to terminate any drag operation
1031 if (mwindow->session->track_highlighted
1032 || mwindow->session->edit_highlighted
1033 || mwindow->session->plugin_highlighted
1034 || mwindow->session->pluginset_highlighted)
1036 mwindow->session->track_highlighted = 0;
1037 mwindow->session->edit_highlighted = 0;
1038 mwindow->session->plugin_highlighted = 0;
1039 mwindow->session->pluginset_highlighted = 0;
1040 mwindow->session->current_operation = NO_OPERATION;
1044 //printf("MWindowGUI::drag_stop %d %d\n", redraw, mwindow->session->current_operation);
1047 mwindow->edl->tracks->update_y_pixels(mwindow->theme);
1048 update_scrollbars(0);
1063 void MWindowGUI::default_positions()
1065 //printf("MWindowGUI::default_positions 1\n");
1066 VWindow *vwindow = mwindow->vwindows.size() > DEFAULT_VWINDOW ?
1067 mwindow->vwindows.get(DEFAULT_VWINDOW) : 0;
1068 if( vwindow && !vwindow->is_running() ) vwindow = 0;
1069 if( vwindow ) vwindow->gui->lock_window("MWindowGUI::default_positions");
1070 mwindow->cwindow->gui->lock_window("MWindowGUI::default_positions");
1071 mwindow->awindow->gui->lock_window("MWindowGUI::default_positions");
1073 // printf("MWindowGUI::default_positions 1 %d %d %d %d\n", mwindow->session->vwindow_x,
1074 // mwindow->session->vwindow_y,
1075 // mwindow->session->vwindow_w,
1076 // mwindow->session->vwindow_h);
1077 reposition_window(mwindow->session->mwindow_x,
1078 mwindow->session->mwindow_y,
1079 mwindow->session->mwindow_w,
1080 mwindow->session->mwindow_h);
1081 if( vwindow ) vwindow->gui->reposition_window(mwindow->session->vwindow_x,
1082 mwindow->session->vwindow_y,
1083 mwindow->session->vwindow_w,
1084 mwindow->session->vwindow_h);
1085 mwindow->cwindow->gui->reposition_window(mwindow->session->cwindow_x,
1086 mwindow->session->cwindow_y,
1087 mwindow->session->cwindow_w,
1088 mwindow->session->cwindow_h);
1089 mwindow->awindow->gui->reposition_window(mwindow->session->awindow_x,
1090 mwindow->session->awindow_y,
1091 mwindow->session->awindow_w,
1092 mwindow->session->awindow_h);
1093 //printf("MWindowGUI::default_positions 1\n");
1095 resize_event(mwindow->session->mwindow_w,
1096 mwindow->session->mwindow_h);
1097 //printf("MWindowGUI::default_positions 1\n");
1098 if( vwindow ) vwindow->gui->resize_event(mwindow->session->vwindow_w,
1099 mwindow->session->vwindow_h);
1100 //printf("MWindowGUI::default_positions 1\n");
1101 mwindow->cwindow->gui->resize_event(mwindow->session->cwindow_w,
1102 mwindow->session->cwindow_h);
1103 //printf("MWindowGUI::default_positions 1\n");
1104 mwindow->awindow->gui->resize_event(mwindow->session->awindow_w,
1105 mwindow->session->awindow_h);
1107 //printf("MWindowGUI::default_positions 1\n");
1110 if( vwindow ) vwindow->gui->flush();
1111 mwindow->cwindow->gui->flush();
1112 mwindow->awindow->gui->flush();
1114 if( vwindow ) vwindow->gui->unlock_window();
1115 mwindow->cwindow->gui->unlock_window();
1116 mwindow->awindow->gui->unlock_window();
1117 //printf("MWindowGUI::default_positions 2\n");
1121 int MWindowGUI::button_release_event()
1123 if( keyvalue_popup ) {
1124 delete keyvalue_popup; keyvalue_popup = 0;
1130 int MWindowGUI::repeat_event(int64_t duration)
1132 // if(duration == 100)
1133 // mwindow->sync_parameters(CHANGE_ALL);
1135 for(int i = 0; i < TOTAL_PANES; i++)
1137 if(pane[i]) result = pane[i]->cursor->repeat_event(duration);
1143 int MWindowGUI::translation_event()
1145 //printf("MWindowGUI::translation_event 1 %d %d\n", get_x(), get_y());
1146 mwindow->session->mwindow_x = get_x();
1147 mwindow->session->mwindow_y = get_y();
1152 int MWindowGUI::save_defaults(BC_Hash *defaults)
1154 defaults->update("MWINDOWWIDTH", get_w());
1155 defaults->update("MWINDOWHEIGHT", get_h());
1156 mainmenu->save_defaults(defaults);
1157 BC_WindowBase::save_defaults(defaults);
1161 int MWindowGUI::keypress_event()
1163 //printf("MWindowGUI::keypress_event 1 %d\n", get_keypress());
1164 int result = mbuttons->keypress_event();
1165 if( result ) return result;
1167 Track *this_track = 0;
1169 switch(get_keypress()) {
1171 mwindow->toggle_editing_mode();
1176 if( alt_down() ) break;
1177 stop_transport("MWindowGUI::keypress_event 1");
1178 mwindow->nearest_plugin_keyframe(shift_down(),
1179 !ctrl_down() ? PLAY_FORWARD : PLAY_REVERSE);
1183 case '1': case '2': case '3': case '4':
1184 case '5': case '6': case '7': case '8':
1185 if( !alt_down() || shift_down() ) break;
1186 if( !mwindow->select_asset(get_keypress()-'1',1) )
1191 if( !ctrl_down() ) {
1193 stop_transport("MWindowGUI::keypress_event 1");
1194 mwindow->prev_edit_handle(shift_down());
1197 mwindow->move_left();
1203 if( !ctrl_down() && !alt_down() ) {
1204 mwindow->move_left();
1210 if( !ctrl_down() ) {
1212 stop_transport("MWindowGUI::keypress_event 2");
1213 mwindow->next_edit_handle(shift_down());
1216 mwindow->move_right();
1222 if( !ctrl_down() && !alt_down() ) {
1223 mwindow->move_right();
1229 if( ctrl_down() && !alt_down() )
1230 mwindow->expand_y();
1231 else if( !ctrl_down() && alt_down() )
1232 mwindow->expand_autos(0,1,1);
1233 else if( ctrl_down() && alt_down() )
1234 mwindow->expand_autos(1,1,1);
1236 mwindow->expand_sample();
1241 if( ctrl_down() && !alt_down() )
1242 mwindow->zoom_in_y();
1243 else if( !ctrl_down() && alt_down() )
1244 mwindow->shrink_autos(0,1,1);
1245 else if( ctrl_down() && alt_down() )
1246 mwindow->shrink_autos(1,1,1);
1248 mwindow->zoom_in_sample();
1256 mwindow->expand_t();
1262 mwindow->move_down();
1264 mwindow->zoom_in_t();
1270 for( int i=0; i<TOTAL_PANES; ++i ) {
1271 if( !pane[i] ) continue;
1272 if( (this_track = pane[i]->over_track()) != 0 ) break;
1273 if( (this_track = pane[i]->over_patchbay()) != 0 ) break;
1276 if( get_keypress() == TAB ) { // Switch the record button
1278 this_track->record = !this_track->record ? 1 : 0;
1281 int total_selected = mwindow->edl->tracks->total_of(Tracks::RECORD);
1282 // all selected if nothing previously selected or
1283 // if this patch was previously the only one selected and armed
1284 int selected = !total_selected || (total_selected == 1 &&
1285 this_track && this_track->record ) ? 1 : 0;
1286 mwindow->edl->tracks->select_all(Tracks::RECORD, selected);
1287 if( !selected && this_track ) this_track->record = 1;
1290 update(0, 1, 0, 0, 1, 0, 1);
1292 mwindow->cwindow->update(0, 1, 1);
1293 lock_window("MWindowGUI::keypress_event 3");
1310 resend_event(mwindow->cwindow->gui);
1314 // since things under cursor have changed...
1316 cursor_motion_event();
1321 int MWindowGUI::keyboard_listener(BC_WindowBase *wp)
1323 return key_listener(wp->get_keypress());
1326 int MWindowGUI::key_listener(int key)
1331 if( !record->running() )
1334 record->record_gui->interrupt_thread->start(0);
1341 channel_info->toggle_scan();
1345 if( !remote_control->deactivate() )
1346 remote_control->activate();
1356 void MWindowGUI::use_android_remote(int on)
1359 delete android_control;
1360 android_control = 0;
1363 if( android_control ) return;
1364 android_control = new AndroidControl(this);
1367 int MWindowGUI::close_event()
1373 void MWindowGUI::stop_drawing()
1375 resource_thread->stop_draw(1);
1378 int MWindowGUI::menu_w()
1380 return mainmenu->get_w();
1383 int MWindowGUI::menu_h()
1385 return mainmenu->get_h();
1388 void MWindowGUI::start_x_pane_drag()
1392 x_pane_drag = new BC_Popup(this,
1393 get_abs_cursor_x(0) - mwindow->theme->pane_w,
1394 BC_DisplayInfo::get_top_border() +
1396 mwindow->theme->mcanvas_y,
1397 mwindow->theme->pane_w,
1398 mwindow->theme->mcanvas_h,
1399 mwindow->theme->drag_pane_color);
1400 x_pane_drag->draw_3segmentv(0,
1402 x_pane_drag->get_h(),
1403 mwindow->theme->get_image_set("xpane")[BUTTON_DOWNHI]);
1404 x_pane_drag->flash(1);
1409 void MWindowGUI::start_y_pane_drag()
1413 //printf("MWindowGUI::start_y_pane_drag %d %d %d\n", __LINE__, get_x(), get_y());
1414 y_pane_drag = new BC_Popup(this,
1415 BC_DisplayInfo::get_left_border() +
1417 mwindow->theme->mcanvas_x,
1418 get_abs_cursor_y(0) - mwindow->theme->pane_h,
1419 mwindow->theme->mcanvas_w,
1420 mwindow->theme->pane_h,
1421 mwindow->theme->drag_pane_color);
1422 y_pane_drag->draw_3segmenth(0,
1424 y_pane_drag->get_w(),
1425 mwindow->theme->get_image_set("ypane")[BUTTON_DOWNHI]);
1426 y_pane_drag->flash(1);
1431 void MWindowGUI::handle_pane_drag()
1437 x_pane_drag->reposition_window(
1438 get_abs_cursor_x(0) - mwindow->theme->pane_w,
1439 x_pane_drag->get_y());
1444 y_pane_drag->reposition_window(
1445 y_pane_drag->get_x(),
1446 get_abs_cursor_y(0) - mwindow->theme->pane_h);
1452 void MWindowGUI::create_x_pane(int cursor_x)
1454 if(total_panes() == 1)
1456 // create a horizontal pane
1457 // do this 1st so the resize_event knows there are 2 panes
1458 mwindow->edl->local_session->view_start[TOP_RIGHT_PANE] =
1459 mwindow->edl->local_session->view_start[TOP_LEFT_PANE] +
1461 mwindow->theme->patchbay_w;
1462 pane[TOP_RIGHT_PANE] = new TimelinePane(mwindow,
1464 mwindow->theme->mcanvas_x +
1466 mwindow->theme->mcanvas_y,
1467 mwindow->theme->mcanvas_x +
1468 mwindow->theme->mcanvas_w -
1470 mwindow->theme->mcanvas_h);
1471 pane[TOP_LEFT_PANE]->resize_event(
1472 mwindow->theme->mcanvas_x,
1473 mwindow->theme->mcanvas_y,
1474 cursor_x - mwindow->theme->pane_w,
1475 mwindow->theme->mcanvas_h);
1476 pane[TOP_RIGHT_PANE]->create_objects();
1479 if(vertical_panes())
1481 // create 2 horizontal panes
1482 mwindow->edl->local_session->track_start[TOP_RIGHT_PANE] =
1483 mwindow->edl->local_session->track_start[TOP_LEFT_PANE];
1484 mwindow->edl->local_session->track_start[BOTTOM_RIGHT_PANE] =
1485 mwindow->edl->local_session->track_start[BOTTOM_LEFT_PANE];
1486 mwindow->edl->local_session->view_start[TOP_RIGHT_PANE] =
1487 mwindow->edl->local_session->view_start[BOTTOM_RIGHT_PANE] =
1488 mwindow->edl->local_session->view_start[TOP_LEFT_PANE] +
1490 mwindow->theme->patchbay_w;
1491 pane[TOP_RIGHT_PANE] = new TimelinePane(mwindow,
1493 mwindow->theme->mcanvas_x +
1495 pane[TOP_LEFT_PANE]->y,
1496 mwindow->theme->mcanvas_x +
1497 mwindow->theme->mcanvas_w -
1499 pane[TOP_LEFT_PANE]->h);
1500 pane[BOTTOM_RIGHT_PANE] = new TimelinePane(mwindow,
1502 mwindow->theme->mcanvas_x +
1504 pane[BOTTOM_LEFT_PANE]->y,
1505 mwindow->theme->mcanvas_x +
1506 mwindow->theme->mcanvas_w -
1508 pane[BOTTOM_LEFT_PANE]->h);
1509 pane[TOP_LEFT_PANE]->resize_event(
1510 pane[TOP_LEFT_PANE]->x,
1511 pane[TOP_LEFT_PANE]->y,
1512 cursor_x - mwindow->theme->pane_w,
1513 pane[TOP_LEFT_PANE]->h);
1514 pane[BOTTOM_LEFT_PANE]->resize_event(
1515 pane[BOTTOM_LEFT_PANE]->x,
1516 pane[BOTTOM_LEFT_PANE]->y,
1517 cursor_x - mwindow->theme->pane_w,
1518 pane[BOTTOM_LEFT_PANE]->h);
1519 pane[TOP_RIGHT_PANE]->create_objects();
1520 pane[BOTTOM_RIGHT_PANE]->create_objects();
1523 if(horizontal_panes())
1525 // resize a horizontal pane
1526 mwindow->edl->local_session->view_start[TOP_RIGHT_PANE] +=
1528 pane[TOP_RIGHT_PANE]->x;
1529 if(mwindow->edl->local_session->view_start[TOP_RIGHT_PANE] < 0)
1530 mwindow->edl->local_session->view_start[TOP_RIGHT_PANE] = 0;
1531 pane[TOP_LEFT_PANE]->resize_event(
1532 mwindow->theme->mcanvas_x,
1533 mwindow->theme->mcanvas_y,
1534 cursor_x - mwindow->theme->pane_w,
1535 mwindow->theme->mcanvas_h);
1536 pane[TOP_RIGHT_PANE]->resize_event(
1537 mwindow->theme->mcanvas_x +
1539 pane[TOP_RIGHT_PANE]->y,
1540 mwindow->theme->mcanvas_x +
1541 mwindow->theme->mcanvas_w -
1543 mwindow->theme->mcanvas_h);
1547 // resize 2 horizontal panes
1548 mwindow->edl->local_session->view_start[TOP_RIGHT_PANE] +=
1550 pane[TOP_RIGHT_PANE]->x;
1551 if(mwindow->edl->local_session->view_start[TOP_RIGHT_PANE] < 0)
1552 mwindow->edl->local_session->view_start[TOP_RIGHT_PANE] = 0;
1553 mwindow->edl->local_session->view_start[BOTTOM_RIGHT_PANE] =
1554 mwindow->edl->local_session->view_start[TOP_RIGHT_PANE];
1556 pane[TOP_LEFT_PANE]->resize_event(
1557 mwindow->theme->mcanvas_x,
1558 pane[TOP_LEFT_PANE]->y,
1559 cursor_x - mwindow->theme->pane_w,
1560 pane[TOP_LEFT_PANE]->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 pane[TOP_RIGHT_PANE]->h);
1569 pane[BOTTOM_LEFT_PANE]->resize_event(
1570 mwindow->theme->mcanvas_x,
1571 pane[BOTTOM_LEFT_PANE]->y,
1572 cursor_x - mwindow->theme->pane_w,
1573 pane[BOTTOM_LEFT_PANE]->h);
1574 pane[BOTTOM_RIGHT_PANE]->resize_event(
1575 mwindow->theme->mcanvas_x +
1577 pane[BOTTOM_RIGHT_PANE]->y,
1578 mwindow->theme->mcanvas_x +
1579 mwindow->theme->mcanvas_w -
1581 pane[BOTTOM_RIGHT_PANE]->h);
1587 void MWindowGUI::delete_x_pane(int cursor_x)
1589 // give left panes coordinates of right pane
1590 if(cursor_x < mwindow->theme->patchbay_w + PANE_DRAG_MARGIN &&
1591 pane[TOP_RIGHT_PANE])
1593 mwindow->edl->local_session->view_start[TOP_LEFT_PANE] =
1594 mwindow->edl->local_session->view_start[TOP_RIGHT_PANE] -
1595 pane[TOP_RIGHT_PANE]->x + mwindow->theme->patchbay_w;
1596 if(mwindow->edl->local_session->view_start[TOP_LEFT_PANE] < 0)
1597 mwindow->edl->local_session->view_start[TOP_LEFT_PANE] = 0;
1598 mwindow->edl->local_session->view_start[BOTTOM_LEFT_PANE] =
1599 mwindow->edl->local_session->view_start[TOP_LEFT_PANE];
1602 switch(total_panes())
1605 if(pane[TOP_LEFT_PANE] && pane[TOP_RIGHT_PANE])
1607 // delete right pane
1608 delete pane[TOP_RIGHT_PANE];
1609 pane[TOP_RIGHT_PANE] = 0;
1610 pane[TOP_LEFT_PANE]->resize_event(
1611 mwindow->theme->mcanvas_x,
1612 mwindow->theme->mcanvas_y,
1613 mwindow->theme->mcanvas_w,
1614 mwindow->theme->mcanvas_h);
1620 // delete right panes
1621 delete pane[TOP_RIGHT_PANE];
1622 pane[TOP_RIGHT_PANE] = 0;
1623 delete pane[BOTTOM_RIGHT_PANE];
1624 pane[BOTTOM_RIGHT_PANE] = 0;
1625 pane[TOP_LEFT_PANE]->resize_event(
1626 mwindow->theme->mcanvas_x,
1627 pane[TOP_LEFT_PANE]->y,
1628 mwindow->theme->mcanvas_w,
1629 pane[TOP_LEFT_PANE]->h);
1630 pane[BOTTOM_LEFT_PANE]->resize_event(
1631 mwindow->theme->mcanvas_x,
1632 pane[BOTTOM_LEFT_PANE]->y,
1633 mwindow->theme->mcanvas_w,
1634 pane[BOTTOM_LEFT_PANE]->h);
1639 void MWindowGUI::create_y_pane(int cursor_y)
1641 if(total_panes() == 1)
1643 mwindow->edl->local_session->view_start[BOTTOM_LEFT_PANE] =
1644 mwindow->edl->local_session->view_start[TOP_LEFT_PANE];
1645 mwindow->edl->local_session->track_start[BOTTOM_LEFT_PANE] =
1646 mwindow->edl->local_session->track_start[TOP_LEFT_PANE] +
1648 mwindow->theme->mtimebar_h;
1649 // do this 1st so the resize_event knows there are 2 panes
1650 pane[BOTTOM_LEFT_PANE] = new TimelinePane(mwindow,
1652 mwindow->theme->mcanvas_x,
1653 mwindow->theme->mcanvas_y +
1655 mwindow->theme->mcanvas_w,
1656 mwindow->theme->mcanvas_h -
1658 pane[TOP_LEFT_PANE]->resize_event(
1659 mwindow->theme->mcanvas_x,
1660 mwindow->theme->mcanvas_y,
1661 mwindow->theme->mcanvas_w,
1662 pane[BOTTOM_LEFT_PANE]->y -
1663 mwindow->theme->mcanvas_y -
1664 mwindow->theme->pane_h);
1665 pane[BOTTOM_LEFT_PANE]->create_objects();
1668 if(horizontal_panes())
1671 mwindow->edl->local_session->view_start[BOTTOM_LEFT_PANE] =
1672 mwindow->edl->local_session->view_start[TOP_LEFT_PANE];
1673 mwindow->edl->local_session->view_start[BOTTOM_RIGHT_PANE] =
1674 mwindow->edl->local_session->view_start[TOP_RIGHT_PANE];
1675 mwindow->edl->local_session->track_start[BOTTOM_LEFT_PANE] =
1676 mwindow->edl->local_session->track_start[BOTTOM_RIGHT_PANE] =
1677 mwindow->edl->local_session->track_start[TOP_LEFT_PANE] +
1679 mwindow->theme->mtimebar_h;
1681 pane[BOTTOM_LEFT_PANE] = new TimelinePane(mwindow,
1683 pane[TOP_LEFT_PANE]->x,
1684 mwindow->theme->mcanvas_y +
1686 pane[TOP_LEFT_PANE]->w,
1687 mwindow->theme->mcanvas_h -
1689 pane[BOTTOM_RIGHT_PANE] = new TimelinePane(mwindow,
1691 pane[TOP_RIGHT_PANE]->x,
1692 mwindow->theme->mcanvas_y +
1694 pane[TOP_RIGHT_PANE]->w,
1695 mwindow->theme->mcanvas_h -
1698 pane[TOP_LEFT_PANE]->resize_event(
1699 pane[TOP_LEFT_PANE]->x,
1700 pane[TOP_LEFT_PANE]->y,
1701 pane[TOP_LEFT_PANE]->w,
1702 pane[BOTTOM_LEFT_PANE]->y -
1703 mwindow->theme->mcanvas_y -
1704 mwindow->theme->pane_h);
1705 pane[TOP_RIGHT_PANE]->resize_event(
1706 pane[TOP_RIGHT_PANE]->x,
1707 pane[TOP_RIGHT_PANE]->y,
1708 pane[TOP_RIGHT_PANE]->w,
1709 pane[BOTTOM_RIGHT_PANE]->y -
1710 mwindow->theme->mcanvas_y -
1711 mwindow->theme->pane_h);
1713 pane[BOTTOM_LEFT_PANE]->create_objects();
1714 pane[BOTTOM_RIGHT_PANE]->create_objects();
1717 if(vertical_panes())
1720 mwindow->edl->local_session->track_start[BOTTOM_LEFT_PANE] +=
1722 (pane[BOTTOM_LEFT_PANE]->y - mwindow->theme->mcanvas_y);
1723 if(mwindow->edl->local_session->track_start[BOTTOM_LEFT_PANE] < 0)
1724 mwindow->edl->local_session->track_start[BOTTOM_LEFT_PANE] = 0;
1725 pane[TOP_LEFT_PANE]->resize_event(
1726 mwindow->theme->mcanvas_x,
1727 mwindow->theme->mcanvas_y,
1728 mwindow->theme->mcanvas_w,
1729 cursor_y - mwindow->theme->pane_h);
1730 pane[BOTTOM_LEFT_PANE]->resize_event(
1731 pane[BOTTOM_LEFT_PANE]->x,
1733 mwindow->theme->mcanvas_y,
1734 mwindow->theme->mcanvas_w,
1735 mwindow->theme->mcanvas_h -
1741 mwindow->edl->local_session->track_start[BOTTOM_LEFT_PANE] +=
1743 (pane[BOTTOM_LEFT_PANE]->y - mwindow->theme->mcanvas_y);
1744 if(mwindow->edl->local_session->track_start[BOTTOM_LEFT_PANE] < 0)
1745 mwindow->edl->local_session->track_start[BOTTOM_LEFT_PANE] = 0;
1746 mwindow->edl->local_session->track_start[BOTTOM_RIGHT_PANE] =
1747 mwindow->edl->local_session->track_start[BOTTOM_LEFT_PANE];
1748 pane[TOP_LEFT_PANE]->resize_event(
1749 pane[TOP_LEFT_PANE]->x,
1750 pane[TOP_LEFT_PANE]->y,
1751 pane[TOP_LEFT_PANE]->w,
1752 cursor_y - mwindow->theme->pane_h);
1753 pane[BOTTOM_LEFT_PANE]->resize_event(
1754 pane[BOTTOM_LEFT_PANE]->x,
1756 mwindow->theme->mcanvas_y,
1757 pane[BOTTOM_LEFT_PANE]->w,
1758 mwindow->theme->mcanvas_h -
1760 pane[TOP_RIGHT_PANE]->resize_event(
1761 pane[TOP_RIGHT_PANE]->x,
1762 pane[TOP_RIGHT_PANE]->y,
1763 pane[TOP_RIGHT_PANE]->w,
1764 cursor_y - mwindow->theme->pane_h);
1765 pane[BOTTOM_RIGHT_PANE]->resize_event(
1766 pane[BOTTOM_RIGHT_PANE]->x,
1768 mwindow->theme->mcanvas_y,
1769 pane[BOTTOM_RIGHT_PANE]->w,
1770 mwindow->theme->mcanvas_h -
1775 void MWindowGUI::delete_y_pane(int cursor_y)
1777 if(cursor_y < mwindow->theme->mtimebar_h +
1779 pane[BOTTOM_LEFT_PANE])
1781 // give top pane coordinates of bottom pane
1782 mwindow->edl->local_session->track_start[TOP_LEFT_PANE] =
1783 mwindow->edl->local_session->track_start[BOTTOM_LEFT_PANE] -
1784 pane[BOTTOM_LEFT_PANE]->y;
1785 if(mwindow->edl->local_session->track_start[TOP_LEFT_PANE] < 0)
1786 mwindow->edl->local_session->track_start[TOP_LEFT_PANE] = 0;
1787 mwindow->edl->local_session->track_start[TOP_RIGHT_PANE] =
1788 mwindow->edl->local_session->track_start[TOP_LEFT_PANE];
1792 switch(total_panes())
1795 delete pane[BOTTOM_LEFT_PANE];
1796 pane[BOTTOM_LEFT_PANE] = 0;
1797 pane[TOP_LEFT_PANE]->resize_event(
1798 mwindow->theme->mcanvas_x,
1799 mwindow->theme->mcanvas_y,
1800 mwindow->theme->mcanvas_w,
1801 mwindow->theme->mcanvas_h);
1805 // delete bottom 2 panes
1807 delete pane[BOTTOM_LEFT_PANE];
1808 pane[BOTTOM_LEFT_PANE] = 0;
1809 delete pane[BOTTOM_RIGHT_PANE];
1810 pane[BOTTOM_RIGHT_PANE] = 0;
1811 pane[TOP_LEFT_PANE]->resize_event(
1812 pane[TOP_LEFT_PANE]->x,
1813 mwindow->theme->mcanvas_y,
1814 pane[TOP_LEFT_PANE]->w,
1815 mwindow->theme->mcanvas_h);
1816 pane[TOP_RIGHT_PANE]->resize_event(
1817 pane[TOP_RIGHT_PANE]->x,
1818 mwindow->theme->mcanvas_y,
1819 pane[TOP_RIGHT_PANE]->w,
1820 mwindow->theme->mcanvas_h);
1825 void MWindowGUI::stop_pane_drag()
1828 resource_thread->stop_draw(1);
1832 // cursor position relative to canvas
1833 int cursor_x = x_pane_drag->get_x() -
1835 BC_DisplayInfo::get_left_border() -
1836 mwindow->theme->mcanvas_x +
1837 mwindow->theme->pane_w;
1842 if(cursor_x >= mwindow->theme->patchbay_w + PANE_DRAG_MARGIN &&
1843 cursor_x < mwindow->theme->mcanvas_w -
1844 BC_ScrollBar::get_span(SCROLL_VERT) -
1847 create_x_pane(cursor_x);
1848 mwindow->edl->local_session->x_pane = cursor_x;
1853 delete_x_pane(cursor_x);
1854 mwindow->edl->local_session->x_pane = -1;
1862 // cursor position relative to canvas
1863 int cursor_y = y_pane_drag->get_y() -
1865 BC_DisplayInfo::get_top_border() -
1866 mwindow->theme->mcanvas_y +
1867 mwindow->theme->pane_h;
1873 if(cursor_y >= mwindow->theme->mtimebar_h +
1875 cursor_y < mwindow->theme->mcanvas_h -
1876 BC_ScrollBar::get_span(SCROLL_HORIZ) -
1879 create_y_pane(cursor_y);
1880 mwindow->edl->local_session->y_pane = cursor_y;
1884 delete_y_pane(cursor_y);
1885 mwindow->edl->local_session->y_pane = -1;
1889 update_pane_dividers();
1891 // required to get new widgets to appear
1893 resource_thread->start_draw();
1896 // create panes from EDL
1897 void MWindowGUI::load_panes()
1899 int need_x_panes = 0;
1900 int need_y_panes = 0;
1901 // use names from create functions
1902 int cursor_x = mwindow->edl->local_session->x_pane;
1903 int cursor_y = mwindow->edl->local_session->y_pane;
1905 resource_thread->stop_draw(1);
1907 mwindow->theme->patchbay_w + PANE_DRAG_MARGIN &&
1909 mwindow->theme->mcanvas_w -
1910 BC_ScrollBar::get_span(SCROLL_VERT) -
1917 mwindow->theme->mtimebar_h + PANE_DRAG_MARGIN &&
1919 mwindow->theme->mcanvas_h -
1920 BC_ScrollBar::get_span(SCROLL_HORIZ) -
1926 //printf("MWindowGUI::load_panes %d %d %d\n", __LINE__, need_x_panes, need_y_panes);
1934 if(total_panes() == 1)
1937 //printf("MWindowGUI::load_panes %d\n", __LINE__);
1938 pane[TOP_RIGHT_PANE] = new TimelinePane(mwindow,
1940 mwindow->theme->mcanvas_x +
1942 mwindow->theme->mcanvas_y,
1943 mwindow->theme->mcanvas_x +
1944 mwindow->theme->mcanvas_w -
1946 cursor_y - mwindow->theme->pane_h);
1947 pane[BOTTOM_LEFT_PANE] = new TimelinePane(mwindow,
1949 mwindow->theme->mcanvas_x,
1950 mwindow->theme->mcanvas_y +
1952 cursor_x - mwindow->theme->pane_w,
1953 mwindow->theme->mcanvas_h -
1955 pane[BOTTOM_RIGHT_PANE] = new TimelinePane(mwindow,
1957 pane[TOP_RIGHT_PANE]->x,
1958 mwindow->theme->mcanvas_y +
1960 pane[TOP_RIGHT_PANE]->w,
1961 mwindow->theme->mcanvas_h -
1963 pane[TOP_LEFT_PANE]->resize_event(
1964 pane[TOP_LEFT_PANE]->x,
1965 pane[TOP_LEFT_PANE]->y,
1966 cursor_x - mwindow->theme->pane_w,
1967 cursor_y - mwindow->theme->pane_h);
1968 pane[TOP_RIGHT_PANE]->create_objects();
1969 pane[BOTTOM_LEFT_PANE]->create_objects();
1970 pane[BOTTOM_RIGHT_PANE]->create_objects();
1973 if(horizontal_panes())
1975 // create vertical panes
1976 //printf("MWindowGUI::load_panes %d\n", __LINE__);
1977 pane[BOTTOM_LEFT_PANE] = new TimelinePane(mwindow,
1979 mwindow->theme->mcanvas_x,
1980 mwindow->theme->mcanvas_y +
1982 cursor_x - mwindow->theme->pane_w,
1983 mwindow->theme->mcanvas_h -
1985 pane[BOTTOM_RIGHT_PANE] = new TimelinePane(mwindow,
1987 pane[TOP_RIGHT_PANE]->x,
1988 mwindow->theme->mcanvas_y +
1990 pane[TOP_RIGHT_PANE]->w,
1991 mwindow->theme->mcanvas_h -
1993 pane[TOP_LEFT_PANE]->resize_event(
1994 pane[TOP_LEFT_PANE]->x,
1995 pane[TOP_LEFT_PANE]->y,
1996 cursor_x - mwindow->theme->pane_w,
1997 cursor_y - mwindow->theme->pane_h);
1998 pane[TOP_RIGHT_PANE]->resize_event(
1999 mwindow->theme->mcanvas_x +
2001 mwindow->theme->mcanvas_y,
2002 mwindow->theme->mcanvas_x +
2003 mwindow->theme->mcanvas_w -
2005 cursor_y - mwindow->theme->pane_h);
2006 pane[BOTTOM_LEFT_PANE]->create_objects();
2007 pane[BOTTOM_RIGHT_PANE]->create_objects();
2010 if(vertical_panes())
2012 // create horizontal panes
2013 //printf("MWindowGUI::load_panes %d\n", __LINE__);
2014 pane[TOP_RIGHT_PANE] = new TimelinePane(mwindow,
2016 mwindow->theme->mcanvas_x +
2018 mwindow->theme->mcanvas_y,
2019 mwindow->theme->mcanvas_x +
2020 mwindow->theme->mcanvas_w -
2022 cursor_y - mwindow->theme->pane_h);
2023 pane[BOTTOM_RIGHT_PANE] = new TimelinePane(mwindow,
2025 pane[TOP_RIGHT_PANE]->x,
2026 mwindow->theme->mcanvas_y +
2028 pane[TOP_RIGHT_PANE]->w,
2029 mwindow->theme->mcanvas_h -
2031 pane[TOP_LEFT_PANE]->resize_event(
2032 pane[TOP_LEFT_PANE]->x,
2033 pane[TOP_LEFT_PANE]->y,
2034 cursor_x - mwindow->theme->pane_w,
2035 cursor_y - mwindow->theme->pane_h);
2036 pane[BOTTOM_LEFT_PANE]->resize_event(
2037 pane[TOP_LEFT_PANE]->x,
2038 mwindow->theme->mcanvas_y +
2040 mwindow->theme->mcanvas_x +
2041 mwindow->theme->mcanvas_w -
2042 cursor_x - mwindow->theme->pane_w,
2043 mwindow->theme->mcanvas_h -
2045 pane[TOP_RIGHT_PANE]->create_objects();
2046 pane[BOTTOM_RIGHT_PANE]->create_objects();
2053 //printf("MWindowGUI::load_panes %d\n", __LINE__);
2054 pane[TOP_LEFT_PANE]->resize_event(
2055 pane[TOP_LEFT_PANE]->x,
2056 pane[TOP_LEFT_PANE]->y,
2057 cursor_x - mwindow->theme->pane_w,
2058 cursor_y - mwindow->theme->pane_h);
2059 pane[TOP_RIGHT_PANE]->resize_event(
2060 mwindow->theme->mcanvas_x +
2062 mwindow->theme->mcanvas_y,
2063 mwindow->theme->mcanvas_x +
2064 mwindow->theme->mcanvas_w -
2066 cursor_y - mwindow->theme->pane_h);
2067 pane[BOTTOM_LEFT_PANE]->resize_event(
2068 pane[TOP_LEFT_PANE]->x,
2069 mwindow->theme->mcanvas_y +
2071 mwindow->theme->mcanvas_x +
2072 mwindow->theme->mcanvas_w -
2073 cursor_x - mwindow->theme->pane_w,
2074 mwindow->theme->mcanvas_h -
2076 pane[BOTTOM_RIGHT_PANE]->resize_event(
2077 pane[TOP_RIGHT_PANE]->x,
2078 mwindow->theme->mcanvas_y +
2080 pane[TOP_RIGHT_PANE]->w,
2081 mwindow->theme->mcanvas_h -
2090 if(pane[BOTTOM_LEFT_PANE]) delete pane[BOTTOM_LEFT_PANE];
2091 if(pane[BOTTOM_RIGHT_PANE]) delete pane[BOTTOM_RIGHT_PANE];
2092 pane[BOTTOM_LEFT_PANE] = 0;
2093 pane[BOTTOM_RIGHT_PANE] = 0;
2095 if(!pane[TOP_RIGHT_PANE])
2097 pane[TOP_RIGHT_PANE] = new TimelinePane(mwindow,
2099 mwindow->theme->mcanvas_x +
2101 mwindow->theme->mcanvas_y,
2102 mwindow->theme->mcanvas_x +
2103 mwindow->theme->mcanvas_w -
2105 mwindow->theme->mcanvas_h);
2106 pane[TOP_LEFT_PANE]->resize_event(
2107 mwindow->theme->mcanvas_x,
2108 mwindow->theme->mcanvas_y,
2109 cursor_x - mwindow->theme->pane_w,
2110 mwindow->theme->mcanvas_h);
2111 pane[TOP_RIGHT_PANE]->create_objects();
2115 pane[TOP_LEFT_PANE]->resize_event(
2116 mwindow->theme->mcanvas_x,
2117 mwindow->theme->mcanvas_y,
2118 cursor_x - mwindow->theme->pane_w,
2119 mwindow->theme->mcanvas_h);
2120 pane[TOP_RIGHT_PANE]->resize_event(
2121 mwindow->theme->mcanvas_x +
2123 pane[TOP_RIGHT_PANE]->y,
2124 mwindow->theme->mcanvas_x +
2125 mwindow->theme->mcanvas_w -
2127 mwindow->theme->mcanvas_h);
2135 if(pane[TOP_RIGHT_PANE]) delete pane[TOP_RIGHT_PANE];
2136 if(pane[BOTTOM_RIGHT_PANE]) delete pane[BOTTOM_RIGHT_PANE];
2137 pane[TOP_RIGHT_PANE] = 0;
2138 pane[BOTTOM_RIGHT_PANE] = 0;
2140 if(!pane[BOTTOM_LEFT_PANE])
2142 //printf("MWindowGUI::load_panes %d\n", __LINE__);
2143 pane[BOTTOM_LEFT_PANE] = new TimelinePane(mwindow,
2145 mwindow->theme->mcanvas_x,
2146 mwindow->theme->mcanvas_y +
2148 mwindow->theme->mcanvas_w,
2149 mwindow->theme->mcanvas_h -
2151 pane[TOP_LEFT_PANE]->resize_event(
2152 mwindow->theme->mcanvas_x,
2153 mwindow->theme->mcanvas_y,
2154 mwindow->theme->mcanvas_w,
2155 pane[BOTTOM_LEFT_PANE]->y -
2156 mwindow->theme->mcanvas_y -
2157 mwindow->theme->pane_h);
2158 pane[BOTTOM_LEFT_PANE]->create_objects();
2162 pane[TOP_LEFT_PANE]->resize_event(
2163 mwindow->theme->mcanvas_x,
2164 mwindow->theme->mcanvas_y,
2165 mwindow->theme->mcanvas_w,
2166 cursor_y - mwindow->theme->pane_h);
2167 pane[BOTTOM_LEFT_PANE]->resize_event(
2168 pane[BOTTOM_LEFT_PANE]->x,
2170 mwindow->theme->mcanvas_y,
2171 mwindow->theme->mcanvas_w,
2172 mwindow->theme->mcanvas_h -
2179 if(pane[TOP_RIGHT_PANE]) delete pane[TOP_RIGHT_PANE];
2180 if(pane[BOTTOM_RIGHT_PANE]) delete pane[BOTTOM_RIGHT_PANE];
2181 if(pane[BOTTOM_LEFT_PANE]) delete pane[BOTTOM_LEFT_PANE];
2182 pane[TOP_RIGHT_PANE] = 0;
2183 pane[BOTTOM_RIGHT_PANE] = 0;
2184 pane[BOTTOM_LEFT_PANE] = 0;
2185 pane[TOP_LEFT_PANE]->resize_event(
2186 mwindow->theme->mcanvas_x,
2187 mwindow->theme->mcanvas_y,
2188 mwindow->theme->mcanvas_w,
2189 mwindow->theme->mcanvas_h);
2192 update_pane_dividers();
2195 resource_thread->start_draw();
2198 void MWindowGUI::update_pane_dividers()
2201 if(horizontal_panes() || total_panes() == 4)
2203 int x = pane[TOP_RIGHT_PANE]->x - mwindow->theme->pane_w;
2204 int y = mwindow->theme->mcanvas_y;
2205 int h = mwindow->theme->mcanvas_h;
2209 add_subwindow(x_divider = new PaneDivider(
2210 mwindow, x, y, h, 1));
2211 x_divider->create_objects();
2215 x_divider->reposition_window(x, y, h);
2228 if(vertical_panes() || total_panes() == 4)
2230 int x = mwindow->theme->mcanvas_x;
2231 int y = pane[BOTTOM_LEFT_PANE]->y -
2232 mwindow->theme->pane_h;
2233 int w = mwindow->theme->mcanvas_w;
2236 add_subwindow(y_divider = new PaneDivider(
2237 mwindow, x, y, w, 0));
2238 y_divider->create_objects();
2242 y_divider->reposition_window(x, y, w);
2256 void MWindowGUI::draw_samplemovement()
2263 update_scrollbars(1);
2266 void MWindowGUI::draw_trackmovement()
2268 update_scrollbars(0);
2275 void MWindowGUI::update_mixers(Track *track, int v)
2277 for( int i=0; i<TOTAL_PANES; ++i ) {
2278 if( !pane[i] ) continue;
2279 PatchBay *patchbay = pane[i]->patchbay;
2280 if( !patchbay ) continue;
2281 for( int j=0; j<patchbay->patches.total; ++j ) {
2282 PatchGUI *patchgui = patchbay->patches.values[j];
2283 if( !patchgui->mix ) continue;
2284 if( !track || patchgui->track == track ) {
2285 patchgui->mix->update(v>=0 ? v :
2286 mwindow->mixer_track_active(patchgui->track));
2292 void MWindowGUI::stop_transport(const char *lock_msg)
2294 if( !mbuttons->transport->is_stopped() ) {
2295 if( lock_msg ) unlock_window();
2296 mbuttons->transport->handle_transport(STOP, 1, 0, 0);
2297 if( lock_msg ) lock_window(lock_msg);
2301 PaneButton::PaneButton(MWindow *mwindow, int x, int y)
2302 : BC_Button(x, y, mwindow->theme->get_image_set("pane"))
2304 this->mwindow = mwindow;
2307 int PaneButton::cursor_motion_event()
2309 if(get_top_level()->get_button_down() &&
2311 get_status() == BUTTON_DOWNHI &&
2314 // printf("PaneButton::cursor_motion_event %d\n", __LINE__);
2316 if(get_cursor_x() < 0 && !mwindow->gui->dragging_pane)
2318 mwindow->gui->start_x_pane_drag();
2321 if(get_cursor_y() < 0 && !mwindow->gui->dragging_pane)
2323 mwindow->gui->start_y_pane_drag();
2327 mwindow->gui->handle_pane_drag();
2329 int result = BC_Button::cursor_motion_event();
2333 int PaneButton::button_release_event()
2335 if( get_buttonpress() != WHEEL_DOWN && get_buttonpress() != WHEEL_UP )
2336 mwindow->gui->stop_pane_drag();
2337 int result = BC_Button::button_release_event();
2342 FFMpegToggle::FFMpegToggle(MWindow *mwindow, MButtons *mbuttons, int x, int y)
2343 : BC_Toggle(x, y, mwindow->theme->ffmpeg_toggle,
2344 mwindow->preferences->get_file_probe_armed("FFMPEG_Early") > 0 ? 1 : 0)
2346 this->mwindow = mwindow;
2347 this->mbuttons = mbuttons;
2348 set_tooltip(get_value() ? FFMPEG_EARLY_TIP : FFMPEG_LATE_TIP);
2351 FFMpegToggle::~FFMpegToggle()
2355 int FFMpegToggle::handle_event()
2357 int ffmpeg_early_probe = get_value();
2358 set_tooltip(ffmpeg_early_probe ? FFMPEG_EARLY_TIP : FFMPEG_LATE_TIP);
2359 mwindow->preferences->set_file_probe_armed("FFMPEG_Early", ffmpeg_early_probe);
2360 mwindow->preferences->set_file_probe_armed("FFMPEG_Late", !ffmpeg_early_probe);
2362 mwindow->show_warning(&mwindow->preferences->warn_indexes,
2363 _("Changing the base codecs may require rebuilding indexes."));