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"
28 #include "cwindowgui.h"
30 #include "channelinfo.h"
33 #include "editpopup.h"
36 #include "edlsession.h"
37 #include "filesystem.h"
38 #include "keyframepopup.h"
41 #include "localsession.h"
42 #include "mainclock.h"
43 #include "maincursor.h"
45 #include "mainsession.h"
49 #include "mwindowgui.h"
51 #include "panedividers.h"
54 #include "pluginpopup.h"
55 #include "pluginset.h"
57 #include "recordgui.h"
58 #include "renderengine.h"
59 #include "resourcethread.h"
60 #include "samplescroll.h"
62 #include "statusbar.h"
64 #include "trackcanvas.h"
65 #include "trackscroll.h"
67 #include "transitionpopup.h"
68 #include "vwindowgui.h"
72 #define PANE_DRAG_MARGIN 50
75 // the main window uses its own private colormap for video
76 MWindowGUI::MWindowGUI(MWindow *mwindow)
77 : BC_Window(_(PROGRAM_NAME ": Program"),
78 mwindow->session->mwindow_x,
79 mwindow->session->mwindow_y,
80 mwindow->session->mwindow_w,
81 mwindow->session->mwindow_h,
88 this->mwindow = mwindow;
95 focused_pane = TOP_LEFT_PANE;
104 for(int i = 0; i < TOTAL_PANES; i++)
121 cwindow_remote_handler = 0;
122 record_remote_handler = 0;
127 MWindowGUI::~MWindowGUI()
129 delete android_control;
130 delete cwindow_remote_handler;
131 delete record_remote_handler;
132 delete remote_control;
133 // delete samplescroll;
134 // delete trackscroll;
135 for(int i = 0; i < TOTAL_PANES; i++)
136 if(pane[i]) delete pane[i];
138 delete render_engine;
139 delete resource_thread;
140 resource_pixmaps.remove_all_objects();
149 void MWindowGUI::get_scrollbars(int flush)
151 //int64_t h_needed = mwindow->edl->get_tracks_height(mwindow->theme);
152 //int64_t w_needed = mwindow->edl->get_tracks_width();
153 int need_xscroll = 0;
154 int need_yscroll = 0;
155 view_w = mwindow->theme->mcanvas_w;
156 view_h = mwindow->theme->mcanvas_h;
158 // Scrollbars are constitutive
159 need_xscroll = need_yscroll = 1;
160 view_h = mwindow->theme->mcanvas_h;
161 view_w = mwindow->theme->mcanvas_w;
163 // for(int i = 0; i < 2; i++)
165 // if(w_needed > view_w)
168 // view_h = mwindow->theme->mcanvas_h - SCROLL_SPAN;
173 // if(h_needed > view_h)
176 // view_w = mwindow->theme->mcanvas_w - SCROLL_SPAN;
181 //printf("MWindowGUI::get_scrollbars 1\n");
183 if(canvas && (view_w != canvas->get_w() || view_h != canvas->get_h()))
185 canvas->reposition_window(mwindow->theme->mcanvas_x,
186 mwindow->theme->mcanvas_y,
194 add_subwindow(samplescroll = new SampleScroll(mwindow,
196 mwindow->theme->mhscroll_x,
197 mwindow->theme->mhscroll_y,
198 mwindow->theme->mhscroll_w));
200 samplescroll->resize_event();
202 samplescroll->set_position(0);
206 if(samplescroll) delete samplescroll;
208 mwindow->edl->local_session->view_start = 0;
214 //printf("MWindowGUI::get_scrollbars 1.1 %p %p\n", this, canvas);
216 add_subwindow(trackscroll = new TrackScroll(mwindow,
218 mwindow->theme->mvscroll_x,
219 mwindow->theme->mvscroll_y,
220 mwindow->theme->mvscroll_h));
222 trackscroll->resize_event();
225 //printf("MWindowGUI::get_scrollbars 1.2\n");
226 trackscroll->update_length(mwindow->edl->get_tracks_height(mwindow->theme),
227 mwindow->edl->local_session->track_start,
230 //printf("MWindowGUI::get_scrollbars 1.3\n");
234 if(trackscroll) delete trackscroll;
236 mwindow->edl->local_session->track_start = 0;
239 if(flush) this->flush();
244 void MWindowGUI::create_objects()
248 resource_thread = new ResourceThread(mwindow, this);
249 resource_thread->create_objects();
252 if(debug) printf("MWindowGUI::create_objects %d\n", __LINE__);
253 set_icon(mwindow->theme->get_image("mwindow_icon"));
254 remote_control = new RemoteControl(this);
255 cwindow_remote_handler = new CWindowRemoteHandler(remote_control);
256 record_remote_handler = new RecordRemoteHandler(remote_control);
257 mwindow->reset_android_remote();
259 if(debug) printf("MWindowGUI::create_objects %d\n", __LINE__);
261 add_subwindow(mainmenu = new MainMenu(mwindow, this));
262 mwindow->theme->get_mwindow_sizes(this, get_w(), get_h());
263 mwindow->theme->draw_mwindow_bg(this);
264 mainmenu->create_objects();
265 if(debug) printf("MWindowGUI::create_objects %d\n", __LINE__);
267 add_subwindow(mbuttons = new MButtons(mwindow, this));
268 mbuttons->create_objects();
270 pane[TOP_LEFT_PANE] = new TimelinePane(mwindow,
272 mwindow->theme->mcanvas_x,
273 mwindow->theme->mcanvas_y,
274 mwindow->theme->mcanvas_w,
275 mwindow->theme->mcanvas_h);
276 pane[TOP_LEFT_PANE]->create_objects();
278 // add_subwindow(timebar = new MTimeBar(mwindow,
280 // mwindow->theme->mtimebar_x,
281 // mwindow->theme->mtimebar_y,
282 // mwindow->theme->mtimebar_w,
283 // mwindow->theme->mtimebar_h));
284 // timebar->create_objects();
286 // if(debug) printf("MWindowGUI::create_objects %d\n", __LINE__);
287 // add_subwindow(patchbay = new PatchBay(mwindow, this));
288 // patchbay->create_objects();
290 // if(debug) printf("MWindowGUI::create_objects %d\n", __LINE__);
291 // get_scrollbars(0);
293 // if(debug) printf("MWindowGUI::create_objects %d\n", __LINE__);
294 // mwindow->gui->add_subwindow(canvas = new TrackCanvas(mwindow, this));
295 // canvas->create_objects();
298 if(debug) printf("MWindowGUI::create_objects %d\n", __LINE__);
299 add_subwindow(zoombar = new ZoomBar(mwindow, this));
300 zoombar->create_objects();
303 if(debug) printf("MWindowGUI::create_objects %d\n", __LINE__);
304 add_subwindow(statusbar = new StatusBar(mwindow, this));
305 statusbar->create_objects();
309 if(debug) printf("MWindowGUI::create_objects %d\n", __LINE__);
310 add_subwindow(mainclock = new MainClock(mwindow,
311 mwindow->theme->mclock_x,
312 mwindow->theme->mclock_y,
313 mwindow->theme->mclock_w));
314 if(debug) printf("MWindowGUI::create_objects %d\n", __LINE__);
315 mainclock->update(0);
319 // if(debug) printf("MWindowGUI::create_objects %d\n", __LINE__);
320 // cursor = new MainCursor(mwindow, this);
321 // cursor->create_objects();
324 if(debug) printf("MWindowGUI::create_objects %d\n", __LINE__);
325 add_subwindow(edit_menu = new EditPopup(mwindow, this));
326 edit_menu->create_objects();
329 if(debug) printf("MWindowGUI::create_objects %d\n", __LINE__);
330 add_subwindow(plugin_menu = new PluginPopup(mwindow, this));
331 plugin_menu->create_objects();
334 if(debug) printf("MWindowGUI::create_objects %d\n", __LINE__);
335 add_subwindow(keyframe_menu = new KeyframePopup(mwindow, this));
336 keyframe_menu->create_objects();
339 if(debug) printf("MWindowGUI::create_objects %d\n", __LINE__);
340 add_subwindow(transition_menu = new TransitionPopup(mwindow, this));
341 transition_menu->create_objects();
343 channel_info = new ChannelInfo(mwindow);
344 db_window = new DbWindow(mwindow);
345 swindow = new SWindow(mwindow);
347 if(debug) printf("MWindowGUI::create_objects %d\n", __LINE__);
349 add_subwindow(pane_button = new PaneButton(mwindow,
350 get_w() - mwindow->theme->get_image_set("pane")[0]->get_w(),
351 mwindow->theme->mzoom_y + 1 - mwindow->theme->get_image_set("pane")[0]->get_h()));
353 pane[TOP_LEFT_PANE]->canvas->activate();
355 if(debug) printf("MWindowGUI::create_objects %d\n", __LINE__);
358 void MWindowGUI::redraw_time_dependancies()
360 zoombar->redraw_time_dependancies();
361 for(int i = 0; i < TOTAL_PANES; i++)
362 if(pane[i] && pane[i]->timebar) pane[i]->timebar->update(0);
363 mainclock->update(mwindow->edl->local_session->get_selectionstart(1));
366 int MWindowGUI::focus_in_event()
368 for(int i = 0; i < TOTAL_PANES; i++)
369 if(pane[i]) pane[i]->cursor->focus_in_event();
373 int MWindowGUI::focus_out_event()
375 for(int i = 0; i < TOTAL_PANES; i++)
376 if(pane[i]) pane[i]->cursor->focus_out_event();
381 int MWindowGUI::resize_event(int w, int h)
383 //printf("MWindowGUI::resize_event %d\n", __LINE__);
384 mwindow->session->mwindow_w = w;
385 mwindow->session->mwindow_h = h;
386 mwindow->theme->get_mwindow_sizes(this, w, h);
387 mwindow->theme->draw_mwindow_bg(this);
388 // mainmenu->reposition_window(0, 0, w, mainmenu->get_h());
389 mbuttons->resize_event();
390 statusbar->resize_event();
392 resource_thread->stop_draw(1);
395 if(total_panes() == 1)
397 pane[TOP_LEFT_PANE]->resize_event(
398 mwindow->theme->mcanvas_x,
399 mwindow->theme->mcanvas_y,
400 mwindow->theme->mcanvas_w,
401 mwindow->theme->mcanvas_h);
404 if(horizontal_panes())
406 pane[TOP_LEFT_PANE]->resize_event(
407 pane[TOP_LEFT_PANE]->x,
408 pane[TOP_LEFT_PANE]->y,
409 pane[TOP_LEFT_PANE]->w,
410 mwindow->theme->mcanvas_h);
411 pane[TOP_RIGHT_PANE]->resize_event(
412 pane[TOP_RIGHT_PANE]->x,
413 pane[TOP_RIGHT_PANE]->y,
414 mwindow->theme->mcanvas_w - pane[TOP_RIGHT_PANE]->x,
415 mwindow->theme->mcanvas_h);
420 pane[TOP_LEFT_PANE]->resize_event(
421 pane[TOP_LEFT_PANE]->x,
422 pane[TOP_LEFT_PANE]->y,
423 mwindow->theme->mcanvas_w,
424 pane[TOP_LEFT_PANE]->h);
425 pane[BOTTOM_LEFT_PANE]->resize_event(
426 pane[BOTTOM_LEFT_PANE]->x,
427 pane[BOTTOM_LEFT_PANE]->y,
428 mwindow->theme->mcanvas_w,
429 mwindow->theme->mcanvas_y +
430 mwindow->theme->mcanvas_h -
431 pane[BOTTOM_LEFT_PANE]->y);
435 pane[TOP_LEFT_PANE]->resize_event(
436 pane[TOP_LEFT_PANE]->x,
437 pane[TOP_LEFT_PANE]->y,
438 pane[TOP_LEFT_PANE]->w,
439 pane[TOP_LEFT_PANE]->h);
440 pane[TOP_RIGHT_PANE]->resize_event(
441 pane[TOP_RIGHT_PANE]->x,
442 pane[TOP_RIGHT_PANE]->y,
443 mwindow->theme->mcanvas_w - pane[TOP_RIGHT_PANE]->x,
444 pane[TOP_RIGHT_PANE]->h);
445 pane[BOTTOM_LEFT_PANE]->resize_event(
446 pane[BOTTOM_LEFT_PANE]->x,
447 pane[BOTTOM_LEFT_PANE]->y,
448 pane[BOTTOM_LEFT_PANE]->w,
449 mwindow->theme->mcanvas_y +
450 mwindow->theme->mcanvas_h -
451 pane[BOTTOM_LEFT_PANE]->y);
452 pane[BOTTOM_RIGHT_PANE]->resize_event(
453 pane[BOTTOM_RIGHT_PANE]->x,
454 pane[BOTTOM_RIGHT_PANE]->y,
455 mwindow->theme->mcanvas_w -
456 pane[BOTTOM_RIGHT_PANE]->x,
457 mwindow->theme->mcanvas_y +
458 mwindow->theme->mcanvas_h -
459 pane[BOTTOM_RIGHT_PANE]->y);
462 resource_thread->start_draw();
464 update_pane_dividers();
465 zoombar->resize_event();
466 pane_button->reposition_window(w - mwindow->theme->get_image_set("pane")[0]->get_w(),
467 mwindow->theme->mzoom_y + 1 - mwindow->theme->get_image_set("pane")[0]->get_h());
468 // get_scrollbars(0);
469 // canvas->resize_event();
470 //printf("MWindowGUI::resize_event %d\n", __LINE__);
475 int MWindowGUI::total_panes()
478 for(int i = 0; i < TOTAL_PANES; i++)
483 int MWindowGUI::vertical_panes()
485 return total_panes() == 2 &&
486 pane[TOP_LEFT_PANE] &&
487 pane[BOTTOM_LEFT_PANE];
490 int MWindowGUI::horizontal_panes()
492 return total_panes() == 2 &&
493 pane[TOP_LEFT_PANE] &&
494 pane[TOP_RIGHT_PANE];
497 TimelinePane* MWindowGUI::get_focused_pane()
499 if(pane[focused_pane]) return pane[focused_pane];
500 for(int i = 0; i < TOTAL_PANES; i++)
502 if(pane[i]) return pane[i];
507 void MWindowGUI::activate_timeline()
509 if(pane[focused_pane])
511 pane[focused_pane]->activate();
515 for(int i = 0; i < TOTAL_PANES; i++)
526 void MWindowGUI::deactivate_timeline()
528 for(int i = 0; i < TOTAL_PANES; i++)
532 pane[i]->canvas->deactivate();
537 void MWindowGUI::update_title(char *path)
540 char filename[BCTEXTLEN], string[BCTEXTLEN];
541 fs.extract_name(filename, path);
542 sprintf(string, _(PROGRAM_NAME ": %s"), filename);
544 //printf("MWindowGUI::update_title %s\n", string);
548 void MWindowGUI::draw_overlays(int flash_it)
550 for(int i = 0; i < TOTAL_PANES; i++)
554 pane[i]->canvas->draw_overlays();
555 if(flash_it) pane[i]->canvas->flash();
560 void MWindowGUI::update_timebar(int flush_it)
562 for(int i = 0; i < TOTAL_PANES; i++)
564 if(pane[i] && pane[i]->timebar)
566 pane[i]->timebar->update(flush_it);
571 void MWindowGUI::update_timebar_highlights()
573 for(int i = 0; i < TOTAL_PANES; i++)
575 if(pane[i] && pane[i]->timebar)
577 pane[i]->timebar->update_highlights();
583 void MWindowGUI::update_patchbay()
585 for(int i = 0; i < TOTAL_PANES; i++)
587 if(pane[i] && pane[i]->patchbay)
589 pane[i]->patchbay->update();
594 void MWindowGUI::draw_indexes(Indexable *indexable)
596 for(int i = 0; i < TOTAL_PANES; i++)
600 pane[i]->canvas->draw_indexes(indexable);
605 void MWindowGUI::draw_canvas(int mode /* = 0 */, int hide_cursor /* = 1 */)
607 if(mode != IGNORE_THREAD)
609 resource_thread->stop_draw(1);
613 for(int i = 0; i < TOTAL_PANES; i++)
617 pane[i]->canvas->draw(mode, hide_cursor);
622 if(mode != IGNORE_THREAD)
624 resource_thread->start_draw();
629 void MWindowGUI::flash_canvas(int flush)
631 for(int i = 0; i < TOTAL_PANES; i++)
635 pane[i]->canvas->flash(flush);
640 void MWindowGUI::draw_cursor(int do_plugintoggles)
642 for(int i = 0; i < TOTAL_PANES; i++)
646 pane[i]->cursor->draw(do_plugintoggles);
651 void MWindowGUI::show_cursor(int do_plugintoggles)
653 for(int i = 0; i < TOTAL_PANES; i++)
657 pane[i]->cursor->show(do_plugintoggles);
662 void MWindowGUI::hide_cursor(int do_plugintoggles)
664 for(int i = 0; i < TOTAL_PANES; i++)
668 pane[i]->cursor->hide(do_plugintoggles);
673 void MWindowGUI::update_cursor()
675 for(int i = 0; i < TOTAL_PANES; i++)
679 pane[i]->cursor->update();
684 void MWindowGUI::set_playing_back(int value)
686 for(int i = 0; i < TOTAL_PANES; i++)
690 pane[i]->cursor->playing_back = value;
695 void MWindowGUI::update_plugintoggles()
697 for(int i = 0; i < TOTAL_PANES; i++)
701 pane[i]->canvas->refresh_plugintoggles();
707 void MWindowGUI::update_scrollbars(int flush)
709 for(int i = 0; i < TOTAL_PANES; i++)
713 pane[i]->update(1, 0, 0, 0);
716 if(flush) this->flush();
719 void MWindowGUI::reset_meters()
721 for(int i = 0; i < TOTAL_PANES; i++)
723 if(pane[i] && pane[i]->patchbay)
725 pane[i]->patchbay->reset_meters();
730 void MWindowGUI::stop_meters()
732 for(int i = 0; i < TOTAL_PANES; i++)
734 if(pane[i] && pane[i]->patchbay)
736 pane[i]->patchbay->stop_meters();
741 void MWindowGUI::update_meters(ArrayList<double> *module_levels)
743 for(int i = 0; i < TOTAL_PANES; i++)
745 if(pane[i] && pane[i]->patchbay)
747 pane[i]->patchbay->update_meters(module_levels);
752 void MWindowGUI::set_editing_mode(int flush)
754 for(int i = 0; i < TOTAL_PANES; i++)
758 pane[i]->canvas->update_cursor(flush);
763 void MWindowGUI::set_meter_format(int mode, int min, int max)
765 for(int i = 0; i < TOTAL_PANES; i++)
767 if(pane[i] && pane[i]->patchbay)
769 pane[i]->patchbay->set_meter_format(mode, min, max);
774 void MWindowGUI::update(int scrollbars,
783 if(debug) PRINT_TRACE
787 mwindow->edl->tracks->update_y_pixels(mwindow->theme);
789 if(do_canvas && do_canvas != IGNORE_THREAD)
791 resource_thread->stop_draw(1);
794 for(int i = 0; i < TOTAL_PANES; i++)
796 if(pane[i]) pane[i]->update(scrollbars,
802 if(do_canvas && do_canvas != IGNORE_THREAD)
804 resource_thread->start_draw();
807 // if(scrollbars) this->get_scrollbars(0);
808 // if(timebar) this->timebar->update(0);
809 if(zoombar) this->zoombar->update();
810 // if(patchbay) this->patchbay->update();
811 if(clock) this->mainclock->update(
812 mwindow->edl->local_session->get_selectionstart(1));
813 if(debug) PRINT_TRACE
819 // this->canvas->draw(do_canvas);
820 // this->cursor->show();
821 // this->canvas->flash(0);
822 // Activate causes the menubar to deactivate. Don't want this for
824 // if(canvas != IGNORE_THREAD) this->canvas->activate();
826 if(debug) PRINT_TRACE
830 if(buttonbar) mbuttons->update();
831 if(debug) PRINT_TRACE
833 // Can't age if the cache called this to draw missing picons
834 // or the GUI is updating the status of the draw toggle.
835 if(do_canvas != FORCE_REDRAW && do_canvas != IGNORE_THREAD)
838 mwindow->age_caches();
839 lock_window("MWindowGUI::update");
843 if(debug) PRINT_TRACE
846 int MWindowGUI::visible(int64_t x1, int64_t x2, int64_t view_x1, int64_t view_x2)
848 return (x1 >= view_x1 && x1 < view_x2) ||
849 (x2 > view_x1 && x2 <= view_x2) ||
850 (x1 <= view_x1 && x2 >= view_x2);
854 int MWindowGUI::show_message(char *message, int color)
856 // printf("MWindowGUI::show_message %d: %s 0x%08x 0x%08x\n",
857 // __LINE__, message, color, mwindow->theme->message_normal);
858 if(color < 0) color = mwindow->theme->message_normal;
859 statusbar->status_text->set_color(color);
860 statusbar->status_text->update(message);
865 // Drag motion called from other window
866 int MWindowGUI::drag_motion()
868 if(get_hidden()) return 0;
870 Track *over_track = 0;
872 PluginSet *over_pluginset = 0;
873 Plugin *over_plugin = 0;
878 drag_popup->cursor_motion_event();
882 // there's no point in drawing highlights has until drag operation has been set
883 if (!mwindow->session->current_operation)
886 if(mwindow->session->free_drag) redraw = 1;
891 mwindow->session->free_drag = 1;
895 mwindow->session->free_drag = 0;
899 for(int i = 0; i < TOTAL_PANES; i++)
901 if(pane[i]) pane[i]->canvas->drag_motion(
910 if(mwindow->session->track_highlighted != over_track)
912 mwindow->session->track_highlighted = over_track;
916 if(mwindow->session->edit_highlighted != over_edit)
918 mwindow->session->edit_highlighted = over_edit;
922 if(mwindow->session->pluginset_highlighted != over_pluginset)
924 mwindow->session->pluginset_highlighted = over_pluginset;
928 if(mwindow->session->plugin_highlighted != over_plugin)
930 mwindow->session->plugin_highlighted = over_plugin;
934 // printf("drag_motion %d %d over_track=%p over_edit=%p\n",
941 lock_window("MWindowGUI::drag_motion");
948 int MWindowGUI::drag_stop()
950 if(get_hidden()) return 0;
951 int result = 0, redraw = 0;
953 for(int i = 0; i < TOTAL_PANES; i++)
955 if(pane[i]) result |= pane[i]->canvas->drag_stop(
960 // since we don't have subwindows we have to terminate any drag operation
963 if (mwindow->session->track_highlighted
964 || mwindow->session->edit_highlighted
965 || mwindow->session->plugin_highlighted
966 || mwindow->session->pluginset_highlighted)
968 mwindow->session->track_highlighted = 0;
969 mwindow->session->edit_highlighted = 0;
970 mwindow->session->plugin_highlighted = 0;
971 mwindow->session->pluginset_highlighted = 0;
972 mwindow->session->current_operation = NO_OPERATION;
976 //printf("TrackCanvas::drag_stop %d %d\n", redraw, mwindow->session->current_operation);
979 mwindow->edl->tracks->update_y_pixels(mwindow->theme);
980 update_scrollbars(0);
995 void MWindowGUI::default_positions()
997 //printf("MWindowGUI::default_positions 1\n");
998 VWindow *vwindow = mwindow->vwindows.size() > DEFAULT_VWINDOW ?
999 mwindow->vwindows.get(0) : 0;
1000 if( vwindow ) vwindow->gui->lock_window("MWindowGUI::default_positions");
1001 mwindow->cwindow->gui->lock_window("MWindowGUI::default_positions");
1002 mwindow->awindow->gui->lock_window("MWindowGUI::default_positions");
1004 // printf("MWindowGUI::default_positions 1 %d %d %d %d\n", mwindow->session->vwindow_x,
1005 // mwindow->session->vwindow_y,
1006 // mwindow->session->vwindow_w,
1007 // mwindow->session->vwindow_h);
1008 reposition_window(mwindow->session->mwindow_x,
1009 mwindow->session->mwindow_y,
1010 mwindow->session->mwindow_w,
1011 mwindow->session->mwindow_h);
1012 if( vwindow ) vwindow->gui->reposition_window(mwindow->session->vwindow_x,
1013 mwindow->session->vwindow_y,
1014 mwindow->session->vwindow_w,
1015 mwindow->session->vwindow_h);
1016 mwindow->cwindow->gui->reposition_window(mwindow->session->cwindow_x,
1017 mwindow->session->cwindow_y,
1018 mwindow->session->cwindow_w,
1019 mwindow->session->cwindow_h);
1020 mwindow->awindow->gui->reposition_window(mwindow->session->awindow_x,
1021 mwindow->session->awindow_y,
1022 mwindow->session->awindow_w,
1023 mwindow->session->awindow_h);
1024 //printf("MWindowGUI::default_positions 1\n");
1026 resize_event(mwindow->session->mwindow_w,
1027 mwindow->session->mwindow_h);
1028 //printf("MWindowGUI::default_positions 1\n");
1029 if( vwindow ) vwindow->gui->resize_event(mwindow->session->vwindow_w,
1030 mwindow->session->vwindow_h);
1031 //printf("MWindowGUI::default_positions 1\n");
1032 mwindow->cwindow->gui->resize_event(mwindow->session->cwindow_w,
1033 mwindow->session->cwindow_h);
1034 //printf("MWindowGUI::default_positions 1\n");
1035 mwindow->awindow->gui->resize_event(mwindow->session->awindow_w,
1036 mwindow->session->awindow_h);
1038 //printf("MWindowGUI::default_positions 1\n");
1041 if( vwindow ) vwindow->gui->flush();
1042 mwindow->cwindow->gui->flush();
1043 mwindow->awindow->gui->flush();
1045 if( vwindow ) vwindow->gui->unlock_window();
1046 mwindow->cwindow->gui->unlock_window();
1047 mwindow->awindow->gui->unlock_window();
1048 //printf("MWindowGUI::default_positions 2\n");
1067 int MWindowGUI::repeat_event(int64_t duration)
1069 // if(duration == 100)
1070 // mwindow->sync_parameters(CHANGE_ALL);
1072 for(int i = 0; i < TOTAL_PANES; i++)
1074 if(pane[i]) result = pane[i]->cursor->repeat_event(duration);
1080 int MWindowGUI::translation_event()
1082 //printf("MWindowGUI::translation_event 1 %d %d\n", get_x(), get_y());
1083 mwindow->session->mwindow_x = get_x();
1084 mwindow->session->mwindow_y = get_y();
1089 int MWindowGUI::save_defaults(BC_Hash *defaults)
1091 defaults->update("MWINDOWWIDTH", get_w());
1092 defaults->update("MWINDOWHEIGHT", get_h());
1093 mainmenu->save_defaults(defaults);
1094 BC_WindowBase::save_defaults(defaults);
1098 int MWindowGUI::keypress_event()
1100 //printf("MWindowGUI::keypress_event 1 %d\n", get_keypress());
1102 result = mbuttons->keypress_event();
1106 switch(get_keypress())
1108 case '1': case '2': case '3': case '4':
1109 case '5': case '6': case '7': case '8':
1110 if( !alt_down() || shift_down() ) break;
1111 if( !mwindow->select_asset(get_keypress()-'1',1) )
1120 mbuttons->transport->handle_transport(STOP, 1, 0, 0);
1121 lock_window("MWindowGUI::keypress_event 1");
1122 mwindow->prev_edit_handle(shift_down());
1125 mwindow->move_left();
1135 mbuttons->transport->handle_transport(STOP, 1, 0, 0);
1136 lock_window("MWindowGUI::keypress_event 2");
1137 mwindow->next_edit_handle(shift_down());
1140 mwindow->move_right();
1148 mwindow->expand_y();
1154 mwindow->expand_autos();
1159 mwindow->expand_sample();
1167 mwindow->zoom_in_y();
1173 mwindow->shrink_autos();
1178 mwindow->zoom_in_sample();
1191 mwindow->expand_t();
1199 mwindow->move_down();
1204 mwindow->zoom_in_t();
1211 // //int cursor_x = 0;
1212 // int cursor_y = 0;
1213 // for(int i = 0; i < TOTAL_PANES; i++)
1217 // //cursor_x = pane[i]->canvas->get_relative_cursor_x();
1218 // cursor_y = pane[i]->canvas->get_relative_cursor_y();
1223 // if(get_keypress() == TAB)
1225 // // Switch the record button
1226 // for(Track *track = mwindow->edl->tracks->first; track; track = track->next)
1228 // int64_t track_x, track_y, track_w, track_h;
1229 // canvas->track_dimensions(track, track_x, track_y, track_w, track_h);
1231 // if(cursor_y >= track_y &&
1232 // cursor_y < track_y + track_h)
1234 // if (track->record)
1235 // track->record = 0;
1237 // track->record = 1;
1245 // Track *this_track = 0;
1246 // for(Track *track = mwindow->edl->tracks->first; track; track = track->next)
1248 // int64_t track_x, track_y, track_w, track_h;
1249 // canvas->track_dimensions(track, track_x, track_y, track_w, track_h);
1251 // if(cursor_y >= track_y &&
1252 // cursor_y < track_y + track_h)
1254 // // This is our track
1255 // this_track = track;
1260 // int total_selected = mwindow->edl->tracks->total_of(Tracks::RECORD);
1262 // // nothing previously selected
1263 // if(total_selected == 0)
1265 // mwindow->edl->tracks->select_all(Tracks::RECORD,
1269 // if(total_selected == 1)
1271 // // this patch was previously the only one on
1272 // if(this_track && this_track->record)
1274 // mwindow->edl->tracks->select_all(Tracks::RECORD,
1277 // // another patch was previously the only one on
1280 // mwindow->edl->tracks->select_all(Tracks::RECORD,
1283 // this_track->record = 1;
1288 // if(total_selected > 1)
1290 // mwindow->edl->tracks->select_all(Tracks::RECORD,
1293 // this_track->record = 1;
1306 // mwindow->cwindow->update(0, 1, 1);
1307 // lock_window("TrackCanvas::keypress_event 3");
1313 // since things under cursor have changed...
1315 cursor_motion_event();
1322 int MWindowGUI::keyboard_listener(BC_WindowBase *wp)
1324 return keyboard_listener(wp->get_keypress());
1327 int MWindowGUI::keyboard_listener(int key)
1332 if( !record->running() )
1335 record->record_gui->interrupt_thread->start(0);
1341 channel_info->toggle_scan();
1344 if( !remote_control->deactivate() )
1345 remote_control->activate();
1355 void MWindowGUI::use_android_remote(int on)
1358 delete android_control;
1359 android_control = 0;
1362 if( android_control ) return;
1363 android_control = new AndroidControl(this);
1366 int MWindowGUI::close_event()
1372 void MWindowGUI::stop_drawing()
1374 resource_thread->stop_draw(1);
1377 int MWindowGUI::menu_h()
1379 return mainmenu->get_h();
1382 void MWindowGUI::start_x_pane_drag()
1386 x_pane_drag = new BC_Popup(this,
1387 get_abs_cursor_x(0) - mwindow->theme->pane_w,
1388 get_resources()->get_top_border() +
1390 mwindow->theme->mcanvas_y,
1391 mwindow->theme->pane_w,
1392 mwindow->theme->mcanvas_h,
1393 mwindow->theme->drag_pane_color);
1394 x_pane_drag->draw_3segmentv(0,
1396 x_pane_drag->get_h(),
1397 mwindow->theme->get_image_set("xpane")[BUTTON_DOWNHI]);
1398 x_pane_drag->flash(1);
1403 void MWindowGUI::start_y_pane_drag()
1407 //printf("MWindowGUI::start_y_pane_drag %d %d %d\n", __LINE__, get_x(), get_y());
1408 y_pane_drag = new BC_Popup(this,
1409 get_resources()->get_left_border() +
1411 mwindow->theme->mcanvas_x,
1412 get_abs_cursor_y(0) - mwindow->theme->pane_h,
1413 mwindow->theme->mcanvas_w,
1414 mwindow->theme->pane_h,
1415 mwindow->theme->drag_pane_color);
1416 y_pane_drag->draw_3segmenth(0,
1418 y_pane_drag->get_w(),
1419 mwindow->theme->get_image_set("ypane")[BUTTON_DOWNHI]);
1420 y_pane_drag->flash(1);
1425 void MWindowGUI::handle_pane_drag()
1431 x_pane_drag->reposition_window(
1432 get_abs_cursor_x(0) - mwindow->theme->pane_w,
1433 x_pane_drag->get_y());
1438 y_pane_drag->reposition_window(
1439 y_pane_drag->get_x(),
1440 get_abs_cursor_y(0) - mwindow->theme->pane_h);
1446 void MWindowGUI::create_x_pane(int cursor_x)
1448 if(total_panes() == 1)
1450 // create a horizontal pane
1451 // do this 1st so the resize_event knows there are 2 panes
1452 mwindow->edl->local_session->view_start[TOP_RIGHT_PANE] =
1453 mwindow->edl->local_session->view_start[TOP_LEFT_PANE] +
1455 mwindow->theme->patchbay_w;
1456 pane[TOP_RIGHT_PANE] = new TimelinePane(mwindow,
1458 mwindow->theme->mcanvas_x +
1460 mwindow->theme->mcanvas_y,
1461 mwindow->theme->mcanvas_x +
1462 mwindow->theme->mcanvas_w -
1464 mwindow->theme->mcanvas_h);
1465 pane[TOP_LEFT_PANE]->resize_event(
1466 mwindow->theme->mcanvas_x,
1467 mwindow->theme->mcanvas_y,
1468 cursor_x - mwindow->theme->pane_w,
1469 mwindow->theme->mcanvas_h);
1470 pane[TOP_RIGHT_PANE]->create_objects();
1473 if(vertical_panes())
1475 // create 2 horizontal panes
1476 mwindow->edl->local_session->track_start[TOP_RIGHT_PANE] =
1477 mwindow->edl->local_session->track_start[TOP_LEFT_PANE];
1478 mwindow->edl->local_session->track_start[BOTTOM_RIGHT_PANE] =
1479 mwindow->edl->local_session->track_start[BOTTOM_LEFT_PANE];
1480 mwindow->edl->local_session->view_start[TOP_RIGHT_PANE] =
1481 mwindow->edl->local_session->view_start[BOTTOM_RIGHT_PANE] =
1482 mwindow->edl->local_session->view_start[TOP_LEFT_PANE] +
1484 mwindow->theme->patchbay_w;
1485 pane[TOP_RIGHT_PANE] = new TimelinePane(mwindow,
1487 mwindow->theme->mcanvas_x +
1489 pane[TOP_LEFT_PANE]->y,
1490 mwindow->theme->mcanvas_x +
1491 mwindow->theme->mcanvas_w -
1493 pane[TOP_LEFT_PANE]->h);
1494 pane[BOTTOM_RIGHT_PANE] = new TimelinePane(mwindow,
1496 mwindow->theme->mcanvas_x +
1498 pane[BOTTOM_LEFT_PANE]->y,
1499 mwindow->theme->mcanvas_x +
1500 mwindow->theme->mcanvas_w -
1502 pane[BOTTOM_LEFT_PANE]->h);
1503 pane[TOP_LEFT_PANE]->resize_event(
1504 pane[TOP_LEFT_PANE]->x,
1505 pane[TOP_LEFT_PANE]->y,
1506 cursor_x - mwindow->theme->pane_w,
1507 pane[TOP_LEFT_PANE]->h);
1508 pane[BOTTOM_LEFT_PANE]->resize_event(
1509 pane[BOTTOM_LEFT_PANE]->x,
1510 pane[BOTTOM_LEFT_PANE]->y,
1511 cursor_x - mwindow->theme->pane_w,
1512 pane[BOTTOM_LEFT_PANE]->h);
1513 pane[TOP_RIGHT_PANE]->create_objects();
1514 pane[BOTTOM_RIGHT_PANE]->create_objects();
1517 if(horizontal_panes())
1519 // resize a horizontal pane
1520 mwindow->edl->local_session->view_start[TOP_RIGHT_PANE] +=
1522 pane[TOP_RIGHT_PANE]->x;
1523 if(mwindow->edl->local_session->view_start[TOP_RIGHT_PANE] < 0)
1524 mwindow->edl->local_session->view_start[TOP_RIGHT_PANE] = 0;
1525 pane[TOP_LEFT_PANE]->resize_event(
1526 mwindow->theme->mcanvas_x,
1527 mwindow->theme->mcanvas_y,
1528 cursor_x - mwindow->theme->pane_w,
1529 mwindow->theme->mcanvas_h);
1530 pane[TOP_RIGHT_PANE]->resize_event(
1531 mwindow->theme->mcanvas_x +
1533 pane[TOP_RIGHT_PANE]->y,
1534 mwindow->theme->mcanvas_x +
1535 mwindow->theme->mcanvas_w -
1537 mwindow->theme->mcanvas_h);
1541 // resize 2 horizontal panes
1542 mwindow->edl->local_session->view_start[TOP_RIGHT_PANE] +=
1544 pane[TOP_RIGHT_PANE]->x;
1545 if(mwindow->edl->local_session->view_start[TOP_RIGHT_PANE] < 0)
1546 mwindow->edl->local_session->view_start[TOP_RIGHT_PANE] = 0;
1547 mwindow->edl->local_session->view_start[BOTTOM_RIGHT_PANE] =
1548 mwindow->edl->local_session->view_start[TOP_RIGHT_PANE];
1550 pane[TOP_LEFT_PANE]->resize_event(
1551 mwindow->theme->mcanvas_x,
1552 pane[TOP_LEFT_PANE]->y,
1553 cursor_x - mwindow->theme->pane_w,
1554 pane[TOP_LEFT_PANE]->h);
1555 pane[TOP_RIGHT_PANE]->resize_event(
1556 mwindow->theme->mcanvas_x +
1558 pane[TOP_RIGHT_PANE]->y,
1559 mwindow->theme->mcanvas_x +
1560 mwindow->theme->mcanvas_w -
1562 pane[TOP_RIGHT_PANE]->h);
1563 pane[BOTTOM_LEFT_PANE]->resize_event(
1564 mwindow->theme->mcanvas_x,
1565 pane[BOTTOM_LEFT_PANE]->y,
1566 cursor_x - mwindow->theme->pane_w,
1567 pane[BOTTOM_LEFT_PANE]->h);
1568 pane[BOTTOM_RIGHT_PANE]->resize_event(
1569 mwindow->theme->mcanvas_x +
1571 pane[BOTTOM_RIGHT_PANE]->y,
1572 mwindow->theme->mcanvas_x +
1573 mwindow->theme->mcanvas_w -
1575 pane[BOTTOM_RIGHT_PANE]->h);
1581 void MWindowGUI::delete_x_pane(int cursor_x)
1583 // give left panes coordinates of right pane
1584 if(cursor_x < mwindow->theme->patchbay_w + PANE_DRAG_MARGIN &&
1585 pane[TOP_RIGHT_PANE])
1587 mwindow->edl->local_session->view_start[TOP_LEFT_PANE] =
1588 mwindow->edl->local_session->view_start[TOP_RIGHT_PANE] -
1589 pane[TOP_RIGHT_PANE]->x + mwindow->theme->patchbay_w;
1590 if(mwindow->edl->local_session->view_start[TOP_LEFT_PANE] < 0)
1591 mwindow->edl->local_session->view_start[TOP_LEFT_PANE] = 0;
1592 mwindow->edl->local_session->view_start[BOTTOM_LEFT_PANE] =
1593 mwindow->edl->local_session->view_start[TOP_LEFT_PANE];
1596 switch(total_panes())
1599 if(pane[TOP_LEFT_PANE] && pane[TOP_RIGHT_PANE])
1601 // delete right pane
1602 delete pane[TOP_RIGHT_PANE];
1603 pane[TOP_RIGHT_PANE] = 0;
1604 pane[TOP_LEFT_PANE]->resize_event(
1605 mwindow->theme->mcanvas_x,
1606 mwindow->theme->mcanvas_y,
1607 mwindow->theme->mcanvas_w,
1608 mwindow->theme->mcanvas_h);
1614 // delete right panes
1615 delete pane[TOP_RIGHT_PANE];
1616 pane[TOP_RIGHT_PANE] = 0;
1617 delete pane[BOTTOM_RIGHT_PANE];
1618 pane[BOTTOM_RIGHT_PANE] = 0;
1619 pane[TOP_LEFT_PANE]->resize_event(
1620 mwindow->theme->mcanvas_x,
1621 pane[TOP_LEFT_PANE]->y,
1622 mwindow->theme->mcanvas_w,
1623 pane[TOP_LEFT_PANE]->h);
1624 pane[BOTTOM_LEFT_PANE]->resize_event(
1625 mwindow->theme->mcanvas_x,
1626 pane[BOTTOM_LEFT_PANE]->y,
1627 mwindow->theme->mcanvas_w,
1628 pane[BOTTOM_LEFT_PANE]->h);
1633 void MWindowGUI::create_y_pane(int cursor_y)
1635 if(total_panes() == 1)
1637 mwindow->edl->local_session->view_start[BOTTOM_LEFT_PANE] =
1638 mwindow->edl->local_session->view_start[TOP_LEFT_PANE];
1639 mwindow->edl->local_session->track_start[BOTTOM_LEFT_PANE] =
1640 mwindow->edl->local_session->track_start[TOP_LEFT_PANE] +
1642 mwindow->theme->mtimebar_h;
1643 // do this 1st so the resize_event knows there are 2 panes
1644 pane[BOTTOM_LEFT_PANE] = new TimelinePane(mwindow,
1646 mwindow->theme->mcanvas_x,
1647 mwindow->theme->mcanvas_y +
1649 mwindow->theme->mcanvas_w,
1650 mwindow->theme->mcanvas_h -
1652 pane[TOP_LEFT_PANE]->resize_event(
1653 mwindow->theme->mcanvas_x,
1654 mwindow->theme->mcanvas_y,
1655 mwindow->theme->mcanvas_w,
1656 pane[BOTTOM_LEFT_PANE]->y -
1657 mwindow->theme->mcanvas_y -
1658 mwindow->theme->pane_h);
1659 pane[BOTTOM_LEFT_PANE]->create_objects();
1662 if(horizontal_panes())
1665 mwindow->edl->local_session->view_start[BOTTOM_LEFT_PANE] =
1666 mwindow->edl->local_session->view_start[TOP_LEFT_PANE];
1667 mwindow->edl->local_session->view_start[BOTTOM_RIGHT_PANE] =
1668 mwindow->edl->local_session->view_start[TOP_RIGHT_PANE];
1669 mwindow->edl->local_session->track_start[BOTTOM_LEFT_PANE] =
1670 mwindow->edl->local_session->track_start[BOTTOM_RIGHT_PANE] =
1671 mwindow->edl->local_session->track_start[TOP_LEFT_PANE] +
1673 mwindow->theme->mtimebar_h;
1675 pane[BOTTOM_LEFT_PANE] = new TimelinePane(mwindow,
1677 pane[TOP_LEFT_PANE]->x,
1678 mwindow->theme->mcanvas_y +
1680 pane[TOP_LEFT_PANE]->w,
1681 mwindow->theme->mcanvas_h -
1683 pane[BOTTOM_RIGHT_PANE] = new TimelinePane(mwindow,
1685 pane[TOP_RIGHT_PANE]->x,
1686 mwindow->theme->mcanvas_y +
1688 pane[TOP_RIGHT_PANE]->w,
1689 mwindow->theme->mcanvas_h -
1692 pane[TOP_LEFT_PANE]->resize_event(
1693 pane[TOP_LEFT_PANE]->x,
1694 pane[TOP_LEFT_PANE]->y,
1695 pane[TOP_LEFT_PANE]->w,
1696 pane[BOTTOM_LEFT_PANE]->y -
1697 mwindow->theme->mcanvas_y -
1698 mwindow->theme->pane_h);
1699 pane[TOP_RIGHT_PANE]->resize_event(
1700 pane[TOP_RIGHT_PANE]->x,
1701 pane[TOP_RIGHT_PANE]->y,
1702 pane[TOP_RIGHT_PANE]->w,
1703 pane[BOTTOM_RIGHT_PANE]->y -
1704 mwindow->theme->mcanvas_y -
1705 mwindow->theme->pane_h);
1707 pane[BOTTOM_LEFT_PANE]->create_objects();
1708 pane[BOTTOM_RIGHT_PANE]->create_objects();
1711 if(vertical_panes())
1714 mwindow->edl->local_session->track_start[BOTTOM_LEFT_PANE] +=
1716 (pane[BOTTOM_LEFT_PANE]->y - mwindow->theme->mcanvas_y);
1717 if(mwindow->edl->local_session->track_start[BOTTOM_LEFT_PANE] < 0)
1718 mwindow->edl->local_session->track_start[BOTTOM_LEFT_PANE] = 0;
1719 pane[TOP_LEFT_PANE]->resize_event(
1720 mwindow->theme->mcanvas_x,
1721 mwindow->theme->mcanvas_y,
1722 mwindow->theme->mcanvas_w,
1723 cursor_y - mwindow->theme->pane_h);
1724 pane[BOTTOM_LEFT_PANE]->resize_event(
1725 pane[BOTTOM_LEFT_PANE]->x,
1727 mwindow->theme->mcanvas_y,
1728 mwindow->theme->mcanvas_w,
1729 mwindow->theme->mcanvas_h -
1735 mwindow->edl->local_session->track_start[BOTTOM_LEFT_PANE] +=
1737 (pane[BOTTOM_LEFT_PANE]->y - mwindow->theme->mcanvas_y);
1738 if(mwindow->edl->local_session->track_start[BOTTOM_LEFT_PANE] < 0)
1739 mwindow->edl->local_session->track_start[BOTTOM_LEFT_PANE] = 0;
1740 mwindow->edl->local_session->track_start[BOTTOM_RIGHT_PANE] =
1741 mwindow->edl->local_session->track_start[BOTTOM_LEFT_PANE];
1742 pane[TOP_LEFT_PANE]->resize_event(
1743 pane[TOP_LEFT_PANE]->x,
1744 pane[TOP_LEFT_PANE]->y,
1745 pane[TOP_LEFT_PANE]->w,
1746 cursor_y - mwindow->theme->pane_h);
1747 pane[BOTTOM_LEFT_PANE]->resize_event(
1748 pane[BOTTOM_LEFT_PANE]->x,
1750 mwindow->theme->mcanvas_y,
1751 pane[BOTTOM_LEFT_PANE]->w,
1752 mwindow->theme->mcanvas_h -
1754 pane[TOP_RIGHT_PANE]->resize_event(
1755 pane[TOP_RIGHT_PANE]->x,
1756 pane[TOP_RIGHT_PANE]->y,
1757 pane[TOP_RIGHT_PANE]->w,
1758 cursor_y - mwindow->theme->pane_h);
1759 pane[BOTTOM_RIGHT_PANE]->resize_event(
1760 pane[BOTTOM_RIGHT_PANE]->x,
1762 mwindow->theme->mcanvas_y,
1763 pane[BOTTOM_RIGHT_PANE]->w,
1764 mwindow->theme->mcanvas_h -
1769 void MWindowGUI::delete_y_pane(int cursor_y)
1771 if(cursor_y < mwindow->theme->mtimebar_h +
1773 pane[BOTTOM_LEFT_PANE])
1775 // give top pane coordinates of bottom pane
1776 mwindow->edl->local_session->track_start[TOP_LEFT_PANE] =
1777 mwindow->edl->local_session->track_start[BOTTOM_LEFT_PANE] -
1778 pane[BOTTOM_LEFT_PANE]->y;
1779 if(mwindow->edl->local_session->track_start[TOP_LEFT_PANE] < 0)
1780 mwindow->edl->local_session->track_start[TOP_LEFT_PANE] = 0;
1781 mwindow->edl->local_session->track_start[TOP_RIGHT_PANE] =
1782 mwindow->edl->local_session->track_start[TOP_LEFT_PANE];
1786 switch(total_panes())
1789 delete pane[BOTTOM_LEFT_PANE];
1790 pane[BOTTOM_LEFT_PANE] = 0;
1791 pane[TOP_LEFT_PANE]->resize_event(
1792 mwindow->theme->mcanvas_x,
1793 mwindow->theme->mcanvas_y,
1794 mwindow->theme->mcanvas_w,
1795 mwindow->theme->mcanvas_h);
1799 // delete bottom 2 panes
1801 delete pane[BOTTOM_LEFT_PANE];
1802 pane[BOTTOM_LEFT_PANE] = 0;
1803 delete pane[BOTTOM_RIGHT_PANE];
1804 pane[BOTTOM_RIGHT_PANE] = 0;
1805 pane[TOP_LEFT_PANE]->resize_event(
1806 pane[TOP_LEFT_PANE]->x,
1807 mwindow->theme->mcanvas_y,
1808 pane[TOP_LEFT_PANE]->w,
1809 mwindow->theme->mcanvas_h);
1810 pane[TOP_RIGHT_PANE]->resize_event(
1811 pane[TOP_RIGHT_PANE]->x,
1812 mwindow->theme->mcanvas_y,
1813 pane[TOP_RIGHT_PANE]->w,
1814 mwindow->theme->mcanvas_h);
1819 void MWindowGUI::stop_pane_drag()
1822 resource_thread->stop_draw(1);
1826 // cursor position relative to canvas
1827 int cursor_x = x_pane_drag->get_x() -
1829 get_resources()->get_left_border() -
1830 mwindow->theme->mcanvas_x +
1831 mwindow->theme->pane_w;
1836 if(cursor_x >= mwindow->theme->patchbay_w + PANE_DRAG_MARGIN &&
1837 cursor_x < mwindow->theme->mcanvas_w -
1838 BC_ScrollBar::get_span(SCROLL_VERT) -
1841 create_x_pane(cursor_x);
1842 mwindow->edl->local_session->x_pane = cursor_x;
1847 delete_x_pane(cursor_x);
1848 mwindow->edl->local_session->x_pane = -1;
1856 // cursor position relative to canvas
1857 int cursor_y = y_pane_drag->get_y() -
1859 get_resources()->get_top_border() -
1860 mwindow->theme->mcanvas_y +
1861 mwindow->theme->pane_h;
1867 if(cursor_y >= mwindow->theme->mtimebar_h +
1869 cursor_y < mwindow->theme->mcanvas_h -
1870 BC_ScrollBar::get_span(SCROLL_HORIZ) -
1873 create_y_pane(cursor_y);
1874 mwindow->edl->local_session->y_pane = cursor_y;
1878 delete_y_pane(cursor_y);
1879 mwindow->edl->local_session->y_pane = -1;
1883 update_pane_dividers();
1885 // required to get new widgets to appear
1887 resource_thread->start_draw();
1890 // create panes from EDL
1891 void MWindowGUI::load_panes()
1893 int need_x_panes = 0;
1894 int need_y_panes = 0;
1895 // use names from create functions
1896 int cursor_x = mwindow->edl->local_session->x_pane;
1897 int cursor_y = mwindow->edl->local_session->y_pane;
1899 resource_thread->stop_draw(1);
1901 mwindow->theme->patchbay_w + PANE_DRAG_MARGIN &&
1903 mwindow->theme->mcanvas_w -
1904 BC_ScrollBar::get_span(SCROLL_VERT) -
1911 mwindow->theme->mtimebar_h + PANE_DRAG_MARGIN &&
1913 mwindow->theme->mcanvas_h -
1914 BC_ScrollBar::get_span(SCROLL_HORIZ) -
1920 //printf("MWindowGUI::load_panes %d %d %d\n", __LINE__, need_x_panes, need_y_panes);
1928 if(total_panes() == 1)
1931 //printf("MWindowGUI::load_panes %d\n", __LINE__);
1932 pane[TOP_RIGHT_PANE] = new TimelinePane(mwindow,
1934 mwindow->theme->mcanvas_x +
1936 mwindow->theme->mcanvas_y,
1937 mwindow->theme->mcanvas_x +
1938 mwindow->theme->mcanvas_w -
1940 cursor_y - mwindow->theme->pane_h);
1941 pane[BOTTOM_LEFT_PANE] = new TimelinePane(mwindow,
1943 mwindow->theme->mcanvas_x,
1944 mwindow->theme->mcanvas_y +
1946 cursor_x - mwindow->theme->pane_w,
1947 mwindow->theme->mcanvas_h -
1949 pane[BOTTOM_RIGHT_PANE] = new TimelinePane(mwindow,
1951 pane[TOP_RIGHT_PANE]->x,
1952 mwindow->theme->mcanvas_y +
1954 pane[TOP_RIGHT_PANE]->w,
1955 mwindow->theme->mcanvas_h -
1957 pane[TOP_LEFT_PANE]->resize_event(
1958 pane[TOP_LEFT_PANE]->x,
1959 pane[TOP_LEFT_PANE]->y,
1960 cursor_x - mwindow->theme->pane_w,
1961 cursor_y - mwindow->theme->pane_h);
1962 pane[TOP_RIGHT_PANE]->create_objects();
1963 pane[BOTTOM_LEFT_PANE]->create_objects();
1964 pane[BOTTOM_RIGHT_PANE]->create_objects();
1967 if(horizontal_panes())
1969 // create vertical panes
1970 //printf("MWindowGUI::load_panes %d\n", __LINE__);
1971 pane[BOTTOM_LEFT_PANE] = new TimelinePane(mwindow,
1973 mwindow->theme->mcanvas_x,
1974 mwindow->theme->mcanvas_y +
1976 cursor_x - mwindow->theme->pane_w,
1977 mwindow->theme->mcanvas_h -
1979 pane[BOTTOM_RIGHT_PANE] = new TimelinePane(mwindow,
1981 pane[TOP_RIGHT_PANE]->x,
1982 mwindow->theme->mcanvas_y +
1984 pane[TOP_RIGHT_PANE]->w,
1985 mwindow->theme->mcanvas_h -
1987 pane[TOP_LEFT_PANE]->resize_event(
1988 pane[TOP_LEFT_PANE]->x,
1989 pane[TOP_LEFT_PANE]->y,
1990 cursor_x - mwindow->theme->pane_w,
1991 cursor_y - mwindow->theme->pane_h);
1992 pane[TOP_RIGHT_PANE]->resize_event(
1993 mwindow->theme->mcanvas_x +
1995 mwindow->theme->mcanvas_y,
1996 mwindow->theme->mcanvas_x +
1997 mwindow->theme->mcanvas_w -
1999 cursor_y - mwindow->theme->pane_h);
2000 pane[BOTTOM_LEFT_PANE]->create_objects();
2001 pane[BOTTOM_RIGHT_PANE]->create_objects();
2004 if(vertical_panes())
2006 // create horizontal panes
2007 //printf("MWindowGUI::load_panes %d\n", __LINE__);
2008 pane[TOP_RIGHT_PANE] = new TimelinePane(mwindow,
2010 mwindow->theme->mcanvas_x +
2012 mwindow->theme->mcanvas_y,
2013 mwindow->theme->mcanvas_x +
2014 mwindow->theme->mcanvas_w -
2016 cursor_y - mwindow->theme->pane_h);
2017 pane[BOTTOM_RIGHT_PANE] = new TimelinePane(mwindow,
2019 pane[TOP_RIGHT_PANE]->x,
2020 mwindow->theme->mcanvas_y +
2022 pane[TOP_RIGHT_PANE]->w,
2023 mwindow->theme->mcanvas_h -
2025 pane[TOP_LEFT_PANE]->resize_event(
2026 pane[TOP_LEFT_PANE]->x,
2027 pane[TOP_LEFT_PANE]->y,
2028 cursor_x - mwindow->theme->pane_w,
2029 cursor_y - mwindow->theme->pane_h);
2030 pane[BOTTOM_LEFT_PANE]->resize_event(
2031 pane[TOP_LEFT_PANE]->x,
2032 mwindow->theme->mcanvas_y +
2034 mwindow->theme->mcanvas_x +
2035 mwindow->theme->mcanvas_w -
2037 mwindow->theme->mcanvas_h -
2039 pane[TOP_RIGHT_PANE]->create_objects();
2040 pane[BOTTOM_RIGHT_PANE]->create_objects();
2047 //printf("MWindowGUI::load_panes %d\n", __LINE__);
2048 pane[TOP_LEFT_PANE]->resize_event(
2049 pane[TOP_LEFT_PANE]->x,
2050 pane[TOP_LEFT_PANE]->y,
2051 cursor_x - mwindow->theme->pane_w,
2052 cursor_y - mwindow->theme->pane_h);
2053 pane[TOP_RIGHT_PANE]->resize_event(
2054 mwindow->theme->mcanvas_x +
2056 mwindow->theme->mcanvas_y,
2057 mwindow->theme->mcanvas_x +
2058 mwindow->theme->mcanvas_w -
2060 cursor_y - mwindow->theme->pane_h);
2061 pane[BOTTOM_LEFT_PANE]->resize_event(
2062 pane[TOP_LEFT_PANE]->x,
2063 mwindow->theme->mcanvas_y +
2065 mwindow->theme->mcanvas_x +
2066 mwindow->theme->mcanvas_w -
2068 mwindow->theme->mcanvas_h -
2070 pane[BOTTOM_RIGHT_PANE]->resize_event(
2071 pane[TOP_RIGHT_PANE]->x,
2072 mwindow->theme->mcanvas_y +
2074 pane[TOP_RIGHT_PANE]->w,
2075 mwindow->theme->mcanvas_h -
2084 if(pane[BOTTOM_LEFT_PANE]) delete pane[BOTTOM_LEFT_PANE];
2085 if(pane[BOTTOM_RIGHT_PANE]) delete pane[BOTTOM_RIGHT_PANE];
2086 pane[BOTTOM_LEFT_PANE] = 0;
2087 pane[BOTTOM_RIGHT_PANE] = 0;
2089 if(!pane[TOP_RIGHT_PANE])
2091 pane[TOP_RIGHT_PANE] = new TimelinePane(mwindow,
2093 mwindow->theme->mcanvas_x +
2095 mwindow->theme->mcanvas_y,
2096 mwindow->theme->mcanvas_x +
2097 mwindow->theme->mcanvas_w -
2099 mwindow->theme->mcanvas_h);
2100 pane[TOP_LEFT_PANE]->resize_event(
2101 mwindow->theme->mcanvas_x,
2102 mwindow->theme->mcanvas_y,
2103 cursor_x - mwindow->theme->pane_w,
2104 mwindow->theme->mcanvas_h);
2105 pane[TOP_RIGHT_PANE]->create_objects();
2109 pane[TOP_LEFT_PANE]->resize_event(
2110 mwindow->theme->mcanvas_x,
2111 mwindow->theme->mcanvas_y,
2112 cursor_x - mwindow->theme->pane_w,
2113 mwindow->theme->mcanvas_h);
2114 pane[TOP_RIGHT_PANE]->resize_event(
2115 mwindow->theme->mcanvas_x +
2117 pane[TOP_RIGHT_PANE]->y,
2118 mwindow->theme->mcanvas_x +
2119 mwindow->theme->mcanvas_w -
2121 mwindow->theme->mcanvas_h);
2129 if(pane[TOP_RIGHT_PANE]) delete pane[TOP_RIGHT_PANE];
2130 if(pane[BOTTOM_RIGHT_PANE]) delete pane[BOTTOM_RIGHT_PANE];
2131 pane[TOP_RIGHT_PANE] = 0;
2132 pane[BOTTOM_RIGHT_PANE] = 0;
2134 if(!pane[BOTTOM_LEFT_PANE])
2136 //printf("MWindowGUI::load_panes %d\n", __LINE__);
2137 pane[BOTTOM_LEFT_PANE] = new TimelinePane(mwindow,
2139 mwindow->theme->mcanvas_x,
2140 mwindow->theme->mcanvas_y +
2142 mwindow->theme->mcanvas_w,
2143 mwindow->theme->mcanvas_h -
2145 pane[TOP_LEFT_PANE]->resize_event(
2146 mwindow->theme->mcanvas_x,
2147 mwindow->theme->mcanvas_y,
2148 mwindow->theme->mcanvas_w,
2149 pane[BOTTOM_LEFT_PANE]->y -
2150 mwindow->theme->mcanvas_y -
2151 mwindow->theme->pane_h);
2152 pane[BOTTOM_LEFT_PANE]->create_objects();
2156 pane[TOP_LEFT_PANE]->resize_event(
2157 mwindow->theme->mcanvas_x,
2158 mwindow->theme->mcanvas_y,
2159 mwindow->theme->mcanvas_w,
2160 cursor_y - mwindow->theme->pane_h);
2161 pane[BOTTOM_LEFT_PANE]->resize_event(
2162 pane[BOTTOM_LEFT_PANE]->x,
2164 mwindow->theme->mcanvas_y,
2165 mwindow->theme->mcanvas_w,
2166 mwindow->theme->mcanvas_h -
2173 if(pane[TOP_RIGHT_PANE]) delete pane[TOP_RIGHT_PANE];
2174 if(pane[BOTTOM_RIGHT_PANE]) delete pane[BOTTOM_RIGHT_PANE];
2175 if(pane[BOTTOM_LEFT_PANE]) delete pane[BOTTOM_LEFT_PANE];
2176 pane[TOP_RIGHT_PANE] = 0;
2177 pane[BOTTOM_RIGHT_PANE] = 0;
2178 pane[BOTTOM_LEFT_PANE] = 0;
2179 pane[TOP_LEFT_PANE]->resize_event(
2180 mwindow->theme->mcanvas_x,
2181 mwindow->theme->mcanvas_y,
2182 mwindow->theme->mcanvas_w,
2183 mwindow->theme->mcanvas_h);
2186 update_pane_dividers();
2189 resource_thread->start_draw();
2192 void MWindowGUI::update_pane_dividers()
2195 if(horizontal_panes() || total_panes() == 4)
2197 int x = pane[TOP_RIGHT_PANE]->x - mwindow->theme->pane_w;
2198 int y = mwindow->theme->mcanvas_y;
2199 int h = mwindow->theme->mcanvas_h;
2203 add_subwindow(x_divider = new PaneDivider(
2204 mwindow, x, y, h, 1));
2205 x_divider->create_objects();
2209 x_divider->reposition_window(x, y, h);
2222 if(vertical_panes() || total_panes() == 4)
2224 int x = mwindow->theme->mcanvas_x;
2225 int y = pane[BOTTOM_LEFT_PANE]->y -
2226 mwindow->theme->pane_h;
2227 int w = mwindow->theme->mcanvas_w;
2230 add_subwindow(y_divider = new PaneDivider(
2231 mwindow, x, y, w, 0));
2232 y_divider->create_objects();
2236 y_divider->reposition_window(x, y, w);
2250 void MWindowGUI::draw_samplemovement()
2257 update_scrollbars(1);
2260 void MWindowGUI::draw_trackmovement()
2262 update_scrollbars(0);
2270 PaneButton::PaneButton(MWindow *mwindow, int x, int y)
2271 : BC_Button(x, y, mwindow->theme->get_image_set("pane"))
2273 this->mwindow = mwindow;
2276 int PaneButton::cursor_motion_event()
2278 if(get_top_level()->get_button_down() &&
2280 get_status() == BUTTON_DOWNHI &&
2283 // printf("PaneButton::cursor_motion_event %d\n", __LINE__);
2285 if(get_cursor_x() < 0 && !mwindow->gui->dragging_pane)
2287 mwindow->gui->start_x_pane_drag();
2290 if(get_cursor_y() < 0 && !mwindow->gui->dragging_pane)
2292 mwindow->gui->start_y_pane_drag();
2296 mwindow->gui->handle_pane_drag();
2298 int result = BC_Button::cursor_motion_event();
2302 int PaneButton::button_release_event()
2304 mwindow->gui->stop_pane_drag();
2307 int result = BC_Button::button_release_event();