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 mwindow->theme->get_mwindow_sizes(this, w, h);
409 mwindow->theme->draw_mwindow_bg(this);
410 mbuttons->resize_event();
411 ffmpeg_toggle->reposition_window(menu_w(), menu_h()+2);
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();
541 int MWindowGUI::total_panes()
544 for(int i = 0; i < TOTAL_PANES; i++)
549 int MWindowGUI::vertical_panes()
551 return total_panes() == 2 &&
552 pane[TOP_LEFT_PANE] &&
553 pane[BOTTOM_LEFT_PANE];
556 int MWindowGUI::horizontal_panes()
558 return total_panes() == 2 &&
559 pane[TOP_LEFT_PANE] &&
560 pane[TOP_RIGHT_PANE];
563 TimelinePane* MWindowGUI::get_focused_pane()
565 if(pane[focused_pane]) return pane[focused_pane];
566 for(int i = 0; i < TOTAL_PANES; i++)
568 if(pane[i]) return pane[i];
573 void MWindowGUI::activate_timeline()
575 if(pane[focused_pane])
577 pane[focused_pane]->activate();
581 for(int i = 0; i < TOTAL_PANES; i++)
592 void MWindowGUI::deactivate_timeline()
594 for(int i = 0; i < TOTAL_PANES; i++)
598 pane[i]->canvas->deactivate();
603 void MWindowGUI::update_title(char *path)
606 char filename[BCTEXTLEN], string[BCTEXTLEN];
607 fs.extract_name(filename, path);
608 sprintf(string, _(PROGRAM_NAME ": %s"), filename);
610 //printf("MWindowGUI::update_title %s\n", string);
614 void MWindowGUI::draw_overlays(int flash_it)
616 for(int i = 0; i < TOTAL_PANES; i++)
620 pane[i]->canvas->draw_overlays();
621 if(flash_it) pane[i]->canvas->flash();
626 void MWindowGUI::update_timebar(int flush_it)
628 for(int i = 0; i < TOTAL_PANES; i++)
630 if(pane[i] && pane[i]->timebar)
632 pane[i]->timebar->update(flush_it);
637 void MWindowGUI::update_timebar_highlights()
639 for(int i = 0; i < TOTAL_PANES; i++)
641 if(pane[i] && pane[i]->timebar)
643 pane[i]->timebar->update_highlights();
649 void MWindowGUI::update_patchbay()
651 for(int i = 0; i < TOTAL_PANES; i++)
653 if(pane[i] && pane[i]->patchbay)
655 pane[i]->patchbay->update();
660 void MWindowGUI::draw_indexes(Indexable *indexable)
662 for(int i = 0; i < TOTAL_PANES; i++)
666 pane[i]->canvas->draw_indexes(indexable);
671 void MWindowGUI::draw_canvas(int mode /* = 0 */, int hide_cursor /* = 1 */)
673 if(mode != IGNORE_THREAD)
675 resource_thread->stop_draw(1);
679 for(int i = 0; i < TOTAL_PANES; i++)
683 pane[i]->canvas->draw(mode, hide_cursor);
688 if(mode != IGNORE_THREAD)
690 resource_thread->start_draw();
695 void MWindowGUI::flash_canvas(int flush)
697 for(int i = 0; i < TOTAL_PANES; i++)
701 pane[i]->canvas->flash(flush);
706 void MWindowGUI::draw_cursor(int do_plugintoggles)
708 for(int i = 0; i < TOTAL_PANES; i++)
712 pane[i]->cursor->draw(do_plugintoggles);
717 void MWindowGUI::show_cursor(int do_plugintoggles)
719 for(int i = 0; i < TOTAL_PANES; i++)
723 pane[i]->cursor->show(do_plugintoggles);
728 void MWindowGUI::hide_cursor(int do_plugintoggles)
730 for(int i = 0; i < TOTAL_PANES; i++)
734 pane[i]->cursor->hide(do_plugintoggles);
739 void MWindowGUI::update_cursor()
741 for(int i = 0; i < TOTAL_PANES; i++)
745 pane[i]->cursor->update();
750 void MWindowGUI::set_playing_back(int value)
752 for(int i = 0; i < TOTAL_PANES; i++)
756 pane[i]->cursor->playing_back = value;
761 void MWindowGUI::update_plugintoggles()
763 for(int i = 0; i < TOTAL_PANES; i++)
767 pane[i]->canvas->refresh_plugintoggles();
773 void MWindowGUI::update_scrollbars(int flush)
775 for(int i = 0; i < TOTAL_PANES; i++)
779 pane[i]->update(1, 0, 0, 0);
782 if(flush) this->flush();
785 void MWindowGUI::reset_meters()
787 for(int i = 0; i < TOTAL_PANES; i++)
789 if(pane[i] && pane[i]->patchbay)
791 pane[i]->patchbay->reset_meters();
796 void MWindowGUI::stop_meters()
798 for(int i = 0; i < TOTAL_PANES; i++)
800 if(pane[i] && pane[i]->patchbay)
802 pane[i]->patchbay->stop_meters();
807 void MWindowGUI::update_meters(ArrayList<double> *module_levels)
809 for(int i = 0; i < TOTAL_PANES; i++)
811 if(pane[i] && pane[i]->patchbay)
813 pane[i]->patchbay->update_meters(module_levels);
818 void MWindowGUI::set_editing_mode(int flush)
820 for(int i = 0; i < TOTAL_PANES; i++)
824 pane[i]->canvas->update_cursor(flush);
829 void MWindowGUI::set_meter_format(int mode, int min, int max)
831 for(int i = 0; i < TOTAL_PANES; i++)
833 if(pane[i] && pane[i]->patchbay)
835 pane[i]->patchbay->set_meter_format(mode, min, max);
840 void MWindowGUI::update(int scrollbars,
849 if(debug) PRINT_TRACE
853 mwindow->edl->tracks->update_y_pixels(mwindow->theme);
855 if(do_canvas && do_canvas != IGNORE_THREAD)
857 resource_thread->stop_draw(1);
860 for(int i = 0; i < TOTAL_PANES; i++)
862 if(pane[i]) pane[i]->update(scrollbars,
868 if(do_canvas && do_canvas != IGNORE_THREAD)
870 resource_thread->start_draw();
873 // if(scrollbars) this->get_scrollbars(0);
874 // if(timebar) this->timebar->update(0);
875 if(zoombar) this->zoombar->update();
876 // if(patchbay) this->patchbay->update();
877 if(clock) this->mainclock->update(
878 mwindow->edl->local_session->get_selectionstart(1));
879 if(debug) PRINT_TRACE
885 // this->canvas->draw(do_canvas);
886 // this->cursor->show();
887 // this->canvas->flash(0);
888 // Activate causes the menubar to deactivate. Don't want this for
890 // if(canvas != IGNORE_THREAD) this->canvas->activate();
892 if(debug) PRINT_TRACE
896 if(buttonbar) mbuttons->update();
897 if(debug) PRINT_TRACE
899 // Can't age if the cache called this to draw missing picons
900 // or the GUI is updating the status of the draw toggle.
901 if(do_canvas != FORCE_REDRAW && do_canvas != IGNORE_THREAD)
904 mwindow->age_caches();
905 lock_window("MWindowGUI::update");
909 if(debug) PRINT_TRACE
912 int MWindowGUI::visible(int64_t x1, int64_t x2, int64_t view_x1, int64_t view_x2)
914 return (x1 >= view_x1 && x1 < view_x2) ||
915 (x2 > view_x1 && x2 <= view_x2) ||
916 (x1 <= view_x1 && x2 >= view_x2);
920 int MWindowGUI::show_message(char *message, int color)
922 // printf("MWindowGUI::show_message %d: %s 0x%08x 0x%08x\n",
923 // __LINE__, message, color, mwindow->theme->message_normal);
924 if(color < 0) color = mwindow->theme->message_normal;
925 statusbar->status_text->set_color(color);
926 statusbar->status_text->update(message);
931 // Drag motion called from other window
932 int MWindowGUI::drag_motion()
934 if(get_hidden()) return 0;
936 Track *over_track = 0;
938 PluginSet *over_pluginset = 0;
939 Plugin *over_plugin = 0;
944 drag_popup->cursor_motion_event();
948 // there's no point in drawing highlights has until drag operation has been set
949 if (!mwindow->session->current_operation)
952 for(int i = 0; i < TOTAL_PANES; i++)
954 if(pane[i]) pane[i]->canvas->drag_motion(
961 if(mwindow->session->track_highlighted != over_track)
963 mwindow->session->track_highlighted = over_track;
967 if(mwindow->session->edit_highlighted != over_edit)
969 mwindow->session->edit_highlighted = over_edit;
973 if(mwindow->session->pluginset_highlighted != over_pluginset)
975 mwindow->session->pluginset_highlighted = over_pluginset;
979 if(mwindow->session->plugin_highlighted != over_plugin)
981 mwindow->session->plugin_highlighted = over_plugin;
985 if( mwindow->session->current_operation == DRAG_ASSET ||
986 mwindow->session->current_operation == DRAG_EDIT ||
987 mwindow->session->current_operation == DRAG_AEFFECT_COPY ||
988 mwindow->session->current_operation == DRAG_VEFFECT_COPY )
994 // printf("drag_motion %d %d over_track=%p over_edit=%p\n",
1001 lock_window("MWindowGUI::drag_motion");
1008 int MWindowGUI::drag_stop()
1010 if(get_hidden()) return 0;
1011 int result = 0, redraw = 0;
1013 for(int i = 0; i < TOTAL_PANES; i++)
1015 if(pane[i]) result |= pane[i]->canvas->drag_stop(
1018 mwindow->edl->optimize();
1020 // since we don't have subwindows we have to terminate any drag operation
1023 if (mwindow->session->track_highlighted
1024 || mwindow->session->edit_highlighted
1025 || mwindow->session->plugin_highlighted
1026 || mwindow->session->pluginset_highlighted)
1028 mwindow->session->track_highlighted = 0;
1029 mwindow->session->edit_highlighted = 0;
1030 mwindow->session->plugin_highlighted = 0;
1031 mwindow->session->pluginset_highlighted = 0;
1032 mwindow->session->current_operation = NO_OPERATION;
1036 //printf("TrackCanvas::drag_stop %d %d\n", redraw, mwindow->session->current_operation);
1039 mwindow->edl->tracks->update_y_pixels(mwindow->theme);
1040 update_scrollbars(0);
1055 void MWindowGUI::default_positions()
1057 //printf("MWindowGUI::default_positions 1\n");
1058 VWindow *vwindow = mwindow->vwindows.size() > DEFAULT_VWINDOW ?
1059 mwindow->vwindows.get(DEFAULT_VWINDOW) : 0;
1060 if( vwindow && !vwindow->is_running() ) vwindow = 0;
1061 if( vwindow ) vwindow->gui->lock_window("MWindowGUI::default_positions");
1062 mwindow->cwindow->gui->lock_window("MWindowGUI::default_positions");
1063 mwindow->awindow->gui->lock_window("MWindowGUI::default_positions");
1065 // printf("MWindowGUI::default_positions 1 %d %d %d %d\n", mwindow->session->vwindow_x,
1066 // mwindow->session->vwindow_y,
1067 // mwindow->session->vwindow_w,
1068 // mwindow->session->vwindow_h);
1069 reposition_window(mwindow->session->mwindow_x,
1070 mwindow->session->mwindow_y,
1071 mwindow->session->mwindow_w,
1072 mwindow->session->mwindow_h);
1073 if( vwindow ) vwindow->gui->reposition_window(mwindow->session->vwindow_x,
1074 mwindow->session->vwindow_y,
1075 mwindow->session->vwindow_w,
1076 mwindow->session->vwindow_h);
1077 mwindow->cwindow->gui->reposition_window(mwindow->session->cwindow_x,
1078 mwindow->session->cwindow_y,
1079 mwindow->session->cwindow_w,
1080 mwindow->session->cwindow_h);
1081 mwindow->awindow->gui->reposition_window(mwindow->session->awindow_x,
1082 mwindow->session->awindow_y,
1083 mwindow->session->awindow_w,
1084 mwindow->session->awindow_h);
1085 //printf("MWindowGUI::default_positions 1\n");
1087 resize_event(mwindow->session->mwindow_w,
1088 mwindow->session->mwindow_h);
1089 //printf("MWindowGUI::default_positions 1\n");
1090 if( vwindow ) vwindow->gui->resize_event(mwindow->session->vwindow_w,
1091 mwindow->session->vwindow_h);
1092 //printf("MWindowGUI::default_positions 1\n");
1093 mwindow->cwindow->gui->resize_event(mwindow->session->cwindow_w,
1094 mwindow->session->cwindow_h);
1095 //printf("MWindowGUI::default_positions 1\n");
1096 mwindow->awindow->gui->resize_event(mwindow->session->awindow_w,
1097 mwindow->session->awindow_h);
1099 //printf("MWindowGUI::default_positions 1\n");
1102 if( vwindow ) vwindow->gui->flush();
1103 mwindow->cwindow->gui->flush();
1104 mwindow->awindow->gui->flush();
1106 if( vwindow ) vwindow->gui->unlock_window();
1107 mwindow->cwindow->gui->unlock_window();
1108 mwindow->awindow->gui->unlock_window();
1109 //printf("MWindowGUI::default_positions 2\n");
1113 int MWindowGUI::button_release_event()
1115 if( keyvalue_popup ) {
1116 delete keyvalue_popup; keyvalue_popup = 0;
1122 int MWindowGUI::repeat_event(int64_t duration)
1124 // if(duration == 100)
1125 // mwindow->sync_parameters(CHANGE_ALL);
1127 for(int i = 0; i < TOTAL_PANES; i++)
1129 if(pane[i]) result = pane[i]->cursor->repeat_event(duration);
1135 int MWindowGUI::translation_event()
1137 //printf("MWindowGUI::translation_event 1 %d %d\n", get_x(), get_y());
1138 mwindow->session->mwindow_x = get_x();
1139 mwindow->session->mwindow_y = get_y();
1144 int MWindowGUI::save_defaults(BC_Hash *defaults)
1146 defaults->update("MWINDOWWIDTH", get_w());
1147 defaults->update("MWINDOWHEIGHT", get_h());
1148 mainmenu->save_defaults(defaults);
1149 BC_WindowBase::save_defaults(defaults);
1153 int MWindowGUI::keypress_event()
1155 //printf("MWindowGUI::keypress_event 1 %d\n", get_keypress());
1156 int result = mbuttons->keypress_event();
1157 if( result ) return result;
1159 switch(get_keypress()) {
1161 mwindow->toggle_editing_mode();
1165 case '1': case '2': case '3': case '4':
1166 case '5': case '6': case '7': case '8':
1167 if( !alt_down() || shift_down() ) break;
1168 if( !mwindow->select_asset(get_keypress()-'1',1) )
1173 if( !ctrl_down() ) {
1176 mbuttons->transport->handle_transport(STOP, 1, 0, 0);
1177 lock_window("MWindowGUI::keypress_event 1");
1178 mwindow->prev_edit_handle(shift_down());
1181 mwindow->move_left();
1187 if( !ctrl_down() ) {
1190 mbuttons->transport->handle_transport(STOP, 1, 0, 0);
1191 lock_window("MWindowGUI::keypress_event 2");
1192 mwindow->next_edit_handle(shift_down());
1195 mwindow->move_right();
1201 if( ctrl_down() && !alt_down() )
1202 mwindow->expand_y();
1203 else if( !ctrl_down() && alt_down() )
1204 mwindow->expand_autos(0,1,1);
1205 else if( ctrl_down() && alt_down() )
1206 mwindow->expand_autos(1,1,1);
1208 mwindow->expand_sample();
1213 if( ctrl_down() && !alt_down() )
1214 mwindow->zoom_in_y();
1215 else if( !ctrl_down() && alt_down() )
1216 mwindow->shrink_autos(0,1,1);
1217 else if( ctrl_down() && alt_down() )
1218 mwindow->shrink_autos(1,1,1);
1220 mwindow->zoom_in_sample();
1228 mwindow->expand_t();
1234 mwindow->move_down();
1236 mwindow->zoom_in_t();
1242 Track *this_track = 0;
1243 for( int i=0; i<TOTAL_PANES; ++i ) {
1244 if( !pane[i] ) continue;
1245 if( (this_track = pane[i]->over_track()) != 0 ) break;
1246 if( (this_track = pane[i]->over_patchbay()) != 0 ) break;
1249 if( get_keypress() == TAB ) { // Switch the record button
1251 this_track->record = !this_track->record ? 1 : 0;
1254 int total_selected = mwindow->edl->tracks->total_of(Tracks::RECORD);
1255 // all selected if nothing previously selected or
1256 // if this patch was previously the only one selected and armed
1257 int selected = !total_selected || (total_selected == 1 &&
1258 this_track && this_track->record ) ? 1 : 0;
1259 mwindow->edl->tracks->select_all(Tracks::RECORD, selected);
1260 if( !selected && this_track ) this_track->record = 1;
1263 update(0, 1, 0, 0, 1, 0, 1);
1265 mwindow->cwindow->update(0, 1, 1);
1266 lock_window("TrackCanvas::keypress_event 3");
1272 // since things under cursor have changed...
1274 cursor_motion_event();
1279 int MWindowGUI::keyboard_listener(BC_WindowBase *wp)
1281 return key_listener(wp->get_keypress());
1284 int MWindowGUI::key_listener(int key)
1289 if( !record->running() )
1292 record->record_gui->interrupt_thread->start(0);
1299 channel_info->toggle_scan();
1303 if( !remote_control->deactivate() )
1304 remote_control->activate();
1314 void MWindowGUI::use_android_remote(int on)
1317 delete android_control;
1318 android_control = 0;
1321 if( android_control ) return;
1322 android_control = new AndroidControl(this);
1325 int MWindowGUI::close_event()
1331 void MWindowGUI::stop_drawing()
1333 resource_thread->stop_draw(1);
1336 int MWindowGUI::menu_w()
1338 return mainmenu->get_w();
1341 int MWindowGUI::menu_h()
1343 return mainmenu->get_h();
1346 void MWindowGUI::start_x_pane_drag()
1350 x_pane_drag = new BC_Popup(this,
1351 get_abs_cursor_x(0) - mwindow->theme->pane_w,
1352 BC_DisplayInfo::get_top_border() +
1354 mwindow->theme->mcanvas_y,
1355 mwindow->theme->pane_w,
1356 mwindow->theme->mcanvas_h,
1357 mwindow->theme->drag_pane_color);
1358 x_pane_drag->draw_3segmentv(0,
1360 x_pane_drag->get_h(),
1361 mwindow->theme->get_image_set("xpane")[BUTTON_DOWNHI]);
1362 x_pane_drag->flash(1);
1367 void MWindowGUI::start_y_pane_drag()
1371 //printf("MWindowGUI::start_y_pane_drag %d %d %d\n", __LINE__, get_x(), get_y());
1372 y_pane_drag = new BC_Popup(this,
1373 BC_DisplayInfo::get_left_border() +
1375 mwindow->theme->mcanvas_x,
1376 get_abs_cursor_y(0) - mwindow->theme->pane_h,
1377 mwindow->theme->mcanvas_w,
1378 mwindow->theme->pane_h,
1379 mwindow->theme->drag_pane_color);
1380 y_pane_drag->draw_3segmenth(0,
1382 y_pane_drag->get_w(),
1383 mwindow->theme->get_image_set("ypane")[BUTTON_DOWNHI]);
1384 y_pane_drag->flash(1);
1389 void MWindowGUI::handle_pane_drag()
1395 x_pane_drag->reposition_window(
1396 get_abs_cursor_x(0) - mwindow->theme->pane_w,
1397 x_pane_drag->get_y());
1402 y_pane_drag->reposition_window(
1403 y_pane_drag->get_x(),
1404 get_abs_cursor_y(0) - mwindow->theme->pane_h);
1410 void MWindowGUI::create_x_pane(int cursor_x)
1412 if(total_panes() == 1)
1414 // create a horizontal pane
1415 // do this 1st so the resize_event knows there are 2 panes
1416 mwindow->edl->local_session->view_start[TOP_RIGHT_PANE] =
1417 mwindow->edl->local_session->view_start[TOP_LEFT_PANE] +
1419 mwindow->theme->patchbay_w;
1420 pane[TOP_RIGHT_PANE] = new TimelinePane(mwindow,
1422 mwindow->theme->mcanvas_x +
1424 mwindow->theme->mcanvas_y,
1425 mwindow->theme->mcanvas_x +
1426 mwindow->theme->mcanvas_w -
1428 mwindow->theme->mcanvas_h);
1429 pane[TOP_LEFT_PANE]->resize_event(
1430 mwindow->theme->mcanvas_x,
1431 mwindow->theme->mcanvas_y,
1432 cursor_x - mwindow->theme->pane_w,
1433 mwindow->theme->mcanvas_h);
1434 pane[TOP_RIGHT_PANE]->create_objects();
1437 if(vertical_panes())
1439 // create 2 horizontal panes
1440 mwindow->edl->local_session->track_start[TOP_RIGHT_PANE] =
1441 mwindow->edl->local_session->track_start[TOP_LEFT_PANE];
1442 mwindow->edl->local_session->track_start[BOTTOM_RIGHT_PANE] =
1443 mwindow->edl->local_session->track_start[BOTTOM_LEFT_PANE];
1444 mwindow->edl->local_session->view_start[TOP_RIGHT_PANE] =
1445 mwindow->edl->local_session->view_start[BOTTOM_RIGHT_PANE] =
1446 mwindow->edl->local_session->view_start[TOP_LEFT_PANE] +
1448 mwindow->theme->patchbay_w;
1449 pane[TOP_RIGHT_PANE] = new TimelinePane(mwindow,
1451 mwindow->theme->mcanvas_x +
1453 pane[TOP_LEFT_PANE]->y,
1454 mwindow->theme->mcanvas_x +
1455 mwindow->theme->mcanvas_w -
1457 pane[TOP_LEFT_PANE]->h);
1458 pane[BOTTOM_RIGHT_PANE] = new TimelinePane(mwindow,
1460 mwindow->theme->mcanvas_x +
1462 pane[BOTTOM_LEFT_PANE]->y,
1463 mwindow->theme->mcanvas_x +
1464 mwindow->theme->mcanvas_w -
1466 pane[BOTTOM_LEFT_PANE]->h);
1467 pane[TOP_LEFT_PANE]->resize_event(
1468 pane[TOP_LEFT_PANE]->x,
1469 pane[TOP_LEFT_PANE]->y,
1470 cursor_x - mwindow->theme->pane_w,
1471 pane[TOP_LEFT_PANE]->h);
1472 pane[BOTTOM_LEFT_PANE]->resize_event(
1473 pane[BOTTOM_LEFT_PANE]->x,
1474 pane[BOTTOM_LEFT_PANE]->y,
1475 cursor_x - mwindow->theme->pane_w,
1476 pane[BOTTOM_LEFT_PANE]->h);
1477 pane[TOP_RIGHT_PANE]->create_objects();
1478 pane[BOTTOM_RIGHT_PANE]->create_objects();
1481 if(horizontal_panes())
1483 // resize a horizontal pane
1484 mwindow->edl->local_session->view_start[TOP_RIGHT_PANE] +=
1486 pane[TOP_RIGHT_PANE]->x;
1487 if(mwindow->edl->local_session->view_start[TOP_RIGHT_PANE] < 0)
1488 mwindow->edl->local_session->view_start[TOP_RIGHT_PANE] = 0;
1489 pane[TOP_LEFT_PANE]->resize_event(
1490 mwindow->theme->mcanvas_x,
1491 mwindow->theme->mcanvas_y,
1492 cursor_x - mwindow->theme->pane_w,
1493 mwindow->theme->mcanvas_h);
1494 pane[TOP_RIGHT_PANE]->resize_event(
1495 mwindow->theme->mcanvas_x +
1497 pane[TOP_RIGHT_PANE]->y,
1498 mwindow->theme->mcanvas_x +
1499 mwindow->theme->mcanvas_w -
1501 mwindow->theme->mcanvas_h);
1505 // resize 2 horizontal panes
1506 mwindow->edl->local_session->view_start[TOP_RIGHT_PANE] +=
1508 pane[TOP_RIGHT_PANE]->x;
1509 if(mwindow->edl->local_session->view_start[TOP_RIGHT_PANE] < 0)
1510 mwindow->edl->local_session->view_start[TOP_RIGHT_PANE] = 0;
1511 mwindow->edl->local_session->view_start[BOTTOM_RIGHT_PANE] =
1512 mwindow->edl->local_session->view_start[TOP_RIGHT_PANE];
1514 pane[TOP_LEFT_PANE]->resize_event(
1515 mwindow->theme->mcanvas_x,
1516 pane[TOP_LEFT_PANE]->y,
1517 cursor_x - mwindow->theme->pane_w,
1518 pane[TOP_LEFT_PANE]->h);
1519 pane[TOP_RIGHT_PANE]->resize_event(
1520 mwindow->theme->mcanvas_x +
1522 pane[TOP_RIGHT_PANE]->y,
1523 mwindow->theme->mcanvas_x +
1524 mwindow->theme->mcanvas_w -
1526 pane[TOP_RIGHT_PANE]->h);
1527 pane[BOTTOM_LEFT_PANE]->resize_event(
1528 mwindow->theme->mcanvas_x,
1529 pane[BOTTOM_LEFT_PANE]->y,
1530 cursor_x - mwindow->theme->pane_w,
1531 pane[BOTTOM_LEFT_PANE]->h);
1532 pane[BOTTOM_RIGHT_PANE]->resize_event(
1533 mwindow->theme->mcanvas_x +
1535 pane[BOTTOM_RIGHT_PANE]->y,
1536 mwindow->theme->mcanvas_x +
1537 mwindow->theme->mcanvas_w -
1539 pane[BOTTOM_RIGHT_PANE]->h);
1545 void MWindowGUI::delete_x_pane(int cursor_x)
1547 // give left panes coordinates of right pane
1548 if(cursor_x < mwindow->theme->patchbay_w + PANE_DRAG_MARGIN &&
1549 pane[TOP_RIGHT_PANE])
1551 mwindow->edl->local_session->view_start[TOP_LEFT_PANE] =
1552 mwindow->edl->local_session->view_start[TOP_RIGHT_PANE] -
1553 pane[TOP_RIGHT_PANE]->x + mwindow->theme->patchbay_w;
1554 if(mwindow->edl->local_session->view_start[TOP_LEFT_PANE] < 0)
1555 mwindow->edl->local_session->view_start[TOP_LEFT_PANE] = 0;
1556 mwindow->edl->local_session->view_start[BOTTOM_LEFT_PANE] =
1557 mwindow->edl->local_session->view_start[TOP_LEFT_PANE];
1560 switch(total_panes())
1563 if(pane[TOP_LEFT_PANE] && pane[TOP_RIGHT_PANE])
1565 // delete right pane
1566 delete pane[TOP_RIGHT_PANE];
1567 pane[TOP_RIGHT_PANE] = 0;
1568 pane[TOP_LEFT_PANE]->resize_event(
1569 mwindow->theme->mcanvas_x,
1570 mwindow->theme->mcanvas_y,
1571 mwindow->theme->mcanvas_w,
1572 mwindow->theme->mcanvas_h);
1578 // delete right panes
1579 delete pane[TOP_RIGHT_PANE];
1580 pane[TOP_RIGHT_PANE] = 0;
1581 delete pane[BOTTOM_RIGHT_PANE];
1582 pane[BOTTOM_RIGHT_PANE] = 0;
1583 pane[TOP_LEFT_PANE]->resize_event(
1584 mwindow->theme->mcanvas_x,
1585 pane[TOP_LEFT_PANE]->y,
1586 mwindow->theme->mcanvas_w,
1587 pane[TOP_LEFT_PANE]->h);
1588 pane[BOTTOM_LEFT_PANE]->resize_event(
1589 mwindow->theme->mcanvas_x,
1590 pane[BOTTOM_LEFT_PANE]->y,
1591 mwindow->theme->mcanvas_w,
1592 pane[BOTTOM_LEFT_PANE]->h);
1597 void MWindowGUI::create_y_pane(int cursor_y)
1599 if(total_panes() == 1)
1601 mwindow->edl->local_session->view_start[BOTTOM_LEFT_PANE] =
1602 mwindow->edl->local_session->view_start[TOP_LEFT_PANE];
1603 mwindow->edl->local_session->track_start[BOTTOM_LEFT_PANE] =
1604 mwindow->edl->local_session->track_start[TOP_LEFT_PANE] +
1606 mwindow->theme->mtimebar_h;
1607 // do this 1st so the resize_event knows there are 2 panes
1608 pane[BOTTOM_LEFT_PANE] = new TimelinePane(mwindow,
1610 mwindow->theme->mcanvas_x,
1611 mwindow->theme->mcanvas_y +
1613 mwindow->theme->mcanvas_w,
1614 mwindow->theme->mcanvas_h -
1616 pane[TOP_LEFT_PANE]->resize_event(
1617 mwindow->theme->mcanvas_x,
1618 mwindow->theme->mcanvas_y,
1619 mwindow->theme->mcanvas_w,
1620 pane[BOTTOM_LEFT_PANE]->y -
1621 mwindow->theme->mcanvas_y -
1622 mwindow->theme->pane_h);
1623 pane[BOTTOM_LEFT_PANE]->create_objects();
1626 if(horizontal_panes())
1629 mwindow->edl->local_session->view_start[BOTTOM_LEFT_PANE] =
1630 mwindow->edl->local_session->view_start[TOP_LEFT_PANE];
1631 mwindow->edl->local_session->view_start[BOTTOM_RIGHT_PANE] =
1632 mwindow->edl->local_session->view_start[TOP_RIGHT_PANE];
1633 mwindow->edl->local_session->track_start[BOTTOM_LEFT_PANE] =
1634 mwindow->edl->local_session->track_start[BOTTOM_RIGHT_PANE] =
1635 mwindow->edl->local_session->track_start[TOP_LEFT_PANE] +
1637 mwindow->theme->mtimebar_h;
1639 pane[BOTTOM_LEFT_PANE] = new TimelinePane(mwindow,
1641 pane[TOP_LEFT_PANE]->x,
1642 mwindow->theme->mcanvas_y +
1644 pane[TOP_LEFT_PANE]->w,
1645 mwindow->theme->mcanvas_h -
1647 pane[BOTTOM_RIGHT_PANE] = new TimelinePane(mwindow,
1649 pane[TOP_RIGHT_PANE]->x,
1650 mwindow->theme->mcanvas_y +
1652 pane[TOP_RIGHT_PANE]->w,
1653 mwindow->theme->mcanvas_h -
1656 pane[TOP_LEFT_PANE]->resize_event(
1657 pane[TOP_LEFT_PANE]->x,
1658 pane[TOP_LEFT_PANE]->y,
1659 pane[TOP_LEFT_PANE]->w,
1660 pane[BOTTOM_LEFT_PANE]->y -
1661 mwindow->theme->mcanvas_y -
1662 mwindow->theme->pane_h);
1663 pane[TOP_RIGHT_PANE]->resize_event(
1664 pane[TOP_RIGHT_PANE]->x,
1665 pane[TOP_RIGHT_PANE]->y,
1666 pane[TOP_RIGHT_PANE]->w,
1667 pane[BOTTOM_RIGHT_PANE]->y -
1668 mwindow->theme->mcanvas_y -
1669 mwindow->theme->pane_h);
1671 pane[BOTTOM_LEFT_PANE]->create_objects();
1672 pane[BOTTOM_RIGHT_PANE]->create_objects();
1675 if(vertical_panes())
1678 mwindow->edl->local_session->track_start[BOTTOM_LEFT_PANE] +=
1680 (pane[BOTTOM_LEFT_PANE]->y - mwindow->theme->mcanvas_y);
1681 if(mwindow->edl->local_session->track_start[BOTTOM_LEFT_PANE] < 0)
1682 mwindow->edl->local_session->track_start[BOTTOM_LEFT_PANE] = 0;
1683 pane[TOP_LEFT_PANE]->resize_event(
1684 mwindow->theme->mcanvas_x,
1685 mwindow->theme->mcanvas_y,
1686 mwindow->theme->mcanvas_w,
1687 cursor_y - mwindow->theme->pane_h);
1688 pane[BOTTOM_LEFT_PANE]->resize_event(
1689 pane[BOTTOM_LEFT_PANE]->x,
1691 mwindow->theme->mcanvas_y,
1692 mwindow->theme->mcanvas_w,
1693 mwindow->theme->mcanvas_h -
1699 mwindow->edl->local_session->track_start[BOTTOM_LEFT_PANE] +=
1701 (pane[BOTTOM_LEFT_PANE]->y - mwindow->theme->mcanvas_y);
1702 if(mwindow->edl->local_session->track_start[BOTTOM_LEFT_PANE] < 0)
1703 mwindow->edl->local_session->track_start[BOTTOM_LEFT_PANE] = 0;
1704 mwindow->edl->local_session->track_start[BOTTOM_RIGHT_PANE] =
1705 mwindow->edl->local_session->track_start[BOTTOM_LEFT_PANE];
1706 pane[TOP_LEFT_PANE]->resize_event(
1707 pane[TOP_LEFT_PANE]->x,
1708 pane[TOP_LEFT_PANE]->y,
1709 pane[TOP_LEFT_PANE]->w,
1710 cursor_y - mwindow->theme->pane_h);
1711 pane[BOTTOM_LEFT_PANE]->resize_event(
1712 pane[BOTTOM_LEFT_PANE]->x,
1714 mwindow->theme->mcanvas_y,
1715 pane[BOTTOM_LEFT_PANE]->w,
1716 mwindow->theme->mcanvas_h -
1718 pane[TOP_RIGHT_PANE]->resize_event(
1719 pane[TOP_RIGHT_PANE]->x,
1720 pane[TOP_RIGHT_PANE]->y,
1721 pane[TOP_RIGHT_PANE]->w,
1722 cursor_y - mwindow->theme->pane_h);
1723 pane[BOTTOM_RIGHT_PANE]->resize_event(
1724 pane[BOTTOM_RIGHT_PANE]->x,
1726 mwindow->theme->mcanvas_y,
1727 pane[BOTTOM_RIGHT_PANE]->w,
1728 mwindow->theme->mcanvas_h -
1733 void MWindowGUI::delete_y_pane(int cursor_y)
1735 if(cursor_y < mwindow->theme->mtimebar_h +
1737 pane[BOTTOM_LEFT_PANE])
1739 // give top pane coordinates of bottom pane
1740 mwindow->edl->local_session->track_start[TOP_LEFT_PANE] =
1741 mwindow->edl->local_session->track_start[BOTTOM_LEFT_PANE] -
1742 pane[BOTTOM_LEFT_PANE]->y;
1743 if(mwindow->edl->local_session->track_start[TOP_LEFT_PANE] < 0)
1744 mwindow->edl->local_session->track_start[TOP_LEFT_PANE] = 0;
1745 mwindow->edl->local_session->track_start[TOP_RIGHT_PANE] =
1746 mwindow->edl->local_session->track_start[TOP_LEFT_PANE];
1750 switch(total_panes())
1753 delete pane[BOTTOM_LEFT_PANE];
1754 pane[BOTTOM_LEFT_PANE] = 0;
1755 pane[TOP_LEFT_PANE]->resize_event(
1756 mwindow->theme->mcanvas_x,
1757 mwindow->theme->mcanvas_y,
1758 mwindow->theme->mcanvas_w,
1759 mwindow->theme->mcanvas_h);
1763 // delete bottom 2 panes
1765 delete pane[BOTTOM_LEFT_PANE];
1766 pane[BOTTOM_LEFT_PANE] = 0;
1767 delete pane[BOTTOM_RIGHT_PANE];
1768 pane[BOTTOM_RIGHT_PANE] = 0;
1769 pane[TOP_LEFT_PANE]->resize_event(
1770 pane[TOP_LEFT_PANE]->x,
1771 mwindow->theme->mcanvas_y,
1772 pane[TOP_LEFT_PANE]->w,
1773 mwindow->theme->mcanvas_h);
1774 pane[TOP_RIGHT_PANE]->resize_event(
1775 pane[TOP_RIGHT_PANE]->x,
1776 mwindow->theme->mcanvas_y,
1777 pane[TOP_RIGHT_PANE]->w,
1778 mwindow->theme->mcanvas_h);
1783 void MWindowGUI::stop_pane_drag()
1786 resource_thread->stop_draw(1);
1790 // cursor position relative to canvas
1791 int cursor_x = x_pane_drag->get_x() -
1793 BC_DisplayInfo::get_left_border() -
1794 mwindow->theme->mcanvas_x +
1795 mwindow->theme->pane_w;
1800 if(cursor_x >= mwindow->theme->patchbay_w + PANE_DRAG_MARGIN &&
1801 cursor_x < mwindow->theme->mcanvas_w -
1802 BC_ScrollBar::get_span(SCROLL_VERT) -
1805 create_x_pane(cursor_x);
1806 mwindow->edl->local_session->x_pane = cursor_x;
1811 delete_x_pane(cursor_x);
1812 mwindow->edl->local_session->x_pane = -1;
1820 // cursor position relative to canvas
1821 int cursor_y = y_pane_drag->get_y() -
1823 BC_DisplayInfo::get_top_border() -
1824 mwindow->theme->mcanvas_y +
1825 mwindow->theme->pane_h;
1831 if(cursor_y >= mwindow->theme->mtimebar_h +
1833 cursor_y < mwindow->theme->mcanvas_h -
1834 BC_ScrollBar::get_span(SCROLL_HORIZ) -
1837 create_y_pane(cursor_y);
1838 mwindow->edl->local_session->y_pane = cursor_y;
1842 delete_y_pane(cursor_y);
1843 mwindow->edl->local_session->y_pane = -1;
1847 update_pane_dividers();
1849 // required to get new widgets to appear
1851 resource_thread->start_draw();
1854 // create panes from EDL
1855 void MWindowGUI::load_panes()
1857 int need_x_panes = 0;
1858 int need_y_panes = 0;
1859 // use names from create functions
1860 int cursor_x = mwindow->edl->local_session->x_pane;
1861 int cursor_y = mwindow->edl->local_session->y_pane;
1863 resource_thread->stop_draw(1);
1865 mwindow->theme->patchbay_w + PANE_DRAG_MARGIN &&
1867 mwindow->theme->mcanvas_w -
1868 BC_ScrollBar::get_span(SCROLL_VERT) -
1875 mwindow->theme->mtimebar_h + PANE_DRAG_MARGIN &&
1877 mwindow->theme->mcanvas_h -
1878 BC_ScrollBar::get_span(SCROLL_HORIZ) -
1884 //printf("MWindowGUI::load_panes %d %d %d\n", __LINE__, need_x_panes, need_y_panes);
1892 if(total_panes() == 1)
1895 //printf("MWindowGUI::load_panes %d\n", __LINE__);
1896 pane[TOP_RIGHT_PANE] = new TimelinePane(mwindow,
1898 mwindow->theme->mcanvas_x +
1900 mwindow->theme->mcanvas_y,
1901 mwindow->theme->mcanvas_x +
1902 mwindow->theme->mcanvas_w -
1904 cursor_y - mwindow->theme->pane_h);
1905 pane[BOTTOM_LEFT_PANE] = new TimelinePane(mwindow,
1907 mwindow->theme->mcanvas_x,
1908 mwindow->theme->mcanvas_y +
1910 cursor_x - mwindow->theme->pane_w,
1911 mwindow->theme->mcanvas_h -
1913 pane[BOTTOM_RIGHT_PANE] = new TimelinePane(mwindow,
1915 pane[TOP_RIGHT_PANE]->x,
1916 mwindow->theme->mcanvas_y +
1918 pane[TOP_RIGHT_PANE]->w,
1919 mwindow->theme->mcanvas_h -
1921 pane[TOP_LEFT_PANE]->resize_event(
1922 pane[TOP_LEFT_PANE]->x,
1923 pane[TOP_LEFT_PANE]->y,
1924 cursor_x - mwindow->theme->pane_w,
1925 cursor_y - mwindow->theme->pane_h);
1926 pane[TOP_RIGHT_PANE]->create_objects();
1927 pane[BOTTOM_LEFT_PANE]->create_objects();
1928 pane[BOTTOM_RIGHT_PANE]->create_objects();
1931 if(horizontal_panes())
1933 // create vertical panes
1934 //printf("MWindowGUI::load_panes %d\n", __LINE__);
1935 pane[BOTTOM_LEFT_PANE] = new TimelinePane(mwindow,
1937 mwindow->theme->mcanvas_x,
1938 mwindow->theme->mcanvas_y +
1940 cursor_x - mwindow->theme->pane_w,
1941 mwindow->theme->mcanvas_h -
1943 pane[BOTTOM_RIGHT_PANE] = new TimelinePane(mwindow,
1945 pane[TOP_RIGHT_PANE]->x,
1946 mwindow->theme->mcanvas_y +
1948 pane[TOP_RIGHT_PANE]->w,
1949 mwindow->theme->mcanvas_h -
1951 pane[TOP_LEFT_PANE]->resize_event(
1952 pane[TOP_LEFT_PANE]->x,
1953 pane[TOP_LEFT_PANE]->y,
1954 cursor_x - mwindow->theme->pane_w,
1955 cursor_y - mwindow->theme->pane_h);
1956 pane[TOP_RIGHT_PANE]->resize_event(
1957 mwindow->theme->mcanvas_x +
1959 mwindow->theme->mcanvas_y,
1960 mwindow->theme->mcanvas_x +
1961 mwindow->theme->mcanvas_w -
1963 cursor_y - mwindow->theme->pane_h);
1964 pane[BOTTOM_LEFT_PANE]->create_objects();
1965 pane[BOTTOM_RIGHT_PANE]->create_objects();
1968 if(vertical_panes())
1970 // create horizontal panes
1971 //printf("MWindowGUI::load_panes %d\n", __LINE__);
1972 pane[TOP_RIGHT_PANE] = new TimelinePane(mwindow,
1974 mwindow->theme->mcanvas_x +
1976 mwindow->theme->mcanvas_y,
1977 mwindow->theme->mcanvas_x +
1978 mwindow->theme->mcanvas_w -
1980 cursor_y - mwindow->theme->pane_h);
1981 pane[BOTTOM_RIGHT_PANE] = new TimelinePane(mwindow,
1983 pane[TOP_RIGHT_PANE]->x,
1984 mwindow->theme->mcanvas_y +
1986 pane[TOP_RIGHT_PANE]->w,
1987 mwindow->theme->mcanvas_h -
1989 pane[TOP_LEFT_PANE]->resize_event(
1990 pane[TOP_LEFT_PANE]->x,
1991 pane[TOP_LEFT_PANE]->y,
1992 cursor_x - mwindow->theme->pane_w,
1993 cursor_y - mwindow->theme->pane_h);
1994 pane[BOTTOM_LEFT_PANE]->resize_event(
1995 pane[TOP_LEFT_PANE]->x,
1996 mwindow->theme->mcanvas_y +
1998 mwindow->theme->mcanvas_x +
1999 mwindow->theme->mcanvas_w -
2000 cursor_x - mwindow->theme->pane_w,
2001 mwindow->theme->mcanvas_h -
2003 pane[TOP_RIGHT_PANE]->create_objects();
2004 pane[BOTTOM_RIGHT_PANE]->create_objects();
2011 //printf("MWindowGUI::load_panes %d\n", __LINE__);
2012 pane[TOP_LEFT_PANE]->resize_event(
2013 pane[TOP_LEFT_PANE]->x,
2014 pane[TOP_LEFT_PANE]->y,
2015 cursor_x - mwindow->theme->pane_w,
2016 cursor_y - mwindow->theme->pane_h);
2017 pane[TOP_RIGHT_PANE]->resize_event(
2018 mwindow->theme->mcanvas_x +
2020 mwindow->theme->mcanvas_y,
2021 mwindow->theme->mcanvas_x +
2022 mwindow->theme->mcanvas_w -
2024 cursor_y - mwindow->theme->pane_h);
2025 pane[BOTTOM_LEFT_PANE]->resize_event(
2026 pane[TOP_LEFT_PANE]->x,
2027 mwindow->theme->mcanvas_y +
2029 mwindow->theme->mcanvas_x +
2030 mwindow->theme->mcanvas_w -
2031 cursor_x - mwindow->theme->pane_w,
2032 mwindow->theme->mcanvas_h -
2034 pane[BOTTOM_RIGHT_PANE]->resize_event(
2035 pane[TOP_RIGHT_PANE]->x,
2036 mwindow->theme->mcanvas_y +
2038 pane[TOP_RIGHT_PANE]->w,
2039 mwindow->theme->mcanvas_h -
2048 if(pane[BOTTOM_LEFT_PANE]) delete pane[BOTTOM_LEFT_PANE];
2049 if(pane[BOTTOM_RIGHT_PANE]) delete pane[BOTTOM_RIGHT_PANE];
2050 pane[BOTTOM_LEFT_PANE] = 0;
2051 pane[BOTTOM_RIGHT_PANE] = 0;
2053 if(!pane[TOP_RIGHT_PANE])
2055 pane[TOP_RIGHT_PANE] = new TimelinePane(mwindow,
2057 mwindow->theme->mcanvas_x +
2059 mwindow->theme->mcanvas_y,
2060 mwindow->theme->mcanvas_x +
2061 mwindow->theme->mcanvas_w -
2063 mwindow->theme->mcanvas_h);
2064 pane[TOP_LEFT_PANE]->resize_event(
2065 mwindow->theme->mcanvas_x,
2066 mwindow->theme->mcanvas_y,
2067 cursor_x - mwindow->theme->pane_w,
2068 mwindow->theme->mcanvas_h);
2069 pane[TOP_RIGHT_PANE]->create_objects();
2073 pane[TOP_LEFT_PANE]->resize_event(
2074 mwindow->theme->mcanvas_x,
2075 mwindow->theme->mcanvas_y,
2076 cursor_x - mwindow->theme->pane_w,
2077 mwindow->theme->mcanvas_h);
2078 pane[TOP_RIGHT_PANE]->resize_event(
2079 mwindow->theme->mcanvas_x +
2081 pane[TOP_RIGHT_PANE]->y,
2082 mwindow->theme->mcanvas_x +
2083 mwindow->theme->mcanvas_w -
2085 mwindow->theme->mcanvas_h);
2093 if(pane[TOP_RIGHT_PANE]) delete pane[TOP_RIGHT_PANE];
2094 if(pane[BOTTOM_RIGHT_PANE]) delete pane[BOTTOM_RIGHT_PANE];
2095 pane[TOP_RIGHT_PANE] = 0;
2096 pane[BOTTOM_RIGHT_PANE] = 0;
2098 if(!pane[BOTTOM_LEFT_PANE])
2100 //printf("MWindowGUI::load_panes %d\n", __LINE__);
2101 pane[BOTTOM_LEFT_PANE] = new TimelinePane(mwindow,
2103 mwindow->theme->mcanvas_x,
2104 mwindow->theme->mcanvas_y +
2106 mwindow->theme->mcanvas_w,
2107 mwindow->theme->mcanvas_h -
2109 pane[TOP_LEFT_PANE]->resize_event(
2110 mwindow->theme->mcanvas_x,
2111 mwindow->theme->mcanvas_y,
2112 mwindow->theme->mcanvas_w,
2113 pane[BOTTOM_LEFT_PANE]->y -
2114 mwindow->theme->mcanvas_y -
2115 mwindow->theme->pane_h);
2116 pane[BOTTOM_LEFT_PANE]->create_objects();
2120 pane[TOP_LEFT_PANE]->resize_event(
2121 mwindow->theme->mcanvas_x,
2122 mwindow->theme->mcanvas_y,
2123 mwindow->theme->mcanvas_w,
2124 cursor_y - mwindow->theme->pane_h);
2125 pane[BOTTOM_LEFT_PANE]->resize_event(
2126 pane[BOTTOM_LEFT_PANE]->x,
2128 mwindow->theme->mcanvas_y,
2129 mwindow->theme->mcanvas_w,
2130 mwindow->theme->mcanvas_h -
2137 if(pane[TOP_RIGHT_PANE]) delete pane[TOP_RIGHT_PANE];
2138 if(pane[BOTTOM_RIGHT_PANE]) delete pane[BOTTOM_RIGHT_PANE];
2139 if(pane[BOTTOM_LEFT_PANE]) delete pane[BOTTOM_LEFT_PANE];
2140 pane[TOP_RIGHT_PANE] = 0;
2141 pane[BOTTOM_RIGHT_PANE] = 0;
2142 pane[BOTTOM_LEFT_PANE] = 0;
2143 pane[TOP_LEFT_PANE]->resize_event(
2144 mwindow->theme->mcanvas_x,
2145 mwindow->theme->mcanvas_y,
2146 mwindow->theme->mcanvas_w,
2147 mwindow->theme->mcanvas_h);
2150 update_pane_dividers();
2153 resource_thread->start_draw();
2156 void MWindowGUI::update_pane_dividers()
2159 if(horizontal_panes() || total_panes() == 4)
2161 int x = pane[TOP_RIGHT_PANE]->x - mwindow->theme->pane_w;
2162 int y = mwindow->theme->mcanvas_y;
2163 int h = mwindow->theme->mcanvas_h;
2167 add_subwindow(x_divider = new PaneDivider(
2168 mwindow, x, y, h, 1));
2169 x_divider->create_objects();
2173 x_divider->reposition_window(x, y, h);
2186 if(vertical_panes() || total_panes() == 4)
2188 int x = mwindow->theme->mcanvas_x;
2189 int y = pane[BOTTOM_LEFT_PANE]->y -
2190 mwindow->theme->pane_h;
2191 int w = mwindow->theme->mcanvas_w;
2194 add_subwindow(y_divider = new PaneDivider(
2195 mwindow, x, y, w, 0));
2196 y_divider->create_objects();
2200 y_divider->reposition_window(x, y, w);
2214 void MWindowGUI::draw_samplemovement()
2221 update_scrollbars(1);
2224 void MWindowGUI::draw_trackmovement()
2226 update_scrollbars(0);
2233 PaneButton::PaneButton(MWindow *mwindow, int x, int y)
2234 : BC_Button(x, y, mwindow->theme->get_image_set("pane"))
2236 this->mwindow = mwindow;
2239 int PaneButton::cursor_motion_event()
2241 if(get_top_level()->get_button_down() &&
2243 get_status() == BUTTON_DOWNHI &&
2246 // printf("PaneButton::cursor_motion_event %d\n", __LINE__);
2248 if(get_cursor_x() < 0 && !mwindow->gui->dragging_pane)
2250 mwindow->gui->start_x_pane_drag();
2253 if(get_cursor_y() < 0 && !mwindow->gui->dragging_pane)
2255 mwindow->gui->start_y_pane_drag();
2259 mwindow->gui->handle_pane_drag();
2261 int result = BC_Button::cursor_motion_event();
2265 int PaneButton::button_release_event()
2267 mwindow->gui->stop_pane_drag();
2268 int result = BC_Button::button_release_event();
2273 FFMpegToggle::FFMpegToggle(MWindow *mwindow, MButtons *mbuttons, int x, int y)
2274 : BC_Toggle(x, y, mwindow->theme->ffmpeg_toggle, mwindow->preferences->ffmpeg_early_probe)
2276 this->mwindow = mwindow;
2277 this->mbuttons = mbuttons;
2278 set_tooltip( mwindow->preferences->ffmpeg_early_probe ?
2279 _("Try FFMpeg first") : _("Try FFMpeg last"));
2282 FFMpegToggle::~FFMpegToggle()
2286 int FFMpegToggle::handle_event()
2288 mwindow->preferences->ffmpeg_early_probe = get_value();
2289 set_tooltip( mwindow->preferences->ffmpeg_early_probe ?
2290 _("Try FFMpeg first") : _("Try FFMpeg last"));
2291 mwindow->show_warning(&mwindow->preferences->warn_indexes,
2292 _("Changing the base codecs may require rebuilding indexes."));