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"
58 #include "recordgui.h"
59 #include "renderengine.h"
60 #include "resourcethread.h"
61 #include "samplescroll.h"
62 #include "shbtnprefs.h"
63 #include "statusbar.h"
66 #include "trackcanvas.h"
67 #include "trackscroll.h"
69 #include "transitionpopup.h"
70 #include "vwindowgui.h"
74 #define PANE_DRAG_MARGIN MAX(mwindow->theme->pane_w, mwindow->theme->pane_h)
77 // the main window uses its own private colormap for video
78 MWindowGUI::MWindowGUI(MWindow *mwindow)
79 : BC_Window(_(PROGRAM_NAME ": Program"),
80 mwindow->session->mwindow_x,
81 mwindow->session->mwindow_y,
82 mwindow->session->mwindow_w,
83 mwindow->session->mwindow_h,
90 this->mwindow = mwindow;
97 focused_pane = TOP_LEFT_PANE;
106 for(int i = 0; i < TOTAL_PANES; i++)
123 cwindow_remote_handler = 0;
124 record_remote_handler = 0;
129 MWindowGUI::~MWindowGUI()
131 delete android_control;
132 delete cwindow_remote_handler;
133 delete record_remote_handler;
134 delete remote_control;
135 // delete samplescroll;
136 // delete trackscroll;
137 for(int i = 0; i < TOTAL_PANES; i++)
138 if(pane[i]) delete pane[i];
140 delete render_engine;
141 delete resource_thread;
142 resource_pixmaps.remove_all_objects();
151 void MWindowGUI::get_scrollbars(int flush)
153 //int64_t h_needed = mwindow->edl->get_tracks_height(mwindow->theme);
154 //int64_t w_needed = mwindow->edl->get_tracks_width();
155 int need_xscroll = 0;
156 int need_yscroll = 0;
157 view_w = mwindow->theme->mcanvas_w;
158 view_h = mwindow->theme->mcanvas_h;
160 // Scrollbars are constitutive
161 need_xscroll = need_yscroll = 1;
162 view_h = mwindow->theme->mcanvas_h;
163 view_w = mwindow->theme->mcanvas_w;
165 // for(int i = 0; i < 2; i++)
167 // if(w_needed > view_w)
170 // view_h = mwindow->theme->mcanvas_h - SCROLL_SPAN;
175 // if(h_needed > view_h)
178 // view_w = mwindow->theme->mcanvas_w - SCROLL_SPAN;
183 //printf("MWindowGUI::get_scrollbars 1\n");
185 if(canvas && (view_w != canvas->get_w() || view_h != canvas->get_h()))
187 canvas->reposition_window(mwindow->theme->mcanvas_x,
188 mwindow->theme->mcanvas_y,
196 add_subwindow(samplescroll = new SampleScroll(mwindow,
198 mwindow->theme->mhscroll_x,
199 mwindow->theme->mhscroll_y,
200 mwindow->theme->mhscroll_w));
202 samplescroll->resize_event();
204 samplescroll->set_position(0);
208 if(samplescroll) delete samplescroll;
210 mwindow->edl->local_session->view_start = 0;
216 //printf("MWindowGUI::get_scrollbars 1.1 %p %p\n", this, canvas);
218 add_subwindow(trackscroll = new TrackScroll(mwindow,
220 mwindow->theme->mvscroll_x,
221 mwindow->theme->mvscroll_y,
222 mwindow->theme->mvscroll_h));
224 trackscroll->resize_event();
227 //printf("MWindowGUI::get_scrollbars 1.2\n");
228 trackscroll->update_length(mwindow->edl->get_tracks_height(mwindow->theme),
229 mwindow->edl->local_session->track_start,
232 //printf("MWindowGUI::get_scrollbars 1.3\n");
236 if(trackscroll) delete trackscroll;
238 mwindow->edl->local_session->track_start = 0;
241 if(flush) this->flush();
246 void MWindowGUI::create_objects()
250 resource_thread = new ResourceThread(mwindow, this);
251 resource_thread->create_objects();
254 if(debug) printf("MWindowGUI::create_objects %d\n", __LINE__);
255 set_icon(mwindow->theme->get_image("mwindow_icon"));
256 remote_control = new RemoteControl(this);
257 cwindow_remote_handler = new CWindowRemoteHandler(remote_control);
258 record_remote_handler = new RecordRemoteHandler(remote_control);
259 mwindow->reset_android_remote();
261 if(debug) printf("MWindowGUI::create_objects %d\n", __LINE__);
263 int x = get_w() - MainShBtns::calculate_w(0);
264 add_subwindow(mainmenu = new MainMenu(mwindow, this, x));
265 add_subwindow(mainshbtns = new MainShBtns(mwindow, x, 0));
266 mainshbtns->load(mwindow->preferences);
267 mwindow->theme->get_mwindow_sizes(this, get_w(), get_h());
268 mwindow->theme->draw_mwindow_bg(this);
269 mainmenu->create_objects();
270 if(debug) printf("MWindowGUI::create_objects %d\n", __LINE__);
272 add_subwindow(mbuttons = new MButtons(mwindow, this));
273 mbuttons->create_objects();
275 pane[TOP_LEFT_PANE] = new TimelinePane(mwindow,
277 mwindow->theme->mcanvas_x,
278 mwindow->theme->mcanvas_y,
279 mwindow->theme->mcanvas_w,
280 mwindow->theme->mcanvas_h);
281 pane[TOP_LEFT_PANE]->create_objects();
283 // add_subwindow(timebar = new MTimeBar(mwindow,
285 // mwindow->theme->mtimebar_x,
286 // mwindow->theme->mtimebar_y,
287 // mwindow->theme->mtimebar_w,
288 // mwindow->theme->mtimebar_h));
289 // timebar->create_objects();
291 // if(debug) printf("MWindowGUI::create_objects %d\n", __LINE__);
292 // add_subwindow(patchbay = new PatchBay(mwindow, this));
293 // patchbay->create_objects();
295 // if(debug) printf("MWindowGUI::create_objects %d\n", __LINE__);
296 // get_scrollbars(0);
298 // if(debug) printf("MWindowGUI::create_objects %d\n", __LINE__);
299 // mwindow->gui->add_subwindow(canvas = new TrackCanvas(mwindow, this));
300 // canvas->create_objects();
303 if(debug) printf("MWindowGUI::create_objects %d\n", __LINE__);
304 add_subwindow(zoombar = new ZoomBar(mwindow, this));
305 zoombar->create_objects();
308 if(debug) printf("MWindowGUI::create_objects %d\n", __LINE__);
309 add_subwindow(statusbar = new StatusBar(mwindow, this));
310 statusbar->create_objects();
314 if(debug) printf("MWindowGUI::create_objects %d\n", __LINE__);
315 add_subwindow(mainclock = new MainClock(mwindow,
316 mwindow->theme->mclock_x,
317 mwindow->theme->mclock_y,
318 mwindow->theme->mclock_w));
319 if(debug) printf("MWindowGUI::create_objects %d\n", __LINE__);
320 mainclock->update(0);
324 // if(debug) printf("MWindowGUI::create_objects %d\n", __LINE__);
325 // cursor = new MainCursor(mwindow, this);
326 // cursor->create_objects();
329 if(debug) printf("MWindowGUI::create_objects %d\n", __LINE__);
330 add_subwindow(edit_menu = new EditPopup(mwindow, this));
331 edit_menu->create_objects();
334 if(debug) printf("MWindowGUI::create_objects %d\n", __LINE__);
335 add_subwindow(plugin_menu = new PluginPopup(mwindow, this));
336 plugin_menu->create_objects();
339 if(debug) printf("MWindowGUI::create_objects %d\n", __LINE__);
340 add_subwindow(keyframe_menu = new KeyframePopup(mwindow, this));
341 keyframe_menu->create_objects();
344 if(debug) printf("MWindowGUI::create_objects %d\n", __LINE__);
345 add_subwindow(transition_menu = new TransitionPopup(mwindow, this));
346 transition_menu->create_objects();
348 channel_info = new ChannelInfo(mwindow);
349 db_window = new DbWindow(mwindow);
350 swindow = new SWindow(mwindow);
352 if(debug) printf("MWindowGUI::create_objects %d\n", __LINE__);
354 add_subwindow(pane_button = new PaneButton(mwindow,
355 get_w() - mwindow->theme->get_image_set("pane")[0]->get_w(),
356 mwindow->theme->mzoom_y + 1 - mwindow->theme->get_image_set("pane")[0]->get_h()));
358 pane[TOP_LEFT_PANE]->canvas->activate();
360 if(debug) printf("MWindowGUI::create_objects %d\n", __LINE__);
363 void MWindowGUI::redraw_time_dependancies()
365 zoombar->redraw_time_dependancies();
366 for(int i = 0; i < TOTAL_PANES; i++)
367 if(pane[i] && pane[i]->timebar) pane[i]->timebar->update(0);
368 mainclock->update(mwindow->edl->local_session->get_selectionstart(1));
371 int MWindowGUI::focus_in_event()
373 for(int i = 0; i < TOTAL_PANES; i++)
374 if(pane[i]) pane[i]->cursor->focus_in_event();
378 int MWindowGUI::focus_out_event()
380 for(int i = 0; i < TOTAL_PANES; i++)
381 if(pane[i]) pane[i]->cursor->focus_out_event();
386 int MWindowGUI::resize_event(int w, int h)
388 //printf("MWindowGUI::resize_event %d\n", __LINE__);
389 mwindow->session->mwindow_w = w;
390 mwindow->session->mwindow_h = h;
391 mwindow->theme->get_mwindow_sizes(this, w, h);
392 mwindow->theme->draw_mwindow_bg(this);
393 mbuttons->resize_event();
394 statusbar->resize_event();
396 resource_thread->stop_draw(1);
398 if(total_panes() > 1)
400 if(horizontal_panes())
402 // printf("MWindowGUI::resize_event %d %d %d\n",
404 // pane[TOP_RIGHT_PANE]->x,
405 // mwindow->theme->mcanvas_w -
406 // BC_ScrollBar::get_span(SCROLL_VERT) -
407 // PANE_DRAG_MARGIN);
408 if(pane[TOP_RIGHT_PANE]->x >= mwindow->theme->mcanvas_w -
409 BC_ScrollBar::get_span(SCROLL_VERT) -
412 delete_x_pane(pane[TOP_RIGHT_PANE]->x);
413 mwindow->edl->local_session->x_pane = -1;
419 if(pane[BOTTOM_LEFT_PANE]->y >= mwindow->theme->mzoom_y -
420 BC_ScrollBar::get_span(SCROLL_HORIZ) -
423 delete_y_pane(pane[BOTTOM_LEFT_PANE]->y);
424 mwindow->edl->local_session->y_pane = -1;
429 if(pane[TOP_RIGHT_PANE]->x >= mwindow->theme->mcanvas_w -
430 BC_ScrollBar::get_span(SCROLL_VERT) -
433 delete_x_pane(pane[TOP_RIGHT_PANE]->x);
434 mwindow->edl->local_session->x_pane = -1;
437 if(pane[BOTTOM_LEFT_PANE]->y >= mwindow->theme->mzoom_y -
438 BC_ScrollBar::get_span(SCROLL_HORIZ) -
441 delete_y_pane(pane[BOTTOM_LEFT_PANE]->y);
442 mwindow->edl->local_session->y_pane = -1;
447 if(total_panes() == 1)
449 pane[TOP_LEFT_PANE]->resize_event(
450 mwindow->theme->mcanvas_x,
451 mwindow->theme->mcanvas_y,
452 mwindow->theme->mcanvas_w,
453 mwindow->theme->mcanvas_h);
456 if(horizontal_panes())
458 pane[TOP_LEFT_PANE]->resize_event(
459 pane[TOP_LEFT_PANE]->x,
460 pane[TOP_LEFT_PANE]->y,
461 pane[TOP_LEFT_PANE]->w,
462 mwindow->theme->mcanvas_h);
463 pane[TOP_RIGHT_PANE]->resize_event(
464 pane[TOP_RIGHT_PANE]->x,
465 pane[TOP_RIGHT_PANE]->y,
466 mwindow->theme->mcanvas_w - pane[TOP_RIGHT_PANE]->x,
467 mwindow->theme->mcanvas_h);
472 pane[TOP_LEFT_PANE]->resize_event(
473 pane[TOP_LEFT_PANE]->x,
474 pane[TOP_LEFT_PANE]->y,
475 mwindow->theme->mcanvas_w,
476 pane[TOP_LEFT_PANE]->h);
477 pane[BOTTOM_LEFT_PANE]->resize_event(
478 pane[BOTTOM_LEFT_PANE]->x,
479 pane[BOTTOM_LEFT_PANE]->y,
480 mwindow->theme->mcanvas_w,
481 mwindow->theme->mcanvas_y +
482 mwindow->theme->mcanvas_h -
483 pane[BOTTOM_LEFT_PANE]->y);
487 pane[TOP_LEFT_PANE]->resize_event(
488 pane[TOP_LEFT_PANE]->x,
489 pane[TOP_LEFT_PANE]->y,
490 pane[TOP_LEFT_PANE]->w,
491 pane[TOP_LEFT_PANE]->h);
492 pane[TOP_RIGHT_PANE]->resize_event(
493 pane[TOP_RIGHT_PANE]->x,
494 pane[TOP_RIGHT_PANE]->y,
495 mwindow->theme->mcanvas_w - pane[TOP_RIGHT_PANE]->x,
496 pane[TOP_RIGHT_PANE]->h);
497 pane[BOTTOM_LEFT_PANE]->resize_event(
498 pane[BOTTOM_LEFT_PANE]->x,
499 pane[BOTTOM_LEFT_PANE]->y,
500 pane[BOTTOM_LEFT_PANE]->w,
501 mwindow->theme->mcanvas_y +
502 mwindow->theme->mcanvas_h -
503 pane[BOTTOM_LEFT_PANE]->y);
504 pane[BOTTOM_RIGHT_PANE]->resize_event(
505 pane[BOTTOM_RIGHT_PANE]->x,
506 pane[BOTTOM_RIGHT_PANE]->y,
507 mwindow->theme->mcanvas_w -
508 pane[BOTTOM_RIGHT_PANE]->x,
509 mwindow->theme->mcanvas_y +
510 mwindow->theme->mcanvas_h -
511 pane[BOTTOM_RIGHT_PANE]->y);
514 resource_thread->start_draw();
516 update_pane_dividers();
517 zoombar->resize_event();
518 pane_button->reposition_window(w - mwindow->theme->get_image_set("pane")[0]->get_w(),
519 mwindow->theme->mzoom_y + 1 - mwindow->theme->get_image_set("pane")[0]->get_h());
520 int x = get_w() - MainShBtns::calculate_w(0);
521 mainmenu->resize_event(x, mainmenu->get_h());
522 mainshbtns->reposition_window(x, 0);
523 // get_scrollbars(0);
524 // canvas->resize_event();
525 //printf("MWindowGUI::resize_event %d\n", __LINE__);
526 // required to get new widgets to appear after a pane deletion
531 int MWindowGUI::total_panes()
534 for(int i = 0; i < TOTAL_PANES; i++)
539 int MWindowGUI::vertical_panes()
541 return total_panes() == 2 &&
542 pane[TOP_LEFT_PANE] &&
543 pane[BOTTOM_LEFT_PANE];
546 int MWindowGUI::horizontal_panes()
548 return total_panes() == 2 &&
549 pane[TOP_LEFT_PANE] &&
550 pane[TOP_RIGHT_PANE];
553 TimelinePane* MWindowGUI::get_focused_pane()
555 if(pane[focused_pane]) return pane[focused_pane];
556 for(int i = 0; i < TOTAL_PANES; i++)
558 if(pane[i]) return pane[i];
563 void MWindowGUI::activate_timeline()
565 if(pane[focused_pane])
567 pane[focused_pane]->activate();
571 for(int i = 0; i < TOTAL_PANES; i++)
582 void MWindowGUI::deactivate_timeline()
584 for(int i = 0; i < TOTAL_PANES; i++)
588 pane[i]->canvas->deactivate();
593 void MWindowGUI::update_title(char *path)
596 char filename[BCTEXTLEN], string[BCTEXTLEN];
597 fs.extract_name(filename, path);
598 sprintf(string, _(PROGRAM_NAME ": %s"), filename);
600 //printf("MWindowGUI::update_title %s\n", string);
604 void MWindowGUI::draw_overlays(int flash_it)
606 for(int i = 0; i < TOTAL_PANES; i++)
610 pane[i]->canvas->draw_overlays();
611 if(flash_it) pane[i]->canvas->flash();
616 void MWindowGUI::update_timebar(int flush_it)
618 for(int i = 0; i < TOTAL_PANES; i++)
620 if(pane[i] && pane[i]->timebar)
622 pane[i]->timebar->update(flush_it);
627 void MWindowGUI::update_timebar_highlights()
629 for(int i = 0; i < TOTAL_PANES; i++)
631 if(pane[i] && pane[i]->timebar)
633 pane[i]->timebar->update_highlights();
639 void MWindowGUI::update_patchbay()
641 for(int i = 0; i < TOTAL_PANES; i++)
643 if(pane[i] && pane[i]->patchbay)
645 pane[i]->patchbay->update();
650 void MWindowGUI::draw_indexes(Indexable *indexable)
652 for(int i = 0; i < TOTAL_PANES; i++)
656 pane[i]->canvas->draw_indexes(indexable);
661 void MWindowGUI::draw_canvas(int mode /* = 0 */, int hide_cursor /* = 1 */)
663 if(mode != IGNORE_THREAD)
665 resource_thread->stop_draw(1);
669 for(int i = 0; i < TOTAL_PANES; i++)
673 pane[i]->canvas->draw(mode, hide_cursor);
678 if(mode != IGNORE_THREAD)
680 resource_thread->start_draw();
685 void MWindowGUI::flash_canvas(int flush)
687 for(int i = 0; i < TOTAL_PANES; i++)
691 pane[i]->canvas->flash(flush);
696 void MWindowGUI::draw_cursor(int do_plugintoggles)
698 for(int i = 0; i < TOTAL_PANES; i++)
702 pane[i]->cursor->draw(do_plugintoggles);
707 void MWindowGUI::show_cursor(int do_plugintoggles)
709 for(int i = 0; i < TOTAL_PANES; i++)
713 pane[i]->cursor->show(do_plugintoggles);
718 void MWindowGUI::hide_cursor(int do_plugintoggles)
720 for(int i = 0; i < TOTAL_PANES; i++)
724 pane[i]->cursor->hide(do_plugintoggles);
729 void MWindowGUI::update_cursor()
731 for(int i = 0; i < TOTAL_PANES; i++)
735 pane[i]->cursor->update();
740 void MWindowGUI::set_playing_back(int value)
742 for(int i = 0; i < TOTAL_PANES; i++)
746 pane[i]->cursor->playing_back = value;
751 void MWindowGUI::update_plugintoggles()
753 for(int i = 0; i < TOTAL_PANES; i++)
757 pane[i]->canvas->refresh_plugintoggles();
763 void MWindowGUI::update_scrollbars(int flush)
765 for(int i = 0; i < TOTAL_PANES; i++)
769 pane[i]->update(1, 0, 0, 0);
772 if(flush) this->flush();
775 void MWindowGUI::reset_meters()
777 for(int i = 0; i < TOTAL_PANES; i++)
779 if(pane[i] && pane[i]->patchbay)
781 pane[i]->patchbay->reset_meters();
786 void MWindowGUI::stop_meters()
788 for(int i = 0; i < TOTAL_PANES; i++)
790 if(pane[i] && pane[i]->patchbay)
792 pane[i]->patchbay->stop_meters();
797 void MWindowGUI::update_meters(ArrayList<double> *module_levels)
799 for(int i = 0; i < TOTAL_PANES; i++)
801 if(pane[i] && pane[i]->patchbay)
803 pane[i]->patchbay->update_meters(module_levels);
808 void MWindowGUI::set_editing_mode(int flush)
810 for(int i = 0; i < TOTAL_PANES; i++)
814 pane[i]->canvas->update_cursor(flush);
819 void MWindowGUI::set_meter_format(int mode, int min, int max)
821 for(int i = 0; i < TOTAL_PANES; i++)
823 if(pane[i] && pane[i]->patchbay)
825 pane[i]->patchbay->set_meter_format(mode, min, max);
830 void MWindowGUI::update(int scrollbars,
839 if(debug) PRINT_TRACE
843 mwindow->edl->tracks->update_y_pixels(mwindow->theme);
845 if(do_canvas && do_canvas != IGNORE_THREAD)
847 resource_thread->stop_draw(1);
850 for(int i = 0; i < TOTAL_PANES; i++)
852 if(pane[i]) pane[i]->update(scrollbars,
858 if(do_canvas && do_canvas != IGNORE_THREAD)
860 resource_thread->start_draw();
863 // if(scrollbars) this->get_scrollbars(0);
864 // if(timebar) this->timebar->update(0);
865 if(zoombar) this->zoombar->update();
866 // if(patchbay) this->patchbay->update();
867 if(clock) this->mainclock->update(
868 mwindow->edl->local_session->get_selectionstart(1));
869 if(debug) PRINT_TRACE
875 // this->canvas->draw(do_canvas);
876 // this->cursor->show();
877 // this->canvas->flash(0);
878 // Activate causes the menubar to deactivate. Don't want this for
880 // if(canvas != IGNORE_THREAD) this->canvas->activate();
882 if(debug) PRINT_TRACE
886 if(buttonbar) mbuttons->update();
887 if(debug) PRINT_TRACE
889 // Can't age if the cache called this to draw missing picons
890 // or the GUI is updating the status of the draw toggle.
891 if(do_canvas != FORCE_REDRAW && do_canvas != IGNORE_THREAD)
894 mwindow->age_caches();
895 lock_window("MWindowGUI::update");
899 if(debug) PRINT_TRACE
902 int MWindowGUI::visible(int64_t x1, int64_t x2, int64_t view_x1, int64_t view_x2)
904 return (x1 >= view_x1 && x1 < view_x2) ||
905 (x2 > view_x1 && x2 <= view_x2) ||
906 (x1 <= view_x1 && x2 >= view_x2);
910 int MWindowGUI::show_message(char *message, int color)
912 // printf("MWindowGUI::show_message %d: %s 0x%08x 0x%08x\n",
913 // __LINE__, message, color, mwindow->theme->message_normal);
914 if(color < 0) color = mwindow->theme->message_normal;
915 statusbar->status_text->set_color(color);
916 statusbar->status_text->update(message);
921 // Drag motion called from other window
922 int MWindowGUI::drag_motion()
924 if(get_hidden()) return 0;
926 Track *over_track = 0;
928 PluginSet *over_pluginset = 0;
929 Plugin *over_plugin = 0;
934 drag_popup->cursor_motion_event();
938 // there's no point in drawing highlights has until drag operation has been set
939 if (!mwindow->session->current_operation)
942 if(mwindow->session->free_drag) redraw = 1;
947 mwindow->session->free_drag = 1;
951 mwindow->session->free_drag = 0;
955 for(int i = 0; i < TOTAL_PANES; i++)
957 if(pane[i]) pane[i]->canvas->drag_motion(
966 if(mwindow->session->track_highlighted != over_track)
968 mwindow->session->track_highlighted = over_track;
972 if(mwindow->session->edit_highlighted != over_edit)
974 mwindow->session->edit_highlighted = over_edit;
978 if(mwindow->session->pluginset_highlighted != over_pluginset)
980 mwindow->session->pluginset_highlighted = over_pluginset;
984 if(mwindow->session->plugin_highlighted != over_plugin)
986 mwindow->session->plugin_highlighted = over_plugin;
990 // printf("drag_motion %d %d over_track=%p over_edit=%p\n",
997 lock_window("MWindowGUI::drag_motion");
1004 int MWindowGUI::drag_stop()
1006 if(get_hidden()) return 0;
1007 int result = 0, redraw = 0;
1009 for(int i = 0; i < TOTAL_PANES; i++)
1011 if(pane[i]) result |= pane[i]->canvas->drag_stop(
1016 // since we don't have subwindows we have to terminate any drag operation
1019 if (mwindow->session->track_highlighted
1020 || mwindow->session->edit_highlighted
1021 || mwindow->session->plugin_highlighted
1022 || mwindow->session->pluginset_highlighted)
1024 mwindow->session->track_highlighted = 0;
1025 mwindow->session->edit_highlighted = 0;
1026 mwindow->session->plugin_highlighted = 0;
1027 mwindow->session->pluginset_highlighted = 0;
1028 mwindow->session->current_operation = NO_OPERATION;
1032 //printf("TrackCanvas::drag_stop %d %d\n", redraw, mwindow->session->current_operation);
1035 mwindow->edl->tracks->update_y_pixels(mwindow->theme);
1036 update_scrollbars(0);
1051 void MWindowGUI::default_positions()
1053 //printf("MWindowGUI::default_positions 1\n");
1054 VWindow *vwindow = mwindow->vwindows.size() > DEFAULT_VWINDOW ?
1055 mwindow->vwindows.get(0) : 0;
1056 if( vwindow ) vwindow->gui->lock_window("MWindowGUI::default_positions");
1057 mwindow->cwindow->gui->lock_window("MWindowGUI::default_positions");
1058 mwindow->awindow->gui->lock_window("MWindowGUI::default_positions");
1060 // printf("MWindowGUI::default_positions 1 %d %d %d %d\n", mwindow->session->vwindow_x,
1061 // mwindow->session->vwindow_y,
1062 // mwindow->session->vwindow_w,
1063 // mwindow->session->vwindow_h);
1064 reposition_window(mwindow->session->mwindow_x,
1065 mwindow->session->mwindow_y,
1066 mwindow->session->mwindow_w,
1067 mwindow->session->mwindow_h);
1068 if( vwindow ) vwindow->gui->reposition_window(mwindow->session->vwindow_x,
1069 mwindow->session->vwindow_y,
1070 mwindow->session->vwindow_w,
1071 mwindow->session->vwindow_h);
1072 mwindow->cwindow->gui->reposition_window(mwindow->session->cwindow_x,
1073 mwindow->session->cwindow_y,
1074 mwindow->session->cwindow_w,
1075 mwindow->session->cwindow_h);
1076 mwindow->awindow->gui->reposition_window(mwindow->session->awindow_x,
1077 mwindow->session->awindow_y,
1078 mwindow->session->awindow_w,
1079 mwindow->session->awindow_h);
1080 //printf("MWindowGUI::default_positions 1\n");
1082 resize_event(mwindow->session->mwindow_w,
1083 mwindow->session->mwindow_h);
1084 //printf("MWindowGUI::default_positions 1\n");
1085 if( vwindow ) vwindow->gui->resize_event(mwindow->session->vwindow_w,
1086 mwindow->session->vwindow_h);
1087 //printf("MWindowGUI::default_positions 1\n");
1088 mwindow->cwindow->gui->resize_event(mwindow->session->cwindow_w,
1089 mwindow->session->cwindow_h);
1090 //printf("MWindowGUI::default_positions 1\n");
1091 mwindow->awindow->gui->resize_event(mwindow->session->awindow_w,
1092 mwindow->session->awindow_h);
1094 //printf("MWindowGUI::default_positions 1\n");
1097 if( vwindow ) vwindow->gui->flush();
1098 mwindow->cwindow->gui->flush();
1099 mwindow->awindow->gui->flush();
1101 if( vwindow ) vwindow->gui->unlock_window();
1102 mwindow->cwindow->gui->unlock_window();
1103 mwindow->awindow->gui->unlock_window();
1104 //printf("MWindowGUI::default_positions 2\n");
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());
1158 result = mbuttons->keypress_event();
1162 switch(get_keypress())
1164 case '1': case '2': case '3': case '4':
1165 case '5': case '6': case '7': case '8':
1166 if( !alt_down() || shift_down() ) break;
1167 if( !mwindow->select_asset(get_keypress()-'1',1) )
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();
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();
1204 mwindow->expand_y();
1210 mwindow->expand_autos();
1215 mwindow->expand_sample();
1223 mwindow->zoom_in_y();
1229 mwindow->shrink_autos();
1234 mwindow->zoom_in_sample();
1247 mwindow->expand_t();
1255 mwindow->move_down();
1260 mwindow->zoom_in_t();
1267 // //int cursor_x = 0;
1268 // int cursor_y = 0;
1269 // for(int i = 0; i < TOTAL_PANES; i++)
1273 // //cursor_x = pane[i]->canvas->get_relative_cursor_x();
1274 // cursor_y = pane[i]->canvas->get_relative_cursor_y();
1279 // if(get_keypress() == TAB)
1281 // // Switch the record button
1282 // for(Track *track = mwindow->edl->tracks->first; track; track = track->next)
1284 // int64_t track_x, track_y, track_w, track_h;
1285 // canvas->track_dimensions(track, track_x, track_y, track_w, track_h);
1287 // if(cursor_y >= track_y &&
1288 // cursor_y < track_y + track_h)
1290 // if (track->record)
1291 // track->record = 0;
1293 // track->record = 1;
1301 // Track *this_track = 0;
1302 // for(Track *track = mwindow->edl->tracks->first; track; track = track->next)
1304 // int64_t track_x, track_y, track_w, track_h;
1305 // canvas->track_dimensions(track, track_x, track_y, track_w, track_h);
1307 // if(cursor_y >= track_y &&
1308 // cursor_y < track_y + track_h)
1310 // // This is our track
1311 // this_track = track;
1316 // int total_selected = mwindow->edl->tracks->total_of(Tracks::RECORD);
1318 // // nothing previously selected
1319 // if(total_selected == 0)
1321 // mwindow->edl->tracks->select_all(Tracks::RECORD,
1325 // if(total_selected == 1)
1327 // // this patch was previously the only one on
1328 // if(this_track && this_track->record)
1330 // mwindow->edl->tracks->select_all(Tracks::RECORD,
1333 // // another patch was previously the only one on
1336 // mwindow->edl->tracks->select_all(Tracks::RECORD,
1339 // this_track->record = 1;
1344 // if(total_selected > 1)
1346 // mwindow->edl->tracks->select_all(Tracks::RECORD,
1349 // this_track->record = 1;
1362 // mwindow->cwindow->update(0, 1, 1);
1363 // lock_window("TrackCanvas::keypress_event 3");
1369 // since things under cursor have changed...
1371 cursor_motion_event();
1378 int MWindowGUI::keyboard_listener(BC_WindowBase *wp)
1380 return keyboard_listener(wp->get_keypress());
1383 int MWindowGUI::keyboard_listener(int key)
1388 if( !record->running() )
1391 record->record_gui->interrupt_thread->start(0);
1397 channel_info->toggle_scan();
1400 if( !remote_control->deactivate() )
1401 remote_control->activate();
1411 void MWindowGUI::use_android_remote(int on)
1414 delete android_control;
1415 android_control = 0;
1418 if( android_control ) return;
1419 android_control = new AndroidControl(this);
1422 int MWindowGUI::close_event()
1428 void MWindowGUI::stop_drawing()
1430 resource_thread->stop_draw(1);
1433 int MWindowGUI::menu_h()
1435 return mainmenu->get_h();
1438 void MWindowGUI::start_x_pane_drag()
1442 x_pane_drag = new BC_Popup(this,
1443 get_abs_cursor_x(0) - mwindow->theme->pane_w,
1444 get_resources()->get_top_border() +
1446 mwindow->theme->mcanvas_y,
1447 mwindow->theme->pane_w,
1448 mwindow->theme->mcanvas_h,
1449 mwindow->theme->drag_pane_color);
1450 x_pane_drag->draw_3segmentv(0,
1452 x_pane_drag->get_h(),
1453 mwindow->theme->get_image_set("xpane")[BUTTON_DOWNHI]);
1454 x_pane_drag->flash(1);
1459 void MWindowGUI::start_y_pane_drag()
1463 //printf("MWindowGUI::start_y_pane_drag %d %d %d\n", __LINE__, get_x(), get_y());
1464 y_pane_drag = new BC_Popup(this,
1465 get_resources()->get_left_border() +
1467 mwindow->theme->mcanvas_x,
1468 get_abs_cursor_y(0) - mwindow->theme->pane_h,
1469 mwindow->theme->mcanvas_w,
1470 mwindow->theme->pane_h,
1471 mwindow->theme->drag_pane_color);
1472 y_pane_drag->draw_3segmenth(0,
1474 y_pane_drag->get_w(),
1475 mwindow->theme->get_image_set("ypane")[BUTTON_DOWNHI]);
1476 y_pane_drag->flash(1);
1481 void MWindowGUI::handle_pane_drag()
1487 x_pane_drag->reposition_window(
1488 get_abs_cursor_x(0) - mwindow->theme->pane_w,
1489 x_pane_drag->get_y());
1494 y_pane_drag->reposition_window(
1495 y_pane_drag->get_x(),
1496 get_abs_cursor_y(0) - mwindow->theme->pane_h);
1502 void MWindowGUI::create_x_pane(int cursor_x)
1504 if(total_panes() == 1)
1506 // create a horizontal pane
1507 // do this 1st so the resize_event knows there are 2 panes
1508 mwindow->edl->local_session->view_start[TOP_RIGHT_PANE] =
1509 mwindow->edl->local_session->view_start[TOP_LEFT_PANE] +
1511 mwindow->theme->patchbay_w;
1512 pane[TOP_RIGHT_PANE] = new TimelinePane(mwindow,
1514 mwindow->theme->mcanvas_x +
1516 mwindow->theme->mcanvas_y,
1517 mwindow->theme->mcanvas_x +
1518 mwindow->theme->mcanvas_w -
1520 mwindow->theme->mcanvas_h);
1521 pane[TOP_LEFT_PANE]->resize_event(
1522 mwindow->theme->mcanvas_x,
1523 mwindow->theme->mcanvas_y,
1524 cursor_x - mwindow->theme->pane_w,
1525 mwindow->theme->mcanvas_h);
1526 pane[TOP_RIGHT_PANE]->create_objects();
1529 if(vertical_panes())
1531 // create 2 horizontal panes
1532 mwindow->edl->local_session->track_start[TOP_RIGHT_PANE] =
1533 mwindow->edl->local_session->track_start[TOP_LEFT_PANE];
1534 mwindow->edl->local_session->track_start[BOTTOM_RIGHT_PANE] =
1535 mwindow->edl->local_session->track_start[BOTTOM_LEFT_PANE];
1536 mwindow->edl->local_session->view_start[TOP_RIGHT_PANE] =
1537 mwindow->edl->local_session->view_start[BOTTOM_RIGHT_PANE] =
1538 mwindow->edl->local_session->view_start[TOP_LEFT_PANE] +
1540 mwindow->theme->patchbay_w;
1541 pane[TOP_RIGHT_PANE] = new TimelinePane(mwindow,
1543 mwindow->theme->mcanvas_x +
1545 pane[TOP_LEFT_PANE]->y,
1546 mwindow->theme->mcanvas_x +
1547 mwindow->theme->mcanvas_w -
1549 pane[TOP_LEFT_PANE]->h);
1550 pane[BOTTOM_RIGHT_PANE] = new TimelinePane(mwindow,
1552 mwindow->theme->mcanvas_x +
1554 pane[BOTTOM_LEFT_PANE]->y,
1555 mwindow->theme->mcanvas_x +
1556 mwindow->theme->mcanvas_w -
1558 pane[BOTTOM_LEFT_PANE]->h);
1559 pane[TOP_LEFT_PANE]->resize_event(
1560 pane[TOP_LEFT_PANE]->x,
1561 pane[TOP_LEFT_PANE]->y,
1562 cursor_x - mwindow->theme->pane_w,
1563 pane[TOP_LEFT_PANE]->h);
1564 pane[BOTTOM_LEFT_PANE]->resize_event(
1565 pane[BOTTOM_LEFT_PANE]->x,
1566 pane[BOTTOM_LEFT_PANE]->y,
1567 cursor_x - mwindow->theme->pane_w,
1568 pane[BOTTOM_LEFT_PANE]->h);
1569 pane[TOP_RIGHT_PANE]->create_objects();
1570 pane[BOTTOM_RIGHT_PANE]->create_objects();
1573 if(horizontal_panes())
1575 // resize a horizontal pane
1576 mwindow->edl->local_session->view_start[TOP_RIGHT_PANE] +=
1578 pane[TOP_RIGHT_PANE]->x;
1579 if(mwindow->edl->local_session->view_start[TOP_RIGHT_PANE] < 0)
1580 mwindow->edl->local_session->view_start[TOP_RIGHT_PANE] = 0;
1581 pane[TOP_LEFT_PANE]->resize_event(
1582 mwindow->theme->mcanvas_x,
1583 mwindow->theme->mcanvas_y,
1584 cursor_x - mwindow->theme->pane_w,
1585 mwindow->theme->mcanvas_h);
1586 pane[TOP_RIGHT_PANE]->resize_event(
1587 mwindow->theme->mcanvas_x +
1589 pane[TOP_RIGHT_PANE]->y,
1590 mwindow->theme->mcanvas_x +
1591 mwindow->theme->mcanvas_w -
1593 mwindow->theme->mcanvas_h);
1597 // resize 2 horizontal panes
1598 mwindow->edl->local_session->view_start[TOP_RIGHT_PANE] +=
1600 pane[TOP_RIGHT_PANE]->x;
1601 if(mwindow->edl->local_session->view_start[TOP_RIGHT_PANE] < 0)
1602 mwindow->edl->local_session->view_start[TOP_RIGHT_PANE] = 0;
1603 mwindow->edl->local_session->view_start[BOTTOM_RIGHT_PANE] =
1604 mwindow->edl->local_session->view_start[TOP_RIGHT_PANE];
1606 pane[TOP_LEFT_PANE]->resize_event(
1607 mwindow->theme->mcanvas_x,
1608 pane[TOP_LEFT_PANE]->y,
1609 cursor_x - mwindow->theme->pane_w,
1610 pane[TOP_LEFT_PANE]->h);
1611 pane[TOP_RIGHT_PANE]->resize_event(
1612 mwindow->theme->mcanvas_x +
1614 pane[TOP_RIGHT_PANE]->y,
1615 mwindow->theme->mcanvas_x +
1616 mwindow->theme->mcanvas_w -
1618 pane[TOP_RIGHT_PANE]->h);
1619 pane[BOTTOM_LEFT_PANE]->resize_event(
1620 mwindow->theme->mcanvas_x,
1621 pane[BOTTOM_LEFT_PANE]->y,
1622 cursor_x - mwindow->theme->pane_w,
1623 pane[BOTTOM_LEFT_PANE]->h);
1624 pane[BOTTOM_RIGHT_PANE]->resize_event(
1625 mwindow->theme->mcanvas_x +
1627 pane[BOTTOM_RIGHT_PANE]->y,
1628 mwindow->theme->mcanvas_x +
1629 mwindow->theme->mcanvas_w -
1631 pane[BOTTOM_RIGHT_PANE]->h);
1637 void MWindowGUI::delete_x_pane(int cursor_x)
1639 // give left panes coordinates of right pane
1640 if(cursor_x < mwindow->theme->patchbay_w + PANE_DRAG_MARGIN &&
1641 pane[TOP_RIGHT_PANE])
1643 mwindow->edl->local_session->view_start[TOP_LEFT_PANE] =
1644 mwindow->edl->local_session->view_start[TOP_RIGHT_PANE] -
1645 pane[TOP_RIGHT_PANE]->x + mwindow->theme->patchbay_w;
1646 if(mwindow->edl->local_session->view_start[TOP_LEFT_PANE] < 0)
1647 mwindow->edl->local_session->view_start[TOP_LEFT_PANE] = 0;
1648 mwindow->edl->local_session->view_start[BOTTOM_LEFT_PANE] =
1649 mwindow->edl->local_session->view_start[TOP_LEFT_PANE];
1652 switch(total_panes())
1655 if(pane[TOP_LEFT_PANE] && pane[TOP_RIGHT_PANE])
1657 // delete right pane
1658 delete pane[TOP_RIGHT_PANE];
1659 pane[TOP_RIGHT_PANE] = 0;
1660 pane[TOP_LEFT_PANE]->resize_event(
1661 mwindow->theme->mcanvas_x,
1662 mwindow->theme->mcanvas_y,
1663 mwindow->theme->mcanvas_w,
1664 mwindow->theme->mcanvas_h);
1670 // delete right panes
1671 delete pane[TOP_RIGHT_PANE];
1672 pane[TOP_RIGHT_PANE] = 0;
1673 delete pane[BOTTOM_RIGHT_PANE];
1674 pane[BOTTOM_RIGHT_PANE] = 0;
1675 pane[TOP_LEFT_PANE]->resize_event(
1676 mwindow->theme->mcanvas_x,
1677 pane[TOP_LEFT_PANE]->y,
1678 mwindow->theme->mcanvas_w,
1679 pane[TOP_LEFT_PANE]->h);
1680 pane[BOTTOM_LEFT_PANE]->resize_event(
1681 mwindow->theme->mcanvas_x,
1682 pane[BOTTOM_LEFT_PANE]->y,
1683 mwindow->theme->mcanvas_w,
1684 pane[BOTTOM_LEFT_PANE]->h);
1689 void MWindowGUI::create_y_pane(int cursor_y)
1691 if(total_panes() == 1)
1693 mwindow->edl->local_session->view_start[BOTTOM_LEFT_PANE] =
1694 mwindow->edl->local_session->view_start[TOP_LEFT_PANE];
1695 mwindow->edl->local_session->track_start[BOTTOM_LEFT_PANE] =
1696 mwindow->edl->local_session->track_start[TOP_LEFT_PANE] +
1698 mwindow->theme->mtimebar_h;
1699 // do this 1st so the resize_event knows there are 2 panes
1700 pane[BOTTOM_LEFT_PANE] = new TimelinePane(mwindow,
1702 mwindow->theme->mcanvas_x,
1703 mwindow->theme->mcanvas_y +
1705 mwindow->theme->mcanvas_w,
1706 mwindow->theme->mcanvas_h -
1708 pane[TOP_LEFT_PANE]->resize_event(
1709 mwindow->theme->mcanvas_x,
1710 mwindow->theme->mcanvas_y,
1711 mwindow->theme->mcanvas_w,
1712 pane[BOTTOM_LEFT_PANE]->y -
1713 mwindow->theme->mcanvas_y -
1714 mwindow->theme->pane_h);
1715 pane[BOTTOM_LEFT_PANE]->create_objects();
1718 if(horizontal_panes())
1721 mwindow->edl->local_session->view_start[BOTTOM_LEFT_PANE] =
1722 mwindow->edl->local_session->view_start[TOP_LEFT_PANE];
1723 mwindow->edl->local_session->view_start[BOTTOM_RIGHT_PANE] =
1724 mwindow->edl->local_session->view_start[TOP_RIGHT_PANE];
1725 mwindow->edl->local_session->track_start[BOTTOM_LEFT_PANE] =
1726 mwindow->edl->local_session->track_start[BOTTOM_RIGHT_PANE] =
1727 mwindow->edl->local_session->track_start[TOP_LEFT_PANE] +
1729 mwindow->theme->mtimebar_h;
1731 pane[BOTTOM_LEFT_PANE] = new TimelinePane(mwindow,
1733 pane[TOP_LEFT_PANE]->x,
1734 mwindow->theme->mcanvas_y +
1736 pane[TOP_LEFT_PANE]->w,
1737 mwindow->theme->mcanvas_h -
1739 pane[BOTTOM_RIGHT_PANE] = new TimelinePane(mwindow,
1741 pane[TOP_RIGHT_PANE]->x,
1742 mwindow->theme->mcanvas_y +
1744 pane[TOP_RIGHT_PANE]->w,
1745 mwindow->theme->mcanvas_h -
1748 pane[TOP_LEFT_PANE]->resize_event(
1749 pane[TOP_LEFT_PANE]->x,
1750 pane[TOP_LEFT_PANE]->y,
1751 pane[TOP_LEFT_PANE]->w,
1752 pane[BOTTOM_LEFT_PANE]->y -
1753 mwindow->theme->mcanvas_y -
1754 mwindow->theme->pane_h);
1755 pane[TOP_RIGHT_PANE]->resize_event(
1756 pane[TOP_RIGHT_PANE]->x,
1757 pane[TOP_RIGHT_PANE]->y,
1758 pane[TOP_RIGHT_PANE]->w,
1759 pane[BOTTOM_RIGHT_PANE]->y -
1760 mwindow->theme->mcanvas_y -
1761 mwindow->theme->pane_h);
1763 pane[BOTTOM_LEFT_PANE]->create_objects();
1764 pane[BOTTOM_RIGHT_PANE]->create_objects();
1767 if(vertical_panes())
1770 mwindow->edl->local_session->track_start[BOTTOM_LEFT_PANE] +=
1772 (pane[BOTTOM_LEFT_PANE]->y - mwindow->theme->mcanvas_y);
1773 if(mwindow->edl->local_session->track_start[BOTTOM_LEFT_PANE] < 0)
1774 mwindow->edl->local_session->track_start[BOTTOM_LEFT_PANE] = 0;
1775 pane[TOP_LEFT_PANE]->resize_event(
1776 mwindow->theme->mcanvas_x,
1777 mwindow->theme->mcanvas_y,
1778 mwindow->theme->mcanvas_w,
1779 cursor_y - mwindow->theme->pane_h);
1780 pane[BOTTOM_LEFT_PANE]->resize_event(
1781 pane[BOTTOM_LEFT_PANE]->x,
1783 mwindow->theme->mcanvas_y,
1784 mwindow->theme->mcanvas_w,
1785 mwindow->theme->mcanvas_h -
1791 mwindow->edl->local_session->track_start[BOTTOM_LEFT_PANE] +=
1793 (pane[BOTTOM_LEFT_PANE]->y - mwindow->theme->mcanvas_y);
1794 if(mwindow->edl->local_session->track_start[BOTTOM_LEFT_PANE] < 0)
1795 mwindow->edl->local_session->track_start[BOTTOM_LEFT_PANE] = 0;
1796 mwindow->edl->local_session->track_start[BOTTOM_RIGHT_PANE] =
1797 mwindow->edl->local_session->track_start[BOTTOM_LEFT_PANE];
1798 pane[TOP_LEFT_PANE]->resize_event(
1799 pane[TOP_LEFT_PANE]->x,
1800 pane[TOP_LEFT_PANE]->y,
1801 pane[TOP_LEFT_PANE]->w,
1802 cursor_y - mwindow->theme->pane_h);
1803 pane[BOTTOM_LEFT_PANE]->resize_event(
1804 pane[BOTTOM_LEFT_PANE]->x,
1806 mwindow->theme->mcanvas_y,
1807 pane[BOTTOM_LEFT_PANE]->w,
1808 mwindow->theme->mcanvas_h -
1810 pane[TOP_RIGHT_PANE]->resize_event(
1811 pane[TOP_RIGHT_PANE]->x,
1812 pane[TOP_RIGHT_PANE]->y,
1813 pane[TOP_RIGHT_PANE]->w,
1814 cursor_y - mwindow->theme->pane_h);
1815 pane[BOTTOM_RIGHT_PANE]->resize_event(
1816 pane[BOTTOM_RIGHT_PANE]->x,
1818 mwindow->theme->mcanvas_y,
1819 pane[BOTTOM_RIGHT_PANE]->w,
1820 mwindow->theme->mcanvas_h -
1825 void MWindowGUI::delete_y_pane(int cursor_y)
1827 if(cursor_y < mwindow->theme->mtimebar_h +
1829 pane[BOTTOM_LEFT_PANE])
1831 // give top pane coordinates of bottom pane
1832 mwindow->edl->local_session->track_start[TOP_LEFT_PANE] =
1833 mwindow->edl->local_session->track_start[BOTTOM_LEFT_PANE] -
1834 pane[BOTTOM_LEFT_PANE]->y;
1835 if(mwindow->edl->local_session->track_start[TOP_LEFT_PANE] < 0)
1836 mwindow->edl->local_session->track_start[TOP_LEFT_PANE] = 0;
1837 mwindow->edl->local_session->track_start[TOP_RIGHT_PANE] =
1838 mwindow->edl->local_session->track_start[TOP_LEFT_PANE];
1842 switch(total_panes())
1845 delete pane[BOTTOM_LEFT_PANE];
1846 pane[BOTTOM_LEFT_PANE] = 0;
1847 pane[TOP_LEFT_PANE]->resize_event(
1848 mwindow->theme->mcanvas_x,
1849 mwindow->theme->mcanvas_y,
1850 mwindow->theme->mcanvas_w,
1851 mwindow->theme->mcanvas_h);
1855 // delete bottom 2 panes
1857 delete pane[BOTTOM_LEFT_PANE];
1858 pane[BOTTOM_LEFT_PANE] = 0;
1859 delete pane[BOTTOM_RIGHT_PANE];
1860 pane[BOTTOM_RIGHT_PANE] = 0;
1861 pane[TOP_LEFT_PANE]->resize_event(
1862 pane[TOP_LEFT_PANE]->x,
1863 mwindow->theme->mcanvas_y,
1864 pane[TOP_LEFT_PANE]->w,
1865 mwindow->theme->mcanvas_h);
1866 pane[TOP_RIGHT_PANE]->resize_event(
1867 pane[TOP_RIGHT_PANE]->x,
1868 mwindow->theme->mcanvas_y,
1869 pane[TOP_RIGHT_PANE]->w,
1870 mwindow->theme->mcanvas_h);
1875 void MWindowGUI::stop_pane_drag()
1878 resource_thread->stop_draw(1);
1882 // cursor position relative to canvas
1883 int cursor_x = x_pane_drag->get_x() -
1885 get_resources()->get_left_border() -
1886 mwindow->theme->mcanvas_x +
1887 mwindow->theme->pane_w;
1892 if(cursor_x >= mwindow->theme->patchbay_w + PANE_DRAG_MARGIN &&
1893 cursor_x < mwindow->theme->mcanvas_w -
1894 BC_ScrollBar::get_span(SCROLL_VERT) -
1897 create_x_pane(cursor_x);
1898 mwindow->edl->local_session->x_pane = cursor_x;
1903 delete_x_pane(cursor_x);
1904 mwindow->edl->local_session->x_pane = -1;
1912 // cursor position relative to canvas
1913 int cursor_y = y_pane_drag->get_y() -
1915 get_resources()->get_top_border() -
1916 mwindow->theme->mcanvas_y +
1917 mwindow->theme->pane_h;
1923 if(cursor_y >= mwindow->theme->mtimebar_h +
1925 cursor_y < mwindow->theme->mcanvas_h -
1926 BC_ScrollBar::get_span(SCROLL_HORIZ) -
1929 create_y_pane(cursor_y);
1930 mwindow->edl->local_session->y_pane = cursor_y;
1934 delete_y_pane(cursor_y);
1935 mwindow->edl->local_session->y_pane = -1;
1939 update_pane_dividers();
1941 // required to get new widgets to appear
1943 resource_thread->start_draw();
1946 // create panes from EDL
1947 void MWindowGUI::load_panes()
1949 int need_x_panes = 0;
1950 int need_y_panes = 0;
1951 // use names from create functions
1952 int cursor_x = mwindow->edl->local_session->x_pane;
1953 int cursor_y = mwindow->edl->local_session->y_pane;
1955 resource_thread->stop_draw(1);
1957 mwindow->theme->patchbay_w + PANE_DRAG_MARGIN &&
1959 mwindow->theme->mcanvas_w -
1960 BC_ScrollBar::get_span(SCROLL_VERT) -
1967 mwindow->theme->mtimebar_h + PANE_DRAG_MARGIN &&
1969 mwindow->theme->mcanvas_h -
1970 BC_ScrollBar::get_span(SCROLL_HORIZ) -
1976 //printf("MWindowGUI::load_panes %d %d %d\n", __LINE__, need_x_panes, need_y_panes);
1984 if(total_panes() == 1)
1987 //printf("MWindowGUI::load_panes %d\n", __LINE__);
1988 pane[TOP_RIGHT_PANE] = new TimelinePane(mwindow,
1990 mwindow->theme->mcanvas_x +
1992 mwindow->theme->mcanvas_y,
1993 mwindow->theme->mcanvas_x +
1994 mwindow->theme->mcanvas_w -
1996 cursor_y - mwindow->theme->pane_h);
1997 pane[BOTTOM_LEFT_PANE] = new TimelinePane(mwindow,
1999 mwindow->theme->mcanvas_x,
2000 mwindow->theme->mcanvas_y +
2002 cursor_x - mwindow->theme->pane_w,
2003 mwindow->theme->mcanvas_h -
2005 pane[BOTTOM_RIGHT_PANE] = new TimelinePane(mwindow,
2007 pane[TOP_RIGHT_PANE]->x,
2008 mwindow->theme->mcanvas_y +
2010 pane[TOP_RIGHT_PANE]->w,
2011 mwindow->theme->mcanvas_h -
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]->create_objects();
2019 pane[BOTTOM_LEFT_PANE]->create_objects();
2020 pane[BOTTOM_RIGHT_PANE]->create_objects();
2023 if(horizontal_panes())
2025 // create vertical panes
2026 //printf("MWindowGUI::load_panes %d\n", __LINE__);
2027 pane[BOTTOM_LEFT_PANE] = new TimelinePane(mwindow,
2029 mwindow->theme->mcanvas_x,
2030 mwindow->theme->mcanvas_y +
2032 cursor_x - mwindow->theme->pane_w,
2033 mwindow->theme->mcanvas_h -
2035 pane[BOTTOM_RIGHT_PANE] = new TimelinePane(mwindow,
2037 pane[TOP_RIGHT_PANE]->x,
2038 mwindow->theme->mcanvas_y +
2040 pane[TOP_RIGHT_PANE]->w,
2041 mwindow->theme->mcanvas_h -
2043 pane[TOP_LEFT_PANE]->resize_event(
2044 pane[TOP_LEFT_PANE]->x,
2045 pane[TOP_LEFT_PANE]->y,
2046 cursor_x - mwindow->theme->pane_w,
2047 cursor_y - mwindow->theme->pane_h);
2048 pane[TOP_RIGHT_PANE]->resize_event(
2049 mwindow->theme->mcanvas_x +
2051 mwindow->theme->mcanvas_y,
2052 mwindow->theme->mcanvas_x +
2053 mwindow->theme->mcanvas_w -
2055 cursor_y - mwindow->theme->pane_h);
2056 pane[BOTTOM_LEFT_PANE]->create_objects();
2057 pane[BOTTOM_RIGHT_PANE]->create_objects();
2060 if(vertical_panes())
2062 // create horizontal panes
2063 //printf("MWindowGUI::load_panes %d\n", __LINE__);
2064 pane[TOP_RIGHT_PANE] = new TimelinePane(mwindow,
2066 mwindow->theme->mcanvas_x +
2068 mwindow->theme->mcanvas_y,
2069 mwindow->theme->mcanvas_x +
2070 mwindow->theme->mcanvas_w -
2072 cursor_y - mwindow->theme->pane_h);
2073 pane[BOTTOM_RIGHT_PANE] = new TimelinePane(mwindow,
2075 pane[TOP_RIGHT_PANE]->x,
2076 mwindow->theme->mcanvas_y +
2078 pane[TOP_RIGHT_PANE]->w,
2079 mwindow->theme->mcanvas_h -
2081 pane[TOP_LEFT_PANE]->resize_event(
2082 pane[TOP_LEFT_PANE]->x,
2083 pane[TOP_LEFT_PANE]->y,
2084 cursor_x - mwindow->theme->pane_w,
2085 cursor_y - mwindow->theme->pane_h);
2086 pane[BOTTOM_LEFT_PANE]->resize_event(
2087 pane[TOP_LEFT_PANE]->x,
2088 mwindow->theme->mcanvas_y +
2090 mwindow->theme->mcanvas_x +
2091 mwindow->theme->mcanvas_w -
2093 mwindow->theme->mcanvas_h -
2095 pane[TOP_RIGHT_PANE]->create_objects();
2096 pane[BOTTOM_RIGHT_PANE]->create_objects();
2103 //printf("MWindowGUI::load_panes %d\n", __LINE__);
2104 pane[TOP_LEFT_PANE]->resize_event(
2105 pane[TOP_LEFT_PANE]->x,
2106 pane[TOP_LEFT_PANE]->y,
2107 cursor_x - mwindow->theme->pane_w,
2108 cursor_y - mwindow->theme->pane_h);
2109 pane[TOP_RIGHT_PANE]->resize_event(
2110 mwindow->theme->mcanvas_x +
2112 mwindow->theme->mcanvas_y,
2113 mwindow->theme->mcanvas_x +
2114 mwindow->theme->mcanvas_w -
2116 cursor_y - mwindow->theme->pane_h);
2117 pane[BOTTOM_LEFT_PANE]->resize_event(
2118 pane[TOP_LEFT_PANE]->x,
2119 mwindow->theme->mcanvas_y +
2121 mwindow->theme->mcanvas_x +
2122 mwindow->theme->mcanvas_w -
2124 mwindow->theme->mcanvas_h -
2126 pane[BOTTOM_RIGHT_PANE]->resize_event(
2127 pane[TOP_RIGHT_PANE]->x,
2128 mwindow->theme->mcanvas_y +
2130 pane[TOP_RIGHT_PANE]->w,
2131 mwindow->theme->mcanvas_h -
2140 if(pane[BOTTOM_LEFT_PANE]) delete pane[BOTTOM_LEFT_PANE];
2141 if(pane[BOTTOM_RIGHT_PANE]) delete pane[BOTTOM_RIGHT_PANE];
2142 pane[BOTTOM_LEFT_PANE] = 0;
2143 pane[BOTTOM_RIGHT_PANE] = 0;
2145 if(!pane[TOP_RIGHT_PANE])
2147 pane[TOP_RIGHT_PANE] = new TimelinePane(mwindow,
2149 mwindow->theme->mcanvas_x +
2151 mwindow->theme->mcanvas_y,
2152 mwindow->theme->mcanvas_x +
2153 mwindow->theme->mcanvas_w -
2155 mwindow->theme->mcanvas_h);
2156 pane[TOP_LEFT_PANE]->resize_event(
2157 mwindow->theme->mcanvas_x,
2158 mwindow->theme->mcanvas_y,
2159 cursor_x - mwindow->theme->pane_w,
2160 mwindow->theme->mcanvas_h);
2161 pane[TOP_RIGHT_PANE]->create_objects();
2165 pane[TOP_LEFT_PANE]->resize_event(
2166 mwindow->theme->mcanvas_x,
2167 mwindow->theme->mcanvas_y,
2168 cursor_x - mwindow->theme->pane_w,
2169 mwindow->theme->mcanvas_h);
2170 pane[TOP_RIGHT_PANE]->resize_event(
2171 mwindow->theme->mcanvas_x +
2173 pane[TOP_RIGHT_PANE]->y,
2174 mwindow->theme->mcanvas_x +
2175 mwindow->theme->mcanvas_w -
2177 mwindow->theme->mcanvas_h);
2185 if(pane[TOP_RIGHT_PANE]) delete pane[TOP_RIGHT_PANE];
2186 if(pane[BOTTOM_RIGHT_PANE]) delete pane[BOTTOM_RIGHT_PANE];
2187 pane[TOP_RIGHT_PANE] = 0;
2188 pane[BOTTOM_RIGHT_PANE] = 0;
2190 if(!pane[BOTTOM_LEFT_PANE])
2192 //printf("MWindowGUI::load_panes %d\n", __LINE__);
2193 pane[BOTTOM_LEFT_PANE] = new TimelinePane(mwindow,
2195 mwindow->theme->mcanvas_x,
2196 mwindow->theme->mcanvas_y +
2198 mwindow->theme->mcanvas_w,
2199 mwindow->theme->mcanvas_h -
2201 pane[TOP_LEFT_PANE]->resize_event(
2202 mwindow->theme->mcanvas_x,
2203 mwindow->theme->mcanvas_y,
2204 mwindow->theme->mcanvas_w,
2205 pane[BOTTOM_LEFT_PANE]->y -
2206 mwindow->theme->mcanvas_y -
2207 mwindow->theme->pane_h);
2208 pane[BOTTOM_LEFT_PANE]->create_objects();
2212 pane[TOP_LEFT_PANE]->resize_event(
2213 mwindow->theme->mcanvas_x,
2214 mwindow->theme->mcanvas_y,
2215 mwindow->theme->mcanvas_w,
2216 cursor_y - mwindow->theme->pane_h);
2217 pane[BOTTOM_LEFT_PANE]->resize_event(
2218 pane[BOTTOM_LEFT_PANE]->x,
2220 mwindow->theme->mcanvas_y,
2221 mwindow->theme->mcanvas_w,
2222 mwindow->theme->mcanvas_h -
2229 if(pane[TOP_RIGHT_PANE]) delete pane[TOP_RIGHT_PANE];
2230 if(pane[BOTTOM_RIGHT_PANE]) delete pane[BOTTOM_RIGHT_PANE];
2231 if(pane[BOTTOM_LEFT_PANE]) delete pane[BOTTOM_LEFT_PANE];
2232 pane[TOP_RIGHT_PANE] = 0;
2233 pane[BOTTOM_RIGHT_PANE] = 0;
2234 pane[BOTTOM_LEFT_PANE] = 0;
2235 pane[TOP_LEFT_PANE]->resize_event(
2236 mwindow->theme->mcanvas_x,
2237 mwindow->theme->mcanvas_y,
2238 mwindow->theme->mcanvas_w,
2239 mwindow->theme->mcanvas_h);
2242 update_pane_dividers();
2245 resource_thread->start_draw();
2248 void MWindowGUI::update_pane_dividers()
2251 if(horizontal_panes() || total_panes() == 4)
2253 int x = pane[TOP_RIGHT_PANE]->x - mwindow->theme->pane_w;
2254 int y = mwindow->theme->mcanvas_y;
2255 int h = mwindow->theme->mcanvas_h;
2259 add_subwindow(x_divider = new PaneDivider(
2260 mwindow, x, y, h, 1));
2261 x_divider->create_objects();
2265 x_divider->reposition_window(x, y, h);
2278 if(vertical_panes() || total_panes() == 4)
2280 int x = mwindow->theme->mcanvas_x;
2281 int y = pane[BOTTOM_LEFT_PANE]->y -
2282 mwindow->theme->pane_h;
2283 int w = mwindow->theme->mcanvas_w;
2286 add_subwindow(y_divider = new PaneDivider(
2287 mwindow, x, y, w, 0));
2288 y_divider->create_objects();
2292 y_divider->reposition_window(x, y, w);
2306 void MWindowGUI::draw_samplemovement()
2313 update_scrollbars(1);
2316 void MWindowGUI::draw_trackmovement()
2318 update_scrollbars(0);
2326 PaneButton::PaneButton(MWindow *mwindow, int x, int y)
2327 : BC_Button(x, y, mwindow->theme->get_image_set("pane"))
2329 this->mwindow = mwindow;
2332 int PaneButton::cursor_motion_event()
2334 if(get_top_level()->get_button_down() &&
2336 get_status() == BUTTON_DOWNHI &&
2339 // printf("PaneButton::cursor_motion_event %d\n", __LINE__);
2341 if(get_cursor_x() < 0 && !mwindow->gui->dragging_pane)
2343 mwindow->gui->start_x_pane_drag();
2346 if(get_cursor_y() < 0 && !mwindow->gui->dragging_pane)
2348 mwindow->gui->start_y_pane_drag();
2352 mwindow->gui->handle_pane_drag();
2354 int result = BC_Button::cursor_motion_event();
2358 int PaneButton::button_release_event()
2360 mwindow->gui->stop_pane_drag();
2363 int result = BC_Button::button_release_event();