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()
254 lock_window("MWindowGUI::create_objects");
257 resource_thread = new ResourceThread(mwindow, this);
258 resource_thread->create_objects();
261 if(debug) printf("MWindowGUI::create_objects %d\n", __LINE__);
262 set_icon(mwindow->theme->get_image("mwindow_icon"));
263 remote_control = new RemoteControl(this);
264 cwindow_remote_handler = new CWindowRemoteHandler(remote_control);
265 record_remote_handler = new RecordRemoteHandler(remote_control);
266 mwindow->reset_android_remote();
268 if(debug) printf("MWindowGUI::create_objects %d\n", __LINE__);
270 int x = get_w() - MainShBtns::calculate_w(0);
271 add_subwindow(mainmenu = new MainMenu(mwindow, this, x));
272 mainmenu->create_objects();
273 add_subwindow(mainshbtns = new MainShBtns(mwindow, x, -1));
274 mainshbtns->load(mwindow->preferences);
275 mwindow->theme->get_mwindow_sizes(this, get_w(), get_h());
276 mwindow->theme->draw_mwindow_bg(this);
277 if(debug) printf("MWindowGUI::create_objects %d\n", __LINE__);
279 add_subwindow(mbuttons = new MButtons(mwindow, this));
280 mbuttons->create_objects();
281 int x1 = mbuttons->get_x() + mbuttons->get_w(), y1 = mbuttons->get_y()+2;
282 add_subwindow(proxy_toggle = new ProxyToggle(mwindow, mbuttons, x1, y1));
283 x1 += proxy_toggle->get_w() + 3;
284 add_subwindow(ffmpeg_toggle = new FFMpegToggle(mwindow, mbuttons, x1, y1));
286 pane[TOP_LEFT_PANE] = new TimelinePane(mwindow,
288 mwindow->theme->mcanvas_x,
289 mwindow->theme->mcanvas_y,
290 mwindow->theme->mcanvas_w,
291 mwindow->theme->mcanvas_h);
292 pane[TOP_LEFT_PANE]->create_objects();
294 // add_subwindow(timebar = new MTimeBar(mwindow,
296 // mwindow->theme->mtimebar_x,
297 // mwindow->theme->mtimebar_y,
298 // mwindow->theme->mtimebar_w,
299 // mwindow->theme->mtimebar_h));
300 // timebar->create_objects();
302 // if(debug) printf("MWindowGUI::create_objects %d\n", __LINE__);
303 // add_subwindow(patchbay = new PatchBay(mwindow, this));
304 // patchbay->create_objects();
306 // if(debug) printf("MWindowGUI::create_objects %d\n", __LINE__);
307 // get_scrollbars(0);
309 // if(debug) printf("MWindowGUI::create_objects %d\n", __LINE__);
310 // mwindow->gui->add_subwindow(canvas = new TrackCanvas(mwindow, this));
311 // canvas->create_objects();
314 if(debug) printf("MWindowGUI::create_objects %d\n", __LINE__);
315 add_subwindow(zoombar = new ZoomBar(mwindow, this));
316 zoombar->create_objects();
319 if(debug) printf("MWindowGUI::create_objects %d\n", __LINE__);
320 add_subwindow(statusbar = new StatusBar(mwindow, this));
321 statusbar->create_objects();
325 if(debug) printf("MWindowGUI::create_objects %d\n", __LINE__);
326 add_subwindow(mainclock = new MainClock(mwindow,
327 mwindow->theme->mclock_x, mwindow->theme->mclock_y,
328 mwindow->theme->mclock_w));
329 if(debug) printf("MWindowGUI::create_objects %d\n", __LINE__);
330 mainclock->update(0);
334 // if(debug) printf("MWindowGUI::create_objects %d\n", __LINE__);
335 // cursor = new MainCursor(mwindow, this);
336 // cursor->create_objects();
339 if(debug) printf("MWindowGUI::create_objects %d\n", __LINE__);
340 add_subwindow(edit_menu = new EditPopup(mwindow, this));
341 edit_menu->create_objects();
344 if(debug) printf("MWindowGUI::create_objects %d\n", __LINE__);
345 add_subwindow(plugin_menu = new PluginPopup(mwindow, this));
346 plugin_menu->create_objects();
349 if(debug) printf("MWindowGUI::create_objects %d\n", __LINE__);
350 add_subwindow(keyframe_menu = new KeyframePopup(mwindow, this));
351 keyframe_menu->create_objects();
352 add_subwindow(keyframe_hide = new KeyframeHidePopup(mwindow, this));
353 keyframe_hide->create_objects();
356 if(debug) printf("MWindowGUI::create_objects %d\n", __LINE__);
357 add_subwindow(transition_menu = new TransitionPopup(mwindow, this));
358 transition_menu->create_objects();
361 channel_info = new ChannelInfo(mwindow);
363 #ifdef HAVE_COMMERCIAL
364 db_window = new DbWindow(mwindow);
366 swindow = new SWindow(mwindow);
368 if(debug) printf("MWindowGUI::create_objects %d\n", __LINE__);
370 add_subwindow(pane_button = new PaneButton(mwindow,
371 get_w() - mwindow->theme->get_image_set("pane")[0]->get_w(),
372 mwindow->theme->mzoom_y + 1 - mwindow->theme->get_image_set("pane")[0]->get_h()));
374 pane[TOP_LEFT_PANE]->canvas->activate();
376 if(debug) printf("MWindowGUI::create_objects %d\n", __LINE__);
380 void MWindowGUI::redraw_time_dependancies()
382 zoombar->redraw_time_dependancies();
383 for(int i = 0; i < TOTAL_PANES; i++)
384 if(pane[i] && pane[i]->timebar) pane[i]->timebar->update(0);
385 mainclock->update(mwindow->edl->local_session->get_selectionstart(1));
388 int MWindowGUI::focus_in_event()
390 for(int i = 0; i < TOTAL_PANES; i++)
391 if(pane[i]) pane[i]->cursor->focus_in_event();
395 int MWindowGUI::focus_out_event()
397 for(int i = 0; i < TOTAL_PANES; i++)
398 if(pane[i]) pane[i]->cursor->focus_out_event();
403 int MWindowGUI::resize_event(int w, int h)
405 //printf("MWindowGUI::resize_event %d\n", __LINE__);
406 mwindow->session->mwindow_w = w;
407 mwindow->session->mwindow_h = h;
408 int x = w - MainShBtns::calculate_w(0);
409 mainmenu->resize_event(x, mainmenu->get_h());
410 mainshbtns->reposition_window(x, -1);
411 mwindow->theme->get_mwindow_sizes(this, w, h);
412 mwindow->theme->draw_mwindow_bg(this);
413 mbuttons->resize_event();
414 int x1 = mbuttons->get_x() + mbuttons->get_w(), y1 = mbuttons->get_y()+2;
415 proxy_toggle->reposition_window(x1, y1);
416 x1 += proxy_toggle->get_w() + 3;
417 ffmpeg_toggle->reposition_window(x1, y1);
418 statusbar->resize_event();
419 zoombar->resize_event();
421 resource_thread->stop_draw(1);
423 if(total_panes() > 1)
425 if(horizontal_panes())
427 // printf("MWindowGUI::resize_event %d %d %d\n",
429 // pane[TOP_RIGHT_PANE]->x,
430 // mwindow->theme->mcanvas_w -
431 // BC_ScrollBar::get_span(SCROLL_VERT) -
432 // PANE_DRAG_MARGIN);
433 if(pane[TOP_RIGHT_PANE]->x >= mwindow->theme->mcanvas_w -
434 BC_ScrollBar::get_span(SCROLL_VERT) -
437 delete_x_pane(pane[TOP_RIGHT_PANE]->x);
438 mwindow->edl->local_session->x_pane = -1;
444 if(pane[BOTTOM_LEFT_PANE]->y >= mwindow->theme->mzoom_y -
445 BC_ScrollBar::get_span(SCROLL_HORIZ) -
448 delete_y_pane(pane[BOTTOM_LEFT_PANE]->y);
449 mwindow->edl->local_session->y_pane = -1;
454 if(pane[TOP_RIGHT_PANE]->x >= mwindow->theme->mcanvas_w -
455 BC_ScrollBar::get_span(SCROLL_VERT) -
458 delete_x_pane(pane[TOP_RIGHT_PANE]->x);
459 mwindow->edl->local_session->x_pane = -1;
462 if(pane[BOTTOM_LEFT_PANE]->y >= mwindow->theme->mzoom_y -
463 BC_ScrollBar::get_span(SCROLL_HORIZ) -
466 delete_y_pane(pane[BOTTOM_LEFT_PANE]->y);
467 mwindow->edl->local_session->y_pane = -1;
472 if(total_panes() == 1)
474 pane[TOP_LEFT_PANE]->resize_event(
475 mwindow->theme->mcanvas_x,
476 mwindow->theme->mcanvas_y,
477 mwindow->theme->mcanvas_w,
478 mwindow->theme->mcanvas_h);
481 if(horizontal_panes())
483 pane[TOP_LEFT_PANE]->resize_event(
484 pane[TOP_LEFT_PANE]->x,
485 pane[TOP_LEFT_PANE]->y,
486 pane[TOP_LEFT_PANE]->w,
487 mwindow->theme->mcanvas_h);
488 pane[TOP_RIGHT_PANE]->resize_event(
489 pane[TOP_RIGHT_PANE]->x,
490 pane[TOP_RIGHT_PANE]->y,
491 mwindow->theme->mcanvas_w - pane[TOP_RIGHT_PANE]->x,
492 mwindow->theme->mcanvas_h);
497 pane[TOP_LEFT_PANE]->resize_event(
498 pane[TOP_LEFT_PANE]->x,
499 pane[TOP_LEFT_PANE]->y,
500 mwindow->theme->mcanvas_w,
501 pane[TOP_LEFT_PANE]->h);
502 pane[BOTTOM_LEFT_PANE]->resize_event(
503 pane[BOTTOM_LEFT_PANE]->x,
504 pane[BOTTOM_LEFT_PANE]->y,
505 mwindow->theme->mcanvas_w,
506 mwindow->theme->mcanvas_y +
507 mwindow->theme->mcanvas_h -
508 pane[BOTTOM_LEFT_PANE]->y);
512 pane[TOP_LEFT_PANE]->resize_event(
513 pane[TOP_LEFT_PANE]->x,
514 pane[TOP_LEFT_PANE]->y,
515 pane[TOP_LEFT_PANE]->w,
516 pane[TOP_LEFT_PANE]->h);
517 pane[TOP_RIGHT_PANE]->resize_event(
518 pane[TOP_RIGHT_PANE]->x,
519 pane[TOP_RIGHT_PANE]->y,
520 mwindow->theme->mcanvas_w - pane[TOP_RIGHT_PANE]->x,
521 pane[TOP_RIGHT_PANE]->h);
522 pane[BOTTOM_LEFT_PANE]->resize_event(
523 pane[BOTTOM_LEFT_PANE]->x,
524 pane[BOTTOM_LEFT_PANE]->y,
525 pane[BOTTOM_LEFT_PANE]->w,
526 mwindow->theme->mcanvas_y +
527 mwindow->theme->mcanvas_h -
528 pane[BOTTOM_LEFT_PANE]->y);
529 pane[BOTTOM_RIGHT_PANE]->resize_event(
530 pane[BOTTOM_RIGHT_PANE]->x,
531 pane[BOTTOM_RIGHT_PANE]->y,
532 mwindow->theme->mcanvas_w -
533 pane[BOTTOM_RIGHT_PANE]->x,
534 mwindow->theme->mcanvas_y +
535 mwindow->theme->mcanvas_h -
536 pane[BOTTOM_RIGHT_PANE]->y);
539 update_pane_dividers();
540 pane_button->reposition_window(w - mwindow->theme->get_image_set("pane")[0]->get_w(),
541 mwindow->theme->mzoom_y + 1 - mwindow->theme->get_image_set("pane")[0]->get_h());
542 resource_thread->start_draw();
548 int MWindowGUI::total_panes()
551 for(int i = 0; i < TOTAL_PANES; i++)
556 int MWindowGUI::vertical_panes()
558 return total_panes() == 2 &&
559 pane[TOP_LEFT_PANE] &&
560 pane[BOTTOM_LEFT_PANE];
563 int MWindowGUI::horizontal_panes()
565 return total_panes() == 2 &&
566 pane[TOP_LEFT_PANE] &&
567 pane[TOP_RIGHT_PANE];
570 TimelinePane* MWindowGUI::get_focused_pane()
572 if(pane[focused_pane]) return pane[focused_pane];
573 for(int i = 0; i < TOTAL_PANES; i++)
575 if(pane[i]) return pane[i];
580 void MWindowGUI::activate_timeline()
582 if(pane[focused_pane])
584 pane[focused_pane]->activate();
588 for(int i = 0; i < TOTAL_PANES; i++)
599 void MWindowGUI::deactivate_timeline()
601 for(int i = 0; i < TOTAL_PANES; i++)
605 pane[i]->canvas->deactivate();
610 void MWindowGUI::update_title(char *path)
613 char filename[BCTEXTLEN], string[BCTEXTLEN];
614 fs.extract_name(filename, path);
615 sprintf(string, _(PROGRAM_NAME ": %s"), filename);
617 //printf("MWindowGUI::update_title %s\n", string);
621 void MWindowGUI::draw_overlays(int flash_it)
623 for(int i = 0; i < TOTAL_PANES; i++)
627 pane[i]->canvas->draw_overlays();
628 if(flash_it) pane[i]->canvas->flash();
633 void MWindowGUI::update_timebar(int flush_it)
635 for(int i = 0; i < TOTAL_PANES; i++)
637 if(pane[i] && pane[i]->timebar)
639 pane[i]->timebar->update(flush_it);
644 void MWindowGUI::update_timebar_highlights()
646 for(int i = 0; i < TOTAL_PANES; i++)
648 if(pane[i] && pane[i]->timebar)
650 pane[i]->timebar->update_highlights();
656 void MWindowGUI::update_patchbay()
658 for(int i = 0; i < TOTAL_PANES; i++)
660 if(pane[i] && pane[i]->patchbay)
662 pane[i]->patchbay->update();
667 void MWindowGUI::update_proxy_toggle()
669 if( mwindow->edl->session->proxy_scale == 1 &&
670 mwindow->edl->session->proxy_disabled_scale == 1 )
671 proxy_toggle->hide();
673 proxy_toggle->show();
676 void MWindowGUI::update_plugintoggles()
678 for(int i = 0; i < TOTAL_PANES; i++)
682 pane[i]->canvas->refresh_plugintoggles();
688 void MWindowGUI::draw_indexes(Indexable *indexable)
690 for(int i = 0; i < TOTAL_PANES; i++)
694 pane[i]->canvas->draw_indexes(indexable);
699 void MWindowGUI::draw_canvas(int mode /* = 0 */, int hide_cursor /* = 1 */)
701 if(mode != IGNORE_THREAD)
703 resource_thread->stop_draw(1);
707 for(int i = 0; i < TOTAL_PANES; i++)
711 pane[i]->canvas->draw(mode, hide_cursor);
716 if(mode != IGNORE_THREAD)
718 resource_thread->start_draw();
723 void MWindowGUI::flash_canvas(int flush)
725 for(int i = 0; i < TOTAL_PANES; i++)
729 pane[i]->canvas->flash(flush);
734 int MWindowGUI::show_window(int flush)
736 int ret = BC_WindowBase::show_window(flush);
737 update_proxy_toggle();
741 void MWindowGUI::draw_cursor(int do_plugintoggles)
743 for(int i = 0; i < TOTAL_PANES; i++)
747 pane[i]->cursor->draw(do_plugintoggles);
752 void MWindowGUI::show_cursor(int do_plugintoggles)
754 for(int i = 0; i < TOTAL_PANES; i++)
758 pane[i]->cursor->show(do_plugintoggles);
763 void MWindowGUI::hide_cursor(int do_plugintoggles)
765 for(int i = 0; i < TOTAL_PANES; i++)
769 pane[i]->cursor->hide(do_plugintoggles);
774 void MWindowGUI::update_cursor()
776 for(int i = 0; i < TOTAL_PANES; i++)
780 pane[i]->cursor->update();
785 void MWindowGUI::set_playing_back(int value)
787 for(int i = 0; i < TOTAL_PANES; i++)
791 pane[i]->cursor->playing_back = value;
796 void MWindowGUI::update_scrollbars(int flush)
798 for(int i = 0; i < TOTAL_PANES; i++)
802 pane[i]->update(1, 0, 0, 0);
805 if(flush) this->flush();
808 void MWindowGUI::reset_meters()
810 for(int i = 0; i < TOTAL_PANES; i++)
812 if(pane[i] && pane[i]->patchbay)
814 pane[i]->patchbay->reset_meters();
819 void MWindowGUI::stop_meters()
821 for(int i = 0; i < TOTAL_PANES; i++)
823 if(pane[i] && pane[i]->patchbay)
825 pane[i]->patchbay->stop_meters();
830 void MWindowGUI::update_meters(ArrayList<double> *module_levels)
832 for(int i = 0; i < TOTAL_PANES; i++)
834 if(pane[i] && pane[i]->patchbay)
836 pane[i]->patchbay->update_meters(module_levels);
841 void MWindowGUI::set_editing_mode(int flush)
843 for(int i = 0; i < TOTAL_PANES; i++)
847 pane[i]->canvas->update_cursor(flush);
852 void MWindowGUI::set_meter_format(int mode, int min, int max)
854 for(int i = 0; i < TOTAL_PANES; i++)
856 if(pane[i] && pane[i]->patchbay)
858 pane[i]->patchbay->set_meter_format(mode, min, max);
863 void MWindowGUI::update(int scrollbars,
872 if(debug) PRINT_TRACE
876 mwindow->edl->tracks->update_y_pixels(mwindow->theme);
878 if(do_canvas && do_canvas != IGNORE_THREAD)
880 resource_thread->stop_draw(1);
883 for(int i = 0; i < TOTAL_PANES; i++)
885 if(pane[i]) pane[i]->update(scrollbars,
891 if(do_canvas && do_canvas != IGNORE_THREAD)
893 resource_thread->start_draw();
896 // if(scrollbars) this->get_scrollbars(0);
897 // if(timebar) this->timebar->update(0);
898 if(zoombar) this->zoombar->update();
899 // if(patchbay) this->patchbay->update();
900 if(clock) this->mainclock->update(
901 mwindow->edl->local_session->get_selectionstart(1));
902 if(debug) PRINT_TRACE
908 // this->canvas->draw(do_canvas);
909 // this->cursor->show();
910 // this->canvas->flash(0);
911 // Activate causes the menubar to deactivate. Don't want this for
913 // if(canvas != IGNORE_THREAD) this->canvas->activate();
915 if(debug) PRINT_TRACE
919 if(buttonbar) mbuttons->update();
920 if(debug) PRINT_TRACE
922 // Can't age if the cache called this to draw missing picons
923 // or the GUI is updating the status of the draw toggle.
924 if(do_canvas != FORCE_REDRAW && do_canvas != IGNORE_THREAD)
927 mwindow->age_caches();
928 lock_window("MWindowGUI::update");
932 if(debug) PRINT_TRACE
935 int MWindowGUI::visible(int64_t x1, int64_t x2, int64_t view_x1, int64_t view_x2)
937 return (x1 >= view_x1 && x1 < view_x2) ||
938 (x2 > view_x1 && x2 <= view_x2) ||
939 (x1 <= view_x1 && x2 >= view_x2);
943 void MWindowGUI::show_message(const char *message, int color)
945 statusbar->show_message(message, color);
948 void MWindowGUI::update_default_message()
950 statusbar->update_default_message();
953 void MWindowGUI::reset_default_message()
955 statusbar->reset_default_message();
958 void MWindowGUI::default_message()
960 statusbar->default_message();
963 // Drag motion called from other window
964 int MWindowGUI::drag_motion()
966 if(get_hidden()) return 0;
968 Track *over_track = 0;
970 PluginSet *over_pluginset = 0;
971 Plugin *over_plugin = 0;
976 drag_popup->cursor_motion_event();
980 // there's no point in drawing highlights has until drag operation has been set
981 if (!mwindow->session->current_operation)
984 for(int i = 0; i < TOTAL_PANES; i++)
986 if(pane[i]) pane[i]->canvas->drag_motion(
993 if(mwindow->session->track_highlighted != over_track)
995 mwindow->session->track_highlighted = over_track;
999 if(mwindow->session->edit_highlighted != over_edit)
1001 mwindow->session->edit_highlighted = over_edit;
1005 if(mwindow->session->pluginset_highlighted != over_pluginset)
1007 mwindow->session->pluginset_highlighted = over_pluginset;
1011 if(mwindow->session->plugin_highlighted != over_plugin)
1013 mwindow->session->plugin_highlighted = over_plugin;
1017 if( mwindow->session->current_operation == DRAG_ASSET ||
1018 mwindow->session->current_operation == DRAG_EDIT ||
1019 mwindow->session->current_operation == DRAG_AEFFECT_COPY ||
1020 mwindow->session->current_operation == DRAG_VEFFECT_COPY )
1026 // printf("drag_motion %d %d over_track=%p over_edit=%p\n",
1033 lock_window("MWindowGUI::drag_motion");
1040 int MWindowGUI::drag_stop()
1042 if(get_hidden()) return 0;
1043 int result = 0, redraw = 0;
1045 for(int i = 0; i < TOTAL_PANES; i++)
1047 if(pane[i]) result |= pane[i]->canvas->drag_stop(
1050 mwindow->edl->optimize();
1052 // since we don't have subwindows we have to terminate any drag operation
1055 if (mwindow->session->track_highlighted
1056 || mwindow->session->edit_highlighted
1057 || mwindow->session->plugin_highlighted
1058 || mwindow->session->pluginset_highlighted)
1060 mwindow->session->track_highlighted = 0;
1061 mwindow->session->edit_highlighted = 0;
1062 mwindow->session->plugin_highlighted = 0;
1063 mwindow->session->pluginset_highlighted = 0;
1064 mwindow->session->current_operation = NO_OPERATION;
1068 //printf("MWindowGUI::drag_stop %d %d\n", redraw, mwindow->session->current_operation);
1071 mwindow->edl->tracks->update_y_pixels(mwindow->theme);
1072 update_scrollbars(0);
1087 void MWindowGUI::default_positions()
1089 //printf("MWindowGUI::default_positions 1\n");
1090 VWindow *vwindow = mwindow->vwindows.size() > DEFAULT_VWINDOW ?
1091 mwindow->vwindows.get(DEFAULT_VWINDOW) : 0;
1092 if( vwindow && !vwindow->is_running() ) vwindow = 0;
1093 if( vwindow ) vwindow->gui->lock_window("MWindowGUI::default_positions");
1094 mwindow->cwindow->gui->lock_window("MWindowGUI::default_positions");
1095 mwindow->awindow->gui->lock_window("MWindowGUI::default_positions");
1097 // printf("MWindowGUI::default_positions 1 %d %d %d %d\n", mwindow->session->vwindow_x,
1098 // mwindow->session->vwindow_y,
1099 // mwindow->session->vwindow_w,
1100 // mwindow->session->vwindow_h);
1101 reposition_window(mwindow->session->mwindow_x,
1102 mwindow->session->mwindow_y,
1103 mwindow->session->mwindow_w,
1104 mwindow->session->mwindow_h);
1105 if( vwindow ) vwindow->gui->reposition_window(mwindow->session->vwindow_x,
1106 mwindow->session->vwindow_y,
1107 mwindow->session->vwindow_w,
1108 mwindow->session->vwindow_h);
1109 mwindow->cwindow->gui->reposition_window(mwindow->session->cwindow_x,
1110 mwindow->session->cwindow_y,
1111 mwindow->session->cwindow_w,
1112 mwindow->session->cwindow_h);
1113 mwindow->awindow->gui->reposition_window(mwindow->session->awindow_x,
1114 mwindow->session->awindow_y,
1115 mwindow->session->awindow_w,
1116 mwindow->session->awindow_h);
1117 //printf("MWindowGUI::default_positions 1\n");
1119 resize_event(mwindow->session->mwindow_w,
1120 mwindow->session->mwindow_h);
1121 //printf("MWindowGUI::default_positions 1\n");
1122 if( vwindow ) vwindow->gui->resize_event(mwindow->session->vwindow_w,
1123 mwindow->session->vwindow_h);
1124 //printf("MWindowGUI::default_positions 1\n");
1125 mwindow->cwindow->gui->resize_event(mwindow->session->cwindow_w,
1126 mwindow->session->cwindow_h);
1127 //printf("MWindowGUI::default_positions 1\n");
1128 mwindow->awindow->gui->resize_event(mwindow->session->awindow_w,
1129 mwindow->session->awindow_h);
1131 //printf("MWindowGUI::default_positions 1\n");
1134 if( vwindow ) vwindow->gui->flush();
1135 mwindow->cwindow->gui->flush();
1136 mwindow->awindow->gui->flush();
1138 if( vwindow ) vwindow->gui->unlock_window();
1139 mwindow->cwindow->gui->unlock_window();
1140 mwindow->awindow->gui->unlock_window();
1141 //printf("MWindowGUI::default_positions 2\n");
1145 int MWindowGUI::button_release_event()
1147 if( keyvalue_popup ) {
1148 delete keyvalue_popup; keyvalue_popup = 0;
1154 int MWindowGUI::repeat_event(int64_t duration)
1156 // if(duration == 100)
1157 // mwindow->sync_parameters(CHANGE_ALL);
1159 for(int i = 0; i < TOTAL_PANES; i++)
1161 if(pane[i]) result = pane[i]->cursor->repeat_event(duration);
1167 int MWindowGUI::translation_event()
1169 //printf("MWindowGUI::translation_event 1 %d %d\n", get_x(), get_y());
1170 mwindow->session->mwindow_x = get_x();
1171 mwindow->session->mwindow_y = get_y();
1176 int MWindowGUI::save_defaults(BC_Hash *defaults)
1178 defaults->update("MWINDOWWIDTH", get_w());
1179 defaults->update("MWINDOWHEIGHT", get_h());
1180 mainmenu->save_defaults(defaults);
1181 BC_WindowBase::save_defaults(defaults);
1185 int MWindowGUI::keypress_event()
1187 //printf("MWindowGUI::keypress_event 1 %d\n", get_keypress());
1188 int result = mbuttons->keypress_event();
1189 if( result ) return result;
1191 Track *this_track = 0;
1193 switch(get_keypress()) {
1195 mwindow->toggle_editing_mode();
1200 if( alt_down() ) break;
1201 stop_transport("MWindowGUI::keypress_event 1");
1202 mwindow->nearest_plugin_keyframe(shift_down(),
1203 !ctrl_down() ? PLAY_FORWARD : PLAY_REVERSE);
1207 case '1': case '2': case '3': case '4':
1208 case '5': case '6': case '7': case '8':
1209 if( !alt_down() || shift_down() ) break;
1210 if( !mwindow->select_asset(get_keypress()-'1',1) )
1215 if( !ctrl_down() ) {
1217 stop_transport("MWindowGUI::keypress_event 1");
1218 mwindow->prev_edit_handle(shift_down());
1221 mwindow->move_left();
1227 if( !ctrl_down() && !alt_down() ) {
1228 mwindow->move_left();
1234 if( !ctrl_down() ) {
1236 stop_transport("MWindowGUI::keypress_event 2");
1237 mwindow->next_edit_handle(shift_down());
1240 mwindow->move_right();
1246 if( !ctrl_down() && !alt_down() ) {
1247 mwindow->move_right();
1253 if( ctrl_down() && !alt_down() )
1254 mwindow->expand_y();
1255 else if( !ctrl_down() && alt_down() )
1256 mwindow->expand_autos(0,1,1);
1257 else if( ctrl_down() && alt_down() )
1258 mwindow->expand_autos(1,1,1);
1260 mwindow->expand_sample();
1265 if( ctrl_down() && !alt_down() )
1266 mwindow->zoom_in_y();
1267 else if( !ctrl_down() && alt_down() )
1268 mwindow->shrink_autos(0,1,1);
1269 else if( ctrl_down() && alt_down() )
1270 mwindow->shrink_autos(1,1,1);
1272 mwindow->zoom_in_sample();
1280 mwindow->expand_t();
1286 mwindow->move_down();
1288 mwindow->zoom_in_t();
1294 for( int i=0; i<TOTAL_PANES; ++i ) {
1295 if( !pane[i] ) continue;
1296 if( (this_track = pane[i]->over_track()) != 0 ) break;
1297 if( (this_track = pane[i]->over_patchbay()) != 0 ) break;
1300 if( get_keypress() == TAB ) { // Switch the record button
1302 this_track->record = !this_track->record ? 1 : 0;
1305 int total_selected = mwindow->edl->tracks->total_of(Tracks::RECORD);
1306 // all selected if nothing previously selected or
1307 // if this patch was previously the only one selected and armed
1308 int selected = !total_selected || (total_selected == 1 &&
1309 this_track && this_track->record ) ? 1 : 0;
1310 mwindow->edl->tracks->select_all(Tracks::RECORD, selected);
1311 if( !selected && this_track ) this_track->record = 1;
1314 update(0, 1, 0, 0, 1, 0, 1);
1316 mwindow->cwindow->update(0, 1, 1);
1317 lock_window("MWindowGUI::keypress_event 3");
1334 resend_event(mwindow->cwindow->gui);
1338 // since things under cursor have changed...
1340 cursor_motion_event();
1345 int MWindowGUI::keyboard_listener(BC_WindowBase *wp)
1347 return key_listener(wp->get_keypress());
1350 int MWindowGUI::key_listener(int key)
1355 if( !record->running() )
1358 record->record_gui->interrupt_thread->start(0);
1365 channel_info->toggle_scan();
1369 if( !remote_control->deactivate() )
1370 remote_control->activate();
1380 void MWindowGUI::use_android_remote(int on)
1383 delete android_control;
1384 android_control = 0;
1387 if( android_control ) return;
1388 android_control = new AndroidControl(this);
1391 int MWindowGUI::close_event()
1397 void MWindowGUI::stop_drawing()
1399 resource_thread->stop_draw(1);
1402 int MWindowGUI::menu_w()
1404 return mainmenu->get_w();
1407 int MWindowGUI::menu_h()
1409 return mainmenu->get_h();
1412 void MWindowGUI::start_x_pane_drag()
1416 x_pane_drag = new BC_Popup(this,
1417 get_abs_cursor_x(0) - mwindow->theme->pane_w,
1418 BC_DisplayInfo::get_top_border() +
1420 mwindow->theme->mcanvas_y,
1421 mwindow->theme->pane_w,
1422 mwindow->theme->mcanvas_h,
1423 mwindow->theme->drag_pane_color);
1424 x_pane_drag->draw_3segmentv(0,
1426 x_pane_drag->get_h(),
1427 mwindow->theme->get_image_set("xpane")[BUTTON_DOWNHI]);
1428 x_pane_drag->flash(1);
1433 void MWindowGUI::start_y_pane_drag()
1437 //printf("MWindowGUI::start_y_pane_drag %d %d %d\n", __LINE__, get_x(), get_y());
1438 y_pane_drag = new BC_Popup(this,
1439 BC_DisplayInfo::get_left_border() +
1441 mwindow->theme->mcanvas_x,
1442 get_abs_cursor_y(0) - mwindow->theme->pane_h,
1443 mwindow->theme->mcanvas_w,
1444 mwindow->theme->pane_h,
1445 mwindow->theme->drag_pane_color);
1446 y_pane_drag->draw_3segmenth(0,
1448 y_pane_drag->get_w(),
1449 mwindow->theme->get_image_set("ypane")[BUTTON_DOWNHI]);
1450 y_pane_drag->flash(1);
1455 void MWindowGUI::handle_pane_drag()
1461 x_pane_drag->reposition_window(
1462 get_abs_cursor_x(0) - mwindow->theme->pane_w,
1463 x_pane_drag->get_y());
1468 y_pane_drag->reposition_window(
1469 y_pane_drag->get_x(),
1470 get_abs_cursor_y(0) - mwindow->theme->pane_h);
1476 void MWindowGUI::create_x_pane(int cursor_x)
1478 if(total_panes() == 1)
1480 // create a horizontal pane
1481 // do this 1st so the resize_event knows there are 2 panes
1482 mwindow->edl->local_session->view_start[TOP_RIGHT_PANE] =
1483 mwindow->edl->local_session->view_start[TOP_LEFT_PANE] +
1485 mwindow->theme->patchbay_w;
1486 pane[TOP_RIGHT_PANE] = new TimelinePane(mwindow,
1488 mwindow->theme->mcanvas_x +
1490 mwindow->theme->mcanvas_y,
1491 mwindow->theme->mcanvas_x +
1492 mwindow->theme->mcanvas_w -
1494 mwindow->theme->mcanvas_h);
1495 pane[TOP_LEFT_PANE]->resize_event(
1496 mwindow->theme->mcanvas_x,
1497 mwindow->theme->mcanvas_y,
1498 cursor_x - mwindow->theme->pane_w,
1499 mwindow->theme->mcanvas_h);
1500 pane[TOP_RIGHT_PANE]->create_objects();
1503 if(vertical_panes())
1505 // create 2 horizontal panes
1506 mwindow->edl->local_session->track_start[TOP_RIGHT_PANE] =
1507 mwindow->edl->local_session->track_start[TOP_LEFT_PANE];
1508 mwindow->edl->local_session->track_start[BOTTOM_RIGHT_PANE] =
1509 mwindow->edl->local_session->track_start[BOTTOM_LEFT_PANE];
1510 mwindow->edl->local_session->view_start[TOP_RIGHT_PANE] =
1511 mwindow->edl->local_session->view_start[BOTTOM_RIGHT_PANE] =
1512 mwindow->edl->local_session->view_start[TOP_LEFT_PANE] +
1514 mwindow->theme->patchbay_w;
1515 pane[TOP_RIGHT_PANE] = new TimelinePane(mwindow,
1517 mwindow->theme->mcanvas_x +
1519 pane[TOP_LEFT_PANE]->y,
1520 mwindow->theme->mcanvas_x +
1521 mwindow->theme->mcanvas_w -
1523 pane[TOP_LEFT_PANE]->h);
1524 pane[BOTTOM_RIGHT_PANE] = new TimelinePane(mwindow,
1526 mwindow->theme->mcanvas_x +
1528 pane[BOTTOM_LEFT_PANE]->y,
1529 mwindow->theme->mcanvas_x +
1530 mwindow->theme->mcanvas_w -
1532 pane[BOTTOM_LEFT_PANE]->h);
1533 pane[TOP_LEFT_PANE]->resize_event(
1534 pane[TOP_LEFT_PANE]->x,
1535 pane[TOP_LEFT_PANE]->y,
1536 cursor_x - mwindow->theme->pane_w,
1537 pane[TOP_LEFT_PANE]->h);
1538 pane[BOTTOM_LEFT_PANE]->resize_event(
1539 pane[BOTTOM_LEFT_PANE]->x,
1540 pane[BOTTOM_LEFT_PANE]->y,
1541 cursor_x - mwindow->theme->pane_w,
1542 pane[BOTTOM_LEFT_PANE]->h);
1543 pane[TOP_RIGHT_PANE]->create_objects();
1544 pane[BOTTOM_RIGHT_PANE]->create_objects();
1547 if(horizontal_panes())
1549 // resize a horizontal pane
1550 mwindow->edl->local_session->view_start[TOP_RIGHT_PANE] +=
1552 pane[TOP_RIGHT_PANE]->x;
1553 if(mwindow->edl->local_session->view_start[TOP_RIGHT_PANE] < 0)
1554 mwindow->edl->local_session->view_start[TOP_RIGHT_PANE] = 0;
1555 pane[TOP_LEFT_PANE]->resize_event(
1556 mwindow->theme->mcanvas_x,
1557 mwindow->theme->mcanvas_y,
1558 cursor_x - mwindow->theme->pane_w,
1559 mwindow->theme->mcanvas_h);
1560 pane[TOP_RIGHT_PANE]->resize_event(
1561 mwindow->theme->mcanvas_x +
1563 pane[TOP_RIGHT_PANE]->y,
1564 mwindow->theme->mcanvas_x +
1565 mwindow->theme->mcanvas_w -
1567 mwindow->theme->mcanvas_h);
1571 // resize 2 horizontal panes
1572 mwindow->edl->local_session->view_start[TOP_RIGHT_PANE] +=
1574 pane[TOP_RIGHT_PANE]->x;
1575 if(mwindow->edl->local_session->view_start[TOP_RIGHT_PANE] < 0)
1576 mwindow->edl->local_session->view_start[TOP_RIGHT_PANE] = 0;
1577 mwindow->edl->local_session->view_start[BOTTOM_RIGHT_PANE] =
1578 mwindow->edl->local_session->view_start[TOP_RIGHT_PANE];
1580 pane[TOP_LEFT_PANE]->resize_event(
1581 mwindow->theme->mcanvas_x,
1582 pane[TOP_LEFT_PANE]->y,
1583 cursor_x - mwindow->theme->pane_w,
1584 pane[TOP_LEFT_PANE]->h);
1585 pane[TOP_RIGHT_PANE]->resize_event(
1586 mwindow->theme->mcanvas_x +
1588 pane[TOP_RIGHT_PANE]->y,
1589 mwindow->theme->mcanvas_x +
1590 mwindow->theme->mcanvas_w -
1592 pane[TOP_RIGHT_PANE]->h);
1593 pane[BOTTOM_LEFT_PANE]->resize_event(
1594 mwindow->theme->mcanvas_x,
1595 pane[BOTTOM_LEFT_PANE]->y,
1596 cursor_x - mwindow->theme->pane_w,
1597 pane[BOTTOM_LEFT_PANE]->h);
1598 pane[BOTTOM_RIGHT_PANE]->resize_event(
1599 mwindow->theme->mcanvas_x +
1601 pane[BOTTOM_RIGHT_PANE]->y,
1602 mwindow->theme->mcanvas_x +
1603 mwindow->theme->mcanvas_w -
1605 pane[BOTTOM_RIGHT_PANE]->h);
1611 void MWindowGUI::delete_x_pane(int cursor_x)
1613 // give left panes coordinates of right pane
1614 if(cursor_x < mwindow->theme->patchbay_w + PANE_DRAG_MARGIN &&
1615 pane[TOP_RIGHT_PANE])
1617 mwindow->edl->local_session->view_start[TOP_LEFT_PANE] =
1618 mwindow->edl->local_session->view_start[TOP_RIGHT_PANE] -
1619 pane[TOP_RIGHT_PANE]->x + mwindow->theme->patchbay_w;
1620 if(mwindow->edl->local_session->view_start[TOP_LEFT_PANE] < 0)
1621 mwindow->edl->local_session->view_start[TOP_LEFT_PANE] = 0;
1622 mwindow->edl->local_session->view_start[BOTTOM_LEFT_PANE] =
1623 mwindow->edl->local_session->view_start[TOP_LEFT_PANE];
1626 switch(total_panes())
1629 if(pane[TOP_LEFT_PANE] && pane[TOP_RIGHT_PANE])
1631 // delete right pane
1632 delete pane[TOP_RIGHT_PANE];
1633 pane[TOP_RIGHT_PANE] = 0;
1634 pane[TOP_LEFT_PANE]->resize_event(
1635 mwindow->theme->mcanvas_x,
1636 mwindow->theme->mcanvas_y,
1637 mwindow->theme->mcanvas_w,
1638 mwindow->theme->mcanvas_h);
1644 // delete right panes
1645 delete pane[TOP_RIGHT_PANE];
1646 pane[TOP_RIGHT_PANE] = 0;
1647 delete pane[BOTTOM_RIGHT_PANE];
1648 pane[BOTTOM_RIGHT_PANE] = 0;
1649 pane[TOP_LEFT_PANE]->resize_event(
1650 mwindow->theme->mcanvas_x,
1651 pane[TOP_LEFT_PANE]->y,
1652 mwindow->theme->mcanvas_w,
1653 pane[TOP_LEFT_PANE]->h);
1654 pane[BOTTOM_LEFT_PANE]->resize_event(
1655 mwindow->theme->mcanvas_x,
1656 pane[BOTTOM_LEFT_PANE]->y,
1657 mwindow->theme->mcanvas_w,
1658 pane[BOTTOM_LEFT_PANE]->h);
1663 void MWindowGUI::create_y_pane(int cursor_y)
1665 if(total_panes() == 1)
1667 mwindow->edl->local_session->view_start[BOTTOM_LEFT_PANE] =
1668 mwindow->edl->local_session->view_start[TOP_LEFT_PANE];
1669 mwindow->edl->local_session->track_start[BOTTOM_LEFT_PANE] =
1670 mwindow->edl->local_session->track_start[TOP_LEFT_PANE] +
1672 mwindow->theme->mtimebar_h;
1673 // do this 1st so the resize_event knows there are 2 panes
1674 pane[BOTTOM_LEFT_PANE] = new TimelinePane(mwindow,
1676 mwindow->theme->mcanvas_x,
1677 mwindow->theme->mcanvas_y +
1679 mwindow->theme->mcanvas_w,
1680 mwindow->theme->mcanvas_h -
1682 pane[TOP_LEFT_PANE]->resize_event(
1683 mwindow->theme->mcanvas_x,
1684 mwindow->theme->mcanvas_y,
1685 mwindow->theme->mcanvas_w,
1686 pane[BOTTOM_LEFT_PANE]->y -
1687 mwindow->theme->mcanvas_y -
1688 mwindow->theme->pane_h);
1689 pane[BOTTOM_LEFT_PANE]->create_objects();
1692 if(horizontal_panes())
1695 mwindow->edl->local_session->view_start[BOTTOM_LEFT_PANE] =
1696 mwindow->edl->local_session->view_start[TOP_LEFT_PANE];
1697 mwindow->edl->local_session->view_start[BOTTOM_RIGHT_PANE] =
1698 mwindow->edl->local_session->view_start[TOP_RIGHT_PANE];
1699 mwindow->edl->local_session->track_start[BOTTOM_LEFT_PANE] =
1700 mwindow->edl->local_session->track_start[BOTTOM_RIGHT_PANE] =
1701 mwindow->edl->local_session->track_start[TOP_LEFT_PANE] +
1703 mwindow->theme->mtimebar_h;
1705 pane[BOTTOM_LEFT_PANE] = new TimelinePane(mwindow,
1707 pane[TOP_LEFT_PANE]->x,
1708 mwindow->theme->mcanvas_y +
1710 pane[TOP_LEFT_PANE]->w,
1711 mwindow->theme->mcanvas_h -
1713 pane[BOTTOM_RIGHT_PANE] = new TimelinePane(mwindow,
1715 pane[TOP_RIGHT_PANE]->x,
1716 mwindow->theme->mcanvas_y +
1718 pane[TOP_RIGHT_PANE]->w,
1719 mwindow->theme->mcanvas_h -
1722 pane[TOP_LEFT_PANE]->resize_event(
1723 pane[TOP_LEFT_PANE]->x,
1724 pane[TOP_LEFT_PANE]->y,
1725 pane[TOP_LEFT_PANE]->w,
1726 pane[BOTTOM_LEFT_PANE]->y -
1727 mwindow->theme->mcanvas_y -
1728 mwindow->theme->pane_h);
1729 pane[TOP_RIGHT_PANE]->resize_event(
1730 pane[TOP_RIGHT_PANE]->x,
1731 pane[TOP_RIGHT_PANE]->y,
1732 pane[TOP_RIGHT_PANE]->w,
1733 pane[BOTTOM_RIGHT_PANE]->y -
1734 mwindow->theme->mcanvas_y -
1735 mwindow->theme->pane_h);
1737 pane[BOTTOM_LEFT_PANE]->create_objects();
1738 pane[BOTTOM_RIGHT_PANE]->create_objects();
1741 if(vertical_panes())
1744 mwindow->edl->local_session->track_start[BOTTOM_LEFT_PANE] +=
1746 (pane[BOTTOM_LEFT_PANE]->y - mwindow->theme->mcanvas_y);
1747 if(mwindow->edl->local_session->track_start[BOTTOM_LEFT_PANE] < 0)
1748 mwindow->edl->local_session->track_start[BOTTOM_LEFT_PANE] = 0;
1749 pane[TOP_LEFT_PANE]->resize_event(
1750 mwindow->theme->mcanvas_x,
1751 mwindow->theme->mcanvas_y,
1752 mwindow->theme->mcanvas_w,
1753 cursor_y - mwindow->theme->pane_h);
1754 pane[BOTTOM_LEFT_PANE]->resize_event(
1755 pane[BOTTOM_LEFT_PANE]->x,
1757 mwindow->theme->mcanvas_y,
1758 mwindow->theme->mcanvas_w,
1759 mwindow->theme->mcanvas_h -
1765 mwindow->edl->local_session->track_start[BOTTOM_LEFT_PANE] +=
1767 (pane[BOTTOM_LEFT_PANE]->y - mwindow->theme->mcanvas_y);
1768 if(mwindow->edl->local_session->track_start[BOTTOM_LEFT_PANE] < 0)
1769 mwindow->edl->local_session->track_start[BOTTOM_LEFT_PANE] = 0;
1770 mwindow->edl->local_session->track_start[BOTTOM_RIGHT_PANE] =
1771 mwindow->edl->local_session->track_start[BOTTOM_LEFT_PANE];
1772 pane[TOP_LEFT_PANE]->resize_event(
1773 pane[TOP_LEFT_PANE]->x,
1774 pane[TOP_LEFT_PANE]->y,
1775 pane[TOP_LEFT_PANE]->w,
1776 cursor_y - mwindow->theme->pane_h);
1777 pane[BOTTOM_LEFT_PANE]->resize_event(
1778 pane[BOTTOM_LEFT_PANE]->x,
1780 mwindow->theme->mcanvas_y,
1781 pane[BOTTOM_LEFT_PANE]->w,
1782 mwindow->theme->mcanvas_h -
1784 pane[TOP_RIGHT_PANE]->resize_event(
1785 pane[TOP_RIGHT_PANE]->x,
1786 pane[TOP_RIGHT_PANE]->y,
1787 pane[TOP_RIGHT_PANE]->w,
1788 cursor_y - mwindow->theme->pane_h);
1789 pane[BOTTOM_RIGHT_PANE]->resize_event(
1790 pane[BOTTOM_RIGHT_PANE]->x,
1792 mwindow->theme->mcanvas_y,
1793 pane[BOTTOM_RIGHT_PANE]->w,
1794 mwindow->theme->mcanvas_h -
1799 void MWindowGUI::delete_y_pane(int cursor_y)
1801 if(cursor_y < mwindow->theme->mtimebar_h +
1803 pane[BOTTOM_LEFT_PANE])
1805 // give top pane coordinates of bottom pane
1806 mwindow->edl->local_session->track_start[TOP_LEFT_PANE] =
1807 mwindow->edl->local_session->track_start[BOTTOM_LEFT_PANE] -
1808 pane[BOTTOM_LEFT_PANE]->y;
1809 if(mwindow->edl->local_session->track_start[TOP_LEFT_PANE] < 0)
1810 mwindow->edl->local_session->track_start[TOP_LEFT_PANE] = 0;
1811 mwindow->edl->local_session->track_start[TOP_RIGHT_PANE] =
1812 mwindow->edl->local_session->track_start[TOP_LEFT_PANE];
1816 switch(total_panes())
1819 delete pane[BOTTOM_LEFT_PANE];
1820 pane[BOTTOM_LEFT_PANE] = 0;
1821 pane[TOP_LEFT_PANE]->resize_event(
1822 mwindow->theme->mcanvas_x,
1823 mwindow->theme->mcanvas_y,
1824 mwindow->theme->mcanvas_w,
1825 mwindow->theme->mcanvas_h);
1829 // delete bottom 2 panes
1831 delete pane[BOTTOM_LEFT_PANE];
1832 pane[BOTTOM_LEFT_PANE] = 0;
1833 delete pane[BOTTOM_RIGHT_PANE];
1834 pane[BOTTOM_RIGHT_PANE] = 0;
1835 pane[TOP_LEFT_PANE]->resize_event(
1836 pane[TOP_LEFT_PANE]->x,
1837 mwindow->theme->mcanvas_y,
1838 pane[TOP_LEFT_PANE]->w,
1839 mwindow->theme->mcanvas_h);
1840 pane[TOP_RIGHT_PANE]->resize_event(
1841 pane[TOP_RIGHT_PANE]->x,
1842 mwindow->theme->mcanvas_y,
1843 pane[TOP_RIGHT_PANE]->w,
1844 mwindow->theme->mcanvas_h);
1849 void MWindowGUI::stop_pane_drag()
1852 resource_thread->stop_draw(1);
1856 // cursor position relative to canvas
1857 int cursor_x = x_pane_drag->get_x() -
1859 BC_DisplayInfo::get_left_border() -
1860 mwindow->theme->mcanvas_x +
1861 mwindow->theme->pane_w;
1866 if(cursor_x >= mwindow->theme->patchbay_w + PANE_DRAG_MARGIN &&
1867 cursor_x < mwindow->theme->mcanvas_w -
1868 BC_ScrollBar::get_span(SCROLL_VERT) -
1871 create_x_pane(cursor_x);
1872 mwindow->edl->local_session->x_pane = cursor_x;
1877 delete_x_pane(cursor_x);
1878 mwindow->edl->local_session->x_pane = -1;
1886 // cursor position relative to canvas
1887 int cursor_y = y_pane_drag->get_y() -
1889 BC_DisplayInfo::get_top_border() -
1890 mwindow->theme->mcanvas_y +
1891 mwindow->theme->pane_h;
1897 if(cursor_y >= mwindow->theme->mtimebar_h +
1899 cursor_y < mwindow->theme->mcanvas_h -
1900 BC_ScrollBar::get_span(SCROLL_HORIZ) -
1903 create_y_pane(cursor_y);
1904 mwindow->edl->local_session->y_pane = cursor_y;
1908 delete_y_pane(cursor_y);
1909 mwindow->edl->local_session->y_pane = -1;
1913 update_pane_dividers();
1915 // required to get new widgets to appear
1917 resource_thread->start_draw();
1920 // create panes from EDL
1921 void MWindowGUI::load_panes()
1923 int need_x_panes = 0;
1924 int need_y_panes = 0;
1925 // use names from create functions
1926 int cursor_x = mwindow->edl->local_session->x_pane;
1927 int cursor_y = mwindow->edl->local_session->y_pane;
1929 resource_thread->stop_draw(1);
1931 mwindow->theme->patchbay_w + PANE_DRAG_MARGIN &&
1933 mwindow->theme->mcanvas_w -
1934 BC_ScrollBar::get_span(SCROLL_VERT) -
1941 mwindow->theme->mtimebar_h + PANE_DRAG_MARGIN &&
1943 mwindow->theme->mcanvas_h -
1944 BC_ScrollBar::get_span(SCROLL_HORIZ) -
1950 //printf("MWindowGUI::load_panes %d %d %d\n", __LINE__, need_x_panes, need_y_panes);
1958 if(total_panes() == 1)
1961 //printf("MWindowGUI::load_panes %d\n", __LINE__);
1962 pane[TOP_RIGHT_PANE] = new TimelinePane(mwindow,
1964 mwindow->theme->mcanvas_x +
1966 mwindow->theme->mcanvas_y,
1967 mwindow->theme->mcanvas_x +
1968 mwindow->theme->mcanvas_w -
1970 cursor_y - mwindow->theme->pane_h);
1971 pane[BOTTOM_LEFT_PANE] = new TimelinePane(mwindow,
1973 mwindow->theme->mcanvas_x,
1974 mwindow->theme->mcanvas_y +
1976 cursor_x - mwindow->theme->pane_w,
1977 mwindow->theme->mcanvas_h -
1979 pane[BOTTOM_RIGHT_PANE] = new TimelinePane(mwindow,
1981 pane[TOP_RIGHT_PANE]->x,
1982 mwindow->theme->mcanvas_y +
1984 pane[TOP_RIGHT_PANE]->w,
1985 mwindow->theme->mcanvas_h -
1987 pane[TOP_LEFT_PANE]->resize_event(
1988 pane[TOP_LEFT_PANE]->x,
1989 pane[TOP_LEFT_PANE]->y,
1990 cursor_x - mwindow->theme->pane_w,
1991 cursor_y - mwindow->theme->pane_h);
1992 pane[TOP_RIGHT_PANE]->create_objects();
1993 pane[BOTTOM_LEFT_PANE]->create_objects();
1994 pane[BOTTOM_RIGHT_PANE]->create_objects();
1997 if(horizontal_panes())
1999 // create vertical panes
2000 //printf("MWindowGUI::load_panes %d\n", __LINE__);
2001 pane[BOTTOM_LEFT_PANE] = new TimelinePane(mwindow,
2003 mwindow->theme->mcanvas_x,
2004 mwindow->theme->mcanvas_y +
2006 cursor_x - mwindow->theme->pane_w,
2007 mwindow->theme->mcanvas_h -
2009 pane[BOTTOM_RIGHT_PANE] = new TimelinePane(mwindow,
2011 pane[TOP_RIGHT_PANE]->x,
2012 mwindow->theme->mcanvas_y +
2014 pane[TOP_RIGHT_PANE]->w,
2015 mwindow->theme->mcanvas_h -
2017 pane[TOP_LEFT_PANE]->resize_event(
2018 pane[TOP_LEFT_PANE]->x,
2019 pane[TOP_LEFT_PANE]->y,
2020 cursor_x - mwindow->theme->pane_w,
2021 cursor_y - mwindow->theme->pane_h);
2022 pane[TOP_RIGHT_PANE]->resize_event(
2023 mwindow->theme->mcanvas_x +
2025 mwindow->theme->mcanvas_y,
2026 mwindow->theme->mcanvas_x +
2027 mwindow->theme->mcanvas_w -
2029 cursor_y - mwindow->theme->pane_h);
2030 pane[BOTTOM_LEFT_PANE]->create_objects();
2031 pane[BOTTOM_RIGHT_PANE]->create_objects();
2034 if(vertical_panes())
2036 // create horizontal panes
2037 //printf("MWindowGUI::load_panes %d\n", __LINE__);
2038 pane[TOP_RIGHT_PANE] = new TimelinePane(mwindow,
2040 mwindow->theme->mcanvas_x +
2042 mwindow->theme->mcanvas_y,
2043 mwindow->theme->mcanvas_x +
2044 mwindow->theme->mcanvas_w -
2046 cursor_y - mwindow->theme->pane_h);
2047 pane[BOTTOM_RIGHT_PANE] = new TimelinePane(mwindow,
2049 pane[TOP_RIGHT_PANE]->x,
2050 mwindow->theme->mcanvas_y +
2052 pane[TOP_RIGHT_PANE]->w,
2053 mwindow->theme->mcanvas_h -
2055 pane[TOP_LEFT_PANE]->resize_event(
2056 pane[TOP_LEFT_PANE]->x,
2057 pane[TOP_LEFT_PANE]->y,
2058 cursor_x - mwindow->theme->pane_w,
2059 cursor_y - mwindow->theme->pane_h);
2060 pane[BOTTOM_LEFT_PANE]->resize_event(
2061 pane[TOP_LEFT_PANE]->x,
2062 mwindow->theme->mcanvas_y +
2064 mwindow->theme->mcanvas_x +
2065 mwindow->theme->mcanvas_w -
2066 cursor_x - mwindow->theme->pane_w,
2067 mwindow->theme->mcanvas_h -
2069 pane[TOP_RIGHT_PANE]->create_objects();
2070 pane[BOTTOM_RIGHT_PANE]->create_objects();
2077 //printf("MWindowGUI::load_panes %d\n", __LINE__);
2078 pane[TOP_LEFT_PANE]->resize_event(
2079 pane[TOP_LEFT_PANE]->x,
2080 pane[TOP_LEFT_PANE]->y,
2081 cursor_x - mwindow->theme->pane_w,
2082 cursor_y - mwindow->theme->pane_h);
2083 pane[TOP_RIGHT_PANE]->resize_event(
2084 mwindow->theme->mcanvas_x +
2086 mwindow->theme->mcanvas_y,
2087 mwindow->theme->mcanvas_x +
2088 mwindow->theme->mcanvas_w -
2090 cursor_y - mwindow->theme->pane_h);
2091 pane[BOTTOM_LEFT_PANE]->resize_event(
2092 pane[TOP_LEFT_PANE]->x,
2093 mwindow->theme->mcanvas_y +
2095 mwindow->theme->mcanvas_x +
2096 mwindow->theme->mcanvas_w -
2097 cursor_x - mwindow->theme->pane_w,
2098 mwindow->theme->mcanvas_h -
2100 pane[BOTTOM_RIGHT_PANE]->resize_event(
2101 pane[TOP_RIGHT_PANE]->x,
2102 mwindow->theme->mcanvas_y +
2104 pane[TOP_RIGHT_PANE]->w,
2105 mwindow->theme->mcanvas_h -
2114 if(pane[BOTTOM_LEFT_PANE]) delete pane[BOTTOM_LEFT_PANE];
2115 if(pane[BOTTOM_RIGHT_PANE]) delete pane[BOTTOM_RIGHT_PANE];
2116 pane[BOTTOM_LEFT_PANE] = 0;
2117 pane[BOTTOM_RIGHT_PANE] = 0;
2119 if(!pane[TOP_RIGHT_PANE])
2121 pane[TOP_RIGHT_PANE] = new TimelinePane(mwindow,
2123 mwindow->theme->mcanvas_x +
2125 mwindow->theme->mcanvas_y,
2126 mwindow->theme->mcanvas_x +
2127 mwindow->theme->mcanvas_w -
2129 mwindow->theme->mcanvas_h);
2130 pane[TOP_LEFT_PANE]->resize_event(
2131 mwindow->theme->mcanvas_x,
2132 mwindow->theme->mcanvas_y,
2133 cursor_x - mwindow->theme->pane_w,
2134 mwindow->theme->mcanvas_h);
2135 pane[TOP_RIGHT_PANE]->create_objects();
2139 pane[TOP_LEFT_PANE]->resize_event(
2140 mwindow->theme->mcanvas_x,
2141 mwindow->theme->mcanvas_y,
2142 cursor_x - mwindow->theme->pane_w,
2143 mwindow->theme->mcanvas_h);
2144 pane[TOP_RIGHT_PANE]->resize_event(
2145 mwindow->theme->mcanvas_x +
2147 pane[TOP_RIGHT_PANE]->y,
2148 mwindow->theme->mcanvas_x +
2149 mwindow->theme->mcanvas_w -
2151 mwindow->theme->mcanvas_h);
2159 if(pane[TOP_RIGHT_PANE]) delete pane[TOP_RIGHT_PANE];
2160 if(pane[BOTTOM_RIGHT_PANE]) delete pane[BOTTOM_RIGHT_PANE];
2161 pane[TOP_RIGHT_PANE] = 0;
2162 pane[BOTTOM_RIGHT_PANE] = 0;
2164 if(!pane[BOTTOM_LEFT_PANE])
2166 //printf("MWindowGUI::load_panes %d\n", __LINE__);
2167 pane[BOTTOM_LEFT_PANE] = new TimelinePane(mwindow,
2169 mwindow->theme->mcanvas_x,
2170 mwindow->theme->mcanvas_y +
2172 mwindow->theme->mcanvas_w,
2173 mwindow->theme->mcanvas_h -
2175 pane[TOP_LEFT_PANE]->resize_event(
2176 mwindow->theme->mcanvas_x,
2177 mwindow->theme->mcanvas_y,
2178 mwindow->theme->mcanvas_w,
2179 pane[BOTTOM_LEFT_PANE]->y -
2180 mwindow->theme->mcanvas_y -
2181 mwindow->theme->pane_h);
2182 pane[BOTTOM_LEFT_PANE]->create_objects();
2186 pane[TOP_LEFT_PANE]->resize_event(
2187 mwindow->theme->mcanvas_x,
2188 mwindow->theme->mcanvas_y,
2189 mwindow->theme->mcanvas_w,
2190 cursor_y - mwindow->theme->pane_h);
2191 pane[BOTTOM_LEFT_PANE]->resize_event(
2192 pane[BOTTOM_LEFT_PANE]->x,
2194 mwindow->theme->mcanvas_y,
2195 mwindow->theme->mcanvas_w,
2196 mwindow->theme->mcanvas_h -
2203 if(pane[TOP_RIGHT_PANE]) delete pane[TOP_RIGHT_PANE];
2204 if(pane[BOTTOM_RIGHT_PANE]) delete pane[BOTTOM_RIGHT_PANE];
2205 if(pane[BOTTOM_LEFT_PANE]) delete pane[BOTTOM_LEFT_PANE];
2206 pane[TOP_RIGHT_PANE] = 0;
2207 pane[BOTTOM_RIGHT_PANE] = 0;
2208 pane[BOTTOM_LEFT_PANE] = 0;
2209 pane[TOP_LEFT_PANE]->resize_event(
2210 mwindow->theme->mcanvas_x,
2211 mwindow->theme->mcanvas_y,
2212 mwindow->theme->mcanvas_w,
2213 mwindow->theme->mcanvas_h);
2216 update_pane_dividers();
2219 resource_thread->start_draw();
2222 void MWindowGUI::update_pane_dividers()
2225 if(horizontal_panes() || total_panes() == 4)
2227 int x = pane[TOP_RIGHT_PANE]->x - mwindow->theme->pane_w;
2228 int y = mwindow->theme->mcanvas_y;
2229 int h = mwindow->theme->mcanvas_h;
2233 add_subwindow(x_divider = new PaneDivider(
2234 mwindow, x, y, h, 1));
2235 x_divider->create_objects();
2239 x_divider->reposition_window(x, y, h);
2252 if(vertical_panes() || total_panes() == 4)
2254 int x = mwindow->theme->mcanvas_x;
2255 int y = pane[BOTTOM_LEFT_PANE]->y -
2256 mwindow->theme->pane_h;
2257 int w = mwindow->theme->mcanvas_w;
2260 add_subwindow(y_divider = new PaneDivider(
2261 mwindow, x, y, w, 0));
2262 y_divider->create_objects();
2266 y_divider->reposition_window(x, y, w);
2280 void MWindowGUI::draw_samplemovement()
2287 update_scrollbars(1);
2290 void MWindowGUI::draw_trackmovement()
2292 update_scrollbars(0);
2299 void MWindowGUI::update_mixers(Track *track, int v)
2301 for( int i=0; i<TOTAL_PANES; ++i ) {
2302 if( !pane[i] ) continue;
2303 PatchBay *patchbay = pane[i]->patchbay;
2304 if( !patchbay ) continue;
2305 for( int j=0; j<patchbay->patches.total; ++j ) {
2306 PatchGUI *patchgui = patchbay->patches.values[j];
2307 if( !patchgui->mix ) continue;
2308 if( !track || patchgui->track == track ) {
2309 patchgui->mix->update(v>=0 ? v :
2310 mwindow->mixer_track_active(patchgui->track));
2316 void MWindowGUI::stop_transport(const char *lock_msg)
2318 if( !mbuttons->transport->is_stopped() ) {
2319 if( lock_msg ) unlock_window();
2320 mbuttons->transport->handle_transport(STOP, 1, 0, 0);
2321 if( lock_msg ) lock_window(lock_msg);
2325 PaneButton::PaneButton(MWindow *mwindow, int x, int y)
2326 : BC_Button(x, y, mwindow->theme->get_image_set("pane"))
2328 this->mwindow = mwindow;
2331 int PaneButton::cursor_motion_event()
2333 if(get_top_level()->get_button_down() &&
2335 get_status() == BUTTON_DOWNHI &&
2338 // printf("PaneButton::cursor_motion_event %d\n", __LINE__);
2340 if(get_cursor_x() < 0 && !mwindow->gui->dragging_pane)
2342 mwindow->gui->start_x_pane_drag();
2345 if(get_cursor_y() < 0 && !mwindow->gui->dragging_pane)
2347 mwindow->gui->start_y_pane_drag();
2351 mwindow->gui->handle_pane_drag();
2353 int result = BC_Button::cursor_motion_event();
2357 int PaneButton::button_release_event()
2359 if( get_buttonpress() != WHEEL_DOWN && get_buttonpress() != WHEEL_UP )
2360 mwindow->gui->stop_pane_drag();
2361 int result = BC_Button::button_release_event();
2366 FFMpegToggle::FFMpegToggle(MWindow *mwindow, MButtons *mbuttons, int x, int y)
2367 : BC_Toggle(x, y, mwindow->theme->ffmpeg_toggle,
2368 mwindow->preferences->get_file_probe_armed("FFMPEG_Early") > 0 ? 1 : 0)
2370 this->mwindow = mwindow;
2371 this->mbuttons = mbuttons;
2372 set_tooltip(get_value() ? FFMPEG_EARLY_TIP : FFMPEG_LATE_TIP);
2375 FFMpegToggle::~FFMpegToggle()
2379 int FFMpegToggle::handle_event()
2381 int ffmpeg_early_probe = get_value();
2382 set_tooltip(ffmpeg_early_probe ? FFMPEG_EARLY_TIP : FFMPEG_LATE_TIP);
2383 mwindow->preferences->set_file_probe_armed("FFMPEG_Early", ffmpeg_early_probe);
2384 mwindow->preferences->set_file_probe_armed("FFMPEG_Late", !ffmpeg_early_probe);
2386 mwindow->show_warning(&mwindow->preferences->warn_indexes,
2387 _("Changing the base codecs may require rebuilding indexes."));
2392 ProxyToggle::ProxyToggle(MWindow *mwindow, MButtons *mbuttons, int x, int y)
2393 : BC_Toggle(x, y, ( !mwindow->edl->session->proxy_use_scaler ?
2394 mwindow->theme->proxy_p_toggle :
2395 mwindow->theme->proxy_s_toggle ),
2396 mwindow->edl->session->proxy_disabled_scale != 1)
2398 this->mwindow = mwindow;
2399 this->mbuttons = mbuttons;
2400 scaler_images = mwindow->edl->session->proxy_use_scaler;
2401 set_tooltip(mwindow->edl->session->proxy_disabled_scale==1 ?
2402 _("Disable proxy") : _("Enable proxy"));
2405 void ProxyToggle::show()
2407 int use_scaler = mwindow->edl->session->proxy_use_scaler;
2408 if( scaler_images != use_scaler )
2409 set_images(!(scaler_images=use_scaler) ?
2410 mwindow->theme->proxy_p_toggle :
2411 mwindow->theme->proxy_s_toggle );
2417 void ProxyToggle::hide()
2423 ProxyToggle::~ProxyToggle()
2427 int ProxyToggle::handle_event()
2429 int disabled = get_value();
2431 mwindow->disable_proxy();
2433 mwindow->enable_proxy();
2434 set_tooltip(!disabled ? _("Disable proxy") : _("Enable proxy"));
2438 int ProxyToggle::keypress_event()
2440 if( ctrl_down() && !shift_down() && !alt_down() ) {
2441 int key = get_keypress();
2443 int value = get_value() ? 0 : 1;
2445 return handle_event();