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::button_release_event()
1149 if( keyvalue_popup ) {
1150 delete keyvalue_popup; keyvalue_popup = 0;
1156 int MWindowGUI::repeat_event(int64_t duration)
1158 // if(duration == 100)
1159 // mwindow->sync_parameters(CHANGE_ALL);
1161 for(int i = 0; i < TOTAL_PANES; i++)
1163 if(pane[i]) result = pane[i]->cursor->repeat_event(duration);
1169 int MWindowGUI::translation_event()
1171 //printf("MWindowGUI::translation_event 1 %d %d\n", get_x(), get_y());
1172 mwindow->session->mwindow_x = get_x();
1173 mwindow->session->mwindow_y = get_y();
1178 int MWindowGUI::save_defaults(BC_Hash *defaults)
1180 defaults->update("MWINDOWWIDTH", get_w());
1181 defaults->update("MWINDOWHEIGHT", get_h());
1182 mainmenu->save_defaults(defaults);
1183 BC_WindowBase::save_defaults(defaults);
1187 int MWindowGUI::keypress_event()
1189 //printf("MWindowGUI::keypress_event 1 %d\n", get_keypress());
1190 int result = mbuttons->keypress_event();
1191 if( result ) return result;
1193 Track *this_track = 0;
1195 switch(get_keypress()) {
1197 mwindow->toggle_editing_mode();
1202 if( alt_down() ) break;
1203 stop_transport("MWindowGUI::keypress_event 1");
1204 mwindow->nearest_plugin_keyframe(shift_down(),
1205 !ctrl_down() ? PLAY_FORWARD : PLAY_REVERSE);
1209 case '1': case '2': case '3': case '4':
1210 case '5': case '6': case '7': case '8':
1211 if( !alt_down() || shift_down() ) break;
1212 if( !mwindow->select_asset(get_keypress()-'1',1) )
1217 if( !ctrl_down() ) {
1219 stop_transport("MWindowGUI::keypress_event 1");
1220 mwindow->prev_edit_handle(shift_down());
1223 mwindow->move_left();
1229 if( !ctrl_down() && !alt_down() ) {
1230 mwindow->move_left();
1236 if( !ctrl_down() ) {
1238 stop_transport("MWindowGUI::keypress_event 2");
1239 mwindow->next_edit_handle(shift_down());
1242 mwindow->move_right();
1248 if( !ctrl_down() && !alt_down() ) {
1249 mwindow->move_right();
1255 if( ctrl_down() && !alt_down() )
1256 mwindow->expand_y();
1257 else if( !ctrl_down() && alt_down() )
1258 mwindow->expand_autos(0,1,1);
1259 else if( ctrl_down() && alt_down() )
1260 mwindow->expand_autos(1,1,1);
1262 mwindow->expand_sample();
1267 if( ctrl_down() && !alt_down() )
1268 mwindow->zoom_in_y();
1269 else if( !ctrl_down() && alt_down() )
1270 mwindow->shrink_autos(0,1,1);
1271 else if( ctrl_down() && alt_down() )
1272 mwindow->shrink_autos(1,1,1);
1274 mwindow->zoom_in_sample();
1282 mwindow->expand_t();
1288 mwindow->move_down();
1290 mwindow->zoom_in_t();
1296 for( int i=0; i<TOTAL_PANES; ++i ) {
1297 if( !pane[i] ) continue;
1298 if( (this_track = pane[i]->over_track()) != 0 ) break;
1299 if( (this_track = pane[i]->over_patchbay()) != 0 ) break;
1302 if( get_keypress() == TAB ) { // Switch the record button
1304 this_track->record = !this_track->record ? 1 : 0;
1307 int total_selected = mwindow->edl->tracks->total_of(Tracks::RECORD);
1308 // all selected if nothing previously selected or
1309 // if this patch was previously the only one selected and armed
1310 int selected = !total_selected || (total_selected == 1 &&
1311 this_track && this_track->record ) ? 1 : 0;
1312 mwindow->edl->tracks->select_all(Tracks::RECORD, selected);
1313 if( !selected && this_track ) this_track->record = 1;
1316 update(0, 1, 0, 0, 1, 0, 1);
1318 mwindow->cwindow->update(0, 1, 1);
1319 lock_window("MWindowGUI::keypress_event 3");
1336 resend_event(mwindow->cwindow->gui);
1340 // since things under cursor have changed...
1342 cursor_motion_event();
1347 int MWindowGUI::keyboard_listener(BC_WindowBase *wp)
1349 return key_listener(wp->get_keypress());
1352 int MWindowGUI::key_listener(int key)
1357 if( !record->running() )
1360 record->record_gui->interrupt_thread->start(0);
1367 channel_info->toggle_scan();
1371 if( !remote_control->deactivate() )
1372 remote_control->activate();
1382 void MWindowGUI::use_android_remote(int on)
1385 delete android_control;
1386 android_control = 0;
1389 if( android_control ) return;
1390 android_control = new AndroidControl(this);
1393 int MWindowGUI::close_event()
1399 void MWindowGUI::stop_drawing()
1401 resource_thread->stop_draw(1);
1404 int MWindowGUI::menu_w()
1406 return mainmenu->get_w();
1409 int MWindowGUI::menu_h()
1411 return mainmenu->get_h();
1414 void MWindowGUI::start_x_pane_drag()
1418 x_pane_drag = new BC_Popup(this,
1419 get_abs_cursor_x(0) - mwindow->theme->pane_w,
1420 BC_DisplayInfo::get_top_border() +
1422 mwindow->theme->mcanvas_y,
1423 mwindow->theme->pane_w,
1424 mwindow->theme->mcanvas_h,
1425 mwindow->theme->drag_pane_color);
1426 x_pane_drag->draw_3segmentv(0,
1428 x_pane_drag->get_h(),
1429 mwindow->theme->get_image_set("xpane")[BUTTON_DOWNHI]);
1430 x_pane_drag->flash(1);
1435 void MWindowGUI::start_y_pane_drag()
1439 //printf("MWindowGUI::start_y_pane_drag %d %d %d\n", __LINE__, get_x(), get_y());
1440 y_pane_drag = new BC_Popup(this,
1441 BC_DisplayInfo::get_left_border() +
1443 mwindow->theme->mcanvas_x,
1444 get_abs_cursor_y(0) - mwindow->theme->pane_h,
1445 mwindow->theme->mcanvas_w,
1446 mwindow->theme->pane_h,
1447 mwindow->theme->drag_pane_color);
1448 y_pane_drag->draw_3segmenth(0,
1450 y_pane_drag->get_w(),
1451 mwindow->theme->get_image_set("ypane")[BUTTON_DOWNHI]);
1452 y_pane_drag->flash(1);
1457 void MWindowGUI::handle_pane_drag()
1463 x_pane_drag->reposition_window(
1464 get_abs_cursor_x(0) - mwindow->theme->pane_w,
1465 x_pane_drag->get_y());
1470 y_pane_drag->reposition_window(
1471 y_pane_drag->get_x(),
1472 get_abs_cursor_y(0) - mwindow->theme->pane_h);
1478 void MWindowGUI::create_x_pane(int cursor_x)
1480 if(total_panes() == 1)
1482 // create a horizontal pane
1483 // do this 1st so the resize_event knows there are 2 panes
1484 mwindow->edl->local_session->view_start[TOP_RIGHT_PANE] =
1485 mwindow->edl->local_session->view_start[TOP_LEFT_PANE] +
1487 mwindow->theme->patchbay_w;
1488 pane[TOP_RIGHT_PANE] = new TimelinePane(mwindow,
1490 mwindow->theme->mcanvas_x +
1492 mwindow->theme->mcanvas_y,
1493 mwindow->theme->mcanvas_x +
1494 mwindow->theme->mcanvas_w -
1496 mwindow->theme->mcanvas_h);
1497 pane[TOP_LEFT_PANE]->resize_event(
1498 mwindow->theme->mcanvas_x,
1499 mwindow->theme->mcanvas_y,
1500 cursor_x - mwindow->theme->pane_w,
1501 mwindow->theme->mcanvas_h);
1502 pane[TOP_RIGHT_PANE]->create_objects();
1505 if(vertical_panes())
1507 // create 2 horizontal panes
1508 mwindow->edl->local_session->track_start[TOP_RIGHT_PANE] =
1509 mwindow->edl->local_session->track_start[TOP_LEFT_PANE];
1510 mwindow->edl->local_session->track_start[BOTTOM_RIGHT_PANE] =
1511 mwindow->edl->local_session->track_start[BOTTOM_LEFT_PANE];
1512 mwindow->edl->local_session->view_start[TOP_RIGHT_PANE] =
1513 mwindow->edl->local_session->view_start[BOTTOM_RIGHT_PANE] =
1514 mwindow->edl->local_session->view_start[TOP_LEFT_PANE] +
1516 mwindow->theme->patchbay_w;
1517 pane[TOP_RIGHT_PANE] = new TimelinePane(mwindow,
1519 mwindow->theme->mcanvas_x +
1521 pane[TOP_LEFT_PANE]->y,
1522 mwindow->theme->mcanvas_x +
1523 mwindow->theme->mcanvas_w -
1525 pane[TOP_LEFT_PANE]->h);
1526 pane[BOTTOM_RIGHT_PANE] = new TimelinePane(mwindow,
1528 mwindow->theme->mcanvas_x +
1530 pane[BOTTOM_LEFT_PANE]->y,
1531 mwindow->theme->mcanvas_x +
1532 mwindow->theme->mcanvas_w -
1534 pane[BOTTOM_LEFT_PANE]->h);
1535 pane[TOP_LEFT_PANE]->resize_event(
1536 pane[TOP_LEFT_PANE]->x,
1537 pane[TOP_LEFT_PANE]->y,
1538 cursor_x - mwindow->theme->pane_w,
1539 pane[TOP_LEFT_PANE]->h);
1540 pane[BOTTOM_LEFT_PANE]->resize_event(
1541 pane[BOTTOM_LEFT_PANE]->x,
1542 pane[BOTTOM_LEFT_PANE]->y,
1543 cursor_x - mwindow->theme->pane_w,
1544 pane[BOTTOM_LEFT_PANE]->h);
1545 pane[TOP_RIGHT_PANE]->create_objects();
1546 pane[BOTTOM_RIGHT_PANE]->create_objects();
1549 if(horizontal_panes())
1551 // resize a horizontal pane
1552 mwindow->edl->local_session->view_start[TOP_RIGHT_PANE] +=
1554 pane[TOP_RIGHT_PANE]->x;
1555 if(mwindow->edl->local_session->view_start[TOP_RIGHT_PANE] < 0)
1556 mwindow->edl->local_session->view_start[TOP_RIGHT_PANE] = 0;
1557 pane[TOP_LEFT_PANE]->resize_event(
1558 mwindow->theme->mcanvas_x,
1559 mwindow->theme->mcanvas_y,
1560 cursor_x - mwindow->theme->pane_w,
1561 mwindow->theme->mcanvas_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 mwindow->theme->mcanvas_h);
1573 // resize 2 horizontal panes
1574 mwindow->edl->local_session->view_start[TOP_RIGHT_PANE] +=
1576 pane[TOP_RIGHT_PANE]->x;
1577 if(mwindow->edl->local_session->view_start[TOP_RIGHT_PANE] < 0)
1578 mwindow->edl->local_session->view_start[TOP_RIGHT_PANE] = 0;
1579 mwindow->edl->local_session->view_start[BOTTOM_RIGHT_PANE] =
1580 mwindow->edl->local_session->view_start[TOP_RIGHT_PANE];
1582 pane[TOP_LEFT_PANE]->resize_event(
1583 mwindow->theme->mcanvas_x,
1584 pane[TOP_LEFT_PANE]->y,
1585 cursor_x - mwindow->theme->pane_w,
1586 pane[TOP_LEFT_PANE]->h);
1587 pane[TOP_RIGHT_PANE]->resize_event(
1588 mwindow->theme->mcanvas_x +
1590 pane[TOP_RIGHT_PANE]->y,
1591 mwindow->theme->mcanvas_x +
1592 mwindow->theme->mcanvas_w -
1594 pane[TOP_RIGHT_PANE]->h);
1595 pane[BOTTOM_LEFT_PANE]->resize_event(
1596 mwindow->theme->mcanvas_x,
1597 pane[BOTTOM_LEFT_PANE]->y,
1598 cursor_x - mwindow->theme->pane_w,
1599 pane[BOTTOM_LEFT_PANE]->h);
1600 pane[BOTTOM_RIGHT_PANE]->resize_event(
1601 mwindow->theme->mcanvas_x +
1603 pane[BOTTOM_RIGHT_PANE]->y,
1604 mwindow->theme->mcanvas_x +
1605 mwindow->theme->mcanvas_w -
1607 pane[BOTTOM_RIGHT_PANE]->h);
1613 void MWindowGUI::delete_x_pane(int cursor_x)
1615 // give left panes coordinates of right pane
1616 if(cursor_x < mwindow->theme->patchbay_w + PANE_DRAG_MARGIN &&
1617 pane[TOP_RIGHT_PANE])
1619 mwindow->edl->local_session->view_start[TOP_LEFT_PANE] =
1620 mwindow->edl->local_session->view_start[TOP_RIGHT_PANE] -
1621 pane[TOP_RIGHT_PANE]->x + mwindow->theme->patchbay_w;
1622 if(mwindow->edl->local_session->view_start[TOP_LEFT_PANE] < 0)
1623 mwindow->edl->local_session->view_start[TOP_LEFT_PANE] = 0;
1624 mwindow->edl->local_session->view_start[BOTTOM_LEFT_PANE] =
1625 mwindow->edl->local_session->view_start[TOP_LEFT_PANE];
1628 switch(total_panes())
1631 if(pane[TOP_LEFT_PANE] && pane[TOP_RIGHT_PANE])
1633 // delete right pane
1634 delete pane[TOP_RIGHT_PANE];
1635 pane[TOP_RIGHT_PANE] = 0;
1636 pane[TOP_LEFT_PANE]->resize_event(
1637 mwindow->theme->mcanvas_x,
1638 mwindow->theme->mcanvas_y,
1639 mwindow->theme->mcanvas_w,
1640 mwindow->theme->mcanvas_h);
1646 // delete right panes
1647 delete pane[TOP_RIGHT_PANE];
1648 pane[TOP_RIGHT_PANE] = 0;
1649 delete pane[BOTTOM_RIGHT_PANE];
1650 pane[BOTTOM_RIGHT_PANE] = 0;
1651 pane[TOP_LEFT_PANE]->resize_event(
1652 mwindow->theme->mcanvas_x,
1653 pane[TOP_LEFT_PANE]->y,
1654 mwindow->theme->mcanvas_w,
1655 pane[TOP_LEFT_PANE]->h);
1656 pane[BOTTOM_LEFT_PANE]->resize_event(
1657 mwindow->theme->mcanvas_x,
1658 pane[BOTTOM_LEFT_PANE]->y,
1659 mwindow->theme->mcanvas_w,
1660 pane[BOTTOM_LEFT_PANE]->h);
1665 void MWindowGUI::create_y_pane(int cursor_y)
1667 if(total_panes() == 1)
1669 mwindow->edl->local_session->view_start[BOTTOM_LEFT_PANE] =
1670 mwindow->edl->local_session->view_start[TOP_LEFT_PANE];
1671 mwindow->edl->local_session->track_start[BOTTOM_LEFT_PANE] =
1672 mwindow->edl->local_session->track_start[TOP_LEFT_PANE] +
1674 mwindow->theme->mtimebar_h;
1675 // do this 1st so the resize_event knows there are 2 panes
1676 pane[BOTTOM_LEFT_PANE] = new TimelinePane(mwindow,
1678 mwindow->theme->mcanvas_x,
1679 mwindow->theme->mcanvas_y +
1681 mwindow->theme->mcanvas_w,
1682 mwindow->theme->mcanvas_h -
1684 pane[TOP_LEFT_PANE]->resize_event(
1685 mwindow->theme->mcanvas_x,
1686 mwindow->theme->mcanvas_y,
1687 mwindow->theme->mcanvas_w,
1688 pane[BOTTOM_LEFT_PANE]->y -
1689 mwindow->theme->mcanvas_y -
1690 mwindow->theme->pane_h);
1691 pane[BOTTOM_LEFT_PANE]->create_objects();
1694 if(horizontal_panes())
1697 mwindow->edl->local_session->view_start[BOTTOM_LEFT_PANE] =
1698 mwindow->edl->local_session->view_start[TOP_LEFT_PANE];
1699 mwindow->edl->local_session->view_start[BOTTOM_RIGHT_PANE] =
1700 mwindow->edl->local_session->view_start[TOP_RIGHT_PANE];
1701 mwindow->edl->local_session->track_start[BOTTOM_LEFT_PANE] =
1702 mwindow->edl->local_session->track_start[BOTTOM_RIGHT_PANE] =
1703 mwindow->edl->local_session->track_start[TOP_LEFT_PANE] +
1705 mwindow->theme->mtimebar_h;
1707 pane[BOTTOM_LEFT_PANE] = new TimelinePane(mwindow,
1709 pane[TOP_LEFT_PANE]->x,
1710 mwindow->theme->mcanvas_y +
1712 pane[TOP_LEFT_PANE]->w,
1713 mwindow->theme->mcanvas_h -
1715 pane[BOTTOM_RIGHT_PANE] = new TimelinePane(mwindow,
1717 pane[TOP_RIGHT_PANE]->x,
1718 mwindow->theme->mcanvas_y +
1720 pane[TOP_RIGHT_PANE]->w,
1721 mwindow->theme->mcanvas_h -
1724 pane[TOP_LEFT_PANE]->resize_event(
1725 pane[TOP_LEFT_PANE]->x,
1726 pane[TOP_LEFT_PANE]->y,
1727 pane[TOP_LEFT_PANE]->w,
1728 pane[BOTTOM_LEFT_PANE]->y -
1729 mwindow->theme->mcanvas_y -
1730 mwindow->theme->pane_h);
1731 pane[TOP_RIGHT_PANE]->resize_event(
1732 pane[TOP_RIGHT_PANE]->x,
1733 pane[TOP_RIGHT_PANE]->y,
1734 pane[TOP_RIGHT_PANE]->w,
1735 pane[BOTTOM_RIGHT_PANE]->y -
1736 mwindow->theme->mcanvas_y -
1737 mwindow->theme->pane_h);
1739 pane[BOTTOM_LEFT_PANE]->create_objects();
1740 pane[BOTTOM_RIGHT_PANE]->create_objects();
1743 if(vertical_panes())
1746 mwindow->edl->local_session->track_start[BOTTOM_LEFT_PANE] +=
1748 (pane[BOTTOM_LEFT_PANE]->y - mwindow->theme->mcanvas_y);
1749 if(mwindow->edl->local_session->track_start[BOTTOM_LEFT_PANE] < 0)
1750 mwindow->edl->local_session->track_start[BOTTOM_LEFT_PANE] = 0;
1751 pane[TOP_LEFT_PANE]->resize_event(
1752 mwindow->theme->mcanvas_x,
1753 mwindow->theme->mcanvas_y,
1754 mwindow->theme->mcanvas_w,
1755 cursor_y - mwindow->theme->pane_h);
1756 pane[BOTTOM_LEFT_PANE]->resize_event(
1757 pane[BOTTOM_LEFT_PANE]->x,
1759 mwindow->theme->mcanvas_y,
1760 mwindow->theme->mcanvas_w,
1761 mwindow->theme->mcanvas_h -
1767 mwindow->edl->local_session->track_start[BOTTOM_LEFT_PANE] +=
1769 (pane[BOTTOM_LEFT_PANE]->y - mwindow->theme->mcanvas_y);
1770 if(mwindow->edl->local_session->track_start[BOTTOM_LEFT_PANE] < 0)
1771 mwindow->edl->local_session->track_start[BOTTOM_LEFT_PANE] = 0;
1772 mwindow->edl->local_session->track_start[BOTTOM_RIGHT_PANE] =
1773 mwindow->edl->local_session->track_start[BOTTOM_LEFT_PANE];
1774 pane[TOP_LEFT_PANE]->resize_event(
1775 pane[TOP_LEFT_PANE]->x,
1776 pane[TOP_LEFT_PANE]->y,
1777 pane[TOP_LEFT_PANE]->w,
1778 cursor_y - mwindow->theme->pane_h);
1779 pane[BOTTOM_LEFT_PANE]->resize_event(
1780 pane[BOTTOM_LEFT_PANE]->x,
1782 mwindow->theme->mcanvas_y,
1783 pane[BOTTOM_LEFT_PANE]->w,
1784 mwindow->theme->mcanvas_h -
1786 pane[TOP_RIGHT_PANE]->resize_event(
1787 pane[TOP_RIGHT_PANE]->x,
1788 pane[TOP_RIGHT_PANE]->y,
1789 pane[TOP_RIGHT_PANE]->w,
1790 cursor_y - mwindow->theme->pane_h);
1791 pane[BOTTOM_RIGHT_PANE]->resize_event(
1792 pane[BOTTOM_RIGHT_PANE]->x,
1794 mwindow->theme->mcanvas_y,
1795 pane[BOTTOM_RIGHT_PANE]->w,
1796 mwindow->theme->mcanvas_h -
1801 void MWindowGUI::delete_y_pane(int cursor_y)
1803 if(cursor_y < mwindow->theme->mtimebar_h +
1805 pane[BOTTOM_LEFT_PANE])
1807 // give top pane coordinates of bottom pane
1808 mwindow->edl->local_session->track_start[TOP_LEFT_PANE] =
1809 mwindow->edl->local_session->track_start[BOTTOM_LEFT_PANE] -
1810 pane[BOTTOM_LEFT_PANE]->y;
1811 if(mwindow->edl->local_session->track_start[TOP_LEFT_PANE] < 0)
1812 mwindow->edl->local_session->track_start[TOP_LEFT_PANE] = 0;
1813 mwindow->edl->local_session->track_start[TOP_RIGHT_PANE] =
1814 mwindow->edl->local_session->track_start[TOP_LEFT_PANE];
1818 switch(total_panes())
1821 delete pane[BOTTOM_LEFT_PANE];
1822 pane[BOTTOM_LEFT_PANE] = 0;
1823 pane[TOP_LEFT_PANE]->resize_event(
1824 mwindow->theme->mcanvas_x,
1825 mwindow->theme->mcanvas_y,
1826 mwindow->theme->mcanvas_w,
1827 mwindow->theme->mcanvas_h);
1831 // delete bottom 2 panes
1833 delete pane[BOTTOM_LEFT_PANE];
1834 pane[BOTTOM_LEFT_PANE] = 0;
1835 delete pane[BOTTOM_RIGHT_PANE];
1836 pane[BOTTOM_RIGHT_PANE] = 0;
1837 pane[TOP_LEFT_PANE]->resize_event(
1838 pane[TOP_LEFT_PANE]->x,
1839 mwindow->theme->mcanvas_y,
1840 pane[TOP_LEFT_PANE]->w,
1841 mwindow->theme->mcanvas_h);
1842 pane[TOP_RIGHT_PANE]->resize_event(
1843 pane[TOP_RIGHT_PANE]->x,
1844 mwindow->theme->mcanvas_y,
1845 pane[TOP_RIGHT_PANE]->w,
1846 mwindow->theme->mcanvas_h);
1851 void MWindowGUI::stop_pane_drag()
1854 resource_thread->stop_draw(1);
1858 // cursor position relative to canvas
1859 int cursor_x = x_pane_drag->get_x() -
1861 BC_DisplayInfo::get_left_border() -
1862 mwindow->theme->mcanvas_x +
1863 mwindow->theme->pane_w;
1868 if(cursor_x >= mwindow->theme->patchbay_w + PANE_DRAG_MARGIN &&
1869 cursor_x < mwindow->theme->mcanvas_w -
1870 BC_ScrollBar::get_span(SCROLL_VERT) -
1873 create_x_pane(cursor_x);
1874 mwindow->edl->local_session->x_pane = cursor_x;
1879 delete_x_pane(cursor_x);
1880 mwindow->edl->local_session->x_pane = -1;
1888 // cursor position relative to canvas
1889 int cursor_y = y_pane_drag->get_y() -
1891 BC_DisplayInfo::get_top_border() -
1892 mwindow->theme->mcanvas_y +
1893 mwindow->theme->pane_h;
1899 if(cursor_y >= mwindow->theme->mtimebar_h +
1901 cursor_y < mwindow->theme->mcanvas_h -
1902 BC_ScrollBar::get_span(SCROLL_HORIZ) -
1905 create_y_pane(cursor_y);
1906 mwindow->edl->local_session->y_pane = cursor_y;
1910 delete_y_pane(cursor_y);
1911 mwindow->edl->local_session->y_pane = -1;
1915 update_pane_dividers();
1917 // required to get new widgets to appear
1919 resource_thread->start_draw();
1922 // create panes from EDL
1923 void MWindowGUI::load_panes()
1925 int need_x_panes = 0;
1926 int need_y_panes = 0;
1927 // use names from create functions
1928 int cursor_x = mwindow->edl->local_session->x_pane;
1929 int cursor_y = mwindow->edl->local_session->y_pane;
1931 resource_thread->stop_draw(1);
1933 mwindow->theme->patchbay_w + PANE_DRAG_MARGIN &&
1935 mwindow->theme->mcanvas_w -
1936 BC_ScrollBar::get_span(SCROLL_VERT) -
1943 mwindow->theme->mtimebar_h + PANE_DRAG_MARGIN &&
1945 mwindow->theme->mcanvas_h -
1946 BC_ScrollBar::get_span(SCROLL_HORIZ) -
1952 //printf("MWindowGUI::load_panes %d %d %d\n", __LINE__, need_x_panes, need_y_panes);
1960 if(total_panes() == 1)
1963 //printf("MWindowGUI::load_panes %d\n", __LINE__);
1964 pane[TOP_RIGHT_PANE] = new TimelinePane(mwindow,
1966 mwindow->theme->mcanvas_x +
1968 mwindow->theme->mcanvas_y,
1969 mwindow->theme->mcanvas_x +
1970 mwindow->theme->mcanvas_w -
1972 cursor_y - mwindow->theme->pane_h);
1973 pane[BOTTOM_LEFT_PANE] = new TimelinePane(mwindow,
1975 mwindow->theme->mcanvas_x,
1976 mwindow->theme->mcanvas_y +
1978 cursor_x - mwindow->theme->pane_w,
1979 mwindow->theme->mcanvas_h -
1981 pane[BOTTOM_RIGHT_PANE] = new TimelinePane(mwindow,
1983 pane[TOP_RIGHT_PANE]->x,
1984 mwindow->theme->mcanvas_y +
1986 pane[TOP_RIGHT_PANE]->w,
1987 mwindow->theme->mcanvas_h -
1989 pane[TOP_LEFT_PANE]->resize_event(
1990 pane[TOP_LEFT_PANE]->x,
1991 pane[TOP_LEFT_PANE]->y,
1992 cursor_x - mwindow->theme->pane_w,
1993 cursor_y - mwindow->theme->pane_h);
1994 pane[TOP_RIGHT_PANE]->create_objects();
1995 pane[BOTTOM_LEFT_PANE]->create_objects();
1996 pane[BOTTOM_RIGHT_PANE]->create_objects();
1999 if(horizontal_panes())
2001 // create vertical panes
2002 //printf("MWindowGUI::load_panes %d\n", __LINE__);
2003 pane[BOTTOM_LEFT_PANE] = new TimelinePane(mwindow,
2005 mwindow->theme->mcanvas_x,
2006 mwindow->theme->mcanvas_y +
2008 cursor_x - mwindow->theme->pane_w,
2009 mwindow->theme->mcanvas_h -
2011 pane[BOTTOM_RIGHT_PANE] = new TimelinePane(mwindow,
2013 pane[TOP_RIGHT_PANE]->x,
2014 mwindow->theme->mcanvas_y +
2016 pane[TOP_RIGHT_PANE]->w,
2017 mwindow->theme->mcanvas_h -
2019 pane[TOP_LEFT_PANE]->resize_event(
2020 pane[TOP_LEFT_PANE]->x,
2021 pane[TOP_LEFT_PANE]->y,
2022 cursor_x - mwindow->theme->pane_w,
2023 cursor_y - mwindow->theme->pane_h);
2024 pane[TOP_RIGHT_PANE]->resize_event(
2025 mwindow->theme->mcanvas_x +
2027 mwindow->theme->mcanvas_y,
2028 mwindow->theme->mcanvas_x +
2029 mwindow->theme->mcanvas_w -
2031 cursor_y - mwindow->theme->pane_h);
2032 pane[BOTTOM_LEFT_PANE]->create_objects();
2033 pane[BOTTOM_RIGHT_PANE]->create_objects();
2036 if(vertical_panes())
2038 // create horizontal panes
2039 //printf("MWindowGUI::load_panes %d\n", __LINE__);
2040 pane[TOP_RIGHT_PANE] = new TimelinePane(mwindow,
2042 mwindow->theme->mcanvas_x +
2044 mwindow->theme->mcanvas_y,
2045 mwindow->theme->mcanvas_x +
2046 mwindow->theme->mcanvas_w -
2048 cursor_y - mwindow->theme->pane_h);
2049 pane[BOTTOM_RIGHT_PANE] = new TimelinePane(mwindow,
2051 pane[TOP_RIGHT_PANE]->x,
2052 mwindow->theme->mcanvas_y +
2054 pane[TOP_RIGHT_PANE]->w,
2055 mwindow->theme->mcanvas_h -
2057 pane[TOP_LEFT_PANE]->resize_event(
2058 pane[TOP_LEFT_PANE]->x,
2059 pane[TOP_LEFT_PANE]->y,
2060 cursor_x - mwindow->theme->pane_w,
2061 cursor_y - mwindow->theme->pane_h);
2062 pane[BOTTOM_LEFT_PANE]->resize_event(
2063 pane[TOP_LEFT_PANE]->x,
2064 mwindow->theme->mcanvas_y +
2066 mwindow->theme->mcanvas_x +
2067 mwindow->theme->mcanvas_w -
2068 cursor_x - mwindow->theme->pane_w,
2069 mwindow->theme->mcanvas_h -
2071 pane[TOP_RIGHT_PANE]->create_objects();
2072 pane[BOTTOM_RIGHT_PANE]->create_objects();
2079 //printf("MWindowGUI::load_panes %d\n", __LINE__);
2080 pane[TOP_LEFT_PANE]->resize_event(
2081 pane[TOP_LEFT_PANE]->x,
2082 pane[TOP_LEFT_PANE]->y,
2083 cursor_x - mwindow->theme->pane_w,
2084 cursor_y - mwindow->theme->pane_h);
2085 pane[TOP_RIGHT_PANE]->resize_event(
2086 mwindow->theme->mcanvas_x +
2088 mwindow->theme->mcanvas_y,
2089 mwindow->theme->mcanvas_x +
2090 mwindow->theme->mcanvas_w -
2092 cursor_y - mwindow->theme->pane_h);
2093 pane[BOTTOM_LEFT_PANE]->resize_event(
2094 pane[TOP_LEFT_PANE]->x,
2095 mwindow->theme->mcanvas_y +
2097 mwindow->theme->mcanvas_x +
2098 mwindow->theme->mcanvas_w -
2099 cursor_x - mwindow->theme->pane_w,
2100 mwindow->theme->mcanvas_h -
2102 pane[BOTTOM_RIGHT_PANE]->resize_event(
2103 pane[TOP_RIGHT_PANE]->x,
2104 mwindow->theme->mcanvas_y +
2106 pane[TOP_RIGHT_PANE]->w,
2107 mwindow->theme->mcanvas_h -
2116 if(pane[BOTTOM_LEFT_PANE]) delete pane[BOTTOM_LEFT_PANE];
2117 if(pane[BOTTOM_RIGHT_PANE]) delete pane[BOTTOM_RIGHT_PANE];
2118 pane[BOTTOM_LEFT_PANE] = 0;
2119 pane[BOTTOM_RIGHT_PANE] = 0;
2121 if(!pane[TOP_RIGHT_PANE])
2123 pane[TOP_RIGHT_PANE] = new TimelinePane(mwindow,
2125 mwindow->theme->mcanvas_x +
2127 mwindow->theme->mcanvas_y,
2128 mwindow->theme->mcanvas_x +
2129 mwindow->theme->mcanvas_w -
2131 mwindow->theme->mcanvas_h);
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]->create_objects();
2141 pane[TOP_LEFT_PANE]->resize_event(
2142 mwindow->theme->mcanvas_x,
2143 mwindow->theme->mcanvas_y,
2144 cursor_x - mwindow->theme->pane_w,
2145 mwindow->theme->mcanvas_h);
2146 pane[TOP_RIGHT_PANE]->resize_event(
2147 mwindow->theme->mcanvas_x +
2149 pane[TOP_RIGHT_PANE]->y,
2150 mwindow->theme->mcanvas_x +
2151 mwindow->theme->mcanvas_w -
2153 mwindow->theme->mcanvas_h);
2161 if(pane[TOP_RIGHT_PANE]) delete pane[TOP_RIGHT_PANE];
2162 if(pane[BOTTOM_RIGHT_PANE]) delete pane[BOTTOM_RIGHT_PANE];
2163 pane[TOP_RIGHT_PANE] = 0;
2164 pane[BOTTOM_RIGHT_PANE] = 0;
2166 if(!pane[BOTTOM_LEFT_PANE])
2168 //printf("MWindowGUI::load_panes %d\n", __LINE__);
2169 pane[BOTTOM_LEFT_PANE] = new TimelinePane(mwindow,
2171 mwindow->theme->mcanvas_x,
2172 mwindow->theme->mcanvas_y +
2174 mwindow->theme->mcanvas_w,
2175 mwindow->theme->mcanvas_h -
2177 pane[TOP_LEFT_PANE]->resize_event(
2178 mwindow->theme->mcanvas_x,
2179 mwindow->theme->mcanvas_y,
2180 mwindow->theme->mcanvas_w,
2181 pane[BOTTOM_LEFT_PANE]->y -
2182 mwindow->theme->mcanvas_y -
2183 mwindow->theme->pane_h);
2184 pane[BOTTOM_LEFT_PANE]->create_objects();
2188 pane[TOP_LEFT_PANE]->resize_event(
2189 mwindow->theme->mcanvas_x,
2190 mwindow->theme->mcanvas_y,
2191 mwindow->theme->mcanvas_w,
2192 cursor_y - mwindow->theme->pane_h);
2193 pane[BOTTOM_LEFT_PANE]->resize_event(
2194 pane[BOTTOM_LEFT_PANE]->x,
2196 mwindow->theme->mcanvas_y,
2197 mwindow->theme->mcanvas_w,
2198 mwindow->theme->mcanvas_h -
2205 if(pane[TOP_RIGHT_PANE]) delete pane[TOP_RIGHT_PANE];
2206 if(pane[BOTTOM_RIGHT_PANE]) delete pane[BOTTOM_RIGHT_PANE];
2207 if(pane[BOTTOM_LEFT_PANE]) delete pane[BOTTOM_LEFT_PANE];
2208 pane[TOP_RIGHT_PANE] = 0;
2209 pane[BOTTOM_RIGHT_PANE] = 0;
2210 pane[BOTTOM_LEFT_PANE] = 0;
2211 pane[TOP_LEFT_PANE]->resize_event(
2212 mwindow->theme->mcanvas_x,
2213 mwindow->theme->mcanvas_y,
2214 mwindow->theme->mcanvas_w,
2215 mwindow->theme->mcanvas_h);
2218 update_pane_dividers();
2221 resource_thread->start_draw();
2224 void MWindowGUI::update_pane_dividers()
2227 if(horizontal_panes() || total_panes() == 4)
2229 int x = pane[TOP_RIGHT_PANE]->x - mwindow->theme->pane_w;
2230 int y = mwindow->theme->mcanvas_y;
2231 int h = mwindow->theme->mcanvas_h;
2235 add_subwindow(x_divider = new PaneDivider(
2236 mwindow, x, y, h, 1));
2237 x_divider->create_objects();
2241 x_divider->reposition_window(x, y, h);
2254 if(vertical_panes() || total_panes() == 4)
2256 int x = mwindow->theme->mcanvas_x;
2257 int y = pane[BOTTOM_LEFT_PANE]->y -
2258 mwindow->theme->pane_h;
2259 int w = mwindow->theme->mcanvas_w;
2262 add_subwindow(y_divider = new PaneDivider(
2263 mwindow, x, y, w, 0));
2264 y_divider->create_objects();
2268 y_divider->reposition_window(x, y, w);
2282 void MWindowGUI::draw_samplemovement()
2289 update_scrollbars(1);
2292 void MWindowGUI::draw_trackmovement()
2294 update_scrollbars(0);
2301 void MWindowGUI::update_mixers(Track *track, int v)
2303 for( int i=0; i<TOTAL_PANES; ++i ) {
2304 if( !pane[i] ) continue;
2305 PatchBay *patchbay = pane[i]->patchbay;
2306 if( !patchbay ) continue;
2307 for( int j=0; j<patchbay->patches.total; ++j ) {
2308 PatchGUI *patchgui = patchbay->patches.values[j];
2309 if( !patchgui->mix ) continue;
2310 if( !track || patchgui->track == track ) {
2311 patchgui->mix->update(v>=0 ? v :
2312 mwindow->mixer_track_active(patchgui->track));
2318 void MWindowGUI::stop_transport(const char *lock_msg)
2320 if( !mbuttons->transport->is_stopped() ) {
2321 if( lock_msg ) unlock_window();
2322 mbuttons->transport->handle_transport(STOP, 1, 0, 0);
2323 if( lock_msg ) lock_window(lock_msg);
2327 PaneButton::PaneButton(MWindow *mwindow, int x, int y)
2328 : BC_Button(x, y, mwindow->theme->get_image_set("pane"))
2330 this->mwindow = mwindow;
2333 int PaneButton::cursor_motion_event()
2335 if(get_top_level()->get_button_down() &&
2337 get_status() == BUTTON_DOWNHI &&
2340 // printf("PaneButton::cursor_motion_event %d\n", __LINE__);
2342 if(get_cursor_x() < 0 && !mwindow->gui->dragging_pane)
2344 mwindow->gui->start_x_pane_drag();
2347 if(get_cursor_y() < 0 && !mwindow->gui->dragging_pane)
2349 mwindow->gui->start_y_pane_drag();
2353 mwindow->gui->handle_pane_drag();
2355 int result = BC_Button::cursor_motion_event();
2359 int PaneButton::button_release_event()
2361 if( get_buttonpress() != WHEEL_DOWN && get_buttonpress() != WHEEL_UP )
2362 mwindow->gui->stop_pane_drag();
2363 int result = BC_Button::button_release_event();
2368 FFMpegToggle::FFMpegToggle(MWindow *mwindow, MButtons *mbuttons, int x, int y)
2369 : BC_Toggle(x, y, mwindow->theme->ffmpeg_toggle,
2370 mwindow->preferences->get_file_probe_armed("FFMPEG_Early") > 0 ? 1 : 0)
2372 this->mwindow = mwindow;
2373 this->mbuttons = mbuttons;
2374 set_tooltip(get_value() ? FFMPEG_EARLY_TIP : FFMPEG_LATE_TIP);
2377 FFMpegToggle::~FFMpegToggle()
2381 int FFMpegToggle::handle_event()
2383 int ffmpeg_early_probe = get_value();
2384 set_tooltip(ffmpeg_early_probe ? FFMPEG_EARLY_TIP : FFMPEG_LATE_TIP);
2385 mwindow->preferences->set_file_probe_armed("FFMPEG_Early", ffmpeg_early_probe);
2386 mwindow->preferences->set_file_probe_armed("FFMPEG_Late", !ffmpeg_early_probe);
2388 mwindow->show_warning(&mwindow->preferences->warn_indexes,
2389 _("Changing the base codecs may require rebuilding indexes."));
2394 ProxyToggle::ProxyToggle(MWindow *mwindow, MButtons *mbuttons, int x, int y)
2395 : BC_Toggle(x, y, ( !mwindow->edl->session->proxy_use_scaler ?
2396 mwindow->theme->proxy_p_toggle :
2397 mwindow->theme->proxy_s_toggle ),
2398 mwindow->edl->session->proxy_disabled_scale != 1)
2400 this->mwindow = mwindow;
2401 this->mbuttons = mbuttons;
2402 scaler_images = mwindow->edl->session->proxy_use_scaler;
2403 set_tooltip(mwindow->edl->session->proxy_disabled_scale==1 ?
2404 _("Disable proxy") : _("Enable proxy"));
2407 void ProxyToggle::show()
2409 int use_scaler = mwindow->edl->session->proxy_use_scaler;
2410 if( scaler_images != use_scaler )
2411 set_images(!(scaler_images=use_scaler) ?
2412 mwindow->theme->proxy_p_toggle :
2413 mwindow->theme->proxy_s_toggle );
2419 void ProxyToggle::hide()
2425 ProxyToggle::~ProxyToggle()
2429 int ProxyToggle::handle_event()
2431 int disabled = get_value();
2433 mwindow->disable_proxy();
2435 mwindow->enable_proxy();
2436 set_tooltip(!disabled ? _("Disable proxy") : _("Enable proxy"));
2440 int ProxyToggle::keypress_event()
2442 if( ctrl_down() && !shift_down() && !alt_down() ) {
2443 int key = get_keypress();
2445 int value = get_value() ? 0 : 1;
2447 return handle_event();