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 redraw, int hide_cursor)
703 resource_thread->stop_draw(0);
705 int mode = redraw ? FORCE_REDRAW : NORMAL_DRAW;
706 for(int i = 0; i < TOTAL_PANES; i++) {
708 pane[i]->canvas->draw(mode, hide_cursor);
711 resource_thread->start_draw();
714 void MWindowGUI::flash_canvas(int flush)
716 for(int i = 0; i < TOTAL_PANES; i++)
720 pane[i]->canvas->flash(flush);
725 int MWindowGUI::show_window(int flush)
727 int ret = BC_WindowBase::show_window(flush);
728 update_proxy_toggle();
732 void MWindowGUI::draw_cursor(int do_plugintoggles)
734 for(int i = 0; i < TOTAL_PANES; i++)
738 pane[i]->cursor->draw(do_plugintoggles);
743 void MWindowGUI::show_cursor(int do_plugintoggles)
745 for(int i = 0; i < TOTAL_PANES; i++)
749 pane[i]->cursor->show(do_plugintoggles);
754 void MWindowGUI::hide_cursor(int do_plugintoggles)
756 for(int i = 0; i < TOTAL_PANES; i++)
760 pane[i]->cursor->hide(do_plugintoggles);
765 void MWindowGUI::update_cursor()
767 for(int i = 0; i < TOTAL_PANES; i++)
771 pane[i]->cursor->update();
776 void MWindowGUI::set_playing_back(int value)
778 for(int i = 0; i < TOTAL_PANES; i++)
782 pane[i]->cursor->playing_back = value;
787 void MWindowGUI::update_scrollbars(int flush)
789 for(int i = 0; i < TOTAL_PANES; i++)
793 pane[i]->update(1, NO_DRAW, 0, 0);
796 if(flush) this->flush();
799 void MWindowGUI::reset_meters()
801 for(int i = 0; i < TOTAL_PANES; i++)
803 if(pane[i] && pane[i]->patchbay)
805 pane[i]->patchbay->reset_meters();
810 void MWindowGUI::stop_meters()
812 for(int i = 0; i < TOTAL_PANES; i++)
814 if(pane[i] && pane[i]->patchbay)
816 pane[i]->patchbay->stop_meters();
821 void MWindowGUI::update_meters(ArrayList<double> *module_levels)
823 for(int i = 0; i < TOTAL_PANES; i++)
825 if(pane[i] && pane[i]->patchbay)
827 pane[i]->patchbay->update_meters(module_levels);
832 void MWindowGUI::set_editing_mode(int flush)
834 for(int i = 0; i < TOTAL_PANES; i++)
838 pane[i]->canvas->update_cursor(flush);
843 void MWindowGUI::set_meter_format(int mode, int min, int max)
845 for(int i = 0; i < TOTAL_PANES; i++)
847 if(pane[i] && pane[i]->patchbay)
849 pane[i]->patchbay->set_meter_format(mode, min, max);
854 void MWindowGUI::update(int scrollbars,
863 if(debug) PRINT_TRACE
867 mwindow->edl->tracks->update_y_pixels(mwindow->theme);
869 if( do_canvas != NO_DRAW && do_canvas != IGNORE_THREAD )
870 resource_thread->stop_draw(1);
872 for(int i = 0; i < TOTAL_PANES; i++)
874 if(pane[i]) pane[i]->update(scrollbars,
880 if( do_canvas != NO_DRAW && do_canvas != IGNORE_THREAD )
881 resource_thread->start_draw();
883 // if(scrollbars) this->get_scrollbars(0);
884 // if(timebar) this->timebar->update(0);
885 if(zoombar) this->zoombar->update();
886 // if(patchbay) this->patchbay->update();
887 if(clock) this->mainclock->update(
888 mwindow->edl->local_session->get_selectionstart(1));
889 if(debug) PRINT_TRACE
895 // this->canvas->draw(do_canvas);
896 // this->cursor->show();
897 // this->canvas->flash(0);
898 // Activate causes the menubar to deactivate. Don't want this for
900 // if(canvas != IGNORE_THREAD) this->canvas->activate();
902 if(debug) PRINT_TRACE
906 if(buttonbar) mbuttons->update();
907 if(debug) PRINT_TRACE
909 // Can't age if the cache called this to draw missing picons
910 // or the GUI is updating the status of the draw toggle.
911 if( do_canvas != FORCE_REDRAW && do_canvas != IGNORE_THREAD ) {
913 mwindow->age_caches();
914 lock_window("MWindowGUI::update");
918 if(debug) PRINT_TRACE
921 int MWindowGUI::visible(int64_t x1, int64_t x2, int64_t view_x1, int64_t view_x2)
923 return (x1 >= view_x1 && x1 < view_x2) ||
924 (x2 > view_x1 && x2 <= view_x2) ||
925 (x1 <= view_x1 && x2 >= view_x2);
929 void MWindowGUI::show_message(const char *message, int color)
931 statusbar->show_message(message, color);
934 void MWindowGUI::update_default_message()
936 statusbar->update_default_message();
939 void MWindowGUI::reset_default_message()
941 statusbar->reset_default_message();
944 void MWindowGUI::default_message()
946 statusbar->default_message();
949 // Drag motion called from other window
950 int MWindowGUI::drag_motion()
952 if(get_hidden()) return 0;
954 Track *over_track = 0;
956 PluginSet *over_pluginset = 0;
957 Plugin *over_plugin = 0;
962 drag_popup->cursor_motion_event();
966 // there's no point in drawing highlights has until drag operation has been set
967 if (!mwindow->session->current_operation)
970 for(int i = 0; i < TOTAL_PANES; i++)
972 if(pane[i]) pane[i]->canvas->drag_motion(
979 if(mwindow->session->track_highlighted != over_track)
981 mwindow->session->track_highlighted = over_track;
985 if(mwindow->session->edit_highlighted != over_edit)
987 mwindow->session->edit_highlighted = over_edit;
991 if(mwindow->session->pluginset_highlighted != over_pluginset)
993 mwindow->session->pluginset_highlighted = over_pluginset;
997 if(mwindow->session->plugin_highlighted != over_plugin)
999 mwindow->session->plugin_highlighted = over_plugin;
1003 if( mwindow->session->current_operation == DRAG_ASSET ||
1004 mwindow->session->current_operation == DRAG_EDIT ||
1005 mwindow->session->current_operation == DRAG_AEFFECT_COPY ||
1006 mwindow->session->current_operation == DRAG_VEFFECT_COPY )
1012 // printf("drag_motion %d %d over_track=%p over_edit=%p\n",
1019 lock_window("MWindowGUI::drag_motion");
1026 int MWindowGUI::drag_stop()
1028 if(get_hidden()) return 0;
1029 int result = 0, redraw = 0;
1031 for(int i = 0; i < TOTAL_PANES; i++)
1033 if(pane[i]) result |= pane[i]->canvas->drag_stop(
1036 mwindow->edl->optimize();
1038 // since we don't have subwindows we have to terminate any drag operation
1041 if (mwindow->session->track_highlighted
1042 || mwindow->session->edit_highlighted
1043 || mwindow->session->plugin_highlighted
1044 || mwindow->session->pluginset_highlighted)
1046 mwindow->session->track_highlighted = 0;
1047 mwindow->session->edit_highlighted = 0;
1048 mwindow->session->plugin_highlighted = 0;
1049 mwindow->session->pluginset_highlighted = 0;
1050 mwindow->session->current_operation = NO_OPERATION;
1054 //printf("MWindowGUI::drag_stop %d %d\n", redraw, mwindow->session->current_operation);
1057 mwindow->edl->tracks->update_y_pixels(mwindow->theme);
1058 update_scrollbars(0);
1073 void MWindowGUI::default_positions()
1075 //printf("MWindowGUI::default_positions 1\n");
1076 VWindow *vwindow = mwindow->vwindows.size() > DEFAULT_VWINDOW ?
1077 mwindow->vwindows.get(DEFAULT_VWINDOW) : 0;
1078 if( vwindow && !vwindow->is_running() ) vwindow = 0;
1079 if( vwindow ) vwindow->gui->lock_window("MWindowGUI::default_positions");
1080 mwindow->cwindow->gui->lock_window("MWindowGUI::default_positions");
1081 mwindow->awindow->gui->lock_window("MWindowGUI::default_positions");
1083 // printf("MWindowGUI::default_positions 1 %d %d %d %d\n", mwindow->session->vwindow_x,
1084 // mwindow->session->vwindow_y,
1085 // mwindow->session->vwindow_w,
1086 // mwindow->session->vwindow_h);
1087 reposition_window(mwindow->session->mwindow_x,
1088 mwindow->session->mwindow_y,
1089 mwindow->session->mwindow_w,
1090 mwindow->session->mwindow_h);
1091 if( vwindow ) vwindow->gui->reposition_window(mwindow->session->vwindow_x,
1092 mwindow->session->vwindow_y,
1093 mwindow->session->vwindow_w,
1094 mwindow->session->vwindow_h);
1095 mwindow->cwindow->gui->reposition_window(mwindow->session->cwindow_x,
1096 mwindow->session->cwindow_y,
1097 mwindow->session->cwindow_w,
1098 mwindow->session->cwindow_h);
1099 mwindow->awindow->gui->reposition_window(mwindow->session->awindow_x,
1100 mwindow->session->awindow_y,
1101 mwindow->session->awindow_w,
1102 mwindow->session->awindow_h);
1103 //printf("MWindowGUI::default_positions 1\n");
1105 resize_event(mwindow->session->mwindow_w,
1106 mwindow->session->mwindow_h);
1107 //printf("MWindowGUI::default_positions 1\n");
1108 if( vwindow ) vwindow->gui->resize_event(mwindow->session->vwindow_w,
1109 mwindow->session->vwindow_h);
1110 //printf("MWindowGUI::default_positions 1\n");
1111 mwindow->cwindow->gui->resize_event(mwindow->session->cwindow_w,
1112 mwindow->session->cwindow_h);
1113 //printf("MWindowGUI::default_positions 1\n");
1114 mwindow->awindow->gui->resize_event(mwindow->session->awindow_w,
1115 mwindow->session->awindow_h);
1117 //printf("MWindowGUI::default_positions 1\n");
1120 if( vwindow ) vwindow->gui->flush();
1121 mwindow->cwindow->gui->flush();
1122 mwindow->awindow->gui->flush();
1124 if( vwindow ) vwindow->gui->unlock_window();
1125 mwindow->cwindow->gui->unlock_window();
1126 mwindow->awindow->gui->unlock_window();
1127 //printf("MWindowGUI::default_positions 2\n");
1131 int MWindowGUI::repeat_event(int64_t duration)
1133 // if(duration == 100)
1134 // mwindow->sync_parameters(CHANGE_ALL);
1136 for(int i = 0; i < TOTAL_PANES; i++)
1138 if(pane[i]) result = pane[i]->cursor->repeat_event(duration);
1144 int MWindowGUI::translation_event()
1146 //printf("MWindowGUI::translation_event 1 %d %d\n", get_x(), get_y());
1147 mwindow->session->mwindow_x = get_x();
1148 mwindow->session->mwindow_y = get_y();
1153 int MWindowGUI::save_defaults(BC_Hash *defaults)
1155 defaults->update("MWINDOWWIDTH", get_w());
1156 defaults->update("MWINDOWHEIGHT", get_h());
1157 mainmenu->save_defaults(defaults);
1158 BC_WindowBase::save_defaults(defaults);
1162 int MWindowGUI::keypress_event()
1164 //printf("MWindowGUI::keypress_event 1 %d\n", get_keypress());
1165 int result = mbuttons->keypress_event();
1166 if( result ) return result;
1168 Track *this_track = 0;
1170 switch(get_keypress()) {
1172 mwindow->toggle_editing_mode();
1177 if( alt_down() ) break;
1178 stop_transport("MWindowGUI::keypress_event 1");
1179 mwindow->nearest_plugin_keyframe(shift_down(),
1180 !ctrl_down() ? PLAY_FORWARD : PLAY_REVERSE);
1184 case '1': case '2': case '3': case '4':
1185 case '5': case '6': case '7': case '8':
1186 if( !alt_down() || shift_down() ) break;
1187 if( !mwindow->select_asset(get_keypress()-'1',1) )
1192 if( !ctrl_down() ) {
1194 stop_transport("MWindowGUI::keypress_event 1");
1195 mwindow->prev_edit_handle(shift_down());
1198 mwindow->move_left();
1204 if( !ctrl_down() && !alt_down() ) {
1205 mwindow->move_left();
1211 if( !ctrl_down() ) {
1213 stop_transport("MWindowGUI::keypress_event 2");
1214 mwindow->next_edit_handle(shift_down());
1217 mwindow->move_right();
1223 if( !ctrl_down() && !alt_down() ) {
1224 mwindow->move_right();
1230 if( ctrl_down() && !alt_down() )
1231 mwindow->expand_y();
1232 else if( !ctrl_down() && alt_down() )
1233 mwindow->expand_autos(0,1,1);
1234 else if( ctrl_down() && alt_down() )
1235 mwindow->expand_autos(1,1,1);
1237 mwindow->expand_sample();
1242 if( ctrl_down() && !alt_down() )
1243 mwindow->zoom_in_y();
1244 else if( !ctrl_down() && alt_down() )
1245 mwindow->shrink_autos(0,1,1);
1246 else if( ctrl_down() && alt_down() )
1247 mwindow->shrink_autos(1,1,1);
1249 mwindow->zoom_in_sample();
1257 mwindow->expand_t();
1263 mwindow->move_down();
1265 mwindow->zoom_in_t();
1271 for( int i=0; i<TOTAL_PANES; ++i ) {
1272 if( !pane[i] ) continue;
1273 if( (this_track = pane[i]->over_track()) != 0 ) break;
1274 if( (this_track = pane[i]->over_patchbay()) != 0 ) break;
1277 if( get_keypress() == TAB ) { // Switch the record button
1279 this_track->record = !this_track->record ? 1 : 0;
1282 int total_selected = mwindow->edl->tracks->total_of(Tracks::RECORD);
1283 // all selected if nothing previously selected or
1284 // if this patch was previously the only one selected and armed
1285 int selected = !total_selected || (total_selected == 1 &&
1286 this_track && this_track->record ) ? 1 : 0;
1287 mwindow->edl->tracks->select_all(Tracks::RECORD, selected);
1288 if( !selected && this_track ) this_track->record = 1;
1291 update(0, NORMAL_DRAW, 0, 0, 1, 0, 1);
1293 mwindow->cwindow->update(0, 1, 1);
1294 lock_window("MWindowGUI::keypress_event 3");
1311 resend_event(mwindow->cwindow->gui);
1315 // since things under cursor have changed...
1317 cursor_motion_event();
1322 int MWindowGUI::keyboard_listener(BC_WindowBase *wp)
1324 return key_listener(wp->get_keypress());
1327 int MWindowGUI::key_listener(int key)
1332 if( !record->running() )
1335 record->record_gui->interrupt_thread->start(0);
1342 channel_info->toggle_scan();
1346 if( !remote_control->deactivate() )
1347 remote_control->activate();
1357 void MWindowGUI::use_android_remote(int on)
1360 delete android_control;
1361 android_control = 0;
1364 if( android_control ) return;
1365 android_control = new AndroidControl(this);
1368 int MWindowGUI::close_event()
1374 void MWindowGUI::stop_drawing()
1376 resource_thread->stop_draw(1);
1379 int MWindowGUI::menu_w()
1381 return mainmenu->get_w();
1384 int MWindowGUI::menu_h()
1386 return mainmenu->get_h();
1389 void MWindowGUI::start_x_pane_drag()
1393 x_pane_drag = new BC_Popup(this,
1394 get_abs_cursor_x(0) - mwindow->theme->pane_w,
1395 BC_DisplayInfo::get_top_border() +
1397 mwindow->theme->mcanvas_y,
1398 mwindow->theme->pane_w,
1399 mwindow->theme->mcanvas_h,
1400 mwindow->theme->drag_pane_color);
1401 x_pane_drag->draw_3segmentv(0,
1403 x_pane_drag->get_h(),
1404 mwindow->theme->get_image_set("xpane")[BUTTON_DOWNHI]);
1405 x_pane_drag->flash(1);
1410 void MWindowGUI::start_y_pane_drag()
1414 //printf("MWindowGUI::start_y_pane_drag %d %d %d\n", __LINE__, get_x(), get_y());
1415 y_pane_drag = new BC_Popup(this,
1416 BC_DisplayInfo::get_left_border() +
1418 mwindow->theme->mcanvas_x,
1419 get_abs_cursor_y(0) - mwindow->theme->pane_h,
1420 mwindow->theme->mcanvas_w,
1421 mwindow->theme->pane_h,
1422 mwindow->theme->drag_pane_color);
1423 y_pane_drag->draw_3segmenth(0,
1425 y_pane_drag->get_w(),
1426 mwindow->theme->get_image_set("ypane")[BUTTON_DOWNHI]);
1427 y_pane_drag->flash(1);
1432 void MWindowGUI::handle_pane_drag()
1438 x_pane_drag->reposition_window(
1439 get_abs_cursor_x(0) - mwindow->theme->pane_w,
1440 x_pane_drag->get_y());
1445 y_pane_drag->reposition_window(
1446 y_pane_drag->get_x(),
1447 get_abs_cursor_y(0) - mwindow->theme->pane_h);
1453 void MWindowGUI::create_x_pane(int cursor_x)
1455 if(total_panes() == 1)
1457 // create a horizontal pane
1458 // do this 1st so the resize_event knows there are 2 panes
1459 mwindow->edl->local_session->view_start[TOP_RIGHT_PANE] =
1460 mwindow->edl->local_session->view_start[TOP_LEFT_PANE] +
1462 mwindow->theme->patchbay_w;
1463 pane[TOP_RIGHT_PANE] = new TimelinePane(mwindow,
1465 mwindow->theme->mcanvas_x +
1467 mwindow->theme->mcanvas_y,
1468 mwindow->theme->mcanvas_x +
1469 mwindow->theme->mcanvas_w -
1471 mwindow->theme->mcanvas_h);
1472 pane[TOP_LEFT_PANE]->resize_event(
1473 mwindow->theme->mcanvas_x,
1474 mwindow->theme->mcanvas_y,
1475 cursor_x - mwindow->theme->pane_w,
1476 mwindow->theme->mcanvas_h);
1477 pane[TOP_RIGHT_PANE]->create_objects();
1480 if(vertical_panes())
1482 // create 2 horizontal panes
1483 mwindow->edl->local_session->track_start[TOP_RIGHT_PANE] =
1484 mwindow->edl->local_session->track_start[TOP_LEFT_PANE];
1485 mwindow->edl->local_session->track_start[BOTTOM_RIGHT_PANE] =
1486 mwindow->edl->local_session->track_start[BOTTOM_LEFT_PANE];
1487 mwindow->edl->local_session->view_start[TOP_RIGHT_PANE] =
1488 mwindow->edl->local_session->view_start[BOTTOM_RIGHT_PANE] =
1489 mwindow->edl->local_session->view_start[TOP_LEFT_PANE] +
1491 mwindow->theme->patchbay_w;
1492 pane[TOP_RIGHT_PANE] = new TimelinePane(mwindow,
1494 mwindow->theme->mcanvas_x +
1496 pane[TOP_LEFT_PANE]->y,
1497 mwindow->theme->mcanvas_x +
1498 mwindow->theme->mcanvas_w -
1500 pane[TOP_LEFT_PANE]->h);
1501 pane[BOTTOM_RIGHT_PANE] = new TimelinePane(mwindow,
1503 mwindow->theme->mcanvas_x +
1505 pane[BOTTOM_LEFT_PANE]->y,
1506 mwindow->theme->mcanvas_x +
1507 mwindow->theme->mcanvas_w -
1509 pane[BOTTOM_LEFT_PANE]->h);
1510 pane[TOP_LEFT_PANE]->resize_event(
1511 pane[TOP_LEFT_PANE]->x,
1512 pane[TOP_LEFT_PANE]->y,
1513 cursor_x - mwindow->theme->pane_w,
1514 pane[TOP_LEFT_PANE]->h);
1515 pane[BOTTOM_LEFT_PANE]->resize_event(
1516 pane[BOTTOM_LEFT_PANE]->x,
1517 pane[BOTTOM_LEFT_PANE]->y,
1518 cursor_x - mwindow->theme->pane_w,
1519 pane[BOTTOM_LEFT_PANE]->h);
1520 pane[TOP_RIGHT_PANE]->create_objects();
1521 pane[BOTTOM_RIGHT_PANE]->create_objects();
1524 if(horizontal_panes())
1526 // resize a horizontal pane
1527 mwindow->edl->local_session->view_start[TOP_RIGHT_PANE] +=
1529 pane[TOP_RIGHT_PANE]->x;
1530 if(mwindow->edl->local_session->view_start[TOP_RIGHT_PANE] < 0)
1531 mwindow->edl->local_session->view_start[TOP_RIGHT_PANE] = 0;
1532 pane[TOP_LEFT_PANE]->resize_event(
1533 mwindow->theme->mcanvas_x,
1534 mwindow->theme->mcanvas_y,
1535 cursor_x - mwindow->theme->pane_w,
1536 mwindow->theme->mcanvas_h);
1537 pane[TOP_RIGHT_PANE]->resize_event(
1538 mwindow->theme->mcanvas_x +
1540 pane[TOP_RIGHT_PANE]->y,
1541 mwindow->theme->mcanvas_x +
1542 mwindow->theme->mcanvas_w -
1544 mwindow->theme->mcanvas_h);
1548 // resize 2 horizontal panes
1549 mwindow->edl->local_session->view_start[TOP_RIGHT_PANE] +=
1551 pane[TOP_RIGHT_PANE]->x;
1552 if(mwindow->edl->local_session->view_start[TOP_RIGHT_PANE] < 0)
1553 mwindow->edl->local_session->view_start[TOP_RIGHT_PANE] = 0;
1554 mwindow->edl->local_session->view_start[BOTTOM_RIGHT_PANE] =
1555 mwindow->edl->local_session->view_start[TOP_RIGHT_PANE];
1557 pane[TOP_LEFT_PANE]->resize_event(
1558 mwindow->theme->mcanvas_x,
1559 pane[TOP_LEFT_PANE]->y,
1560 cursor_x - mwindow->theme->pane_w,
1561 pane[TOP_LEFT_PANE]->h);
1562 pane[TOP_RIGHT_PANE]->resize_event(
1563 mwindow->theme->mcanvas_x +
1565 pane[TOP_RIGHT_PANE]->y,
1566 mwindow->theme->mcanvas_x +
1567 mwindow->theme->mcanvas_w -
1569 pane[TOP_RIGHT_PANE]->h);
1570 pane[BOTTOM_LEFT_PANE]->resize_event(
1571 mwindow->theme->mcanvas_x,
1572 pane[BOTTOM_LEFT_PANE]->y,
1573 cursor_x - mwindow->theme->pane_w,
1574 pane[BOTTOM_LEFT_PANE]->h);
1575 pane[BOTTOM_RIGHT_PANE]->resize_event(
1576 mwindow->theme->mcanvas_x +
1578 pane[BOTTOM_RIGHT_PANE]->y,
1579 mwindow->theme->mcanvas_x +
1580 mwindow->theme->mcanvas_w -
1582 pane[BOTTOM_RIGHT_PANE]->h);
1588 void MWindowGUI::delete_x_pane(int cursor_x)
1590 // give left panes coordinates of right pane
1591 if(cursor_x < mwindow->theme->patchbay_w + PANE_DRAG_MARGIN &&
1592 pane[TOP_RIGHT_PANE])
1594 mwindow->edl->local_session->view_start[TOP_LEFT_PANE] =
1595 mwindow->edl->local_session->view_start[TOP_RIGHT_PANE] -
1596 pane[TOP_RIGHT_PANE]->x + mwindow->theme->patchbay_w;
1597 if(mwindow->edl->local_session->view_start[TOP_LEFT_PANE] < 0)
1598 mwindow->edl->local_session->view_start[TOP_LEFT_PANE] = 0;
1599 mwindow->edl->local_session->view_start[BOTTOM_LEFT_PANE] =
1600 mwindow->edl->local_session->view_start[TOP_LEFT_PANE];
1603 switch(total_panes())
1606 if(pane[TOP_LEFT_PANE] && pane[TOP_RIGHT_PANE])
1608 // delete right pane
1609 delete pane[TOP_RIGHT_PANE];
1610 pane[TOP_RIGHT_PANE] = 0;
1611 pane[TOP_LEFT_PANE]->resize_event(
1612 mwindow->theme->mcanvas_x,
1613 mwindow->theme->mcanvas_y,
1614 mwindow->theme->mcanvas_w,
1615 mwindow->theme->mcanvas_h);
1621 // delete right panes
1622 delete pane[TOP_RIGHT_PANE];
1623 pane[TOP_RIGHT_PANE] = 0;
1624 delete pane[BOTTOM_RIGHT_PANE];
1625 pane[BOTTOM_RIGHT_PANE] = 0;
1626 pane[TOP_LEFT_PANE]->resize_event(
1627 mwindow->theme->mcanvas_x,
1628 pane[TOP_LEFT_PANE]->y,
1629 mwindow->theme->mcanvas_w,
1630 pane[TOP_LEFT_PANE]->h);
1631 pane[BOTTOM_LEFT_PANE]->resize_event(
1632 mwindow->theme->mcanvas_x,
1633 pane[BOTTOM_LEFT_PANE]->y,
1634 mwindow->theme->mcanvas_w,
1635 pane[BOTTOM_LEFT_PANE]->h);
1640 void MWindowGUI::create_y_pane(int cursor_y)
1642 if(total_panes() == 1)
1644 mwindow->edl->local_session->view_start[BOTTOM_LEFT_PANE] =
1645 mwindow->edl->local_session->view_start[TOP_LEFT_PANE];
1646 mwindow->edl->local_session->track_start[BOTTOM_LEFT_PANE] =
1647 mwindow->edl->local_session->track_start[TOP_LEFT_PANE] +
1649 mwindow->theme->mtimebar_h;
1650 // do this 1st so the resize_event knows there are 2 panes
1651 pane[BOTTOM_LEFT_PANE] = new TimelinePane(mwindow,
1653 mwindow->theme->mcanvas_x,
1654 mwindow->theme->mcanvas_y +
1656 mwindow->theme->mcanvas_w,
1657 mwindow->theme->mcanvas_h -
1659 pane[TOP_LEFT_PANE]->resize_event(
1660 mwindow->theme->mcanvas_x,
1661 mwindow->theme->mcanvas_y,
1662 mwindow->theme->mcanvas_w,
1663 pane[BOTTOM_LEFT_PANE]->y -
1664 mwindow->theme->mcanvas_y -
1665 mwindow->theme->pane_h);
1666 pane[BOTTOM_LEFT_PANE]->create_objects();
1669 if(horizontal_panes())
1672 mwindow->edl->local_session->view_start[BOTTOM_LEFT_PANE] =
1673 mwindow->edl->local_session->view_start[TOP_LEFT_PANE];
1674 mwindow->edl->local_session->view_start[BOTTOM_RIGHT_PANE] =
1675 mwindow->edl->local_session->view_start[TOP_RIGHT_PANE];
1676 mwindow->edl->local_session->track_start[BOTTOM_LEFT_PANE] =
1677 mwindow->edl->local_session->track_start[BOTTOM_RIGHT_PANE] =
1678 mwindow->edl->local_session->track_start[TOP_LEFT_PANE] +
1680 mwindow->theme->mtimebar_h;
1682 pane[BOTTOM_LEFT_PANE] = new TimelinePane(mwindow,
1684 pane[TOP_LEFT_PANE]->x,
1685 mwindow->theme->mcanvas_y +
1687 pane[TOP_LEFT_PANE]->w,
1688 mwindow->theme->mcanvas_h -
1690 pane[BOTTOM_RIGHT_PANE] = new TimelinePane(mwindow,
1692 pane[TOP_RIGHT_PANE]->x,
1693 mwindow->theme->mcanvas_y +
1695 pane[TOP_RIGHT_PANE]->w,
1696 mwindow->theme->mcanvas_h -
1699 pane[TOP_LEFT_PANE]->resize_event(
1700 pane[TOP_LEFT_PANE]->x,
1701 pane[TOP_LEFT_PANE]->y,
1702 pane[TOP_LEFT_PANE]->w,
1703 pane[BOTTOM_LEFT_PANE]->y -
1704 mwindow->theme->mcanvas_y -
1705 mwindow->theme->pane_h);
1706 pane[TOP_RIGHT_PANE]->resize_event(
1707 pane[TOP_RIGHT_PANE]->x,
1708 pane[TOP_RIGHT_PANE]->y,
1709 pane[TOP_RIGHT_PANE]->w,
1710 pane[BOTTOM_RIGHT_PANE]->y -
1711 mwindow->theme->mcanvas_y -
1712 mwindow->theme->pane_h);
1714 pane[BOTTOM_LEFT_PANE]->create_objects();
1715 pane[BOTTOM_RIGHT_PANE]->create_objects();
1718 if(vertical_panes())
1721 mwindow->edl->local_session->track_start[BOTTOM_LEFT_PANE] +=
1723 (pane[BOTTOM_LEFT_PANE]->y - mwindow->theme->mcanvas_y);
1724 if(mwindow->edl->local_session->track_start[BOTTOM_LEFT_PANE] < 0)
1725 mwindow->edl->local_session->track_start[BOTTOM_LEFT_PANE] = 0;
1726 pane[TOP_LEFT_PANE]->resize_event(
1727 mwindow->theme->mcanvas_x,
1728 mwindow->theme->mcanvas_y,
1729 mwindow->theme->mcanvas_w,
1730 cursor_y - mwindow->theme->pane_h);
1731 pane[BOTTOM_LEFT_PANE]->resize_event(
1732 pane[BOTTOM_LEFT_PANE]->x,
1734 mwindow->theme->mcanvas_y,
1735 mwindow->theme->mcanvas_w,
1736 mwindow->theme->mcanvas_h -
1742 mwindow->edl->local_session->track_start[BOTTOM_LEFT_PANE] +=
1744 (pane[BOTTOM_LEFT_PANE]->y - mwindow->theme->mcanvas_y);
1745 if(mwindow->edl->local_session->track_start[BOTTOM_LEFT_PANE] < 0)
1746 mwindow->edl->local_session->track_start[BOTTOM_LEFT_PANE] = 0;
1747 mwindow->edl->local_session->track_start[BOTTOM_RIGHT_PANE] =
1748 mwindow->edl->local_session->track_start[BOTTOM_LEFT_PANE];
1749 pane[TOP_LEFT_PANE]->resize_event(
1750 pane[TOP_LEFT_PANE]->x,
1751 pane[TOP_LEFT_PANE]->y,
1752 pane[TOP_LEFT_PANE]->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 pane[BOTTOM_LEFT_PANE]->w,
1759 mwindow->theme->mcanvas_h -
1761 pane[TOP_RIGHT_PANE]->resize_event(
1762 pane[TOP_RIGHT_PANE]->x,
1763 pane[TOP_RIGHT_PANE]->y,
1764 pane[TOP_RIGHT_PANE]->w,
1765 cursor_y - mwindow->theme->pane_h);
1766 pane[BOTTOM_RIGHT_PANE]->resize_event(
1767 pane[BOTTOM_RIGHT_PANE]->x,
1769 mwindow->theme->mcanvas_y,
1770 pane[BOTTOM_RIGHT_PANE]->w,
1771 mwindow->theme->mcanvas_h -
1776 void MWindowGUI::delete_y_pane(int cursor_y)
1778 if(cursor_y < mwindow->theme->mtimebar_h +
1780 pane[BOTTOM_LEFT_PANE])
1782 // give top pane coordinates of bottom pane
1783 mwindow->edl->local_session->track_start[TOP_LEFT_PANE] =
1784 mwindow->edl->local_session->track_start[BOTTOM_LEFT_PANE] -
1785 pane[BOTTOM_LEFT_PANE]->y;
1786 if(mwindow->edl->local_session->track_start[TOP_LEFT_PANE] < 0)
1787 mwindow->edl->local_session->track_start[TOP_LEFT_PANE] = 0;
1788 mwindow->edl->local_session->track_start[TOP_RIGHT_PANE] =
1789 mwindow->edl->local_session->track_start[TOP_LEFT_PANE];
1793 switch(total_panes())
1796 delete pane[BOTTOM_LEFT_PANE];
1797 pane[BOTTOM_LEFT_PANE] = 0;
1798 pane[TOP_LEFT_PANE]->resize_event(
1799 mwindow->theme->mcanvas_x,
1800 mwindow->theme->mcanvas_y,
1801 mwindow->theme->mcanvas_w,
1802 mwindow->theme->mcanvas_h);
1806 // delete bottom 2 panes
1808 delete pane[BOTTOM_LEFT_PANE];
1809 pane[BOTTOM_LEFT_PANE] = 0;
1810 delete pane[BOTTOM_RIGHT_PANE];
1811 pane[BOTTOM_RIGHT_PANE] = 0;
1812 pane[TOP_LEFT_PANE]->resize_event(
1813 pane[TOP_LEFT_PANE]->x,
1814 mwindow->theme->mcanvas_y,
1815 pane[TOP_LEFT_PANE]->w,
1816 mwindow->theme->mcanvas_h);
1817 pane[TOP_RIGHT_PANE]->resize_event(
1818 pane[TOP_RIGHT_PANE]->x,
1819 mwindow->theme->mcanvas_y,
1820 pane[TOP_RIGHT_PANE]->w,
1821 mwindow->theme->mcanvas_h);
1826 void MWindowGUI::stop_pane_drag()
1829 resource_thread->stop_draw(0);
1833 // cursor position relative to canvas
1834 int cursor_x = x_pane_drag->get_x() -
1836 BC_DisplayInfo::get_left_border() -
1837 mwindow->theme->mcanvas_x +
1838 mwindow->theme->pane_w;
1843 if(cursor_x >= mwindow->theme->patchbay_w + PANE_DRAG_MARGIN &&
1844 cursor_x < mwindow->theme->mcanvas_w -
1845 BC_ScrollBar::get_span(SCROLL_VERT) -
1848 create_x_pane(cursor_x);
1849 mwindow->edl->local_session->x_pane = cursor_x;
1854 delete_x_pane(cursor_x);
1855 mwindow->edl->local_session->x_pane = -1;
1863 // cursor position relative to canvas
1864 int cursor_y = y_pane_drag->get_y() -
1866 BC_DisplayInfo::get_top_border() -
1867 mwindow->theme->mcanvas_y +
1868 mwindow->theme->pane_h;
1874 if(cursor_y >= mwindow->theme->mtimebar_h +
1876 cursor_y < mwindow->theme->mcanvas_h -
1877 BC_ScrollBar::get_span(SCROLL_HORIZ) -
1880 create_y_pane(cursor_y);
1881 mwindow->edl->local_session->y_pane = cursor_y;
1885 delete_y_pane(cursor_y);
1886 mwindow->edl->local_session->y_pane = -1;
1890 update_pane_dividers();
1892 // required to get new widgets to appear
1894 resource_thread->start_draw();
1897 // create panes from EDL
1898 void MWindowGUI::load_panes()
1900 int need_x_panes = 0;
1901 int need_y_panes = 0;
1902 // use names from create functions
1903 int cursor_x = mwindow->edl->local_session->x_pane;
1904 int cursor_y = mwindow->edl->local_session->y_pane;
1906 resource_thread->stop_draw(1);
1908 mwindow->theme->patchbay_w + PANE_DRAG_MARGIN &&
1910 mwindow->theme->mcanvas_w -
1911 BC_ScrollBar::get_span(SCROLL_VERT) -
1918 mwindow->theme->mtimebar_h + PANE_DRAG_MARGIN &&
1920 mwindow->theme->mcanvas_h -
1921 BC_ScrollBar::get_span(SCROLL_HORIZ) -
1927 //printf("MWindowGUI::load_panes %d %d %d\n", __LINE__, need_x_panes, need_y_panes);
1935 if(total_panes() == 1)
1938 //printf("MWindowGUI::load_panes %d\n", __LINE__);
1939 pane[TOP_RIGHT_PANE] = new TimelinePane(mwindow,
1941 mwindow->theme->mcanvas_x +
1943 mwindow->theme->mcanvas_y,
1944 mwindow->theme->mcanvas_x +
1945 mwindow->theme->mcanvas_w -
1947 cursor_y - mwindow->theme->pane_h);
1948 pane[BOTTOM_LEFT_PANE] = new TimelinePane(mwindow,
1950 mwindow->theme->mcanvas_x,
1951 mwindow->theme->mcanvas_y +
1953 cursor_x - mwindow->theme->pane_w,
1954 mwindow->theme->mcanvas_h -
1956 pane[BOTTOM_RIGHT_PANE] = new TimelinePane(mwindow,
1958 pane[TOP_RIGHT_PANE]->x,
1959 mwindow->theme->mcanvas_y +
1961 pane[TOP_RIGHT_PANE]->w,
1962 mwindow->theme->mcanvas_h -
1964 pane[TOP_LEFT_PANE]->resize_event(
1965 pane[TOP_LEFT_PANE]->x,
1966 pane[TOP_LEFT_PANE]->y,
1967 cursor_x - mwindow->theme->pane_w,
1968 cursor_y - mwindow->theme->pane_h);
1969 pane[TOP_RIGHT_PANE]->create_objects();
1970 pane[BOTTOM_LEFT_PANE]->create_objects();
1971 pane[BOTTOM_RIGHT_PANE]->create_objects();
1974 if(horizontal_panes())
1976 // create vertical panes
1977 //printf("MWindowGUI::load_panes %d\n", __LINE__);
1978 pane[BOTTOM_LEFT_PANE] = new TimelinePane(mwindow,
1980 mwindow->theme->mcanvas_x,
1981 mwindow->theme->mcanvas_y +
1983 cursor_x - mwindow->theme->pane_w,
1984 mwindow->theme->mcanvas_h -
1986 pane[BOTTOM_RIGHT_PANE] = new TimelinePane(mwindow,
1988 pane[TOP_RIGHT_PANE]->x,
1989 mwindow->theme->mcanvas_y +
1991 pane[TOP_RIGHT_PANE]->w,
1992 mwindow->theme->mcanvas_h -
1994 pane[TOP_LEFT_PANE]->resize_event(
1995 pane[TOP_LEFT_PANE]->x,
1996 pane[TOP_LEFT_PANE]->y,
1997 cursor_x - mwindow->theme->pane_w,
1998 cursor_y - mwindow->theme->pane_h);
1999 pane[TOP_RIGHT_PANE]->resize_event(
2000 mwindow->theme->mcanvas_x +
2002 mwindow->theme->mcanvas_y,
2003 mwindow->theme->mcanvas_x +
2004 mwindow->theme->mcanvas_w -
2006 cursor_y - mwindow->theme->pane_h);
2007 pane[BOTTOM_LEFT_PANE]->create_objects();
2008 pane[BOTTOM_RIGHT_PANE]->create_objects();
2011 if(vertical_panes())
2013 // create horizontal panes
2014 //printf("MWindowGUI::load_panes %d\n", __LINE__);
2015 pane[TOP_RIGHT_PANE] = new TimelinePane(mwindow,
2017 mwindow->theme->mcanvas_x +
2019 mwindow->theme->mcanvas_y,
2020 mwindow->theme->mcanvas_x +
2021 mwindow->theme->mcanvas_w -
2023 cursor_y - mwindow->theme->pane_h);
2024 pane[BOTTOM_RIGHT_PANE] = new TimelinePane(mwindow,
2026 pane[TOP_RIGHT_PANE]->x,
2027 mwindow->theme->mcanvas_y +
2029 pane[TOP_RIGHT_PANE]->w,
2030 mwindow->theme->mcanvas_h -
2032 pane[TOP_LEFT_PANE]->resize_event(
2033 pane[TOP_LEFT_PANE]->x,
2034 pane[TOP_LEFT_PANE]->y,
2035 cursor_x - mwindow->theme->pane_w,
2036 cursor_y - mwindow->theme->pane_h);
2037 pane[BOTTOM_LEFT_PANE]->resize_event(
2038 pane[TOP_LEFT_PANE]->x,
2039 mwindow->theme->mcanvas_y +
2041 mwindow->theme->mcanvas_x +
2042 mwindow->theme->mcanvas_w -
2043 cursor_x - mwindow->theme->pane_w,
2044 mwindow->theme->mcanvas_h -
2046 pane[TOP_RIGHT_PANE]->create_objects();
2047 pane[BOTTOM_RIGHT_PANE]->create_objects();
2054 //printf("MWindowGUI::load_panes %d\n", __LINE__);
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[TOP_RIGHT_PANE]->resize_event(
2061 mwindow->theme->mcanvas_x +
2063 mwindow->theme->mcanvas_y,
2064 mwindow->theme->mcanvas_x +
2065 mwindow->theme->mcanvas_w -
2067 cursor_y - mwindow->theme->pane_h);
2068 pane[BOTTOM_LEFT_PANE]->resize_event(
2069 pane[TOP_LEFT_PANE]->x,
2070 mwindow->theme->mcanvas_y +
2072 mwindow->theme->mcanvas_x +
2073 mwindow->theme->mcanvas_w -
2074 cursor_x - mwindow->theme->pane_w,
2075 mwindow->theme->mcanvas_h -
2077 pane[BOTTOM_RIGHT_PANE]->resize_event(
2078 pane[TOP_RIGHT_PANE]->x,
2079 mwindow->theme->mcanvas_y +
2081 pane[TOP_RIGHT_PANE]->w,
2082 mwindow->theme->mcanvas_h -
2091 if(pane[BOTTOM_LEFT_PANE]) delete pane[BOTTOM_LEFT_PANE];
2092 if(pane[BOTTOM_RIGHT_PANE]) delete pane[BOTTOM_RIGHT_PANE];
2093 pane[BOTTOM_LEFT_PANE] = 0;
2094 pane[BOTTOM_RIGHT_PANE] = 0;
2096 if(!pane[TOP_RIGHT_PANE])
2098 pane[TOP_RIGHT_PANE] = new TimelinePane(mwindow,
2100 mwindow->theme->mcanvas_x +
2102 mwindow->theme->mcanvas_y,
2103 mwindow->theme->mcanvas_x +
2104 mwindow->theme->mcanvas_w -
2106 mwindow->theme->mcanvas_h);
2107 pane[TOP_LEFT_PANE]->resize_event(
2108 mwindow->theme->mcanvas_x,
2109 mwindow->theme->mcanvas_y,
2110 cursor_x - mwindow->theme->pane_w,
2111 mwindow->theme->mcanvas_h);
2112 pane[TOP_RIGHT_PANE]->create_objects();
2116 pane[TOP_LEFT_PANE]->resize_event(
2117 mwindow->theme->mcanvas_x,
2118 mwindow->theme->mcanvas_y,
2119 cursor_x - mwindow->theme->pane_w,
2120 mwindow->theme->mcanvas_h);
2121 pane[TOP_RIGHT_PANE]->resize_event(
2122 mwindow->theme->mcanvas_x +
2124 pane[TOP_RIGHT_PANE]->y,
2125 mwindow->theme->mcanvas_x +
2126 mwindow->theme->mcanvas_w -
2128 mwindow->theme->mcanvas_h);
2136 if(pane[TOP_RIGHT_PANE]) delete pane[TOP_RIGHT_PANE];
2137 if(pane[BOTTOM_RIGHT_PANE]) delete pane[BOTTOM_RIGHT_PANE];
2138 pane[TOP_RIGHT_PANE] = 0;
2139 pane[BOTTOM_RIGHT_PANE] = 0;
2141 if(!pane[BOTTOM_LEFT_PANE])
2143 //printf("MWindowGUI::load_panes %d\n", __LINE__);
2144 pane[BOTTOM_LEFT_PANE] = new TimelinePane(mwindow,
2146 mwindow->theme->mcanvas_x,
2147 mwindow->theme->mcanvas_y +
2149 mwindow->theme->mcanvas_w,
2150 mwindow->theme->mcanvas_h -
2152 pane[TOP_LEFT_PANE]->resize_event(
2153 mwindow->theme->mcanvas_x,
2154 mwindow->theme->mcanvas_y,
2155 mwindow->theme->mcanvas_w,
2156 pane[BOTTOM_LEFT_PANE]->y -
2157 mwindow->theme->mcanvas_y -
2158 mwindow->theme->pane_h);
2159 pane[BOTTOM_LEFT_PANE]->create_objects();
2163 pane[TOP_LEFT_PANE]->resize_event(
2164 mwindow->theme->mcanvas_x,
2165 mwindow->theme->mcanvas_y,
2166 mwindow->theme->mcanvas_w,
2167 cursor_y - mwindow->theme->pane_h);
2168 pane[BOTTOM_LEFT_PANE]->resize_event(
2169 pane[BOTTOM_LEFT_PANE]->x,
2171 mwindow->theme->mcanvas_y,
2172 mwindow->theme->mcanvas_w,
2173 mwindow->theme->mcanvas_h -
2180 if(pane[TOP_RIGHT_PANE]) delete pane[TOP_RIGHT_PANE];
2181 if(pane[BOTTOM_RIGHT_PANE]) delete pane[BOTTOM_RIGHT_PANE];
2182 if(pane[BOTTOM_LEFT_PANE]) delete pane[BOTTOM_LEFT_PANE];
2183 pane[TOP_RIGHT_PANE] = 0;
2184 pane[BOTTOM_RIGHT_PANE] = 0;
2185 pane[BOTTOM_LEFT_PANE] = 0;
2186 pane[TOP_LEFT_PANE]->resize_event(
2187 mwindow->theme->mcanvas_x,
2188 mwindow->theme->mcanvas_y,
2189 mwindow->theme->mcanvas_w,
2190 mwindow->theme->mcanvas_h);
2193 update_pane_dividers();
2196 resource_thread->start_draw();
2199 void MWindowGUI::update_pane_dividers()
2202 if(horizontal_panes() || total_panes() == 4)
2204 int x = pane[TOP_RIGHT_PANE]->x - mwindow->theme->pane_w;
2205 int y = mwindow->theme->mcanvas_y;
2206 int h = mwindow->theme->mcanvas_h;
2210 add_subwindow(x_divider = new PaneDivider(
2211 mwindow, x, y, h, 1));
2212 x_divider->create_objects();
2216 x_divider->reposition_window(x, y, h);
2229 if(vertical_panes() || total_panes() == 4)
2231 int x = mwindow->theme->mcanvas_x;
2232 int y = pane[BOTTOM_LEFT_PANE]->y -
2233 mwindow->theme->pane_h;
2234 int w = mwindow->theme->mcanvas_w;
2237 add_subwindow(y_divider = new PaneDivider(
2238 mwindow, x, y, w, 0));
2239 y_divider->create_objects();
2243 y_divider->reposition_window(x, y, w);
2257 void MWindowGUI::draw_samplemovement()
2264 update_scrollbars(1);
2267 void MWindowGUI::draw_trackmovement()
2269 update_scrollbars(0);
2276 void MWindowGUI::update_mixers(Track *track, int v)
2278 for( int i=0; i<TOTAL_PANES; ++i ) {
2279 if( !pane[i] ) continue;
2280 PatchBay *patchbay = pane[i]->patchbay;
2281 if( !patchbay ) continue;
2282 for( int j=0; j<patchbay->patches.total; ++j ) {
2283 PatchGUI *patchgui = patchbay->patches.values[j];
2284 if( !patchgui->mix ) continue;
2285 if( !track || patchgui->track == track ) {
2286 patchgui->mix->update(v>=0 ? v :
2287 mwindow->mixer_track_active(patchgui->track));
2293 void MWindowGUI::stop_transport(const char *lock_msg)
2295 if( !mbuttons->transport->is_stopped() ) {
2296 if( lock_msg ) unlock_window();
2297 mbuttons->transport->handle_transport(STOP, 1, 0, 0);
2298 if( lock_msg ) lock_window(lock_msg);
2302 PaneButton::PaneButton(MWindow *mwindow, int x, int y)
2303 : BC_Button(x, y, mwindow->theme->get_image_set("pane"))
2305 this->mwindow = mwindow;
2308 int PaneButton::cursor_motion_event()
2310 if(get_top_level()->get_button_down() &&
2312 get_status() == BUTTON_DOWNHI &&
2315 // printf("PaneButton::cursor_motion_event %d\n", __LINE__);
2317 if(get_cursor_x() < 0 && !mwindow->gui->dragging_pane)
2319 mwindow->gui->start_x_pane_drag();
2322 if(get_cursor_y() < 0 && !mwindow->gui->dragging_pane)
2324 mwindow->gui->start_y_pane_drag();
2328 mwindow->gui->handle_pane_drag();
2330 int result = BC_Button::cursor_motion_event();
2334 int PaneButton::button_release_event()
2336 if( get_buttonpress() != WHEEL_DOWN && get_buttonpress() != WHEEL_UP )
2337 mwindow->gui->stop_pane_drag();
2338 int result = BC_Button::button_release_event();
2343 FFMpegToggle::FFMpegToggle(MWindow *mwindow, MButtons *mbuttons, int x, int y)
2344 : BC_Toggle(x, y, mwindow->theme->ffmpeg_toggle,
2345 mwindow->preferences->get_file_probe_armed("FFMPEG_Early") > 0 ? 1 : 0)
2347 this->mwindow = mwindow;
2348 this->mbuttons = mbuttons;
2349 set_tooltip(get_value() ? FFMPEG_EARLY_TIP : FFMPEG_LATE_TIP);
2352 FFMpegToggle::~FFMpegToggle()
2356 int FFMpegToggle::handle_event()
2358 int ffmpeg_early_probe = get_value();
2359 set_tooltip(ffmpeg_early_probe ? FFMPEG_EARLY_TIP : FFMPEG_LATE_TIP);
2360 mwindow->preferences->set_file_probe_armed("FFMPEG_Early", ffmpeg_early_probe);
2361 mwindow->preferences->set_file_probe_armed("FFMPEG_Late", !ffmpeg_early_probe);
2363 mwindow->show_warning(&mwindow->preferences->warn_indexes,
2364 _("Changing the base codecs may require rebuilding indexes."));
2369 ProxyToggle::ProxyToggle(MWindow *mwindow, MButtons *mbuttons, int x, int y)
2370 : BC_Toggle(x, y, ( !mwindow->edl->session->proxy_use_scaler ?
2371 mwindow->theme->proxy_p_toggle :
2372 mwindow->theme->proxy_s_toggle ),
2373 mwindow->edl->session->proxy_disabled_scale != 1)
2375 this->mwindow = mwindow;
2376 this->mbuttons = mbuttons;
2377 scaler_images = mwindow->edl->session->proxy_use_scaler;
2378 set_tooltip(mwindow->edl->session->proxy_disabled_scale==1 ?
2379 _("Disable proxy") : _("Enable proxy"));
2382 void ProxyToggle::show()
2384 int use_scaler = mwindow->edl->session->proxy_use_scaler;
2385 if( scaler_images != use_scaler )
2386 set_images(!(scaler_images=use_scaler) ?
2387 mwindow->theme->proxy_p_toggle :
2388 mwindow->theme->proxy_s_toggle );
2394 void ProxyToggle::hide()
2400 ProxyToggle::~ProxyToggle()
2404 int ProxyToggle::handle_event()
2406 int disabled = get_value();
2408 mwindow->disable_proxy();
2410 mwindow->enable_proxy();
2411 set_tooltip(!disabled ? _("Disable proxy") : _("Enable proxy"));
2415 int ProxyToggle::keypress_event()
2417 if( ctrl_down() && !shift_down() && !alt_down() ) {
2418 int key = get_keypress();
2420 int value = get_value() ? 0 : 1;
2422 return handle_event();