4 * Copyright (C) 1997-2014 Adam Williams <broadcast at earthling dot net>
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 #include "androidcontrol.h"
23 #include "awindowgui.h"
25 #include "bcdisplayinfo.h"
27 #include "bcsignals.h"
29 #include "cwindowgui.h"
31 #include "channelinfo.h"
34 #include "editpopup.h"
37 #include "edlsession.h"
38 #include "filesystem.h"
39 #include "keyframepopup.h"
42 #include "localsession.h"
43 #include "mainclock.h"
44 #include "maincursor.h"
46 #include "mainsession.h"
50 #include "mwindowgui.h"
52 #include "panedividers.h"
55 #include "pluginpopup.h"
56 #include "pluginset.h"
57 #include "preferences.h"
59 #include "recordgui.h"
60 #include "renderengine.h"
61 #include "resourcethread.h"
62 #include "samplescroll.h"
63 #include "shbtnprefs.h"
64 #include "statusbar.h"
67 #include "trackcanvas.h"
68 #include "trackscroll.h"
70 #include "transitionpopup.h"
71 #include "vwindowgui.h"
75 #define PANE_DRAG_MARGIN MAX(mwindow->theme->pane_w, mwindow->theme->pane_h)
78 // the main window uses its own private colormap for video
79 MWindowGUI::MWindowGUI(MWindow *mwindow)
80 : BC_Window(_(PROGRAM_NAME ": Program"),
81 mwindow->session->mwindow_x,
82 mwindow->session->mwindow_y,
83 mwindow->session->mwindow_w,
84 mwindow->session->mwindow_h,
91 this->mwindow = mwindow;
98 focused_pane = TOP_LEFT_PANE;
107 for(int i = 0; i < TOTAL_PANES; i++)
124 cwindow_remote_handler = 0;
125 record_remote_handler = 0;
130 MWindowGUI::~MWindowGUI()
132 delete android_control;
133 delete cwindow_remote_handler;
134 delete record_remote_handler;
135 delete remote_control;
136 // delete samplescroll;
137 // delete trackscroll;
138 for(int i = 0; i < TOTAL_PANES; i++)
139 if(pane[i]) delete pane[i];
141 delete render_engine;
142 delete resource_thread;
143 resource_pixmaps.remove_all_objects();
152 void MWindowGUI::get_scrollbars(int flush)
154 //int64_t h_needed = mwindow->edl->get_tracks_height(mwindow->theme);
155 //int64_t w_needed = mwindow->edl->get_tracks_width();
156 int need_xscroll = 0;
157 int need_yscroll = 0;
158 view_w = mwindow->theme->mcanvas_w;
159 view_h = mwindow->theme->mcanvas_h;
161 // Scrollbars are constitutive
162 need_xscroll = need_yscroll = 1;
163 view_h = mwindow->theme->mcanvas_h;
164 view_w = mwindow->theme->mcanvas_w;
166 // for(int i = 0; i < 2; i++)
168 // if(w_needed > view_w)
171 // view_h = mwindow->theme->mcanvas_h - SCROLL_SPAN;
176 // if(h_needed > view_h)
179 // view_w = mwindow->theme->mcanvas_w - SCROLL_SPAN;
184 //printf("MWindowGUI::get_scrollbars 1\n");
186 if(canvas && (view_w != canvas->get_w() || view_h != canvas->get_h()))
188 canvas->reposition_window(mwindow->theme->mcanvas_x,
189 mwindow->theme->mcanvas_y,
197 add_subwindow(samplescroll = new SampleScroll(mwindow,
199 mwindow->theme->mhscroll_x,
200 mwindow->theme->mhscroll_y,
201 mwindow->theme->mhscroll_w));
203 samplescroll->resize_event();
205 samplescroll->set_position(0);
209 if(samplescroll) delete samplescroll;
211 mwindow->edl->local_session->view_start = 0;
217 //printf("MWindowGUI::get_scrollbars 1.1 %p %p\n", this, canvas);
219 add_subwindow(trackscroll = new TrackScroll(mwindow,
221 mwindow->theme->mvscroll_x,
222 mwindow->theme->mvscroll_y,
223 mwindow->theme->mvscroll_h));
225 trackscroll->resize_event();
228 //printf("MWindowGUI::get_scrollbars 1.2\n");
229 trackscroll->update_length(mwindow->edl->get_tracks_height(mwindow->theme),
230 mwindow->edl->local_session->track_start,
233 //printf("MWindowGUI::get_scrollbars 1.3\n");
237 if(trackscroll) delete trackscroll;
239 mwindow->edl->local_session->track_start = 0;
242 if(flush) this->flush();
247 void MWindowGUI::create_objects()
251 resource_thread = new ResourceThread(mwindow, this);
252 resource_thread->create_objects();
255 if(debug) printf("MWindowGUI::create_objects %d\n", __LINE__);
256 set_icon(mwindow->theme->get_image("mwindow_icon"));
257 remote_control = new RemoteControl(this);
258 cwindow_remote_handler = new CWindowRemoteHandler(remote_control);
259 record_remote_handler = new RecordRemoteHandler(remote_control);
260 mwindow->reset_android_remote();
262 if(debug) printf("MWindowGUI::create_objects %d\n", __LINE__);
264 int x = get_w() - MainShBtns::calculate_w(0);
265 add_subwindow(mainmenu = new MainMenu(mwindow, this, x));
266 mainmenu->create_objects();
267 add_subwindow(mainshbtns = new MainShBtns(mwindow, x, -1));
268 mainshbtns->load(mwindow->preferences);
269 mwindow->theme->get_mwindow_sizes(this, get_w(), get_h());
270 mwindow->theme->draw_mwindow_bg(this);
271 if(debug) printf("MWindowGUI::create_objects %d\n", __LINE__);
273 add_subwindow(mbuttons = new MButtons(mwindow, this));
274 mbuttons->create_objects();
275 add_subwindow(ffmpeg_toggle = new FFMpegToggle(mwindow, mbuttons, menu_w(), menu_h()+2));
277 pane[TOP_LEFT_PANE] = new TimelinePane(mwindow,
279 mwindow->theme->mcanvas_x,
280 mwindow->theme->mcanvas_y,
281 mwindow->theme->mcanvas_w,
282 mwindow->theme->mcanvas_h);
283 pane[TOP_LEFT_PANE]->create_objects();
285 // add_subwindow(timebar = new MTimeBar(mwindow,
287 // mwindow->theme->mtimebar_x,
288 // mwindow->theme->mtimebar_y,
289 // mwindow->theme->mtimebar_w,
290 // mwindow->theme->mtimebar_h));
291 // timebar->create_objects();
293 // if(debug) printf("MWindowGUI::create_objects %d\n", __LINE__);
294 // add_subwindow(patchbay = new PatchBay(mwindow, this));
295 // patchbay->create_objects();
297 // if(debug) printf("MWindowGUI::create_objects %d\n", __LINE__);
298 // get_scrollbars(0);
300 // if(debug) printf("MWindowGUI::create_objects %d\n", __LINE__);
301 // mwindow->gui->add_subwindow(canvas = new TrackCanvas(mwindow, this));
302 // canvas->create_objects();
305 if(debug) printf("MWindowGUI::create_objects %d\n", __LINE__);
306 add_subwindow(zoombar = new ZoomBar(mwindow, this));
307 zoombar->create_objects();
310 if(debug) printf("MWindowGUI::create_objects %d\n", __LINE__);
311 add_subwindow(statusbar = new StatusBar(mwindow, this));
312 statusbar->create_objects();
316 if(debug) printf("MWindowGUI::create_objects %d\n", __LINE__);
317 add_subwindow(mainclock = new MainClock(mwindow,
318 mwindow->theme->mclock_x,
319 mwindow->theme->mclock_y,
320 mwindow->theme->mclock_w));
321 mainclock->set_position_offset( (double)
322 (mwindow->edl->session->get_frame_offset() /
323 mwindow->edl->session->frame_rate));
324 if(debug) printf("MWindowGUI::create_objects %d\n", __LINE__);
325 mainclock->update(0);
329 // if(debug) printf("MWindowGUI::create_objects %d\n", __LINE__);
330 // cursor = new MainCursor(mwindow, this);
331 // cursor->create_objects();
334 if(debug) printf("MWindowGUI::create_objects %d\n", __LINE__);
335 add_subwindow(edit_menu = new EditPopup(mwindow, this));
336 edit_menu->create_objects();
339 if(debug) printf("MWindowGUI::create_objects %d\n", __LINE__);
340 add_subwindow(plugin_menu = new PluginPopup(mwindow, this));
341 plugin_menu->create_objects();
344 if(debug) printf("MWindowGUI::create_objects %d\n", __LINE__);
345 add_subwindow(keyframe_menu = new KeyframePopup(mwindow, this));
346 keyframe_menu->create_objects();
349 if(debug) printf("MWindowGUI::create_objects %d\n", __LINE__);
350 add_subwindow(transition_menu = new TransitionPopup(mwindow, this));
351 transition_menu->create_objects();
353 channel_info = new ChannelInfo(mwindow);
354 db_window = new DbWindow(mwindow);
355 swindow = new SWindow(mwindow);
357 if(debug) printf("MWindowGUI::create_objects %d\n", __LINE__);
359 add_subwindow(pane_button = new PaneButton(mwindow,
360 get_w() - mwindow->theme->get_image_set("pane")[0]->get_w(),
361 mwindow->theme->mzoom_y + 1 - mwindow->theme->get_image_set("pane")[0]->get_h()));
363 pane[TOP_LEFT_PANE]->canvas->activate();
365 if(debug) printf("MWindowGUI::create_objects %d\n", __LINE__);
368 void MWindowGUI::redraw_time_dependancies()
370 zoombar->redraw_time_dependancies();
371 for(int i = 0; i < TOTAL_PANES; i++)
372 if(pane[i] && pane[i]->timebar) pane[i]->timebar->update(0);
373 mainclock->update(mwindow->edl->local_session->get_selectionstart(1));
376 int MWindowGUI::focus_in_event()
378 for(int i = 0; i < TOTAL_PANES; i++)
379 if(pane[i]) pane[i]->cursor->focus_in_event();
383 int MWindowGUI::focus_out_event()
385 for(int i = 0; i < TOTAL_PANES; i++)
386 if(pane[i]) pane[i]->cursor->focus_out_event();
391 int MWindowGUI::resize_event(int w, int h)
393 //printf("MWindowGUI::resize_event %d\n", __LINE__);
394 mwindow->session->mwindow_w = w;
395 mwindow->session->mwindow_h = h;
396 int x = w - MainShBtns::calculate_w(0);
397 mainmenu->resize_event(x, mainmenu->get_h());
398 mainshbtns->reposition_window(x, -1);
399 mwindow->theme->get_mwindow_sizes(this, w, h);
400 mwindow->theme->draw_mwindow_bg(this);
401 mbuttons->resize_event();
402 ffmpeg_toggle->reposition_window(menu_w(), menu_h()+2);
403 statusbar->resize_event();
405 resource_thread->stop_draw(1);
407 if(total_panes() > 1)
409 if(horizontal_panes())
411 // printf("MWindowGUI::resize_event %d %d %d\n",
413 // pane[TOP_RIGHT_PANE]->x,
414 // mwindow->theme->mcanvas_w -
415 // BC_ScrollBar::get_span(SCROLL_VERT) -
416 // PANE_DRAG_MARGIN);
417 if(pane[TOP_RIGHT_PANE]->x >= mwindow->theme->mcanvas_w -
418 BC_ScrollBar::get_span(SCROLL_VERT) -
421 delete_x_pane(pane[TOP_RIGHT_PANE]->x);
422 mwindow->edl->local_session->x_pane = -1;
428 if(pane[BOTTOM_LEFT_PANE]->y >= mwindow->theme->mzoom_y -
429 BC_ScrollBar::get_span(SCROLL_HORIZ) -
432 delete_y_pane(pane[BOTTOM_LEFT_PANE]->y);
433 mwindow->edl->local_session->y_pane = -1;
438 if(pane[TOP_RIGHT_PANE]->x >= mwindow->theme->mcanvas_w -
439 BC_ScrollBar::get_span(SCROLL_VERT) -
442 delete_x_pane(pane[TOP_RIGHT_PANE]->x);
443 mwindow->edl->local_session->x_pane = -1;
446 if(pane[BOTTOM_LEFT_PANE]->y >= mwindow->theme->mzoom_y -
447 BC_ScrollBar::get_span(SCROLL_HORIZ) -
450 delete_y_pane(pane[BOTTOM_LEFT_PANE]->y);
451 mwindow->edl->local_session->y_pane = -1;
456 if(total_panes() == 1)
458 pane[TOP_LEFT_PANE]->resize_event(
459 mwindow->theme->mcanvas_x,
460 mwindow->theme->mcanvas_y,
461 mwindow->theme->mcanvas_w,
462 mwindow->theme->mcanvas_h);
465 if(horizontal_panes())
467 pane[TOP_LEFT_PANE]->resize_event(
468 pane[TOP_LEFT_PANE]->x,
469 pane[TOP_LEFT_PANE]->y,
470 pane[TOP_LEFT_PANE]->w,
471 mwindow->theme->mcanvas_h);
472 pane[TOP_RIGHT_PANE]->resize_event(
473 pane[TOP_RIGHT_PANE]->x,
474 pane[TOP_RIGHT_PANE]->y,
475 mwindow->theme->mcanvas_w - pane[TOP_RIGHT_PANE]->x,
476 mwindow->theme->mcanvas_h);
481 pane[TOP_LEFT_PANE]->resize_event(
482 pane[TOP_LEFT_PANE]->x,
483 pane[TOP_LEFT_PANE]->y,
484 mwindow->theme->mcanvas_w,
485 pane[TOP_LEFT_PANE]->h);
486 pane[BOTTOM_LEFT_PANE]->resize_event(
487 pane[BOTTOM_LEFT_PANE]->x,
488 pane[BOTTOM_LEFT_PANE]->y,
489 mwindow->theme->mcanvas_w,
490 mwindow->theme->mcanvas_y +
491 mwindow->theme->mcanvas_h -
492 pane[BOTTOM_LEFT_PANE]->y);
496 pane[TOP_LEFT_PANE]->resize_event(
497 pane[TOP_LEFT_PANE]->x,
498 pane[TOP_LEFT_PANE]->y,
499 pane[TOP_LEFT_PANE]->w,
500 pane[TOP_LEFT_PANE]->h);
501 pane[TOP_RIGHT_PANE]->resize_event(
502 pane[TOP_RIGHT_PANE]->x,
503 pane[TOP_RIGHT_PANE]->y,
504 mwindow->theme->mcanvas_w - pane[TOP_RIGHT_PANE]->x,
505 pane[TOP_RIGHT_PANE]->h);
506 pane[BOTTOM_LEFT_PANE]->resize_event(
507 pane[BOTTOM_LEFT_PANE]->x,
508 pane[BOTTOM_LEFT_PANE]->y,
509 pane[BOTTOM_LEFT_PANE]->w,
510 mwindow->theme->mcanvas_y +
511 mwindow->theme->mcanvas_h -
512 pane[BOTTOM_LEFT_PANE]->y);
513 pane[BOTTOM_RIGHT_PANE]->resize_event(
514 pane[BOTTOM_RIGHT_PANE]->x,
515 pane[BOTTOM_RIGHT_PANE]->y,
516 mwindow->theme->mcanvas_w -
517 pane[BOTTOM_RIGHT_PANE]->x,
518 mwindow->theme->mcanvas_y +
519 mwindow->theme->mcanvas_h -
520 pane[BOTTOM_RIGHT_PANE]->y);
523 resource_thread->start_draw();
525 update_pane_dividers();
526 zoombar->resize_event();
527 pane_button->reposition_window(w - mwindow->theme->get_image_set("pane")[0]->get_w(),
528 mwindow->theme->mzoom_y + 1 - mwindow->theme->get_image_set("pane")[0]->get_h());
529 // get_scrollbars(0);
530 // canvas->resize_event();
531 //printf("MWindowGUI::resize_event %d\n", __LINE__);
532 // required to get new widgets to appear after a pane deletion
537 int MWindowGUI::total_panes()
540 for(int i = 0; i < TOTAL_PANES; i++)
545 int MWindowGUI::vertical_panes()
547 return total_panes() == 2 &&
548 pane[TOP_LEFT_PANE] &&
549 pane[BOTTOM_LEFT_PANE];
552 int MWindowGUI::horizontal_panes()
554 return total_panes() == 2 &&
555 pane[TOP_LEFT_PANE] &&
556 pane[TOP_RIGHT_PANE];
559 TimelinePane* MWindowGUI::get_focused_pane()
561 if(pane[focused_pane]) return pane[focused_pane];
562 for(int i = 0; i < TOTAL_PANES; i++)
564 if(pane[i]) return pane[i];
569 void MWindowGUI::activate_timeline()
571 if(pane[focused_pane])
573 pane[focused_pane]->activate();
577 for(int i = 0; i < TOTAL_PANES; i++)
588 void MWindowGUI::deactivate_timeline()
590 for(int i = 0; i < TOTAL_PANES; i++)
594 pane[i]->canvas->deactivate();
599 void MWindowGUI::update_title(char *path)
602 char filename[BCTEXTLEN], string[BCTEXTLEN];
603 fs.extract_name(filename, path);
604 sprintf(string, _(PROGRAM_NAME ": %s"), filename);
606 //printf("MWindowGUI::update_title %s\n", string);
610 void MWindowGUI::draw_overlays(int flash_it)
612 for(int i = 0; i < TOTAL_PANES; i++)
616 pane[i]->canvas->draw_overlays();
617 if(flash_it) pane[i]->canvas->flash();
622 void MWindowGUI::update_timebar(int flush_it)
624 for(int i = 0; i < TOTAL_PANES; i++)
626 if(pane[i] && pane[i]->timebar)
628 pane[i]->timebar->update(flush_it);
633 void MWindowGUI::update_timebar_highlights()
635 for(int i = 0; i < TOTAL_PANES; i++)
637 if(pane[i] && pane[i]->timebar)
639 pane[i]->timebar->update_highlights();
645 void MWindowGUI::update_patchbay()
647 for(int i = 0; i < TOTAL_PANES; i++)
649 if(pane[i] && pane[i]->patchbay)
651 pane[i]->patchbay->update();
656 void MWindowGUI::draw_indexes(Indexable *indexable)
658 for(int i = 0; i < TOTAL_PANES; i++)
662 pane[i]->canvas->draw_indexes(indexable);
667 void MWindowGUI::draw_canvas(int mode /* = 0 */, int hide_cursor /* = 1 */)
669 if(mode != IGNORE_THREAD)
671 resource_thread->stop_draw(1);
675 for(int i = 0; i < TOTAL_PANES; i++)
679 pane[i]->canvas->draw(mode, hide_cursor);
684 if(mode != IGNORE_THREAD)
686 resource_thread->start_draw();
691 void MWindowGUI::flash_canvas(int flush)
693 for(int i = 0; i < TOTAL_PANES; i++)
697 pane[i]->canvas->flash(flush);
702 void MWindowGUI::draw_cursor(int do_plugintoggles)
704 for(int i = 0; i < TOTAL_PANES; i++)
708 pane[i]->cursor->draw(do_plugintoggles);
713 void MWindowGUI::show_cursor(int do_plugintoggles)
715 for(int i = 0; i < TOTAL_PANES; i++)
719 pane[i]->cursor->show(do_plugintoggles);
724 void MWindowGUI::hide_cursor(int do_plugintoggles)
726 for(int i = 0; i < TOTAL_PANES; i++)
730 pane[i]->cursor->hide(do_plugintoggles);
735 void MWindowGUI::update_cursor()
737 for(int i = 0; i < TOTAL_PANES; i++)
741 pane[i]->cursor->update();
746 void MWindowGUI::set_playing_back(int value)
748 for(int i = 0; i < TOTAL_PANES; i++)
752 pane[i]->cursor->playing_back = value;
757 void MWindowGUI::update_plugintoggles()
759 for(int i = 0; i < TOTAL_PANES; i++)
763 pane[i]->canvas->refresh_plugintoggles();
769 void MWindowGUI::update_scrollbars(int flush)
771 for(int i = 0; i < TOTAL_PANES; i++)
775 pane[i]->update(1, 0, 0, 0);
778 if(flush) this->flush();
781 void MWindowGUI::reset_meters()
783 for(int i = 0; i < TOTAL_PANES; i++)
785 if(pane[i] && pane[i]->patchbay)
787 pane[i]->patchbay->reset_meters();
792 void MWindowGUI::stop_meters()
794 for(int i = 0; i < TOTAL_PANES; i++)
796 if(pane[i] && pane[i]->patchbay)
798 pane[i]->patchbay->stop_meters();
803 void MWindowGUI::update_meters(ArrayList<double> *module_levels)
805 for(int i = 0; i < TOTAL_PANES; i++)
807 if(pane[i] && pane[i]->patchbay)
809 pane[i]->patchbay->update_meters(module_levels);
814 void MWindowGUI::set_editing_mode(int flush)
816 for(int i = 0; i < TOTAL_PANES; i++)
820 pane[i]->canvas->update_cursor(flush);
825 void MWindowGUI::set_meter_format(int mode, int min, int max)
827 for(int i = 0; i < TOTAL_PANES; i++)
829 if(pane[i] && pane[i]->patchbay)
831 pane[i]->patchbay->set_meter_format(mode, min, max);
836 void MWindowGUI::update(int scrollbars,
845 if(debug) PRINT_TRACE
849 mwindow->edl->tracks->update_y_pixels(mwindow->theme);
851 if(do_canvas && do_canvas != IGNORE_THREAD)
853 resource_thread->stop_draw(1);
856 for(int i = 0; i < TOTAL_PANES; i++)
858 if(pane[i]) pane[i]->update(scrollbars,
864 if(do_canvas && do_canvas != IGNORE_THREAD)
866 resource_thread->start_draw();
869 // if(scrollbars) this->get_scrollbars(0);
870 // if(timebar) this->timebar->update(0);
871 if(zoombar) this->zoombar->update();
872 // if(patchbay) this->patchbay->update();
873 if(clock) this->mainclock->update(
874 mwindow->edl->local_session->get_selectionstart(1));
875 if(debug) PRINT_TRACE
881 // this->canvas->draw(do_canvas);
882 // this->cursor->show();
883 // this->canvas->flash(0);
884 // Activate causes the menubar to deactivate. Don't want this for
886 // if(canvas != IGNORE_THREAD) this->canvas->activate();
888 if(debug) PRINT_TRACE
892 if(buttonbar) mbuttons->update();
893 if(debug) PRINT_TRACE
895 // Can't age if the cache called this to draw missing picons
896 // or the GUI is updating the status of the draw toggle.
897 if(do_canvas != FORCE_REDRAW && do_canvas != IGNORE_THREAD)
900 mwindow->age_caches();
901 lock_window("MWindowGUI::update");
905 if(debug) PRINT_TRACE
908 int MWindowGUI::visible(int64_t x1, int64_t x2, int64_t view_x1, int64_t view_x2)
910 return (x1 >= view_x1 && x1 < view_x2) ||
911 (x2 > view_x1 && x2 <= view_x2) ||
912 (x1 <= view_x1 && x2 >= view_x2);
916 int MWindowGUI::show_message(char *message, int color)
918 // printf("MWindowGUI::show_message %d: %s 0x%08x 0x%08x\n",
919 // __LINE__, message, color, mwindow->theme->message_normal);
920 if(color < 0) color = mwindow->theme->message_normal;
921 statusbar->status_text->set_color(color);
922 statusbar->status_text->update(message);
927 // Drag motion called from other window
928 int MWindowGUI::drag_motion()
930 if(get_hidden()) return 0;
932 Track *over_track = 0;
934 PluginSet *over_pluginset = 0;
935 Plugin *over_plugin = 0;
940 drag_popup->cursor_motion_event();
944 // there's no point in drawing highlights has until drag operation has been set
945 if (!mwindow->session->current_operation)
948 for(int i = 0; i < TOTAL_PANES; i++)
950 if(pane[i]) pane[i]->canvas->drag_motion(
957 if(mwindow->session->track_highlighted != over_track)
959 mwindow->session->track_highlighted = over_track;
963 if(mwindow->session->edit_highlighted != over_edit)
965 mwindow->session->edit_highlighted = over_edit;
969 if(mwindow->session->pluginset_highlighted != over_pluginset)
971 mwindow->session->pluginset_highlighted = over_pluginset;
975 if(mwindow->session->plugin_highlighted != over_plugin)
977 mwindow->session->plugin_highlighted = over_plugin;
981 if( mwindow->session->current_operation == DRAG_ASSET ||
982 mwindow->session->current_operation == DRAG_EDIT ||
983 mwindow->session->current_operation == DRAG_AEFFECT_COPY ||
984 mwindow->session->current_operation == DRAG_VEFFECT_COPY )
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())
1165 mwindow->toggle_editing_mode();
1168 case '1': case '2': case '3': case '4':
1169 case '5': case '6': case '7': case '8':
1170 if( !alt_down() || shift_down() ) break;
1171 if( !mwindow->select_asset(get_keypress()-'1',1) )
1180 mbuttons->transport->handle_transport(STOP, 1, 0, 0);
1181 lock_window("MWindowGUI::keypress_event 1");
1182 mwindow->prev_edit_handle(shift_down());
1185 mwindow->move_left();
1195 mbuttons->transport->handle_transport(STOP, 1, 0, 0);
1196 lock_window("MWindowGUI::keypress_event 2");
1197 mwindow->next_edit_handle(shift_down());
1200 mwindow->move_right();
1206 if(ctrl_down() && !alt_down())
1208 mwindow->expand_y();
1212 if(!ctrl_down() && alt_down())
1214 mwindow->expand_autos(0,1,1);
1218 if(ctrl_down() && alt_down())
1220 mwindow->expand_autos(1,1,1);
1225 mwindow->expand_sample();
1231 if(ctrl_down() && !alt_down())
1233 mwindow->zoom_in_y();
1237 if(!ctrl_down() && alt_down())
1239 mwindow->shrink_autos(0,1,1);
1243 if(ctrl_down() && alt_down())
1245 mwindow->shrink_autos(1,1,1);
1250 mwindow->zoom_in_sample();
1263 mwindow->expand_t();
1271 mwindow->move_down();
1276 mwindow->zoom_in_t();
1283 // //int cursor_x = 0;
1284 // int cursor_y = 0;
1285 // for(int i = 0; i < TOTAL_PANES; i++)
1289 // //cursor_x = pane[i]->canvas->get_relative_cursor_x();
1290 // cursor_y = pane[i]->canvas->get_relative_cursor_y();
1295 // if(get_keypress() == TAB)
1297 // // Switch the record button
1298 // for(Track *track = mwindow->edl->tracks->first; track; track = track->next)
1300 // int64_t track_x, track_y, track_w, track_h;
1301 // canvas->track_dimensions(track, track_x, track_y, track_w, track_h);
1303 // if(cursor_y >= track_y &&
1304 // cursor_y < track_y + track_h)
1306 // if (track->record)
1307 // track->record = 0;
1309 // track->record = 1;
1317 // Track *this_track = 0;
1318 // for(Track *track = mwindow->edl->tracks->first; track; track = track->next)
1320 // int64_t track_x, track_y, track_w, track_h;
1321 // canvas->track_dimensions(track, track_x, track_y, track_w, track_h);
1323 // if(cursor_y >= track_y &&
1324 // cursor_y < track_y + track_h)
1326 // // This is our track
1327 // this_track = track;
1332 // int total_selected = mwindow->edl->tracks->total_of(Tracks::RECORD);
1334 // // nothing previously selected
1335 // if(total_selected == 0)
1337 // mwindow->edl->tracks->select_all(Tracks::RECORD,
1341 // if(total_selected == 1)
1343 // // this patch was previously the only one on
1344 // if(this_track && this_track->record)
1346 // mwindow->edl->tracks->select_all(Tracks::RECORD,
1349 // // another patch was previously the only one on
1352 // mwindow->edl->tracks->select_all(Tracks::RECORD,
1355 // this_track->record = 1;
1360 // if(total_selected > 1)
1362 // mwindow->edl->tracks->select_all(Tracks::RECORD,
1365 // this_track->record = 1;
1378 // mwindow->cwindow->update(0, 1, 1);
1379 // lock_window("TrackCanvas::keypress_event 3");
1385 // since things under cursor have changed...
1387 cursor_motion_event();
1394 int MWindowGUI::keyboard_listener(BC_WindowBase *wp)
1396 return keyboard_listener(wp->get_keypress());
1399 int MWindowGUI::keyboard_listener(int key)
1404 if( !record->running() )
1407 record->record_gui->interrupt_thread->start(0);
1413 channel_info->toggle_scan();
1416 if( !remote_control->deactivate() )
1417 remote_control->activate();
1427 void MWindowGUI::use_android_remote(int on)
1430 delete android_control;
1431 android_control = 0;
1434 if( android_control ) return;
1435 android_control = new AndroidControl(this);
1438 int MWindowGUI::close_event()
1444 void MWindowGUI::stop_drawing()
1446 resource_thread->stop_draw(1);
1449 int MWindowGUI::menu_w()
1451 return mainmenu->get_w();
1454 int MWindowGUI::menu_h()
1456 return mainmenu->get_h();
1459 void MWindowGUI::start_x_pane_drag()
1463 x_pane_drag = new BC_Popup(this,
1464 get_abs_cursor_x(0) - mwindow->theme->pane_w,
1465 BC_DisplayInfo::get_top_border() +
1467 mwindow->theme->mcanvas_y,
1468 mwindow->theme->pane_w,
1469 mwindow->theme->mcanvas_h,
1470 mwindow->theme->drag_pane_color);
1471 x_pane_drag->draw_3segmentv(0,
1473 x_pane_drag->get_h(),
1474 mwindow->theme->get_image_set("xpane")[BUTTON_DOWNHI]);
1475 x_pane_drag->flash(1);
1480 void MWindowGUI::start_y_pane_drag()
1484 //printf("MWindowGUI::start_y_pane_drag %d %d %d\n", __LINE__, get_x(), get_y());
1485 y_pane_drag = new BC_Popup(this,
1486 BC_DisplayInfo::get_left_border() +
1488 mwindow->theme->mcanvas_x,
1489 get_abs_cursor_y(0) - mwindow->theme->pane_h,
1490 mwindow->theme->mcanvas_w,
1491 mwindow->theme->pane_h,
1492 mwindow->theme->drag_pane_color);
1493 y_pane_drag->draw_3segmenth(0,
1495 y_pane_drag->get_w(),
1496 mwindow->theme->get_image_set("ypane")[BUTTON_DOWNHI]);
1497 y_pane_drag->flash(1);
1502 void MWindowGUI::handle_pane_drag()
1508 x_pane_drag->reposition_window(
1509 get_abs_cursor_x(0) - mwindow->theme->pane_w,
1510 x_pane_drag->get_y());
1515 y_pane_drag->reposition_window(
1516 y_pane_drag->get_x(),
1517 get_abs_cursor_y(0) - mwindow->theme->pane_h);
1523 void MWindowGUI::create_x_pane(int cursor_x)
1525 if(total_panes() == 1)
1527 // create a horizontal pane
1528 // do this 1st so the resize_event knows there are 2 panes
1529 mwindow->edl->local_session->view_start[TOP_RIGHT_PANE] =
1530 mwindow->edl->local_session->view_start[TOP_LEFT_PANE] +
1532 mwindow->theme->patchbay_w;
1533 pane[TOP_RIGHT_PANE] = new TimelinePane(mwindow,
1535 mwindow->theme->mcanvas_x +
1537 mwindow->theme->mcanvas_y,
1538 mwindow->theme->mcanvas_x +
1539 mwindow->theme->mcanvas_w -
1541 mwindow->theme->mcanvas_h);
1542 pane[TOP_LEFT_PANE]->resize_event(
1543 mwindow->theme->mcanvas_x,
1544 mwindow->theme->mcanvas_y,
1545 cursor_x - mwindow->theme->pane_w,
1546 mwindow->theme->mcanvas_h);
1547 pane[TOP_RIGHT_PANE]->create_objects();
1550 if(vertical_panes())
1552 // create 2 horizontal panes
1553 mwindow->edl->local_session->track_start[TOP_RIGHT_PANE] =
1554 mwindow->edl->local_session->track_start[TOP_LEFT_PANE];
1555 mwindow->edl->local_session->track_start[BOTTOM_RIGHT_PANE] =
1556 mwindow->edl->local_session->track_start[BOTTOM_LEFT_PANE];
1557 mwindow->edl->local_session->view_start[TOP_RIGHT_PANE] =
1558 mwindow->edl->local_session->view_start[BOTTOM_RIGHT_PANE] =
1559 mwindow->edl->local_session->view_start[TOP_LEFT_PANE] +
1561 mwindow->theme->patchbay_w;
1562 pane[TOP_RIGHT_PANE] = new TimelinePane(mwindow,
1564 mwindow->theme->mcanvas_x +
1566 pane[TOP_LEFT_PANE]->y,
1567 mwindow->theme->mcanvas_x +
1568 mwindow->theme->mcanvas_w -
1570 pane[TOP_LEFT_PANE]->h);
1571 pane[BOTTOM_RIGHT_PANE] = new TimelinePane(mwindow,
1573 mwindow->theme->mcanvas_x +
1575 pane[BOTTOM_LEFT_PANE]->y,
1576 mwindow->theme->mcanvas_x +
1577 mwindow->theme->mcanvas_w -
1579 pane[BOTTOM_LEFT_PANE]->h);
1580 pane[TOP_LEFT_PANE]->resize_event(
1581 pane[TOP_LEFT_PANE]->x,
1582 pane[TOP_LEFT_PANE]->y,
1583 cursor_x - mwindow->theme->pane_w,
1584 pane[TOP_LEFT_PANE]->h);
1585 pane[BOTTOM_LEFT_PANE]->resize_event(
1586 pane[BOTTOM_LEFT_PANE]->x,
1587 pane[BOTTOM_LEFT_PANE]->y,
1588 cursor_x - mwindow->theme->pane_w,
1589 pane[BOTTOM_LEFT_PANE]->h);
1590 pane[TOP_RIGHT_PANE]->create_objects();
1591 pane[BOTTOM_RIGHT_PANE]->create_objects();
1594 if(horizontal_panes())
1596 // resize a horizontal pane
1597 mwindow->edl->local_session->view_start[TOP_RIGHT_PANE] +=
1599 pane[TOP_RIGHT_PANE]->x;
1600 if(mwindow->edl->local_session->view_start[TOP_RIGHT_PANE] < 0)
1601 mwindow->edl->local_session->view_start[TOP_RIGHT_PANE] = 0;
1602 pane[TOP_LEFT_PANE]->resize_event(
1603 mwindow->theme->mcanvas_x,
1604 mwindow->theme->mcanvas_y,
1605 cursor_x - mwindow->theme->pane_w,
1606 mwindow->theme->mcanvas_h);
1607 pane[TOP_RIGHT_PANE]->resize_event(
1608 mwindow->theme->mcanvas_x +
1610 pane[TOP_RIGHT_PANE]->y,
1611 mwindow->theme->mcanvas_x +
1612 mwindow->theme->mcanvas_w -
1614 mwindow->theme->mcanvas_h);
1618 // resize 2 horizontal panes
1619 mwindow->edl->local_session->view_start[TOP_RIGHT_PANE] +=
1621 pane[TOP_RIGHT_PANE]->x;
1622 if(mwindow->edl->local_session->view_start[TOP_RIGHT_PANE] < 0)
1623 mwindow->edl->local_session->view_start[TOP_RIGHT_PANE] = 0;
1624 mwindow->edl->local_session->view_start[BOTTOM_RIGHT_PANE] =
1625 mwindow->edl->local_session->view_start[TOP_RIGHT_PANE];
1627 pane[TOP_LEFT_PANE]->resize_event(
1628 mwindow->theme->mcanvas_x,
1629 pane[TOP_LEFT_PANE]->y,
1630 cursor_x - mwindow->theme->pane_w,
1631 pane[TOP_LEFT_PANE]->h);
1632 pane[TOP_RIGHT_PANE]->resize_event(
1633 mwindow->theme->mcanvas_x +
1635 pane[TOP_RIGHT_PANE]->y,
1636 mwindow->theme->mcanvas_x +
1637 mwindow->theme->mcanvas_w -
1639 pane[TOP_RIGHT_PANE]->h);
1640 pane[BOTTOM_LEFT_PANE]->resize_event(
1641 mwindow->theme->mcanvas_x,
1642 pane[BOTTOM_LEFT_PANE]->y,
1643 cursor_x - mwindow->theme->pane_w,
1644 pane[BOTTOM_LEFT_PANE]->h);
1645 pane[BOTTOM_RIGHT_PANE]->resize_event(
1646 mwindow->theme->mcanvas_x +
1648 pane[BOTTOM_RIGHT_PANE]->y,
1649 mwindow->theme->mcanvas_x +
1650 mwindow->theme->mcanvas_w -
1652 pane[BOTTOM_RIGHT_PANE]->h);
1658 void MWindowGUI::delete_x_pane(int cursor_x)
1660 // give left panes coordinates of right pane
1661 if(cursor_x < mwindow->theme->patchbay_w + PANE_DRAG_MARGIN &&
1662 pane[TOP_RIGHT_PANE])
1664 mwindow->edl->local_session->view_start[TOP_LEFT_PANE] =
1665 mwindow->edl->local_session->view_start[TOP_RIGHT_PANE] -
1666 pane[TOP_RIGHT_PANE]->x + mwindow->theme->patchbay_w;
1667 if(mwindow->edl->local_session->view_start[TOP_LEFT_PANE] < 0)
1668 mwindow->edl->local_session->view_start[TOP_LEFT_PANE] = 0;
1669 mwindow->edl->local_session->view_start[BOTTOM_LEFT_PANE] =
1670 mwindow->edl->local_session->view_start[TOP_LEFT_PANE];
1673 switch(total_panes())
1676 if(pane[TOP_LEFT_PANE] && pane[TOP_RIGHT_PANE])
1678 // delete right pane
1679 delete pane[TOP_RIGHT_PANE];
1680 pane[TOP_RIGHT_PANE] = 0;
1681 pane[TOP_LEFT_PANE]->resize_event(
1682 mwindow->theme->mcanvas_x,
1683 mwindow->theme->mcanvas_y,
1684 mwindow->theme->mcanvas_w,
1685 mwindow->theme->mcanvas_h);
1691 // delete right panes
1692 delete pane[TOP_RIGHT_PANE];
1693 pane[TOP_RIGHT_PANE] = 0;
1694 delete pane[BOTTOM_RIGHT_PANE];
1695 pane[BOTTOM_RIGHT_PANE] = 0;
1696 pane[TOP_LEFT_PANE]->resize_event(
1697 mwindow->theme->mcanvas_x,
1698 pane[TOP_LEFT_PANE]->y,
1699 mwindow->theme->mcanvas_w,
1700 pane[TOP_LEFT_PANE]->h);
1701 pane[BOTTOM_LEFT_PANE]->resize_event(
1702 mwindow->theme->mcanvas_x,
1703 pane[BOTTOM_LEFT_PANE]->y,
1704 mwindow->theme->mcanvas_w,
1705 pane[BOTTOM_LEFT_PANE]->h);
1710 void MWindowGUI::create_y_pane(int cursor_y)
1712 if(total_panes() == 1)
1714 mwindow->edl->local_session->view_start[BOTTOM_LEFT_PANE] =
1715 mwindow->edl->local_session->view_start[TOP_LEFT_PANE];
1716 mwindow->edl->local_session->track_start[BOTTOM_LEFT_PANE] =
1717 mwindow->edl->local_session->track_start[TOP_LEFT_PANE] +
1719 mwindow->theme->mtimebar_h;
1720 // do this 1st so the resize_event knows there are 2 panes
1721 pane[BOTTOM_LEFT_PANE] = new TimelinePane(mwindow,
1723 mwindow->theme->mcanvas_x,
1724 mwindow->theme->mcanvas_y +
1726 mwindow->theme->mcanvas_w,
1727 mwindow->theme->mcanvas_h -
1729 pane[TOP_LEFT_PANE]->resize_event(
1730 mwindow->theme->mcanvas_x,
1731 mwindow->theme->mcanvas_y,
1732 mwindow->theme->mcanvas_w,
1733 pane[BOTTOM_LEFT_PANE]->y -
1734 mwindow->theme->mcanvas_y -
1735 mwindow->theme->pane_h);
1736 pane[BOTTOM_LEFT_PANE]->create_objects();
1739 if(horizontal_panes())
1742 mwindow->edl->local_session->view_start[BOTTOM_LEFT_PANE] =
1743 mwindow->edl->local_session->view_start[TOP_LEFT_PANE];
1744 mwindow->edl->local_session->view_start[BOTTOM_RIGHT_PANE] =
1745 mwindow->edl->local_session->view_start[TOP_RIGHT_PANE];
1746 mwindow->edl->local_session->track_start[BOTTOM_LEFT_PANE] =
1747 mwindow->edl->local_session->track_start[BOTTOM_RIGHT_PANE] =
1748 mwindow->edl->local_session->track_start[TOP_LEFT_PANE] +
1750 mwindow->theme->mtimebar_h;
1752 pane[BOTTOM_LEFT_PANE] = new TimelinePane(mwindow,
1754 pane[TOP_LEFT_PANE]->x,
1755 mwindow->theme->mcanvas_y +
1757 pane[TOP_LEFT_PANE]->w,
1758 mwindow->theme->mcanvas_h -
1760 pane[BOTTOM_RIGHT_PANE] = new TimelinePane(mwindow,
1762 pane[TOP_RIGHT_PANE]->x,
1763 mwindow->theme->mcanvas_y +
1765 pane[TOP_RIGHT_PANE]->w,
1766 mwindow->theme->mcanvas_h -
1769 pane[TOP_LEFT_PANE]->resize_event(
1770 pane[TOP_LEFT_PANE]->x,
1771 pane[TOP_LEFT_PANE]->y,
1772 pane[TOP_LEFT_PANE]->w,
1773 pane[BOTTOM_LEFT_PANE]->y -
1774 mwindow->theme->mcanvas_y -
1775 mwindow->theme->pane_h);
1776 pane[TOP_RIGHT_PANE]->resize_event(
1777 pane[TOP_RIGHT_PANE]->x,
1778 pane[TOP_RIGHT_PANE]->y,
1779 pane[TOP_RIGHT_PANE]->w,
1780 pane[BOTTOM_RIGHT_PANE]->y -
1781 mwindow->theme->mcanvas_y -
1782 mwindow->theme->pane_h);
1784 pane[BOTTOM_LEFT_PANE]->create_objects();
1785 pane[BOTTOM_RIGHT_PANE]->create_objects();
1788 if(vertical_panes())
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 pane[TOP_LEFT_PANE]->resize_event(
1797 mwindow->theme->mcanvas_x,
1798 mwindow->theme->mcanvas_y,
1799 mwindow->theme->mcanvas_w,
1800 cursor_y - mwindow->theme->pane_h);
1801 pane[BOTTOM_LEFT_PANE]->resize_event(
1802 pane[BOTTOM_LEFT_PANE]->x,
1804 mwindow->theme->mcanvas_y,
1805 mwindow->theme->mcanvas_w,
1806 mwindow->theme->mcanvas_h -
1812 mwindow->edl->local_session->track_start[BOTTOM_LEFT_PANE] +=
1814 (pane[BOTTOM_LEFT_PANE]->y - mwindow->theme->mcanvas_y);
1815 if(mwindow->edl->local_session->track_start[BOTTOM_LEFT_PANE] < 0)
1816 mwindow->edl->local_session->track_start[BOTTOM_LEFT_PANE] = 0;
1817 mwindow->edl->local_session->track_start[BOTTOM_RIGHT_PANE] =
1818 mwindow->edl->local_session->track_start[BOTTOM_LEFT_PANE];
1819 pane[TOP_LEFT_PANE]->resize_event(
1820 pane[TOP_LEFT_PANE]->x,
1821 pane[TOP_LEFT_PANE]->y,
1822 pane[TOP_LEFT_PANE]->w,
1823 cursor_y - mwindow->theme->pane_h);
1824 pane[BOTTOM_LEFT_PANE]->resize_event(
1825 pane[BOTTOM_LEFT_PANE]->x,
1827 mwindow->theme->mcanvas_y,
1828 pane[BOTTOM_LEFT_PANE]->w,
1829 mwindow->theme->mcanvas_h -
1831 pane[TOP_RIGHT_PANE]->resize_event(
1832 pane[TOP_RIGHT_PANE]->x,
1833 pane[TOP_RIGHT_PANE]->y,
1834 pane[TOP_RIGHT_PANE]->w,
1835 cursor_y - mwindow->theme->pane_h);
1836 pane[BOTTOM_RIGHT_PANE]->resize_event(
1837 pane[BOTTOM_RIGHT_PANE]->x,
1839 mwindow->theme->mcanvas_y,
1840 pane[BOTTOM_RIGHT_PANE]->w,
1841 mwindow->theme->mcanvas_h -
1846 void MWindowGUI::delete_y_pane(int cursor_y)
1848 if(cursor_y < mwindow->theme->mtimebar_h +
1850 pane[BOTTOM_LEFT_PANE])
1852 // give top pane coordinates of bottom pane
1853 mwindow->edl->local_session->track_start[TOP_LEFT_PANE] =
1854 mwindow->edl->local_session->track_start[BOTTOM_LEFT_PANE] -
1855 pane[BOTTOM_LEFT_PANE]->y;
1856 if(mwindow->edl->local_session->track_start[TOP_LEFT_PANE] < 0)
1857 mwindow->edl->local_session->track_start[TOP_LEFT_PANE] = 0;
1858 mwindow->edl->local_session->track_start[TOP_RIGHT_PANE] =
1859 mwindow->edl->local_session->track_start[TOP_LEFT_PANE];
1863 switch(total_panes())
1866 delete pane[BOTTOM_LEFT_PANE];
1867 pane[BOTTOM_LEFT_PANE] = 0;
1868 pane[TOP_LEFT_PANE]->resize_event(
1869 mwindow->theme->mcanvas_x,
1870 mwindow->theme->mcanvas_y,
1871 mwindow->theme->mcanvas_w,
1872 mwindow->theme->mcanvas_h);
1876 // delete bottom 2 panes
1878 delete pane[BOTTOM_LEFT_PANE];
1879 pane[BOTTOM_LEFT_PANE] = 0;
1880 delete pane[BOTTOM_RIGHT_PANE];
1881 pane[BOTTOM_RIGHT_PANE] = 0;
1882 pane[TOP_LEFT_PANE]->resize_event(
1883 pane[TOP_LEFT_PANE]->x,
1884 mwindow->theme->mcanvas_y,
1885 pane[TOP_LEFT_PANE]->w,
1886 mwindow->theme->mcanvas_h);
1887 pane[TOP_RIGHT_PANE]->resize_event(
1888 pane[TOP_RIGHT_PANE]->x,
1889 mwindow->theme->mcanvas_y,
1890 pane[TOP_RIGHT_PANE]->w,
1891 mwindow->theme->mcanvas_h);
1896 void MWindowGUI::stop_pane_drag()
1899 resource_thread->stop_draw(1);
1903 // cursor position relative to canvas
1904 int cursor_x = x_pane_drag->get_x() -
1906 BC_DisplayInfo::get_left_border() -
1907 mwindow->theme->mcanvas_x +
1908 mwindow->theme->pane_w;
1913 if(cursor_x >= mwindow->theme->patchbay_w + PANE_DRAG_MARGIN &&
1914 cursor_x < mwindow->theme->mcanvas_w -
1915 BC_ScrollBar::get_span(SCROLL_VERT) -
1918 create_x_pane(cursor_x);
1919 mwindow->edl->local_session->x_pane = cursor_x;
1924 delete_x_pane(cursor_x);
1925 mwindow->edl->local_session->x_pane = -1;
1933 // cursor position relative to canvas
1934 int cursor_y = y_pane_drag->get_y() -
1936 BC_DisplayInfo::get_top_border() -
1937 mwindow->theme->mcanvas_y +
1938 mwindow->theme->pane_h;
1944 if(cursor_y >= mwindow->theme->mtimebar_h +
1946 cursor_y < mwindow->theme->mcanvas_h -
1947 BC_ScrollBar::get_span(SCROLL_HORIZ) -
1950 create_y_pane(cursor_y);
1951 mwindow->edl->local_session->y_pane = cursor_y;
1955 delete_y_pane(cursor_y);
1956 mwindow->edl->local_session->y_pane = -1;
1960 update_pane_dividers();
1962 // required to get new widgets to appear
1964 resource_thread->start_draw();
1967 // create panes from EDL
1968 void MWindowGUI::load_panes()
1970 int need_x_panes = 0;
1971 int need_y_panes = 0;
1972 // use names from create functions
1973 int cursor_x = mwindow->edl->local_session->x_pane;
1974 int cursor_y = mwindow->edl->local_session->y_pane;
1976 resource_thread->stop_draw(1);
1978 mwindow->theme->patchbay_w + PANE_DRAG_MARGIN &&
1980 mwindow->theme->mcanvas_w -
1981 BC_ScrollBar::get_span(SCROLL_VERT) -
1988 mwindow->theme->mtimebar_h + PANE_DRAG_MARGIN &&
1990 mwindow->theme->mcanvas_h -
1991 BC_ScrollBar::get_span(SCROLL_HORIZ) -
1997 //printf("MWindowGUI::load_panes %d %d %d\n", __LINE__, need_x_panes, need_y_panes);
2005 if(total_panes() == 1)
2008 //printf("MWindowGUI::load_panes %d\n", __LINE__);
2009 pane[TOP_RIGHT_PANE] = new TimelinePane(mwindow,
2011 mwindow->theme->mcanvas_x +
2013 mwindow->theme->mcanvas_y,
2014 mwindow->theme->mcanvas_x +
2015 mwindow->theme->mcanvas_w -
2017 cursor_y - mwindow->theme->pane_h);
2018 pane[BOTTOM_LEFT_PANE] = new TimelinePane(mwindow,
2020 mwindow->theme->mcanvas_x,
2021 mwindow->theme->mcanvas_y +
2023 cursor_x - mwindow->theme->pane_w,
2024 mwindow->theme->mcanvas_h -
2026 pane[BOTTOM_RIGHT_PANE] = new TimelinePane(mwindow,
2028 pane[TOP_RIGHT_PANE]->x,
2029 mwindow->theme->mcanvas_y +
2031 pane[TOP_RIGHT_PANE]->w,
2032 mwindow->theme->mcanvas_h -
2034 pane[TOP_LEFT_PANE]->resize_event(
2035 pane[TOP_LEFT_PANE]->x,
2036 pane[TOP_LEFT_PANE]->y,
2037 cursor_x - mwindow->theme->pane_w,
2038 cursor_y - mwindow->theme->pane_h);
2039 pane[TOP_RIGHT_PANE]->create_objects();
2040 pane[BOTTOM_LEFT_PANE]->create_objects();
2041 pane[BOTTOM_RIGHT_PANE]->create_objects();
2044 if(horizontal_panes())
2046 // create vertical panes
2047 //printf("MWindowGUI::load_panes %d\n", __LINE__);
2048 pane[BOTTOM_LEFT_PANE] = new TimelinePane(mwindow,
2050 mwindow->theme->mcanvas_x,
2051 mwindow->theme->mcanvas_y +
2053 cursor_x - mwindow->theme->pane_w,
2054 mwindow->theme->mcanvas_h -
2056 pane[BOTTOM_RIGHT_PANE] = new TimelinePane(mwindow,
2058 pane[TOP_RIGHT_PANE]->x,
2059 mwindow->theme->mcanvas_y +
2061 pane[TOP_RIGHT_PANE]->w,
2062 mwindow->theme->mcanvas_h -
2064 pane[TOP_LEFT_PANE]->resize_event(
2065 pane[TOP_LEFT_PANE]->x,
2066 pane[TOP_LEFT_PANE]->y,
2067 cursor_x - mwindow->theme->pane_w,
2068 cursor_y - mwindow->theme->pane_h);
2069 pane[TOP_RIGHT_PANE]->resize_event(
2070 mwindow->theme->mcanvas_x +
2072 mwindow->theme->mcanvas_y,
2073 mwindow->theme->mcanvas_x +
2074 mwindow->theme->mcanvas_w -
2076 cursor_y - mwindow->theme->pane_h);
2077 pane[BOTTOM_LEFT_PANE]->create_objects();
2078 pane[BOTTOM_RIGHT_PANE]->create_objects();
2081 if(vertical_panes())
2083 // create horizontal panes
2084 //printf("MWindowGUI::load_panes %d\n", __LINE__);
2085 pane[TOP_RIGHT_PANE] = new TimelinePane(mwindow,
2087 mwindow->theme->mcanvas_x +
2089 mwindow->theme->mcanvas_y,
2090 mwindow->theme->mcanvas_x +
2091 mwindow->theme->mcanvas_w -
2093 cursor_y - mwindow->theme->pane_h);
2094 pane[BOTTOM_RIGHT_PANE] = new TimelinePane(mwindow,
2096 pane[TOP_RIGHT_PANE]->x,
2097 mwindow->theme->mcanvas_y +
2099 pane[TOP_RIGHT_PANE]->w,
2100 mwindow->theme->mcanvas_h -
2102 pane[TOP_LEFT_PANE]->resize_event(
2103 pane[TOP_LEFT_PANE]->x,
2104 pane[TOP_LEFT_PANE]->y,
2105 cursor_x - mwindow->theme->pane_w,
2106 cursor_y - mwindow->theme->pane_h);
2107 pane[BOTTOM_LEFT_PANE]->resize_event(
2108 pane[TOP_LEFT_PANE]->x,
2109 mwindow->theme->mcanvas_y +
2111 mwindow->theme->mcanvas_x +
2112 mwindow->theme->mcanvas_w -
2114 mwindow->theme->mcanvas_h -
2116 pane[TOP_RIGHT_PANE]->create_objects();
2117 pane[BOTTOM_RIGHT_PANE]->create_objects();
2124 //printf("MWindowGUI::load_panes %d\n", __LINE__);
2125 pane[TOP_LEFT_PANE]->resize_event(
2126 pane[TOP_LEFT_PANE]->x,
2127 pane[TOP_LEFT_PANE]->y,
2128 cursor_x - mwindow->theme->pane_w,
2129 cursor_y - mwindow->theme->pane_h);
2130 pane[TOP_RIGHT_PANE]->resize_event(
2131 mwindow->theme->mcanvas_x +
2133 mwindow->theme->mcanvas_y,
2134 mwindow->theme->mcanvas_x +
2135 mwindow->theme->mcanvas_w -
2137 cursor_y - mwindow->theme->pane_h);
2138 pane[BOTTOM_LEFT_PANE]->resize_event(
2139 pane[TOP_LEFT_PANE]->x,
2140 mwindow->theme->mcanvas_y +
2142 mwindow->theme->mcanvas_x +
2143 mwindow->theme->mcanvas_w -
2145 mwindow->theme->mcanvas_h -
2147 pane[BOTTOM_RIGHT_PANE]->resize_event(
2148 pane[TOP_RIGHT_PANE]->x,
2149 mwindow->theme->mcanvas_y +
2151 pane[TOP_RIGHT_PANE]->w,
2152 mwindow->theme->mcanvas_h -
2161 if(pane[BOTTOM_LEFT_PANE]) delete pane[BOTTOM_LEFT_PANE];
2162 if(pane[BOTTOM_RIGHT_PANE]) delete pane[BOTTOM_RIGHT_PANE];
2163 pane[BOTTOM_LEFT_PANE] = 0;
2164 pane[BOTTOM_RIGHT_PANE] = 0;
2166 if(!pane[TOP_RIGHT_PANE])
2168 pane[TOP_RIGHT_PANE] = new TimelinePane(mwindow,
2170 mwindow->theme->mcanvas_x +
2172 mwindow->theme->mcanvas_y,
2173 mwindow->theme->mcanvas_x +
2174 mwindow->theme->mcanvas_w -
2176 mwindow->theme->mcanvas_h);
2177 pane[TOP_LEFT_PANE]->resize_event(
2178 mwindow->theme->mcanvas_x,
2179 mwindow->theme->mcanvas_y,
2180 cursor_x - mwindow->theme->pane_w,
2181 mwindow->theme->mcanvas_h);
2182 pane[TOP_RIGHT_PANE]->create_objects();
2186 pane[TOP_LEFT_PANE]->resize_event(
2187 mwindow->theme->mcanvas_x,
2188 mwindow->theme->mcanvas_y,
2189 cursor_x - mwindow->theme->pane_w,
2190 mwindow->theme->mcanvas_h);
2191 pane[TOP_RIGHT_PANE]->resize_event(
2192 mwindow->theme->mcanvas_x +
2194 pane[TOP_RIGHT_PANE]->y,
2195 mwindow->theme->mcanvas_x +
2196 mwindow->theme->mcanvas_w -
2198 mwindow->theme->mcanvas_h);
2206 if(pane[TOP_RIGHT_PANE]) delete pane[TOP_RIGHT_PANE];
2207 if(pane[BOTTOM_RIGHT_PANE]) delete pane[BOTTOM_RIGHT_PANE];
2208 pane[TOP_RIGHT_PANE] = 0;
2209 pane[BOTTOM_RIGHT_PANE] = 0;
2211 if(!pane[BOTTOM_LEFT_PANE])
2213 //printf("MWindowGUI::load_panes %d\n", __LINE__);
2214 pane[BOTTOM_LEFT_PANE] = new TimelinePane(mwindow,
2216 mwindow->theme->mcanvas_x,
2217 mwindow->theme->mcanvas_y +
2219 mwindow->theme->mcanvas_w,
2220 mwindow->theme->mcanvas_h -
2222 pane[TOP_LEFT_PANE]->resize_event(
2223 mwindow->theme->mcanvas_x,
2224 mwindow->theme->mcanvas_y,
2225 mwindow->theme->mcanvas_w,
2226 pane[BOTTOM_LEFT_PANE]->y -
2227 mwindow->theme->mcanvas_y -
2228 mwindow->theme->pane_h);
2229 pane[BOTTOM_LEFT_PANE]->create_objects();
2233 pane[TOP_LEFT_PANE]->resize_event(
2234 mwindow->theme->mcanvas_x,
2235 mwindow->theme->mcanvas_y,
2236 mwindow->theme->mcanvas_w,
2237 cursor_y - mwindow->theme->pane_h);
2238 pane[BOTTOM_LEFT_PANE]->resize_event(
2239 pane[BOTTOM_LEFT_PANE]->x,
2241 mwindow->theme->mcanvas_y,
2242 mwindow->theme->mcanvas_w,
2243 mwindow->theme->mcanvas_h -
2250 if(pane[TOP_RIGHT_PANE]) delete pane[TOP_RIGHT_PANE];
2251 if(pane[BOTTOM_RIGHT_PANE]) delete pane[BOTTOM_RIGHT_PANE];
2252 if(pane[BOTTOM_LEFT_PANE]) delete pane[BOTTOM_LEFT_PANE];
2253 pane[TOP_RIGHT_PANE] = 0;
2254 pane[BOTTOM_RIGHT_PANE] = 0;
2255 pane[BOTTOM_LEFT_PANE] = 0;
2256 pane[TOP_LEFT_PANE]->resize_event(
2257 mwindow->theme->mcanvas_x,
2258 mwindow->theme->mcanvas_y,
2259 mwindow->theme->mcanvas_w,
2260 mwindow->theme->mcanvas_h);
2263 update_pane_dividers();
2266 resource_thread->start_draw();
2269 void MWindowGUI::update_pane_dividers()
2272 if(horizontal_panes() || total_panes() == 4)
2274 int x = pane[TOP_RIGHT_PANE]->x - mwindow->theme->pane_w;
2275 int y = mwindow->theme->mcanvas_y;
2276 int h = mwindow->theme->mcanvas_h;
2280 add_subwindow(x_divider = new PaneDivider(
2281 mwindow, x, y, h, 1));
2282 x_divider->create_objects();
2286 x_divider->reposition_window(x, y, h);
2299 if(vertical_panes() || total_panes() == 4)
2301 int x = mwindow->theme->mcanvas_x;
2302 int y = pane[BOTTOM_LEFT_PANE]->y -
2303 mwindow->theme->pane_h;
2304 int w = mwindow->theme->mcanvas_w;
2307 add_subwindow(y_divider = new PaneDivider(
2308 mwindow, x, y, w, 0));
2309 y_divider->create_objects();
2313 y_divider->reposition_window(x, y, w);
2327 void MWindowGUI::draw_samplemovement()
2334 update_scrollbars(1);
2337 void MWindowGUI::draw_trackmovement()
2339 update_scrollbars(0);
2346 PaneButton::PaneButton(MWindow *mwindow, int x, int y)
2347 : BC_Button(x, y, mwindow->theme->get_image_set("pane"))
2349 this->mwindow = mwindow;
2352 int PaneButton::cursor_motion_event()
2354 if(get_top_level()->get_button_down() &&
2356 get_status() == BUTTON_DOWNHI &&
2359 // printf("PaneButton::cursor_motion_event %d\n", __LINE__);
2361 if(get_cursor_x() < 0 && !mwindow->gui->dragging_pane)
2363 mwindow->gui->start_x_pane_drag();
2366 if(get_cursor_y() < 0 && !mwindow->gui->dragging_pane)
2368 mwindow->gui->start_y_pane_drag();
2372 mwindow->gui->handle_pane_drag();
2374 int result = BC_Button::cursor_motion_event();
2378 int PaneButton::button_release_event()
2380 mwindow->gui->stop_pane_drag();
2382 int result = BC_Button::button_release_event();
2387 FFMpegToggle::FFMpegToggle(MWindow *mwindow, MButtons *mbuttons, int x, int y)
2388 : BC_Toggle(x, y, mwindow->theme->ffmpeg_toggle, mwindow->preferences->ffmpeg_early_probe)
2390 this->mwindow = mwindow;
2391 this->mbuttons = mbuttons;
2392 set_tooltip(_("FFMpeg early probe"));
2395 FFMpegToggle::~FFMpegToggle()
2399 int FFMpegToggle::handle_event()
2401 mwindow->preferences->ffmpeg_early_probe = get_value();
2402 mwindow->show_warning(&mwindow->preferences->warn_indexes,
2403 _("Changing the base codecs may require rebuilding indexes."));