4 * Copyright (C) 1997-2014 Adam Williams <broadcast at earthling dot net>
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 #include "androidcontrol.h"
23 #include "awindowgui.h"
25 #include "bcdisplayinfo.h"
27 #include "bcsignals.h"
29 #include "cwindowgui.h"
31 #include "channelinfo.h"
34 #include "editpopup.h"
37 #include "edlsession.h"
38 #include "filesystem.h"
39 #include "keyframepopup.h"
42 #include "localsession.h"
43 #include "mainclock.h"
44 #include "maincursor.h"
46 #include "mainsession.h"
50 #include "mwindowgui.h"
52 #include "panedividers.h"
55 #include "pluginpopup.h"
56 #include "pluginset.h"
57 #include "preferences.h"
59 #include "recordgui.h"
60 #include "renderengine.h"
61 #include "resourcethread.h"
62 #include "samplescroll.h"
63 #include "shbtnprefs.h"
64 #include "statusbar.h"
67 #include "trackcanvas.h"
68 #include "trackscroll.h"
70 #include "transitionpopup.h"
71 #include "vwindowgui.h"
75 #define PANE_DRAG_MARGIN MAX(mwindow->theme->pane_w, mwindow->theme->pane_h)
78 // the main window uses its own private colormap for video
79 MWindowGUI::MWindowGUI(MWindow *mwindow)
80 : BC_Window(_(PROGRAM_NAME ": Program"),
81 mwindow->session->mwindow_x,
82 mwindow->session->mwindow_y,
83 mwindow->session->mwindow_w,
84 mwindow->session->mwindow_h,
91 this->mwindow = mwindow;
98 focused_pane = TOP_LEFT_PANE;
107 for(int i = 0; i < TOTAL_PANES; i++)
126 cwindow_remote_handler = 0;
127 record_remote_handler = 0;
132 MWindowGUI::~MWindowGUI()
134 delete android_control;
135 delete cwindow_remote_handler;
136 delete record_remote_handler;
137 delete remote_control;
138 delete keyvalue_popup;
139 // delete samplescroll;
140 // delete trackscroll;
141 for(int i = 0; i < TOTAL_PANES; i++)
142 if(pane[i]) delete pane[i];
144 delete render_engine;
145 delete resource_thread;
146 resource_pixmaps.remove_all_objects();
157 void MWindowGUI::get_scrollbars(int flush)
159 //int64_t h_needed = mwindow->edl->get_tracks_height(mwindow->theme);
160 //int64_t w_needed = mwindow->edl->get_tracks_width();
161 int need_xscroll = 0;
162 int need_yscroll = 0;
163 view_w = mwindow->theme->mcanvas_w;
164 view_h = mwindow->theme->mcanvas_h;
166 // Scrollbars are constitutive
167 need_xscroll = need_yscroll = 1;
168 view_h = mwindow->theme->mcanvas_h;
169 view_w = mwindow->theme->mcanvas_w;
171 // for(int i = 0; i < 2; i++)
173 // if(w_needed > view_w)
176 // view_h = mwindow->theme->mcanvas_h - SCROLL_SPAN;
181 // if(h_needed > view_h)
184 // view_w = mwindow->theme->mcanvas_w - SCROLL_SPAN;
189 //printf("MWindowGUI::get_scrollbars 1\n");
191 if(canvas && (view_w != canvas->get_w() || view_h != canvas->get_h()))
193 canvas->reposition_window(mwindow->theme->mcanvas_x,
194 mwindow->theme->mcanvas_y,
202 add_subwindow(samplescroll = new SampleScroll(mwindow,
204 mwindow->theme->mhscroll_x,
205 mwindow->theme->mhscroll_y,
206 mwindow->theme->mhscroll_w));
208 samplescroll->resize_event();
210 samplescroll->set_position(0);
214 if(samplescroll) delete samplescroll;
216 mwindow->edl->local_session->view_start = 0;
222 //printf("MWindowGUI::get_scrollbars 1.1 %p %p\n", this, canvas);
224 add_subwindow(trackscroll = new TrackScroll(mwindow,
226 mwindow->theme->mvscroll_x,
227 mwindow->theme->mvscroll_y,
228 mwindow->theme->mvscroll_h));
230 trackscroll->resize_event();
233 //printf("MWindowGUI::get_scrollbars 1.2\n");
234 trackscroll->update_length(mwindow->edl->get_tracks_height(mwindow->theme),
235 mwindow->edl->local_session->track_start,
238 //printf("MWindowGUI::get_scrollbars 1.3\n");
242 if(trackscroll) delete trackscroll;
244 mwindow->edl->local_session->track_start = 0;
247 if(flush) this->flush();
252 void MWindowGUI::create_objects()
256 resource_thread = new ResourceThread(mwindow, this);
257 resource_thread->create_objects();
260 if(debug) printf("MWindowGUI::create_objects %d\n", __LINE__);
261 set_icon(mwindow->theme->get_image("mwindow_icon"));
262 remote_control = new RemoteControl(this);
263 cwindow_remote_handler = new CWindowRemoteHandler(remote_control);
264 record_remote_handler = new RecordRemoteHandler(remote_control);
265 mwindow->reset_android_remote();
267 if(debug) printf("MWindowGUI::create_objects %d\n", __LINE__);
269 int x = get_w() - MainShBtns::calculate_w(0);
270 add_subwindow(mainmenu = new MainMenu(mwindow, this, x));
271 mainmenu->create_objects();
272 add_subwindow(mainshbtns = new MainShBtns(mwindow, x, -1));
273 mainshbtns->load(mwindow->preferences);
274 mwindow->theme->get_mwindow_sizes(this, get_w(), get_h());
275 mwindow->theme->draw_mwindow_bg(this);
276 if(debug) printf("MWindowGUI::create_objects %d\n", __LINE__);
278 add_subwindow(mbuttons = new MButtons(mwindow, this));
279 mbuttons->create_objects();
280 add_subwindow(ffmpeg_toggle = new FFMpegToggle(mwindow, mbuttons, menu_w(), menu_h()+2));
282 pane[TOP_LEFT_PANE] = new TimelinePane(mwindow,
284 mwindow->theme->mcanvas_x,
285 mwindow->theme->mcanvas_y,
286 mwindow->theme->mcanvas_w,
287 mwindow->theme->mcanvas_h);
288 pane[TOP_LEFT_PANE]->create_objects();
290 // add_subwindow(timebar = new MTimeBar(mwindow,
292 // mwindow->theme->mtimebar_x,
293 // mwindow->theme->mtimebar_y,
294 // mwindow->theme->mtimebar_w,
295 // mwindow->theme->mtimebar_h));
296 // timebar->create_objects();
298 // if(debug) printf("MWindowGUI::create_objects %d\n", __LINE__);
299 // add_subwindow(patchbay = new PatchBay(mwindow, this));
300 // patchbay->create_objects();
302 // if(debug) printf("MWindowGUI::create_objects %d\n", __LINE__);
303 // get_scrollbars(0);
305 // if(debug) printf("MWindowGUI::create_objects %d\n", __LINE__);
306 // mwindow->gui->add_subwindow(canvas = new TrackCanvas(mwindow, this));
307 // canvas->create_objects();
310 if(debug) printf("MWindowGUI::create_objects %d\n", __LINE__);
311 add_subwindow(zoombar = new ZoomBar(mwindow, this));
312 zoombar->create_objects();
315 if(debug) printf("MWindowGUI::create_objects %d\n", __LINE__);
316 add_subwindow(statusbar = new StatusBar(mwindow, this));
317 statusbar->create_objects();
321 if(debug) printf("MWindowGUI::create_objects %d\n", __LINE__);
322 add_subwindow(mainclock = new MainClock(mwindow,
323 mwindow->theme->mclock_x,
324 mwindow->theme->mclock_y,
325 mwindow->theme->mclock_w));
326 mainclock->set_position_offset( (double)
327 (mwindow->edl->session->get_frame_offset() /
328 mwindow->edl->session->frame_rate));
329 if(debug) printf("MWindowGUI::create_objects %d\n", __LINE__);
330 mainclock->update(0);
334 // if(debug) printf("MWindowGUI::create_objects %d\n", __LINE__);
335 // cursor = new MainCursor(mwindow, this);
336 // cursor->create_objects();
339 if(debug) printf("MWindowGUI::create_objects %d\n", __LINE__);
340 add_subwindow(edit_menu = new EditPopup(mwindow, this));
341 edit_menu->create_objects();
344 if(debug) printf("MWindowGUI::create_objects %d\n", __LINE__);
345 add_subwindow(plugin_menu = new PluginPopup(mwindow, this));
346 plugin_menu->create_objects();
349 if(debug) printf("MWindowGUI::create_objects %d\n", __LINE__);
350 add_subwindow(keyframe_menu = new KeyframePopup(mwindow, this));
351 keyframe_menu->create_objects();
352 add_subwindow(keyframe_hide = new KeyframeHidePopup(mwindow, this));
353 keyframe_hide->create_objects();
356 if(debug) printf("MWindowGUI::create_objects %d\n", __LINE__);
357 add_subwindow(transition_menu = new TransitionPopup(mwindow, this));
358 transition_menu->create_objects();
361 channel_info = new ChannelInfo(mwindow);
363 db_window = new DbWindow(mwindow);
364 swindow = new SWindow(mwindow);
366 if(debug) printf("MWindowGUI::create_objects %d\n", __LINE__);
368 add_subwindow(pane_button = new PaneButton(mwindow,
369 get_w() - mwindow->theme->get_image_set("pane")[0]->get_w(),
370 mwindow->theme->mzoom_y + 1 - mwindow->theme->get_image_set("pane")[0]->get_h()));
372 pane[TOP_LEFT_PANE]->canvas->activate();
374 if(debug) printf("MWindowGUI::create_objects %d\n", __LINE__);
377 void MWindowGUI::redraw_time_dependancies()
379 zoombar->redraw_time_dependancies();
380 for(int i = 0; i < TOTAL_PANES; i++)
381 if(pane[i] && pane[i]->timebar) pane[i]->timebar->update(0);
382 mainclock->update(mwindow->edl->local_session->get_selectionstart(1));
385 int MWindowGUI::focus_in_event()
387 for(int i = 0; i < TOTAL_PANES; i++)
388 if(pane[i]) pane[i]->cursor->focus_in_event();
392 int MWindowGUI::focus_out_event()
394 for(int i = 0; i < TOTAL_PANES; i++)
395 if(pane[i]) pane[i]->cursor->focus_out_event();
400 int MWindowGUI::resize_event(int w, int h)
402 //printf("MWindowGUI::resize_event %d\n", __LINE__);
403 mwindow->session->mwindow_w = w;
404 mwindow->session->mwindow_h = h;
405 int x = w - MainShBtns::calculate_w(0);
406 mainmenu->resize_event(x, mainmenu->get_h());
407 mainshbtns->reposition_window(x, -1);
408 ffmpeg_toggle->reposition_window(menu_w(), menu_h()+2);
409 mwindow->theme->get_mwindow_sizes(this, w, h);
410 mwindow->theme->draw_mwindow_bg(this);
411 mbuttons->resize_event();
412 statusbar->resize_event();
413 zoombar->resize_event();
415 resource_thread->stop_draw(1);
417 if(total_panes() > 1)
419 if(horizontal_panes())
421 // printf("MWindowGUI::resize_event %d %d %d\n",
423 // pane[TOP_RIGHT_PANE]->x,
424 // mwindow->theme->mcanvas_w -
425 // BC_ScrollBar::get_span(SCROLL_VERT) -
426 // PANE_DRAG_MARGIN);
427 if(pane[TOP_RIGHT_PANE]->x >= mwindow->theme->mcanvas_w -
428 BC_ScrollBar::get_span(SCROLL_VERT) -
431 delete_x_pane(pane[TOP_RIGHT_PANE]->x);
432 mwindow->edl->local_session->x_pane = -1;
438 if(pane[BOTTOM_LEFT_PANE]->y >= mwindow->theme->mzoom_y -
439 BC_ScrollBar::get_span(SCROLL_HORIZ) -
442 delete_y_pane(pane[BOTTOM_LEFT_PANE]->y);
443 mwindow->edl->local_session->y_pane = -1;
448 if(pane[TOP_RIGHT_PANE]->x >= mwindow->theme->mcanvas_w -
449 BC_ScrollBar::get_span(SCROLL_VERT) -
452 delete_x_pane(pane[TOP_RIGHT_PANE]->x);
453 mwindow->edl->local_session->x_pane = -1;
456 if(pane[BOTTOM_LEFT_PANE]->y >= mwindow->theme->mzoom_y -
457 BC_ScrollBar::get_span(SCROLL_HORIZ) -
460 delete_y_pane(pane[BOTTOM_LEFT_PANE]->y);
461 mwindow->edl->local_session->y_pane = -1;
466 if(total_panes() == 1)
468 pane[TOP_LEFT_PANE]->resize_event(
469 mwindow->theme->mcanvas_x,
470 mwindow->theme->mcanvas_y,
471 mwindow->theme->mcanvas_w,
472 mwindow->theme->mcanvas_h);
475 if(horizontal_panes())
477 pane[TOP_LEFT_PANE]->resize_event(
478 pane[TOP_LEFT_PANE]->x,
479 pane[TOP_LEFT_PANE]->y,
480 pane[TOP_LEFT_PANE]->w,
481 mwindow->theme->mcanvas_h);
482 pane[TOP_RIGHT_PANE]->resize_event(
483 pane[TOP_RIGHT_PANE]->x,
484 pane[TOP_RIGHT_PANE]->y,
485 mwindow->theme->mcanvas_w - pane[TOP_RIGHT_PANE]->x,
486 mwindow->theme->mcanvas_h);
491 pane[TOP_LEFT_PANE]->resize_event(
492 pane[TOP_LEFT_PANE]->x,
493 pane[TOP_LEFT_PANE]->y,
494 mwindow->theme->mcanvas_w,
495 pane[TOP_LEFT_PANE]->h);
496 pane[BOTTOM_LEFT_PANE]->resize_event(
497 pane[BOTTOM_LEFT_PANE]->x,
498 pane[BOTTOM_LEFT_PANE]->y,
499 mwindow->theme->mcanvas_w,
500 mwindow->theme->mcanvas_y +
501 mwindow->theme->mcanvas_h -
502 pane[BOTTOM_LEFT_PANE]->y);
506 pane[TOP_LEFT_PANE]->resize_event(
507 pane[TOP_LEFT_PANE]->x,
508 pane[TOP_LEFT_PANE]->y,
509 pane[TOP_LEFT_PANE]->w,
510 pane[TOP_LEFT_PANE]->h);
511 pane[TOP_RIGHT_PANE]->resize_event(
512 pane[TOP_RIGHT_PANE]->x,
513 pane[TOP_RIGHT_PANE]->y,
514 mwindow->theme->mcanvas_w - pane[TOP_RIGHT_PANE]->x,
515 pane[TOP_RIGHT_PANE]->h);
516 pane[BOTTOM_LEFT_PANE]->resize_event(
517 pane[BOTTOM_LEFT_PANE]->x,
518 pane[BOTTOM_LEFT_PANE]->y,
519 pane[BOTTOM_LEFT_PANE]->w,
520 mwindow->theme->mcanvas_y +
521 mwindow->theme->mcanvas_h -
522 pane[BOTTOM_LEFT_PANE]->y);
523 pane[BOTTOM_RIGHT_PANE]->resize_event(
524 pane[BOTTOM_RIGHT_PANE]->x,
525 pane[BOTTOM_RIGHT_PANE]->y,
526 mwindow->theme->mcanvas_w -
527 pane[BOTTOM_RIGHT_PANE]->x,
528 mwindow->theme->mcanvas_y +
529 mwindow->theme->mcanvas_h -
530 pane[BOTTOM_RIGHT_PANE]->y);
533 update_pane_dividers();
534 pane_button->reposition_window(w - mwindow->theme->get_image_set("pane")[0]->get_w(),
535 mwindow->theme->mzoom_y + 1 - mwindow->theme->get_image_set("pane")[0]->get_h());
536 resource_thread->start_draw();
542 int MWindowGUI::total_panes()
545 for(int i = 0; i < TOTAL_PANES; i++)
550 int MWindowGUI::vertical_panes()
552 return total_panes() == 2 &&
553 pane[TOP_LEFT_PANE] &&
554 pane[BOTTOM_LEFT_PANE];
557 int MWindowGUI::horizontal_panes()
559 return total_panes() == 2 &&
560 pane[TOP_LEFT_PANE] &&
561 pane[TOP_RIGHT_PANE];
564 TimelinePane* MWindowGUI::get_focused_pane()
566 if(pane[focused_pane]) return pane[focused_pane];
567 for(int i = 0; i < TOTAL_PANES; i++)
569 if(pane[i]) return pane[i];
574 void MWindowGUI::activate_timeline()
576 if(pane[focused_pane])
578 pane[focused_pane]->activate();
582 for(int i = 0; i < TOTAL_PANES; i++)
593 void MWindowGUI::deactivate_timeline()
595 for(int i = 0; i < TOTAL_PANES; i++)
599 pane[i]->canvas->deactivate();
604 void MWindowGUI::update_title(char *path)
607 char filename[BCTEXTLEN], string[BCTEXTLEN];
608 fs.extract_name(filename, path);
609 sprintf(string, _(PROGRAM_NAME ": %s"), filename);
611 //printf("MWindowGUI::update_title %s\n", string);
615 void MWindowGUI::draw_overlays(int flash_it)
617 for(int i = 0; i < TOTAL_PANES; i++)
621 pane[i]->canvas->draw_overlays();
622 if(flash_it) pane[i]->canvas->flash();
627 void MWindowGUI::update_timebar(int flush_it)
629 for(int i = 0; i < TOTAL_PANES; i++)
631 if(pane[i] && pane[i]->timebar)
633 pane[i]->timebar->update(flush_it);
638 void MWindowGUI::update_timebar_highlights()
640 for(int i = 0; i < TOTAL_PANES; i++)
642 if(pane[i] && pane[i]->timebar)
644 pane[i]->timebar->update_highlights();
650 void MWindowGUI::update_patchbay()
652 for(int i = 0; i < TOTAL_PANES; i++)
654 if(pane[i] && pane[i]->patchbay)
656 pane[i]->patchbay->update();
661 void MWindowGUI::draw_indexes(Indexable *indexable)
663 for(int i = 0; i < TOTAL_PANES; i++)
667 pane[i]->canvas->draw_indexes(indexable);
672 void MWindowGUI::draw_canvas(int mode /* = 0 */, int hide_cursor /* = 1 */)
674 if(mode != IGNORE_THREAD)
676 resource_thread->stop_draw(1);
680 for(int i = 0; i < TOTAL_PANES; i++)
684 pane[i]->canvas->draw(mode, hide_cursor);
689 if(mode != IGNORE_THREAD)
691 resource_thread->start_draw();
696 void MWindowGUI::flash_canvas(int flush)
698 for(int i = 0; i < TOTAL_PANES; i++)
702 pane[i]->canvas->flash(flush);
707 void MWindowGUI::draw_cursor(int do_plugintoggles)
709 for(int i = 0; i < TOTAL_PANES; i++)
713 pane[i]->cursor->draw(do_plugintoggles);
718 void MWindowGUI::show_cursor(int do_plugintoggles)
720 for(int i = 0; i < TOTAL_PANES; i++)
724 pane[i]->cursor->show(do_plugintoggles);
729 void MWindowGUI::hide_cursor(int do_plugintoggles)
731 for(int i = 0; i < TOTAL_PANES; i++)
735 pane[i]->cursor->hide(do_plugintoggles);
740 void MWindowGUI::update_cursor()
742 for(int i = 0; i < TOTAL_PANES; i++)
746 pane[i]->cursor->update();
751 void MWindowGUI::set_playing_back(int value)
753 for(int i = 0; i < TOTAL_PANES; i++)
757 pane[i]->cursor->playing_back = value;
762 void MWindowGUI::update_plugintoggles()
764 for(int i = 0; i < TOTAL_PANES; i++)
768 pane[i]->canvas->refresh_plugintoggles();
774 void MWindowGUI::update_scrollbars(int flush)
776 for(int i = 0; i < TOTAL_PANES; i++)
780 pane[i]->update(1, 0, 0, 0);
783 if(flush) this->flush();
786 void MWindowGUI::reset_meters()
788 for(int i = 0; i < TOTAL_PANES; i++)
790 if(pane[i] && pane[i]->patchbay)
792 pane[i]->patchbay->reset_meters();
797 void MWindowGUI::stop_meters()
799 for(int i = 0; i < TOTAL_PANES; i++)
801 if(pane[i] && pane[i]->patchbay)
803 pane[i]->patchbay->stop_meters();
808 void MWindowGUI::update_meters(ArrayList<double> *module_levels)
810 for(int i = 0; i < TOTAL_PANES; i++)
812 if(pane[i] && pane[i]->patchbay)
814 pane[i]->patchbay->update_meters(module_levels);
819 void MWindowGUI::set_editing_mode(int flush)
821 for(int i = 0; i < TOTAL_PANES; i++)
825 pane[i]->canvas->update_cursor(flush);
830 void MWindowGUI::set_meter_format(int mode, int min, int max)
832 for(int i = 0; i < TOTAL_PANES; i++)
834 if(pane[i] && pane[i]->patchbay)
836 pane[i]->patchbay->set_meter_format(mode, min, max);
841 void MWindowGUI::update(int scrollbars,
850 if(debug) PRINT_TRACE
854 mwindow->edl->tracks->update_y_pixels(mwindow->theme);
856 if(do_canvas && do_canvas != IGNORE_THREAD)
858 resource_thread->stop_draw(1);
861 for(int i = 0; i < TOTAL_PANES; i++)
863 if(pane[i]) pane[i]->update(scrollbars,
869 if(do_canvas && do_canvas != IGNORE_THREAD)
871 resource_thread->start_draw();
874 // if(scrollbars) this->get_scrollbars(0);
875 // if(timebar) this->timebar->update(0);
876 if(zoombar) this->zoombar->update();
877 // if(patchbay) this->patchbay->update();
878 if(clock) this->mainclock->update(
879 mwindow->edl->local_session->get_selectionstart(1));
880 if(debug) PRINT_TRACE
886 // this->canvas->draw(do_canvas);
887 // this->cursor->show();
888 // this->canvas->flash(0);
889 // Activate causes the menubar to deactivate. Don't want this for
891 // if(canvas != IGNORE_THREAD) this->canvas->activate();
893 if(debug) PRINT_TRACE
897 if(buttonbar) mbuttons->update();
898 if(debug) PRINT_TRACE
900 // Can't age if the cache called this to draw missing picons
901 // or the GUI is updating the status of the draw toggle.
902 if(do_canvas != FORCE_REDRAW && do_canvas != IGNORE_THREAD)
905 mwindow->age_caches();
906 lock_window("MWindowGUI::update");
910 if(debug) PRINT_TRACE
913 int MWindowGUI::visible(int64_t x1, int64_t x2, int64_t view_x1, int64_t view_x2)
915 return (x1 >= view_x1 && x1 < view_x2) ||
916 (x2 > view_x1 && x2 <= view_x2) ||
917 (x1 <= view_x1 && x2 >= view_x2);
921 void MWindowGUI::show_message(const char *message, int color)
923 statusbar->set_message(message, color);
925 void MWindowGUI::set_default_message(const char *message)
927 statusbar->set_default_message(message);
929 void MWindowGUI::reset_default_message()
931 statusbar->reset_default_message();
933 void MWindowGUI::default_message()
935 statusbar->default_message();
938 // Drag motion called from other window
939 int MWindowGUI::drag_motion()
941 if(get_hidden()) return 0;
943 Track *over_track = 0;
945 PluginSet *over_pluginset = 0;
946 Plugin *over_plugin = 0;
951 drag_popup->cursor_motion_event();
955 // there's no point in drawing highlights has until drag operation has been set
956 if (!mwindow->session->current_operation)
959 for(int i = 0; i < TOTAL_PANES; i++)
961 if(pane[i]) pane[i]->canvas->drag_motion(
968 if(mwindow->session->track_highlighted != over_track)
970 mwindow->session->track_highlighted = over_track;
974 if(mwindow->session->edit_highlighted != over_edit)
976 mwindow->session->edit_highlighted = over_edit;
980 if(mwindow->session->pluginset_highlighted != over_pluginset)
982 mwindow->session->pluginset_highlighted = over_pluginset;
986 if(mwindow->session->plugin_highlighted != over_plugin)
988 mwindow->session->plugin_highlighted = over_plugin;
992 if( mwindow->session->current_operation == DRAG_ASSET ||
993 mwindow->session->current_operation == DRAG_EDIT ||
994 mwindow->session->current_operation == DRAG_AEFFECT_COPY ||
995 mwindow->session->current_operation == DRAG_VEFFECT_COPY )
1001 // printf("drag_motion %d %d over_track=%p over_edit=%p\n",
1008 lock_window("MWindowGUI::drag_motion");
1015 int MWindowGUI::drag_stop()
1017 if(get_hidden()) return 0;
1018 int result = 0, redraw = 0;
1020 for(int i = 0; i < TOTAL_PANES; i++)
1022 if(pane[i]) result |= pane[i]->canvas->drag_stop(
1025 mwindow->edl->optimize();
1027 // since we don't have subwindows we have to terminate any drag operation
1030 if (mwindow->session->track_highlighted
1031 || mwindow->session->edit_highlighted
1032 || mwindow->session->plugin_highlighted
1033 || mwindow->session->pluginset_highlighted)
1035 mwindow->session->track_highlighted = 0;
1036 mwindow->session->edit_highlighted = 0;
1037 mwindow->session->plugin_highlighted = 0;
1038 mwindow->session->pluginset_highlighted = 0;
1039 mwindow->session->current_operation = NO_OPERATION;
1043 //printf("TrackCanvas::drag_stop %d %d\n", redraw, mwindow->session->current_operation);
1046 mwindow->edl->tracks->update_y_pixels(mwindow->theme);
1047 update_scrollbars(0);
1062 void MWindowGUI::default_positions()
1064 //printf("MWindowGUI::default_positions 1\n");
1065 VWindow *vwindow = mwindow->vwindows.size() > DEFAULT_VWINDOW ?
1066 mwindow->vwindows.get(DEFAULT_VWINDOW) : 0;
1067 if( vwindow && !vwindow->is_running() ) vwindow = 0;
1068 if( vwindow ) vwindow->gui->lock_window("MWindowGUI::default_positions");
1069 mwindow->cwindow->gui->lock_window("MWindowGUI::default_positions");
1070 mwindow->awindow->gui->lock_window("MWindowGUI::default_positions");
1072 // printf("MWindowGUI::default_positions 1 %d %d %d %d\n", mwindow->session->vwindow_x,
1073 // mwindow->session->vwindow_y,
1074 // mwindow->session->vwindow_w,
1075 // mwindow->session->vwindow_h);
1076 reposition_window(mwindow->session->mwindow_x,
1077 mwindow->session->mwindow_y,
1078 mwindow->session->mwindow_w,
1079 mwindow->session->mwindow_h);
1080 if( vwindow ) vwindow->gui->reposition_window(mwindow->session->vwindow_x,
1081 mwindow->session->vwindow_y,
1082 mwindow->session->vwindow_w,
1083 mwindow->session->vwindow_h);
1084 mwindow->cwindow->gui->reposition_window(mwindow->session->cwindow_x,
1085 mwindow->session->cwindow_y,
1086 mwindow->session->cwindow_w,
1087 mwindow->session->cwindow_h);
1088 mwindow->awindow->gui->reposition_window(mwindow->session->awindow_x,
1089 mwindow->session->awindow_y,
1090 mwindow->session->awindow_w,
1091 mwindow->session->awindow_h);
1092 //printf("MWindowGUI::default_positions 1\n");
1094 resize_event(mwindow->session->mwindow_w,
1095 mwindow->session->mwindow_h);
1096 //printf("MWindowGUI::default_positions 1\n");
1097 if( vwindow ) vwindow->gui->resize_event(mwindow->session->vwindow_w,
1098 mwindow->session->vwindow_h);
1099 //printf("MWindowGUI::default_positions 1\n");
1100 mwindow->cwindow->gui->resize_event(mwindow->session->cwindow_w,
1101 mwindow->session->cwindow_h);
1102 //printf("MWindowGUI::default_positions 1\n");
1103 mwindow->awindow->gui->resize_event(mwindow->session->awindow_w,
1104 mwindow->session->awindow_h);
1106 //printf("MWindowGUI::default_positions 1\n");
1109 if( vwindow ) vwindow->gui->flush();
1110 mwindow->cwindow->gui->flush();
1111 mwindow->awindow->gui->flush();
1113 if( vwindow ) vwindow->gui->unlock_window();
1114 mwindow->cwindow->gui->unlock_window();
1115 mwindow->awindow->gui->unlock_window();
1116 //printf("MWindowGUI::default_positions 2\n");
1120 int MWindowGUI::button_release_event()
1122 if( keyvalue_popup ) {
1123 delete keyvalue_popup; keyvalue_popup = 0;
1129 int MWindowGUI::repeat_event(int64_t duration)
1131 // if(duration == 100)
1132 // mwindow->sync_parameters(CHANGE_ALL);
1134 for(int i = 0; i < TOTAL_PANES; i++)
1136 if(pane[i]) result = pane[i]->cursor->repeat_event(duration);
1142 int MWindowGUI::translation_event()
1144 //printf("MWindowGUI::translation_event 1 %d %d\n", get_x(), get_y());
1145 mwindow->session->mwindow_x = get_x();
1146 mwindow->session->mwindow_y = get_y();
1151 int MWindowGUI::save_defaults(BC_Hash *defaults)
1153 defaults->update("MWINDOWWIDTH", get_w());
1154 defaults->update("MWINDOWHEIGHT", get_h());
1155 mainmenu->save_defaults(defaults);
1156 BC_WindowBase::save_defaults(defaults);
1160 int MWindowGUI::keypress_event()
1162 //printf("MWindowGUI::keypress_event 1 %d\n", get_keypress());
1163 int result = mbuttons->keypress_event();
1164 if( result ) return result;
1166 switch(get_keypress()) {
1168 mwindow->toggle_editing_mode();
1172 case '1': case '2': case '3': case '4':
1173 case '5': case '6': case '7': case '8':
1174 if( !alt_down() || shift_down() ) break;
1175 if( !mwindow->select_asset(get_keypress()-'1',1) )
1180 if( !ctrl_down() ) {
1183 mbuttons->transport->handle_transport(STOP, 1, 0, 0);
1184 lock_window("MWindowGUI::keypress_event 1");
1185 mwindow->prev_edit_handle(shift_down());
1188 mwindow->move_left();
1194 if( !ctrl_down() ) {
1197 mbuttons->transport->handle_transport(STOP, 1, 0, 0);
1198 lock_window("MWindowGUI::keypress_event 2");
1199 mwindow->next_edit_handle(shift_down());
1202 mwindow->move_right();
1208 if( ctrl_down() && !alt_down() )
1209 mwindow->expand_y();
1210 else if( !ctrl_down() && alt_down() )
1211 mwindow->expand_autos(0,1,1);
1212 else if( ctrl_down() && alt_down() )
1213 mwindow->expand_autos(1,1,1);
1215 mwindow->expand_sample();
1220 if( ctrl_down() && !alt_down() )
1221 mwindow->zoom_in_y();
1222 else if( !ctrl_down() && alt_down() )
1223 mwindow->shrink_autos(0,1,1);
1224 else if( ctrl_down() && alt_down() )
1225 mwindow->shrink_autos(1,1,1);
1227 mwindow->zoom_in_sample();
1235 mwindow->expand_t();
1241 mwindow->move_down();
1243 mwindow->zoom_in_t();
1249 Track *this_track = 0;
1250 for( int i=0; i<TOTAL_PANES; ++i ) {
1251 if( !pane[i] ) continue;
1252 if( (this_track = pane[i]->over_track()) != 0 ) break;
1253 if( (this_track = pane[i]->over_patchbay()) != 0 ) break;
1256 if( get_keypress() == TAB ) { // Switch the record button
1258 this_track->record = !this_track->record ? 1 : 0;
1261 int total_selected = mwindow->edl->tracks->total_of(Tracks::RECORD);
1262 // all selected if nothing previously selected or
1263 // if this patch was previously the only one selected and armed
1264 int selected = !total_selected || (total_selected == 1 &&
1265 this_track && this_track->record ) ? 1 : 0;
1266 mwindow->edl->tracks->select_all(Tracks::RECORD, selected);
1267 if( !selected && this_track ) this_track->record = 1;
1270 update(0, 1, 0, 0, 1, 0, 1);
1272 mwindow->cwindow->update(0, 1, 1);
1273 lock_window("TrackCanvas::keypress_event 3");
1279 // since things under cursor have changed...
1281 cursor_motion_event();
1286 int MWindowGUI::keyboard_listener(BC_WindowBase *wp)
1288 return key_listener(wp->get_keypress());
1291 int MWindowGUI::key_listener(int key)
1296 if( !record->running() )
1299 record->record_gui->interrupt_thread->start(0);
1306 channel_info->toggle_scan();
1310 if( !remote_control->deactivate() )
1311 remote_control->activate();
1321 void MWindowGUI::use_android_remote(int on)
1324 delete android_control;
1325 android_control = 0;
1328 if( android_control ) return;
1329 android_control = new AndroidControl(this);
1332 int MWindowGUI::close_event()
1338 void MWindowGUI::stop_drawing()
1340 resource_thread->stop_draw(1);
1343 int MWindowGUI::menu_w()
1345 return mainmenu->get_w();
1348 int MWindowGUI::menu_h()
1350 return mainmenu->get_h();
1353 void MWindowGUI::start_x_pane_drag()
1357 x_pane_drag = new BC_Popup(this,
1358 get_abs_cursor_x(0) - mwindow->theme->pane_w,
1359 BC_DisplayInfo::get_top_border() +
1361 mwindow->theme->mcanvas_y,
1362 mwindow->theme->pane_w,
1363 mwindow->theme->mcanvas_h,
1364 mwindow->theme->drag_pane_color);
1365 x_pane_drag->draw_3segmentv(0,
1367 x_pane_drag->get_h(),
1368 mwindow->theme->get_image_set("xpane")[BUTTON_DOWNHI]);
1369 x_pane_drag->flash(1);
1374 void MWindowGUI::start_y_pane_drag()
1378 //printf("MWindowGUI::start_y_pane_drag %d %d %d\n", __LINE__, get_x(), get_y());
1379 y_pane_drag = new BC_Popup(this,
1380 BC_DisplayInfo::get_left_border() +
1382 mwindow->theme->mcanvas_x,
1383 get_abs_cursor_y(0) - mwindow->theme->pane_h,
1384 mwindow->theme->mcanvas_w,
1385 mwindow->theme->pane_h,
1386 mwindow->theme->drag_pane_color);
1387 y_pane_drag->draw_3segmenth(0,
1389 y_pane_drag->get_w(),
1390 mwindow->theme->get_image_set("ypane")[BUTTON_DOWNHI]);
1391 y_pane_drag->flash(1);
1396 void MWindowGUI::handle_pane_drag()
1402 x_pane_drag->reposition_window(
1403 get_abs_cursor_x(0) - mwindow->theme->pane_w,
1404 x_pane_drag->get_y());
1409 y_pane_drag->reposition_window(
1410 y_pane_drag->get_x(),
1411 get_abs_cursor_y(0) - mwindow->theme->pane_h);
1417 void MWindowGUI::create_x_pane(int cursor_x)
1419 if(total_panes() == 1)
1421 // create a horizontal pane
1422 // do this 1st so the resize_event knows there are 2 panes
1423 mwindow->edl->local_session->view_start[TOP_RIGHT_PANE] =
1424 mwindow->edl->local_session->view_start[TOP_LEFT_PANE] +
1426 mwindow->theme->patchbay_w;
1427 pane[TOP_RIGHT_PANE] = new TimelinePane(mwindow,
1429 mwindow->theme->mcanvas_x +
1431 mwindow->theme->mcanvas_y,
1432 mwindow->theme->mcanvas_x +
1433 mwindow->theme->mcanvas_w -
1435 mwindow->theme->mcanvas_h);
1436 pane[TOP_LEFT_PANE]->resize_event(
1437 mwindow->theme->mcanvas_x,
1438 mwindow->theme->mcanvas_y,
1439 cursor_x - mwindow->theme->pane_w,
1440 mwindow->theme->mcanvas_h);
1441 pane[TOP_RIGHT_PANE]->create_objects();
1444 if(vertical_panes())
1446 // create 2 horizontal panes
1447 mwindow->edl->local_session->track_start[TOP_RIGHT_PANE] =
1448 mwindow->edl->local_session->track_start[TOP_LEFT_PANE];
1449 mwindow->edl->local_session->track_start[BOTTOM_RIGHT_PANE] =
1450 mwindow->edl->local_session->track_start[BOTTOM_LEFT_PANE];
1451 mwindow->edl->local_session->view_start[TOP_RIGHT_PANE] =
1452 mwindow->edl->local_session->view_start[BOTTOM_RIGHT_PANE] =
1453 mwindow->edl->local_session->view_start[TOP_LEFT_PANE] +
1455 mwindow->theme->patchbay_w;
1456 pane[TOP_RIGHT_PANE] = new TimelinePane(mwindow,
1458 mwindow->theme->mcanvas_x +
1460 pane[TOP_LEFT_PANE]->y,
1461 mwindow->theme->mcanvas_x +
1462 mwindow->theme->mcanvas_w -
1464 pane[TOP_LEFT_PANE]->h);
1465 pane[BOTTOM_RIGHT_PANE] = new TimelinePane(mwindow,
1467 mwindow->theme->mcanvas_x +
1469 pane[BOTTOM_LEFT_PANE]->y,
1470 mwindow->theme->mcanvas_x +
1471 mwindow->theme->mcanvas_w -
1473 pane[BOTTOM_LEFT_PANE]->h);
1474 pane[TOP_LEFT_PANE]->resize_event(
1475 pane[TOP_LEFT_PANE]->x,
1476 pane[TOP_LEFT_PANE]->y,
1477 cursor_x - mwindow->theme->pane_w,
1478 pane[TOP_LEFT_PANE]->h);
1479 pane[BOTTOM_LEFT_PANE]->resize_event(
1480 pane[BOTTOM_LEFT_PANE]->x,
1481 pane[BOTTOM_LEFT_PANE]->y,
1482 cursor_x - mwindow->theme->pane_w,
1483 pane[BOTTOM_LEFT_PANE]->h);
1484 pane[TOP_RIGHT_PANE]->create_objects();
1485 pane[BOTTOM_RIGHT_PANE]->create_objects();
1488 if(horizontal_panes())
1490 // resize a horizontal pane
1491 mwindow->edl->local_session->view_start[TOP_RIGHT_PANE] +=
1493 pane[TOP_RIGHT_PANE]->x;
1494 if(mwindow->edl->local_session->view_start[TOP_RIGHT_PANE] < 0)
1495 mwindow->edl->local_session->view_start[TOP_RIGHT_PANE] = 0;
1496 pane[TOP_LEFT_PANE]->resize_event(
1497 mwindow->theme->mcanvas_x,
1498 mwindow->theme->mcanvas_y,
1499 cursor_x - mwindow->theme->pane_w,
1500 mwindow->theme->mcanvas_h);
1501 pane[TOP_RIGHT_PANE]->resize_event(
1502 mwindow->theme->mcanvas_x +
1504 pane[TOP_RIGHT_PANE]->y,
1505 mwindow->theme->mcanvas_x +
1506 mwindow->theme->mcanvas_w -
1508 mwindow->theme->mcanvas_h);
1512 // resize 2 horizontal panes
1513 mwindow->edl->local_session->view_start[TOP_RIGHT_PANE] +=
1515 pane[TOP_RIGHT_PANE]->x;
1516 if(mwindow->edl->local_session->view_start[TOP_RIGHT_PANE] < 0)
1517 mwindow->edl->local_session->view_start[TOP_RIGHT_PANE] = 0;
1518 mwindow->edl->local_session->view_start[BOTTOM_RIGHT_PANE] =
1519 mwindow->edl->local_session->view_start[TOP_RIGHT_PANE];
1521 pane[TOP_LEFT_PANE]->resize_event(
1522 mwindow->theme->mcanvas_x,
1523 pane[TOP_LEFT_PANE]->y,
1524 cursor_x - mwindow->theme->pane_w,
1525 pane[TOP_LEFT_PANE]->h);
1526 pane[TOP_RIGHT_PANE]->resize_event(
1527 mwindow->theme->mcanvas_x +
1529 pane[TOP_RIGHT_PANE]->y,
1530 mwindow->theme->mcanvas_x +
1531 mwindow->theme->mcanvas_w -
1533 pane[TOP_RIGHT_PANE]->h);
1534 pane[BOTTOM_LEFT_PANE]->resize_event(
1535 mwindow->theme->mcanvas_x,
1536 pane[BOTTOM_LEFT_PANE]->y,
1537 cursor_x - mwindow->theme->pane_w,
1538 pane[BOTTOM_LEFT_PANE]->h);
1539 pane[BOTTOM_RIGHT_PANE]->resize_event(
1540 mwindow->theme->mcanvas_x +
1542 pane[BOTTOM_RIGHT_PANE]->y,
1543 mwindow->theme->mcanvas_x +
1544 mwindow->theme->mcanvas_w -
1546 pane[BOTTOM_RIGHT_PANE]->h);
1552 void MWindowGUI::delete_x_pane(int cursor_x)
1554 // give left panes coordinates of right pane
1555 if(cursor_x < mwindow->theme->patchbay_w + PANE_DRAG_MARGIN &&
1556 pane[TOP_RIGHT_PANE])
1558 mwindow->edl->local_session->view_start[TOP_LEFT_PANE] =
1559 mwindow->edl->local_session->view_start[TOP_RIGHT_PANE] -
1560 pane[TOP_RIGHT_PANE]->x + mwindow->theme->patchbay_w;
1561 if(mwindow->edl->local_session->view_start[TOP_LEFT_PANE] < 0)
1562 mwindow->edl->local_session->view_start[TOP_LEFT_PANE] = 0;
1563 mwindow->edl->local_session->view_start[BOTTOM_LEFT_PANE] =
1564 mwindow->edl->local_session->view_start[TOP_LEFT_PANE];
1567 switch(total_panes())
1570 if(pane[TOP_LEFT_PANE] && pane[TOP_RIGHT_PANE])
1572 // delete right pane
1573 delete pane[TOP_RIGHT_PANE];
1574 pane[TOP_RIGHT_PANE] = 0;
1575 pane[TOP_LEFT_PANE]->resize_event(
1576 mwindow->theme->mcanvas_x,
1577 mwindow->theme->mcanvas_y,
1578 mwindow->theme->mcanvas_w,
1579 mwindow->theme->mcanvas_h);
1585 // delete right panes
1586 delete pane[TOP_RIGHT_PANE];
1587 pane[TOP_RIGHT_PANE] = 0;
1588 delete pane[BOTTOM_RIGHT_PANE];
1589 pane[BOTTOM_RIGHT_PANE] = 0;
1590 pane[TOP_LEFT_PANE]->resize_event(
1591 mwindow->theme->mcanvas_x,
1592 pane[TOP_LEFT_PANE]->y,
1593 mwindow->theme->mcanvas_w,
1594 pane[TOP_LEFT_PANE]->h);
1595 pane[BOTTOM_LEFT_PANE]->resize_event(
1596 mwindow->theme->mcanvas_x,
1597 pane[BOTTOM_LEFT_PANE]->y,
1598 mwindow->theme->mcanvas_w,
1599 pane[BOTTOM_LEFT_PANE]->h);
1604 void MWindowGUI::create_y_pane(int cursor_y)
1606 if(total_panes() == 1)
1608 mwindow->edl->local_session->view_start[BOTTOM_LEFT_PANE] =
1609 mwindow->edl->local_session->view_start[TOP_LEFT_PANE];
1610 mwindow->edl->local_session->track_start[BOTTOM_LEFT_PANE] =
1611 mwindow->edl->local_session->track_start[TOP_LEFT_PANE] +
1613 mwindow->theme->mtimebar_h;
1614 // do this 1st so the resize_event knows there are 2 panes
1615 pane[BOTTOM_LEFT_PANE] = new TimelinePane(mwindow,
1617 mwindow->theme->mcanvas_x,
1618 mwindow->theme->mcanvas_y +
1620 mwindow->theme->mcanvas_w,
1621 mwindow->theme->mcanvas_h -
1623 pane[TOP_LEFT_PANE]->resize_event(
1624 mwindow->theme->mcanvas_x,
1625 mwindow->theme->mcanvas_y,
1626 mwindow->theme->mcanvas_w,
1627 pane[BOTTOM_LEFT_PANE]->y -
1628 mwindow->theme->mcanvas_y -
1629 mwindow->theme->pane_h);
1630 pane[BOTTOM_LEFT_PANE]->create_objects();
1633 if(horizontal_panes())
1636 mwindow->edl->local_session->view_start[BOTTOM_LEFT_PANE] =
1637 mwindow->edl->local_session->view_start[TOP_LEFT_PANE];
1638 mwindow->edl->local_session->view_start[BOTTOM_RIGHT_PANE] =
1639 mwindow->edl->local_session->view_start[TOP_RIGHT_PANE];
1640 mwindow->edl->local_session->track_start[BOTTOM_LEFT_PANE] =
1641 mwindow->edl->local_session->track_start[BOTTOM_RIGHT_PANE] =
1642 mwindow->edl->local_session->track_start[TOP_LEFT_PANE] +
1644 mwindow->theme->mtimebar_h;
1646 pane[BOTTOM_LEFT_PANE] = new TimelinePane(mwindow,
1648 pane[TOP_LEFT_PANE]->x,
1649 mwindow->theme->mcanvas_y +
1651 pane[TOP_LEFT_PANE]->w,
1652 mwindow->theme->mcanvas_h -
1654 pane[BOTTOM_RIGHT_PANE] = new TimelinePane(mwindow,
1656 pane[TOP_RIGHT_PANE]->x,
1657 mwindow->theme->mcanvas_y +
1659 pane[TOP_RIGHT_PANE]->w,
1660 mwindow->theme->mcanvas_h -
1663 pane[TOP_LEFT_PANE]->resize_event(
1664 pane[TOP_LEFT_PANE]->x,
1665 pane[TOP_LEFT_PANE]->y,
1666 pane[TOP_LEFT_PANE]->w,
1667 pane[BOTTOM_LEFT_PANE]->y -
1668 mwindow->theme->mcanvas_y -
1669 mwindow->theme->pane_h);
1670 pane[TOP_RIGHT_PANE]->resize_event(
1671 pane[TOP_RIGHT_PANE]->x,
1672 pane[TOP_RIGHT_PANE]->y,
1673 pane[TOP_RIGHT_PANE]->w,
1674 pane[BOTTOM_RIGHT_PANE]->y -
1675 mwindow->theme->mcanvas_y -
1676 mwindow->theme->pane_h);
1678 pane[BOTTOM_LEFT_PANE]->create_objects();
1679 pane[BOTTOM_RIGHT_PANE]->create_objects();
1682 if(vertical_panes())
1685 mwindow->edl->local_session->track_start[BOTTOM_LEFT_PANE] +=
1687 (pane[BOTTOM_LEFT_PANE]->y - mwindow->theme->mcanvas_y);
1688 if(mwindow->edl->local_session->track_start[BOTTOM_LEFT_PANE] < 0)
1689 mwindow->edl->local_session->track_start[BOTTOM_LEFT_PANE] = 0;
1690 pane[TOP_LEFT_PANE]->resize_event(
1691 mwindow->theme->mcanvas_x,
1692 mwindow->theme->mcanvas_y,
1693 mwindow->theme->mcanvas_w,
1694 cursor_y - mwindow->theme->pane_h);
1695 pane[BOTTOM_LEFT_PANE]->resize_event(
1696 pane[BOTTOM_LEFT_PANE]->x,
1698 mwindow->theme->mcanvas_y,
1699 mwindow->theme->mcanvas_w,
1700 mwindow->theme->mcanvas_h -
1706 mwindow->edl->local_session->track_start[BOTTOM_LEFT_PANE] +=
1708 (pane[BOTTOM_LEFT_PANE]->y - mwindow->theme->mcanvas_y);
1709 if(mwindow->edl->local_session->track_start[BOTTOM_LEFT_PANE] < 0)
1710 mwindow->edl->local_session->track_start[BOTTOM_LEFT_PANE] = 0;
1711 mwindow->edl->local_session->track_start[BOTTOM_RIGHT_PANE] =
1712 mwindow->edl->local_session->track_start[BOTTOM_LEFT_PANE];
1713 pane[TOP_LEFT_PANE]->resize_event(
1714 pane[TOP_LEFT_PANE]->x,
1715 pane[TOP_LEFT_PANE]->y,
1716 pane[TOP_LEFT_PANE]->w,
1717 cursor_y - mwindow->theme->pane_h);
1718 pane[BOTTOM_LEFT_PANE]->resize_event(
1719 pane[BOTTOM_LEFT_PANE]->x,
1721 mwindow->theme->mcanvas_y,
1722 pane[BOTTOM_LEFT_PANE]->w,
1723 mwindow->theme->mcanvas_h -
1725 pane[TOP_RIGHT_PANE]->resize_event(
1726 pane[TOP_RIGHT_PANE]->x,
1727 pane[TOP_RIGHT_PANE]->y,
1728 pane[TOP_RIGHT_PANE]->w,
1729 cursor_y - mwindow->theme->pane_h);
1730 pane[BOTTOM_RIGHT_PANE]->resize_event(
1731 pane[BOTTOM_RIGHT_PANE]->x,
1733 mwindow->theme->mcanvas_y,
1734 pane[BOTTOM_RIGHT_PANE]->w,
1735 mwindow->theme->mcanvas_h -
1740 void MWindowGUI::delete_y_pane(int cursor_y)
1742 if(cursor_y < mwindow->theme->mtimebar_h +
1744 pane[BOTTOM_LEFT_PANE])
1746 // give top pane coordinates of bottom pane
1747 mwindow->edl->local_session->track_start[TOP_LEFT_PANE] =
1748 mwindow->edl->local_session->track_start[BOTTOM_LEFT_PANE] -
1749 pane[BOTTOM_LEFT_PANE]->y;
1750 if(mwindow->edl->local_session->track_start[TOP_LEFT_PANE] < 0)
1751 mwindow->edl->local_session->track_start[TOP_LEFT_PANE] = 0;
1752 mwindow->edl->local_session->track_start[TOP_RIGHT_PANE] =
1753 mwindow->edl->local_session->track_start[TOP_LEFT_PANE];
1757 switch(total_panes())
1760 delete pane[BOTTOM_LEFT_PANE];
1761 pane[BOTTOM_LEFT_PANE] = 0;
1762 pane[TOP_LEFT_PANE]->resize_event(
1763 mwindow->theme->mcanvas_x,
1764 mwindow->theme->mcanvas_y,
1765 mwindow->theme->mcanvas_w,
1766 mwindow->theme->mcanvas_h);
1770 // delete bottom 2 panes
1772 delete pane[BOTTOM_LEFT_PANE];
1773 pane[BOTTOM_LEFT_PANE] = 0;
1774 delete pane[BOTTOM_RIGHT_PANE];
1775 pane[BOTTOM_RIGHT_PANE] = 0;
1776 pane[TOP_LEFT_PANE]->resize_event(
1777 pane[TOP_LEFT_PANE]->x,
1778 mwindow->theme->mcanvas_y,
1779 pane[TOP_LEFT_PANE]->w,
1780 mwindow->theme->mcanvas_h);
1781 pane[TOP_RIGHT_PANE]->resize_event(
1782 pane[TOP_RIGHT_PANE]->x,
1783 mwindow->theme->mcanvas_y,
1784 pane[TOP_RIGHT_PANE]->w,
1785 mwindow->theme->mcanvas_h);
1790 void MWindowGUI::stop_pane_drag()
1793 resource_thread->stop_draw(1);
1797 // cursor position relative to canvas
1798 int cursor_x = x_pane_drag->get_x() -
1800 BC_DisplayInfo::get_left_border() -
1801 mwindow->theme->mcanvas_x +
1802 mwindow->theme->pane_w;
1807 if(cursor_x >= mwindow->theme->patchbay_w + PANE_DRAG_MARGIN &&
1808 cursor_x < mwindow->theme->mcanvas_w -
1809 BC_ScrollBar::get_span(SCROLL_VERT) -
1812 create_x_pane(cursor_x);
1813 mwindow->edl->local_session->x_pane = cursor_x;
1818 delete_x_pane(cursor_x);
1819 mwindow->edl->local_session->x_pane = -1;
1827 // cursor position relative to canvas
1828 int cursor_y = y_pane_drag->get_y() -
1830 BC_DisplayInfo::get_top_border() -
1831 mwindow->theme->mcanvas_y +
1832 mwindow->theme->pane_h;
1838 if(cursor_y >= mwindow->theme->mtimebar_h +
1840 cursor_y < mwindow->theme->mcanvas_h -
1841 BC_ScrollBar::get_span(SCROLL_HORIZ) -
1844 create_y_pane(cursor_y);
1845 mwindow->edl->local_session->y_pane = cursor_y;
1849 delete_y_pane(cursor_y);
1850 mwindow->edl->local_session->y_pane = -1;
1854 update_pane_dividers();
1856 // required to get new widgets to appear
1858 resource_thread->start_draw();
1861 // create panes from EDL
1862 void MWindowGUI::load_panes()
1864 int need_x_panes = 0;
1865 int need_y_panes = 0;
1866 // use names from create functions
1867 int cursor_x = mwindow->edl->local_session->x_pane;
1868 int cursor_y = mwindow->edl->local_session->y_pane;
1870 resource_thread->stop_draw(1);
1872 mwindow->theme->patchbay_w + PANE_DRAG_MARGIN &&
1874 mwindow->theme->mcanvas_w -
1875 BC_ScrollBar::get_span(SCROLL_VERT) -
1882 mwindow->theme->mtimebar_h + PANE_DRAG_MARGIN &&
1884 mwindow->theme->mcanvas_h -
1885 BC_ScrollBar::get_span(SCROLL_HORIZ) -
1891 //printf("MWindowGUI::load_panes %d %d %d\n", __LINE__, need_x_panes, need_y_panes);
1899 if(total_panes() == 1)
1902 //printf("MWindowGUI::load_panes %d\n", __LINE__);
1903 pane[TOP_RIGHT_PANE] = new TimelinePane(mwindow,
1905 mwindow->theme->mcanvas_x +
1907 mwindow->theme->mcanvas_y,
1908 mwindow->theme->mcanvas_x +
1909 mwindow->theme->mcanvas_w -
1911 cursor_y - mwindow->theme->pane_h);
1912 pane[BOTTOM_LEFT_PANE] = new TimelinePane(mwindow,
1914 mwindow->theme->mcanvas_x,
1915 mwindow->theme->mcanvas_y +
1917 cursor_x - mwindow->theme->pane_w,
1918 mwindow->theme->mcanvas_h -
1920 pane[BOTTOM_RIGHT_PANE] = new TimelinePane(mwindow,
1922 pane[TOP_RIGHT_PANE]->x,
1923 mwindow->theme->mcanvas_y +
1925 pane[TOP_RIGHT_PANE]->w,
1926 mwindow->theme->mcanvas_h -
1928 pane[TOP_LEFT_PANE]->resize_event(
1929 pane[TOP_LEFT_PANE]->x,
1930 pane[TOP_LEFT_PANE]->y,
1931 cursor_x - mwindow->theme->pane_w,
1932 cursor_y - mwindow->theme->pane_h);
1933 pane[TOP_RIGHT_PANE]->create_objects();
1934 pane[BOTTOM_LEFT_PANE]->create_objects();
1935 pane[BOTTOM_RIGHT_PANE]->create_objects();
1938 if(horizontal_panes())
1940 // create vertical panes
1941 //printf("MWindowGUI::load_panes %d\n", __LINE__);
1942 pane[BOTTOM_LEFT_PANE] = new TimelinePane(mwindow,
1944 mwindow->theme->mcanvas_x,
1945 mwindow->theme->mcanvas_y +
1947 cursor_x - mwindow->theme->pane_w,
1948 mwindow->theme->mcanvas_h -
1950 pane[BOTTOM_RIGHT_PANE] = new TimelinePane(mwindow,
1952 pane[TOP_RIGHT_PANE]->x,
1953 mwindow->theme->mcanvas_y +
1955 pane[TOP_RIGHT_PANE]->w,
1956 mwindow->theme->mcanvas_h -
1958 pane[TOP_LEFT_PANE]->resize_event(
1959 pane[TOP_LEFT_PANE]->x,
1960 pane[TOP_LEFT_PANE]->y,
1961 cursor_x - mwindow->theme->pane_w,
1962 cursor_y - mwindow->theme->pane_h);
1963 pane[TOP_RIGHT_PANE]->resize_event(
1964 mwindow->theme->mcanvas_x +
1966 mwindow->theme->mcanvas_y,
1967 mwindow->theme->mcanvas_x +
1968 mwindow->theme->mcanvas_w -
1970 cursor_y - mwindow->theme->pane_h);
1971 pane[BOTTOM_LEFT_PANE]->create_objects();
1972 pane[BOTTOM_RIGHT_PANE]->create_objects();
1975 if(vertical_panes())
1977 // create horizontal panes
1978 //printf("MWindowGUI::load_panes %d\n", __LINE__);
1979 pane[TOP_RIGHT_PANE] = new TimelinePane(mwindow,
1981 mwindow->theme->mcanvas_x +
1983 mwindow->theme->mcanvas_y,
1984 mwindow->theme->mcanvas_x +
1985 mwindow->theme->mcanvas_w -
1987 cursor_y - mwindow->theme->pane_h);
1988 pane[BOTTOM_RIGHT_PANE] = new TimelinePane(mwindow,
1990 pane[TOP_RIGHT_PANE]->x,
1991 mwindow->theme->mcanvas_y +
1993 pane[TOP_RIGHT_PANE]->w,
1994 mwindow->theme->mcanvas_h -
1996 pane[TOP_LEFT_PANE]->resize_event(
1997 pane[TOP_LEFT_PANE]->x,
1998 pane[TOP_LEFT_PANE]->y,
1999 cursor_x - mwindow->theme->pane_w,
2000 cursor_y - mwindow->theme->pane_h);
2001 pane[BOTTOM_LEFT_PANE]->resize_event(
2002 pane[TOP_LEFT_PANE]->x,
2003 mwindow->theme->mcanvas_y +
2005 mwindow->theme->mcanvas_x +
2006 mwindow->theme->mcanvas_w -
2007 cursor_x - mwindow->theme->pane_w,
2008 mwindow->theme->mcanvas_h -
2010 pane[TOP_RIGHT_PANE]->create_objects();
2011 pane[BOTTOM_RIGHT_PANE]->create_objects();
2018 //printf("MWindowGUI::load_panes %d\n", __LINE__);
2019 pane[TOP_LEFT_PANE]->resize_event(
2020 pane[TOP_LEFT_PANE]->x,
2021 pane[TOP_LEFT_PANE]->y,
2022 cursor_x - mwindow->theme->pane_w,
2023 cursor_y - mwindow->theme->pane_h);
2024 pane[TOP_RIGHT_PANE]->resize_event(
2025 mwindow->theme->mcanvas_x +
2027 mwindow->theme->mcanvas_y,
2028 mwindow->theme->mcanvas_x +
2029 mwindow->theme->mcanvas_w -
2031 cursor_y - mwindow->theme->pane_h);
2032 pane[BOTTOM_LEFT_PANE]->resize_event(
2033 pane[TOP_LEFT_PANE]->x,
2034 mwindow->theme->mcanvas_y +
2036 mwindow->theme->mcanvas_x +
2037 mwindow->theme->mcanvas_w -
2038 cursor_x - mwindow->theme->pane_w,
2039 mwindow->theme->mcanvas_h -
2041 pane[BOTTOM_RIGHT_PANE]->resize_event(
2042 pane[TOP_RIGHT_PANE]->x,
2043 mwindow->theme->mcanvas_y +
2045 pane[TOP_RIGHT_PANE]->w,
2046 mwindow->theme->mcanvas_h -
2055 if(pane[BOTTOM_LEFT_PANE]) delete pane[BOTTOM_LEFT_PANE];
2056 if(pane[BOTTOM_RIGHT_PANE]) delete pane[BOTTOM_RIGHT_PANE];
2057 pane[BOTTOM_LEFT_PANE] = 0;
2058 pane[BOTTOM_RIGHT_PANE] = 0;
2060 if(!pane[TOP_RIGHT_PANE])
2062 pane[TOP_RIGHT_PANE] = new TimelinePane(mwindow,
2064 mwindow->theme->mcanvas_x +
2066 mwindow->theme->mcanvas_y,
2067 mwindow->theme->mcanvas_x +
2068 mwindow->theme->mcanvas_w -
2070 mwindow->theme->mcanvas_h);
2071 pane[TOP_LEFT_PANE]->resize_event(
2072 mwindow->theme->mcanvas_x,
2073 mwindow->theme->mcanvas_y,
2074 cursor_x - mwindow->theme->pane_w,
2075 mwindow->theme->mcanvas_h);
2076 pane[TOP_RIGHT_PANE]->create_objects();
2080 pane[TOP_LEFT_PANE]->resize_event(
2081 mwindow->theme->mcanvas_x,
2082 mwindow->theme->mcanvas_y,
2083 cursor_x - mwindow->theme->pane_w,
2084 mwindow->theme->mcanvas_h);
2085 pane[TOP_RIGHT_PANE]->resize_event(
2086 mwindow->theme->mcanvas_x +
2088 pane[TOP_RIGHT_PANE]->y,
2089 mwindow->theme->mcanvas_x +
2090 mwindow->theme->mcanvas_w -
2092 mwindow->theme->mcanvas_h);
2100 if(pane[TOP_RIGHT_PANE]) delete pane[TOP_RIGHT_PANE];
2101 if(pane[BOTTOM_RIGHT_PANE]) delete pane[BOTTOM_RIGHT_PANE];
2102 pane[TOP_RIGHT_PANE] = 0;
2103 pane[BOTTOM_RIGHT_PANE] = 0;
2105 if(!pane[BOTTOM_LEFT_PANE])
2107 //printf("MWindowGUI::load_panes %d\n", __LINE__);
2108 pane[BOTTOM_LEFT_PANE] = new TimelinePane(mwindow,
2110 mwindow->theme->mcanvas_x,
2111 mwindow->theme->mcanvas_y +
2113 mwindow->theme->mcanvas_w,
2114 mwindow->theme->mcanvas_h -
2116 pane[TOP_LEFT_PANE]->resize_event(
2117 mwindow->theme->mcanvas_x,
2118 mwindow->theme->mcanvas_y,
2119 mwindow->theme->mcanvas_w,
2120 pane[BOTTOM_LEFT_PANE]->y -
2121 mwindow->theme->mcanvas_y -
2122 mwindow->theme->pane_h);
2123 pane[BOTTOM_LEFT_PANE]->create_objects();
2127 pane[TOP_LEFT_PANE]->resize_event(
2128 mwindow->theme->mcanvas_x,
2129 mwindow->theme->mcanvas_y,
2130 mwindow->theme->mcanvas_w,
2131 cursor_y - mwindow->theme->pane_h);
2132 pane[BOTTOM_LEFT_PANE]->resize_event(
2133 pane[BOTTOM_LEFT_PANE]->x,
2135 mwindow->theme->mcanvas_y,
2136 mwindow->theme->mcanvas_w,
2137 mwindow->theme->mcanvas_h -
2144 if(pane[TOP_RIGHT_PANE]) delete pane[TOP_RIGHT_PANE];
2145 if(pane[BOTTOM_RIGHT_PANE]) delete pane[BOTTOM_RIGHT_PANE];
2146 if(pane[BOTTOM_LEFT_PANE]) delete pane[BOTTOM_LEFT_PANE];
2147 pane[TOP_RIGHT_PANE] = 0;
2148 pane[BOTTOM_RIGHT_PANE] = 0;
2149 pane[BOTTOM_LEFT_PANE] = 0;
2150 pane[TOP_LEFT_PANE]->resize_event(
2151 mwindow->theme->mcanvas_x,
2152 mwindow->theme->mcanvas_y,
2153 mwindow->theme->mcanvas_w,
2154 mwindow->theme->mcanvas_h);
2157 update_pane_dividers();
2160 resource_thread->start_draw();
2163 void MWindowGUI::update_pane_dividers()
2166 if(horizontal_panes() || total_panes() == 4)
2168 int x = pane[TOP_RIGHT_PANE]->x - mwindow->theme->pane_w;
2169 int y = mwindow->theme->mcanvas_y;
2170 int h = mwindow->theme->mcanvas_h;
2174 add_subwindow(x_divider = new PaneDivider(
2175 mwindow, x, y, h, 1));
2176 x_divider->create_objects();
2180 x_divider->reposition_window(x, y, h);
2193 if(vertical_panes() || total_panes() == 4)
2195 int x = mwindow->theme->mcanvas_x;
2196 int y = pane[BOTTOM_LEFT_PANE]->y -
2197 mwindow->theme->pane_h;
2198 int w = mwindow->theme->mcanvas_w;
2201 add_subwindow(y_divider = new PaneDivider(
2202 mwindow, x, y, w, 0));
2203 y_divider->create_objects();
2207 y_divider->reposition_window(x, y, w);
2221 void MWindowGUI::draw_samplemovement()
2228 update_scrollbars(1);
2231 void MWindowGUI::draw_trackmovement()
2233 update_scrollbars(0);
2240 PaneButton::PaneButton(MWindow *mwindow, int x, int y)
2241 : BC_Button(x, y, mwindow->theme->get_image_set("pane"))
2243 this->mwindow = mwindow;
2246 int PaneButton::cursor_motion_event()
2248 if(get_top_level()->get_button_down() &&
2250 get_status() == BUTTON_DOWNHI &&
2253 // printf("PaneButton::cursor_motion_event %d\n", __LINE__);
2255 if(get_cursor_x() < 0 && !mwindow->gui->dragging_pane)
2257 mwindow->gui->start_x_pane_drag();
2260 if(get_cursor_y() < 0 && !mwindow->gui->dragging_pane)
2262 mwindow->gui->start_y_pane_drag();
2266 mwindow->gui->handle_pane_drag();
2268 int result = BC_Button::cursor_motion_event();
2272 int PaneButton::button_release_event()
2274 mwindow->gui->stop_pane_drag();
2275 int result = BC_Button::button_release_event();
2280 FFMpegToggle::FFMpegToggle(MWindow *mwindow, MButtons *mbuttons, int x, int y)
2281 : BC_Toggle(x, y, mwindow->theme->ffmpeg_toggle,
2282 mwindow->preferences->get_file_probe_armed("FFMPEG_Early") > 0 ? 1 : 0)
2284 this->mwindow = mwindow;
2285 this->mbuttons = mbuttons;
2286 set_tooltip(get_value() ? FFMPEG_EARLY_TIP : FFMPEG_LATE_TIP);
2289 FFMpegToggle::~FFMpegToggle()
2293 int FFMpegToggle::handle_event()
2295 int ffmpeg_early_probe = get_value();
2296 set_tooltip(ffmpeg_early_probe ? FFMPEG_EARLY_TIP : FFMPEG_LATE_TIP);
2297 mwindow->preferences->set_file_probe_armed("FFMPEG_Early", ffmpeg_early_probe);
2298 mwindow->preferences->set_file_probe_armed("FFMPEG_Late", !ffmpeg_early_probe);
2300 mwindow->show_warning(&mwindow->preferences->warn_indexes,
2301 _("Changing the base codecs may require rebuilding indexes."));