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 int value = mwindow->edl->session->proxy_scale == 1 ? 1 : 0;
670 proxy_toggle->set_value(value);
671 if( mwindow->edl->session->proxy_scale == 1 &&
672 mwindow->edl->session->proxy_disabled_scale == 1 )
673 proxy_toggle->hide();
675 proxy_toggle->show();
678 void MWindowGUI::update_plugintoggles()
680 for(int i = 0; i < TOTAL_PANES; i++)
684 pane[i]->canvas->refresh_plugintoggles();
690 void MWindowGUI::draw_indexes(Indexable *indexable)
692 for(int i = 0; i < TOTAL_PANES; i++)
696 pane[i]->canvas->draw_indexes(indexable);
701 void MWindowGUI::draw_canvas(int mode /* = 0 */, int hide_cursor /* = 1 */)
703 if(mode != IGNORE_THREAD)
705 resource_thread->stop_draw(1);
709 for(int i = 0; i < TOTAL_PANES; i++)
713 pane[i]->canvas->draw(mode, hide_cursor);
718 if(mode != IGNORE_THREAD)
720 resource_thread->start_draw();
725 void MWindowGUI::flash_canvas(int flush)
727 for(int i = 0; i < TOTAL_PANES; i++)
731 pane[i]->canvas->flash(flush);
736 int MWindowGUI::show_window(int flush)
738 int ret = BC_WindowBase::show_window(flush);
739 update_proxy_toggle();
743 void MWindowGUI::draw_cursor(int do_plugintoggles)
745 for(int i = 0; i < TOTAL_PANES; i++)
749 pane[i]->cursor->draw(do_plugintoggles);
754 void MWindowGUI::show_cursor(int do_plugintoggles)
756 for(int i = 0; i < TOTAL_PANES; i++)
760 pane[i]->cursor->show(do_plugintoggles);
765 void MWindowGUI::hide_cursor(int do_plugintoggles)
767 for(int i = 0; i < TOTAL_PANES; i++)
771 pane[i]->cursor->hide(do_plugintoggles);
776 void MWindowGUI::update_cursor()
778 for(int i = 0; i < TOTAL_PANES; i++)
782 pane[i]->cursor->update();
787 void MWindowGUI::set_playing_back(int value)
789 for(int i = 0; i < TOTAL_PANES; i++)
793 pane[i]->cursor->playing_back = value;
798 void MWindowGUI::update_scrollbars(int flush)
800 for(int i = 0; i < TOTAL_PANES; i++)
804 pane[i]->update(1, 0, 0, 0);
807 if(flush) this->flush();
810 void MWindowGUI::reset_meters()
812 for(int i = 0; i < TOTAL_PANES; i++)
814 if(pane[i] && pane[i]->patchbay)
816 pane[i]->patchbay->reset_meters();
821 void MWindowGUI::stop_meters()
823 for(int i = 0; i < TOTAL_PANES; i++)
825 if(pane[i] && pane[i]->patchbay)
827 pane[i]->patchbay->stop_meters();
832 void MWindowGUI::update_meters(ArrayList<double> *module_levels)
834 for(int i = 0; i < TOTAL_PANES; i++)
836 if(pane[i] && pane[i]->patchbay)
838 pane[i]->patchbay->update_meters(module_levels);
843 void MWindowGUI::set_editing_mode(int flush)
845 for(int i = 0; i < TOTAL_PANES; i++)
849 pane[i]->canvas->update_cursor(flush);
854 void MWindowGUI::set_meter_format(int mode, int min, int max)
856 for(int i = 0; i < TOTAL_PANES; i++)
858 if(pane[i] && pane[i]->patchbay)
860 pane[i]->patchbay->set_meter_format(mode, min, max);
865 void MWindowGUI::update(int scrollbars,
874 if(debug) PRINT_TRACE
878 mwindow->edl->tracks->update_y_pixels(mwindow->theme);
880 if(do_canvas && do_canvas != IGNORE_THREAD)
882 resource_thread->stop_draw(1);
885 for(int i = 0; i < TOTAL_PANES; i++)
887 if(pane[i]) pane[i]->update(scrollbars,
893 if(do_canvas && do_canvas != IGNORE_THREAD)
895 resource_thread->start_draw();
898 // if(scrollbars) this->get_scrollbars(0);
899 // if(timebar) this->timebar->update(0);
900 if(zoombar) this->zoombar->update();
901 // if(patchbay) this->patchbay->update();
902 if(clock) this->mainclock->update(
903 mwindow->edl->local_session->get_selectionstart(1));
904 if(debug) PRINT_TRACE
910 // this->canvas->draw(do_canvas);
911 // this->cursor->show();
912 // this->canvas->flash(0);
913 // Activate causes the menubar to deactivate. Don't want this for
915 // if(canvas != IGNORE_THREAD) this->canvas->activate();
917 if(debug) PRINT_TRACE
921 if(buttonbar) mbuttons->update();
922 if(debug) PRINT_TRACE
924 // Can't age if the cache called this to draw missing picons
925 // or the GUI is updating the status of the draw toggle.
926 if(do_canvas != FORCE_REDRAW && do_canvas != IGNORE_THREAD)
929 mwindow->age_caches();
930 lock_window("MWindowGUI::update");
934 if(debug) PRINT_TRACE
937 int MWindowGUI::visible(int64_t x1, int64_t x2, int64_t view_x1, int64_t view_x2)
939 return (x1 >= view_x1 && x1 < view_x2) ||
940 (x2 > view_x1 && x2 <= view_x2) ||
941 (x1 <= view_x1 && x2 >= view_x2);
945 void MWindowGUI::show_message(const char *message, int color)
947 statusbar->show_message(message, color);
950 void MWindowGUI::update_default_message()
952 statusbar->update_default_message();
955 void MWindowGUI::reset_default_message()
957 statusbar->reset_default_message();
960 void MWindowGUI::default_message()
962 statusbar->default_message();
965 // Drag motion called from other window
966 int MWindowGUI::drag_motion()
968 if(get_hidden()) return 0;
970 Track *over_track = 0;
972 PluginSet *over_pluginset = 0;
973 Plugin *over_plugin = 0;
978 drag_popup->cursor_motion_event();
982 // there's no point in drawing highlights has until drag operation has been set
983 if (!mwindow->session->current_operation)
986 for(int i = 0; i < TOTAL_PANES; i++)
988 if(pane[i]) pane[i]->canvas->drag_motion(
995 if(mwindow->session->track_highlighted != over_track)
997 mwindow->session->track_highlighted = over_track;
1001 if(mwindow->session->edit_highlighted != over_edit)
1003 mwindow->session->edit_highlighted = over_edit;
1007 if(mwindow->session->pluginset_highlighted != over_pluginset)
1009 mwindow->session->pluginset_highlighted = over_pluginset;
1013 if(mwindow->session->plugin_highlighted != over_plugin)
1015 mwindow->session->plugin_highlighted = over_plugin;
1019 if( mwindow->session->current_operation == DRAG_ASSET ||
1020 mwindow->session->current_operation == DRAG_EDIT ||
1021 mwindow->session->current_operation == DRAG_AEFFECT_COPY ||
1022 mwindow->session->current_operation == DRAG_VEFFECT_COPY )
1028 // printf("drag_motion %d %d over_track=%p over_edit=%p\n",
1035 lock_window("MWindowGUI::drag_motion");
1042 int MWindowGUI::drag_stop()
1044 if(get_hidden()) return 0;
1045 int result = 0, redraw = 0;
1047 for(int i = 0; i < TOTAL_PANES; i++)
1049 if(pane[i]) result |= pane[i]->canvas->drag_stop(
1052 mwindow->edl->optimize();
1054 // since we don't have subwindows we have to terminate any drag operation
1057 if (mwindow->session->track_highlighted
1058 || mwindow->session->edit_highlighted
1059 || mwindow->session->plugin_highlighted
1060 || mwindow->session->pluginset_highlighted)
1062 mwindow->session->track_highlighted = 0;
1063 mwindow->session->edit_highlighted = 0;
1064 mwindow->session->plugin_highlighted = 0;
1065 mwindow->session->pluginset_highlighted = 0;
1066 mwindow->session->current_operation = NO_OPERATION;
1070 //printf("MWindowGUI::drag_stop %d %d\n", redraw, mwindow->session->current_operation);
1073 mwindow->edl->tracks->update_y_pixels(mwindow->theme);
1074 update_scrollbars(0);
1089 void MWindowGUI::default_positions()
1091 //printf("MWindowGUI::default_positions 1\n");
1092 VWindow *vwindow = mwindow->vwindows.size() > DEFAULT_VWINDOW ?
1093 mwindow->vwindows.get(DEFAULT_VWINDOW) : 0;
1094 if( vwindow && !vwindow->is_running() ) vwindow = 0;
1095 if( vwindow ) vwindow->gui->lock_window("MWindowGUI::default_positions");
1096 mwindow->cwindow->gui->lock_window("MWindowGUI::default_positions");
1097 mwindow->awindow->gui->lock_window("MWindowGUI::default_positions");
1099 // printf("MWindowGUI::default_positions 1 %d %d %d %d\n", mwindow->session->vwindow_x,
1100 // mwindow->session->vwindow_y,
1101 // mwindow->session->vwindow_w,
1102 // mwindow->session->vwindow_h);
1103 reposition_window(mwindow->session->mwindow_x,
1104 mwindow->session->mwindow_y,
1105 mwindow->session->mwindow_w,
1106 mwindow->session->mwindow_h);
1107 if( vwindow ) vwindow->gui->reposition_window(mwindow->session->vwindow_x,
1108 mwindow->session->vwindow_y,
1109 mwindow->session->vwindow_w,
1110 mwindow->session->vwindow_h);
1111 mwindow->cwindow->gui->reposition_window(mwindow->session->cwindow_x,
1112 mwindow->session->cwindow_y,
1113 mwindow->session->cwindow_w,
1114 mwindow->session->cwindow_h);
1115 mwindow->awindow->gui->reposition_window(mwindow->session->awindow_x,
1116 mwindow->session->awindow_y,
1117 mwindow->session->awindow_w,
1118 mwindow->session->awindow_h);
1119 //printf("MWindowGUI::default_positions 1\n");
1121 resize_event(mwindow->session->mwindow_w,
1122 mwindow->session->mwindow_h);
1123 //printf("MWindowGUI::default_positions 1\n");
1124 if( vwindow ) vwindow->gui->resize_event(mwindow->session->vwindow_w,
1125 mwindow->session->vwindow_h);
1126 //printf("MWindowGUI::default_positions 1\n");
1127 mwindow->cwindow->gui->resize_event(mwindow->session->cwindow_w,
1128 mwindow->session->cwindow_h);
1129 //printf("MWindowGUI::default_positions 1\n");
1130 mwindow->awindow->gui->resize_event(mwindow->session->awindow_w,
1131 mwindow->session->awindow_h);
1133 //printf("MWindowGUI::default_positions 1\n");
1136 if( vwindow ) vwindow->gui->flush();
1137 mwindow->cwindow->gui->flush();
1138 mwindow->awindow->gui->flush();
1140 if( vwindow ) vwindow->gui->unlock_window();
1141 mwindow->cwindow->gui->unlock_window();
1142 mwindow->awindow->gui->unlock_window();
1143 //printf("MWindowGUI::default_positions 2\n");
1147 int MWindowGUI::repeat_event(int64_t duration)
1149 // if(duration == 100)
1150 // mwindow->sync_parameters(CHANGE_ALL);
1152 for(int i = 0; i < TOTAL_PANES; i++)
1154 if(pane[i]) result = pane[i]->cursor->repeat_event(duration);
1160 int MWindowGUI::translation_event()
1162 //printf("MWindowGUI::translation_event 1 %d %d\n", get_x(), get_y());
1163 mwindow->session->mwindow_x = get_x();
1164 mwindow->session->mwindow_y = get_y();
1169 int MWindowGUI::save_defaults(BC_Hash *defaults)
1171 defaults->update("MWINDOWWIDTH", get_w());
1172 defaults->update("MWINDOWHEIGHT", get_h());
1173 mainmenu->save_defaults(defaults);
1174 BC_WindowBase::save_defaults(defaults);
1178 int MWindowGUI::keypress_event()
1180 //printf("MWindowGUI::keypress_event 1 %d\n", get_keypress());
1181 int result = mbuttons->keypress_event();
1182 if( result ) return result;
1184 Track *this_track = 0;
1186 switch(get_keypress()) {
1188 mwindow->toggle_editing_mode();
1193 if( alt_down() ) break;
1194 stop_transport("MWindowGUI::keypress_event 1");
1195 mwindow->nearest_plugin_keyframe(shift_down(),
1196 !ctrl_down() ? PLAY_FORWARD : PLAY_REVERSE);
1200 case '1': case '2': case '3': case '4':
1201 case '5': case '6': case '7': case '8':
1202 if( !alt_down() || shift_down() ) break;
1203 if( !mwindow->select_asset(get_keypress()-'1',1) )
1208 if( !ctrl_down() ) {
1210 stop_transport("MWindowGUI::keypress_event 1");
1211 mwindow->prev_edit_handle(shift_down());
1214 mwindow->move_left();
1220 if( !ctrl_down() && !alt_down() ) {
1221 mwindow->move_left();
1227 if( !ctrl_down() ) {
1229 stop_transport("MWindowGUI::keypress_event 2");
1230 mwindow->next_edit_handle(shift_down());
1233 mwindow->move_right();
1239 if( !ctrl_down() && !alt_down() ) {
1240 mwindow->move_right();
1246 if( ctrl_down() && !alt_down() )
1247 mwindow->expand_y();
1248 else if( !ctrl_down() && alt_down() )
1249 mwindow->expand_autos(0,1,1);
1250 else if( ctrl_down() && alt_down() )
1251 mwindow->expand_autos(1,1,1);
1253 mwindow->expand_sample();
1258 if( ctrl_down() && !alt_down() )
1259 mwindow->zoom_in_y();
1260 else if( !ctrl_down() && alt_down() )
1261 mwindow->shrink_autos(0,1,1);
1262 else if( ctrl_down() && alt_down() )
1263 mwindow->shrink_autos(1,1,1);
1265 mwindow->zoom_in_sample();
1273 mwindow->expand_t();
1279 mwindow->move_down();
1281 mwindow->zoom_in_t();
1287 for( int i=0; i<TOTAL_PANES; ++i ) {
1288 if( !pane[i] ) continue;
1289 if( (this_track = pane[i]->over_track()) != 0 ) break;
1290 if( (this_track = pane[i]->over_patchbay()) != 0 ) break;
1293 if( get_keypress() == TAB ) { // Switch the record button
1295 this_track->record = !this_track->record ? 1 : 0;
1298 int total_selected = mwindow->edl->tracks->total_of(Tracks::RECORD);
1299 // all selected if nothing previously selected or
1300 // if this patch was previously the only one selected and armed
1301 int selected = !total_selected || (total_selected == 1 &&
1302 this_track && this_track->record ) ? 1 : 0;
1303 mwindow->edl->tracks->select_all(Tracks::RECORD, selected);
1304 if( !selected && this_track ) this_track->record = 1;
1307 update(0, 1, 0, 0, 1, 0, 1);
1309 mwindow->cwindow->update(0, 1, 1);
1310 lock_window("MWindowGUI::keypress_event 3");
1327 resend_event(mwindow->cwindow->gui);
1331 // since things under cursor have changed...
1333 cursor_motion_event();
1338 int MWindowGUI::keyboard_listener(BC_WindowBase *wp)
1340 return key_listener(wp->get_keypress());
1343 int MWindowGUI::key_listener(int key)
1348 if( !record->running() )
1351 record->record_gui->interrupt_thread->start(0);
1358 channel_info->toggle_scan();
1362 if( !remote_control->deactivate() )
1363 remote_control->activate();
1373 void MWindowGUI::use_android_remote(int on)
1376 delete android_control;
1377 android_control = 0;
1380 if( android_control ) return;
1381 android_control = new AndroidControl(this);
1384 int MWindowGUI::close_event()
1390 void MWindowGUI::stop_drawing()
1392 resource_thread->stop_draw(1);
1395 int MWindowGUI::menu_w()
1397 return mainmenu->get_w();
1400 int MWindowGUI::menu_h()
1402 return mainmenu->get_h();
1405 void MWindowGUI::start_x_pane_drag()
1409 x_pane_drag = new BC_Popup(this,
1410 get_abs_cursor_x(0) - mwindow->theme->pane_w,
1411 BC_DisplayInfo::get_top_border() +
1413 mwindow->theme->mcanvas_y,
1414 mwindow->theme->pane_w,
1415 mwindow->theme->mcanvas_h,
1416 mwindow->theme->drag_pane_color);
1417 x_pane_drag->draw_3segmentv(0,
1419 x_pane_drag->get_h(),
1420 mwindow->theme->get_image_set("xpane")[BUTTON_DOWNHI]);
1421 x_pane_drag->flash(1);
1426 void MWindowGUI::start_y_pane_drag()
1430 //printf("MWindowGUI::start_y_pane_drag %d %d %d\n", __LINE__, get_x(), get_y());
1431 y_pane_drag = new BC_Popup(this,
1432 BC_DisplayInfo::get_left_border() +
1434 mwindow->theme->mcanvas_x,
1435 get_abs_cursor_y(0) - mwindow->theme->pane_h,
1436 mwindow->theme->mcanvas_w,
1437 mwindow->theme->pane_h,
1438 mwindow->theme->drag_pane_color);
1439 y_pane_drag->draw_3segmenth(0,
1441 y_pane_drag->get_w(),
1442 mwindow->theme->get_image_set("ypane")[BUTTON_DOWNHI]);
1443 y_pane_drag->flash(1);
1448 void MWindowGUI::handle_pane_drag()
1454 x_pane_drag->reposition_window(
1455 get_abs_cursor_x(0) - mwindow->theme->pane_w,
1456 x_pane_drag->get_y());
1461 y_pane_drag->reposition_window(
1462 y_pane_drag->get_x(),
1463 get_abs_cursor_y(0) - mwindow->theme->pane_h);
1469 void MWindowGUI::create_x_pane(int cursor_x)
1471 if(total_panes() == 1)
1473 // create a horizontal pane
1474 // do this 1st so the resize_event knows there are 2 panes
1475 mwindow->edl->local_session->view_start[TOP_RIGHT_PANE] =
1476 mwindow->edl->local_session->view_start[TOP_LEFT_PANE] +
1478 mwindow->theme->patchbay_w;
1479 pane[TOP_RIGHT_PANE] = new TimelinePane(mwindow,
1481 mwindow->theme->mcanvas_x +
1483 mwindow->theme->mcanvas_y,
1484 mwindow->theme->mcanvas_x +
1485 mwindow->theme->mcanvas_w -
1487 mwindow->theme->mcanvas_h);
1488 pane[TOP_LEFT_PANE]->resize_event(
1489 mwindow->theme->mcanvas_x,
1490 mwindow->theme->mcanvas_y,
1491 cursor_x - mwindow->theme->pane_w,
1492 mwindow->theme->mcanvas_h);
1493 pane[TOP_RIGHT_PANE]->create_objects();
1496 if(vertical_panes())
1498 // create 2 horizontal panes
1499 mwindow->edl->local_session->track_start[TOP_RIGHT_PANE] =
1500 mwindow->edl->local_session->track_start[TOP_LEFT_PANE];
1501 mwindow->edl->local_session->track_start[BOTTOM_RIGHT_PANE] =
1502 mwindow->edl->local_session->track_start[BOTTOM_LEFT_PANE];
1503 mwindow->edl->local_session->view_start[TOP_RIGHT_PANE] =
1504 mwindow->edl->local_session->view_start[BOTTOM_RIGHT_PANE] =
1505 mwindow->edl->local_session->view_start[TOP_LEFT_PANE] +
1507 mwindow->theme->patchbay_w;
1508 pane[TOP_RIGHT_PANE] = new TimelinePane(mwindow,
1510 mwindow->theme->mcanvas_x +
1512 pane[TOP_LEFT_PANE]->y,
1513 mwindow->theme->mcanvas_x +
1514 mwindow->theme->mcanvas_w -
1516 pane[TOP_LEFT_PANE]->h);
1517 pane[BOTTOM_RIGHT_PANE] = new TimelinePane(mwindow,
1519 mwindow->theme->mcanvas_x +
1521 pane[BOTTOM_LEFT_PANE]->y,
1522 mwindow->theme->mcanvas_x +
1523 mwindow->theme->mcanvas_w -
1525 pane[BOTTOM_LEFT_PANE]->h);
1526 pane[TOP_LEFT_PANE]->resize_event(
1527 pane[TOP_LEFT_PANE]->x,
1528 pane[TOP_LEFT_PANE]->y,
1529 cursor_x - mwindow->theme->pane_w,
1530 pane[TOP_LEFT_PANE]->h);
1531 pane[BOTTOM_LEFT_PANE]->resize_event(
1532 pane[BOTTOM_LEFT_PANE]->x,
1533 pane[BOTTOM_LEFT_PANE]->y,
1534 cursor_x - mwindow->theme->pane_w,
1535 pane[BOTTOM_LEFT_PANE]->h);
1536 pane[TOP_RIGHT_PANE]->create_objects();
1537 pane[BOTTOM_RIGHT_PANE]->create_objects();
1540 if(horizontal_panes())
1542 // resize a horizontal pane
1543 mwindow->edl->local_session->view_start[TOP_RIGHT_PANE] +=
1545 pane[TOP_RIGHT_PANE]->x;
1546 if(mwindow->edl->local_session->view_start[TOP_RIGHT_PANE] < 0)
1547 mwindow->edl->local_session->view_start[TOP_RIGHT_PANE] = 0;
1548 pane[TOP_LEFT_PANE]->resize_event(
1549 mwindow->theme->mcanvas_x,
1550 mwindow->theme->mcanvas_y,
1551 cursor_x - mwindow->theme->pane_w,
1552 mwindow->theme->mcanvas_h);
1553 pane[TOP_RIGHT_PANE]->resize_event(
1554 mwindow->theme->mcanvas_x +
1556 pane[TOP_RIGHT_PANE]->y,
1557 mwindow->theme->mcanvas_x +
1558 mwindow->theme->mcanvas_w -
1560 mwindow->theme->mcanvas_h);
1564 // resize 2 horizontal panes
1565 mwindow->edl->local_session->view_start[TOP_RIGHT_PANE] +=
1567 pane[TOP_RIGHT_PANE]->x;
1568 if(mwindow->edl->local_session->view_start[TOP_RIGHT_PANE] < 0)
1569 mwindow->edl->local_session->view_start[TOP_RIGHT_PANE] = 0;
1570 mwindow->edl->local_session->view_start[BOTTOM_RIGHT_PANE] =
1571 mwindow->edl->local_session->view_start[TOP_RIGHT_PANE];
1573 pane[TOP_LEFT_PANE]->resize_event(
1574 mwindow->theme->mcanvas_x,
1575 pane[TOP_LEFT_PANE]->y,
1576 cursor_x - mwindow->theme->pane_w,
1577 pane[TOP_LEFT_PANE]->h);
1578 pane[TOP_RIGHT_PANE]->resize_event(
1579 mwindow->theme->mcanvas_x +
1581 pane[TOP_RIGHT_PANE]->y,
1582 mwindow->theme->mcanvas_x +
1583 mwindow->theme->mcanvas_w -
1585 pane[TOP_RIGHT_PANE]->h);
1586 pane[BOTTOM_LEFT_PANE]->resize_event(
1587 mwindow->theme->mcanvas_x,
1588 pane[BOTTOM_LEFT_PANE]->y,
1589 cursor_x - mwindow->theme->pane_w,
1590 pane[BOTTOM_LEFT_PANE]->h);
1591 pane[BOTTOM_RIGHT_PANE]->resize_event(
1592 mwindow->theme->mcanvas_x +
1594 pane[BOTTOM_RIGHT_PANE]->y,
1595 mwindow->theme->mcanvas_x +
1596 mwindow->theme->mcanvas_w -
1598 pane[BOTTOM_RIGHT_PANE]->h);
1604 void MWindowGUI::delete_x_pane(int cursor_x)
1606 // give left panes coordinates of right pane
1607 if(cursor_x < mwindow->theme->patchbay_w + PANE_DRAG_MARGIN &&
1608 pane[TOP_RIGHT_PANE])
1610 mwindow->edl->local_session->view_start[TOP_LEFT_PANE] =
1611 mwindow->edl->local_session->view_start[TOP_RIGHT_PANE] -
1612 pane[TOP_RIGHT_PANE]->x + mwindow->theme->patchbay_w;
1613 if(mwindow->edl->local_session->view_start[TOP_LEFT_PANE] < 0)
1614 mwindow->edl->local_session->view_start[TOP_LEFT_PANE] = 0;
1615 mwindow->edl->local_session->view_start[BOTTOM_LEFT_PANE] =
1616 mwindow->edl->local_session->view_start[TOP_LEFT_PANE];
1619 switch(total_panes())
1622 if(pane[TOP_LEFT_PANE] && pane[TOP_RIGHT_PANE])
1624 // delete right pane
1625 delete pane[TOP_RIGHT_PANE];
1626 pane[TOP_RIGHT_PANE] = 0;
1627 pane[TOP_LEFT_PANE]->resize_event(
1628 mwindow->theme->mcanvas_x,
1629 mwindow->theme->mcanvas_y,
1630 mwindow->theme->mcanvas_w,
1631 mwindow->theme->mcanvas_h);
1637 // delete right panes
1638 delete pane[TOP_RIGHT_PANE];
1639 pane[TOP_RIGHT_PANE] = 0;
1640 delete pane[BOTTOM_RIGHT_PANE];
1641 pane[BOTTOM_RIGHT_PANE] = 0;
1642 pane[TOP_LEFT_PANE]->resize_event(
1643 mwindow->theme->mcanvas_x,
1644 pane[TOP_LEFT_PANE]->y,
1645 mwindow->theme->mcanvas_w,
1646 pane[TOP_LEFT_PANE]->h);
1647 pane[BOTTOM_LEFT_PANE]->resize_event(
1648 mwindow->theme->mcanvas_x,
1649 pane[BOTTOM_LEFT_PANE]->y,
1650 mwindow->theme->mcanvas_w,
1651 pane[BOTTOM_LEFT_PANE]->h);
1656 void MWindowGUI::create_y_pane(int cursor_y)
1658 if(total_panes() == 1)
1660 mwindow->edl->local_session->view_start[BOTTOM_LEFT_PANE] =
1661 mwindow->edl->local_session->view_start[TOP_LEFT_PANE];
1662 mwindow->edl->local_session->track_start[BOTTOM_LEFT_PANE] =
1663 mwindow->edl->local_session->track_start[TOP_LEFT_PANE] +
1665 mwindow->theme->mtimebar_h;
1666 // do this 1st so the resize_event knows there are 2 panes
1667 pane[BOTTOM_LEFT_PANE] = new TimelinePane(mwindow,
1669 mwindow->theme->mcanvas_x,
1670 mwindow->theme->mcanvas_y +
1672 mwindow->theme->mcanvas_w,
1673 mwindow->theme->mcanvas_h -
1675 pane[TOP_LEFT_PANE]->resize_event(
1676 mwindow->theme->mcanvas_x,
1677 mwindow->theme->mcanvas_y,
1678 mwindow->theme->mcanvas_w,
1679 pane[BOTTOM_LEFT_PANE]->y -
1680 mwindow->theme->mcanvas_y -
1681 mwindow->theme->pane_h);
1682 pane[BOTTOM_LEFT_PANE]->create_objects();
1685 if(horizontal_panes())
1688 mwindow->edl->local_session->view_start[BOTTOM_LEFT_PANE] =
1689 mwindow->edl->local_session->view_start[TOP_LEFT_PANE];
1690 mwindow->edl->local_session->view_start[BOTTOM_RIGHT_PANE] =
1691 mwindow->edl->local_session->view_start[TOP_RIGHT_PANE];
1692 mwindow->edl->local_session->track_start[BOTTOM_LEFT_PANE] =
1693 mwindow->edl->local_session->track_start[BOTTOM_RIGHT_PANE] =
1694 mwindow->edl->local_session->track_start[TOP_LEFT_PANE] +
1696 mwindow->theme->mtimebar_h;
1698 pane[BOTTOM_LEFT_PANE] = new TimelinePane(mwindow,
1700 pane[TOP_LEFT_PANE]->x,
1701 mwindow->theme->mcanvas_y +
1703 pane[TOP_LEFT_PANE]->w,
1704 mwindow->theme->mcanvas_h -
1706 pane[BOTTOM_RIGHT_PANE] = new TimelinePane(mwindow,
1708 pane[TOP_RIGHT_PANE]->x,
1709 mwindow->theme->mcanvas_y +
1711 pane[TOP_RIGHT_PANE]->w,
1712 mwindow->theme->mcanvas_h -
1715 pane[TOP_LEFT_PANE]->resize_event(
1716 pane[TOP_LEFT_PANE]->x,
1717 pane[TOP_LEFT_PANE]->y,
1718 pane[TOP_LEFT_PANE]->w,
1719 pane[BOTTOM_LEFT_PANE]->y -
1720 mwindow->theme->mcanvas_y -
1721 mwindow->theme->pane_h);
1722 pane[TOP_RIGHT_PANE]->resize_event(
1723 pane[TOP_RIGHT_PANE]->x,
1724 pane[TOP_RIGHT_PANE]->y,
1725 pane[TOP_RIGHT_PANE]->w,
1726 pane[BOTTOM_RIGHT_PANE]->y -
1727 mwindow->theme->mcanvas_y -
1728 mwindow->theme->pane_h);
1730 pane[BOTTOM_LEFT_PANE]->create_objects();
1731 pane[BOTTOM_RIGHT_PANE]->create_objects();
1734 if(vertical_panes())
1737 mwindow->edl->local_session->track_start[BOTTOM_LEFT_PANE] +=
1739 (pane[BOTTOM_LEFT_PANE]->y - mwindow->theme->mcanvas_y);
1740 if(mwindow->edl->local_session->track_start[BOTTOM_LEFT_PANE] < 0)
1741 mwindow->edl->local_session->track_start[BOTTOM_LEFT_PANE] = 0;
1742 pane[TOP_LEFT_PANE]->resize_event(
1743 mwindow->theme->mcanvas_x,
1744 mwindow->theme->mcanvas_y,
1745 mwindow->theme->mcanvas_w,
1746 cursor_y - mwindow->theme->pane_h);
1747 pane[BOTTOM_LEFT_PANE]->resize_event(
1748 pane[BOTTOM_LEFT_PANE]->x,
1750 mwindow->theme->mcanvas_y,
1751 mwindow->theme->mcanvas_w,
1752 mwindow->theme->mcanvas_h -
1758 mwindow->edl->local_session->track_start[BOTTOM_LEFT_PANE] +=
1760 (pane[BOTTOM_LEFT_PANE]->y - mwindow->theme->mcanvas_y);
1761 if(mwindow->edl->local_session->track_start[BOTTOM_LEFT_PANE] < 0)
1762 mwindow->edl->local_session->track_start[BOTTOM_LEFT_PANE] = 0;
1763 mwindow->edl->local_session->track_start[BOTTOM_RIGHT_PANE] =
1764 mwindow->edl->local_session->track_start[BOTTOM_LEFT_PANE];
1765 pane[TOP_LEFT_PANE]->resize_event(
1766 pane[TOP_LEFT_PANE]->x,
1767 pane[TOP_LEFT_PANE]->y,
1768 pane[TOP_LEFT_PANE]->w,
1769 cursor_y - mwindow->theme->pane_h);
1770 pane[BOTTOM_LEFT_PANE]->resize_event(
1771 pane[BOTTOM_LEFT_PANE]->x,
1773 mwindow->theme->mcanvas_y,
1774 pane[BOTTOM_LEFT_PANE]->w,
1775 mwindow->theme->mcanvas_h -
1777 pane[TOP_RIGHT_PANE]->resize_event(
1778 pane[TOP_RIGHT_PANE]->x,
1779 pane[TOP_RIGHT_PANE]->y,
1780 pane[TOP_RIGHT_PANE]->w,
1781 cursor_y - mwindow->theme->pane_h);
1782 pane[BOTTOM_RIGHT_PANE]->resize_event(
1783 pane[BOTTOM_RIGHT_PANE]->x,
1785 mwindow->theme->mcanvas_y,
1786 pane[BOTTOM_RIGHT_PANE]->w,
1787 mwindow->theme->mcanvas_h -
1792 void MWindowGUI::delete_y_pane(int cursor_y)
1794 if(cursor_y < mwindow->theme->mtimebar_h +
1796 pane[BOTTOM_LEFT_PANE])
1798 // give top pane coordinates of bottom pane
1799 mwindow->edl->local_session->track_start[TOP_LEFT_PANE] =
1800 mwindow->edl->local_session->track_start[BOTTOM_LEFT_PANE] -
1801 pane[BOTTOM_LEFT_PANE]->y;
1802 if(mwindow->edl->local_session->track_start[TOP_LEFT_PANE] < 0)
1803 mwindow->edl->local_session->track_start[TOP_LEFT_PANE] = 0;
1804 mwindow->edl->local_session->track_start[TOP_RIGHT_PANE] =
1805 mwindow->edl->local_session->track_start[TOP_LEFT_PANE];
1809 switch(total_panes())
1812 delete pane[BOTTOM_LEFT_PANE];
1813 pane[BOTTOM_LEFT_PANE] = 0;
1814 pane[TOP_LEFT_PANE]->resize_event(
1815 mwindow->theme->mcanvas_x,
1816 mwindow->theme->mcanvas_y,
1817 mwindow->theme->mcanvas_w,
1818 mwindow->theme->mcanvas_h);
1822 // delete bottom 2 panes
1824 delete pane[BOTTOM_LEFT_PANE];
1825 pane[BOTTOM_LEFT_PANE] = 0;
1826 delete pane[BOTTOM_RIGHT_PANE];
1827 pane[BOTTOM_RIGHT_PANE] = 0;
1828 pane[TOP_LEFT_PANE]->resize_event(
1829 pane[TOP_LEFT_PANE]->x,
1830 mwindow->theme->mcanvas_y,
1831 pane[TOP_LEFT_PANE]->w,
1832 mwindow->theme->mcanvas_h);
1833 pane[TOP_RIGHT_PANE]->resize_event(
1834 pane[TOP_RIGHT_PANE]->x,
1835 mwindow->theme->mcanvas_y,
1836 pane[TOP_RIGHT_PANE]->w,
1837 mwindow->theme->mcanvas_h);
1842 void MWindowGUI::stop_pane_drag()
1845 resource_thread->stop_draw(1);
1849 // cursor position relative to canvas
1850 int cursor_x = x_pane_drag->get_x() -
1852 BC_DisplayInfo::get_left_border() -
1853 mwindow->theme->mcanvas_x +
1854 mwindow->theme->pane_w;
1859 if(cursor_x >= mwindow->theme->patchbay_w + PANE_DRAG_MARGIN &&
1860 cursor_x < mwindow->theme->mcanvas_w -
1861 BC_ScrollBar::get_span(SCROLL_VERT) -
1864 create_x_pane(cursor_x);
1865 mwindow->edl->local_session->x_pane = cursor_x;
1870 delete_x_pane(cursor_x);
1871 mwindow->edl->local_session->x_pane = -1;
1879 // cursor position relative to canvas
1880 int cursor_y = y_pane_drag->get_y() -
1882 BC_DisplayInfo::get_top_border() -
1883 mwindow->theme->mcanvas_y +
1884 mwindow->theme->pane_h;
1890 if(cursor_y >= mwindow->theme->mtimebar_h +
1892 cursor_y < mwindow->theme->mcanvas_h -
1893 BC_ScrollBar::get_span(SCROLL_HORIZ) -
1896 create_y_pane(cursor_y);
1897 mwindow->edl->local_session->y_pane = cursor_y;
1901 delete_y_pane(cursor_y);
1902 mwindow->edl->local_session->y_pane = -1;
1906 update_pane_dividers();
1908 // required to get new widgets to appear
1910 resource_thread->start_draw();
1913 // create panes from EDL
1914 void MWindowGUI::load_panes()
1916 int need_x_panes = 0;
1917 int need_y_panes = 0;
1918 // use names from create functions
1919 int cursor_x = mwindow->edl->local_session->x_pane;
1920 int cursor_y = mwindow->edl->local_session->y_pane;
1922 resource_thread->stop_draw(1);
1924 mwindow->theme->patchbay_w + PANE_DRAG_MARGIN &&
1926 mwindow->theme->mcanvas_w -
1927 BC_ScrollBar::get_span(SCROLL_VERT) -
1934 mwindow->theme->mtimebar_h + PANE_DRAG_MARGIN &&
1936 mwindow->theme->mcanvas_h -
1937 BC_ScrollBar::get_span(SCROLL_HORIZ) -
1943 //printf("MWindowGUI::load_panes %d %d %d\n", __LINE__, need_x_panes, need_y_panes);
1951 if(total_panes() == 1)
1954 //printf("MWindowGUI::load_panes %d\n", __LINE__);
1955 pane[TOP_RIGHT_PANE] = new TimelinePane(mwindow,
1957 mwindow->theme->mcanvas_x +
1959 mwindow->theme->mcanvas_y,
1960 mwindow->theme->mcanvas_x +
1961 mwindow->theme->mcanvas_w -
1963 cursor_y - mwindow->theme->pane_h);
1964 pane[BOTTOM_LEFT_PANE] = new TimelinePane(mwindow,
1966 mwindow->theme->mcanvas_x,
1967 mwindow->theme->mcanvas_y +
1969 cursor_x - mwindow->theme->pane_w,
1970 mwindow->theme->mcanvas_h -
1972 pane[BOTTOM_RIGHT_PANE] = new TimelinePane(mwindow,
1974 pane[TOP_RIGHT_PANE]->x,
1975 mwindow->theme->mcanvas_y +
1977 pane[TOP_RIGHT_PANE]->w,
1978 mwindow->theme->mcanvas_h -
1980 pane[TOP_LEFT_PANE]->resize_event(
1981 pane[TOP_LEFT_PANE]->x,
1982 pane[TOP_LEFT_PANE]->y,
1983 cursor_x - mwindow->theme->pane_w,
1984 cursor_y - mwindow->theme->pane_h);
1985 pane[TOP_RIGHT_PANE]->create_objects();
1986 pane[BOTTOM_LEFT_PANE]->create_objects();
1987 pane[BOTTOM_RIGHT_PANE]->create_objects();
1990 if(horizontal_panes())
1992 // create vertical panes
1993 //printf("MWindowGUI::load_panes %d\n", __LINE__);
1994 pane[BOTTOM_LEFT_PANE] = new TimelinePane(mwindow,
1996 mwindow->theme->mcanvas_x,
1997 mwindow->theme->mcanvas_y +
1999 cursor_x - mwindow->theme->pane_w,
2000 mwindow->theme->mcanvas_h -
2002 pane[BOTTOM_RIGHT_PANE] = new TimelinePane(mwindow,
2004 pane[TOP_RIGHT_PANE]->x,
2005 mwindow->theme->mcanvas_y +
2007 pane[TOP_RIGHT_PANE]->w,
2008 mwindow->theme->mcanvas_h -
2010 pane[TOP_LEFT_PANE]->resize_event(
2011 pane[TOP_LEFT_PANE]->x,
2012 pane[TOP_LEFT_PANE]->y,
2013 cursor_x - mwindow->theme->pane_w,
2014 cursor_y - mwindow->theme->pane_h);
2015 pane[TOP_RIGHT_PANE]->resize_event(
2016 mwindow->theme->mcanvas_x +
2018 mwindow->theme->mcanvas_y,
2019 mwindow->theme->mcanvas_x +
2020 mwindow->theme->mcanvas_w -
2022 cursor_y - mwindow->theme->pane_h);
2023 pane[BOTTOM_LEFT_PANE]->create_objects();
2024 pane[BOTTOM_RIGHT_PANE]->create_objects();
2027 if(vertical_panes())
2029 // create horizontal panes
2030 //printf("MWindowGUI::load_panes %d\n", __LINE__);
2031 pane[TOP_RIGHT_PANE] = new TimelinePane(mwindow,
2033 mwindow->theme->mcanvas_x +
2035 mwindow->theme->mcanvas_y,
2036 mwindow->theme->mcanvas_x +
2037 mwindow->theme->mcanvas_w -
2039 cursor_y - mwindow->theme->pane_h);
2040 pane[BOTTOM_RIGHT_PANE] = new TimelinePane(mwindow,
2042 pane[TOP_RIGHT_PANE]->x,
2043 mwindow->theme->mcanvas_y +
2045 pane[TOP_RIGHT_PANE]->w,
2046 mwindow->theme->mcanvas_h -
2048 pane[TOP_LEFT_PANE]->resize_event(
2049 pane[TOP_LEFT_PANE]->x,
2050 pane[TOP_LEFT_PANE]->y,
2051 cursor_x - mwindow->theme->pane_w,
2052 cursor_y - mwindow->theme->pane_h);
2053 pane[BOTTOM_LEFT_PANE]->resize_event(
2054 pane[TOP_LEFT_PANE]->x,
2055 mwindow->theme->mcanvas_y +
2057 mwindow->theme->mcanvas_x +
2058 mwindow->theme->mcanvas_w -
2059 cursor_x - mwindow->theme->pane_w,
2060 mwindow->theme->mcanvas_h -
2062 pane[TOP_RIGHT_PANE]->create_objects();
2063 pane[BOTTOM_RIGHT_PANE]->create_objects();
2070 //printf("MWindowGUI::load_panes %d\n", __LINE__);
2071 pane[TOP_LEFT_PANE]->resize_event(
2072 pane[TOP_LEFT_PANE]->x,
2073 pane[TOP_LEFT_PANE]->y,
2074 cursor_x - mwindow->theme->pane_w,
2075 cursor_y - mwindow->theme->pane_h);
2076 pane[TOP_RIGHT_PANE]->resize_event(
2077 mwindow->theme->mcanvas_x +
2079 mwindow->theme->mcanvas_y,
2080 mwindow->theme->mcanvas_x +
2081 mwindow->theme->mcanvas_w -
2083 cursor_y - mwindow->theme->pane_h);
2084 pane[BOTTOM_LEFT_PANE]->resize_event(
2085 pane[TOP_LEFT_PANE]->x,
2086 mwindow->theme->mcanvas_y +
2088 mwindow->theme->mcanvas_x +
2089 mwindow->theme->mcanvas_w -
2090 cursor_x - mwindow->theme->pane_w,
2091 mwindow->theme->mcanvas_h -
2093 pane[BOTTOM_RIGHT_PANE]->resize_event(
2094 pane[TOP_RIGHT_PANE]->x,
2095 mwindow->theme->mcanvas_y +
2097 pane[TOP_RIGHT_PANE]->w,
2098 mwindow->theme->mcanvas_h -
2107 if(pane[BOTTOM_LEFT_PANE]) delete pane[BOTTOM_LEFT_PANE];
2108 if(pane[BOTTOM_RIGHT_PANE]) delete pane[BOTTOM_RIGHT_PANE];
2109 pane[BOTTOM_LEFT_PANE] = 0;
2110 pane[BOTTOM_RIGHT_PANE] = 0;
2112 if(!pane[TOP_RIGHT_PANE])
2114 pane[TOP_RIGHT_PANE] = new TimelinePane(mwindow,
2116 mwindow->theme->mcanvas_x +
2118 mwindow->theme->mcanvas_y,
2119 mwindow->theme->mcanvas_x +
2120 mwindow->theme->mcanvas_w -
2122 mwindow->theme->mcanvas_h);
2123 pane[TOP_LEFT_PANE]->resize_event(
2124 mwindow->theme->mcanvas_x,
2125 mwindow->theme->mcanvas_y,
2126 cursor_x - mwindow->theme->pane_w,
2127 mwindow->theme->mcanvas_h);
2128 pane[TOP_RIGHT_PANE]->create_objects();
2132 pane[TOP_LEFT_PANE]->resize_event(
2133 mwindow->theme->mcanvas_x,
2134 mwindow->theme->mcanvas_y,
2135 cursor_x - mwindow->theme->pane_w,
2136 mwindow->theme->mcanvas_h);
2137 pane[TOP_RIGHT_PANE]->resize_event(
2138 mwindow->theme->mcanvas_x +
2140 pane[TOP_RIGHT_PANE]->y,
2141 mwindow->theme->mcanvas_x +
2142 mwindow->theme->mcanvas_w -
2144 mwindow->theme->mcanvas_h);
2152 if(pane[TOP_RIGHT_PANE]) delete pane[TOP_RIGHT_PANE];
2153 if(pane[BOTTOM_RIGHT_PANE]) delete pane[BOTTOM_RIGHT_PANE];
2154 pane[TOP_RIGHT_PANE] = 0;
2155 pane[BOTTOM_RIGHT_PANE] = 0;
2157 if(!pane[BOTTOM_LEFT_PANE])
2159 //printf("MWindowGUI::load_panes %d\n", __LINE__);
2160 pane[BOTTOM_LEFT_PANE] = new TimelinePane(mwindow,
2162 mwindow->theme->mcanvas_x,
2163 mwindow->theme->mcanvas_y +
2165 mwindow->theme->mcanvas_w,
2166 mwindow->theme->mcanvas_h -
2168 pane[TOP_LEFT_PANE]->resize_event(
2169 mwindow->theme->mcanvas_x,
2170 mwindow->theme->mcanvas_y,
2171 mwindow->theme->mcanvas_w,
2172 pane[BOTTOM_LEFT_PANE]->y -
2173 mwindow->theme->mcanvas_y -
2174 mwindow->theme->pane_h);
2175 pane[BOTTOM_LEFT_PANE]->create_objects();
2179 pane[TOP_LEFT_PANE]->resize_event(
2180 mwindow->theme->mcanvas_x,
2181 mwindow->theme->mcanvas_y,
2182 mwindow->theme->mcanvas_w,
2183 cursor_y - mwindow->theme->pane_h);
2184 pane[BOTTOM_LEFT_PANE]->resize_event(
2185 pane[BOTTOM_LEFT_PANE]->x,
2187 mwindow->theme->mcanvas_y,
2188 mwindow->theme->mcanvas_w,
2189 mwindow->theme->mcanvas_h -
2196 if(pane[TOP_RIGHT_PANE]) delete pane[TOP_RIGHT_PANE];
2197 if(pane[BOTTOM_RIGHT_PANE]) delete pane[BOTTOM_RIGHT_PANE];
2198 if(pane[BOTTOM_LEFT_PANE]) delete pane[BOTTOM_LEFT_PANE];
2199 pane[TOP_RIGHT_PANE] = 0;
2200 pane[BOTTOM_RIGHT_PANE] = 0;
2201 pane[BOTTOM_LEFT_PANE] = 0;
2202 pane[TOP_LEFT_PANE]->resize_event(
2203 mwindow->theme->mcanvas_x,
2204 mwindow->theme->mcanvas_y,
2205 mwindow->theme->mcanvas_w,
2206 mwindow->theme->mcanvas_h);
2209 update_pane_dividers();
2212 resource_thread->start_draw();
2215 void MWindowGUI::update_pane_dividers()
2218 if(horizontal_panes() || total_panes() == 4)
2220 int x = pane[TOP_RIGHT_PANE]->x - mwindow->theme->pane_w;
2221 int y = mwindow->theme->mcanvas_y;
2222 int h = mwindow->theme->mcanvas_h;
2226 add_subwindow(x_divider = new PaneDivider(
2227 mwindow, x, y, h, 1));
2228 x_divider->create_objects();
2232 x_divider->reposition_window(x, y, h);
2245 if(vertical_panes() || total_panes() == 4)
2247 int x = mwindow->theme->mcanvas_x;
2248 int y = pane[BOTTOM_LEFT_PANE]->y -
2249 mwindow->theme->pane_h;
2250 int w = mwindow->theme->mcanvas_w;
2253 add_subwindow(y_divider = new PaneDivider(
2254 mwindow, x, y, w, 0));
2255 y_divider->create_objects();
2259 y_divider->reposition_window(x, y, w);
2273 void MWindowGUI::draw_samplemovement()
2280 update_scrollbars(1);
2283 void MWindowGUI::draw_trackmovement()
2285 update_scrollbars(0);
2292 void MWindowGUI::update_mixers(Track *track, int v)
2294 for( int i=0; i<TOTAL_PANES; ++i ) {
2295 if( !pane[i] ) continue;
2296 PatchBay *patchbay = pane[i]->patchbay;
2297 if( !patchbay ) continue;
2298 for( int j=0; j<patchbay->patches.total; ++j ) {
2299 PatchGUI *patchgui = patchbay->patches.values[j];
2300 if( !patchgui->mix ) continue;
2301 if( !track || patchgui->track == track ) {
2302 patchgui->mix->update(v>=0 ? v :
2303 mwindow->mixer_track_active(patchgui->track));
2309 void MWindowGUI::stop_transport(const char *lock_msg)
2311 if( !mbuttons->transport->is_stopped() ) {
2312 if( lock_msg ) unlock_window();
2313 mbuttons->transport->handle_transport(STOP, 1, 0, 0);
2314 if( lock_msg ) lock_window(lock_msg);
2318 PaneButton::PaneButton(MWindow *mwindow, int x, int y)
2319 : BC_Button(x, y, mwindow->theme->get_image_set("pane"))
2321 this->mwindow = mwindow;
2324 int PaneButton::cursor_motion_event()
2326 if(get_top_level()->get_button_down() &&
2328 get_status() == BUTTON_DOWNHI &&
2331 // printf("PaneButton::cursor_motion_event %d\n", __LINE__);
2333 if(get_cursor_x() < 0 && !mwindow->gui->dragging_pane)
2335 mwindow->gui->start_x_pane_drag();
2338 if(get_cursor_y() < 0 && !mwindow->gui->dragging_pane)
2340 mwindow->gui->start_y_pane_drag();
2344 mwindow->gui->handle_pane_drag();
2346 int result = BC_Button::cursor_motion_event();
2350 int PaneButton::button_release_event()
2352 if( get_buttonpress() != WHEEL_DOWN && get_buttonpress() != WHEEL_UP )
2353 mwindow->gui->stop_pane_drag();
2354 int result = BC_Button::button_release_event();
2359 FFMpegToggle::FFMpegToggle(MWindow *mwindow, MButtons *mbuttons, int x, int y)
2360 : BC_Toggle(x, y, mwindow->theme->ffmpeg_toggle,
2361 mwindow->preferences->get_file_probe_armed("FFMPEG_Early") > 0 ? 1 : 0)
2363 this->mwindow = mwindow;
2364 this->mbuttons = mbuttons;
2365 set_tooltip(get_value() ? FFMPEG_EARLY_TIP : FFMPEG_LATE_TIP);
2368 FFMpegToggle::~FFMpegToggle()
2372 int FFMpegToggle::handle_event()
2374 int ffmpeg_early_probe = get_value();
2375 set_tooltip(ffmpeg_early_probe ? FFMPEG_EARLY_TIP : FFMPEG_LATE_TIP);
2376 mwindow->preferences->set_file_probe_armed("FFMPEG_Early", ffmpeg_early_probe);
2377 mwindow->preferences->set_file_probe_armed("FFMPEG_Late", !ffmpeg_early_probe);
2379 mwindow->show_warning(&mwindow->preferences->warn_indexes,
2380 _("Changing the base codecs may require rebuilding indexes."));
2385 ProxyToggle::ProxyToggle(MWindow *mwindow, MButtons *mbuttons, int x, int y)
2386 : BC_Toggle(x, y, ( !mwindow->edl->session->proxy_use_scaler ?
2387 mwindow->theme->proxy_p_toggle :
2388 mwindow->theme->proxy_s_toggle ),
2389 mwindow->edl->session->proxy_disabled_scale != 1)
2391 this->mwindow = mwindow;
2392 this->mbuttons = mbuttons;
2393 scaler_images = mwindow->edl->session->proxy_use_scaler;
2394 set_tooltip(mwindow->edl->session->proxy_disabled_scale==1 ?
2395 _("Disable proxy") : _("Enable proxy"));
2398 void ProxyToggle::show()
2400 int use_scaler = mwindow->edl->session->proxy_use_scaler;
2401 if( scaler_images != use_scaler )
2402 set_images(!(scaler_images=use_scaler) ?
2403 mwindow->theme->proxy_p_toggle :
2404 mwindow->theme->proxy_s_toggle );
2410 void ProxyToggle::hide()
2416 ProxyToggle::~ProxyToggle()
2420 int ProxyToggle::handle_event()
2422 int disabled = get_value();
2424 mwindow->disable_proxy();
2426 mwindow->enable_proxy();
2427 set_tooltip(!disabled ? _("Disable proxy") : _("Enable proxy"));
2431 int ProxyToggle::keypress_event()
2433 if( ctrl_down() && !shift_down() && !alt_down() ) {
2434 int key = get_keypress();
2436 int value = get_value() ? 0 : 1;
2438 return handle_event();