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 int MWindowGUI::show_message(char *message, int color)
923 // printf("MWindowGUI::show_message %d: %s 0x%08x 0x%08x\n",
924 // __LINE__, message, color, mwindow->theme->message_normal);
925 if(color < 0) color = mwindow->theme->message_normal;
926 statusbar->status_text->set_color(color);
927 statusbar->status_text->update(message);
932 // Drag motion called from other window
933 int MWindowGUI::drag_motion()
935 if(get_hidden()) return 0;
937 Track *over_track = 0;
939 PluginSet *over_pluginset = 0;
940 Plugin *over_plugin = 0;
945 drag_popup->cursor_motion_event();
949 // there's no point in drawing highlights has until drag operation has been set
950 if (!mwindow->session->current_operation)
953 for(int i = 0; i < TOTAL_PANES; i++)
955 if(pane[i]) pane[i]->canvas->drag_motion(
962 if(mwindow->session->track_highlighted != over_track)
964 mwindow->session->track_highlighted = over_track;
968 if(mwindow->session->edit_highlighted != over_edit)
970 mwindow->session->edit_highlighted = over_edit;
974 if(mwindow->session->pluginset_highlighted != over_pluginset)
976 mwindow->session->pluginset_highlighted = over_pluginset;
980 if(mwindow->session->plugin_highlighted != over_plugin)
982 mwindow->session->plugin_highlighted = over_plugin;
986 if( mwindow->session->current_operation == DRAG_ASSET ||
987 mwindow->session->current_operation == DRAG_EDIT ||
988 mwindow->session->current_operation == DRAG_AEFFECT_COPY ||
989 mwindow->session->current_operation == DRAG_VEFFECT_COPY )
995 // printf("drag_motion %d %d over_track=%p over_edit=%p\n",
1002 lock_window("MWindowGUI::drag_motion");
1009 int MWindowGUI::drag_stop()
1011 if(get_hidden()) return 0;
1012 int result = 0, redraw = 0;
1014 for(int i = 0; i < TOTAL_PANES; i++)
1016 if(pane[i]) result |= pane[i]->canvas->drag_stop(
1019 mwindow->edl->optimize();
1021 // since we don't have subwindows we have to terminate any drag operation
1024 if (mwindow->session->track_highlighted
1025 || mwindow->session->edit_highlighted
1026 || mwindow->session->plugin_highlighted
1027 || mwindow->session->pluginset_highlighted)
1029 mwindow->session->track_highlighted = 0;
1030 mwindow->session->edit_highlighted = 0;
1031 mwindow->session->plugin_highlighted = 0;
1032 mwindow->session->pluginset_highlighted = 0;
1033 mwindow->session->current_operation = NO_OPERATION;
1037 //printf("TrackCanvas::drag_stop %d %d\n", redraw, mwindow->session->current_operation);
1040 mwindow->edl->tracks->update_y_pixels(mwindow->theme);
1041 update_scrollbars(0);
1056 void MWindowGUI::default_positions()
1058 //printf("MWindowGUI::default_positions 1\n");
1059 VWindow *vwindow = mwindow->vwindows.size() > DEFAULT_VWINDOW ?
1060 mwindow->vwindows.get(DEFAULT_VWINDOW) : 0;
1061 if( vwindow && !vwindow->is_running() ) vwindow = 0;
1062 if( vwindow ) vwindow->gui->lock_window("MWindowGUI::default_positions");
1063 mwindow->cwindow->gui->lock_window("MWindowGUI::default_positions");
1064 mwindow->awindow->gui->lock_window("MWindowGUI::default_positions");
1066 // printf("MWindowGUI::default_positions 1 %d %d %d %d\n", mwindow->session->vwindow_x,
1067 // mwindow->session->vwindow_y,
1068 // mwindow->session->vwindow_w,
1069 // mwindow->session->vwindow_h);
1070 reposition_window(mwindow->session->mwindow_x,
1071 mwindow->session->mwindow_y,
1072 mwindow->session->mwindow_w,
1073 mwindow->session->mwindow_h);
1074 if( vwindow ) vwindow->gui->reposition_window(mwindow->session->vwindow_x,
1075 mwindow->session->vwindow_y,
1076 mwindow->session->vwindow_w,
1077 mwindow->session->vwindow_h);
1078 mwindow->cwindow->gui->reposition_window(mwindow->session->cwindow_x,
1079 mwindow->session->cwindow_y,
1080 mwindow->session->cwindow_w,
1081 mwindow->session->cwindow_h);
1082 mwindow->awindow->gui->reposition_window(mwindow->session->awindow_x,
1083 mwindow->session->awindow_y,
1084 mwindow->session->awindow_w,
1085 mwindow->session->awindow_h);
1086 //printf("MWindowGUI::default_positions 1\n");
1088 resize_event(mwindow->session->mwindow_w,
1089 mwindow->session->mwindow_h);
1090 //printf("MWindowGUI::default_positions 1\n");
1091 if( vwindow ) vwindow->gui->resize_event(mwindow->session->vwindow_w,
1092 mwindow->session->vwindow_h);
1093 //printf("MWindowGUI::default_positions 1\n");
1094 mwindow->cwindow->gui->resize_event(mwindow->session->cwindow_w,
1095 mwindow->session->cwindow_h);
1096 //printf("MWindowGUI::default_positions 1\n");
1097 mwindow->awindow->gui->resize_event(mwindow->session->awindow_w,
1098 mwindow->session->awindow_h);
1100 //printf("MWindowGUI::default_positions 1\n");
1103 if( vwindow ) vwindow->gui->flush();
1104 mwindow->cwindow->gui->flush();
1105 mwindow->awindow->gui->flush();
1107 if( vwindow ) vwindow->gui->unlock_window();
1108 mwindow->cwindow->gui->unlock_window();
1109 mwindow->awindow->gui->unlock_window();
1110 //printf("MWindowGUI::default_positions 2\n");
1114 int MWindowGUI::button_release_event()
1116 if( keyvalue_popup ) {
1117 delete keyvalue_popup; keyvalue_popup = 0;
1123 int MWindowGUI::repeat_event(int64_t duration)
1125 // if(duration == 100)
1126 // mwindow->sync_parameters(CHANGE_ALL);
1128 for(int i = 0; i < TOTAL_PANES; i++)
1130 if(pane[i]) result = pane[i]->cursor->repeat_event(duration);
1136 int MWindowGUI::translation_event()
1138 //printf("MWindowGUI::translation_event 1 %d %d\n", get_x(), get_y());
1139 mwindow->session->mwindow_x = get_x();
1140 mwindow->session->mwindow_y = get_y();
1145 int MWindowGUI::save_defaults(BC_Hash *defaults)
1147 defaults->update("MWINDOWWIDTH", get_w());
1148 defaults->update("MWINDOWHEIGHT", get_h());
1149 mainmenu->save_defaults(defaults);
1150 BC_WindowBase::save_defaults(defaults);
1154 int MWindowGUI::keypress_event()
1156 //printf("MWindowGUI::keypress_event 1 %d\n", get_keypress());
1157 int result = mbuttons->keypress_event();
1158 if( result ) return result;
1160 switch(get_keypress()) {
1162 mwindow->toggle_editing_mode();
1166 case '1': case '2': case '3': case '4':
1167 case '5': case '6': case '7': case '8':
1168 if( !alt_down() || shift_down() ) break;
1169 if( !mwindow->select_asset(get_keypress()-'1',1) )
1174 if( !ctrl_down() ) {
1177 mbuttons->transport->handle_transport(STOP, 1, 0, 0);
1178 lock_window("MWindowGUI::keypress_event 1");
1179 mwindow->prev_edit_handle(shift_down());
1182 mwindow->move_left();
1188 if( !ctrl_down() ) {
1191 mbuttons->transport->handle_transport(STOP, 1, 0, 0);
1192 lock_window("MWindowGUI::keypress_event 2");
1193 mwindow->next_edit_handle(shift_down());
1196 mwindow->move_right();
1202 if( ctrl_down() && !alt_down() )
1203 mwindow->expand_y();
1204 else if( !ctrl_down() && alt_down() )
1205 mwindow->expand_autos(0,1,1);
1206 else if( ctrl_down() && alt_down() )
1207 mwindow->expand_autos(1,1,1);
1209 mwindow->expand_sample();
1214 if( ctrl_down() && !alt_down() )
1215 mwindow->zoom_in_y();
1216 else if( !ctrl_down() && alt_down() )
1217 mwindow->shrink_autos(0,1,1);
1218 else if( ctrl_down() && alt_down() )
1219 mwindow->shrink_autos(1,1,1);
1221 mwindow->zoom_in_sample();
1229 mwindow->expand_t();
1235 mwindow->move_down();
1237 mwindow->zoom_in_t();
1243 Track *this_track = 0;
1244 for( int i=0; i<TOTAL_PANES; ++i ) {
1245 if( !pane[i] ) continue;
1246 if( (this_track = pane[i]->over_track()) != 0 ) break;
1247 if( (this_track = pane[i]->over_patchbay()) != 0 ) break;
1250 if( get_keypress() == TAB ) { // Switch the record button
1252 this_track->record = !this_track->record ? 1 : 0;
1255 int total_selected = mwindow->edl->tracks->total_of(Tracks::RECORD);
1256 // all selected if nothing previously selected or
1257 // if this patch was previously the only one selected and armed
1258 int selected = !total_selected || (total_selected == 1 &&
1259 this_track && this_track->record ) ? 1 : 0;
1260 mwindow->edl->tracks->select_all(Tracks::RECORD, selected);
1261 if( !selected && this_track ) this_track->record = 1;
1264 update(0, 1, 0, 0, 1, 0, 1);
1266 mwindow->cwindow->update(0, 1, 1);
1267 lock_window("TrackCanvas::keypress_event 3");
1273 // since things under cursor have changed...
1275 cursor_motion_event();
1280 int MWindowGUI::keyboard_listener(BC_WindowBase *wp)
1282 return key_listener(wp->get_keypress());
1285 int MWindowGUI::key_listener(int key)
1290 if( !record->running() )
1293 record->record_gui->interrupt_thread->start(0);
1300 channel_info->toggle_scan();
1304 if( !remote_control->deactivate() )
1305 remote_control->activate();
1315 void MWindowGUI::use_android_remote(int on)
1318 delete android_control;
1319 android_control = 0;
1322 if( android_control ) return;
1323 android_control = new AndroidControl(this);
1326 int MWindowGUI::close_event()
1332 void MWindowGUI::stop_drawing()
1334 resource_thread->stop_draw(1);
1337 int MWindowGUI::menu_w()
1339 return mainmenu->get_w();
1342 int MWindowGUI::menu_h()
1344 return mainmenu->get_h();
1347 void MWindowGUI::start_x_pane_drag()
1351 x_pane_drag = new BC_Popup(this,
1352 get_abs_cursor_x(0) - mwindow->theme->pane_w,
1353 BC_DisplayInfo::get_top_border() +
1355 mwindow->theme->mcanvas_y,
1356 mwindow->theme->pane_w,
1357 mwindow->theme->mcanvas_h,
1358 mwindow->theme->drag_pane_color);
1359 x_pane_drag->draw_3segmentv(0,
1361 x_pane_drag->get_h(),
1362 mwindow->theme->get_image_set("xpane")[BUTTON_DOWNHI]);
1363 x_pane_drag->flash(1);
1368 void MWindowGUI::start_y_pane_drag()
1372 //printf("MWindowGUI::start_y_pane_drag %d %d %d\n", __LINE__, get_x(), get_y());
1373 y_pane_drag = new BC_Popup(this,
1374 BC_DisplayInfo::get_left_border() +
1376 mwindow->theme->mcanvas_x,
1377 get_abs_cursor_y(0) - mwindow->theme->pane_h,
1378 mwindow->theme->mcanvas_w,
1379 mwindow->theme->pane_h,
1380 mwindow->theme->drag_pane_color);
1381 y_pane_drag->draw_3segmenth(0,
1383 y_pane_drag->get_w(),
1384 mwindow->theme->get_image_set("ypane")[BUTTON_DOWNHI]);
1385 y_pane_drag->flash(1);
1390 void MWindowGUI::handle_pane_drag()
1396 x_pane_drag->reposition_window(
1397 get_abs_cursor_x(0) - mwindow->theme->pane_w,
1398 x_pane_drag->get_y());
1403 y_pane_drag->reposition_window(
1404 y_pane_drag->get_x(),
1405 get_abs_cursor_y(0) - mwindow->theme->pane_h);
1411 void MWindowGUI::create_x_pane(int cursor_x)
1413 if(total_panes() == 1)
1415 // create a horizontal pane
1416 // do this 1st so the resize_event knows there are 2 panes
1417 mwindow->edl->local_session->view_start[TOP_RIGHT_PANE] =
1418 mwindow->edl->local_session->view_start[TOP_LEFT_PANE] +
1420 mwindow->theme->patchbay_w;
1421 pane[TOP_RIGHT_PANE] = new TimelinePane(mwindow,
1423 mwindow->theme->mcanvas_x +
1425 mwindow->theme->mcanvas_y,
1426 mwindow->theme->mcanvas_x +
1427 mwindow->theme->mcanvas_w -
1429 mwindow->theme->mcanvas_h);
1430 pane[TOP_LEFT_PANE]->resize_event(
1431 mwindow->theme->mcanvas_x,
1432 mwindow->theme->mcanvas_y,
1433 cursor_x - mwindow->theme->pane_w,
1434 mwindow->theme->mcanvas_h);
1435 pane[TOP_RIGHT_PANE]->create_objects();
1438 if(vertical_panes())
1440 // create 2 horizontal panes
1441 mwindow->edl->local_session->track_start[TOP_RIGHT_PANE] =
1442 mwindow->edl->local_session->track_start[TOP_LEFT_PANE];
1443 mwindow->edl->local_session->track_start[BOTTOM_RIGHT_PANE] =
1444 mwindow->edl->local_session->track_start[BOTTOM_LEFT_PANE];
1445 mwindow->edl->local_session->view_start[TOP_RIGHT_PANE] =
1446 mwindow->edl->local_session->view_start[BOTTOM_RIGHT_PANE] =
1447 mwindow->edl->local_session->view_start[TOP_LEFT_PANE] +
1449 mwindow->theme->patchbay_w;
1450 pane[TOP_RIGHT_PANE] = new TimelinePane(mwindow,
1452 mwindow->theme->mcanvas_x +
1454 pane[TOP_LEFT_PANE]->y,
1455 mwindow->theme->mcanvas_x +
1456 mwindow->theme->mcanvas_w -
1458 pane[TOP_LEFT_PANE]->h);
1459 pane[BOTTOM_RIGHT_PANE] = new TimelinePane(mwindow,
1461 mwindow->theme->mcanvas_x +
1463 pane[BOTTOM_LEFT_PANE]->y,
1464 mwindow->theme->mcanvas_x +
1465 mwindow->theme->mcanvas_w -
1467 pane[BOTTOM_LEFT_PANE]->h);
1468 pane[TOP_LEFT_PANE]->resize_event(
1469 pane[TOP_LEFT_PANE]->x,
1470 pane[TOP_LEFT_PANE]->y,
1471 cursor_x - mwindow->theme->pane_w,
1472 pane[TOP_LEFT_PANE]->h);
1473 pane[BOTTOM_LEFT_PANE]->resize_event(
1474 pane[BOTTOM_LEFT_PANE]->x,
1475 pane[BOTTOM_LEFT_PANE]->y,
1476 cursor_x - mwindow->theme->pane_w,
1477 pane[BOTTOM_LEFT_PANE]->h);
1478 pane[TOP_RIGHT_PANE]->create_objects();
1479 pane[BOTTOM_RIGHT_PANE]->create_objects();
1482 if(horizontal_panes())
1484 // resize a horizontal pane
1485 mwindow->edl->local_session->view_start[TOP_RIGHT_PANE] +=
1487 pane[TOP_RIGHT_PANE]->x;
1488 if(mwindow->edl->local_session->view_start[TOP_RIGHT_PANE] < 0)
1489 mwindow->edl->local_session->view_start[TOP_RIGHT_PANE] = 0;
1490 pane[TOP_LEFT_PANE]->resize_event(
1491 mwindow->theme->mcanvas_x,
1492 mwindow->theme->mcanvas_y,
1493 cursor_x - mwindow->theme->pane_w,
1494 mwindow->theme->mcanvas_h);
1495 pane[TOP_RIGHT_PANE]->resize_event(
1496 mwindow->theme->mcanvas_x +
1498 pane[TOP_RIGHT_PANE]->y,
1499 mwindow->theme->mcanvas_x +
1500 mwindow->theme->mcanvas_w -
1502 mwindow->theme->mcanvas_h);
1506 // resize 2 horizontal panes
1507 mwindow->edl->local_session->view_start[TOP_RIGHT_PANE] +=
1509 pane[TOP_RIGHT_PANE]->x;
1510 if(mwindow->edl->local_session->view_start[TOP_RIGHT_PANE] < 0)
1511 mwindow->edl->local_session->view_start[TOP_RIGHT_PANE] = 0;
1512 mwindow->edl->local_session->view_start[BOTTOM_RIGHT_PANE] =
1513 mwindow->edl->local_session->view_start[TOP_RIGHT_PANE];
1515 pane[TOP_LEFT_PANE]->resize_event(
1516 mwindow->theme->mcanvas_x,
1517 pane[TOP_LEFT_PANE]->y,
1518 cursor_x - mwindow->theme->pane_w,
1519 pane[TOP_LEFT_PANE]->h);
1520 pane[TOP_RIGHT_PANE]->resize_event(
1521 mwindow->theme->mcanvas_x +
1523 pane[TOP_RIGHT_PANE]->y,
1524 mwindow->theme->mcanvas_x +
1525 mwindow->theme->mcanvas_w -
1527 pane[TOP_RIGHT_PANE]->h);
1528 pane[BOTTOM_LEFT_PANE]->resize_event(
1529 mwindow->theme->mcanvas_x,
1530 pane[BOTTOM_LEFT_PANE]->y,
1531 cursor_x - mwindow->theme->pane_w,
1532 pane[BOTTOM_LEFT_PANE]->h);
1533 pane[BOTTOM_RIGHT_PANE]->resize_event(
1534 mwindow->theme->mcanvas_x +
1536 pane[BOTTOM_RIGHT_PANE]->y,
1537 mwindow->theme->mcanvas_x +
1538 mwindow->theme->mcanvas_w -
1540 pane[BOTTOM_RIGHT_PANE]->h);
1546 void MWindowGUI::delete_x_pane(int cursor_x)
1548 // give left panes coordinates of right pane
1549 if(cursor_x < mwindow->theme->patchbay_w + PANE_DRAG_MARGIN &&
1550 pane[TOP_RIGHT_PANE])
1552 mwindow->edl->local_session->view_start[TOP_LEFT_PANE] =
1553 mwindow->edl->local_session->view_start[TOP_RIGHT_PANE] -
1554 pane[TOP_RIGHT_PANE]->x + mwindow->theme->patchbay_w;
1555 if(mwindow->edl->local_session->view_start[TOP_LEFT_PANE] < 0)
1556 mwindow->edl->local_session->view_start[TOP_LEFT_PANE] = 0;
1557 mwindow->edl->local_session->view_start[BOTTOM_LEFT_PANE] =
1558 mwindow->edl->local_session->view_start[TOP_LEFT_PANE];
1561 switch(total_panes())
1564 if(pane[TOP_LEFT_PANE] && pane[TOP_RIGHT_PANE])
1566 // delete right pane
1567 delete pane[TOP_RIGHT_PANE];
1568 pane[TOP_RIGHT_PANE] = 0;
1569 pane[TOP_LEFT_PANE]->resize_event(
1570 mwindow->theme->mcanvas_x,
1571 mwindow->theme->mcanvas_y,
1572 mwindow->theme->mcanvas_w,
1573 mwindow->theme->mcanvas_h);
1579 // delete right panes
1580 delete pane[TOP_RIGHT_PANE];
1581 pane[TOP_RIGHT_PANE] = 0;
1582 delete pane[BOTTOM_RIGHT_PANE];
1583 pane[BOTTOM_RIGHT_PANE] = 0;
1584 pane[TOP_LEFT_PANE]->resize_event(
1585 mwindow->theme->mcanvas_x,
1586 pane[TOP_LEFT_PANE]->y,
1587 mwindow->theme->mcanvas_w,
1588 pane[TOP_LEFT_PANE]->h);
1589 pane[BOTTOM_LEFT_PANE]->resize_event(
1590 mwindow->theme->mcanvas_x,
1591 pane[BOTTOM_LEFT_PANE]->y,
1592 mwindow->theme->mcanvas_w,
1593 pane[BOTTOM_LEFT_PANE]->h);
1598 void MWindowGUI::create_y_pane(int cursor_y)
1600 if(total_panes() == 1)
1602 mwindow->edl->local_session->view_start[BOTTOM_LEFT_PANE] =
1603 mwindow->edl->local_session->view_start[TOP_LEFT_PANE];
1604 mwindow->edl->local_session->track_start[BOTTOM_LEFT_PANE] =
1605 mwindow->edl->local_session->track_start[TOP_LEFT_PANE] +
1607 mwindow->theme->mtimebar_h;
1608 // do this 1st so the resize_event knows there are 2 panes
1609 pane[BOTTOM_LEFT_PANE] = new TimelinePane(mwindow,
1611 mwindow->theme->mcanvas_x,
1612 mwindow->theme->mcanvas_y +
1614 mwindow->theme->mcanvas_w,
1615 mwindow->theme->mcanvas_h -
1617 pane[TOP_LEFT_PANE]->resize_event(
1618 mwindow->theme->mcanvas_x,
1619 mwindow->theme->mcanvas_y,
1620 mwindow->theme->mcanvas_w,
1621 pane[BOTTOM_LEFT_PANE]->y -
1622 mwindow->theme->mcanvas_y -
1623 mwindow->theme->pane_h);
1624 pane[BOTTOM_LEFT_PANE]->create_objects();
1627 if(horizontal_panes())
1630 mwindow->edl->local_session->view_start[BOTTOM_LEFT_PANE] =
1631 mwindow->edl->local_session->view_start[TOP_LEFT_PANE];
1632 mwindow->edl->local_session->view_start[BOTTOM_RIGHT_PANE] =
1633 mwindow->edl->local_session->view_start[TOP_RIGHT_PANE];
1634 mwindow->edl->local_session->track_start[BOTTOM_LEFT_PANE] =
1635 mwindow->edl->local_session->track_start[BOTTOM_RIGHT_PANE] =
1636 mwindow->edl->local_session->track_start[TOP_LEFT_PANE] +
1638 mwindow->theme->mtimebar_h;
1640 pane[BOTTOM_LEFT_PANE] = new TimelinePane(mwindow,
1642 pane[TOP_LEFT_PANE]->x,
1643 mwindow->theme->mcanvas_y +
1645 pane[TOP_LEFT_PANE]->w,
1646 mwindow->theme->mcanvas_h -
1648 pane[BOTTOM_RIGHT_PANE] = new TimelinePane(mwindow,
1650 pane[TOP_RIGHT_PANE]->x,
1651 mwindow->theme->mcanvas_y +
1653 pane[TOP_RIGHT_PANE]->w,
1654 mwindow->theme->mcanvas_h -
1657 pane[TOP_LEFT_PANE]->resize_event(
1658 pane[TOP_LEFT_PANE]->x,
1659 pane[TOP_LEFT_PANE]->y,
1660 pane[TOP_LEFT_PANE]->w,
1661 pane[BOTTOM_LEFT_PANE]->y -
1662 mwindow->theme->mcanvas_y -
1663 mwindow->theme->pane_h);
1664 pane[TOP_RIGHT_PANE]->resize_event(
1665 pane[TOP_RIGHT_PANE]->x,
1666 pane[TOP_RIGHT_PANE]->y,
1667 pane[TOP_RIGHT_PANE]->w,
1668 pane[BOTTOM_RIGHT_PANE]->y -
1669 mwindow->theme->mcanvas_y -
1670 mwindow->theme->pane_h);
1672 pane[BOTTOM_LEFT_PANE]->create_objects();
1673 pane[BOTTOM_RIGHT_PANE]->create_objects();
1676 if(vertical_panes())
1679 mwindow->edl->local_session->track_start[BOTTOM_LEFT_PANE] +=
1681 (pane[BOTTOM_LEFT_PANE]->y - mwindow->theme->mcanvas_y);
1682 if(mwindow->edl->local_session->track_start[BOTTOM_LEFT_PANE] < 0)
1683 mwindow->edl->local_session->track_start[BOTTOM_LEFT_PANE] = 0;
1684 pane[TOP_LEFT_PANE]->resize_event(
1685 mwindow->theme->mcanvas_x,
1686 mwindow->theme->mcanvas_y,
1687 mwindow->theme->mcanvas_w,
1688 cursor_y - mwindow->theme->pane_h);
1689 pane[BOTTOM_LEFT_PANE]->resize_event(
1690 pane[BOTTOM_LEFT_PANE]->x,
1692 mwindow->theme->mcanvas_y,
1693 mwindow->theme->mcanvas_w,
1694 mwindow->theme->mcanvas_h -
1700 mwindow->edl->local_session->track_start[BOTTOM_LEFT_PANE] +=
1702 (pane[BOTTOM_LEFT_PANE]->y - mwindow->theme->mcanvas_y);
1703 if(mwindow->edl->local_session->track_start[BOTTOM_LEFT_PANE] < 0)
1704 mwindow->edl->local_session->track_start[BOTTOM_LEFT_PANE] = 0;
1705 mwindow->edl->local_session->track_start[BOTTOM_RIGHT_PANE] =
1706 mwindow->edl->local_session->track_start[BOTTOM_LEFT_PANE];
1707 pane[TOP_LEFT_PANE]->resize_event(
1708 pane[TOP_LEFT_PANE]->x,
1709 pane[TOP_LEFT_PANE]->y,
1710 pane[TOP_LEFT_PANE]->w,
1711 cursor_y - mwindow->theme->pane_h);
1712 pane[BOTTOM_LEFT_PANE]->resize_event(
1713 pane[BOTTOM_LEFT_PANE]->x,
1715 mwindow->theme->mcanvas_y,
1716 pane[BOTTOM_LEFT_PANE]->w,
1717 mwindow->theme->mcanvas_h -
1719 pane[TOP_RIGHT_PANE]->resize_event(
1720 pane[TOP_RIGHT_PANE]->x,
1721 pane[TOP_RIGHT_PANE]->y,
1722 pane[TOP_RIGHT_PANE]->w,
1723 cursor_y - mwindow->theme->pane_h);
1724 pane[BOTTOM_RIGHT_PANE]->resize_event(
1725 pane[BOTTOM_RIGHT_PANE]->x,
1727 mwindow->theme->mcanvas_y,
1728 pane[BOTTOM_RIGHT_PANE]->w,
1729 mwindow->theme->mcanvas_h -
1734 void MWindowGUI::delete_y_pane(int cursor_y)
1736 if(cursor_y < mwindow->theme->mtimebar_h +
1738 pane[BOTTOM_LEFT_PANE])
1740 // give top pane coordinates of bottom pane
1741 mwindow->edl->local_session->track_start[TOP_LEFT_PANE] =
1742 mwindow->edl->local_session->track_start[BOTTOM_LEFT_PANE] -
1743 pane[BOTTOM_LEFT_PANE]->y;
1744 if(mwindow->edl->local_session->track_start[TOP_LEFT_PANE] < 0)
1745 mwindow->edl->local_session->track_start[TOP_LEFT_PANE] = 0;
1746 mwindow->edl->local_session->track_start[TOP_RIGHT_PANE] =
1747 mwindow->edl->local_session->track_start[TOP_LEFT_PANE];
1751 switch(total_panes())
1754 delete pane[BOTTOM_LEFT_PANE];
1755 pane[BOTTOM_LEFT_PANE] = 0;
1756 pane[TOP_LEFT_PANE]->resize_event(
1757 mwindow->theme->mcanvas_x,
1758 mwindow->theme->mcanvas_y,
1759 mwindow->theme->mcanvas_w,
1760 mwindow->theme->mcanvas_h);
1764 // delete bottom 2 panes
1766 delete pane[BOTTOM_LEFT_PANE];
1767 pane[BOTTOM_LEFT_PANE] = 0;
1768 delete pane[BOTTOM_RIGHT_PANE];
1769 pane[BOTTOM_RIGHT_PANE] = 0;
1770 pane[TOP_LEFT_PANE]->resize_event(
1771 pane[TOP_LEFT_PANE]->x,
1772 mwindow->theme->mcanvas_y,
1773 pane[TOP_LEFT_PANE]->w,
1774 mwindow->theme->mcanvas_h);
1775 pane[TOP_RIGHT_PANE]->resize_event(
1776 pane[TOP_RIGHT_PANE]->x,
1777 mwindow->theme->mcanvas_y,
1778 pane[TOP_RIGHT_PANE]->w,
1779 mwindow->theme->mcanvas_h);
1784 void MWindowGUI::stop_pane_drag()
1787 resource_thread->stop_draw(1);
1791 // cursor position relative to canvas
1792 int cursor_x = x_pane_drag->get_x() -
1794 BC_DisplayInfo::get_left_border() -
1795 mwindow->theme->mcanvas_x +
1796 mwindow->theme->pane_w;
1801 if(cursor_x >= mwindow->theme->patchbay_w + PANE_DRAG_MARGIN &&
1802 cursor_x < mwindow->theme->mcanvas_w -
1803 BC_ScrollBar::get_span(SCROLL_VERT) -
1806 create_x_pane(cursor_x);
1807 mwindow->edl->local_session->x_pane = cursor_x;
1812 delete_x_pane(cursor_x);
1813 mwindow->edl->local_session->x_pane = -1;
1821 // cursor position relative to canvas
1822 int cursor_y = y_pane_drag->get_y() -
1824 BC_DisplayInfo::get_top_border() -
1825 mwindow->theme->mcanvas_y +
1826 mwindow->theme->pane_h;
1832 if(cursor_y >= mwindow->theme->mtimebar_h +
1834 cursor_y < mwindow->theme->mcanvas_h -
1835 BC_ScrollBar::get_span(SCROLL_HORIZ) -
1838 create_y_pane(cursor_y);
1839 mwindow->edl->local_session->y_pane = cursor_y;
1843 delete_y_pane(cursor_y);
1844 mwindow->edl->local_session->y_pane = -1;
1848 update_pane_dividers();
1850 // required to get new widgets to appear
1852 resource_thread->start_draw();
1855 // create panes from EDL
1856 void MWindowGUI::load_panes()
1858 int need_x_panes = 0;
1859 int need_y_panes = 0;
1860 // use names from create functions
1861 int cursor_x = mwindow->edl->local_session->x_pane;
1862 int cursor_y = mwindow->edl->local_session->y_pane;
1864 resource_thread->stop_draw(1);
1866 mwindow->theme->patchbay_w + PANE_DRAG_MARGIN &&
1868 mwindow->theme->mcanvas_w -
1869 BC_ScrollBar::get_span(SCROLL_VERT) -
1876 mwindow->theme->mtimebar_h + PANE_DRAG_MARGIN &&
1878 mwindow->theme->mcanvas_h -
1879 BC_ScrollBar::get_span(SCROLL_HORIZ) -
1885 //printf("MWindowGUI::load_panes %d %d %d\n", __LINE__, need_x_panes, need_y_panes);
1893 if(total_panes() == 1)
1896 //printf("MWindowGUI::load_panes %d\n", __LINE__);
1897 pane[TOP_RIGHT_PANE] = new TimelinePane(mwindow,
1899 mwindow->theme->mcanvas_x +
1901 mwindow->theme->mcanvas_y,
1902 mwindow->theme->mcanvas_x +
1903 mwindow->theme->mcanvas_w -
1905 cursor_y - mwindow->theme->pane_h);
1906 pane[BOTTOM_LEFT_PANE] = new TimelinePane(mwindow,
1908 mwindow->theme->mcanvas_x,
1909 mwindow->theme->mcanvas_y +
1911 cursor_x - mwindow->theme->pane_w,
1912 mwindow->theme->mcanvas_h -
1914 pane[BOTTOM_RIGHT_PANE] = new TimelinePane(mwindow,
1916 pane[TOP_RIGHT_PANE]->x,
1917 mwindow->theme->mcanvas_y +
1919 pane[TOP_RIGHT_PANE]->w,
1920 mwindow->theme->mcanvas_h -
1922 pane[TOP_LEFT_PANE]->resize_event(
1923 pane[TOP_LEFT_PANE]->x,
1924 pane[TOP_LEFT_PANE]->y,
1925 cursor_x - mwindow->theme->pane_w,
1926 cursor_y - mwindow->theme->pane_h);
1927 pane[TOP_RIGHT_PANE]->create_objects();
1928 pane[BOTTOM_LEFT_PANE]->create_objects();
1929 pane[BOTTOM_RIGHT_PANE]->create_objects();
1932 if(horizontal_panes())
1934 // create vertical panes
1935 //printf("MWindowGUI::load_panes %d\n", __LINE__);
1936 pane[BOTTOM_LEFT_PANE] = new TimelinePane(mwindow,
1938 mwindow->theme->mcanvas_x,
1939 mwindow->theme->mcanvas_y +
1941 cursor_x - mwindow->theme->pane_w,
1942 mwindow->theme->mcanvas_h -
1944 pane[BOTTOM_RIGHT_PANE] = new TimelinePane(mwindow,
1946 pane[TOP_RIGHT_PANE]->x,
1947 mwindow->theme->mcanvas_y +
1949 pane[TOP_RIGHT_PANE]->w,
1950 mwindow->theme->mcanvas_h -
1952 pane[TOP_LEFT_PANE]->resize_event(
1953 pane[TOP_LEFT_PANE]->x,
1954 pane[TOP_LEFT_PANE]->y,
1955 cursor_x - mwindow->theme->pane_w,
1956 cursor_y - mwindow->theme->pane_h);
1957 pane[TOP_RIGHT_PANE]->resize_event(
1958 mwindow->theme->mcanvas_x +
1960 mwindow->theme->mcanvas_y,
1961 mwindow->theme->mcanvas_x +
1962 mwindow->theme->mcanvas_w -
1964 cursor_y - mwindow->theme->pane_h);
1965 pane[BOTTOM_LEFT_PANE]->create_objects();
1966 pane[BOTTOM_RIGHT_PANE]->create_objects();
1969 if(vertical_panes())
1971 // create horizontal panes
1972 //printf("MWindowGUI::load_panes %d\n", __LINE__);
1973 pane[TOP_RIGHT_PANE] = new TimelinePane(mwindow,
1975 mwindow->theme->mcanvas_x +
1977 mwindow->theme->mcanvas_y,
1978 mwindow->theme->mcanvas_x +
1979 mwindow->theme->mcanvas_w -
1981 cursor_y - mwindow->theme->pane_h);
1982 pane[BOTTOM_RIGHT_PANE] = new TimelinePane(mwindow,
1984 pane[TOP_RIGHT_PANE]->x,
1985 mwindow->theme->mcanvas_y +
1987 pane[TOP_RIGHT_PANE]->w,
1988 mwindow->theme->mcanvas_h -
1990 pane[TOP_LEFT_PANE]->resize_event(
1991 pane[TOP_LEFT_PANE]->x,
1992 pane[TOP_LEFT_PANE]->y,
1993 cursor_x - mwindow->theme->pane_w,
1994 cursor_y - mwindow->theme->pane_h);
1995 pane[BOTTOM_LEFT_PANE]->resize_event(
1996 pane[TOP_LEFT_PANE]->x,
1997 mwindow->theme->mcanvas_y +
1999 mwindow->theme->mcanvas_x +
2000 mwindow->theme->mcanvas_w -
2001 cursor_x - mwindow->theme->pane_w,
2002 mwindow->theme->mcanvas_h -
2004 pane[TOP_RIGHT_PANE]->create_objects();
2005 pane[BOTTOM_RIGHT_PANE]->create_objects();
2012 //printf("MWindowGUI::load_panes %d\n", __LINE__);
2013 pane[TOP_LEFT_PANE]->resize_event(
2014 pane[TOP_LEFT_PANE]->x,
2015 pane[TOP_LEFT_PANE]->y,
2016 cursor_x - mwindow->theme->pane_w,
2017 cursor_y - mwindow->theme->pane_h);
2018 pane[TOP_RIGHT_PANE]->resize_event(
2019 mwindow->theme->mcanvas_x +
2021 mwindow->theme->mcanvas_y,
2022 mwindow->theme->mcanvas_x +
2023 mwindow->theme->mcanvas_w -
2025 cursor_y - mwindow->theme->pane_h);
2026 pane[BOTTOM_LEFT_PANE]->resize_event(
2027 pane[TOP_LEFT_PANE]->x,
2028 mwindow->theme->mcanvas_y +
2030 mwindow->theme->mcanvas_x +
2031 mwindow->theme->mcanvas_w -
2032 cursor_x - mwindow->theme->pane_w,
2033 mwindow->theme->mcanvas_h -
2035 pane[BOTTOM_RIGHT_PANE]->resize_event(
2036 pane[TOP_RIGHT_PANE]->x,
2037 mwindow->theme->mcanvas_y +
2039 pane[TOP_RIGHT_PANE]->w,
2040 mwindow->theme->mcanvas_h -
2049 if(pane[BOTTOM_LEFT_PANE]) delete pane[BOTTOM_LEFT_PANE];
2050 if(pane[BOTTOM_RIGHT_PANE]) delete pane[BOTTOM_RIGHT_PANE];
2051 pane[BOTTOM_LEFT_PANE] = 0;
2052 pane[BOTTOM_RIGHT_PANE] = 0;
2054 if(!pane[TOP_RIGHT_PANE])
2056 pane[TOP_RIGHT_PANE] = new TimelinePane(mwindow,
2058 mwindow->theme->mcanvas_x +
2060 mwindow->theme->mcanvas_y,
2061 mwindow->theme->mcanvas_x +
2062 mwindow->theme->mcanvas_w -
2064 mwindow->theme->mcanvas_h);
2065 pane[TOP_LEFT_PANE]->resize_event(
2066 mwindow->theme->mcanvas_x,
2067 mwindow->theme->mcanvas_y,
2068 cursor_x - mwindow->theme->pane_w,
2069 mwindow->theme->mcanvas_h);
2070 pane[TOP_RIGHT_PANE]->create_objects();
2074 pane[TOP_LEFT_PANE]->resize_event(
2075 mwindow->theme->mcanvas_x,
2076 mwindow->theme->mcanvas_y,
2077 cursor_x - mwindow->theme->pane_w,
2078 mwindow->theme->mcanvas_h);
2079 pane[TOP_RIGHT_PANE]->resize_event(
2080 mwindow->theme->mcanvas_x +
2082 pane[TOP_RIGHT_PANE]->y,
2083 mwindow->theme->mcanvas_x +
2084 mwindow->theme->mcanvas_w -
2086 mwindow->theme->mcanvas_h);
2094 if(pane[TOP_RIGHT_PANE]) delete pane[TOP_RIGHT_PANE];
2095 if(pane[BOTTOM_RIGHT_PANE]) delete pane[BOTTOM_RIGHT_PANE];
2096 pane[TOP_RIGHT_PANE] = 0;
2097 pane[BOTTOM_RIGHT_PANE] = 0;
2099 if(!pane[BOTTOM_LEFT_PANE])
2101 //printf("MWindowGUI::load_panes %d\n", __LINE__);
2102 pane[BOTTOM_LEFT_PANE] = new TimelinePane(mwindow,
2104 mwindow->theme->mcanvas_x,
2105 mwindow->theme->mcanvas_y +
2107 mwindow->theme->mcanvas_w,
2108 mwindow->theme->mcanvas_h -
2110 pane[TOP_LEFT_PANE]->resize_event(
2111 mwindow->theme->mcanvas_x,
2112 mwindow->theme->mcanvas_y,
2113 mwindow->theme->mcanvas_w,
2114 pane[BOTTOM_LEFT_PANE]->y -
2115 mwindow->theme->mcanvas_y -
2116 mwindow->theme->pane_h);
2117 pane[BOTTOM_LEFT_PANE]->create_objects();
2121 pane[TOP_LEFT_PANE]->resize_event(
2122 mwindow->theme->mcanvas_x,
2123 mwindow->theme->mcanvas_y,
2124 mwindow->theme->mcanvas_w,
2125 cursor_y - mwindow->theme->pane_h);
2126 pane[BOTTOM_LEFT_PANE]->resize_event(
2127 pane[BOTTOM_LEFT_PANE]->x,
2129 mwindow->theme->mcanvas_y,
2130 mwindow->theme->mcanvas_w,
2131 mwindow->theme->mcanvas_h -
2138 if(pane[TOP_RIGHT_PANE]) delete pane[TOP_RIGHT_PANE];
2139 if(pane[BOTTOM_RIGHT_PANE]) delete pane[BOTTOM_RIGHT_PANE];
2140 if(pane[BOTTOM_LEFT_PANE]) delete pane[BOTTOM_LEFT_PANE];
2141 pane[TOP_RIGHT_PANE] = 0;
2142 pane[BOTTOM_RIGHT_PANE] = 0;
2143 pane[BOTTOM_LEFT_PANE] = 0;
2144 pane[TOP_LEFT_PANE]->resize_event(
2145 mwindow->theme->mcanvas_x,
2146 mwindow->theme->mcanvas_y,
2147 mwindow->theme->mcanvas_w,
2148 mwindow->theme->mcanvas_h);
2151 update_pane_dividers();
2154 resource_thread->start_draw();
2157 void MWindowGUI::update_pane_dividers()
2160 if(horizontal_panes() || total_panes() == 4)
2162 int x = pane[TOP_RIGHT_PANE]->x - mwindow->theme->pane_w;
2163 int y = mwindow->theme->mcanvas_y;
2164 int h = mwindow->theme->mcanvas_h;
2168 add_subwindow(x_divider = new PaneDivider(
2169 mwindow, x, y, h, 1));
2170 x_divider->create_objects();
2174 x_divider->reposition_window(x, y, h);
2187 if(vertical_panes() || total_panes() == 4)
2189 int x = mwindow->theme->mcanvas_x;
2190 int y = pane[BOTTOM_LEFT_PANE]->y -
2191 mwindow->theme->pane_h;
2192 int w = mwindow->theme->mcanvas_w;
2195 add_subwindow(y_divider = new PaneDivider(
2196 mwindow, x, y, w, 0));
2197 y_divider->create_objects();
2201 y_divider->reposition_window(x, y, w);
2215 void MWindowGUI::draw_samplemovement()
2222 update_scrollbars(1);
2225 void MWindowGUI::draw_trackmovement()
2227 update_scrollbars(0);
2234 PaneButton::PaneButton(MWindow *mwindow, int x, int y)
2235 : BC_Button(x, y, mwindow->theme->get_image_set("pane"))
2237 this->mwindow = mwindow;
2240 int PaneButton::cursor_motion_event()
2242 if(get_top_level()->get_button_down() &&
2244 get_status() == BUTTON_DOWNHI &&
2247 // printf("PaneButton::cursor_motion_event %d\n", __LINE__);
2249 if(get_cursor_x() < 0 && !mwindow->gui->dragging_pane)
2251 mwindow->gui->start_x_pane_drag();
2254 if(get_cursor_y() < 0 && !mwindow->gui->dragging_pane)
2256 mwindow->gui->start_y_pane_drag();
2260 mwindow->gui->handle_pane_drag();
2262 int result = BC_Button::cursor_motion_event();
2266 int PaneButton::button_release_event()
2268 mwindow->gui->stop_pane_drag();
2269 int result = BC_Button::button_release_event();
2274 FFMpegToggle::FFMpegToggle(MWindow *mwindow, MButtons *mbuttons, int x, int y)
2275 : BC_Toggle(x, y, mwindow->theme->ffmpeg_toggle, mwindow->preferences->ffmpeg_early_probe)
2277 this->mwindow = mwindow;
2278 this->mbuttons = mbuttons;
2279 set_tooltip( mwindow->preferences->ffmpeg_early_probe ?
2280 _("Try FFMpeg first") : _("Try FFMpeg last"));
2283 FFMpegToggle::~FFMpegToggle()
2287 int FFMpegToggle::handle_event()
2289 mwindow->preferences->ffmpeg_early_probe = get_value();
2290 set_tooltip( mwindow->preferences->ffmpeg_early_probe ?
2291 _("Try FFMpeg first") : _("Try FFMpeg last"));
2292 mwindow->show_warning(&mwindow->preferences->warn_indexes,
2293 _("Changing the base codecs may require rebuilding indexes."));