4 * Copyright (C) 1997-2014 Adam Williams <broadcast at earthling dot net>
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 #include "androidcontrol.h"
23 #include "awindowgui.h"
25 #include "bcdisplayinfo.h"
27 #include "bcsignals.h"
29 #include "cwindowgui.h"
31 #include "channelinfo.h"
34 #include "editpopup.h"
37 #include "edlsession.h"
38 #include "filesystem.h"
39 #include "keyframepopup.h"
42 #include "localsession.h"
43 #include "mainclock.h"
44 #include "maincursor.h"
46 #include "mainsession.h"
50 #include "mwindowgui.h"
52 #include "panedividers.h"
55 #include "pluginpopup.h"
56 #include "pluginset.h"
57 #include "preferences.h"
59 #include "recordgui.h"
60 #include "renderengine.h"
61 #include "resourcethread.h"
62 #include "samplescroll.h"
63 #include "shbtnprefs.h"
64 #include "statusbar.h"
67 #include "trackcanvas.h"
68 #include "trackscroll.h"
70 #include "transitionpopup.h"
71 #include "vwindowgui.h"
75 #define PANE_DRAG_MARGIN MAX(mwindow->theme->pane_w, mwindow->theme->pane_h)
78 // the main window uses its own private colormap for video
79 MWindowGUI::MWindowGUI(MWindow *mwindow)
80 : BC_Window(_(PROGRAM_NAME ": Program"),
81 mwindow->session->mwindow_x,
82 mwindow->session->mwindow_y,
83 mwindow->session->mwindow_w,
84 mwindow->session->mwindow_h,
91 this->mwindow = mwindow;
98 focused_pane = TOP_LEFT_PANE;
107 for(int i = 0; i < TOTAL_PANES; i++)
126 cwindow_remote_handler = 0;
127 record_remote_handler = 0;
132 MWindowGUI::~MWindowGUI()
134 delete android_control;
135 delete cwindow_remote_handler;
136 delete record_remote_handler;
137 delete remote_control;
138 delete keyvalue_popup;
139 // delete samplescroll;
140 // delete trackscroll;
141 for(int i = 0; i < TOTAL_PANES; i++)
142 if(pane[i]) delete pane[i];
144 delete render_engine;
145 delete resource_thread;
146 resource_pixmaps.remove_all_objects();
157 void MWindowGUI::get_scrollbars(int flush)
159 //int64_t h_needed = mwindow->edl->get_tracks_height(mwindow->theme);
160 //int64_t w_needed = mwindow->edl->get_tracks_width();
161 int need_xscroll = 0;
162 int need_yscroll = 0;
163 view_w = mwindow->theme->mcanvas_w;
164 view_h = mwindow->theme->mcanvas_h;
166 // Scrollbars are constitutive
167 need_xscroll = need_yscroll = 1;
168 view_h = mwindow->theme->mcanvas_h;
169 view_w = mwindow->theme->mcanvas_w;
171 // for(int i = 0; i < 2; i++)
173 // if(w_needed > view_w)
176 // view_h = mwindow->theme->mcanvas_h - SCROLL_SPAN;
181 // if(h_needed > view_h)
184 // view_w = mwindow->theme->mcanvas_w - SCROLL_SPAN;
189 //printf("MWindowGUI::get_scrollbars 1\n");
191 if(canvas && (view_w != canvas->get_w() || view_h != canvas->get_h()))
193 canvas->reposition_window(mwindow->theme->mcanvas_x,
194 mwindow->theme->mcanvas_y,
202 add_subwindow(samplescroll = new SampleScroll(mwindow,
204 mwindow->theme->mhscroll_x,
205 mwindow->theme->mhscroll_y,
206 mwindow->theme->mhscroll_w));
208 samplescroll->resize_event();
210 samplescroll->set_position(0);
214 if(samplescroll) delete samplescroll;
216 mwindow->edl->local_session->view_start = 0;
222 //printf("MWindowGUI::get_scrollbars 1.1 %p %p\n", this, canvas);
224 add_subwindow(trackscroll = new TrackScroll(mwindow,
226 mwindow->theme->mvscroll_x,
227 mwindow->theme->mvscroll_y,
228 mwindow->theme->mvscroll_h));
230 trackscroll->resize_event();
233 //printf("MWindowGUI::get_scrollbars 1.2\n");
234 trackscroll->update_length(mwindow->edl->get_tracks_height(mwindow->theme),
235 mwindow->edl->local_session->track_start,
238 //printf("MWindowGUI::get_scrollbars 1.3\n");
242 if(trackscroll) delete trackscroll;
244 mwindow->edl->local_session->track_start = 0;
247 if(flush) this->flush();
252 void MWindowGUI::create_objects()
256 resource_thread = new ResourceThread(mwindow, this);
257 resource_thread->create_objects();
260 if(debug) printf("MWindowGUI::create_objects %d\n", __LINE__);
261 set_icon(mwindow->theme->get_image("mwindow_icon"));
262 remote_control = new RemoteControl(this);
263 cwindow_remote_handler = new CWindowRemoteHandler(remote_control);
264 record_remote_handler = new RecordRemoteHandler(remote_control);
265 mwindow->reset_android_remote();
267 if(debug) printf("MWindowGUI::create_objects %d\n", __LINE__);
269 int x = get_w() - MainShBtns::calculate_w(0);
270 add_subwindow(mainmenu = new MainMenu(mwindow, this, x));
271 mainmenu->create_objects();
272 add_subwindow(mainshbtns = new MainShBtns(mwindow, x, -1));
273 mainshbtns->load(mwindow->preferences);
274 mwindow->theme->get_mwindow_sizes(this, get_w(), get_h());
275 mwindow->theme->draw_mwindow_bg(this);
276 if(debug) printf("MWindowGUI::create_objects %d\n", __LINE__);
278 add_subwindow(mbuttons = new MButtons(mwindow, this));
279 mbuttons->create_objects();
280 int x1 = mbuttons->get_x() + mbuttons->get_w(), y1 = mbuttons->get_y()+2;
281 add_subwindow(proxy_toggle = new ProxyToggle(mwindow, mbuttons, x1, y1));
282 x1 += proxy_toggle->get_w() + 3;
283 add_subwindow(ffmpeg_toggle = new FFMpegToggle(mwindow, mbuttons, x1, y1));
285 pane[TOP_LEFT_PANE] = new TimelinePane(mwindow,
287 mwindow->theme->mcanvas_x,
288 mwindow->theme->mcanvas_y,
289 mwindow->theme->mcanvas_w,
290 mwindow->theme->mcanvas_h);
291 pane[TOP_LEFT_PANE]->create_objects();
293 // add_subwindow(timebar = new MTimeBar(mwindow,
295 // mwindow->theme->mtimebar_x,
296 // mwindow->theme->mtimebar_y,
297 // mwindow->theme->mtimebar_w,
298 // mwindow->theme->mtimebar_h));
299 // timebar->create_objects();
301 // if(debug) printf("MWindowGUI::create_objects %d\n", __LINE__);
302 // add_subwindow(patchbay = new PatchBay(mwindow, this));
303 // patchbay->create_objects();
305 // if(debug) printf("MWindowGUI::create_objects %d\n", __LINE__);
306 // get_scrollbars(0);
308 // if(debug) printf("MWindowGUI::create_objects %d\n", __LINE__);
309 // mwindow->gui->add_subwindow(canvas = new TrackCanvas(mwindow, this));
310 // canvas->create_objects();
313 if(debug) printf("MWindowGUI::create_objects %d\n", __LINE__);
314 add_subwindow(zoombar = new ZoomBar(mwindow, this));
315 zoombar->create_objects();
318 if(debug) printf("MWindowGUI::create_objects %d\n", __LINE__);
319 add_subwindow(statusbar = new StatusBar(mwindow, this));
320 statusbar->create_objects();
324 if(debug) printf("MWindowGUI::create_objects %d\n", __LINE__);
325 add_subwindow(mainclock = new MainClock(mwindow,
326 mwindow->theme->mclock_x, mwindow->theme->mclock_y,
327 mwindow->theme->mclock_w));
328 if(debug) printf("MWindowGUI::create_objects %d\n", __LINE__);
329 mainclock->update(0);
333 // if(debug) printf("MWindowGUI::create_objects %d\n", __LINE__);
334 // cursor = new MainCursor(mwindow, this);
335 // cursor->create_objects();
338 if(debug) printf("MWindowGUI::create_objects %d\n", __LINE__);
339 add_subwindow(edit_menu = new EditPopup(mwindow, this));
340 edit_menu->create_objects();
343 if(debug) printf("MWindowGUI::create_objects %d\n", __LINE__);
344 add_subwindow(plugin_menu = new PluginPopup(mwindow, this));
345 plugin_menu->create_objects();
348 if(debug) printf("MWindowGUI::create_objects %d\n", __LINE__);
349 add_subwindow(keyframe_menu = new KeyframePopup(mwindow, this));
350 keyframe_menu->create_objects();
351 add_subwindow(keyframe_hide = new KeyframeHidePopup(mwindow, this));
352 keyframe_hide->create_objects();
355 if(debug) printf("MWindowGUI::create_objects %d\n", __LINE__);
356 add_subwindow(transition_menu = new TransitionPopup(mwindow, this));
357 transition_menu->create_objects();
360 channel_info = new ChannelInfo(mwindow);
362 #ifdef HAVE_COMMERCIAL
363 db_window = new DbWindow(mwindow);
365 swindow = new SWindow(mwindow);
367 if(debug) printf("MWindowGUI::create_objects %d\n", __LINE__);
369 add_subwindow(pane_button = new PaneButton(mwindow,
370 get_w() - mwindow->theme->get_image_set("pane")[0]->get_w(),
371 mwindow->theme->mzoom_y + 1 - mwindow->theme->get_image_set("pane")[0]->get_h()));
373 pane[TOP_LEFT_PANE]->canvas->activate();
375 if(debug) printf("MWindowGUI::create_objects %d\n", __LINE__);
378 void MWindowGUI::redraw_time_dependancies()
380 zoombar->redraw_time_dependancies();
381 for(int i = 0; i < TOTAL_PANES; i++)
382 if(pane[i] && pane[i]->timebar) pane[i]->timebar->update(0);
383 mainclock->update(mwindow->edl->local_session->get_selectionstart(1));
386 int MWindowGUI::focus_in_event()
388 for(int i = 0; i < TOTAL_PANES; i++)
389 if(pane[i]) pane[i]->cursor->focus_in_event();
393 int MWindowGUI::focus_out_event()
395 for(int i = 0; i < TOTAL_PANES; i++)
396 if(pane[i]) pane[i]->cursor->focus_out_event();
401 int MWindowGUI::resize_event(int w, int h)
403 //printf("MWindowGUI::resize_event %d\n", __LINE__);
404 mwindow->session->mwindow_w = w;
405 mwindow->session->mwindow_h = h;
406 int x = w - MainShBtns::calculate_w(0);
407 mainmenu->resize_event(x, mainmenu->get_h());
408 mainshbtns->reposition_window(x, -1);
409 mwindow->theme->get_mwindow_sizes(this, w, h);
410 mwindow->theme->draw_mwindow_bg(this);
411 mbuttons->resize_event();
412 int x1 = mbuttons->get_x() + mbuttons->get_w(), y1 = mbuttons->get_y()+2;
413 proxy_toggle->reposition_window(x1, y1);
414 x1 += proxy_toggle->get_w() + 3;
415 ffmpeg_toggle->reposition_window(x1, y1);
416 statusbar->resize_event();
417 zoombar->resize_event();
419 resource_thread->stop_draw(1);
421 if(total_panes() > 1)
423 if(horizontal_panes())
425 // printf("MWindowGUI::resize_event %d %d %d\n",
427 // pane[TOP_RIGHT_PANE]->x,
428 // mwindow->theme->mcanvas_w -
429 // BC_ScrollBar::get_span(SCROLL_VERT) -
430 // PANE_DRAG_MARGIN);
431 if(pane[TOP_RIGHT_PANE]->x >= mwindow->theme->mcanvas_w -
432 BC_ScrollBar::get_span(SCROLL_VERT) -
435 delete_x_pane(pane[TOP_RIGHT_PANE]->x);
436 mwindow->edl->local_session->x_pane = -1;
442 if(pane[BOTTOM_LEFT_PANE]->y >= mwindow->theme->mzoom_y -
443 BC_ScrollBar::get_span(SCROLL_HORIZ) -
446 delete_y_pane(pane[BOTTOM_LEFT_PANE]->y);
447 mwindow->edl->local_session->y_pane = -1;
452 if(pane[TOP_RIGHT_PANE]->x >= mwindow->theme->mcanvas_w -
453 BC_ScrollBar::get_span(SCROLL_VERT) -
456 delete_x_pane(pane[TOP_RIGHT_PANE]->x);
457 mwindow->edl->local_session->x_pane = -1;
460 if(pane[BOTTOM_LEFT_PANE]->y >= mwindow->theme->mzoom_y -
461 BC_ScrollBar::get_span(SCROLL_HORIZ) -
464 delete_y_pane(pane[BOTTOM_LEFT_PANE]->y);
465 mwindow->edl->local_session->y_pane = -1;
470 if(total_panes() == 1)
472 pane[TOP_LEFT_PANE]->resize_event(
473 mwindow->theme->mcanvas_x,
474 mwindow->theme->mcanvas_y,
475 mwindow->theme->mcanvas_w,
476 mwindow->theme->mcanvas_h);
479 if(horizontal_panes())
481 pane[TOP_LEFT_PANE]->resize_event(
482 pane[TOP_LEFT_PANE]->x,
483 pane[TOP_LEFT_PANE]->y,
484 pane[TOP_LEFT_PANE]->w,
485 mwindow->theme->mcanvas_h);
486 pane[TOP_RIGHT_PANE]->resize_event(
487 pane[TOP_RIGHT_PANE]->x,
488 pane[TOP_RIGHT_PANE]->y,
489 mwindow->theme->mcanvas_w - pane[TOP_RIGHT_PANE]->x,
490 mwindow->theme->mcanvas_h);
495 pane[TOP_LEFT_PANE]->resize_event(
496 pane[TOP_LEFT_PANE]->x,
497 pane[TOP_LEFT_PANE]->y,
498 mwindow->theme->mcanvas_w,
499 pane[TOP_LEFT_PANE]->h);
500 pane[BOTTOM_LEFT_PANE]->resize_event(
501 pane[BOTTOM_LEFT_PANE]->x,
502 pane[BOTTOM_LEFT_PANE]->y,
503 mwindow->theme->mcanvas_w,
504 mwindow->theme->mcanvas_y +
505 mwindow->theme->mcanvas_h -
506 pane[BOTTOM_LEFT_PANE]->y);
510 pane[TOP_LEFT_PANE]->resize_event(
511 pane[TOP_LEFT_PANE]->x,
512 pane[TOP_LEFT_PANE]->y,
513 pane[TOP_LEFT_PANE]->w,
514 pane[TOP_LEFT_PANE]->h);
515 pane[TOP_RIGHT_PANE]->resize_event(
516 pane[TOP_RIGHT_PANE]->x,
517 pane[TOP_RIGHT_PANE]->y,
518 mwindow->theme->mcanvas_w - pane[TOP_RIGHT_PANE]->x,
519 pane[TOP_RIGHT_PANE]->h);
520 pane[BOTTOM_LEFT_PANE]->resize_event(
521 pane[BOTTOM_LEFT_PANE]->x,
522 pane[BOTTOM_LEFT_PANE]->y,
523 pane[BOTTOM_LEFT_PANE]->w,
524 mwindow->theme->mcanvas_y +
525 mwindow->theme->mcanvas_h -
526 pane[BOTTOM_LEFT_PANE]->y);
527 pane[BOTTOM_RIGHT_PANE]->resize_event(
528 pane[BOTTOM_RIGHT_PANE]->x,
529 pane[BOTTOM_RIGHT_PANE]->y,
530 mwindow->theme->mcanvas_w -
531 pane[BOTTOM_RIGHT_PANE]->x,
532 mwindow->theme->mcanvas_y +
533 mwindow->theme->mcanvas_h -
534 pane[BOTTOM_RIGHT_PANE]->y);
537 update_pane_dividers();
538 pane_button->reposition_window(w - mwindow->theme->get_image_set("pane")[0]->get_w(),
539 mwindow->theme->mzoom_y + 1 - mwindow->theme->get_image_set("pane")[0]->get_h());
540 resource_thread->start_draw();
546 int MWindowGUI::total_panes()
549 for(int i = 0; i < TOTAL_PANES; i++)
554 int MWindowGUI::vertical_panes()
556 return total_panes() == 2 &&
557 pane[TOP_LEFT_PANE] &&
558 pane[BOTTOM_LEFT_PANE];
561 int MWindowGUI::horizontal_panes()
563 return total_panes() == 2 &&
564 pane[TOP_LEFT_PANE] &&
565 pane[TOP_RIGHT_PANE];
568 TimelinePane* MWindowGUI::get_focused_pane()
570 if(pane[focused_pane]) return pane[focused_pane];
571 for(int i = 0; i < TOTAL_PANES; i++)
573 if(pane[i]) return pane[i];
578 void MWindowGUI::activate_timeline()
580 if(pane[focused_pane])
582 pane[focused_pane]->activate();
586 for(int i = 0; i < TOTAL_PANES; i++)
597 void MWindowGUI::deactivate_timeline()
599 for(int i = 0; i < TOTAL_PANES; i++)
603 pane[i]->canvas->deactivate();
608 void MWindowGUI::update_title(char *path)
611 char filename[BCTEXTLEN], string[BCTEXTLEN];
612 fs.extract_name(filename, path);
613 sprintf(string, _(PROGRAM_NAME ": %s"), filename);
615 //printf("MWindowGUI::update_title %s\n", string);
619 void MWindowGUI::draw_overlays(int flash_it)
621 for(int i = 0; i < TOTAL_PANES; i++)
625 pane[i]->canvas->draw_overlays();
626 if(flash_it) pane[i]->canvas->flash();
631 void MWindowGUI::update_timebar(int flush_it)
633 for(int i = 0; i < TOTAL_PANES; i++)
635 if(pane[i] && pane[i]->timebar)
637 pane[i]->timebar->update(flush_it);
642 void MWindowGUI::update_timebar_highlights()
644 for(int i = 0; i < TOTAL_PANES; i++)
646 if(pane[i] && pane[i]->timebar)
648 pane[i]->timebar->update_highlights();
654 void MWindowGUI::update_patchbay()
656 for(int i = 0; i < TOTAL_PANES; i++)
658 if(pane[i] && pane[i]->patchbay)
660 pane[i]->patchbay->update();
665 void MWindowGUI::update_proxy_toggle()
667 if( mwindow->edl->session->proxy_scale == 1 &&
668 mwindow->edl->session->proxy_disabled_scale == 1 )
669 proxy_toggle->hide_window();
671 proxy_toggle->show_window();
674 void MWindowGUI::update_plugintoggles()
676 for(int i = 0; i < TOTAL_PANES; i++)
680 pane[i]->canvas->refresh_plugintoggles();
686 void MWindowGUI::draw_indexes(Indexable *indexable)
688 for(int i = 0; i < TOTAL_PANES; i++)
692 pane[i]->canvas->draw_indexes(indexable);
697 void MWindowGUI::draw_canvas(int mode /* = 0 */, int hide_cursor /* = 1 */)
699 if(mode != IGNORE_THREAD)
701 resource_thread->stop_draw(1);
705 for(int i = 0; i < TOTAL_PANES; i++)
709 pane[i]->canvas->draw(mode, hide_cursor);
714 if(mode != IGNORE_THREAD)
716 resource_thread->start_draw();
721 void MWindowGUI::flash_canvas(int flush)
723 for(int i = 0; i < TOTAL_PANES; i++)
727 pane[i]->canvas->flash(flush);
732 int MWindowGUI::show_window(int flush)
734 int ret = BC_WindowBase::show_window(flush);
735 update_proxy_toggle();
739 void MWindowGUI::draw_cursor(int do_plugintoggles)
741 for(int i = 0; i < TOTAL_PANES; i++)
745 pane[i]->cursor->draw(do_plugintoggles);
750 void MWindowGUI::show_cursor(int do_plugintoggles)
752 for(int i = 0; i < TOTAL_PANES; i++)
756 pane[i]->cursor->show(do_plugintoggles);
761 void MWindowGUI::hide_cursor(int do_plugintoggles)
763 for(int i = 0; i < TOTAL_PANES; i++)
767 pane[i]->cursor->hide(do_plugintoggles);
772 void MWindowGUI::update_cursor()
774 for(int i = 0; i < TOTAL_PANES; i++)
778 pane[i]->cursor->update();
783 void MWindowGUI::set_playing_back(int value)
785 for(int i = 0; i < TOTAL_PANES; i++)
789 pane[i]->cursor->playing_back = value;
794 void MWindowGUI::update_scrollbars(int flush)
796 for(int i = 0; i < TOTAL_PANES; i++)
800 pane[i]->update(1, 0, 0, 0);
803 if(flush) this->flush();
806 void MWindowGUI::reset_meters()
808 for(int i = 0; i < TOTAL_PANES; i++)
810 if(pane[i] && pane[i]->patchbay)
812 pane[i]->patchbay->reset_meters();
817 void MWindowGUI::stop_meters()
819 for(int i = 0; i < TOTAL_PANES; i++)
821 if(pane[i] && pane[i]->patchbay)
823 pane[i]->patchbay->stop_meters();
828 void MWindowGUI::update_meters(ArrayList<double> *module_levels)
830 for(int i = 0; i < TOTAL_PANES; i++)
832 if(pane[i] && pane[i]->patchbay)
834 pane[i]->patchbay->update_meters(module_levels);
839 void MWindowGUI::set_editing_mode(int flush)
841 for(int i = 0; i < TOTAL_PANES; i++)
845 pane[i]->canvas->update_cursor(flush);
850 void MWindowGUI::set_meter_format(int mode, int min, int max)
852 for(int i = 0; i < TOTAL_PANES; i++)
854 if(pane[i] && pane[i]->patchbay)
856 pane[i]->patchbay->set_meter_format(mode, min, max);
861 void MWindowGUI::update(int scrollbars,
870 if(debug) PRINT_TRACE
874 mwindow->edl->tracks->update_y_pixels(mwindow->theme);
876 if(do_canvas && do_canvas != IGNORE_THREAD)
878 resource_thread->stop_draw(1);
881 for(int i = 0; i < TOTAL_PANES; i++)
883 if(pane[i]) pane[i]->update(scrollbars,
889 if(do_canvas && do_canvas != IGNORE_THREAD)
891 resource_thread->start_draw();
894 // if(scrollbars) this->get_scrollbars(0);
895 // if(timebar) this->timebar->update(0);
896 if(zoombar) this->zoombar->update();
897 // if(patchbay) this->patchbay->update();
898 if(clock) this->mainclock->update(
899 mwindow->edl->local_session->get_selectionstart(1));
900 if(debug) PRINT_TRACE
906 // this->canvas->draw(do_canvas);
907 // this->cursor->show();
908 // this->canvas->flash(0);
909 // Activate causes the menubar to deactivate. Don't want this for
911 // if(canvas != IGNORE_THREAD) this->canvas->activate();
913 if(debug) PRINT_TRACE
917 if(buttonbar) mbuttons->update();
918 if(debug) PRINT_TRACE
920 // Can't age if the cache called this to draw missing picons
921 // or the GUI is updating the status of the draw toggle.
922 if(do_canvas != FORCE_REDRAW && do_canvas != IGNORE_THREAD)
925 mwindow->age_caches();
926 lock_window("MWindowGUI::update");
930 if(debug) PRINT_TRACE
933 int MWindowGUI::visible(int64_t x1, int64_t x2, int64_t view_x1, int64_t view_x2)
935 return (x1 >= view_x1 && x1 < view_x2) ||
936 (x2 > view_x1 && x2 <= view_x2) ||
937 (x1 <= view_x1 && x2 >= view_x2);
941 void MWindowGUI::show_message(const char *message, int color)
943 statusbar->show_message(message, color);
946 void MWindowGUI::update_default_message()
948 statusbar->update_default_message();
951 void MWindowGUI::reset_default_message()
953 statusbar->reset_default_message();
956 void MWindowGUI::default_message()
958 statusbar->default_message();
961 // Drag motion called from other window
962 int MWindowGUI::drag_motion()
964 if(get_hidden()) return 0;
966 Track *over_track = 0;
968 PluginSet *over_pluginset = 0;
969 Plugin *over_plugin = 0;
974 drag_popup->cursor_motion_event();
978 // there's no point in drawing highlights has until drag operation has been set
979 if (!mwindow->session->current_operation)
982 for(int i = 0; i < TOTAL_PANES; i++)
984 if(pane[i]) pane[i]->canvas->drag_motion(
991 if(mwindow->session->track_highlighted != over_track)
993 mwindow->session->track_highlighted = over_track;
997 if(mwindow->session->edit_highlighted != over_edit)
999 mwindow->session->edit_highlighted = over_edit;
1003 if(mwindow->session->pluginset_highlighted != over_pluginset)
1005 mwindow->session->pluginset_highlighted = over_pluginset;
1009 if(mwindow->session->plugin_highlighted != over_plugin)
1011 mwindow->session->plugin_highlighted = over_plugin;
1015 if( mwindow->session->current_operation == DRAG_ASSET ||
1016 mwindow->session->current_operation == DRAG_EDIT ||
1017 mwindow->session->current_operation == DRAG_AEFFECT_COPY ||
1018 mwindow->session->current_operation == DRAG_VEFFECT_COPY )
1024 // printf("drag_motion %d %d over_track=%p over_edit=%p\n",
1031 lock_window("MWindowGUI::drag_motion");
1038 int MWindowGUI::drag_stop()
1040 if(get_hidden()) return 0;
1041 int result = 0, redraw = 0;
1043 for(int i = 0; i < TOTAL_PANES; i++)
1045 if(pane[i]) result |= pane[i]->canvas->drag_stop(
1048 mwindow->edl->optimize();
1050 // since we don't have subwindows we have to terminate any drag operation
1053 if (mwindow->session->track_highlighted
1054 || mwindow->session->edit_highlighted
1055 || mwindow->session->plugin_highlighted
1056 || mwindow->session->pluginset_highlighted)
1058 mwindow->session->track_highlighted = 0;
1059 mwindow->session->edit_highlighted = 0;
1060 mwindow->session->plugin_highlighted = 0;
1061 mwindow->session->pluginset_highlighted = 0;
1062 mwindow->session->current_operation = NO_OPERATION;
1066 //printf("MWindowGUI::drag_stop %d %d\n", redraw, mwindow->session->current_operation);
1069 mwindow->edl->tracks->update_y_pixels(mwindow->theme);
1070 update_scrollbars(0);
1085 void MWindowGUI::default_positions()
1087 //printf("MWindowGUI::default_positions 1\n");
1088 VWindow *vwindow = mwindow->vwindows.size() > DEFAULT_VWINDOW ?
1089 mwindow->vwindows.get(DEFAULT_VWINDOW) : 0;
1090 if( vwindow && !vwindow->is_running() ) vwindow = 0;
1091 if( vwindow ) vwindow->gui->lock_window("MWindowGUI::default_positions");
1092 mwindow->cwindow->gui->lock_window("MWindowGUI::default_positions");
1093 mwindow->awindow->gui->lock_window("MWindowGUI::default_positions");
1095 // printf("MWindowGUI::default_positions 1 %d %d %d %d\n", mwindow->session->vwindow_x,
1096 // mwindow->session->vwindow_y,
1097 // mwindow->session->vwindow_w,
1098 // mwindow->session->vwindow_h);
1099 reposition_window(mwindow->session->mwindow_x,
1100 mwindow->session->mwindow_y,
1101 mwindow->session->mwindow_w,
1102 mwindow->session->mwindow_h);
1103 if( vwindow ) vwindow->gui->reposition_window(mwindow->session->vwindow_x,
1104 mwindow->session->vwindow_y,
1105 mwindow->session->vwindow_w,
1106 mwindow->session->vwindow_h);
1107 mwindow->cwindow->gui->reposition_window(mwindow->session->cwindow_x,
1108 mwindow->session->cwindow_y,
1109 mwindow->session->cwindow_w,
1110 mwindow->session->cwindow_h);
1111 mwindow->awindow->gui->reposition_window(mwindow->session->awindow_x,
1112 mwindow->session->awindow_y,
1113 mwindow->session->awindow_w,
1114 mwindow->session->awindow_h);
1115 //printf("MWindowGUI::default_positions 1\n");
1117 resize_event(mwindow->session->mwindow_w,
1118 mwindow->session->mwindow_h);
1119 //printf("MWindowGUI::default_positions 1\n");
1120 if( vwindow ) vwindow->gui->resize_event(mwindow->session->vwindow_w,
1121 mwindow->session->vwindow_h);
1122 //printf("MWindowGUI::default_positions 1\n");
1123 mwindow->cwindow->gui->resize_event(mwindow->session->cwindow_w,
1124 mwindow->session->cwindow_h);
1125 //printf("MWindowGUI::default_positions 1\n");
1126 mwindow->awindow->gui->resize_event(mwindow->session->awindow_w,
1127 mwindow->session->awindow_h);
1129 //printf("MWindowGUI::default_positions 1\n");
1132 if( vwindow ) vwindow->gui->flush();
1133 mwindow->cwindow->gui->flush();
1134 mwindow->awindow->gui->flush();
1136 if( vwindow ) vwindow->gui->unlock_window();
1137 mwindow->cwindow->gui->unlock_window();
1138 mwindow->awindow->gui->unlock_window();
1139 //printf("MWindowGUI::default_positions 2\n");
1143 int MWindowGUI::button_release_event()
1145 if( keyvalue_popup ) {
1146 delete keyvalue_popup; keyvalue_popup = 0;
1152 int MWindowGUI::repeat_event(int64_t duration)
1154 // if(duration == 100)
1155 // mwindow->sync_parameters(CHANGE_ALL);
1157 for(int i = 0; i < TOTAL_PANES; i++)
1159 if(pane[i]) result = pane[i]->cursor->repeat_event(duration);
1165 int MWindowGUI::translation_event()
1167 //printf("MWindowGUI::translation_event 1 %d %d\n", get_x(), get_y());
1168 mwindow->session->mwindow_x = get_x();
1169 mwindow->session->mwindow_y = get_y();
1174 int MWindowGUI::save_defaults(BC_Hash *defaults)
1176 defaults->update("MWINDOWWIDTH", get_w());
1177 defaults->update("MWINDOWHEIGHT", get_h());
1178 mainmenu->save_defaults(defaults);
1179 BC_WindowBase::save_defaults(defaults);
1183 int MWindowGUI::keypress_event()
1185 //printf("MWindowGUI::keypress_event 1 %d\n", get_keypress());
1186 int result = mbuttons->keypress_event();
1187 if( result ) return result;
1189 Track *this_track = 0;
1191 switch(get_keypress()) {
1193 mwindow->toggle_editing_mode();
1198 if( alt_down() ) break;
1199 stop_transport("MWindowGUI::keypress_event 1");
1200 mwindow->nearest_plugin_keyframe(shift_down(),
1201 !ctrl_down() ? PLAY_FORWARD : PLAY_REVERSE);
1205 case '1': case '2': case '3': case '4':
1206 case '5': case '6': case '7': case '8':
1207 if( !alt_down() || shift_down() ) break;
1208 if( !mwindow->select_asset(get_keypress()-'1',1) )
1213 if( !ctrl_down() ) {
1215 stop_transport("MWindowGUI::keypress_event 1");
1216 mwindow->prev_edit_handle(shift_down());
1219 mwindow->move_left();
1225 if( !ctrl_down() && !alt_down() ) {
1226 mwindow->move_left();
1232 if( !ctrl_down() ) {
1234 stop_transport("MWindowGUI::keypress_event 2");
1235 mwindow->next_edit_handle(shift_down());
1238 mwindow->move_right();
1244 if( !ctrl_down() && !alt_down() ) {
1245 mwindow->move_right();
1251 if( ctrl_down() && !alt_down() )
1252 mwindow->expand_y();
1253 else if( !ctrl_down() && alt_down() )
1254 mwindow->expand_autos(0,1,1);
1255 else if( ctrl_down() && alt_down() )
1256 mwindow->expand_autos(1,1,1);
1258 mwindow->expand_sample();
1263 if( ctrl_down() && !alt_down() )
1264 mwindow->zoom_in_y();
1265 else if( !ctrl_down() && alt_down() )
1266 mwindow->shrink_autos(0,1,1);
1267 else if( ctrl_down() && alt_down() )
1268 mwindow->shrink_autos(1,1,1);
1270 mwindow->zoom_in_sample();
1278 mwindow->expand_t();
1284 mwindow->move_down();
1286 mwindow->zoom_in_t();
1292 for( int i=0; i<TOTAL_PANES; ++i ) {
1293 if( !pane[i] ) continue;
1294 if( (this_track = pane[i]->over_track()) != 0 ) break;
1295 if( (this_track = pane[i]->over_patchbay()) != 0 ) break;
1298 if( get_keypress() == TAB ) { // Switch the record button
1300 this_track->record = !this_track->record ? 1 : 0;
1303 int total_selected = mwindow->edl->tracks->total_of(Tracks::RECORD);
1304 // all selected if nothing previously selected or
1305 // if this patch was previously the only one selected and armed
1306 int selected = !total_selected || (total_selected == 1 &&
1307 this_track && this_track->record ) ? 1 : 0;
1308 mwindow->edl->tracks->select_all(Tracks::RECORD, selected);
1309 if( !selected && this_track ) this_track->record = 1;
1312 update(0, 1, 0, 0, 1, 0, 1);
1314 mwindow->cwindow->update(0, 1, 1);
1315 lock_window("MWindowGUI::keypress_event 3");
1332 resend_event(mwindow->cwindow->gui);
1336 // since things under cursor have changed...
1338 cursor_motion_event();
1343 int MWindowGUI::keyboard_listener(BC_WindowBase *wp)
1345 return key_listener(wp->get_keypress());
1348 int MWindowGUI::key_listener(int key)
1353 if( !record->running() )
1356 record->record_gui->interrupt_thread->start(0);
1363 channel_info->toggle_scan();
1367 if( !remote_control->deactivate() )
1368 remote_control->activate();
1378 void MWindowGUI::use_android_remote(int on)
1381 delete android_control;
1382 android_control = 0;
1385 if( android_control ) return;
1386 android_control = new AndroidControl(this);
1389 int MWindowGUI::close_event()
1395 void MWindowGUI::stop_drawing()
1397 resource_thread->stop_draw(1);
1400 int MWindowGUI::menu_w()
1402 return mainmenu->get_w();
1405 int MWindowGUI::menu_h()
1407 return mainmenu->get_h();
1410 void MWindowGUI::start_x_pane_drag()
1414 x_pane_drag = new BC_Popup(this,
1415 get_abs_cursor_x(0) - mwindow->theme->pane_w,
1416 BC_DisplayInfo::get_top_border() +
1418 mwindow->theme->mcanvas_y,
1419 mwindow->theme->pane_w,
1420 mwindow->theme->mcanvas_h,
1421 mwindow->theme->drag_pane_color);
1422 x_pane_drag->draw_3segmentv(0,
1424 x_pane_drag->get_h(),
1425 mwindow->theme->get_image_set("xpane")[BUTTON_DOWNHI]);
1426 x_pane_drag->flash(1);
1431 void MWindowGUI::start_y_pane_drag()
1435 //printf("MWindowGUI::start_y_pane_drag %d %d %d\n", __LINE__, get_x(), get_y());
1436 y_pane_drag = new BC_Popup(this,
1437 BC_DisplayInfo::get_left_border() +
1439 mwindow->theme->mcanvas_x,
1440 get_abs_cursor_y(0) - mwindow->theme->pane_h,
1441 mwindow->theme->mcanvas_w,
1442 mwindow->theme->pane_h,
1443 mwindow->theme->drag_pane_color);
1444 y_pane_drag->draw_3segmenth(0,
1446 y_pane_drag->get_w(),
1447 mwindow->theme->get_image_set("ypane")[BUTTON_DOWNHI]);
1448 y_pane_drag->flash(1);
1453 void MWindowGUI::handle_pane_drag()
1459 x_pane_drag->reposition_window(
1460 get_abs_cursor_x(0) - mwindow->theme->pane_w,
1461 x_pane_drag->get_y());
1466 y_pane_drag->reposition_window(
1467 y_pane_drag->get_x(),
1468 get_abs_cursor_y(0) - mwindow->theme->pane_h);
1474 void MWindowGUI::create_x_pane(int cursor_x)
1476 if(total_panes() == 1)
1478 // create a horizontal pane
1479 // do this 1st so the resize_event knows there are 2 panes
1480 mwindow->edl->local_session->view_start[TOP_RIGHT_PANE] =
1481 mwindow->edl->local_session->view_start[TOP_LEFT_PANE] +
1483 mwindow->theme->patchbay_w;
1484 pane[TOP_RIGHT_PANE] = new TimelinePane(mwindow,
1486 mwindow->theme->mcanvas_x +
1488 mwindow->theme->mcanvas_y,
1489 mwindow->theme->mcanvas_x +
1490 mwindow->theme->mcanvas_w -
1492 mwindow->theme->mcanvas_h);
1493 pane[TOP_LEFT_PANE]->resize_event(
1494 mwindow->theme->mcanvas_x,
1495 mwindow->theme->mcanvas_y,
1496 cursor_x - mwindow->theme->pane_w,
1497 mwindow->theme->mcanvas_h);
1498 pane[TOP_RIGHT_PANE]->create_objects();
1501 if(vertical_panes())
1503 // create 2 horizontal panes
1504 mwindow->edl->local_session->track_start[TOP_RIGHT_PANE] =
1505 mwindow->edl->local_session->track_start[TOP_LEFT_PANE];
1506 mwindow->edl->local_session->track_start[BOTTOM_RIGHT_PANE] =
1507 mwindow->edl->local_session->track_start[BOTTOM_LEFT_PANE];
1508 mwindow->edl->local_session->view_start[TOP_RIGHT_PANE] =
1509 mwindow->edl->local_session->view_start[BOTTOM_RIGHT_PANE] =
1510 mwindow->edl->local_session->view_start[TOP_LEFT_PANE] +
1512 mwindow->theme->patchbay_w;
1513 pane[TOP_RIGHT_PANE] = new TimelinePane(mwindow,
1515 mwindow->theme->mcanvas_x +
1517 pane[TOP_LEFT_PANE]->y,
1518 mwindow->theme->mcanvas_x +
1519 mwindow->theme->mcanvas_w -
1521 pane[TOP_LEFT_PANE]->h);
1522 pane[BOTTOM_RIGHT_PANE] = new TimelinePane(mwindow,
1524 mwindow->theme->mcanvas_x +
1526 pane[BOTTOM_LEFT_PANE]->y,
1527 mwindow->theme->mcanvas_x +
1528 mwindow->theme->mcanvas_w -
1530 pane[BOTTOM_LEFT_PANE]->h);
1531 pane[TOP_LEFT_PANE]->resize_event(
1532 pane[TOP_LEFT_PANE]->x,
1533 pane[TOP_LEFT_PANE]->y,
1534 cursor_x - mwindow->theme->pane_w,
1535 pane[TOP_LEFT_PANE]->h);
1536 pane[BOTTOM_LEFT_PANE]->resize_event(
1537 pane[BOTTOM_LEFT_PANE]->x,
1538 pane[BOTTOM_LEFT_PANE]->y,
1539 cursor_x - mwindow->theme->pane_w,
1540 pane[BOTTOM_LEFT_PANE]->h);
1541 pane[TOP_RIGHT_PANE]->create_objects();
1542 pane[BOTTOM_RIGHT_PANE]->create_objects();
1545 if(horizontal_panes())
1547 // resize a horizontal pane
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 pane[TOP_LEFT_PANE]->resize_event(
1554 mwindow->theme->mcanvas_x,
1555 mwindow->theme->mcanvas_y,
1556 cursor_x - mwindow->theme->pane_w,
1557 mwindow->theme->mcanvas_h);
1558 pane[TOP_RIGHT_PANE]->resize_event(
1559 mwindow->theme->mcanvas_x +
1561 pane[TOP_RIGHT_PANE]->y,
1562 mwindow->theme->mcanvas_x +
1563 mwindow->theme->mcanvas_w -
1565 mwindow->theme->mcanvas_h);
1569 // resize 2 horizontal panes
1570 mwindow->edl->local_session->view_start[TOP_RIGHT_PANE] +=
1572 pane[TOP_RIGHT_PANE]->x;
1573 if(mwindow->edl->local_session->view_start[TOP_RIGHT_PANE] < 0)
1574 mwindow->edl->local_session->view_start[TOP_RIGHT_PANE] = 0;
1575 mwindow->edl->local_session->view_start[BOTTOM_RIGHT_PANE] =
1576 mwindow->edl->local_session->view_start[TOP_RIGHT_PANE];
1578 pane[TOP_LEFT_PANE]->resize_event(
1579 mwindow->theme->mcanvas_x,
1580 pane[TOP_LEFT_PANE]->y,
1581 cursor_x - mwindow->theme->pane_w,
1582 pane[TOP_LEFT_PANE]->h);
1583 pane[TOP_RIGHT_PANE]->resize_event(
1584 mwindow->theme->mcanvas_x +
1586 pane[TOP_RIGHT_PANE]->y,
1587 mwindow->theme->mcanvas_x +
1588 mwindow->theme->mcanvas_w -
1590 pane[TOP_RIGHT_PANE]->h);
1591 pane[BOTTOM_LEFT_PANE]->resize_event(
1592 mwindow->theme->mcanvas_x,
1593 pane[BOTTOM_LEFT_PANE]->y,
1594 cursor_x - mwindow->theme->pane_w,
1595 pane[BOTTOM_LEFT_PANE]->h);
1596 pane[BOTTOM_RIGHT_PANE]->resize_event(
1597 mwindow->theme->mcanvas_x +
1599 pane[BOTTOM_RIGHT_PANE]->y,
1600 mwindow->theme->mcanvas_x +
1601 mwindow->theme->mcanvas_w -
1603 pane[BOTTOM_RIGHT_PANE]->h);
1609 void MWindowGUI::delete_x_pane(int cursor_x)
1611 // give left panes coordinates of right pane
1612 if(cursor_x < mwindow->theme->patchbay_w + PANE_DRAG_MARGIN &&
1613 pane[TOP_RIGHT_PANE])
1615 mwindow->edl->local_session->view_start[TOP_LEFT_PANE] =
1616 mwindow->edl->local_session->view_start[TOP_RIGHT_PANE] -
1617 pane[TOP_RIGHT_PANE]->x + mwindow->theme->patchbay_w;
1618 if(mwindow->edl->local_session->view_start[TOP_LEFT_PANE] < 0)
1619 mwindow->edl->local_session->view_start[TOP_LEFT_PANE] = 0;
1620 mwindow->edl->local_session->view_start[BOTTOM_LEFT_PANE] =
1621 mwindow->edl->local_session->view_start[TOP_LEFT_PANE];
1624 switch(total_panes())
1627 if(pane[TOP_LEFT_PANE] && pane[TOP_RIGHT_PANE])
1629 // delete right pane
1630 delete pane[TOP_RIGHT_PANE];
1631 pane[TOP_RIGHT_PANE] = 0;
1632 pane[TOP_LEFT_PANE]->resize_event(
1633 mwindow->theme->mcanvas_x,
1634 mwindow->theme->mcanvas_y,
1635 mwindow->theme->mcanvas_w,
1636 mwindow->theme->mcanvas_h);
1642 // delete right panes
1643 delete pane[TOP_RIGHT_PANE];
1644 pane[TOP_RIGHT_PANE] = 0;
1645 delete pane[BOTTOM_RIGHT_PANE];
1646 pane[BOTTOM_RIGHT_PANE] = 0;
1647 pane[TOP_LEFT_PANE]->resize_event(
1648 mwindow->theme->mcanvas_x,
1649 pane[TOP_LEFT_PANE]->y,
1650 mwindow->theme->mcanvas_w,
1651 pane[TOP_LEFT_PANE]->h);
1652 pane[BOTTOM_LEFT_PANE]->resize_event(
1653 mwindow->theme->mcanvas_x,
1654 pane[BOTTOM_LEFT_PANE]->y,
1655 mwindow->theme->mcanvas_w,
1656 pane[BOTTOM_LEFT_PANE]->h);
1661 void MWindowGUI::create_y_pane(int cursor_y)
1663 if(total_panes() == 1)
1665 mwindow->edl->local_session->view_start[BOTTOM_LEFT_PANE] =
1666 mwindow->edl->local_session->view_start[TOP_LEFT_PANE];
1667 mwindow->edl->local_session->track_start[BOTTOM_LEFT_PANE] =
1668 mwindow->edl->local_session->track_start[TOP_LEFT_PANE] +
1670 mwindow->theme->mtimebar_h;
1671 // do this 1st so the resize_event knows there are 2 panes
1672 pane[BOTTOM_LEFT_PANE] = new TimelinePane(mwindow,
1674 mwindow->theme->mcanvas_x,
1675 mwindow->theme->mcanvas_y +
1677 mwindow->theme->mcanvas_w,
1678 mwindow->theme->mcanvas_h -
1680 pane[TOP_LEFT_PANE]->resize_event(
1681 mwindow->theme->mcanvas_x,
1682 mwindow->theme->mcanvas_y,
1683 mwindow->theme->mcanvas_w,
1684 pane[BOTTOM_LEFT_PANE]->y -
1685 mwindow->theme->mcanvas_y -
1686 mwindow->theme->pane_h);
1687 pane[BOTTOM_LEFT_PANE]->create_objects();
1690 if(horizontal_panes())
1693 mwindow->edl->local_session->view_start[BOTTOM_LEFT_PANE] =
1694 mwindow->edl->local_session->view_start[TOP_LEFT_PANE];
1695 mwindow->edl->local_session->view_start[BOTTOM_RIGHT_PANE] =
1696 mwindow->edl->local_session->view_start[TOP_RIGHT_PANE];
1697 mwindow->edl->local_session->track_start[BOTTOM_LEFT_PANE] =
1698 mwindow->edl->local_session->track_start[BOTTOM_RIGHT_PANE] =
1699 mwindow->edl->local_session->track_start[TOP_LEFT_PANE] +
1701 mwindow->theme->mtimebar_h;
1703 pane[BOTTOM_LEFT_PANE] = new TimelinePane(mwindow,
1705 pane[TOP_LEFT_PANE]->x,
1706 mwindow->theme->mcanvas_y +
1708 pane[TOP_LEFT_PANE]->w,
1709 mwindow->theme->mcanvas_h -
1711 pane[BOTTOM_RIGHT_PANE] = new TimelinePane(mwindow,
1713 pane[TOP_RIGHT_PANE]->x,
1714 mwindow->theme->mcanvas_y +
1716 pane[TOP_RIGHT_PANE]->w,
1717 mwindow->theme->mcanvas_h -
1720 pane[TOP_LEFT_PANE]->resize_event(
1721 pane[TOP_LEFT_PANE]->x,
1722 pane[TOP_LEFT_PANE]->y,
1723 pane[TOP_LEFT_PANE]->w,
1724 pane[BOTTOM_LEFT_PANE]->y -
1725 mwindow->theme->mcanvas_y -
1726 mwindow->theme->pane_h);
1727 pane[TOP_RIGHT_PANE]->resize_event(
1728 pane[TOP_RIGHT_PANE]->x,
1729 pane[TOP_RIGHT_PANE]->y,
1730 pane[TOP_RIGHT_PANE]->w,
1731 pane[BOTTOM_RIGHT_PANE]->y -
1732 mwindow->theme->mcanvas_y -
1733 mwindow->theme->pane_h);
1735 pane[BOTTOM_LEFT_PANE]->create_objects();
1736 pane[BOTTOM_RIGHT_PANE]->create_objects();
1739 if(vertical_panes())
1742 mwindow->edl->local_session->track_start[BOTTOM_LEFT_PANE] +=
1744 (pane[BOTTOM_LEFT_PANE]->y - mwindow->theme->mcanvas_y);
1745 if(mwindow->edl->local_session->track_start[BOTTOM_LEFT_PANE] < 0)
1746 mwindow->edl->local_session->track_start[BOTTOM_LEFT_PANE] = 0;
1747 pane[TOP_LEFT_PANE]->resize_event(
1748 mwindow->theme->mcanvas_x,
1749 mwindow->theme->mcanvas_y,
1750 mwindow->theme->mcanvas_w,
1751 cursor_y - mwindow->theme->pane_h);
1752 pane[BOTTOM_LEFT_PANE]->resize_event(
1753 pane[BOTTOM_LEFT_PANE]->x,
1755 mwindow->theme->mcanvas_y,
1756 mwindow->theme->mcanvas_w,
1757 mwindow->theme->mcanvas_h -
1763 mwindow->edl->local_session->track_start[BOTTOM_LEFT_PANE] +=
1765 (pane[BOTTOM_LEFT_PANE]->y - mwindow->theme->mcanvas_y);
1766 if(mwindow->edl->local_session->track_start[BOTTOM_LEFT_PANE] < 0)
1767 mwindow->edl->local_session->track_start[BOTTOM_LEFT_PANE] = 0;
1768 mwindow->edl->local_session->track_start[BOTTOM_RIGHT_PANE] =
1769 mwindow->edl->local_session->track_start[BOTTOM_LEFT_PANE];
1770 pane[TOP_LEFT_PANE]->resize_event(
1771 pane[TOP_LEFT_PANE]->x,
1772 pane[TOP_LEFT_PANE]->y,
1773 pane[TOP_LEFT_PANE]->w,
1774 cursor_y - mwindow->theme->pane_h);
1775 pane[BOTTOM_LEFT_PANE]->resize_event(
1776 pane[BOTTOM_LEFT_PANE]->x,
1778 mwindow->theme->mcanvas_y,
1779 pane[BOTTOM_LEFT_PANE]->w,
1780 mwindow->theme->mcanvas_h -
1782 pane[TOP_RIGHT_PANE]->resize_event(
1783 pane[TOP_RIGHT_PANE]->x,
1784 pane[TOP_RIGHT_PANE]->y,
1785 pane[TOP_RIGHT_PANE]->w,
1786 cursor_y - mwindow->theme->pane_h);
1787 pane[BOTTOM_RIGHT_PANE]->resize_event(
1788 pane[BOTTOM_RIGHT_PANE]->x,
1790 mwindow->theme->mcanvas_y,
1791 pane[BOTTOM_RIGHT_PANE]->w,
1792 mwindow->theme->mcanvas_h -
1797 void MWindowGUI::delete_y_pane(int cursor_y)
1799 if(cursor_y < mwindow->theme->mtimebar_h +
1801 pane[BOTTOM_LEFT_PANE])
1803 // give top pane coordinates of bottom pane
1804 mwindow->edl->local_session->track_start[TOP_LEFT_PANE] =
1805 mwindow->edl->local_session->track_start[BOTTOM_LEFT_PANE] -
1806 pane[BOTTOM_LEFT_PANE]->y;
1807 if(mwindow->edl->local_session->track_start[TOP_LEFT_PANE] < 0)
1808 mwindow->edl->local_session->track_start[TOP_LEFT_PANE] = 0;
1809 mwindow->edl->local_session->track_start[TOP_RIGHT_PANE] =
1810 mwindow->edl->local_session->track_start[TOP_LEFT_PANE];
1814 switch(total_panes())
1817 delete pane[BOTTOM_LEFT_PANE];
1818 pane[BOTTOM_LEFT_PANE] = 0;
1819 pane[TOP_LEFT_PANE]->resize_event(
1820 mwindow->theme->mcanvas_x,
1821 mwindow->theme->mcanvas_y,
1822 mwindow->theme->mcanvas_w,
1823 mwindow->theme->mcanvas_h);
1827 // delete bottom 2 panes
1829 delete pane[BOTTOM_LEFT_PANE];
1830 pane[BOTTOM_LEFT_PANE] = 0;
1831 delete pane[BOTTOM_RIGHT_PANE];
1832 pane[BOTTOM_RIGHT_PANE] = 0;
1833 pane[TOP_LEFT_PANE]->resize_event(
1834 pane[TOP_LEFT_PANE]->x,
1835 mwindow->theme->mcanvas_y,
1836 pane[TOP_LEFT_PANE]->w,
1837 mwindow->theme->mcanvas_h);
1838 pane[TOP_RIGHT_PANE]->resize_event(
1839 pane[TOP_RIGHT_PANE]->x,
1840 mwindow->theme->mcanvas_y,
1841 pane[TOP_RIGHT_PANE]->w,
1842 mwindow->theme->mcanvas_h);
1847 void MWindowGUI::stop_pane_drag()
1850 resource_thread->stop_draw(1);
1854 // cursor position relative to canvas
1855 int cursor_x = x_pane_drag->get_x() -
1857 BC_DisplayInfo::get_left_border() -
1858 mwindow->theme->mcanvas_x +
1859 mwindow->theme->pane_w;
1864 if(cursor_x >= mwindow->theme->patchbay_w + PANE_DRAG_MARGIN &&
1865 cursor_x < mwindow->theme->mcanvas_w -
1866 BC_ScrollBar::get_span(SCROLL_VERT) -
1869 create_x_pane(cursor_x);
1870 mwindow->edl->local_session->x_pane = cursor_x;
1875 delete_x_pane(cursor_x);
1876 mwindow->edl->local_session->x_pane = -1;
1884 // cursor position relative to canvas
1885 int cursor_y = y_pane_drag->get_y() -
1887 BC_DisplayInfo::get_top_border() -
1888 mwindow->theme->mcanvas_y +
1889 mwindow->theme->pane_h;
1895 if(cursor_y >= mwindow->theme->mtimebar_h +
1897 cursor_y < mwindow->theme->mcanvas_h -
1898 BC_ScrollBar::get_span(SCROLL_HORIZ) -
1901 create_y_pane(cursor_y);
1902 mwindow->edl->local_session->y_pane = cursor_y;
1906 delete_y_pane(cursor_y);
1907 mwindow->edl->local_session->y_pane = -1;
1911 update_pane_dividers();
1913 // required to get new widgets to appear
1915 resource_thread->start_draw();
1918 // create panes from EDL
1919 void MWindowGUI::load_panes()
1921 int need_x_panes = 0;
1922 int need_y_panes = 0;
1923 // use names from create functions
1924 int cursor_x = mwindow->edl->local_session->x_pane;
1925 int cursor_y = mwindow->edl->local_session->y_pane;
1927 resource_thread->stop_draw(1);
1929 mwindow->theme->patchbay_w + PANE_DRAG_MARGIN &&
1931 mwindow->theme->mcanvas_w -
1932 BC_ScrollBar::get_span(SCROLL_VERT) -
1939 mwindow->theme->mtimebar_h + PANE_DRAG_MARGIN &&
1941 mwindow->theme->mcanvas_h -
1942 BC_ScrollBar::get_span(SCROLL_HORIZ) -
1948 //printf("MWindowGUI::load_panes %d %d %d\n", __LINE__, need_x_panes, need_y_panes);
1956 if(total_panes() == 1)
1959 //printf("MWindowGUI::load_panes %d\n", __LINE__);
1960 pane[TOP_RIGHT_PANE] = new TimelinePane(mwindow,
1962 mwindow->theme->mcanvas_x +
1964 mwindow->theme->mcanvas_y,
1965 mwindow->theme->mcanvas_x +
1966 mwindow->theme->mcanvas_w -
1968 cursor_y - mwindow->theme->pane_h);
1969 pane[BOTTOM_LEFT_PANE] = new TimelinePane(mwindow,
1971 mwindow->theme->mcanvas_x,
1972 mwindow->theme->mcanvas_y +
1974 cursor_x - mwindow->theme->pane_w,
1975 mwindow->theme->mcanvas_h -
1977 pane[BOTTOM_RIGHT_PANE] = new TimelinePane(mwindow,
1979 pane[TOP_RIGHT_PANE]->x,
1980 mwindow->theme->mcanvas_y +
1982 pane[TOP_RIGHT_PANE]->w,
1983 mwindow->theme->mcanvas_h -
1985 pane[TOP_LEFT_PANE]->resize_event(
1986 pane[TOP_LEFT_PANE]->x,
1987 pane[TOP_LEFT_PANE]->y,
1988 cursor_x - mwindow->theme->pane_w,
1989 cursor_y - mwindow->theme->pane_h);
1990 pane[TOP_RIGHT_PANE]->create_objects();
1991 pane[BOTTOM_LEFT_PANE]->create_objects();
1992 pane[BOTTOM_RIGHT_PANE]->create_objects();
1995 if(horizontal_panes())
1997 // create vertical panes
1998 //printf("MWindowGUI::load_panes %d\n", __LINE__);
1999 pane[BOTTOM_LEFT_PANE] = new TimelinePane(mwindow,
2001 mwindow->theme->mcanvas_x,
2002 mwindow->theme->mcanvas_y +
2004 cursor_x - mwindow->theme->pane_w,
2005 mwindow->theme->mcanvas_h -
2007 pane[BOTTOM_RIGHT_PANE] = new TimelinePane(mwindow,
2009 pane[TOP_RIGHT_PANE]->x,
2010 mwindow->theme->mcanvas_y +
2012 pane[TOP_RIGHT_PANE]->w,
2013 mwindow->theme->mcanvas_h -
2015 pane[TOP_LEFT_PANE]->resize_event(
2016 pane[TOP_LEFT_PANE]->x,
2017 pane[TOP_LEFT_PANE]->y,
2018 cursor_x - mwindow->theme->pane_w,
2019 cursor_y - mwindow->theme->pane_h);
2020 pane[TOP_RIGHT_PANE]->resize_event(
2021 mwindow->theme->mcanvas_x +
2023 mwindow->theme->mcanvas_y,
2024 mwindow->theme->mcanvas_x +
2025 mwindow->theme->mcanvas_w -
2027 cursor_y - mwindow->theme->pane_h);
2028 pane[BOTTOM_LEFT_PANE]->create_objects();
2029 pane[BOTTOM_RIGHT_PANE]->create_objects();
2032 if(vertical_panes())
2034 // create horizontal panes
2035 //printf("MWindowGUI::load_panes %d\n", __LINE__);
2036 pane[TOP_RIGHT_PANE] = new TimelinePane(mwindow,
2038 mwindow->theme->mcanvas_x +
2040 mwindow->theme->mcanvas_y,
2041 mwindow->theme->mcanvas_x +
2042 mwindow->theme->mcanvas_w -
2044 cursor_y - mwindow->theme->pane_h);
2045 pane[BOTTOM_RIGHT_PANE] = new TimelinePane(mwindow,
2047 pane[TOP_RIGHT_PANE]->x,
2048 mwindow->theme->mcanvas_y +
2050 pane[TOP_RIGHT_PANE]->w,
2051 mwindow->theme->mcanvas_h -
2053 pane[TOP_LEFT_PANE]->resize_event(
2054 pane[TOP_LEFT_PANE]->x,
2055 pane[TOP_LEFT_PANE]->y,
2056 cursor_x - mwindow->theme->pane_w,
2057 cursor_y - mwindow->theme->pane_h);
2058 pane[BOTTOM_LEFT_PANE]->resize_event(
2059 pane[TOP_LEFT_PANE]->x,
2060 mwindow->theme->mcanvas_y +
2062 mwindow->theme->mcanvas_x +
2063 mwindow->theme->mcanvas_w -
2064 cursor_x - mwindow->theme->pane_w,
2065 mwindow->theme->mcanvas_h -
2067 pane[TOP_RIGHT_PANE]->create_objects();
2068 pane[BOTTOM_RIGHT_PANE]->create_objects();
2075 //printf("MWindowGUI::load_panes %d\n", __LINE__);
2076 pane[TOP_LEFT_PANE]->resize_event(
2077 pane[TOP_LEFT_PANE]->x,
2078 pane[TOP_LEFT_PANE]->y,
2079 cursor_x - mwindow->theme->pane_w,
2080 cursor_y - mwindow->theme->pane_h);
2081 pane[TOP_RIGHT_PANE]->resize_event(
2082 mwindow->theme->mcanvas_x +
2084 mwindow->theme->mcanvas_y,
2085 mwindow->theme->mcanvas_x +
2086 mwindow->theme->mcanvas_w -
2088 cursor_y - mwindow->theme->pane_h);
2089 pane[BOTTOM_LEFT_PANE]->resize_event(
2090 pane[TOP_LEFT_PANE]->x,
2091 mwindow->theme->mcanvas_y +
2093 mwindow->theme->mcanvas_x +
2094 mwindow->theme->mcanvas_w -
2095 cursor_x - mwindow->theme->pane_w,
2096 mwindow->theme->mcanvas_h -
2098 pane[BOTTOM_RIGHT_PANE]->resize_event(
2099 pane[TOP_RIGHT_PANE]->x,
2100 mwindow->theme->mcanvas_y +
2102 pane[TOP_RIGHT_PANE]->w,
2103 mwindow->theme->mcanvas_h -
2112 if(pane[BOTTOM_LEFT_PANE]) delete pane[BOTTOM_LEFT_PANE];
2113 if(pane[BOTTOM_RIGHT_PANE]) delete pane[BOTTOM_RIGHT_PANE];
2114 pane[BOTTOM_LEFT_PANE] = 0;
2115 pane[BOTTOM_RIGHT_PANE] = 0;
2117 if(!pane[TOP_RIGHT_PANE])
2119 pane[TOP_RIGHT_PANE] = new TimelinePane(mwindow,
2121 mwindow->theme->mcanvas_x +
2123 mwindow->theme->mcanvas_y,
2124 mwindow->theme->mcanvas_x +
2125 mwindow->theme->mcanvas_w -
2127 mwindow->theme->mcanvas_h);
2128 pane[TOP_LEFT_PANE]->resize_event(
2129 mwindow->theme->mcanvas_x,
2130 mwindow->theme->mcanvas_y,
2131 cursor_x - mwindow->theme->pane_w,
2132 mwindow->theme->mcanvas_h);
2133 pane[TOP_RIGHT_PANE]->create_objects();
2137 pane[TOP_LEFT_PANE]->resize_event(
2138 mwindow->theme->mcanvas_x,
2139 mwindow->theme->mcanvas_y,
2140 cursor_x - mwindow->theme->pane_w,
2141 mwindow->theme->mcanvas_h);
2142 pane[TOP_RIGHT_PANE]->resize_event(
2143 mwindow->theme->mcanvas_x +
2145 pane[TOP_RIGHT_PANE]->y,
2146 mwindow->theme->mcanvas_x +
2147 mwindow->theme->mcanvas_w -
2149 mwindow->theme->mcanvas_h);
2157 if(pane[TOP_RIGHT_PANE]) delete pane[TOP_RIGHT_PANE];
2158 if(pane[BOTTOM_RIGHT_PANE]) delete pane[BOTTOM_RIGHT_PANE];
2159 pane[TOP_RIGHT_PANE] = 0;
2160 pane[BOTTOM_RIGHT_PANE] = 0;
2162 if(!pane[BOTTOM_LEFT_PANE])
2164 //printf("MWindowGUI::load_panes %d\n", __LINE__);
2165 pane[BOTTOM_LEFT_PANE] = new TimelinePane(mwindow,
2167 mwindow->theme->mcanvas_x,
2168 mwindow->theme->mcanvas_y +
2170 mwindow->theme->mcanvas_w,
2171 mwindow->theme->mcanvas_h -
2173 pane[TOP_LEFT_PANE]->resize_event(
2174 mwindow->theme->mcanvas_x,
2175 mwindow->theme->mcanvas_y,
2176 mwindow->theme->mcanvas_w,
2177 pane[BOTTOM_LEFT_PANE]->y -
2178 mwindow->theme->mcanvas_y -
2179 mwindow->theme->pane_h);
2180 pane[BOTTOM_LEFT_PANE]->create_objects();
2184 pane[TOP_LEFT_PANE]->resize_event(
2185 mwindow->theme->mcanvas_x,
2186 mwindow->theme->mcanvas_y,
2187 mwindow->theme->mcanvas_w,
2188 cursor_y - mwindow->theme->pane_h);
2189 pane[BOTTOM_LEFT_PANE]->resize_event(
2190 pane[BOTTOM_LEFT_PANE]->x,
2192 mwindow->theme->mcanvas_y,
2193 mwindow->theme->mcanvas_w,
2194 mwindow->theme->mcanvas_h -
2201 if(pane[TOP_RIGHT_PANE]) delete pane[TOP_RIGHT_PANE];
2202 if(pane[BOTTOM_RIGHT_PANE]) delete pane[BOTTOM_RIGHT_PANE];
2203 if(pane[BOTTOM_LEFT_PANE]) delete pane[BOTTOM_LEFT_PANE];
2204 pane[TOP_RIGHT_PANE] = 0;
2205 pane[BOTTOM_RIGHT_PANE] = 0;
2206 pane[BOTTOM_LEFT_PANE] = 0;
2207 pane[TOP_LEFT_PANE]->resize_event(
2208 mwindow->theme->mcanvas_x,
2209 mwindow->theme->mcanvas_y,
2210 mwindow->theme->mcanvas_w,
2211 mwindow->theme->mcanvas_h);
2214 update_pane_dividers();
2217 resource_thread->start_draw();
2220 void MWindowGUI::update_pane_dividers()
2223 if(horizontal_panes() || total_panes() == 4)
2225 int x = pane[TOP_RIGHT_PANE]->x - mwindow->theme->pane_w;
2226 int y = mwindow->theme->mcanvas_y;
2227 int h = mwindow->theme->mcanvas_h;
2231 add_subwindow(x_divider = new PaneDivider(
2232 mwindow, x, y, h, 1));
2233 x_divider->create_objects();
2237 x_divider->reposition_window(x, y, h);
2250 if(vertical_panes() || total_panes() == 4)
2252 int x = mwindow->theme->mcanvas_x;
2253 int y = pane[BOTTOM_LEFT_PANE]->y -
2254 mwindow->theme->pane_h;
2255 int w = mwindow->theme->mcanvas_w;
2258 add_subwindow(y_divider = new PaneDivider(
2259 mwindow, x, y, w, 0));
2260 y_divider->create_objects();
2264 y_divider->reposition_window(x, y, w);
2278 void MWindowGUI::draw_samplemovement()
2285 update_scrollbars(1);
2288 void MWindowGUI::draw_trackmovement()
2290 update_scrollbars(0);
2297 void MWindowGUI::update_mixers(Track *track, int v)
2299 for( int i=0; i<TOTAL_PANES; ++i ) {
2300 if( !pane[i] ) continue;
2301 PatchBay *patchbay = pane[i]->patchbay;
2302 if( !patchbay ) continue;
2303 for( int j=0; j<patchbay->patches.total; ++j ) {
2304 PatchGUI *patchgui = patchbay->patches.values[j];
2305 if( !patchgui->mix ) continue;
2306 if( !track || patchgui->track == track ) {
2307 patchgui->mix->update(v>=0 ? v :
2308 mwindow->mixer_track_active(patchgui->track));
2314 void MWindowGUI::stop_transport(const char *lock_msg)
2316 if( !mbuttons->transport->is_stopped() ) {
2317 if( lock_msg ) unlock_window();
2318 mbuttons->transport->handle_transport(STOP, 1, 0, 0);
2319 if( lock_msg ) lock_window(lock_msg);
2323 PaneButton::PaneButton(MWindow *mwindow, int x, int y)
2324 : BC_Button(x, y, mwindow->theme->get_image_set("pane"))
2326 this->mwindow = mwindow;
2329 int PaneButton::cursor_motion_event()
2331 if(get_top_level()->get_button_down() &&
2333 get_status() == BUTTON_DOWNHI &&
2336 // printf("PaneButton::cursor_motion_event %d\n", __LINE__);
2338 if(get_cursor_x() < 0 && !mwindow->gui->dragging_pane)
2340 mwindow->gui->start_x_pane_drag();
2343 if(get_cursor_y() < 0 && !mwindow->gui->dragging_pane)
2345 mwindow->gui->start_y_pane_drag();
2349 mwindow->gui->handle_pane_drag();
2351 int result = BC_Button::cursor_motion_event();
2355 int PaneButton::button_release_event()
2357 if( get_buttonpress() != WHEEL_DOWN && get_buttonpress() != WHEEL_UP )
2358 mwindow->gui->stop_pane_drag();
2359 int result = BC_Button::button_release_event();
2364 FFMpegToggle::FFMpegToggle(MWindow *mwindow, MButtons *mbuttons, int x, int y)
2365 : BC_Toggle(x, y, mwindow->theme->ffmpeg_toggle,
2366 mwindow->preferences->get_file_probe_armed("FFMPEG_Early") > 0 ? 1 : 0)
2368 this->mwindow = mwindow;
2369 this->mbuttons = mbuttons;
2370 set_tooltip(get_value() ? FFMPEG_EARLY_TIP : FFMPEG_LATE_TIP);
2373 FFMpegToggle::~FFMpegToggle()
2377 int FFMpegToggle::handle_event()
2379 int ffmpeg_early_probe = get_value();
2380 set_tooltip(ffmpeg_early_probe ? FFMPEG_EARLY_TIP : FFMPEG_LATE_TIP);
2381 mwindow->preferences->set_file_probe_armed("FFMPEG_Early", ffmpeg_early_probe);
2382 mwindow->preferences->set_file_probe_armed("FFMPEG_Late", !ffmpeg_early_probe);
2384 mwindow->show_warning(&mwindow->preferences->warn_indexes,
2385 _("Changing the base codecs may require rebuilding indexes."));
2390 ProxyToggle::ProxyToggle(MWindow *mwindow, MButtons *mbuttons, int x, int y)
2391 : BC_Toggle(x, y, mwindow->theme->proxy_toggle,
2392 mwindow->edl->session->proxy_disabled_scale != 1)
2394 this->mwindow = mwindow;
2395 this->mbuttons = mbuttons;
2396 set_tooltip(mwindow->edl->session->proxy_disabled_scale==1 ?
2397 _("Disable proxy") : _("Enable proxy"));
2400 ProxyToggle::~ProxyToggle()
2404 int ProxyToggle::handle_event()
2406 int disabled = get_value();
2408 mwindow->disable_proxy();
2410 mwindow->enable_proxy();
2411 set_tooltip(!disabled ? _("Disable proxy") : _("Enable proxy"));
2415 int ProxyToggle::keypress_event()
2417 if( ctrl_down() && !shift_down() && !alt_down() ) {
2418 int key = get_keypress();
2420 int value = get_value() ? 0 : 1;
2422 return handle_event();