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++)
125 cwindow_remote_handler = 0;
126 record_remote_handler = 0;
131 MWindowGUI::~MWindowGUI()
133 delete android_control;
134 delete cwindow_remote_handler;
135 delete record_remote_handler;
136 delete remote_control;
137 // delete samplescroll;
138 // delete trackscroll;
139 for(int i = 0; i < TOTAL_PANES; i++)
140 if(pane[i]) delete pane[i];
142 delete render_engine;
143 delete resource_thread;
144 resource_pixmaps.remove_all_objects();
155 void MWindowGUI::get_scrollbars(int flush)
157 //int64_t h_needed = mwindow->edl->get_tracks_height(mwindow->theme);
158 //int64_t w_needed = mwindow->edl->get_tracks_width();
159 int need_xscroll = 0;
160 int need_yscroll = 0;
161 view_w = mwindow->theme->mcanvas_w;
162 view_h = mwindow->theme->mcanvas_h;
164 // Scrollbars are constitutive
165 need_xscroll = need_yscroll = 1;
166 view_h = mwindow->theme->mcanvas_h;
167 view_w = mwindow->theme->mcanvas_w;
169 // for(int i = 0; i < 2; i++)
171 // if(w_needed > view_w)
174 // view_h = mwindow->theme->mcanvas_h - SCROLL_SPAN;
179 // if(h_needed > view_h)
182 // view_w = mwindow->theme->mcanvas_w - SCROLL_SPAN;
187 //printf("MWindowGUI::get_scrollbars 1\n");
189 if(canvas && (view_w != canvas->get_w() || view_h != canvas->get_h()))
191 canvas->reposition_window(mwindow->theme->mcanvas_x,
192 mwindow->theme->mcanvas_y,
200 add_subwindow(samplescroll = new SampleScroll(mwindow,
202 mwindow->theme->mhscroll_x,
203 mwindow->theme->mhscroll_y,
204 mwindow->theme->mhscroll_w));
206 samplescroll->resize_event();
208 samplescroll->set_position(0);
212 if(samplescroll) delete samplescroll;
214 mwindow->edl->local_session->view_start = 0;
220 //printf("MWindowGUI::get_scrollbars 1.1 %p %p\n", this, canvas);
222 add_subwindow(trackscroll = new TrackScroll(mwindow,
224 mwindow->theme->mvscroll_x,
225 mwindow->theme->mvscroll_y,
226 mwindow->theme->mvscroll_h));
228 trackscroll->resize_event();
231 //printf("MWindowGUI::get_scrollbars 1.2\n");
232 trackscroll->update_length(mwindow->edl->get_tracks_height(mwindow->theme),
233 mwindow->edl->local_session->track_start,
236 //printf("MWindowGUI::get_scrollbars 1.3\n");
240 if(trackscroll) delete trackscroll;
242 mwindow->edl->local_session->track_start = 0;
245 if(flush) this->flush();
250 void MWindowGUI::create_objects()
254 resource_thread = new ResourceThread(mwindow, this);
255 resource_thread->create_objects();
258 if(debug) printf("MWindowGUI::create_objects %d\n", __LINE__);
259 set_icon(mwindow->theme->get_image("mwindow_icon"));
260 remote_control = new RemoteControl(this);
261 cwindow_remote_handler = new CWindowRemoteHandler(remote_control);
262 record_remote_handler = new RecordRemoteHandler(remote_control);
263 mwindow->reset_android_remote();
265 if(debug) printf("MWindowGUI::create_objects %d\n", __LINE__);
267 int x = get_w() - MainShBtns::calculate_w(0);
268 add_subwindow(mainmenu = new MainMenu(mwindow, this, x));
269 mainmenu->create_objects();
270 add_subwindow(mainshbtns = new MainShBtns(mwindow, x, -1));
271 mainshbtns->load(mwindow->preferences);
272 mwindow->theme->get_mwindow_sizes(this, get_w(), get_h());
273 mwindow->theme->draw_mwindow_bg(this);
274 if(debug) printf("MWindowGUI::create_objects %d\n", __LINE__);
276 add_subwindow(mbuttons = new MButtons(mwindow, this));
277 mbuttons->create_objects();
278 add_subwindow(ffmpeg_toggle = new FFMpegToggle(mwindow, mbuttons, menu_w(), menu_h()+2));
280 pane[TOP_LEFT_PANE] = new TimelinePane(mwindow,
282 mwindow->theme->mcanvas_x,
283 mwindow->theme->mcanvas_y,
284 mwindow->theme->mcanvas_w,
285 mwindow->theme->mcanvas_h);
286 pane[TOP_LEFT_PANE]->create_objects();
288 // add_subwindow(timebar = new MTimeBar(mwindow,
290 // mwindow->theme->mtimebar_x,
291 // mwindow->theme->mtimebar_y,
292 // mwindow->theme->mtimebar_w,
293 // mwindow->theme->mtimebar_h));
294 // timebar->create_objects();
296 // if(debug) printf("MWindowGUI::create_objects %d\n", __LINE__);
297 // add_subwindow(patchbay = new PatchBay(mwindow, this));
298 // patchbay->create_objects();
300 // if(debug) printf("MWindowGUI::create_objects %d\n", __LINE__);
301 // get_scrollbars(0);
303 // if(debug) printf("MWindowGUI::create_objects %d\n", __LINE__);
304 // mwindow->gui->add_subwindow(canvas = new TrackCanvas(mwindow, this));
305 // canvas->create_objects();
308 if(debug) printf("MWindowGUI::create_objects %d\n", __LINE__);
309 add_subwindow(zoombar = new ZoomBar(mwindow, this));
310 zoombar->create_objects();
313 if(debug) printf("MWindowGUI::create_objects %d\n", __LINE__);
314 add_subwindow(statusbar = new StatusBar(mwindow, this));
315 statusbar->create_objects();
319 if(debug) printf("MWindowGUI::create_objects %d\n", __LINE__);
320 add_subwindow(mainclock = new MainClock(mwindow,
321 mwindow->theme->mclock_x,
322 mwindow->theme->mclock_y,
323 mwindow->theme->mclock_w));
324 mainclock->set_position_offset( (double)
325 (mwindow->edl->session->get_frame_offset() /
326 mwindow->edl->session->frame_rate));
327 if(debug) printf("MWindowGUI::create_objects %d\n", __LINE__);
328 mainclock->update(0);
332 // if(debug) printf("MWindowGUI::create_objects %d\n", __LINE__);
333 // cursor = new MainCursor(mwindow, this);
334 // cursor->create_objects();
337 if(debug) printf("MWindowGUI::create_objects %d\n", __LINE__);
338 add_subwindow(edit_menu = new EditPopup(mwindow, this));
339 edit_menu->create_objects();
342 if(debug) printf("MWindowGUI::create_objects %d\n", __LINE__);
343 add_subwindow(plugin_menu = new PluginPopup(mwindow, this));
344 plugin_menu->create_objects();
347 if(debug) printf("MWindowGUI::create_objects %d\n", __LINE__);
348 add_subwindow(keyframe_menu = new KeyframePopup(mwindow, this));
349 keyframe_menu->create_objects();
350 add_subwindow(keyframe_hide = new KeyframeHidePopup(mwindow, this));
351 keyframe_hide->create_objects();
354 if(debug) printf("MWindowGUI::create_objects %d\n", __LINE__);
355 add_subwindow(transition_menu = new TransitionPopup(mwindow, this));
356 transition_menu->create_objects();
359 channel_info = new ChannelInfo(mwindow);
361 db_window = new DbWindow(mwindow);
362 swindow = new SWindow(mwindow);
364 if(debug) printf("MWindowGUI::create_objects %d\n", __LINE__);
366 add_subwindow(pane_button = new PaneButton(mwindow,
367 get_w() - mwindow->theme->get_image_set("pane")[0]->get_w(),
368 mwindow->theme->mzoom_y + 1 - mwindow->theme->get_image_set("pane")[0]->get_h()));
370 pane[TOP_LEFT_PANE]->canvas->activate();
372 if(debug) printf("MWindowGUI::create_objects %d\n", __LINE__);
375 void MWindowGUI::redraw_time_dependancies()
377 zoombar->redraw_time_dependancies();
378 for(int i = 0; i < TOTAL_PANES; i++)
379 if(pane[i] && pane[i]->timebar) pane[i]->timebar->update(0);
380 mainclock->update(mwindow->edl->local_session->get_selectionstart(1));
383 int MWindowGUI::focus_in_event()
385 for(int i = 0; i < TOTAL_PANES; i++)
386 if(pane[i]) pane[i]->cursor->focus_in_event();
390 int MWindowGUI::focus_out_event()
392 for(int i = 0; i < TOTAL_PANES; i++)
393 if(pane[i]) pane[i]->cursor->focus_out_event();
398 int MWindowGUI::resize_event(int w, int h)
400 //printf("MWindowGUI::resize_event %d\n", __LINE__);
401 mwindow->session->mwindow_w = w;
402 mwindow->session->mwindow_h = h;
403 int x = w - MainShBtns::calculate_w(0);
404 mainmenu->resize_event(x, mainmenu->get_h());
405 mainshbtns->reposition_window(x, -1);
406 mwindow->theme->get_mwindow_sizes(this, w, h);
407 mwindow->theme->draw_mwindow_bg(this);
408 mbuttons->resize_event();
409 ffmpeg_toggle->reposition_window(menu_w(), menu_h()+2);
410 statusbar->resize_event();
411 zoombar->resize_event();
413 resource_thread->stop_draw(1);
415 if(total_panes() > 1)
417 if(horizontal_panes())
419 // printf("MWindowGUI::resize_event %d %d %d\n",
421 // pane[TOP_RIGHT_PANE]->x,
422 // mwindow->theme->mcanvas_w -
423 // BC_ScrollBar::get_span(SCROLL_VERT) -
424 // PANE_DRAG_MARGIN);
425 if(pane[TOP_RIGHT_PANE]->x >= mwindow->theme->mcanvas_w -
426 BC_ScrollBar::get_span(SCROLL_VERT) -
429 delete_x_pane(pane[TOP_RIGHT_PANE]->x);
430 mwindow->edl->local_session->x_pane = -1;
436 if(pane[BOTTOM_LEFT_PANE]->y >= mwindow->theme->mzoom_y -
437 BC_ScrollBar::get_span(SCROLL_HORIZ) -
440 delete_y_pane(pane[BOTTOM_LEFT_PANE]->y);
441 mwindow->edl->local_session->y_pane = -1;
446 if(pane[TOP_RIGHT_PANE]->x >= mwindow->theme->mcanvas_w -
447 BC_ScrollBar::get_span(SCROLL_VERT) -
450 delete_x_pane(pane[TOP_RIGHT_PANE]->x);
451 mwindow->edl->local_session->x_pane = -1;
454 if(pane[BOTTOM_LEFT_PANE]->y >= mwindow->theme->mzoom_y -
455 BC_ScrollBar::get_span(SCROLL_HORIZ) -
458 delete_y_pane(pane[BOTTOM_LEFT_PANE]->y);
459 mwindow->edl->local_session->y_pane = -1;
464 if(total_panes() == 1)
466 pane[TOP_LEFT_PANE]->resize_event(
467 mwindow->theme->mcanvas_x,
468 mwindow->theme->mcanvas_y,
469 mwindow->theme->mcanvas_w,
470 mwindow->theme->mcanvas_h);
473 if(horizontal_panes())
475 pane[TOP_LEFT_PANE]->resize_event(
476 pane[TOP_LEFT_PANE]->x,
477 pane[TOP_LEFT_PANE]->y,
478 pane[TOP_LEFT_PANE]->w,
479 mwindow->theme->mcanvas_h);
480 pane[TOP_RIGHT_PANE]->resize_event(
481 pane[TOP_RIGHT_PANE]->x,
482 pane[TOP_RIGHT_PANE]->y,
483 mwindow->theme->mcanvas_w - pane[TOP_RIGHT_PANE]->x,
484 mwindow->theme->mcanvas_h);
489 pane[TOP_LEFT_PANE]->resize_event(
490 pane[TOP_LEFT_PANE]->x,
491 pane[TOP_LEFT_PANE]->y,
492 mwindow->theme->mcanvas_w,
493 pane[TOP_LEFT_PANE]->h);
494 pane[BOTTOM_LEFT_PANE]->resize_event(
495 pane[BOTTOM_LEFT_PANE]->x,
496 pane[BOTTOM_LEFT_PANE]->y,
497 mwindow->theme->mcanvas_w,
498 mwindow->theme->mcanvas_y +
499 mwindow->theme->mcanvas_h -
500 pane[BOTTOM_LEFT_PANE]->y);
504 pane[TOP_LEFT_PANE]->resize_event(
505 pane[TOP_LEFT_PANE]->x,
506 pane[TOP_LEFT_PANE]->y,
507 pane[TOP_LEFT_PANE]->w,
508 pane[TOP_LEFT_PANE]->h);
509 pane[TOP_RIGHT_PANE]->resize_event(
510 pane[TOP_RIGHT_PANE]->x,
511 pane[TOP_RIGHT_PANE]->y,
512 mwindow->theme->mcanvas_w - pane[TOP_RIGHT_PANE]->x,
513 pane[TOP_RIGHT_PANE]->h);
514 pane[BOTTOM_LEFT_PANE]->resize_event(
515 pane[BOTTOM_LEFT_PANE]->x,
516 pane[BOTTOM_LEFT_PANE]->y,
517 pane[BOTTOM_LEFT_PANE]->w,
518 mwindow->theme->mcanvas_y +
519 mwindow->theme->mcanvas_h -
520 pane[BOTTOM_LEFT_PANE]->y);
521 pane[BOTTOM_RIGHT_PANE]->resize_event(
522 pane[BOTTOM_RIGHT_PANE]->x,
523 pane[BOTTOM_RIGHT_PANE]->y,
524 mwindow->theme->mcanvas_w -
525 pane[BOTTOM_RIGHT_PANE]->x,
526 mwindow->theme->mcanvas_y +
527 mwindow->theme->mcanvas_h -
528 pane[BOTTOM_RIGHT_PANE]->y);
531 update_pane_dividers();
532 pane_button->reposition_window(w - mwindow->theme->get_image_set("pane")[0]->get_w(),
533 mwindow->theme->mzoom_y + 1 - mwindow->theme->get_image_set("pane")[0]->get_h());
534 resource_thread->start_draw();
539 int MWindowGUI::total_panes()
542 for(int i = 0; i < TOTAL_PANES; i++)
547 int MWindowGUI::vertical_panes()
549 return total_panes() == 2 &&
550 pane[TOP_LEFT_PANE] &&
551 pane[BOTTOM_LEFT_PANE];
554 int MWindowGUI::horizontal_panes()
556 return total_panes() == 2 &&
557 pane[TOP_LEFT_PANE] &&
558 pane[TOP_RIGHT_PANE];
561 TimelinePane* MWindowGUI::get_focused_pane()
563 if(pane[focused_pane]) return pane[focused_pane];
564 for(int i = 0; i < TOTAL_PANES; i++)
566 if(pane[i]) return pane[i];
571 void MWindowGUI::activate_timeline()
573 if(pane[focused_pane])
575 pane[focused_pane]->activate();
579 for(int i = 0; i < TOTAL_PANES; i++)
590 void MWindowGUI::deactivate_timeline()
592 for(int i = 0; i < TOTAL_PANES; i++)
596 pane[i]->canvas->deactivate();
601 void MWindowGUI::update_title(char *path)
604 char filename[BCTEXTLEN], string[BCTEXTLEN];
605 fs.extract_name(filename, path);
606 sprintf(string, _(PROGRAM_NAME ": %s"), filename);
608 //printf("MWindowGUI::update_title %s\n", string);
612 void MWindowGUI::draw_overlays(int flash_it)
614 for(int i = 0; i < TOTAL_PANES; i++)
618 pane[i]->canvas->draw_overlays();
619 if(flash_it) pane[i]->canvas->flash();
624 void MWindowGUI::update_timebar(int flush_it)
626 for(int i = 0; i < TOTAL_PANES; i++)
628 if(pane[i] && pane[i]->timebar)
630 pane[i]->timebar->update(flush_it);
635 void MWindowGUI::update_timebar_highlights()
637 for(int i = 0; i < TOTAL_PANES; i++)
639 if(pane[i] && pane[i]->timebar)
641 pane[i]->timebar->update_highlights();
647 void MWindowGUI::update_patchbay()
649 for(int i = 0; i < TOTAL_PANES; i++)
651 if(pane[i] && pane[i]->patchbay)
653 pane[i]->patchbay->update();
658 void MWindowGUI::draw_indexes(Indexable *indexable)
660 for(int i = 0; i < TOTAL_PANES; i++)
664 pane[i]->canvas->draw_indexes(indexable);
669 void MWindowGUI::draw_canvas(int mode /* = 0 */, int hide_cursor /* = 1 */)
671 if(mode != IGNORE_THREAD)
673 resource_thread->stop_draw(1);
677 for(int i = 0; i < TOTAL_PANES; i++)
681 pane[i]->canvas->draw(mode, hide_cursor);
686 if(mode != IGNORE_THREAD)
688 resource_thread->start_draw();
693 void MWindowGUI::flash_canvas(int flush)
695 for(int i = 0; i < TOTAL_PANES; i++)
699 pane[i]->canvas->flash(flush);
704 void MWindowGUI::draw_cursor(int do_plugintoggles)
706 for(int i = 0; i < TOTAL_PANES; i++)
710 pane[i]->cursor->draw(do_plugintoggles);
715 void MWindowGUI::show_cursor(int do_plugintoggles)
717 for(int i = 0; i < TOTAL_PANES; i++)
721 pane[i]->cursor->show(do_plugintoggles);
726 void MWindowGUI::hide_cursor(int do_plugintoggles)
728 for(int i = 0; i < TOTAL_PANES; i++)
732 pane[i]->cursor->hide(do_plugintoggles);
737 void MWindowGUI::update_cursor()
739 for(int i = 0; i < TOTAL_PANES; i++)
743 pane[i]->cursor->update();
748 void MWindowGUI::set_playing_back(int value)
750 for(int i = 0; i < TOTAL_PANES; i++)
754 pane[i]->cursor->playing_back = value;
759 void MWindowGUI::update_plugintoggles()
761 for(int i = 0; i < TOTAL_PANES; i++)
765 pane[i]->canvas->refresh_plugintoggles();
771 void MWindowGUI::update_scrollbars(int flush)
773 for(int i = 0; i < TOTAL_PANES; i++)
777 pane[i]->update(1, 0, 0, 0);
780 if(flush) this->flush();
783 void MWindowGUI::reset_meters()
785 for(int i = 0; i < TOTAL_PANES; i++)
787 if(pane[i] && pane[i]->patchbay)
789 pane[i]->patchbay->reset_meters();
794 void MWindowGUI::stop_meters()
796 for(int i = 0; i < TOTAL_PANES; i++)
798 if(pane[i] && pane[i]->patchbay)
800 pane[i]->patchbay->stop_meters();
805 void MWindowGUI::update_meters(ArrayList<double> *module_levels)
807 for(int i = 0; i < TOTAL_PANES; i++)
809 if(pane[i] && pane[i]->patchbay)
811 pane[i]->patchbay->update_meters(module_levels);
816 void MWindowGUI::set_editing_mode(int flush)
818 for(int i = 0; i < TOTAL_PANES; i++)
822 pane[i]->canvas->update_cursor(flush);
827 void MWindowGUI::set_meter_format(int mode, int min, int max)
829 for(int i = 0; i < TOTAL_PANES; i++)
831 if(pane[i] && pane[i]->patchbay)
833 pane[i]->patchbay->set_meter_format(mode, min, max);
838 void MWindowGUI::update(int scrollbars,
847 if(debug) PRINT_TRACE
851 mwindow->edl->tracks->update_y_pixels(mwindow->theme);
853 if(do_canvas && do_canvas != IGNORE_THREAD)
855 resource_thread->stop_draw(1);
858 for(int i = 0; i < TOTAL_PANES; i++)
860 if(pane[i]) pane[i]->update(scrollbars,
866 if(do_canvas && do_canvas != IGNORE_THREAD)
868 resource_thread->start_draw();
871 // if(scrollbars) this->get_scrollbars(0);
872 // if(timebar) this->timebar->update(0);
873 if(zoombar) this->zoombar->update();
874 // if(patchbay) this->patchbay->update();
875 if(clock) this->mainclock->update(
876 mwindow->edl->local_session->get_selectionstart(1));
877 if(debug) PRINT_TRACE
883 // this->canvas->draw(do_canvas);
884 // this->cursor->show();
885 // this->canvas->flash(0);
886 // Activate causes the menubar to deactivate. Don't want this for
888 // if(canvas != IGNORE_THREAD) this->canvas->activate();
890 if(debug) PRINT_TRACE
894 if(buttonbar) mbuttons->update();
895 if(debug) PRINT_TRACE
897 // Can't age if the cache called this to draw missing picons
898 // or the GUI is updating the status of the draw toggle.
899 if(do_canvas != FORCE_REDRAW && do_canvas != IGNORE_THREAD)
902 mwindow->age_caches();
903 lock_window("MWindowGUI::update");
907 if(debug) PRINT_TRACE
910 int MWindowGUI::visible(int64_t x1, int64_t x2, int64_t view_x1, int64_t view_x2)
912 return (x1 >= view_x1 && x1 < view_x2) ||
913 (x2 > view_x1 && x2 <= view_x2) ||
914 (x1 <= view_x1 && x2 >= view_x2);
918 int MWindowGUI::show_message(char *message, int color)
920 // printf("MWindowGUI::show_message %d: %s 0x%08x 0x%08x\n",
921 // __LINE__, message, color, mwindow->theme->message_normal);
922 if(color < 0) color = mwindow->theme->message_normal;
923 statusbar->status_text->set_color(color);
924 statusbar->status_text->update(message);
929 // Drag motion called from other window
930 int MWindowGUI::drag_motion()
932 if(get_hidden()) return 0;
934 Track *over_track = 0;
936 PluginSet *over_pluginset = 0;
937 Plugin *over_plugin = 0;
942 drag_popup->cursor_motion_event();
946 // there's no point in drawing highlights has until drag operation has been set
947 if (!mwindow->session->current_operation)
950 for(int i = 0; i < TOTAL_PANES; i++)
952 if(pane[i]) pane[i]->canvas->drag_motion(
959 if(mwindow->session->track_highlighted != over_track)
961 mwindow->session->track_highlighted = over_track;
965 if(mwindow->session->edit_highlighted != over_edit)
967 mwindow->session->edit_highlighted = over_edit;
971 if(mwindow->session->pluginset_highlighted != over_pluginset)
973 mwindow->session->pluginset_highlighted = over_pluginset;
977 if(mwindow->session->plugin_highlighted != over_plugin)
979 mwindow->session->plugin_highlighted = over_plugin;
983 if( mwindow->session->current_operation == DRAG_ASSET ||
984 mwindow->session->current_operation == DRAG_EDIT ||
985 mwindow->session->current_operation == DRAG_AEFFECT_COPY ||
986 mwindow->session->current_operation == DRAG_VEFFECT_COPY )
992 // printf("drag_motion %d %d over_track=%p over_edit=%p\n",
999 lock_window("MWindowGUI::drag_motion");
1006 int MWindowGUI::drag_stop()
1008 if(get_hidden()) return 0;
1009 int result = 0, redraw = 0;
1011 for(int i = 0; i < TOTAL_PANES; i++)
1013 if(pane[i]) result |= pane[i]->canvas->drag_stop(
1016 mwindow->edl->optimize();
1018 // since we don't have subwindows we have to terminate any drag operation
1021 if (mwindow->session->track_highlighted
1022 || mwindow->session->edit_highlighted
1023 || mwindow->session->plugin_highlighted
1024 || mwindow->session->pluginset_highlighted)
1026 mwindow->session->track_highlighted = 0;
1027 mwindow->session->edit_highlighted = 0;
1028 mwindow->session->plugin_highlighted = 0;
1029 mwindow->session->pluginset_highlighted = 0;
1030 mwindow->session->current_operation = NO_OPERATION;
1034 //printf("TrackCanvas::drag_stop %d %d\n", redraw, mwindow->session->current_operation);
1037 mwindow->edl->tracks->update_y_pixels(mwindow->theme);
1038 update_scrollbars(0);
1053 void MWindowGUI::default_positions()
1055 //printf("MWindowGUI::default_positions 1\n");
1056 VWindow *vwindow = mwindow->vwindows.size() > DEFAULT_VWINDOW ?
1057 mwindow->vwindows.get(0) : 0;
1058 if( vwindow ) vwindow->gui->lock_window("MWindowGUI::default_positions");
1059 mwindow->cwindow->gui->lock_window("MWindowGUI::default_positions");
1060 mwindow->awindow->gui->lock_window("MWindowGUI::default_positions");
1062 // printf("MWindowGUI::default_positions 1 %d %d %d %d\n", mwindow->session->vwindow_x,
1063 // mwindow->session->vwindow_y,
1064 // mwindow->session->vwindow_w,
1065 // mwindow->session->vwindow_h);
1066 reposition_window(mwindow->session->mwindow_x,
1067 mwindow->session->mwindow_y,
1068 mwindow->session->mwindow_w,
1069 mwindow->session->mwindow_h);
1070 if( vwindow ) vwindow->gui->reposition_window(mwindow->session->vwindow_x,
1071 mwindow->session->vwindow_y,
1072 mwindow->session->vwindow_w,
1073 mwindow->session->vwindow_h);
1074 mwindow->cwindow->gui->reposition_window(mwindow->session->cwindow_x,
1075 mwindow->session->cwindow_y,
1076 mwindow->session->cwindow_w,
1077 mwindow->session->cwindow_h);
1078 mwindow->awindow->gui->reposition_window(mwindow->session->awindow_x,
1079 mwindow->session->awindow_y,
1080 mwindow->session->awindow_w,
1081 mwindow->session->awindow_h);
1082 //printf("MWindowGUI::default_positions 1\n");
1084 resize_event(mwindow->session->mwindow_w,
1085 mwindow->session->mwindow_h);
1086 //printf("MWindowGUI::default_positions 1\n");
1087 if( vwindow ) vwindow->gui->resize_event(mwindow->session->vwindow_w,
1088 mwindow->session->vwindow_h);
1089 //printf("MWindowGUI::default_positions 1\n");
1090 mwindow->cwindow->gui->resize_event(mwindow->session->cwindow_w,
1091 mwindow->session->cwindow_h);
1092 //printf("MWindowGUI::default_positions 1\n");
1093 mwindow->awindow->gui->resize_event(mwindow->session->awindow_w,
1094 mwindow->session->awindow_h);
1096 //printf("MWindowGUI::default_positions 1\n");
1099 if( vwindow ) vwindow->gui->flush();
1100 mwindow->cwindow->gui->flush();
1101 mwindow->awindow->gui->flush();
1103 if( vwindow ) vwindow->gui->unlock_window();
1104 mwindow->cwindow->gui->unlock_window();
1105 mwindow->awindow->gui->unlock_window();
1106 //printf("MWindowGUI::default_positions 2\n");
1125 int MWindowGUI::repeat_event(int64_t duration)
1127 // if(duration == 100)
1128 // mwindow->sync_parameters(CHANGE_ALL);
1130 for(int i = 0; i < TOTAL_PANES; i++)
1132 if(pane[i]) result = pane[i]->cursor->repeat_event(duration);
1138 int MWindowGUI::translation_event()
1140 //printf("MWindowGUI::translation_event 1 %d %d\n", get_x(), get_y());
1141 mwindow->session->mwindow_x = get_x();
1142 mwindow->session->mwindow_y = get_y();
1147 int MWindowGUI::save_defaults(BC_Hash *defaults)
1149 defaults->update("MWINDOWWIDTH", get_w());
1150 defaults->update("MWINDOWHEIGHT", get_h());
1151 mainmenu->save_defaults(defaults);
1152 BC_WindowBase::save_defaults(defaults);
1156 int MWindowGUI::keypress_event()
1158 //printf("MWindowGUI::keypress_event 1 %d\n", get_keypress());
1159 int result = mbuttons->keypress_event();
1160 if( result ) return result;
1162 switch(get_keypress()) {
1164 mwindow->toggle_editing_mode();
1168 case '1': case '2': case '3': case '4':
1169 case '5': case '6': case '7': case '8':
1170 if( !alt_down() || shift_down() ) break;
1171 if( !mwindow->select_asset(get_keypress()-'1',1) )
1176 if( !ctrl_down() ) {
1179 mbuttons->transport->handle_transport(STOP, 1, 0, 0);
1180 lock_window("MWindowGUI::keypress_event 1");
1181 mwindow->prev_edit_handle(shift_down());
1184 mwindow->move_left();
1190 if( !ctrl_down() ) {
1193 mbuttons->transport->handle_transport(STOP, 1, 0, 0);
1194 lock_window("MWindowGUI::keypress_event 2");
1195 mwindow->next_edit_handle(shift_down());
1198 mwindow->move_right();
1204 if( ctrl_down() && !alt_down() )
1205 mwindow->expand_y();
1206 else if( !ctrl_down() && alt_down() )
1207 mwindow->expand_autos(0,1,1);
1208 else if( ctrl_down() && alt_down() )
1209 mwindow->expand_autos(1,1,1);
1211 mwindow->expand_sample();
1216 if( ctrl_down() && !alt_down() )
1217 mwindow->zoom_in_y();
1218 else if( !ctrl_down() && alt_down() )
1219 mwindow->shrink_autos(0,1,1);
1220 else if( ctrl_down() && alt_down() )
1221 mwindow->shrink_autos(1,1,1);
1223 mwindow->zoom_in_sample();
1231 mwindow->expand_t();
1237 mwindow->move_down();
1239 mwindow->zoom_in_t();
1245 Track *this_track = 0;
1246 for( int i=0; i<TOTAL_PANES; ++i ) {
1247 if( !pane[i] ) continue;
1248 if( (this_track = pane[i]->over_track()) != 0 ) break;
1249 if( (this_track = pane[i]->over_patchbay()) != 0 ) break;
1252 if( get_keypress() == TAB ) { // Switch the record button
1254 this_track->record = !this_track->record ? 1 : 0;
1257 int total_selected = mwindow->edl->tracks->total_of(Tracks::RECORD);
1258 // all selected if nothing previously selected or
1259 // if this patch was previously the only one selected and armed
1260 int selected = !total_selected || (total_selected == 1 &&
1261 this_track && this_track->record ) ? 1 : 0;
1262 mwindow->edl->tracks->select_all(Tracks::RECORD, selected);
1263 if( !selected && this_track ) this_track->record = 1;
1266 update(0, 1, 0, 0, 1, 0, 1);
1268 mwindow->cwindow->update(0, 1, 1);
1269 lock_window("TrackCanvas::keypress_event 3");
1275 // since things under cursor have changed...
1277 cursor_motion_event();
1283 int MWindowGUI::keyboard_listener(BC_WindowBase *wp)
1285 return key_listener(wp->get_keypress());
1288 int MWindowGUI::key_listener(int key)
1293 if( !record->running() )
1296 record->record_gui->interrupt_thread->start(0);
1303 channel_info->toggle_scan();
1307 if( !remote_control->deactivate() )
1308 remote_control->activate();
1318 void MWindowGUI::use_android_remote(int on)
1321 delete android_control;
1322 android_control = 0;
1325 if( android_control ) return;
1326 android_control = new AndroidControl(this);
1329 int MWindowGUI::close_event()
1335 void MWindowGUI::stop_drawing()
1337 resource_thread->stop_draw(1);
1340 int MWindowGUI::menu_w()
1342 return mainmenu->get_w();
1345 int MWindowGUI::menu_h()
1347 return mainmenu->get_h();
1350 void MWindowGUI::start_x_pane_drag()
1354 x_pane_drag = new BC_Popup(this,
1355 get_abs_cursor_x(0) - mwindow->theme->pane_w,
1356 BC_DisplayInfo::get_top_border() +
1358 mwindow->theme->mcanvas_y,
1359 mwindow->theme->pane_w,
1360 mwindow->theme->mcanvas_h,
1361 mwindow->theme->drag_pane_color);
1362 x_pane_drag->draw_3segmentv(0,
1364 x_pane_drag->get_h(),
1365 mwindow->theme->get_image_set("xpane")[BUTTON_DOWNHI]);
1366 x_pane_drag->flash(1);
1371 void MWindowGUI::start_y_pane_drag()
1375 //printf("MWindowGUI::start_y_pane_drag %d %d %d\n", __LINE__, get_x(), get_y());
1376 y_pane_drag = new BC_Popup(this,
1377 BC_DisplayInfo::get_left_border() +
1379 mwindow->theme->mcanvas_x,
1380 get_abs_cursor_y(0) - mwindow->theme->pane_h,
1381 mwindow->theme->mcanvas_w,
1382 mwindow->theme->pane_h,
1383 mwindow->theme->drag_pane_color);
1384 y_pane_drag->draw_3segmenth(0,
1386 y_pane_drag->get_w(),
1387 mwindow->theme->get_image_set("ypane")[BUTTON_DOWNHI]);
1388 y_pane_drag->flash(1);
1393 void MWindowGUI::handle_pane_drag()
1399 x_pane_drag->reposition_window(
1400 get_abs_cursor_x(0) - mwindow->theme->pane_w,
1401 x_pane_drag->get_y());
1406 y_pane_drag->reposition_window(
1407 y_pane_drag->get_x(),
1408 get_abs_cursor_y(0) - mwindow->theme->pane_h);
1414 void MWindowGUI::create_x_pane(int cursor_x)
1416 if(total_panes() == 1)
1418 // create a horizontal pane
1419 // do this 1st so the resize_event knows there are 2 panes
1420 mwindow->edl->local_session->view_start[TOP_RIGHT_PANE] =
1421 mwindow->edl->local_session->view_start[TOP_LEFT_PANE] +
1423 mwindow->theme->patchbay_w;
1424 pane[TOP_RIGHT_PANE] = new TimelinePane(mwindow,
1426 mwindow->theme->mcanvas_x +
1428 mwindow->theme->mcanvas_y,
1429 mwindow->theme->mcanvas_x +
1430 mwindow->theme->mcanvas_w -
1432 mwindow->theme->mcanvas_h);
1433 pane[TOP_LEFT_PANE]->resize_event(
1434 mwindow->theme->mcanvas_x,
1435 mwindow->theme->mcanvas_y,
1436 cursor_x - mwindow->theme->pane_w,
1437 mwindow->theme->mcanvas_h);
1438 pane[TOP_RIGHT_PANE]->create_objects();
1441 if(vertical_panes())
1443 // create 2 horizontal panes
1444 mwindow->edl->local_session->track_start[TOP_RIGHT_PANE] =
1445 mwindow->edl->local_session->track_start[TOP_LEFT_PANE];
1446 mwindow->edl->local_session->track_start[BOTTOM_RIGHT_PANE] =
1447 mwindow->edl->local_session->track_start[BOTTOM_LEFT_PANE];
1448 mwindow->edl->local_session->view_start[TOP_RIGHT_PANE] =
1449 mwindow->edl->local_session->view_start[BOTTOM_RIGHT_PANE] =
1450 mwindow->edl->local_session->view_start[TOP_LEFT_PANE] +
1452 mwindow->theme->patchbay_w;
1453 pane[TOP_RIGHT_PANE] = new TimelinePane(mwindow,
1455 mwindow->theme->mcanvas_x +
1457 pane[TOP_LEFT_PANE]->y,
1458 mwindow->theme->mcanvas_x +
1459 mwindow->theme->mcanvas_w -
1461 pane[TOP_LEFT_PANE]->h);
1462 pane[BOTTOM_RIGHT_PANE] = new TimelinePane(mwindow,
1464 mwindow->theme->mcanvas_x +
1466 pane[BOTTOM_LEFT_PANE]->y,
1467 mwindow->theme->mcanvas_x +
1468 mwindow->theme->mcanvas_w -
1470 pane[BOTTOM_LEFT_PANE]->h);
1471 pane[TOP_LEFT_PANE]->resize_event(
1472 pane[TOP_LEFT_PANE]->x,
1473 pane[TOP_LEFT_PANE]->y,
1474 cursor_x - mwindow->theme->pane_w,
1475 pane[TOP_LEFT_PANE]->h);
1476 pane[BOTTOM_LEFT_PANE]->resize_event(
1477 pane[BOTTOM_LEFT_PANE]->x,
1478 pane[BOTTOM_LEFT_PANE]->y,
1479 cursor_x - mwindow->theme->pane_w,
1480 pane[BOTTOM_LEFT_PANE]->h);
1481 pane[TOP_RIGHT_PANE]->create_objects();
1482 pane[BOTTOM_RIGHT_PANE]->create_objects();
1485 if(horizontal_panes())
1487 // resize a horizontal pane
1488 mwindow->edl->local_session->view_start[TOP_RIGHT_PANE] +=
1490 pane[TOP_RIGHT_PANE]->x;
1491 if(mwindow->edl->local_session->view_start[TOP_RIGHT_PANE] < 0)
1492 mwindow->edl->local_session->view_start[TOP_RIGHT_PANE] = 0;
1493 pane[TOP_LEFT_PANE]->resize_event(
1494 mwindow->theme->mcanvas_x,
1495 mwindow->theme->mcanvas_y,
1496 cursor_x - mwindow->theme->pane_w,
1497 mwindow->theme->mcanvas_h);
1498 pane[TOP_RIGHT_PANE]->resize_event(
1499 mwindow->theme->mcanvas_x +
1501 pane[TOP_RIGHT_PANE]->y,
1502 mwindow->theme->mcanvas_x +
1503 mwindow->theme->mcanvas_w -
1505 mwindow->theme->mcanvas_h);
1509 // resize 2 horizontal panes
1510 mwindow->edl->local_session->view_start[TOP_RIGHT_PANE] +=
1512 pane[TOP_RIGHT_PANE]->x;
1513 if(mwindow->edl->local_session->view_start[TOP_RIGHT_PANE] < 0)
1514 mwindow->edl->local_session->view_start[TOP_RIGHT_PANE] = 0;
1515 mwindow->edl->local_session->view_start[BOTTOM_RIGHT_PANE] =
1516 mwindow->edl->local_session->view_start[TOP_RIGHT_PANE];
1518 pane[TOP_LEFT_PANE]->resize_event(
1519 mwindow->theme->mcanvas_x,
1520 pane[TOP_LEFT_PANE]->y,
1521 cursor_x - mwindow->theme->pane_w,
1522 pane[TOP_LEFT_PANE]->h);
1523 pane[TOP_RIGHT_PANE]->resize_event(
1524 mwindow->theme->mcanvas_x +
1526 pane[TOP_RIGHT_PANE]->y,
1527 mwindow->theme->mcanvas_x +
1528 mwindow->theme->mcanvas_w -
1530 pane[TOP_RIGHT_PANE]->h);
1531 pane[BOTTOM_LEFT_PANE]->resize_event(
1532 mwindow->theme->mcanvas_x,
1533 pane[BOTTOM_LEFT_PANE]->y,
1534 cursor_x - mwindow->theme->pane_w,
1535 pane[BOTTOM_LEFT_PANE]->h);
1536 pane[BOTTOM_RIGHT_PANE]->resize_event(
1537 mwindow->theme->mcanvas_x +
1539 pane[BOTTOM_RIGHT_PANE]->y,
1540 mwindow->theme->mcanvas_x +
1541 mwindow->theme->mcanvas_w -
1543 pane[BOTTOM_RIGHT_PANE]->h);
1549 void MWindowGUI::delete_x_pane(int cursor_x)
1551 // give left panes coordinates of right pane
1552 if(cursor_x < mwindow->theme->patchbay_w + PANE_DRAG_MARGIN &&
1553 pane[TOP_RIGHT_PANE])
1555 mwindow->edl->local_session->view_start[TOP_LEFT_PANE] =
1556 mwindow->edl->local_session->view_start[TOP_RIGHT_PANE] -
1557 pane[TOP_RIGHT_PANE]->x + mwindow->theme->patchbay_w;
1558 if(mwindow->edl->local_session->view_start[TOP_LEFT_PANE] < 0)
1559 mwindow->edl->local_session->view_start[TOP_LEFT_PANE] = 0;
1560 mwindow->edl->local_session->view_start[BOTTOM_LEFT_PANE] =
1561 mwindow->edl->local_session->view_start[TOP_LEFT_PANE];
1564 switch(total_panes())
1567 if(pane[TOP_LEFT_PANE] && pane[TOP_RIGHT_PANE])
1569 // delete right pane
1570 delete pane[TOP_RIGHT_PANE];
1571 pane[TOP_RIGHT_PANE] = 0;
1572 pane[TOP_LEFT_PANE]->resize_event(
1573 mwindow->theme->mcanvas_x,
1574 mwindow->theme->mcanvas_y,
1575 mwindow->theme->mcanvas_w,
1576 mwindow->theme->mcanvas_h);
1582 // delete right panes
1583 delete pane[TOP_RIGHT_PANE];
1584 pane[TOP_RIGHT_PANE] = 0;
1585 delete pane[BOTTOM_RIGHT_PANE];
1586 pane[BOTTOM_RIGHT_PANE] = 0;
1587 pane[TOP_LEFT_PANE]->resize_event(
1588 mwindow->theme->mcanvas_x,
1589 pane[TOP_LEFT_PANE]->y,
1590 mwindow->theme->mcanvas_w,
1591 pane[TOP_LEFT_PANE]->h);
1592 pane[BOTTOM_LEFT_PANE]->resize_event(
1593 mwindow->theme->mcanvas_x,
1594 pane[BOTTOM_LEFT_PANE]->y,
1595 mwindow->theme->mcanvas_w,
1596 pane[BOTTOM_LEFT_PANE]->h);
1601 void MWindowGUI::create_y_pane(int cursor_y)
1603 if(total_panes() == 1)
1605 mwindow->edl->local_session->view_start[BOTTOM_LEFT_PANE] =
1606 mwindow->edl->local_session->view_start[TOP_LEFT_PANE];
1607 mwindow->edl->local_session->track_start[BOTTOM_LEFT_PANE] =
1608 mwindow->edl->local_session->track_start[TOP_LEFT_PANE] +
1610 mwindow->theme->mtimebar_h;
1611 // do this 1st so the resize_event knows there are 2 panes
1612 pane[BOTTOM_LEFT_PANE] = new TimelinePane(mwindow,
1614 mwindow->theme->mcanvas_x,
1615 mwindow->theme->mcanvas_y +
1617 mwindow->theme->mcanvas_w,
1618 mwindow->theme->mcanvas_h -
1620 pane[TOP_LEFT_PANE]->resize_event(
1621 mwindow->theme->mcanvas_x,
1622 mwindow->theme->mcanvas_y,
1623 mwindow->theme->mcanvas_w,
1624 pane[BOTTOM_LEFT_PANE]->y -
1625 mwindow->theme->mcanvas_y -
1626 mwindow->theme->pane_h);
1627 pane[BOTTOM_LEFT_PANE]->create_objects();
1630 if(horizontal_panes())
1633 mwindow->edl->local_session->view_start[BOTTOM_LEFT_PANE] =
1634 mwindow->edl->local_session->view_start[TOP_LEFT_PANE];
1635 mwindow->edl->local_session->view_start[BOTTOM_RIGHT_PANE] =
1636 mwindow->edl->local_session->view_start[TOP_RIGHT_PANE];
1637 mwindow->edl->local_session->track_start[BOTTOM_LEFT_PANE] =
1638 mwindow->edl->local_session->track_start[BOTTOM_RIGHT_PANE] =
1639 mwindow->edl->local_session->track_start[TOP_LEFT_PANE] +
1641 mwindow->theme->mtimebar_h;
1643 pane[BOTTOM_LEFT_PANE] = new TimelinePane(mwindow,
1645 pane[TOP_LEFT_PANE]->x,
1646 mwindow->theme->mcanvas_y +
1648 pane[TOP_LEFT_PANE]->w,
1649 mwindow->theme->mcanvas_h -
1651 pane[BOTTOM_RIGHT_PANE] = new TimelinePane(mwindow,
1653 pane[TOP_RIGHT_PANE]->x,
1654 mwindow->theme->mcanvas_y +
1656 pane[TOP_RIGHT_PANE]->w,
1657 mwindow->theme->mcanvas_h -
1660 pane[TOP_LEFT_PANE]->resize_event(
1661 pane[TOP_LEFT_PANE]->x,
1662 pane[TOP_LEFT_PANE]->y,
1663 pane[TOP_LEFT_PANE]->w,
1664 pane[BOTTOM_LEFT_PANE]->y -
1665 mwindow->theme->mcanvas_y -
1666 mwindow->theme->pane_h);
1667 pane[TOP_RIGHT_PANE]->resize_event(
1668 pane[TOP_RIGHT_PANE]->x,
1669 pane[TOP_RIGHT_PANE]->y,
1670 pane[TOP_RIGHT_PANE]->w,
1671 pane[BOTTOM_RIGHT_PANE]->y -
1672 mwindow->theme->mcanvas_y -
1673 mwindow->theme->pane_h);
1675 pane[BOTTOM_LEFT_PANE]->create_objects();
1676 pane[BOTTOM_RIGHT_PANE]->create_objects();
1679 if(vertical_panes())
1682 mwindow->edl->local_session->track_start[BOTTOM_LEFT_PANE] +=
1684 (pane[BOTTOM_LEFT_PANE]->y - mwindow->theme->mcanvas_y);
1685 if(mwindow->edl->local_session->track_start[BOTTOM_LEFT_PANE] < 0)
1686 mwindow->edl->local_session->track_start[BOTTOM_LEFT_PANE] = 0;
1687 pane[TOP_LEFT_PANE]->resize_event(
1688 mwindow->theme->mcanvas_x,
1689 mwindow->theme->mcanvas_y,
1690 mwindow->theme->mcanvas_w,
1691 cursor_y - mwindow->theme->pane_h);
1692 pane[BOTTOM_LEFT_PANE]->resize_event(
1693 pane[BOTTOM_LEFT_PANE]->x,
1695 mwindow->theme->mcanvas_y,
1696 mwindow->theme->mcanvas_w,
1697 mwindow->theme->mcanvas_h -
1703 mwindow->edl->local_session->track_start[BOTTOM_LEFT_PANE] +=
1705 (pane[BOTTOM_LEFT_PANE]->y - mwindow->theme->mcanvas_y);
1706 if(mwindow->edl->local_session->track_start[BOTTOM_LEFT_PANE] < 0)
1707 mwindow->edl->local_session->track_start[BOTTOM_LEFT_PANE] = 0;
1708 mwindow->edl->local_session->track_start[BOTTOM_RIGHT_PANE] =
1709 mwindow->edl->local_session->track_start[BOTTOM_LEFT_PANE];
1710 pane[TOP_LEFT_PANE]->resize_event(
1711 pane[TOP_LEFT_PANE]->x,
1712 pane[TOP_LEFT_PANE]->y,
1713 pane[TOP_LEFT_PANE]->w,
1714 cursor_y - mwindow->theme->pane_h);
1715 pane[BOTTOM_LEFT_PANE]->resize_event(
1716 pane[BOTTOM_LEFT_PANE]->x,
1718 mwindow->theme->mcanvas_y,
1719 pane[BOTTOM_LEFT_PANE]->w,
1720 mwindow->theme->mcanvas_h -
1722 pane[TOP_RIGHT_PANE]->resize_event(
1723 pane[TOP_RIGHT_PANE]->x,
1724 pane[TOP_RIGHT_PANE]->y,
1725 pane[TOP_RIGHT_PANE]->w,
1726 cursor_y - mwindow->theme->pane_h);
1727 pane[BOTTOM_RIGHT_PANE]->resize_event(
1728 pane[BOTTOM_RIGHT_PANE]->x,
1730 mwindow->theme->mcanvas_y,
1731 pane[BOTTOM_RIGHT_PANE]->w,
1732 mwindow->theme->mcanvas_h -
1737 void MWindowGUI::delete_y_pane(int cursor_y)
1739 if(cursor_y < mwindow->theme->mtimebar_h +
1741 pane[BOTTOM_LEFT_PANE])
1743 // give top pane coordinates of bottom pane
1744 mwindow->edl->local_session->track_start[TOP_LEFT_PANE] =
1745 mwindow->edl->local_session->track_start[BOTTOM_LEFT_PANE] -
1746 pane[BOTTOM_LEFT_PANE]->y;
1747 if(mwindow->edl->local_session->track_start[TOP_LEFT_PANE] < 0)
1748 mwindow->edl->local_session->track_start[TOP_LEFT_PANE] = 0;
1749 mwindow->edl->local_session->track_start[TOP_RIGHT_PANE] =
1750 mwindow->edl->local_session->track_start[TOP_LEFT_PANE];
1754 switch(total_panes())
1757 delete pane[BOTTOM_LEFT_PANE];
1758 pane[BOTTOM_LEFT_PANE] = 0;
1759 pane[TOP_LEFT_PANE]->resize_event(
1760 mwindow->theme->mcanvas_x,
1761 mwindow->theme->mcanvas_y,
1762 mwindow->theme->mcanvas_w,
1763 mwindow->theme->mcanvas_h);
1767 // delete bottom 2 panes
1769 delete pane[BOTTOM_LEFT_PANE];
1770 pane[BOTTOM_LEFT_PANE] = 0;
1771 delete pane[BOTTOM_RIGHT_PANE];
1772 pane[BOTTOM_RIGHT_PANE] = 0;
1773 pane[TOP_LEFT_PANE]->resize_event(
1774 pane[TOP_LEFT_PANE]->x,
1775 mwindow->theme->mcanvas_y,
1776 pane[TOP_LEFT_PANE]->w,
1777 mwindow->theme->mcanvas_h);
1778 pane[TOP_RIGHT_PANE]->resize_event(
1779 pane[TOP_RIGHT_PANE]->x,
1780 mwindow->theme->mcanvas_y,
1781 pane[TOP_RIGHT_PANE]->w,
1782 mwindow->theme->mcanvas_h);
1787 void MWindowGUI::stop_pane_drag()
1790 resource_thread->stop_draw(1);
1794 // cursor position relative to canvas
1795 int cursor_x = x_pane_drag->get_x() -
1797 BC_DisplayInfo::get_left_border() -
1798 mwindow->theme->mcanvas_x +
1799 mwindow->theme->pane_w;
1804 if(cursor_x >= mwindow->theme->patchbay_w + PANE_DRAG_MARGIN &&
1805 cursor_x < mwindow->theme->mcanvas_w -
1806 BC_ScrollBar::get_span(SCROLL_VERT) -
1809 create_x_pane(cursor_x);
1810 mwindow->edl->local_session->x_pane = cursor_x;
1815 delete_x_pane(cursor_x);
1816 mwindow->edl->local_session->x_pane = -1;
1824 // cursor position relative to canvas
1825 int cursor_y = y_pane_drag->get_y() -
1827 BC_DisplayInfo::get_top_border() -
1828 mwindow->theme->mcanvas_y +
1829 mwindow->theme->pane_h;
1835 if(cursor_y >= mwindow->theme->mtimebar_h +
1837 cursor_y < mwindow->theme->mcanvas_h -
1838 BC_ScrollBar::get_span(SCROLL_HORIZ) -
1841 create_y_pane(cursor_y);
1842 mwindow->edl->local_session->y_pane = cursor_y;
1846 delete_y_pane(cursor_y);
1847 mwindow->edl->local_session->y_pane = -1;
1851 update_pane_dividers();
1853 // required to get new widgets to appear
1855 resource_thread->start_draw();
1858 // create panes from EDL
1859 void MWindowGUI::load_panes()
1861 int need_x_panes = 0;
1862 int need_y_panes = 0;
1863 // use names from create functions
1864 int cursor_x = mwindow->edl->local_session->x_pane;
1865 int cursor_y = mwindow->edl->local_session->y_pane;
1867 resource_thread->stop_draw(1);
1869 mwindow->theme->patchbay_w + PANE_DRAG_MARGIN &&
1871 mwindow->theme->mcanvas_w -
1872 BC_ScrollBar::get_span(SCROLL_VERT) -
1879 mwindow->theme->mtimebar_h + PANE_DRAG_MARGIN &&
1881 mwindow->theme->mcanvas_h -
1882 BC_ScrollBar::get_span(SCROLL_HORIZ) -
1888 //printf("MWindowGUI::load_panes %d %d %d\n", __LINE__, need_x_panes, need_y_panes);
1896 if(total_panes() == 1)
1899 //printf("MWindowGUI::load_panes %d\n", __LINE__);
1900 pane[TOP_RIGHT_PANE] = new TimelinePane(mwindow,
1902 mwindow->theme->mcanvas_x +
1904 mwindow->theme->mcanvas_y,
1905 mwindow->theme->mcanvas_x +
1906 mwindow->theme->mcanvas_w -
1908 cursor_y - mwindow->theme->pane_h);
1909 pane[BOTTOM_LEFT_PANE] = new TimelinePane(mwindow,
1911 mwindow->theme->mcanvas_x,
1912 mwindow->theme->mcanvas_y +
1914 cursor_x - mwindow->theme->pane_w,
1915 mwindow->theme->mcanvas_h -
1917 pane[BOTTOM_RIGHT_PANE] = new TimelinePane(mwindow,
1919 pane[TOP_RIGHT_PANE]->x,
1920 mwindow->theme->mcanvas_y +
1922 pane[TOP_RIGHT_PANE]->w,
1923 mwindow->theme->mcanvas_h -
1925 pane[TOP_LEFT_PANE]->resize_event(
1926 pane[TOP_LEFT_PANE]->x,
1927 pane[TOP_LEFT_PANE]->y,
1928 cursor_x - mwindow->theme->pane_w,
1929 cursor_y - mwindow->theme->pane_h);
1930 pane[TOP_RIGHT_PANE]->create_objects();
1931 pane[BOTTOM_LEFT_PANE]->create_objects();
1932 pane[BOTTOM_RIGHT_PANE]->create_objects();
1935 if(horizontal_panes())
1937 // create vertical panes
1938 //printf("MWindowGUI::load_panes %d\n", __LINE__);
1939 pane[BOTTOM_LEFT_PANE] = new TimelinePane(mwindow,
1941 mwindow->theme->mcanvas_x,
1942 mwindow->theme->mcanvas_y +
1944 cursor_x - mwindow->theme->pane_w,
1945 mwindow->theme->mcanvas_h -
1947 pane[BOTTOM_RIGHT_PANE] = new TimelinePane(mwindow,
1949 pane[TOP_RIGHT_PANE]->x,
1950 mwindow->theme->mcanvas_y +
1952 pane[TOP_RIGHT_PANE]->w,
1953 mwindow->theme->mcanvas_h -
1955 pane[TOP_LEFT_PANE]->resize_event(
1956 pane[TOP_LEFT_PANE]->x,
1957 pane[TOP_LEFT_PANE]->y,
1958 cursor_x - mwindow->theme->pane_w,
1959 cursor_y - mwindow->theme->pane_h);
1960 pane[TOP_RIGHT_PANE]->resize_event(
1961 mwindow->theme->mcanvas_x +
1963 mwindow->theme->mcanvas_y,
1964 mwindow->theme->mcanvas_x +
1965 mwindow->theme->mcanvas_w -
1967 cursor_y - mwindow->theme->pane_h);
1968 pane[BOTTOM_LEFT_PANE]->create_objects();
1969 pane[BOTTOM_RIGHT_PANE]->create_objects();
1972 if(vertical_panes())
1974 // create horizontal panes
1975 //printf("MWindowGUI::load_panes %d\n", __LINE__);
1976 pane[TOP_RIGHT_PANE] = new TimelinePane(mwindow,
1978 mwindow->theme->mcanvas_x +
1980 mwindow->theme->mcanvas_y,
1981 mwindow->theme->mcanvas_x +
1982 mwindow->theme->mcanvas_w -
1984 cursor_y - mwindow->theme->pane_h);
1985 pane[BOTTOM_RIGHT_PANE] = new TimelinePane(mwindow,
1987 pane[TOP_RIGHT_PANE]->x,
1988 mwindow->theme->mcanvas_y +
1990 pane[TOP_RIGHT_PANE]->w,
1991 mwindow->theme->mcanvas_h -
1993 pane[TOP_LEFT_PANE]->resize_event(
1994 pane[TOP_LEFT_PANE]->x,
1995 pane[TOP_LEFT_PANE]->y,
1996 cursor_x - mwindow->theme->pane_w,
1997 cursor_y - mwindow->theme->pane_h);
1998 pane[BOTTOM_LEFT_PANE]->resize_event(
1999 pane[TOP_LEFT_PANE]->x,
2000 mwindow->theme->mcanvas_y +
2002 mwindow->theme->mcanvas_x +
2003 mwindow->theme->mcanvas_w -
2004 cursor_x - mwindow->theme->pane_w,
2005 mwindow->theme->mcanvas_h -
2007 pane[TOP_RIGHT_PANE]->create_objects();
2008 pane[BOTTOM_RIGHT_PANE]->create_objects();
2015 //printf("MWindowGUI::load_panes %d\n", __LINE__);
2016 pane[TOP_LEFT_PANE]->resize_event(
2017 pane[TOP_LEFT_PANE]->x,
2018 pane[TOP_LEFT_PANE]->y,
2019 cursor_x - mwindow->theme->pane_w,
2020 cursor_y - mwindow->theme->pane_h);
2021 pane[TOP_RIGHT_PANE]->resize_event(
2022 mwindow->theme->mcanvas_x +
2024 mwindow->theme->mcanvas_y,
2025 mwindow->theme->mcanvas_x +
2026 mwindow->theme->mcanvas_w -
2028 cursor_y - mwindow->theme->pane_h);
2029 pane[BOTTOM_LEFT_PANE]->resize_event(
2030 pane[TOP_LEFT_PANE]->x,
2031 mwindow->theme->mcanvas_y +
2033 mwindow->theme->mcanvas_x +
2034 mwindow->theme->mcanvas_w -
2035 cursor_x - mwindow->theme->pane_w,
2036 mwindow->theme->mcanvas_h -
2038 pane[BOTTOM_RIGHT_PANE]->resize_event(
2039 pane[TOP_RIGHT_PANE]->x,
2040 mwindow->theme->mcanvas_y +
2042 pane[TOP_RIGHT_PANE]->w,
2043 mwindow->theme->mcanvas_h -
2052 if(pane[BOTTOM_LEFT_PANE]) delete pane[BOTTOM_LEFT_PANE];
2053 if(pane[BOTTOM_RIGHT_PANE]) delete pane[BOTTOM_RIGHT_PANE];
2054 pane[BOTTOM_LEFT_PANE] = 0;
2055 pane[BOTTOM_RIGHT_PANE] = 0;
2057 if(!pane[TOP_RIGHT_PANE])
2059 pane[TOP_RIGHT_PANE] = new TimelinePane(mwindow,
2061 mwindow->theme->mcanvas_x +
2063 mwindow->theme->mcanvas_y,
2064 mwindow->theme->mcanvas_x +
2065 mwindow->theme->mcanvas_w -
2067 mwindow->theme->mcanvas_h);
2068 pane[TOP_LEFT_PANE]->resize_event(
2069 mwindow->theme->mcanvas_x,
2070 mwindow->theme->mcanvas_y,
2071 cursor_x - mwindow->theme->pane_w,
2072 mwindow->theme->mcanvas_h);
2073 pane[TOP_RIGHT_PANE]->create_objects();
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]->resize_event(
2083 mwindow->theme->mcanvas_x +
2085 pane[TOP_RIGHT_PANE]->y,
2086 mwindow->theme->mcanvas_x +
2087 mwindow->theme->mcanvas_w -
2089 mwindow->theme->mcanvas_h);
2097 if(pane[TOP_RIGHT_PANE]) delete pane[TOP_RIGHT_PANE];
2098 if(pane[BOTTOM_RIGHT_PANE]) delete pane[BOTTOM_RIGHT_PANE];
2099 pane[TOP_RIGHT_PANE] = 0;
2100 pane[BOTTOM_RIGHT_PANE] = 0;
2102 if(!pane[BOTTOM_LEFT_PANE])
2104 //printf("MWindowGUI::load_panes %d\n", __LINE__);
2105 pane[BOTTOM_LEFT_PANE] = new TimelinePane(mwindow,
2107 mwindow->theme->mcanvas_x,
2108 mwindow->theme->mcanvas_y +
2110 mwindow->theme->mcanvas_w,
2111 mwindow->theme->mcanvas_h -
2113 pane[TOP_LEFT_PANE]->resize_event(
2114 mwindow->theme->mcanvas_x,
2115 mwindow->theme->mcanvas_y,
2116 mwindow->theme->mcanvas_w,
2117 pane[BOTTOM_LEFT_PANE]->y -
2118 mwindow->theme->mcanvas_y -
2119 mwindow->theme->pane_h);
2120 pane[BOTTOM_LEFT_PANE]->create_objects();
2124 pane[TOP_LEFT_PANE]->resize_event(
2125 mwindow->theme->mcanvas_x,
2126 mwindow->theme->mcanvas_y,
2127 mwindow->theme->mcanvas_w,
2128 cursor_y - mwindow->theme->pane_h);
2129 pane[BOTTOM_LEFT_PANE]->resize_event(
2130 pane[BOTTOM_LEFT_PANE]->x,
2132 mwindow->theme->mcanvas_y,
2133 mwindow->theme->mcanvas_w,
2134 mwindow->theme->mcanvas_h -
2141 if(pane[TOP_RIGHT_PANE]) delete pane[TOP_RIGHT_PANE];
2142 if(pane[BOTTOM_RIGHT_PANE]) delete pane[BOTTOM_RIGHT_PANE];
2143 if(pane[BOTTOM_LEFT_PANE]) delete pane[BOTTOM_LEFT_PANE];
2144 pane[TOP_RIGHT_PANE] = 0;
2145 pane[BOTTOM_RIGHT_PANE] = 0;
2146 pane[BOTTOM_LEFT_PANE] = 0;
2147 pane[TOP_LEFT_PANE]->resize_event(
2148 mwindow->theme->mcanvas_x,
2149 mwindow->theme->mcanvas_y,
2150 mwindow->theme->mcanvas_w,
2151 mwindow->theme->mcanvas_h);
2154 update_pane_dividers();
2157 resource_thread->start_draw();
2160 void MWindowGUI::update_pane_dividers()
2163 if(horizontal_panes() || total_panes() == 4)
2165 int x = pane[TOP_RIGHT_PANE]->x - mwindow->theme->pane_w;
2166 int y = mwindow->theme->mcanvas_y;
2167 int h = mwindow->theme->mcanvas_h;
2171 add_subwindow(x_divider = new PaneDivider(
2172 mwindow, x, y, h, 1));
2173 x_divider->create_objects();
2177 x_divider->reposition_window(x, y, h);
2190 if(vertical_panes() || total_panes() == 4)
2192 int x = mwindow->theme->mcanvas_x;
2193 int y = pane[BOTTOM_LEFT_PANE]->y -
2194 mwindow->theme->pane_h;
2195 int w = mwindow->theme->mcanvas_w;
2198 add_subwindow(y_divider = new PaneDivider(
2199 mwindow, x, y, w, 0));
2200 y_divider->create_objects();
2204 y_divider->reposition_window(x, y, w);
2218 void MWindowGUI::draw_samplemovement()
2225 update_scrollbars(1);
2228 void MWindowGUI::draw_trackmovement()
2230 update_scrollbars(0);
2237 PaneButton::PaneButton(MWindow *mwindow, int x, int y)
2238 : BC_Button(x, y, mwindow->theme->get_image_set("pane"))
2240 this->mwindow = mwindow;
2243 int PaneButton::cursor_motion_event()
2245 if(get_top_level()->get_button_down() &&
2247 get_status() == BUTTON_DOWNHI &&
2250 // printf("PaneButton::cursor_motion_event %d\n", __LINE__);
2252 if(get_cursor_x() < 0 && !mwindow->gui->dragging_pane)
2254 mwindow->gui->start_x_pane_drag();
2257 if(get_cursor_y() < 0 && !mwindow->gui->dragging_pane)
2259 mwindow->gui->start_y_pane_drag();
2263 mwindow->gui->handle_pane_drag();
2265 int result = BC_Button::cursor_motion_event();
2269 int PaneButton::button_release_event()
2271 mwindow->gui->stop_pane_drag();
2273 int result = BC_Button::button_release_event();
2278 FFMpegToggle::FFMpegToggle(MWindow *mwindow, MButtons *mbuttons, int x, int y)
2279 : BC_Toggle(x, y, mwindow->theme->ffmpeg_toggle, mwindow->preferences->ffmpeg_early_probe)
2281 this->mwindow = mwindow;
2282 this->mbuttons = mbuttons;
2283 set_tooltip( mwindow->preferences->ffmpeg_early_probe ?
2284 _("Try FFMpeg first") : _("Try FFMpeg last"));
2287 FFMpegToggle::~FFMpegToggle()
2291 int FFMpegToggle::handle_event()
2293 mwindow->preferences->ffmpeg_early_probe = get_value();
2294 set_tooltip( mwindow->preferences->ffmpeg_early_probe ?
2295 _("Try FFMpeg first") : _("Try FFMpeg last"));
2296 mwindow->show_warning(&mwindow->preferences->warn_indexes,
2297 _("Changing the base codecs may require rebuilding indexes."));