4 * Copyright (C) 1997-2014 Adam Williams <broadcast at earthling dot net>
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 #include "androidcontrol.h"
23 #include "awindowgui.h"
25 #include "bcdisplayinfo.h"
27 #include "bcsignals.h"
29 #include "cwindowgui.h"
31 #include "channelinfo.h"
34 #include "editpopup.h"
37 #include "edlsession.h"
38 #include "filesystem.h"
39 #include "keyframepopup.h"
42 #include "localsession.h"
43 #include "mainclock.h"
44 #include "maincursor.h"
46 #include "mainsession.h"
50 #include "mwindowgui.h"
52 #include "panedividers.h"
55 #include "pluginpopup.h"
56 #include "pluginset.h"
57 #include "preferences.h"
59 #include "recordgui.h"
60 #include "renderengine.h"
61 #include "resourcethread.h"
62 #include "samplescroll.h"
63 #include "shbtnprefs.h"
64 #include "statusbar.h"
67 #include "trackcanvas.h"
68 #include "trackscroll.h"
70 #include "transitionpopup.h"
71 #include "vwindowgui.h"
75 #define PANE_DRAG_MARGIN MAX(mwindow->theme->pane_w, mwindow->theme->pane_h)
78 // the main window uses its own private colormap for video
79 MWindowGUI::MWindowGUI(MWindow *mwindow)
80 : BC_Window(_(PROGRAM_NAME ": Program"),
81 mwindow->session->mwindow_x,
82 mwindow->session->mwindow_y,
83 mwindow->session->mwindow_w,
84 mwindow->session->mwindow_h,
91 this->mwindow = mwindow;
98 focused_pane = TOP_LEFT_PANE;
107 for(int i = 0; i < TOTAL_PANES; i++)
126 cwindow_remote_handler = 0;
127 record_remote_handler = 0;
132 MWindowGUI::~MWindowGUI()
134 delete android_control;
135 delete cwindow_remote_handler;
136 delete record_remote_handler;
137 delete remote_control;
138 delete keyvalue_popup;
139 // delete samplescroll;
140 // delete trackscroll;
141 for(int i = 0; i < TOTAL_PANES; i++)
142 if(pane[i]) delete pane[i];
144 delete render_engine;
145 delete resource_thread;
146 resource_pixmaps.remove_all_objects();
157 void MWindowGUI::get_scrollbars(int flush)
159 //int64_t h_needed = mwindow->edl->get_tracks_height(mwindow->theme);
160 //int64_t w_needed = mwindow->edl->get_tracks_width();
161 int need_xscroll = 0;
162 int need_yscroll = 0;
163 view_w = mwindow->theme->mcanvas_w;
164 view_h = mwindow->theme->mcanvas_h;
166 // Scrollbars are constitutive
167 need_xscroll = need_yscroll = 1;
168 view_h = mwindow->theme->mcanvas_h;
169 view_w = mwindow->theme->mcanvas_w;
171 // for(int i = 0; i < 2; i++)
173 // if(w_needed > view_w)
176 // view_h = mwindow->theme->mcanvas_h - SCROLL_SPAN;
181 // if(h_needed > view_h)
184 // view_w = mwindow->theme->mcanvas_w - SCROLL_SPAN;
189 //printf("MWindowGUI::get_scrollbars 1\n");
191 if(canvas && (view_w != canvas->get_w() || view_h != canvas->get_h()))
193 canvas->reposition_window(mwindow->theme->mcanvas_x,
194 mwindow->theme->mcanvas_y,
202 add_subwindow(samplescroll = new SampleScroll(mwindow,
204 mwindow->theme->mhscroll_x,
205 mwindow->theme->mhscroll_y,
206 mwindow->theme->mhscroll_w));
208 samplescroll->resize_event();
210 samplescroll->set_position(0);
214 if(samplescroll) delete samplescroll;
216 mwindow->edl->local_session->view_start = 0;
222 //printf("MWindowGUI::get_scrollbars 1.1 %p %p\n", this, canvas);
224 add_subwindow(trackscroll = new TrackScroll(mwindow,
226 mwindow->theme->mvscroll_x,
227 mwindow->theme->mvscroll_y,
228 mwindow->theme->mvscroll_h));
230 trackscroll->resize_event();
233 //printf("MWindowGUI::get_scrollbars 1.2\n");
234 trackscroll->update_length(mwindow->edl->get_tracks_height(mwindow->theme),
235 mwindow->edl->local_session->track_start,
238 //printf("MWindowGUI::get_scrollbars 1.3\n");
242 if(trackscroll) delete trackscroll;
244 mwindow->edl->local_session->track_start = 0;
247 if(flush) this->flush();
252 void MWindowGUI::create_objects()
256 resource_thread = new ResourceThread(mwindow, this);
257 resource_thread->create_objects();
260 if(debug) printf("MWindowGUI::create_objects %d\n", __LINE__);
261 set_icon(mwindow->theme->get_image("mwindow_icon"));
262 remote_control = new RemoteControl(this);
263 cwindow_remote_handler = new CWindowRemoteHandler(remote_control);
264 record_remote_handler = new RecordRemoteHandler(remote_control);
265 mwindow->reset_android_remote();
267 if(debug) printf("MWindowGUI::create_objects %d\n", __LINE__);
269 int x = get_w() - MainShBtns::calculate_w(0);
270 add_subwindow(mainmenu = new MainMenu(mwindow, this, x));
271 mainmenu->create_objects();
272 add_subwindow(mainshbtns = new MainShBtns(mwindow, x, -1));
273 mainshbtns->load(mwindow->preferences);
274 mwindow->theme->get_mwindow_sizes(this, get_w(), get_h());
275 mwindow->theme->draw_mwindow_bg(this);
276 if(debug) printf("MWindowGUI::create_objects %d\n", __LINE__);
278 add_subwindow(mbuttons = new MButtons(mwindow, this));
279 mbuttons->create_objects();
280 add_subwindow(ffmpeg_toggle = new FFMpegToggle(mwindow, mbuttons, menu_w(), menu_h()+2));
282 pane[TOP_LEFT_PANE] = new TimelinePane(mwindow,
284 mwindow->theme->mcanvas_x,
285 mwindow->theme->mcanvas_y,
286 mwindow->theme->mcanvas_w,
287 mwindow->theme->mcanvas_h);
288 pane[TOP_LEFT_PANE]->create_objects();
290 // add_subwindow(timebar = new MTimeBar(mwindow,
292 // mwindow->theme->mtimebar_x,
293 // mwindow->theme->mtimebar_y,
294 // mwindow->theme->mtimebar_w,
295 // mwindow->theme->mtimebar_h));
296 // timebar->create_objects();
298 // if(debug) printf("MWindowGUI::create_objects %d\n", __LINE__);
299 // add_subwindow(patchbay = new PatchBay(mwindow, this));
300 // patchbay->create_objects();
302 // if(debug) printf("MWindowGUI::create_objects %d\n", __LINE__);
303 // get_scrollbars(0);
305 // if(debug) printf("MWindowGUI::create_objects %d\n", __LINE__);
306 // mwindow->gui->add_subwindow(canvas = new TrackCanvas(mwindow, this));
307 // canvas->create_objects();
310 if(debug) printf("MWindowGUI::create_objects %d\n", __LINE__);
311 add_subwindow(zoombar = new ZoomBar(mwindow, this));
312 zoombar->create_objects();
315 if(debug) printf("MWindowGUI::create_objects %d\n", __LINE__);
316 add_subwindow(statusbar = new StatusBar(mwindow, this));
317 statusbar->create_objects();
321 if(debug) printf("MWindowGUI::create_objects %d\n", __LINE__);
322 add_subwindow(mainclock = new MainClock(mwindow,
323 mwindow->theme->mclock_x,
324 mwindow->theme->mclock_y,
325 mwindow->theme->mclock_w));
326 mainclock->set_position_offset( (double)
327 (mwindow->edl->session->get_frame_offset() /
328 mwindow->edl->session->frame_rate));
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 db_window = new DbWindow(mwindow);
364 swindow = new SWindow(mwindow);
366 if(debug) printf("MWindowGUI::create_objects %d\n", __LINE__);
368 add_subwindow(pane_button = new PaneButton(mwindow,
369 get_w() - mwindow->theme->get_image_set("pane")[0]->get_w(),
370 mwindow->theme->mzoom_y + 1 - mwindow->theme->get_image_set("pane")[0]->get_h()));
372 pane[TOP_LEFT_PANE]->canvas->activate();
374 if(debug) printf("MWindowGUI::create_objects %d\n", __LINE__);
377 void MWindowGUI::redraw_time_dependancies()
379 zoombar->redraw_time_dependancies();
380 for(int i = 0; i < TOTAL_PANES; i++)
381 if(pane[i] && pane[i]->timebar) pane[i]->timebar->update(0);
382 mainclock->update(mwindow->edl->local_session->get_selectionstart(1));
385 int MWindowGUI::cursor_enter_event()
387 reset_default_message();
391 int MWindowGUI::focus_in_event()
393 for(int i = 0; i < TOTAL_PANES; i++)
394 if(pane[i]) pane[i]->cursor->focus_in_event();
398 int MWindowGUI::focus_out_event()
400 for(int i = 0; i < TOTAL_PANES; i++)
401 if(pane[i]) pane[i]->cursor->focus_out_event();
406 int MWindowGUI::resize_event(int w, int h)
408 //printf("MWindowGUI::resize_event %d\n", __LINE__);
409 mwindow->session->mwindow_w = w;
410 mwindow->session->mwindow_h = h;
411 int x = w - MainShBtns::calculate_w(0);
412 mainmenu->resize_event(x, mainmenu->get_h());
413 mainshbtns->reposition_window(x, -1);
414 ffmpeg_toggle->reposition_window(menu_w(), menu_h()+2);
415 mwindow->theme->get_mwindow_sizes(this, w, h);
416 mwindow->theme->draw_mwindow_bg(this);
417 mbuttons->resize_event();
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::draw_indexes(Indexable *indexable)
669 for(int i = 0; i < TOTAL_PANES; i++)
673 pane[i]->canvas->draw_indexes(indexable);
678 void MWindowGUI::draw_canvas(int mode /* = 0 */, int hide_cursor /* = 1 */)
680 if(mode != IGNORE_THREAD)
682 resource_thread->stop_draw(1);
686 for(int i = 0; i < TOTAL_PANES; i++)
690 pane[i]->canvas->draw(mode, hide_cursor);
695 if(mode != IGNORE_THREAD)
697 resource_thread->start_draw();
702 void MWindowGUI::flash_canvas(int flush)
704 for(int i = 0; i < TOTAL_PANES; i++)
708 pane[i]->canvas->flash(flush);
713 void MWindowGUI::draw_cursor(int do_plugintoggles)
715 for(int i = 0; i < TOTAL_PANES; i++)
719 pane[i]->cursor->draw(do_plugintoggles);
724 void MWindowGUI::show_cursor(int do_plugintoggles)
726 for(int i = 0; i < TOTAL_PANES; i++)
730 pane[i]->cursor->show(do_plugintoggles);
735 void MWindowGUI::hide_cursor(int do_plugintoggles)
737 for(int i = 0; i < TOTAL_PANES; i++)
741 pane[i]->cursor->hide(do_plugintoggles);
746 void MWindowGUI::update_cursor()
748 for(int i = 0; i < TOTAL_PANES; i++)
752 pane[i]->cursor->update();
757 void MWindowGUI::set_playing_back(int value)
759 for(int i = 0; i < TOTAL_PANES; i++)
763 pane[i]->cursor->playing_back = value;
768 void MWindowGUI::update_plugintoggles()
770 for(int i = 0; i < TOTAL_PANES; i++)
774 pane[i]->canvas->refresh_plugintoggles();
780 void MWindowGUI::update_scrollbars(int flush)
782 for(int i = 0; i < TOTAL_PANES; i++)
786 pane[i]->update(1, 0, 0, 0);
789 if(flush) this->flush();
792 void MWindowGUI::reset_meters()
794 for(int i = 0; i < TOTAL_PANES; i++)
796 if(pane[i] && pane[i]->patchbay)
798 pane[i]->patchbay->reset_meters();
803 void MWindowGUI::stop_meters()
805 for(int i = 0; i < TOTAL_PANES; i++)
807 if(pane[i] && pane[i]->patchbay)
809 pane[i]->patchbay->stop_meters();
814 void MWindowGUI::update_meters(ArrayList<double> *module_levels)
816 for(int i = 0; i < TOTAL_PANES; i++)
818 if(pane[i] && pane[i]->patchbay)
820 pane[i]->patchbay->update_meters(module_levels);
825 void MWindowGUI::set_editing_mode(int flush)
827 for(int i = 0; i < TOTAL_PANES; i++)
831 pane[i]->canvas->update_cursor(flush);
836 void MWindowGUI::set_meter_format(int mode, int min, int max)
838 for(int i = 0; i < TOTAL_PANES; i++)
840 if(pane[i] && pane[i]->patchbay)
842 pane[i]->patchbay->set_meter_format(mode, min, max);
847 void MWindowGUI::update(int scrollbars,
856 if(debug) PRINT_TRACE
860 mwindow->edl->tracks->update_y_pixels(mwindow->theme);
862 if(do_canvas && do_canvas != IGNORE_THREAD)
864 resource_thread->stop_draw(1);
867 for(int i = 0; i < TOTAL_PANES; i++)
869 if(pane[i]) pane[i]->update(scrollbars,
875 if(do_canvas && do_canvas != IGNORE_THREAD)
877 resource_thread->start_draw();
880 // if(scrollbars) this->get_scrollbars(0);
881 // if(timebar) this->timebar->update(0);
882 if(zoombar) this->zoombar->update();
883 // if(patchbay) this->patchbay->update();
884 if(clock) this->mainclock->update(
885 mwindow->edl->local_session->get_selectionstart(1));
886 if(debug) PRINT_TRACE
892 // this->canvas->draw(do_canvas);
893 // this->cursor->show();
894 // this->canvas->flash(0);
895 // Activate causes the menubar to deactivate. Don't want this for
897 // if(canvas != IGNORE_THREAD) this->canvas->activate();
899 if(debug) PRINT_TRACE
903 if(buttonbar) mbuttons->update();
904 if(debug) PRINT_TRACE
906 // Can't age if the cache called this to draw missing picons
907 // or the GUI is updating the status of the draw toggle.
908 if(do_canvas != FORCE_REDRAW && do_canvas != IGNORE_THREAD)
911 mwindow->age_caches();
912 lock_window("MWindowGUI::update");
916 if(debug) PRINT_TRACE
919 int MWindowGUI::visible(int64_t x1, int64_t x2, int64_t view_x1, int64_t view_x2)
921 return (x1 >= view_x1 && x1 < view_x2) ||
922 (x2 > view_x1 && x2 <= view_x2) ||
923 (x1 <= view_x1 && x2 >= view_x2);
927 void MWindowGUI::show_message(const char *message, int color)
929 statusbar->set_message(message, color);
931 void MWindowGUI::set_default_message(const char *message)
933 statusbar->set_default_message(message);
935 void MWindowGUI::reset_default_message()
937 statusbar->reset_default_message();
939 void MWindowGUI::default_message()
941 statusbar->default_message();
944 // Drag motion called from other window
945 int MWindowGUI::drag_motion()
947 if(get_hidden()) return 0;
949 Track *over_track = 0;
951 PluginSet *over_pluginset = 0;
952 Plugin *over_plugin = 0;
957 drag_popup->cursor_motion_event();
961 // there's no point in drawing highlights has until drag operation has been set
962 if (!mwindow->session->current_operation)
965 for(int i = 0; i < TOTAL_PANES; i++)
967 if(pane[i]) pane[i]->canvas->drag_motion(
974 if(mwindow->session->track_highlighted != over_track)
976 mwindow->session->track_highlighted = over_track;
980 if(mwindow->session->edit_highlighted != over_edit)
982 mwindow->session->edit_highlighted = over_edit;
986 if(mwindow->session->pluginset_highlighted != over_pluginset)
988 mwindow->session->pluginset_highlighted = over_pluginset;
992 if(mwindow->session->plugin_highlighted != over_plugin)
994 mwindow->session->plugin_highlighted = over_plugin;
998 if( mwindow->session->current_operation == DRAG_ASSET ||
999 mwindow->session->current_operation == DRAG_EDIT ||
1000 mwindow->session->current_operation == DRAG_AEFFECT_COPY ||
1001 mwindow->session->current_operation == DRAG_VEFFECT_COPY )
1007 // printf("drag_motion %d %d over_track=%p over_edit=%p\n",
1014 lock_window("MWindowGUI::drag_motion");
1021 int MWindowGUI::drag_stop()
1023 if(get_hidden()) return 0;
1024 int result = 0, redraw = 0;
1026 for(int i = 0; i < TOTAL_PANES; i++)
1028 if(pane[i]) result |= pane[i]->canvas->drag_stop(
1031 mwindow->edl->optimize();
1033 // since we don't have subwindows we have to terminate any drag operation
1036 if (mwindow->session->track_highlighted
1037 || mwindow->session->edit_highlighted
1038 || mwindow->session->plugin_highlighted
1039 || mwindow->session->pluginset_highlighted)
1041 mwindow->session->track_highlighted = 0;
1042 mwindow->session->edit_highlighted = 0;
1043 mwindow->session->plugin_highlighted = 0;
1044 mwindow->session->pluginset_highlighted = 0;
1045 mwindow->session->current_operation = NO_OPERATION;
1049 //printf("TrackCanvas::drag_stop %d %d\n", redraw, mwindow->session->current_operation);
1052 mwindow->edl->tracks->update_y_pixels(mwindow->theme);
1053 update_scrollbars(0);
1068 void MWindowGUI::default_positions()
1070 //printf("MWindowGUI::default_positions 1\n");
1071 VWindow *vwindow = mwindow->vwindows.size() > DEFAULT_VWINDOW ?
1072 mwindow->vwindows.get(DEFAULT_VWINDOW) : 0;
1073 if( vwindow && !vwindow->is_running() ) vwindow = 0;
1074 if( vwindow ) vwindow->gui->lock_window("MWindowGUI::default_positions");
1075 mwindow->cwindow->gui->lock_window("MWindowGUI::default_positions");
1076 mwindow->awindow->gui->lock_window("MWindowGUI::default_positions");
1078 // printf("MWindowGUI::default_positions 1 %d %d %d %d\n", mwindow->session->vwindow_x,
1079 // mwindow->session->vwindow_y,
1080 // mwindow->session->vwindow_w,
1081 // mwindow->session->vwindow_h);
1082 reposition_window(mwindow->session->mwindow_x,
1083 mwindow->session->mwindow_y,
1084 mwindow->session->mwindow_w,
1085 mwindow->session->mwindow_h);
1086 if( vwindow ) vwindow->gui->reposition_window(mwindow->session->vwindow_x,
1087 mwindow->session->vwindow_y,
1088 mwindow->session->vwindow_w,
1089 mwindow->session->vwindow_h);
1090 mwindow->cwindow->gui->reposition_window(mwindow->session->cwindow_x,
1091 mwindow->session->cwindow_y,
1092 mwindow->session->cwindow_w,
1093 mwindow->session->cwindow_h);
1094 mwindow->awindow->gui->reposition_window(mwindow->session->awindow_x,
1095 mwindow->session->awindow_y,
1096 mwindow->session->awindow_w,
1097 mwindow->session->awindow_h);
1098 //printf("MWindowGUI::default_positions 1\n");
1100 resize_event(mwindow->session->mwindow_w,
1101 mwindow->session->mwindow_h);
1102 //printf("MWindowGUI::default_positions 1\n");
1103 if( vwindow ) vwindow->gui->resize_event(mwindow->session->vwindow_w,
1104 mwindow->session->vwindow_h);
1105 //printf("MWindowGUI::default_positions 1\n");
1106 mwindow->cwindow->gui->resize_event(mwindow->session->cwindow_w,
1107 mwindow->session->cwindow_h);
1108 //printf("MWindowGUI::default_positions 1\n");
1109 mwindow->awindow->gui->resize_event(mwindow->session->awindow_w,
1110 mwindow->session->awindow_h);
1112 //printf("MWindowGUI::default_positions 1\n");
1115 if( vwindow ) vwindow->gui->flush();
1116 mwindow->cwindow->gui->flush();
1117 mwindow->awindow->gui->flush();
1119 if( vwindow ) vwindow->gui->unlock_window();
1120 mwindow->cwindow->gui->unlock_window();
1121 mwindow->awindow->gui->unlock_window();
1122 //printf("MWindowGUI::default_positions 2\n");
1126 int MWindowGUI::button_release_event()
1128 if( keyvalue_popup ) {
1129 delete keyvalue_popup; keyvalue_popup = 0;
1135 int MWindowGUI::repeat_event(int64_t duration)
1137 // if(duration == 100)
1138 // mwindow->sync_parameters(CHANGE_ALL);
1140 for(int i = 0; i < TOTAL_PANES; i++)
1142 if(pane[i]) result = pane[i]->cursor->repeat_event(duration);
1148 int MWindowGUI::translation_event()
1150 //printf("MWindowGUI::translation_event 1 %d %d\n", get_x(), get_y());
1151 mwindow->session->mwindow_x = get_x();
1152 mwindow->session->mwindow_y = get_y();
1157 int MWindowGUI::save_defaults(BC_Hash *defaults)
1159 defaults->update("MWINDOWWIDTH", get_w());
1160 defaults->update("MWINDOWHEIGHT", get_h());
1161 mainmenu->save_defaults(defaults);
1162 BC_WindowBase::save_defaults(defaults);
1166 int MWindowGUI::keypress_event()
1168 //printf("MWindowGUI::keypress_event 1 %d\n", get_keypress());
1169 int result = mbuttons->keypress_event();
1170 if( result ) return result;
1172 switch(get_keypress()) {
1174 mwindow->toggle_editing_mode();
1178 case '1': case '2': case '3': case '4':
1179 case '5': case '6': case '7': case '8':
1180 if( !alt_down() || shift_down() ) break;
1181 if( !mwindow->select_asset(get_keypress()-'1',1) )
1186 if( !ctrl_down() ) {
1189 mbuttons->transport->handle_transport(STOP, 1, 0, 0);
1190 lock_window("MWindowGUI::keypress_event 1");
1191 mwindow->prev_edit_handle(shift_down());
1194 mwindow->move_left();
1200 if( !ctrl_down() ) {
1203 mbuttons->transport->handle_transport(STOP, 1, 0, 0);
1204 lock_window("MWindowGUI::keypress_event 2");
1205 mwindow->next_edit_handle(shift_down());
1208 mwindow->move_right();
1214 if( ctrl_down() && !alt_down() )
1215 mwindow->expand_y();
1216 else if( !ctrl_down() && alt_down() )
1217 mwindow->expand_autos(0,1,1);
1218 else if( ctrl_down() && alt_down() )
1219 mwindow->expand_autos(1,1,1);
1221 mwindow->expand_sample();
1226 if( ctrl_down() && !alt_down() )
1227 mwindow->zoom_in_y();
1228 else if( !ctrl_down() && alt_down() )
1229 mwindow->shrink_autos(0,1,1);
1230 else if( ctrl_down() && alt_down() )
1231 mwindow->shrink_autos(1,1,1);
1233 mwindow->zoom_in_sample();
1241 mwindow->expand_t();
1247 mwindow->move_down();
1249 mwindow->zoom_in_t();
1255 Track *this_track = 0;
1256 for( int i=0; i<TOTAL_PANES; ++i ) {
1257 if( !pane[i] ) continue;
1258 if( (this_track = pane[i]->over_track()) != 0 ) break;
1259 if( (this_track = pane[i]->over_patchbay()) != 0 ) break;
1262 if( get_keypress() == TAB ) { // Switch the record button
1264 this_track->record = !this_track->record ? 1 : 0;
1267 int total_selected = mwindow->edl->tracks->total_of(Tracks::RECORD);
1268 // all selected if nothing previously selected or
1269 // if this patch was previously the only one selected and armed
1270 int selected = !total_selected || (total_selected == 1 &&
1271 this_track && this_track->record ) ? 1 : 0;
1272 mwindow->edl->tracks->select_all(Tracks::RECORD, selected);
1273 if( !selected && this_track ) this_track->record = 1;
1276 update(0, 1, 0, 0, 1, 0, 1);
1278 mwindow->cwindow->update(0, 1, 1);
1279 lock_window("TrackCanvas::keypress_event 3");
1285 // since things under cursor have changed...
1287 cursor_motion_event();
1292 int MWindowGUI::keyboard_listener(BC_WindowBase *wp)
1294 return key_listener(wp->get_keypress());
1297 int MWindowGUI::key_listener(int key)
1302 if( !record->running() )
1305 record->record_gui->interrupt_thread->start(0);
1312 channel_info->toggle_scan();
1316 if( !remote_control->deactivate() )
1317 remote_control->activate();
1327 void MWindowGUI::use_android_remote(int on)
1330 delete android_control;
1331 android_control = 0;
1334 if( android_control ) return;
1335 android_control = new AndroidControl(this);
1338 int MWindowGUI::close_event()
1344 void MWindowGUI::stop_drawing()
1346 resource_thread->stop_draw(1);
1349 int MWindowGUI::menu_w()
1351 return mainmenu->get_w();
1354 int MWindowGUI::menu_h()
1356 return mainmenu->get_h();
1359 void MWindowGUI::start_x_pane_drag()
1363 x_pane_drag = new BC_Popup(this,
1364 get_abs_cursor_x(0) - mwindow->theme->pane_w,
1365 BC_DisplayInfo::get_top_border() +
1367 mwindow->theme->mcanvas_y,
1368 mwindow->theme->pane_w,
1369 mwindow->theme->mcanvas_h,
1370 mwindow->theme->drag_pane_color);
1371 x_pane_drag->draw_3segmentv(0,
1373 x_pane_drag->get_h(),
1374 mwindow->theme->get_image_set("xpane")[BUTTON_DOWNHI]);
1375 x_pane_drag->flash(1);
1380 void MWindowGUI::start_y_pane_drag()
1384 //printf("MWindowGUI::start_y_pane_drag %d %d %d\n", __LINE__, get_x(), get_y());
1385 y_pane_drag = new BC_Popup(this,
1386 BC_DisplayInfo::get_left_border() +
1388 mwindow->theme->mcanvas_x,
1389 get_abs_cursor_y(0) - mwindow->theme->pane_h,
1390 mwindow->theme->mcanvas_w,
1391 mwindow->theme->pane_h,
1392 mwindow->theme->drag_pane_color);
1393 y_pane_drag->draw_3segmenth(0,
1395 y_pane_drag->get_w(),
1396 mwindow->theme->get_image_set("ypane")[BUTTON_DOWNHI]);
1397 y_pane_drag->flash(1);
1402 void MWindowGUI::handle_pane_drag()
1408 x_pane_drag->reposition_window(
1409 get_abs_cursor_x(0) - mwindow->theme->pane_w,
1410 x_pane_drag->get_y());
1415 y_pane_drag->reposition_window(
1416 y_pane_drag->get_x(),
1417 get_abs_cursor_y(0) - mwindow->theme->pane_h);
1423 void MWindowGUI::create_x_pane(int cursor_x)
1425 if(total_panes() == 1)
1427 // create a horizontal pane
1428 // do this 1st so the resize_event knows there are 2 panes
1429 mwindow->edl->local_session->view_start[TOP_RIGHT_PANE] =
1430 mwindow->edl->local_session->view_start[TOP_LEFT_PANE] +
1432 mwindow->theme->patchbay_w;
1433 pane[TOP_RIGHT_PANE] = new TimelinePane(mwindow,
1435 mwindow->theme->mcanvas_x +
1437 mwindow->theme->mcanvas_y,
1438 mwindow->theme->mcanvas_x +
1439 mwindow->theme->mcanvas_w -
1441 mwindow->theme->mcanvas_h);
1442 pane[TOP_LEFT_PANE]->resize_event(
1443 mwindow->theme->mcanvas_x,
1444 mwindow->theme->mcanvas_y,
1445 cursor_x - mwindow->theme->pane_w,
1446 mwindow->theme->mcanvas_h);
1447 pane[TOP_RIGHT_PANE]->create_objects();
1450 if(vertical_panes())
1452 // create 2 horizontal panes
1453 mwindow->edl->local_session->track_start[TOP_RIGHT_PANE] =
1454 mwindow->edl->local_session->track_start[TOP_LEFT_PANE];
1455 mwindow->edl->local_session->track_start[BOTTOM_RIGHT_PANE] =
1456 mwindow->edl->local_session->track_start[BOTTOM_LEFT_PANE];
1457 mwindow->edl->local_session->view_start[TOP_RIGHT_PANE] =
1458 mwindow->edl->local_session->view_start[BOTTOM_RIGHT_PANE] =
1459 mwindow->edl->local_session->view_start[TOP_LEFT_PANE] +
1461 mwindow->theme->patchbay_w;
1462 pane[TOP_RIGHT_PANE] = new TimelinePane(mwindow,
1464 mwindow->theme->mcanvas_x +
1466 pane[TOP_LEFT_PANE]->y,
1467 mwindow->theme->mcanvas_x +
1468 mwindow->theme->mcanvas_w -
1470 pane[TOP_LEFT_PANE]->h);
1471 pane[BOTTOM_RIGHT_PANE] = new TimelinePane(mwindow,
1473 mwindow->theme->mcanvas_x +
1475 pane[BOTTOM_LEFT_PANE]->y,
1476 mwindow->theme->mcanvas_x +
1477 mwindow->theme->mcanvas_w -
1479 pane[BOTTOM_LEFT_PANE]->h);
1480 pane[TOP_LEFT_PANE]->resize_event(
1481 pane[TOP_LEFT_PANE]->x,
1482 pane[TOP_LEFT_PANE]->y,
1483 cursor_x - mwindow->theme->pane_w,
1484 pane[TOP_LEFT_PANE]->h);
1485 pane[BOTTOM_LEFT_PANE]->resize_event(
1486 pane[BOTTOM_LEFT_PANE]->x,
1487 pane[BOTTOM_LEFT_PANE]->y,
1488 cursor_x - mwindow->theme->pane_w,
1489 pane[BOTTOM_LEFT_PANE]->h);
1490 pane[TOP_RIGHT_PANE]->create_objects();
1491 pane[BOTTOM_RIGHT_PANE]->create_objects();
1494 if(horizontal_panes())
1496 // resize a horizontal pane
1497 mwindow->edl->local_session->view_start[TOP_RIGHT_PANE] +=
1499 pane[TOP_RIGHT_PANE]->x;
1500 if(mwindow->edl->local_session->view_start[TOP_RIGHT_PANE] < 0)
1501 mwindow->edl->local_session->view_start[TOP_RIGHT_PANE] = 0;
1502 pane[TOP_LEFT_PANE]->resize_event(
1503 mwindow->theme->mcanvas_x,
1504 mwindow->theme->mcanvas_y,
1505 cursor_x - mwindow->theme->pane_w,
1506 mwindow->theme->mcanvas_h);
1507 pane[TOP_RIGHT_PANE]->resize_event(
1508 mwindow->theme->mcanvas_x +
1510 pane[TOP_RIGHT_PANE]->y,
1511 mwindow->theme->mcanvas_x +
1512 mwindow->theme->mcanvas_w -
1514 mwindow->theme->mcanvas_h);
1518 // resize 2 horizontal panes
1519 mwindow->edl->local_session->view_start[TOP_RIGHT_PANE] +=
1521 pane[TOP_RIGHT_PANE]->x;
1522 if(mwindow->edl->local_session->view_start[TOP_RIGHT_PANE] < 0)
1523 mwindow->edl->local_session->view_start[TOP_RIGHT_PANE] = 0;
1524 mwindow->edl->local_session->view_start[BOTTOM_RIGHT_PANE] =
1525 mwindow->edl->local_session->view_start[TOP_RIGHT_PANE];
1527 pane[TOP_LEFT_PANE]->resize_event(
1528 mwindow->theme->mcanvas_x,
1529 pane[TOP_LEFT_PANE]->y,
1530 cursor_x - mwindow->theme->pane_w,
1531 pane[TOP_LEFT_PANE]->h);
1532 pane[TOP_RIGHT_PANE]->resize_event(
1533 mwindow->theme->mcanvas_x +
1535 pane[TOP_RIGHT_PANE]->y,
1536 mwindow->theme->mcanvas_x +
1537 mwindow->theme->mcanvas_w -
1539 pane[TOP_RIGHT_PANE]->h);
1540 pane[BOTTOM_LEFT_PANE]->resize_event(
1541 mwindow->theme->mcanvas_x,
1542 pane[BOTTOM_LEFT_PANE]->y,
1543 cursor_x - mwindow->theme->pane_w,
1544 pane[BOTTOM_LEFT_PANE]->h);
1545 pane[BOTTOM_RIGHT_PANE]->resize_event(
1546 mwindow->theme->mcanvas_x +
1548 pane[BOTTOM_RIGHT_PANE]->y,
1549 mwindow->theme->mcanvas_x +
1550 mwindow->theme->mcanvas_w -
1552 pane[BOTTOM_RIGHT_PANE]->h);
1558 void MWindowGUI::delete_x_pane(int cursor_x)
1560 // give left panes coordinates of right pane
1561 if(cursor_x < mwindow->theme->patchbay_w + PANE_DRAG_MARGIN &&
1562 pane[TOP_RIGHT_PANE])
1564 mwindow->edl->local_session->view_start[TOP_LEFT_PANE] =
1565 mwindow->edl->local_session->view_start[TOP_RIGHT_PANE] -
1566 pane[TOP_RIGHT_PANE]->x + mwindow->theme->patchbay_w;
1567 if(mwindow->edl->local_session->view_start[TOP_LEFT_PANE] < 0)
1568 mwindow->edl->local_session->view_start[TOP_LEFT_PANE] = 0;
1569 mwindow->edl->local_session->view_start[BOTTOM_LEFT_PANE] =
1570 mwindow->edl->local_session->view_start[TOP_LEFT_PANE];
1573 switch(total_panes())
1576 if(pane[TOP_LEFT_PANE] && pane[TOP_RIGHT_PANE])
1578 // delete right pane
1579 delete pane[TOP_RIGHT_PANE];
1580 pane[TOP_RIGHT_PANE] = 0;
1581 pane[TOP_LEFT_PANE]->resize_event(
1582 mwindow->theme->mcanvas_x,
1583 mwindow->theme->mcanvas_y,
1584 mwindow->theme->mcanvas_w,
1585 mwindow->theme->mcanvas_h);
1591 // delete right panes
1592 delete pane[TOP_RIGHT_PANE];
1593 pane[TOP_RIGHT_PANE] = 0;
1594 delete pane[BOTTOM_RIGHT_PANE];
1595 pane[BOTTOM_RIGHT_PANE] = 0;
1596 pane[TOP_LEFT_PANE]->resize_event(
1597 mwindow->theme->mcanvas_x,
1598 pane[TOP_LEFT_PANE]->y,
1599 mwindow->theme->mcanvas_w,
1600 pane[TOP_LEFT_PANE]->h);
1601 pane[BOTTOM_LEFT_PANE]->resize_event(
1602 mwindow->theme->mcanvas_x,
1603 pane[BOTTOM_LEFT_PANE]->y,
1604 mwindow->theme->mcanvas_w,
1605 pane[BOTTOM_LEFT_PANE]->h);
1610 void MWindowGUI::create_y_pane(int cursor_y)
1612 if(total_panes() == 1)
1614 mwindow->edl->local_session->view_start[BOTTOM_LEFT_PANE] =
1615 mwindow->edl->local_session->view_start[TOP_LEFT_PANE];
1616 mwindow->edl->local_session->track_start[BOTTOM_LEFT_PANE] =
1617 mwindow->edl->local_session->track_start[TOP_LEFT_PANE] +
1619 mwindow->theme->mtimebar_h;
1620 // do this 1st so the resize_event knows there are 2 panes
1621 pane[BOTTOM_LEFT_PANE] = new TimelinePane(mwindow,
1623 mwindow->theme->mcanvas_x,
1624 mwindow->theme->mcanvas_y +
1626 mwindow->theme->mcanvas_w,
1627 mwindow->theme->mcanvas_h -
1629 pane[TOP_LEFT_PANE]->resize_event(
1630 mwindow->theme->mcanvas_x,
1631 mwindow->theme->mcanvas_y,
1632 mwindow->theme->mcanvas_w,
1633 pane[BOTTOM_LEFT_PANE]->y -
1634 mwindow->theme->mcanvas_y -
1635 mwindow->theme->pane_h);
1636 pane[BOTTOM_LEFT_PANE]->create_objects();
1639 if(horizontal_panes())
1642 mwindow->edl->local_session->view_start[BOTTOM_LEFT_PANE] =
1643 mwindow->edl->local_session->view_start[TOP_LEFT_PANE];
1644 mwindow->edl->local_session->view_start[BOTTOM_RIGHT_PANE] =
1645 mwindow->edl->local_session->view_start[TOP_RIGHT_PANE];
1646 mwindow->edl->local_session->track_start[BOTTOM_LEFT_PANE] =
1647 mwindow->edl->local_session->track_start[BOTTOM_RIGHT_PANE] =
1648 mwindow->edl->local_session->track_start[TOP_LEFT_PANE] +
1650 mwindow->theme->mtimebar_h;
1652 pane[BOTTOM_LEFT_PANE] = new TimelinePane(mwindow,
1654 pane[TOP_LEFT_PANE]->x,
1655 mwindow->theme->mcanvas_y +
1657 pane[TOP_LEFT_PANE]->w,
1658 mwindow->theme->mcanvas_h -
1660 pane[BOTTOM_RIGHT_PANE] = new TimelinePane(mwindow,
1662 pane[TOP_RIGHT_PANE]->x,
1663 mwindow->theme->mcanvas_y +
1665 pane[TOP_RIGHT_PANE]->w,
1666 mwindow->theme->mcanvas_h -
1669 pane[TOP_LEFT_PANE]->resize_event(
1670 pane[TOP_LEFT_PANE]->x,
1671 pane[TOP_LEFT_PANE]->y,
1672 pane[TOP_LEFT_PANE]->w,
1673 pane[BOTTOM_LEFT_PANE]->y -
1674 mwindow->theme->mcanvas_y -
1675 mwindow->theme->pane_h);
1676 pane[TOP_RIGHT_PANE]->resize_event(
1677 pane[TOP_RIGHT_PANE]->x,
1678 pane[TOP_RIGHT_PANE]->y,
1679 pane[TOP_RIGHT_PANE]->w,
1680 pane[BOTTOM_RIGHT_PANE]->y -
1681 mwindow->theme->mcanvas_y -
1682 mwindow->theme->pane_h);
1684 pane[BOTTOM_LEFT_PANE]->create_objects();
1685 pane[BOTTOM_RIGHT_PANE]->create_objects();
1688 if(vertical_panes())
1691 mwindow->edl->local_session->track_start[BOTTOM_LEFT_PANE] +=
1693 (pane[BOTTOM_LEFT_PANE]->y - mwindow->theme->mcanvas_y);
1694 if(mwindow->edl->local_session->track_start[BOTTOM_LEFT_PANE] < 0)
1695 mwindow->edl->local_session->track_start[BOTTOM_LEFT_PANE] = 0;
1696 pane[TOP_LEFT_PANE]->resize_event(
1697 mwindow->theme->mcanvas_x,
1698 mwindow->theme->mcanvas_y,
1699 mwindow->theme->mcanvas_w,
1700 cursor_y - mwindow->theme->pane_h);
1701 pane[BOTTOM_LEFT_PANE]->resize_event(
1702 pane[BOTTOM_LEFT_PANE]->x,
1704 mwindow->theme->mcanvas_y,
1705 mwindow->theme->mcanvas_w,
1706 mwindow->theme->mcanvas_h -
1712 mwindow->edl->local_session->track_start[BOTTOM_LEFT_PANE] +=
1714 (pane[BOTTOM_LEFT_PANE]->y - mwindow->theme->mcanvas_y);
1715 if(mwindow->edl->local_session->track_start[BOTTOM_LEFT_PANE] < 0)
1716 mwindow->edl->local_session->track_start[BOTTOM_LEFT_PANE] = 0;
1717 mwindow->edl->local_session->track_start[BOTTOM_RIGHT_PANE] =
1718 mwindow->edl->local_session->track_start[BOTTOM_LEFT_PANE];
1719 pane[TOP_LEFT_PANE]->resize_event(
1720 pane[TOP_LEFT_PANE]->x,
1721 pane[TOP_LEFT_PANE]->y,
1722 pane[TOP_LEFT_PANE]->w,
1723 cursor_y - mwindow->theme->pane_h);
1724 pane[BOTTOM_LEFT_PANE]->resize_event(
1725 pane[BOTTOM_LEFT_PANE]->x,
1727 mwindow->theme->mcanvas_y,
1728 pane[BOTTOM_LEFT_PANE]->w,
1729 mwindow->theme->mcanvas_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 cursor_y - mwindow->theme->pane_h);
1736 pane[BOTTOM_RIGHT_PANE]->resize_event(
1737 pane[BOTTOM_RIGHT_PANE]->x,
1739 mwindow->theme->mcanvas_y,
1740 pane[BOTTOM_RIGHT_PANE]->w,
1741 mwindow->theme->mcanvas_h -
1746 void MWindowGUI::delete_y_pane(int cursor_y)
1748 if(cursor_y < mwindow->theme->mtimebar_h +
1750 pane[BOTTOM_LEFT_PANE])
1752 // give top pane coordinates of bottom pane
1753 mwindow->edl->local_session->track_start[TOP_LEFT_PANE] =
1754 mwindow->edl->local_session->track_start[BOTTOM_LEFT_PANE] -
1755 pane[BOTTOM_LEFT_PANE]->y;
1756 if(mwindow->edl->local_session->track_start[TOP_LEFT_PANE] < 0)
1757 mwindow->edl->local_session->track_start[TOP_LEFT_PANE] = 0;
1758 mwindow->edl->local_session->track_start[TOP_RIGHT_PANE] =
1759 mwindow->edl->local_session->track_start[TOP_LEFT_PANE];
1763 switch(total_panes())
1766 delete pane[BOTTOM_LEFT_PANE];
1767 pane[BOTTOM_LEFT_PANE] = 0;
1768 pane[TOP_LEFT_PANE]->resize_event(
1769 mwindow->theme->mcanvas_x,
1770 mwindow->theme->mcanvas_y,
1771 mwindow->theme->mcanvas_w,
1772 mwindow->theme->mcanvas_h);
1776 // delete bottom 2 panes
1778 delete pane[BOTTOM_LEFT_PANE];
1779 pane[BOTTOM_LEFT_PANE] = 0;
1780 delete pane[BOTTOM_RIGHT_PANE];
1781 pane[BOTTOM_RIGHT_PANE] = 0;
1782 pane[TOP_LEFT_PANE]->resize_event(
1783 pane[TOP_LEFT_PANE]->x,
1784 mwindow->theme->mcanvas_y,
1785 pane[TOP_LEFT_PANE]->w,
1786 mwindow->theme->mcanvas_h);
1787 pane[TOP_RIGHT_PANE]->resize_event(
1788 pane[TOP_RIGHT_PANE]->x,
1789 mwindow->theme->mcanvas_y,
1790 pane[TOP_RIGHT_PANE]->w,
1791 mwindow->theme->mcanvas_h);
1796 void MWindowGUI::stop_pane_drag()
1799 resource_thread->stop_draw(1);
1803 // cursor position relative to canvas
1804 int cursor_x = x_pane_drag->get_x() -
1806 BC_DisplayInfo::get_left_border() -
1807 mwindow->theme->mcanvas_x +
1808 mwindow->theme->pane_w;
1813 if(cursor_x >= mwindow->theme->patchbay_w + PANE_DRAG_MARGIN &&
1814 cursor_x < mwindow->theme->mcanvas_w -
1815 BC_ScrollBar::get_span(SCROLL_VERT) -
1818 create_x_pane(cursor_x);
1819 mwindow->edl->local_session->x_pane = cursor_x;
1824 delete_x_pane(cursor_x);
1825 mwindow->edl->local_session->x_pane = -1;
1833 // cursor position relative to canvas
1834 int cursor_y = y_pane_drag->get_y() -
1836 BC_DisplayInfo::get_top_border() -
1837 mwindow->theme->mcanvas_y +
1838 mwindow->theme->pane_h;
1844 if(cursor_y >= mwindow->theme->mtimebar_h +
1846 cursor_y < mwindow->theme->mcanvas_h -
1847 BC_ScrollBar::get_span(SCROLL_HORIZ) -
1850 create_y_pane(cursor_y);
1851 mwindow->edl->local_session->y_pane = cursor_y;
1855 delete_y_pane(cursor_y);
1856 mwindow->edl->local_session->y_pane = -1;
1860 update_pane_dividers();
1862 // required to get new widgets to appear
1864 resource_thread->start_draw();
1867 // create panes from EDL
1868 void MWindowGUI::load_panes()
1870 int need_x_panes = 0;
1871 int need_y_panes = 0;
1872 // use names from create functions
1873 int cursor_x = mwindow->edl->local_session->x_pane;
1874 int cursor_y = mwindow->edl->local_session->y_pane;
1876 resource_thread->stop_draw(1);
1878 mwindow->theme->patchbay_w + PANE_DRAG_MARGIN &&
1880 mwindow->theme->mcanvas_w -
1881 BC_ScrollBar::get_span(SCROLL_VERT) -
1888 mwindow->theme->mtimebar_h + PANE_DRAG_MARGIN &&
1890 mwindow->theme->mcanvas_h -
1891 BC_ScrollBar::get_span(SCROLL_HORIZ) -
1897 //printf("MWindowGUI::load_panes %d %d %d\n", __LINE__, need_x_panes, need_y_panes);
1905 if(total_panes() == 1)
1908 //printf("MWindowGUI::load_panes %d\n", __LINE__);
1909 pane[TOP_RIGHT_PANE] = new TimelinePane(mwindow,
1911 mwindow->theme->mcanvas_x +
1913 mwindow->theme->mcanvas_y,
1914 mwindow->theme->mcanvas_x +
1915 mwindow->theme->mcanvas_w -
1917 cursor_y - mwindow->theme->pane_h);
1918 pane[BOTTOM_LEFT_PANE] = new TimelinePane(mwindow,
1920 mwindow->theme->mcanvas_x,
1921 mwindow->theme->mcanvas_y +
1923 cursor_x - mwindow->theme->pane_w,
1924 mwindow->theme->mcanvas_h -
1926 pane[BOTTOM_RIGHT_PANE] = new TimelinePane(mwindow,
1928 pane[TOP_RIGHT_PANE]->x,
1929 mwindow->theme->mcanvas_y +
1931 pane[TOP_RIGHT_PANE]->w,
1932 mwindow->theme->mcanvas_h -
1934 pane[TOP_LEFT_PANE]->resize_event(
1935 pane[TOP_LEFT_PANE]->x,
1936 pane[TOP_LEFT_PANE]->y,
1937 cursor_x - mwindow->theme->pane_w,
1938 cursor_y - mwindow->theme->pane_h);
1939 pane[TOP_RIGHT_PANE]->create_objects();
1940 pane[BOTTOM_LEFT_PANE]->create_objects();
1941 pane[BOTTOM_RIGHT_PANE]->create_objects();
1944 if(horizontal_panes())
1946 // create vertical panes
1947 //printf("MWindowGUI::load_panes %d\n", __LINE__);
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]->resize_event(
1970 mwindow->theme->mcanvas_x +
1972 mwindow->theme->mcanvas_y,
1973 mwindow->theme->mcanvas_x +
1974 mwindow->theme->mcanvas_w -
1976 cursor_y - mwindow->theme->pane_h);
1977 pane[BOTTOM_LEFT_PANE]->create_objects();
1978 pane[BOTTOM_RIGHT_PANE]->create_objects();
1981 if(vertical_panes())
1983 // create horizontal panes
1984 //printf("MWindowGUI::load_panes %d\n", __LINE__);
1985 pane[TOP_RIGHT_PANE] = new TimelinePane(mwindow,
1987 mwindow->theme->mcanvas_x +
1989 mwindow->theme->mcanvas_y,
1990 mwindow->theme->mcanvas_x +
1991 mwindow->theme->mcanvas_w -
1993 cursor_y - mwindow->theme->pane_h);
1994 pane[BOTTOM_RIGHT_PANE] = new TimelinePane(mwindow,
1996 pane[TOP_RIGHT_PANE]->x,
1997 mwindow->theme->mcanvas_y +
1999 pane[TOP_RIGHT_PANE]->w,
2000 mwindow->theme->mcanvas_h -
2002 pane[TOP_LEFT_PANE]->resize_event(
2003 pane[TOP_LEFT_PANE]->x,
2004 pane[TOP_LEFT_PANE]->y,
2005 cursor_x - mwindow->theme->pane_w,
2006 cursor_y - mwindow->theme->pane_h);
2007 pane[BOTTOM_LEFT_PANE]->resize_event(
2008 pane[TOP_LEFT_PANE]->x,
2009 mwindow->theme->mcanvas_y +
2011 mwindow->theme->mcanvas_x +
2012 mwindow->theme->mcanvas_w -
2013 cursor_x - mwindow->theme->pane_w,
2014 mwindow->theme->mcanvas_h -
2016 pane[TOP_RIGHT_PANE]->create_objects();
2017 pane[BOTTOM_RIGHT_PANE]->create_objects();
2024 //printf("MWindowGUI::load_panes %d\n", __LINE__);
2025 pane[TOP_LEFT_PANE]->resize_event(
2026 pane[TOP_LEFT_PANE]->x,
2027 pane[TOP_LEFT_PANE]->y,
2028 cursor_x - mwindow->theme->pane_w,
2029 cursor_y - mwindow->theme->pane_h);
2030 pane[TOP_RIGHT_PANE]->resize_event(
2031 mwindow->theme->mcanvas_x +
2033 mwindow->theme->mcanvas_y,
2034 mwindow->theme->mcanvas_x +
2035 mwindow->theme->mcanvas_w -
2037 cursor_y - mwindow->theme->pane_h);
2038 pane[BOTTOM_LEFT_PANE]->resize_event(
2039 pane[TOP_LEFT_PANE]->x,
2040 mwindow->theme->mcanvas_y +
2042 mwindow->theme->mcanvas_x +
2043 mwindow->theme->mcanvas_w -
2044 cursor_x - mwindow->theme->pane_w,
2045 mwindow->theme->mcanvas_h -
2047 pane[BOTTOM_RIGHT_PANE]->resize_event(
2048 pane[TOP_RIGHT_PANE]->x,
2049 mwindow->theme->mcanvas_y +
2051 pane[TOP_RIGHT_PANE]->w,
2052 mwindow->theme->mcanvas_h -
2061 if(pane[BOTTOM_LEFT_PANE]) delete pane[BOTTOM_LEFT_PANE];
2062 if(pane[BOTTOM_RIGHT_PANE]) delete pane[BOTTOM_RIGHT_PANE];
2063 pane[BOTTOM_LEFT_PANE] = 0;
2064 pane[BOTTOM_RIGHT_PANE] = 0;
2066 if(!pane[TOP_RIGHT_PANE])
2068 pane[TOP_RIGHT_PANE] = new TimelinePane(mwindow,
2070 mwindow->theme->mcanvas_x +
2072 mwindow->theme->mcanvas_y,
2073 mwindow->theme->mcanvas_x +
2074 mwindow->theme->mcanvas_w -
2076 mwindow->theme->mcanvas_h);
2077 pane[TOP_LEFT_PANE]->resize_event(
2078 mwindow->theme->mcanvas_x,
2079 mwindow->theme->mcanvas_y,
2080 cursor_x - mwindow->theme->pane_w,
2081 mwindow->theme->mcanvas_h);
2082 pane[TOP_RIGHT_PANE]->create_objects();
2086 pane[TOP_LEFT_PANE]->resize_event(
2087 mwindow->theme->mcanvas_x,
2088 mwindow->theme->mcanvas_y,
2089 cursor_x - mwindow->theme->pane_w,
2090 mwindow->theme->mcanvas_h);
2091 pane[TOP_RIGHT_PANE]->resize_event(
2092 mwindow->theme->mcanvas_x +
2094 pane[TOP_RIGHT_PANE]->y,
2095 mwindow->theme->mcanvas_x +
2096 mwindow->theme->mcanvas_w -
2098 mwindow->theme->mcanvas_h);
2106 if(pane[TOP_RIGHT_PANE]) delete pane[TOP_RIGHT_PANE];
2107 if(pane[BOTTOM_RIGHT_PANE]) delete pane[BOTTOM_RIGHT_PANE];
2108 pane[TOP_RIGHT_PANE] = 0;
2109 pane[BOTTOM_RIGHT_PANE] = 0;
2111 if(!pane[BOTTOM_LEFT_PANE])
2113 //printf("MWindowGUI::load_panes %d\n", __LINE__);
2114 pane[BOTTOM_LEFT_PANE] = new TimelinePane(mwindow,
2116 mwindow->theme->mcanvas_x,
2117 mwindow->theme->mcanvas_y +
2119 mwindow->theme->mcanvas_w,
2120 mwindow->theme->mcanvas_h -
2122 pane[TOP_LEFT_PANE]->resize_event(
2123 mwindow->theme->mcanvas_x,
2124 mwindow->theme->mcanvas_y,
2125 mwindow->theme->mcanvas_w,
2126 pane[BOTTOM_LEFT_PANE]->y -
2127 mwindow->theme->mcanvas_y -
2128 mwindow->theme->pane_h);
2129 pane[BOTTOM_LEFT_PANE]->create_objects();
2133 pane[TOP_LEFT_PANE]->resize_event(
2134 mwindow->theme->mcanvas_x,
2135 mwindow->theme->mcanvas_y,
2136 mwindow->theme->mcanvas_w,
2137 cursor_y - mwindow->theme->pane_h);
2138 pane[BOTTOM_LEFT_PANE]->resize_event(
2139 pane[BOTTOM_LEFT_PANE]->x,
2141 mwindow->theme->mcanvas_y,
2142 mwindow->theme->mcanvas_w,
2143 mwindow->theme->mcanvas_h -
2150 if(pane[TOP_RIGHT_PANE]) delete pane[TOP_RIGHT_PANE];
2151 if(pane[BOTTOM_RIGHT_PANE]) delete pane[BOTTOM_RIGHT_PANE];
2152 if(pane[BOTTOM_LEFT_PANE]) delete pane[BOTTOM_LEFT_PANE];
2153 pane[TOP_RIGHT_PANE] = 0;
2154 pane[BOTTOM_RIGHT_PANE] = 0;
2155 pane[BOTTOM_LEFT_PANE] = 0;
2156 pane[TOP_LEFT_PANE]->resize_event(
2157 mwindow->theme->mcanvas_x,
2158 mwindow->theme->mcanvas_y,
2159 mwindow->theme->mcanvas_w,
2160 mwindow->theme->mcanvas_h);
2163 update_pane_dividers();
2166 resource_thread->start_draw();
2169 void MWindowGUI::update_pane_dividers()
2172 if(horizontal_panes() || total_panes() == 4)
2174 int x = pane[TOP_RIGHT_PANE]->x - mwindow->theme->pane_w;
2175 int y = mwindow->theme->mcanvas_y;
2176 int h = mwindow->theme->mcanvas_h;
2180 add_subwindow(x_divider = new PaneDivider(
2181 mwindow, x, y, h, 1));
2182 x_divider->create_objects();
2186 x_divider->reposition_window(x, y, h);
2199 if(vertical_panes() || total_panes() == 4)
2201 int x = mwindow->theme->mcanvas_x;
2202 int y = pane[BOTTOM_LEFT_PANE]->y -
2203 mwindow->theme->pane_h;
2204 int w = mwindow->theme->mcanvas_w;
2207 add_subwindow(y_divider = new PaneDivider(
2208 mwindow, x, y, w, 0));
2209 y_divider->create_objects();
2213 y_divider->reposition_window(x, y, w);
2227 void MWindowGUI::draw_samplemovement()
2234 update_scrollbars(1);
2237 void MWindowGUI::draw_trackmovement()
2239 update_scrollbars(0);
2246 PaneButton::PaneButton(MWindow *mwindow, int x, int y)
2247 : BC_Button(x, y, mwindow->theme->get_image_set("pane"))
2249 this->mwindow = mwindow;
2252 int PaneButton::cursor_motion_event()
2254 if(get_top_level()->get_button_down() &&
2256 get_status() == BUTTON_DOWNHI &&
2259 // printf("PaneButton::cursor_motion_event %d\n", __LINE__);
2261 if(get_cursor_x() < 0 && !mwindow->gui->dragging_pane)
2263 mwindow->gui->start_x_pane_drag();
2266 if(get_cursor_y() < 0 && !mwindow->gui->dragging_pane)
2268 mwindow->gui->start_y_pane_drag();
2272 mwindow->gui->handle_pane_drag();
2274 int result = BC_Button::cursor_motion_event();
2278 int PaneButton::button_release_event()
2280 mwindow->gui->stop_pane_drag();
2281 int result = BC_Button::button_release_event();
2286 FFMpegToggle::FFMpegToggle(MWindow *mwindow, MButtons *mbuttons, int x, int y)
2287 : BC_Toggle(x, y, mwindow->theme->ffmpeg_toggle,
2288 mwindow->preferences->get_file_probe_armed("FFMPEG_Early") > 0 ? 1 : 0)
2290 this->mwindow = mwindow;
2291 this->mbuttons = mbuttons;
2292 set_tooltip( !get_value() ? _("Try FFMpeg first") : _("Try FFMpeg last") );
2295 FFMpegToggle::~FFMpegToggle()
2299 int FFMpegToggle::handle_event()
2301 int ffmpeg_early_probe = get_value();
2302 set_tooltip( !ffmpeg_early_probe ? _("Try FFMpeg first") : _("Try FFMpeg last"));
2303 mwindow->preferences->set_file_probe_armed("FFMPEG_Early", ffmpeg_early_probe);
2304 mwindow->preferences->set_file_probe_armed("FFMPEG_Late", !ffmpeg_early_probe);
2306 mwindow->show_warning(&mwindow->preferences->warn_indexes,
2307 _("Changing the base codecs may require rebuilding indexes."));