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(DEFAULT_VWINDOW) : 0;
1058 if( vwindow && !vwindow->is_running() ) vwindow = 0;
1059 if( vwindow ) vwindow->gui->lock_window("MWindowGUI::default_positions");
1060 mwindow->cwindow->gui->lock_window("MWindowGUI::default_positions");
1061 mwindow->awindow->gui->lock_window("MWindowGUI::default_positions");
1063 // printf("MWindowGUI::default_positions 1 %d %d %d %d\n", mwindow->session->vwindow_x,
1064 // mwindow->session->vwindow_y,
1065 // mwindow->session->vwindow_w,
1066 // mwindow->session->vwindow_h);
1067 reposition_window(mwindow->session->mwindow_x,
1068 mwindow->session->mwindow_y,
1069 mwindow->session->mwindow_w,
1070 mwindow->session->mwindow_h);
1071 if( vwindow ) vwindow->gui->reposition_window(mwindow->session->vwindow_x,
1072 mwindow->session->vwindow_y,
1073 mwindow->session->vwindow_w,
1074 mwindow->session->vwindow_h);
1075 mwindow->cwindow->gui->reposition_window(mwindow->session->cwindow_x,
1076 mwindow->session->cwindow_y,
1077 mwindow->session->cwindow_w,
1078 mwindow->session->cwindow_h);
1079 mwindow->awindow->gui->reposition_window(mwindow->session->awindow_x,
1080 mwindow->session->awindow_y,
1081 mwindow->session->awindow_w,
1082 mwindow->session->awindow_h);
1083 //printf("MWindowGUI::default_positions 1\n");
1085 resize_event(mwindow->session->mwindow_w,
1086 mwindow->session->mwindow_h);
1087 //printf("MWindowGUI::default_positions 1\n");
1088 if( vwindow ) vwindow->gui->resize_event(mwindow->session->vwindow_w,
1089 mwindow->session->vwindow_h);
1090 //printf("MWindowGUI::default_positions 1\n");
1091 mwindow->cwindow->gui->resize_event(mwindow->session->cwindow_w,
1092 mwindow->session->cwindow_h);
1093 //printf("MWindowGUI::default_positions 1\n");
1094 mwindow->awindow->gui->resize_event(mwindow->session->awindow_w,
1095 mwindow->session->awindow_h);
1097 //printf("MWindowGUI::default_positions 1\n");
1100 if( vwindow ) vwindow->gui->flush();
1101 mwindow->cwindow->gui->flush();
1102 mwindow->awindow->gui->flush();
1104 if( vwindow ) vwindow->gui->unlock_window();
1105 mwindow->cwindow->gui->unlock_window();
1106 mwindow->awindow->gui->unlock_window();
1107 //printf("MWindowGUI::default_positions 2\n");
1126 int MWindowGUI::repeat_event(int64_t duration)
1128 // if(duration == 100)
1129 // mwindow->sync_parameters(CHANGE_ALL);
1131 for(int i = 0; i < TOTAL_PANES; i++)
1133 if(pane[i]) result = pane[i]->cursor->repeat_event(duration);
1139 int MWindowGUI::translation_event()
1141 //printf("MWindowGUI::translation_event 1 %d %d\n", get_x(), get_y());
1142 mwindow->session->mwindow_x = get_x();
1143 mwindow->session->mwindow_y = get_y();
1148 int MWindowGUI::save_defaults(BC_Hash *defaults)
1150 defaults->update("MWINDOWWIDTH", get_w());
1151 defaults->update("MWINDOWHEIGHT", get_h());
1152 mainmenu->save_defaults(defaults);
1153 BC_WindowBase::save_defaults(defaults);
1157 int MWindowGUI::keypress_event()
1159 //printf("MWindowGUI::keypress_event 1 %d\n", get_keypress());
1160 int result = mbuttons->keypress_event();
1161 if( result ) return result;
1163 switch(get_keypress()) {
1165 mwindow->toggle_editing_mode();
1169 case '1': case '2': case '3': case '4':
1170 case '5': case '6': case '7': case '8':
1171 if( !alt_down() || shift_down() ) break;
1172 if( !mwindow->select_asset(get_keypress()-'1',1) )
1177 if( !ctrl_down() ) {
1180 mbuttons->transport->handle_transport(STOP, 1, 0, 0);
1181 lock_window("MWindowGUI::keypress_event 1");
1182 mwindow->prev_edit_handle(shift_down());
1185 mwindow->move_left();
1191 if( !ctrl_down() ) {
1194 mbuttons->transport->handle_transport(STOP, 1, 0, 0);
1195 lock_window("MWindowGUI::keypress_event 2");
1196 mwindow->next_edit_handle(shift_down());
1199 mwindow->move_right();
1205 if( ctrl_down() && !alt_down() )
1206 mwindow->expand_y();
1207 else if( !ctrl_down() && alt_down() )
1208 mwindow->expand_autos(0,1,1);
1209 else if( ctrl_down() && alt_down() )
1210 mwindow->expand_autos(1,1,1);
1212 mwindow->expand_sample();
1217 if( ctrl_down() && !alt_down() )
1218 mwindow->zoom_in_y();
1219 else if( !ctrl_down() && alt_down() )
1220 mwindow->shrink_autos(0,1,1);
1221 else if( ctrl_down() && alt_down() )
1222 mwindow->shrink_autos(1,1,1);
1224 mwindow->zoom_in_sample();
1232 mwindow->expand_t();
1238 mwindow->move_down();
1240 mwindow->zoom_in_t();
1246 Track *this_track = 0;
1247 for( int i=0; i<TOTAL_PANES; ++i ) {
1248 if( !pane[i] ) continue;
1249 if( (this_track = pane[i]->over_track()) != 0 ) break;
1250 if( (this_track = pane[i]->over_patchbay()) != 0 ) break;
1253 if( get_keypress() == TAB ) { // Switch the record button
1255 this_track->record = !this_track->record ? 1 : 0;
1258 int total_selected = mwindow->edl->tracks->total_of(Tracks::RECORD);
1259 // all selected if nothing previously selected or
1260 // if this patch was previously the only one selected and armed
1261 int selected = !total_selected || (total_selected == 1 &&
1262 this_track && this_track->record ) ? 1 : 0;
1263 mwindow->edl->tracks->select_all(Tracks::RECORD, selected);
1264 if( !selected && this_track ) this_track->record = 1;
1267 update(0, 1, 0, 0, 1, 0, 1);
1269 mwindow->cwindow->update(0, 1, 1);
1270 lock_window("TrackCanvas::keypress_event 3");
1276 // since things under cursor have changed...
1278 cursor_motion_event();
1284 int MWindowGUI::keyboard_listener(BC_WindowBase *wp)
1286 return key_listener(wp->get_keypress());
1289 int MWindowGUI::key_listener(int key)
1294 if( !record->running() )
1297 record->record_gui->interrupt_thread->start(0);
1304 channel_info->toggle_scan();
1308 if( !remote_control->deactivate() )
1309 remote_control->activate();
1319 void MWindowGUI::use_android_remote(int on)
1322 delete android_control;
1323 android_control = 0;
1326 if( android_control ) return;
1327 android_control = new AndroidControl(this);
1330 int MWindowGUI::close_event()
1336 void MWindowGUI::stop_drawing()
1338 resource_thread->stop_draw(1);
1341 int MWindowGUI::menu_w()
1343 return mainmenu->get_w();
1346 int MWindowGUI::menu_h()
1348 return mainmenu->get_h();
1351 void MWindowGUI::start_x_pane_drag()
1355 x_pane_drag = new BC_Popup(this,
1356 get_abs_cursor_x(0) - mwindow->theme->pane_w,
1357 BC_DisplayInfo::get_top_border() +
1359 mwindow->theme->mcanvas_y,
1360 mwindow->theme->pane_w,
1361 mwindow->theme->mcanvas_h,
1362 mwindow->theme->drag_pane_color);
1363 x_pane_drag->draw_3segmentv(0,
1365 x_pane_drag->get_h(),
1366 mwindow->theme->get_image_set("xpane")[BUTTON_DOWNHI]);
1367 x_pane_drag->flash(1);
1372 void MWindowGUI::start_y_pane_drag()
1376 //printf("MWindowGUI::start_y_pane_drag %d %d %d\n", __LINE__, get_x(), get_y());
1377 y_pane_drag = new BC_Popup(this,
1378 BC_DisplayInfo::get_left_border() +
1380 mwindow->theme->mcanvas_x,
1381 get_abs_cursor_y(0) - mwindow->theme->pane_h,
1382 mwindow->theme->mcanvas_w,
1383 mwindow->theme->pane_h,
1384 mwindow->theme->drag_pane_color);
1385 y_pane_drag->draw_3segmenth(0,
1387 y_pane_drag->get_w(),
1388 mwindow->theme->get_image_set("ypane")[BUTTON_DOWNHI]);
1389 y_pane_drag->flash(1);
1394 void MWindowGUI::handle_pane_drag()
1400 x_pane_drag->reposition_window(
1401 get_abs_cursor_x(0) - mwindow->theme->pane_w,
1402 x_pane_drag->get_y());
1407 y_pane_drag->reposition_window(
1408 y_pane_drag->get_x(),
1409 get_abs_cursor_y(0) - mwindow->theme->pane_h);
1415 void MWindowGUI::create_x_pane(int cursor_x)
1417 if(total_panes() == 1)
1419 // create a horizontal pane
1420 // do this 1st so the resize_event knows there are 2 panes
1421 mwindow->edl->local_session->view_start[TOP_RIGHT_PANE] =
1422 mwindow->edl->local_session->view_start[TOP_LEFT_PANE] +
1424 mwindow->theme->patchbay_w;
1425 pane[TOP_RIGHT_PANE] = new TimelinePane(mwindow,
1427 mwindow->theme->mcanvas_x +
1429 mwindow->theme->mcanvas_y,
1430 mwindow->theme->mcanvas_x +
1431 mwindow->theme->mcanvas_w -
1433 mwindow->theme->mcanvas_h);
1434 pane[TOP_LEFT_PANE]->resize_event(
1435 mwindow->theme->mcanvas_x,
1436 mwindow->theme->mcanvas_y,
1437 cursor_x - mwindow->theme->pane_w,
1438 mwindow->theme->mcanvas_h);
1439 pane[TOP_RIGHT_PANE]->create_objects();
1442 if(vertical_panes())
1444 // create 2 horizontal panes
1445 mwindow->edl->local_session->track_start[TOP_RIGHT_PANE] =
1446 mwindow->edl->local_session->track_start[TOP_LEFT_PANE];
1447 mwindow->edl->local_session->track_start[BOTTOM_RIGHT_PANE] =
1448 mwindow->edl->local_session->track_start[BOTTOM_LEFT_PANE];
1449 mwindow->edl->local_session->view_start[TOP_RIGHT_PANE] =
1450 mwindow->edl->local_session->view_start[BOTTOM_RIGHT_PANE] =
1451 mwindow->edl->local_session->view_start[TOP_LEFT_PANE] +
1453 mwindow->theme->patchbay_w;
1454 pane[TOP_RIGHT_PANE] = new TimelinePane(mwindow,
1456 mwindow->theme->mcanvas_x +
1458 pane[TOP_LEFT_PANE]->y,
1459 mwindow->theme->mcanvas_x +
1460 mwindow->theme->mcanvas_w -
1462 pane[TOP_LEFT_PANE]->h);
1463 pane[BOTTOM_RIGHT_PANE] = new TimelinePane(mwindow,
1465 mwindow->theme->mcanvas_x +
1467 pane[BOTTOM_LEFT_PANE]->y,
1468 mwindow->theme->mcanvas_x +
1469 mwindow->theme->mcanvas_w -
1471 pane[BOTTOM_LEFT_PANE]->h);
1472 pane[TOP_LEFT_PANE]->resize_event(
1473 pane[TOP_LEFT_PANE]->x,
1474 pane[TOP_LEFT_PANE]->y,
1475 cursor_x - mwindow->theme->pane_w,
1476 pane[TOP_LEFT_PANE]->h);
1477 pane[BOTTOM_LEFT_PANE]->resize_event(
1478 pane[BOTTOM_LEFT_PANE]->x,
1479 pane[BOTTOM_LEFT_PANE]->y,
1480 cursor_x - mwindow->theme->pane_w,
1481 pane[BOTTOM_LEFT_PANE]->h);
1482 pane[TOP_RIGHT_PANE]->create_objects();
1483 pane[BOTTOM_RIGHT_PANE]->create_objects();
1486 if(horizontal_panes())
1488 // resize a horizontal pane
1489 mwindow->edl->local_session->view_start[TOP_RIGHT_PANE] +=
1491 pane[TOP_RIGHT_PANE]->x;
1492 if(mwindow->edl->local_session->view_start[TOP_RIGHT_PANE] < 0)
1493 mwindow->edl->local_session->view_start[TOP_RIGHT_PANE] = 0;
1494 pane[TOP_LEFT_PANE]->resize_event(
1495 mwindow->theme->mcanvas_x,
1496 mwindow->theme->mcanvas_y,
1497 cursor_x - mwindow->theme->pane_w,
1498 mwindow->theme->mcanvas_h);
1499 pane[TOP_RIGHT_PANE]->resize_event(
1500 mwindow->theme->mcanvas_x +
1502 pane[TOP_RIGHT_PANE]->y,
1503 mwindow->theme->mcanvas_x +
1504 mwindow->theme->mcanvas_w -
1506 mwindow->theme->mcanvas_h);
1510 // resize 2 horizontal panes
1511 mwindow->edl->local_session->view_start[TOP_RIGHT_PANE] +=
1513 pane[TOP_RIGHT_PANE]->x;
1514 if(mwindow->edl->local_session->view_start[TOP_RIGHT_PANE] < 0)
1515 mwindow->edl->local_session->view_start[TOP_RIGHT_PANE] = 0;
1516 mwindow->edl->local_session->view_start[BOTTOM_RIGHT_PANE] =
1517 mwindow->edl->local_session->view_start[TOP_RIGHT_PANE];
1519 pane[TOP_LEFT_PANE]->resize_event(
1520 mwindow->theme->mcanvas_x,
1521 pane[TOP_LEFT_PANE]->y,
1522 cursor_x - mwindow->theme->pane_w,
1523 pane[TOP_LEFT_PANE]->h);
1524 pane[TOP_RIGHT_PANE]->resize_event(
1525 mwindow->theme->mcanvas_x +
1527 pane[TOP_RIGHT_PANE]->y,
1528 mwindow->theme->mcanvas_x +
1529 mwindow->theme->mcanvas_w -
1531 pane[TOP_RIGHT_PANE]->h);
1532 pane[BOTTOM_LEFT_PANE]->resize_event(
1533 mwindow->theme->mcanvas_x,
1534 pane[BOTTOM_LEFT_PANE]->y,
1535 cursor_x - mwindow->theme->pane_w,
1536 pane[BOTTOM_LEFT_PANE]->h);
1537 pane[BOTTOM_RIGHT_PANE]->resize_event(
1538 mwindow->theme->mcanvas_x +
1540 pane[BOTTOM_RIGHT_PANE]->y,
1541 mwindow->theme->mcanvas_x +
1542 mwindow->theme->mcanvas_w -
1544 pane[BOTTOM_RIGHT_PANE]->h);
1550 void MWindowGUI::delete_x_pane(int cursor_x)
1552 // give left panes coordinates of right pane
1553 if(cursor_x < mwindow->theme->patchbay_w + PANE_DRAG_MARGIN &&
1554 pane[TOP_RIGHT_PANE])
1556 mwindow->edl->local_session->view_start[TOP_LEFT_PANE] =
1557 mwindow->edl->local_session->view_start[TOP_RIGHT_PANE] -
1558 pane[TOP_RIGHT_PANE]->x + mwindow->theme->patchbay_w;
1559 if(mwindow->edl->local_session->view_start[TOP_LEFT_PANE] < 0)
1560 mwindow->edl->local_session->view_start[TOP_LEFT_PANE] = 0;
1561 mwindow->edl->local_session->view_start[BOTTOM_LEFT_PANE] =
1562 mwindow->edl->local_session->view_start[TOP_LEFT_PANE];
1565 switch(total_panes())
1568 if(pane[TOP_LEFT_PANE] && pane[TOP_RIGHT_PANE])
1570 // delete right pane
1571 delete pane[TOP_RIGHT_PANE];
1572 pane[TOP_RIGHT_PANE] = 0;
1573 pane[TOP_LEFT_PANE]->resize_event(
1574 mwindow->theme->mcanvas_x,
1575 mwindow->theme->mcanvas_y,
1576 mwindow->theme->mcanvas_w,
1577 mwindow->theme->mcanvas_h);
1583 // delete right panes
1584 delete pane[TOP_RIGHT_PANE];
1585 pane[TOP_RIGHT_PANE] = 0;
1586 delete pane[BOTTOM_RIGHT_PANE];
1587 pane[BOTTOM_RIGHT_PANE] = 0;
1588 pane[TOP_LEFT_PANE]->resize_event(
1589 mwindow->theme->mcanvas_x,
1590 pane[TOP_LEFT_PANE]->y,
1591 mwindow->theme->mcanvas_w,
1592 pane[TOP_LEFT_PANE]->h);
1593 pane[BOTTOM_LEFT_PANE]->resize_event(
1594 mwindow->theme->mcanvas_x,
1595 pane[BOTTOM_LEFT_PANE]->y,
1596 mwindow->theme->mcanvas_w,
1597 pane[BOTTOM_LEFT_PANE]->h);
1602 void MWindowGUI::create_y_pane(int cursor_y)
1604 if(total_panes() == 1)
1606 mwindow->edl->local_session->view_start[BOTTOM_LEFT_PANE] =
1607 mwindow->edl->local_session->view_start[TOP_LEFT_PANE];
1608 mwindow->edl->local_session->track_start[BOTTOM_LEFT_PANE] =
1609 mwindow->edl->local_session->track_start[TOP_LEFT_PANE] +
1611 mwindow->theme->mtimebar_h;
1612 // do this 1st so the resize_event knows there are 2 panes
1613 pane[BOTTOM_LEFT_PANE] = new TimelinePane(mwindow,
1615 mwindow->theme->mcanvas_x,
1616 mwindow->theme->mcanvas_y +
1618 mwindow->theme->mcanvas_w,
1619 mwindow->theme->mcanvas_h -
1621 pane[TOP_LEFT_PANE]->resize_event(
1622 mwindow->theme->mcanvas_x,
1623 mwindow->theme->mcanvas_y,
1624 mwindow->theme->mcanvas_w,
1625 pane[BOTTOM_LEFT_PANE]->y -
1626 mwindow->theme->mcanvas_y -
1627 mwindow->theme->pane_h);
1628 pane[BOTTOM_LEFT_PANE]->create_objects();
1631 if(horizontal_panes())
1634 mwindow->edl->local_session->view_start[BOTTOM_LEFT_PANE] =
1635 mwindow->edl->local_session->view_start[TOP_LEFT_PANE];
1636 mwindow->edl->local_session->view_start[BOTTOM_RIGHT_PANE] =
1637 mwindow->edl->local_session->view_start[TOP_RIGHT_PANE];
1638 mwindow->edl->local_session->track_start[BOTTOM_LEFT_PANE] =
1639 mwindow->edl->local_session->track_start[BOTTOM_RIGHT_PANE] =
1640 mwindow->edl->local_session->track_start[TOP_LEFT_PANE] +
1642 mwindow->theme->mtimebar_h;
1644 pane[BOTTOM_LEFT_PANE] = new TimelinePane(mwindow,
1646 pane[TOP_LEFT_PANE]->x,
1647 mwindow->theme->mcanvas_y +
1649 pane[TOP_LEFT_PANE]->w,
1650 mwindow->theme->mcanvas_h -
1652 pane[BOTTOM_RIGHT_PANE] = new TimelinePane(mwindow,
1654 pane[TOP_RIGHT_PANE]->x,
1655 mwindow->theme->mcanvas_y +
1657 pane[TOP_RIGHT_PANE]->w,
1658 mwindow->theme->mcanvas_h -
1661 pane[TOP_LEFT_PANE]->resize_event(
1662 pane[TOP_LEFT_PANE]->x,
1663 pane[TOP_LEFT_PANE]->y,
1664 pane[TOP_LEFT_PANE]->w,
1665 pane[BOTTOM_LEFT_PANE]->y -
1666 mwindow->theme->mcanvas_y -
1667 mwindow->theme->pane_h);
1668 pane[TOP_RIGHT_PANE]->resize_event(
1669 pane[TOP_RIGHT_PANE]->x,
1670 pane[TOP_RIGHT_PANE]->y,
1671 pane[TOP_RIGHT_PANE]->w,
1672 pane[BOTTOM_RIGHT_PANE]->y -
1673 mwindow->theme->mcanvas_y -
1674 mwindow->theme->pane_h);
1676 pane[BOTTOM_LEFT_PANE]->create_objects();
1677 pane[BOTTOM_RIGHT_PANE]->create_objects();
1680 if(vertical_panes())
1683 mwindow->edl->local_session->track_start[BOTTOM_LEFT_PANE] +=
1685 (pane[BOTTOM_LEFT_PANE]->y - mwindow->theme->mcanvas_y);
1686 if(mwindow->edl->local_session->track_start[BOTTOM_LEFT_PANE] < 0)
1687 mwindow->edl->local_session->track_start[BOTTOM_LEFT_PANE] = 0;
1688 pane[TOP_LEFT_PANE]->resize_event(
1689 mwindow->theme->mcanvas_x,
1690 mwindow->theme->mcanvas_y,
1691 mwindow->theme->mcanvas_w,
1692 cursor_y - mwindow->theme->pane_h);
1693 pane[BOTTOM_LEFT_PANE]->resize_event(
1694 pane[BOTTOM_LEFT_PANE]->x,
1696 mwindow->theme->mcanvas_y,
1697 mwindow->theme->mcanvas_w,
1698 mwindow->theme->mcanvas_h -
1704 mwindow->edl->local_session->track_start[BOTTOM_LEFT_PANE] +=
1706 (pane[BOTTOM_LEFT_PANE]->y - mwindow->theme->mcanvas_y);
1707 if(mwindow->edl->local_session->track_start[BOTTOM_LEFT_PANE] < 0)
1708 mwindow->edl->local_session->track_start[BOTTOM_LEFT_PANE] = 0;
1709 mwindow->edl->local_session->track_start[BOTTOM_RIGHT_PANE] =
1710 mwindow->edl->local_session->track_start[BOTTOM_LEFT_PANE];
1711 pane[TOP_LEFT_PANE]->resize_event(
1712 pane[TOP_LEFT_PANE]->x,
1713 pane[TOP_LEFT_PANE]->y,
1714 pane[TOP_LEFT_PANE]->w,
1715 cursor_y - mwindow->theme->pane_h);
1716 pane[BOTTOM_LEFT_PANE]->resize_event(
1717 pane[BOTTOM_LEFT_PANE]->x,
1719 mwindow->theme->mcanvas_y,
1720 pane[BOTTOM_LEFT_PANE]->w,
1721 mwindow->theme->mcanvas_h -
1723 pane[TOP_RIGHT_PANE]->resize_event(
1724 pane[TOP_RIGHT_PANE]->x,
1725 pane[TOP_RIGHT_PANE]->y,
1726 pane[TOP_RIGHT_PANE]->w,
1727 cursor_y - mwindow->theme->pane_h);
1728 pane[BOTTOM_RIGHT_PANE]->resize_event(
1729 pane[BOTTOM_RIGHT_PANE]->x,
1731 mwindow->theme->mcanvas_y,
1732 pane[BOTTOM_RIGHT_PANE]->w,
1733 mwindow->theme->mcanvas_h -
1738 void MWindowGUI::delete_y_pane(int cursor_y)
1740 if(cursor_y < mwindow->theme->mtimebar_h +
1742 pane[BOTTOM_LEFT_PANE])
1744 // give top pane coordinates of bottom pane
1745 mwindow->edl->local_session->track_start[TOP_LEFT_PANE] =
1746 mwindow->edl->local_session->track_start[BOTTOM_LEFT_PANE] -
1747 pane[BOTTOM_LEFT_PANE]->y;
1748 if(mwindow->edl->local_session->track_start[TOP_LEFT_PANE] < 0)
1749 mwindow->edl->local_session->track_start[TOP_LEFT_PANE] = 0;
1750 mwindow->edl->local_session->track_start[TOP_RIGHT_PANE] =
1751 mwindow->edl->local_session->track_start[TOP_LEFT_PANE];
1755 switch(total_panes())
1758 delete pane[BOTTOM_LEFT_PANE];
1759 pane[BOTTOM_LEFT_PANE] = 0;
1760 pane[TOP_LEFT_PANE]->resize_event(
1761 mwindow->theme->mcanvas_x,
1762 mwindow->theme->mcanvas_y,
1763 mwindow->theme->mcanvas_w,
1764 mwindow->theme->mcanvas_h);
1768 // delete bottom 2 panes
1770 delete pane[BOTTOM_LEFT_PANE];
1771 pane[BOTTOM_LEFT_PANE] = 0;
1772 delete pane[BOTTOM_RIGHT_PANE];
1773 pane[BOTTOM_RIGHT_PANE] = 0;
1774 pane[TOP_LEFT_PANE]->resize_event(
1775 pane[TOP_LEFT_PANE]->x,
1776 mwindow->theme->mcanvas_y,
1777 pane[TOP_LEFT_PANE]->w,
1778 mwindow->theme->mcanvas_h);
1779 pane[TOP_RIGHT_PANE]->resize_event(
1780 pane[TOP_RIGHT_PANE]->x,
1781 mwindow->theme->mcanvas_y,
1782 pane[TOP_RIGHT_PANE]->w,
1783 mwindow->theme->mcanvas_h);
1788 void MWindowGUI::stop_pane_drag()
1791 resource_thread->stop_draw(1);
1795 // cursor position relative to canvas
1796 int cursor_x = x_pane_drag->get_x() -
1798 BC_DisplayInfo::get_left_border() -
1799 mwindow->theme->mcanvas_x +
1800 mwindow->theme->pane_w;
1805 if(cursor_x >= mwindow->theme->patchbay_w + PANE_DRAG_MARGIN &&
1806 cursor_x < mwindow->theme->mcanvas_w -
1807 BC_ScrollBar::get_span(SCROLL_VERT) -
1810 create_x_pane(cursor_x);
1811 mwindow->edl->local_session->x_pane = cursor_x;
1816 delete_x_pane(cursor_x);
1817 mwindow->edl->local_session->x_pane = -1;
1825 // cursor position relative to canvas
1826 int cursor_y = y_pane_drag->get_y() -
1828 BC_DisplayInfo::get_top_border() -
1829 mwindow->theme->mcanvas_y +
1830 mwindow->theme->pane_h;
1836 if(cursor_y >= mwindow->theme->mtimebar_h +
1838 cursor_y < mwindow->theme->mcanvas_h -
1839 BC_ScrollBar::get_span(SCROLL_HORIZ) -
1842 create_y_pane(cursor_y);
1843 mwindow->edl->local_session->y_pane = cursor_y;
1847 delete_y_pane(cursor_y);
1848 mwindow->edl->local_session->y_pane = -1;
1852 update_pane_dividers();
1854 // required to get new widgets to appear
1856 resource_thread->start_draw();
1859 // create panes from EDL
1860 void MWindowGUI::load_panes()
1862 int need_x_panes = 0;
1863 int need_y_panes = 0;
1864 // use names from create functions
1865 int cursor_x = mwindow->edl->local_session->x_pane;
1866 int cursor_y = mwindow->edl->local_session->y_pane;
1868 resource_thread->stop_draw(1);
1870 mwindow->theme->patchbay_w + PANE_DRAG_MARGIN &&
1872 mwindow->theme->mcanvas_w -
1873 BC_ScrollBar::get_span(SCROLL_VERT) -
1880 mwindow->theme->mtimebar_h + PANE_DRAG_MARGIN &&
1882 mwindow->theme->mcanvas_h -
1883 BC_ScrollBar::get_span(SCROLL_HORIZ) -
1889 //printf("MWindowGUI::load_panes %d %d %d\n", __LINE__, need_x_panes, need_y_panes);
1897 if(total_panes() == 1)
1900 //printf("MWindowGUI::load_panes %d\n", __LINE__);
1901 pane[TOP_RIGHT_PANE] = new TimelinePane(mwindow,
1903 mwindow->theme->mcanvas_x +
1905 mwindow->theme->mcanvas_y,
1906 mwindow->theme->mcanvas_x +
1907 mwindow->theme->mcanvas_w -
1909 cursor_y - mwindow->theme->pane_h);
1910 pane[BOTTOM_LEFT_PANE] = new TimelinePane(mwindow,
1912 mwindow->theme->mcanvas_x,
1913 mwindow->theme->mcanvas_y +
1915 cursor_x - mwindow->theme->pane_w,
1916 mwindow->theme->mcanvas_h -
1918 pane[BOTTOM_RIGHT_PANE] = new TimelinePane(mwindow,
1920 pane[TOP_RIGHT_PANE]->x,
1921 mwindow->theme->mcanvas_y +
1923 pane[TOP_RIGHT_PANE]->w,
1924 mwindow->theme->mcanvas_h -
1926 pane[TOP_LEFT_PANE]->resize_event(
1927 pane[TOP_LEFT_PANE]->x,
1928 pane[TOP_LEFT_PANE]->y,
1929 cursor_x - mwindow->theme->pane_w,
1930 cursor_y - mwindow->theme->pane_h);
1931 pane[TOP_RIGHT_PANE]->create_objects();
1932 pane[BOTTOM_LEFT_PANE]->create_objects();
1933 pane[BOTTOM_RIGHT_PANE]->create_objects();
1936 if(horizontal_panes())
1938 // create vertical panes
1939 //printf("MWindowGUI::load_panes %d\n", __LINE__);
1940 pane[BOTTOM_LEFT_PANE] = new TimelinePane(mwindow,
1942 mwindow->theme->mcanvas_x,
1943 mwindow->theme->mcanvas_y +
1945 cursor_x - mwindow->theme->pane_w,
1946 mwindow->theme->mcanvas_h -
1948 pane[BOTTOM_RIGHT_PANE] = new TimelinePane(mwindow,
1950 pane[TOP_RIGHT_PANE]->x,
1951 mwindow->theme->mcanvas_y +
1953 pane[TOP_RIGHT_PANE]->w,
1954 mwindow->theme->mcanvas_h -
1956 pane[TOP_LEFT_PANE]->resize_event(
1957 pane[TOP_LEFT_PANE]->x,
1958 pane[TOP_LEFT_PANE]->y,
1959 cursor_x - mwindow->theme->pane_w,
1960 cursor_y - mwindow->theme->pane_h);
1961 pane[TOP_RIGHT_PANE]->resize_event(
1962 mwindow->theme->mcanvas_x +
1964 mwindow->theme->mcanvas_y,
1965 mwindow->theme->mcanvas_x +
1966 mwindow->theme->mcanvas_w -
1968 cursor_y - mwindow->theme->pane_h);
1969 pane[BOTTOM_LEFT_PANE]->create_objects();
1970 pane[BOTTOM_RIGHT_PANE]->create_objects();
1973 if(vertical_panes())
1975 // create horizontal panes
1976 //printf("MWindowGUI::load_panes %d\n", __LINE__);
1977 pane[TOP_RIGHT_PANE] = new TimelinePane(mwindow,
1979 mwindow->theme->mcanvas_x +
1981 mwindow->theme->mcanvas_y,
1982 mwindow->theme->mcanvas_x +
1983 mwindow->theme->mcanvas_w -
1985 cursor_y - mwindow->theme->pane_h);
1986 pane[BOTTOM_RIGHT_PANE] = new TimelinePane(mwindow,
1988 pane[TOP_RIGHT_PANE]->x,
1989 mwindow->theme->mcanvas_y +
1991 pane[TOP_RIGHT_PANE]->w,
1992 mwindow->theme->mcanvas_h -
1994 pane[TOP_LEFT_PANE]->resize_event(
1995 pane[TOP_LEFT_PANE]->x,
1996 pane[TOP_LEFT_PANE]->y,
1997 cursor_x - mwindow->theme->pane_w,
1998 cursor_y - mwindow->theme->pane_h);
1999 pane[BOTTOM_LEFT_PANE]->resize_event(
2000 pane[TOP_LEFT_PANE]->x,
2001 mwindow->theme->mcanvas_y +
2003 mwindow->theme->mcanvas_x +
2004 mwindow->theme->mcanvas_w -
2005 cursor_x - mwindow->theme->pane_w,
2006 mwindow->theme->mcanvas_h -
2008 pane[TOP_RIGHT_PANE]->create_objects();
2009 pane[BOTTOM_RIGHT_PANE]->create_objects();
2016 //printf("MWindowGUI::load_panes %d\n", __LINE__);
2017 pane[TOP_LEFT_PANE]->resize_event(
2018 pane[TOP_LEFT_PANE]->x,
2019 pane[TOP_LEFT_PANE]->y,
2020 cursor_x - mwindow->theme->pane_w,
2021 cursor_y - mwindow->theme->pane_h);
2022 pane[TOP_RIGHT_PANE]->resize_event(
2023 mwindow->theme->mcanvas_x +
2025 mwindow->theme->mcanvas_y,
2026 mwindow->theme->mcanvas_x +
2027 mwindow->theme->mcanvas_w -
2029 cursor_y - mwindow->theme->pane_h);
2030 pane[BOTTOM_LEFT_PANE]->resize_event(
2031 pane[TOP_LEFT_PANE]->x,
2032 mwindow->theme->mcanvas_y +
2034 mwindow->theme->mcanvas_x +
2035 mwindow->theme->mcanvas_w -
2036 cursor_x - mwindow->theme->pane_w,
2037 mwindow->theme->mcanvas_h -
2039 pane[BOTTOM_RIGHT_PANE]->resize_event(
2040 pane[TOP_RIGHT_PANE]->x,
2041 mwindow->theme->mcanvas_y +
2043 pane[TOP_RIGHT_PANE]->w,
2044 mwindow->theme->mcanvas_h -
2053 if(pane[BOTTOM_LEFT_PANE]) delete pane[BOTTOM_LEFT_PANE];
2054 if(pane[BOTTOM_RIGHT_PANE]) delete pane[BOTTOM_RIGHT_PANE];
2055 pane[BOTTOM_LEFT_PANE] = 0;
2056 pane[BOTTOM_RIGHT_PANE] = 0;
2058 if(!pane[TOP_RIGHT_PANE])
2060 pane[TOP_RIGHT_PANE] = new TimelinePane(mwindow,
2062 mwindow->theme->mcanvas_x +
2064 mwindow->theme->mcanvas_y,
2065 mwindow->theme->mcanvas_x +
2066 mwindow->theme->mcanvas_w -
2068 mwindow->theme->mcanvas_h);
2069 pane[TOP_LEFT_PANE]->resize_event(
2070 mwindow->theme->mcanvas_x,
2071 mwindow->theme->mcanvas_y,
2072 cursor_x - mwindow->theme->pane_w,
2073 mwindow->theme->mcanvas_h);
2074 pane[TOP_RIGHT_PANE]->create_objects();
2078 pane[TOP_LEFT_PANE]->resize_event(
2079 mwindow->theme->mcanvas_x,
2080 mwindow->theme->mcanvas_y,
2081 cursor_x - mwindow->theme->pane_w,
2082 mwindow->theme->mcanvas_h);
2083 pane[TOP_RIGHT_PANE]->resize_event(
2084 mwindow->theme->mcanvas_x +
2086 pane[TOP_RIGHT_PANE]->y,
2087 mwindow->theme->mcanvas_x +
2088 mwindow->theme->mcanvas_w -
2090 mwindow->theme->mcanvas_h);
2098 if(pane[TOP_RIGHT_PANE]) delete pane[TOP_RIGHT_PANE];
2099 if(pane[BOTTOM_RIGHT_PANE]) delete pane[BOTTOM_RIGHT_PANE];
2100 pane[TOP_RIGHT_PANE] = 0;
2101 pane[BOTTOM_RIGHT_PANE] = 0;
2103 if(!pane[BOTTOM_LEFT_PANE])
2105 //printf("MWindowGUI::load_panes %d\n", __LINE__);
2106 pane[BOTTOM_LEFT_PANE] = new TimelinePane(mwindow,
2108 mwindow->theme->mcanvas_x,
2109 mwindow->theme->mcanvas_y +
2111 mwindow->theme->mcanvas_w,
2112 mwindow->theme->mcanvas_h -
2114 pane[TOP_LEFT_PANE]->resize_event(
2115 mwindow->theme->mcanvas_x,
2116 mwindow->theme->mcanvas_y,
2117 mwindow->theme->mcanvas_w,
2118 pane[BOTTOM_LEFT_PANE]->y -
2119 mwindow->theme->mcanvas_y -
2120 mwindow->theme->pane_h);
2121 pane[BOTTOM_LEFT_PANE]->create_objects();
2125 pane[TOP_LEFT_PANE]->resize_event(
2126 mwindow->theme->mcanvas_x,
2127 mwindow->theme->mcanvas_y,
2128 mwindow->theme->mcanvas_w,
2129 cursor_y - mwindow->theme->pane_h);
2130 pane[BOTTOM_LEFT_PANE]->resize_event(
2131 pane[BOTTOM_LEFT_PANE]->x,
2133 mwindow->theme->mcanvas_y,
2134 mwindow->theme->mcanvas_w,
2135 mwindow->theme->mcanvas_h -
2142 if(pane[TOP_RIGHT_PANE]) delete pane[TOP_RIGHT_PANE];
2143 if(pane[BOTTOM_RIGHT_PANE]) delete pane[BOTTOM_RIGHT_PANE];
2144 if(pane[BOTTOM_LEFT_PANE]) delete pane[BOTTOM_LEFT_PANE];
2145 pane[TOP_RIGHT_PANE] = 0;
2146 pane[BOTTOM_RIGHT_PANE] = 0;
2147 pane[BOTTOM_LEFT_PANE] = 0;
2148 pane[TOP_LEFT_PANE]->resize_event(
2149 mwindow->theme->mcanvas_x,
2150 mwindow->theme->mcanvas_y,
2151 mwindow->theme->mcanvas_w,
2152 mwindow->theme->mcanvas_h);
2155 update_pane_dividers();
2158 resource_thread->start_draw();
2161 void MWindowGUI::update_pane_dividers()
2164 if(horizontal_panes() || total_panes() == 4)
2166 int x = pane[TOP_RIGHT_PANE]->x - mwindow->theme->pane_w;
2167 int y = mwindow->theme->mcanvas_y;
2168 int h = mwindow->theme->mcanvas_h;
2172 add_subwindow(x_divider = new PaneDivider(
2173 mwindow, x, y, h, 1));
2174 x_divider->create_objects();
2178 x_divider->reposition_window(x, y, h);
2191 if(vertical_panes() || total_panes() == 4)
2193 int x = mwindow->theme->mcanvas_x;
2194 int y = pane[BOTTOM_LEFT_PANE]->y -
2195 mwindow->theme->pane_h;
2196 int w = mwindow->theme->mcanvas_w;
2199 add_subwindow(y_divider = new PaneDivider(
2200 mwindow, x, y, w, 0));
2201 y_divider->create_objects();
2205 y_divider->reposition_window(x, y, w);
2219 void MWindowGUI::draw_samplemovement()
2226 update_scrollbars(1);
2229 void MWindowGUI::draw_trackmovement()
2231 update_scrollbars(0);
2238 PaneButton::PaneButton(MWindow *mwindow, int x, int y)
2239 : BC_Button(x, y, mwindow->theme->get_image_set("pane"))
2241 this->mwindow = mwindow;
2244 int PaneButton::cursor_motion_event()
2246 if(get_top_level()->get_button_down() &&
2248 get_status() == BUTTON_DOWNHI &&
2251 // printf("PaneButton::cursor_motion_event %d\n", __LINE__);
2253 if(get_cursor_x() < 0 && !mwindow->gui->dragging_pane)
2255 mwindow->gui->start_x_pane_drag();
2258 if(get_cursor_y() < 0 && !mwindow->gui->dragging_pane)
2260 mwindow->gui->start_y_pane_drag();
2264 mwindow->gui->handle_pane_drag();
2266 int result = BC_Button::cursor_motion_event();
2270 int PaneButton::button_release_event()
2272 mwindow->gui->stop_pane_drag();
2274 int result = BC_Button::button_release_event();
2279 FFMpegToggle::FFMpegToggle(MWindow *mwindow, MButtons *mbuttons, int x, int y)
2280 : BC_Toggle(x, y, mwindow->theme->ffmpeg_toggle, mwindow->preferences->ffmpeg_early_probe)
2282 this->mwindow = mwindow;
2283 this->mbuttons = mbuttons;
2284 set_tooltip( mwindow->preferences->ffmpeg_early_probe ?
2285 _("Try FFMpeg first") : _("Try FFMpeg last"));
2288 FFMpegToggle::~FFMpegToggle()
2292 int FFMpegToggle::handle_event()
2294 mwindow->preferences->ffmpeg_early_probe = get_value();
2295 set_tooltip( mwindow->preferences->ffmpeg_early_probe ?
2296 _("Try FFMpeg first") : _("Try FFMpeg last"));
2297 mwindow->show_warning(&mwindow->preferences->warn_indexes,
2298 _("Changing the base codecs may require rebuilding indexes."));