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 if(debug) printf("MWindowGUI::create_objects %d\n", __LINE__);
322 mainclock->update(0);
326 // if(debug) printf("MWindowGUI::create_objects %d\n", __LINE__);
327 // cursor = new MainCursor(mwindow, this);
328 // cursor->create_objects();
331 if(debug) printf("MWindowGUI::create_objects %d\n", __LINE__);
332 add_subwindow(edit_menu = new EditPopup(mwindow, this));
333 edit_menu->create_objects();
336 if(debug) printf("MWindowGUI::create_objects %d\n", __LINE__);
337 add_subwindow(plugin_menu = new PluginPopup(mwindow, this));
338 plugin_menu->create_objects();
341 if(debug) printf("MWindowGUI::create_objects %d\n", __LINE__);
342 add_subwindow(keyframe_menu = new KeyframePopup(mwindow, this));
343 keyframe_menu->create_objects();
346 if(debug) printf("MWindowGUI::create_objects %d\n", __LINE__);
347 add_subwindow(transition_menu = new TransitionPopup(mwindow, this));
348 transition_menu->create_objects();
350 channel_info = new ChannelInfo(mwindow);
351 db_window = new DbWindow(mwindow);
352 swindow = new SWindow(mwindow);
354 if(debug) printf("MWindowGUI::create_objects %d\n", __LINE__);
356 add_subwindow(pane_button = new PaneButton(mwindow,
357 get_w() - mwindow->theme->get_image_set("pane")[0]->get_w(),
358 mwindow->theme->mzoom_y + 1 - mwindow->theme->get_image_set("pane")[0]->get_h()));
360 pane[TOP_LEFT_PANE]->canvas->activate();
362 if(debug) printf("MWindowGUI::create_objects %d\n", __LINE__);
365 void MWindowGUI::redraw_time_dependancies()
367 zoombar->redraw_time_dependancies();
368 for(int i = 0; i < TOTAL_PANES; i++)
369 if(pane[i] && pane[i]->timebar) pane[i]->timebar->update(0);
370 mainclock->update(mwindow->edl->local_session->get_selectionstart(1));
373 int MWindowGUI::focus_in_event()
375 for(int i = 0; i < TOTAL_PANES; i++)
376 if(pane[i]) pane[i]->cursor->focus_in_event();
380 int MWindowGUI::focus_out_event()
382 for(int i = 0; i < TOTAL_PANES; i++)
383 if(pane[i]) pane[i]->cursor->focus_out_event();
388 int MWindowGUI::resize_event(int w, int h)
390 //printf("MWindowGUI::resize_event %d\n", __LINE__);
391 mwindow->session->mwindow_w = w;
392 mwindow->session->mwindow_h = h;
393 int x = w - MainShBtns::calculate_w(0);
394 mainmenu->resize_event(x, mainmenu->get_h());
395 mainshbtns->reposition_window(x, -1);
396 mwindow->theme->get_mwindow_sizes(this, w, h);
397 mwindow->theme->draw_mwindow_bg(this);
398 mbuttons->resize_event();
399 ffmpeg_toggle->reposition_window(menu_w(), menu_h()+2);
400 statusbar->resize_event();
402 resource_thread->stop_draw(1);
404 if(total_panes() > 1)
406 if(horizontal_panes())
408 // printf("MWindowGUI::resize_event %d %d %d\n",
410 // pane[TOP_RIGHT_PANE]->x,
411 // mwindow->theme->mcanvas_w -
412 // BC_ScrollBar::get_span(SCROLL_VERT) -
413 // PANE_DRAG_MARGIN);
414 if(pane[TOP_RIGHT_PANE]->x >= mwindow->theme->mcanvas_w -
415 BC_ScrollBar::get_span(SCROLL_VERT) -
418 delete_x_pane(pane[TOP_RIGHT_PANE]->x);
419 mwindow->edl->local_session->x_pane = -1;
425 if(pane[BOTTOM_LEFT_PANE]->y >= mwindow->theme->mzoom_y -
426 BC_ScrollBar::get_span(SCROLL_HORIZ) -
429 delete_y_pane(pane[BOTTOM_LEFT_PANE]->y);
430 mwindow->edl->local_session->y_pane = -1;
435 if(pane[TOP_RIGHT_PANE]->x >= mwindow->theme->mcanvas_w -
436 BC_ScrollBar::get_span(SCROLL_VERT) -
439 delete_x_pane(pane[TOP_RIGHT_PANE]->x);
440 mwindow->edl->local_session->x_pane = -1;
443 if(pane[BOTTOM_LEFT_PANE]->y >= mwindow->theme->mzoom_y -
444 BC_ScrollBar::get_span(SCROLL_HORIZ) -
447 delete_y_pane(pane[BOTTOM_LEFT_PANE]->y);
448 mwindow->edl->local_session->y_pane = -1;
453 if(total_panes() == 1)
455 pane[TOP_LEFT_PANE]->resize_event(
456 mwindow->theme->mcanvas_x,
457 mwindow->theme->mcanvas_y,
458 mwindow->theme->mcanvas_w,
459 mwindow->theme->mcanvas_h);
462 if(horizontal_panes())
464 pane[TOP_LEFT_PANE]->resize_event(
465 pane[TOP_LEFT_PANE]->x,
466 pane[TOP_LEFT_PANE]->y,
467 pane[TOP_LEFT_PANE]->w,
468 mwindow->theme->mcanvas_h);
469 pane[TOP_RIGHT_PANE]->resize_event(
470 pane[TOP_RIGHT_PANE]->x,
471 pane[TOP_RIGHT_PANE]->y,
472 mwindow->theme->mcanvas_w - pane[TOP_RIGHT_PANE]->x,
473 mwindow->theme->mcanvas_h);
478 pane[TOP_LEFT_PANE]->resize_event(
479 pane[TOP_LEFT_PANE]->x,
480 pane[TOP_LEFT_PANE]->y,
481 mwindow->theme->mcanvas_w,
482 pane[TOP_LEFT_PANE]->h);
483 pane[BOTTOM_LEFT_PANE]->resize_event(
484 pane[BOTTOM_LEFT_PANE]->x,
485 pane[BOTTOM_LEFT_PANE]->y,
486 mwindow->theme->mcanvas_w,
487 mwindow->theme->mcanvas_y +
488 mwindow->theme->mcanvas_h -
489 pane[BOTTOM_LEFT_PANE]->y);
493 pane[TOP_LEFT_PANE]->resize_event(
494 pane[TOP_LEFT_PANE]->x,
495 pane[TOP_LEFT_PANE]->y,
496 pane[TOP_LEFT_PANE]->w,
497 pane[TOP_LEFT_PANE]->h);
498 pane[TOP_RIGHT_PANE]->resize_event(
499 pane[TOP_RIGHT_PANE]->x,
500 pane[TOP_RIGHT_PANE]->y,
501 mwindow->theme->mcanvas_w - pane[TOP_RIGHT_PANE]->x,
502 pane[TOP_RIGHT_PANE]->h);
503 pane[BOTTOM_LEFT_PANE]->resize_event(
504 pane[BOTTOM_LEFT_PANE]->x,
505 pane[BOTTOM_LEFT_PANE]->y,
506 pane[BOTTOM_LEFT_PANE]->w,
507 mwindow->theme->mcanvas_y +
508 mwindow->theme->mcanvas_h -
509 pane[BOTTOM_LEFT_PANE]->y);
510 pane[BOTTOM_RIGHT_PANE]->resize_event(
511 pane[BOTTOM_RIGHT_PANE]->x,
512 pane[BOTTOM_RIGHT_PANE]->y,
513 mwindow->theme->mcanvas_w -
514 pane[BOTTOM_RIGHT_PANE]->x,
515 mwindow->theme->mcanvas_y +
516 mwindow->theme->mcanvas_h -
517 pane[BOTTOM_RIGHT_PANE]->y);
520 resource_thread->start_draw();
522 update_pane_dividers();
523 zoombar->resize_event();
524 pane_button->reposition_window(w - mwindow->theme->get_image_set("pane")[0]->get_w(),
525 mwindow->theme->mzoom_y + 1 - mwindow->theme->get_image_set("pane")[0]->get_h());
526 // get_scrollbars(0);
527 // canvas->resize_event();
528 //printf("MWindowGUI::resize_event %d\n", __LINE__);
529 // required to get new widgets to appear after a pane deletion
534 int MWindowGUI::total_panes()
537 for(int i = 0; i < TOTAL_PANES; i++)
542 int MWindowGUI::vertical_panes()
544 return total_panes() == 2 &&
545 pane[TOP_LEFT_PANE] &&
546 pane[BOTTOM_LEFT_PANE];
549 int MWindowGUI::horizontal_panes()
551 return total_panes() == 2 &&
552 pane[TOP_LEFT_PANE] &&
553 pane[TOP_RIGHT_PANE];
556 TimelinePane* MWindowGUI::get_focused_pane()
558 if(pane[focused_pane]) return pane[focused_pane];
559 for(int i = 0; i < TOTAL_PANES; i++)
561 if(pane[i]) return pane[i];
566 void MWindowGUI::activate_timeline()
568 if(pane[focused_pane])
570 pane[focused_pane]->activate();
574 for(int i = 0; i < TOTAL_PANES; i++)
585 void MWindowGUI::deactivate_timeline()
587 for(int i = 0; i < TOTAL_PANES; i++)
591 pane[i]->canvas->deactivate();
596 void MWindowGUI::update_title(char *path)
599 char filename[BCTEXTLEN], string[BCTEXTLEN];
600 fs.extract_name(filename, path);
601 sprintf(string, _(PROGRAM_NAME ": %s"), filename);
603 //printf("MWindowGUI::update_title %s\n", string);
607 void MWindowGUI::draw_overlays(int flash_it)
609 for(int i = 0; i < TOTAL_PANES; i++)
613 pane[i]->canvas->draw_overlays();
614 if(flash_it) pane[i]->canvas->flash();
619 void MWindowGUI::update_timebar(int flush_it)
621 for(int i = 0; i < TOTAL_PANES; i++)
623 if(pane[i] && pane[i]->timebar)
625 pane[i]->timebar->update(flush_it);
630 void MWindowGUI::update_timebar_highlights()
632 for(int i = 0; i < TOTAL_PANES; i++)
634 if(pane[i] && pane[i]->timebar)
636 pane[i]->timebar->update_highlights();
642 void MWindowGUI::update_patchbay()
644 for(int i = 0; i < TOTAL_PANES; i++)
646 if(pane[i] && pane[i]->patchbay)
648 pane[i]->patchbay->update();
653 void MWindowGUI::draw_indexes(Indexable *indexable)
655 for(int i = 0; i < TOTAL_PANES; i++)
659 pane[i]->canvas->draw_indexes(indexable);
664 void MWindowGUI::draw_canvas(int mode /* = 0 */, int hide_cursor /* = 1 */)
666 if(mode != IGNORE_THREAD)
668 resource_thread->stop_draw(1);
672 for(int i = 0; i < TOTAL_PANES; i++)
676 pane[i]->canvas->draw(mode, hide_cursor);
681 if(mode != IGNORE_THREAD)
683 resource_thread->start_draw();
688 void MWindowGUI::flash_canvas(int flush)
690 for(int i = 0; i < TOTAL_PANES; i++)
694 pane[i]->canvas->flash(flush);
699 void MWindowGUI::draw_cursor(int do_plugintoggles)
701 for(int i = 0; i < TOTAL_PANES; i++)
705 pane[i]->cursor->draw(do_plugintoggles);
710 void MWindowGUI::show_cursor(int do_plugintoggles)
712 for(int i = 0; i < TOTAL_PANES; i++)
716 pane[i]->cursor->show(do_plugintoggles);
721 void MWindowGUI::hide_cursor(int do_plugintoggles)
723 for(int i = 0; i < TOTAL_PANES; i++)
727 pane[i]->cursor->hide(do_plugintoggles);
732 void MWindowGUI::update_cursor()
734 for(int i = 0; i < TOTAL_PANES; i++)
738 pane[i]->cursor->update();
743 void MWindowGUI::set_playing_back(int value)
745 for(int i = 0; i < TOTAL_PANES; i++)
749 pane[i]->cursor->playing_back = value;
754 void MWindowGUI::update_plugintoggles()
756 for(int i = 0; i < TOTAL_PANES; i++)
760 pane[i]->canvas->refresh_plugintoggles();
766 void MWindowGUI::update_scrollbars(int flush)
768 for(int i = 0; i < TOTAL_PANES; i++)
772 pane[i]->update(1, 0, 0, 0);
775 if(flush) this->flush();
778 void MWindowGUI::reset_meters()
780 for(int i = 0; i < TOTAL_PANES; i++)
782 if(pane[i] && pane[i]->patchbay)
784 pane[i]->patchbay->reset_meters();
789 void MWindowGUI::stop_meters()
791 for(int i = 0; i < TOTAL_PANES; i++)
793 if(pane[i] && pane[i]->patchbay)
795 pane[i]->patchbay->stop_meters();
800 void MWindowGUI::update_meters(ArrayList<double> *module_levels)
802 for(int i = 0; i < TOTAL_PANES; i++)
804 if(pane[i] && pane[i]->patchbay)
806 pane[i]->patchbay->update_meters(module_levels);
811 void MWindowGUI::set_editing_mode(int flush)
813 for(int i = 0; i < TOTAL_PANES; i++)
817 pane[i]->canvas->update_cursor(flush);
822 void MWindowGUI::set_meter_format(int mode, int min, int max)
824 for(int i = 0; i < TOTAL_PANES; i++)
826 if(pane[i] && pane[i]->patchbay)
828 pane[i]->patchbay->set_meter_format(mode, min, max);
833 void MWindowGUI::update(int scrollbars,
842 if(debug) PRINT_TRACE
846 mwindow->edl->tracks->update_y_pixels(mwindow->theme);
848 if(do_canvas && do_canvas != IGNORE_THREAD)
850 resource_thread->stop_draw(1);
853 for(int i = 0; i < TOTAL_PANES; i++)
855 if(pane[i]) pane[i]->update(scrollbars,
861 if(do_canvas && do_canvas != IGNORE_THREAD)
863 resource_thread->start_draw();
866 // if(scrollbars) this->get_scrollbars(0);
867 // if(timebar) this->timebar->update(0);
868 if(zoombar) this->zoombar->update();
869 // if(patchbay) this->patchbay->update();
870 if(clock) this->mainclock->update(
871 mwindow->edl->local_session->get_selectionstart(1));
872 if(debug) PRINT_TRACE
878 // this->canvas->draw(do_canvas);
879 // this->cursor->show();
880 // this->canvas->flash(0);
881 // Activate causes the menubar to deactivate. Don't want this for
883 // if(canvas != IGNORE_THREAD) this->canvas->activate();
885 if(debug) PRINT_TRACE
889 if(buttonbar) mbuttons->update();
890 if(debug) PRINT_TRACE
892 // Can't age if the cache called this to draw missing picons
893 // or the GUI is updating the status of the draw toggle.
894 if(do_canvas != FORCE_REDRAW && do_canvas != IGNORE_THREAD)
897 mwindow->age_caches();
898 lock_window("MWindowGUI::update");
902 if(debug) PRINT_TRACE
905 int MWindowGUI::visible(int64_t x1, int64_t x2, int64_t view_x1, int64_t view_x2)
907 return (x1 >= view_x1 && x1 < view_x2) ||
908 (x2 > view_x1 && x2 <= view_x2) ||
909 (x1 <= view_x1 && x2 >= view_x2);
913 int MWindowGUI::show_message(char *message, int color)
915 // printf("MWindowGUI::show_message %d: %s 0x%08x 0x%08x\n",
916 // __LINE__, message, color, mwindow->theme->message_normal);
917 if(color < 0) color = mwindow->theme->message_normal;
918 statusbar->status_text->set_color(color);
919 statusbar->status_text->update(message);
924 // Drag motion called from other window
925 int MWindowGUI::drag_motion()
927 if(get_hidden()) return 0;
929 Track *over_track = 0;
931 PluginSet *over_pluginset = 0;
932 Plugin *over_plugin = 0;
937 drag_popup->cursor_motion_event();
941 // there's no point in drawing highlights has until drag operation has been set
942 if (!mwindow->session->current_operation)
945 if(mwindow->session->free_drag) redraw = 1;
950 mwindow->session->free_drag = 1;
954 mwindow->session->free_drag = 0;
958 for(int i = 0; i < TOTAL_PANES; i++)
960 if(pane[i]) pane[i]->canvas->drag_motion(
969 if(mwindow->session->track_highlighted != over_track)
971 mwindow->session->track_highlighted = over_track;
975 if(mwindow->session->edit_highlighted != over_edit)
977 mwindow->session->edit_highlighted = over_edit;
981 if(mwindow->session->pluginset_highlighted != over_pluginset)
983 mwindow->session->pluginset_highlighted = over_pluginset;
987 if(mwindow->session->plugin_highlighted != over_plugin)
989 mwindow->session->plugin_highlighted = over_plugin;
993 // printf("drag_motion %d %d over_track=%p over_edit=%p\n",
1000 lock_window("MWindowGUI::drag_motion");
1007 int MWindowGUI::drag_stop()
1009 if(get_hidden()) return 0;
1010 int result = 0, redraw = 0;
1012 for(int i = 0; i < TOTAL_PANES; i++)
1014 if(pane[i]) result |= pane[i]->canvas->drag_stop(
1019 // since we don't have subwindows we have to terminate any drag operation
1022 if (mwindow->session->track_highlighted
1023 || mwindow->session->edit_highlighted
1024 || mwindow->session->plugin_highlighted
1025 || mwindow->session->pluginset_highlighted)
1027 mwindow->session->track_highlighted = 0;
1028 mwindow->session->edit_highlighted = 0;
1029 mwindow->session->plugin_highlighted = 0;
1030 mwindow->session->pluginset_highlighted = 0;
1031 mwindow->session->current_operation = NO_OPERATION;
1035 //printf("TrackCanvas::drag_stop %d %d\n", redraw, mwindow->session->current_operation);
1038 mwindow->edl->tracks->update_y_pixels(mwindow->theme);
1039 update_scrollbars(0);
1054 void MWindowGUI::default_positions()
1056 //printf("MWindowGUI::default_positions 1\n");
1057 VWindow *vwindow = mwindow->vwindows.size() > DEFAULT_VWINDOW ?
1058 mwindow->vwindows.get(0) : 0;
1059 if( vwindow ) vwindow->gui->lock_window("MWindowGUI::default_positions");
1060 mwindow->cwindow->gui->lock_window("MWindowGUI::default_positions");
1061 mwindow->awindow->gui->lock_window("MWindowGUI::default_positions");
1063 // printf("MWindowGUI::default_positions 1 %d %d %d %d\n", mwindow->session->vwindow_x,
1064 // mwindow->session->vwindow_y,
1065 // mwindow->session->vwindow_w,
1066 // mwindow->session->vwindow_h);
1067 reposition_window(mwindow->session->mwindow_x,
1068 mwindow->session->mwindow_y,
1069 mwindow->session->mwindow_w,
1070 mwindow->session->mwindow_h);
1071 if( vwindow ) vwindow->gui->reposition_window(mwindow->session->vwindow_x,
1072 mwindow->session->vwindow_y,
1073 mwindow->session->vwindow_w,
1074 mwindow->session->vwindow_h);
1075 mwindow->cwindow->gui->reposition_window(mwindow->session->cwindow_x,
1076 mwindow->session->cwindow_y,
1077 mwindow->session->cwindow_w,
1078 mwindow->session->cwindow_h);
1079 mwindow->awindow->gui->reposition_window(mwindow->session->awindow_x,
1080 mwindow->session->awindow_y,
1081 mwindow->session->awindow_w,
1082 mwindow->session->awindow_h);
1083 //printf("MWindowGUI::default_positions 1\n");
1085 resize_event(mwindow->session->mwindow_w,
1086 mwindow->session->mwindow_h);
1087 //printf("MWindowGUI::default_positions 1\n");
1088 if( vwindow ) vwindow->gui->resize_event(mwindow->session->vwindow_w,
1089 mwindow->session->vwindow_h);
1090 //printf("MWindowGUI::default_positions 1\n");
1091 mwindow->cwindow->gui->resize_event(mwindow->session->cwindow_w,
1092 mwindow->session->cwindow_h);
1093 //printf("MWindowGUI::default_positions 1\n");
1094 mwindow->awindow->gui->resize_event(mwindow->session->awindow_w,
1095 mwindow->session->awindow_h);
1097 //printf("MWindowGUI::default_positions 1\n");
1100 if( vwindow ) vwindow->gui->flush();
1101 mwindow->cwindow->gui->flush();
1102 mwindow->awindow->gui->flush();
1104 if( vwindow ) vwindow->gui->unlock_window();
1105 mwindow->cwindow->gui->unlock_window();
1106 mwindow->awindow->gui->unlock_window();
1107 //printf("MWindowGUI::default_positions 2\n");
1126 int MWindowGUI::repeat_event(int64_t duration)
1128 // if(duration == 100)
1129 // mwindow->sync_parameters(CHANGE_ALL);
1131 for(int i = 0; i < TOTAL_PANES; i++)
1133 if(pane[i]) result = pane[i]->cursor->repeat_event(duration);
1139 int MWindowGUI::translation_event()
1141 //printf("MWindowGUI::translation_event 1 %d %d\n", get_x(), get_y());
1142 mwindow->session->mwindow_x = get_x();
1143 mwindow->session->mwindow_y = get_y();
1148 int MWindowGUI::save_defaults(BC_Hash *defaults)
1150 defaults->update("MWINDOWWIDTH", get_w());
1151 defaults->update("MWINDOWHEIGHT", get_h());
1152 mainmenu->save_defaults(defaults);
1153 BC_WindowBase::save_defaults(defaults);
1157 int MWindowGUI::keypress_event()
1159 //printf("MWindowGUI::keypress_event 1 %d\n", get_keypress());
1161 result = mbuttons->keypress_event();
1165 switch(get_keypress())
1167 case '1': case '2': case '3': case '4':
1168 case '5': case '6': case '7': case '8':
1169 if( !alt_down() || shift_down() ) break;
1170 if( !mwindow->select_asset(get_keypress()-'1',1) )
1179 mbuttons->transport->handle_transport(STOP, 1, 0, 0);
1180 lock_window("MWindowGUI::keypress_event 1");
1181 mwindow->prev_edit_handle(shift_down());
1184 mwindow->move_left();
1194 mbuttons->transport->handle_transport(STOP, 1, 0, 0);
1195 lock_window("MWindowGUI::keypress_event 2");
1196 mwindow->next_edit_handle(shift_down());
1199 mwindow->move_right();
1207 mwindow->expand_y();
1213 mwindow->expand_autos();
1218 mwindow->expand_sample();
1226 mwindow->zoom_in_y();
1232 mwindow->shrink_autos();
1237 mwindow->zoom_in_sample();
1250 mwindow->expand_t();
1258 mwindow->move_down();
1263 mwindow->zoom_in_t();
1270 // //int cursor_x = 0;
1271 // int cursor_y = 0;
1272 // for(int i = 0; i < TOTAL_PANES; i++)
1276 // //cursor_x = pane[i]->canvas->get_relative_cursor_x();
1277 // cursor_y = pane[i]->canvas->get_relative_cursor_y();
1282 // if(get_keypress() == TAB)
1284 // // Switch the record button
1285 // for(Track *track = mwindow->edl->tracks->first; track; track = track->next)
1287 // int64_t track_x, track_y, track_w, track_h;
1288 // canvas->track_dimensions(track, track_x, track_y, track_w, track_h);
1290 // if(cursor_y >= track_y &&
1291 // cursor_y < track_y + track_h)
1293 // if (track->record)
1294 // track->record = 0;
1296 // track->record = 1;
1304 // Track *this_track = 0;
1305 // for(Track *track = mwindow->edl->tracks->first; track; track = track->next)
1307 // int64_t track_x, track_y, track_w, track_h;
1308 // canvas->track_dimensions(track, track_x, track_y, track_w, track_h);
1310 // if(cursor_y >= track_y &&
1311 // cursor_y < track_y + track_h)
1313 // // This is our track
1314 // this_track = track;
1319 // int total_selected = mwindow->edl->tracks->total_of(Tracks::RECORD);
1321 // // nothing previously selected
1322 // if(total_selected == 0)
1324 // mwindow->edl->tracks->select_all(Tracks::RECORD,
1328 // if(total_selected == 1)
1330 // // this patch was previously the only one on
1331 // if(this_track && this_track->record)
1333 // mwindow->edl->tracks->select_all(Tracks::RECORD,
1336 // // another patch was previously the only one on
1339 // mwindow->edl->tracks->select_all(Tracks::RECORD,
1342 // this_track->record = 1;
1347 // if(total_selected > 1)
1349 // mwindow->edl->tracks->select_all(Tracks::RECORD,
1352 // this_track->record = 1;
1365 // mwindow->cwindow->update(0, 1, 1);
1366 // lock_window("TrackCanvas::keypress_event 3");
1372 // since things under cursor have changed...
1374 cursor_motion_event();
1381 int MWindowGUI::keyboard_listener(BC_WindowBase *wp)
1383 return keyboard_listener(wp->get_keypress());
1386 int MWindowGUI::keyboard_listener(int key)
1391 if( !record->running() )
1394 record->record_gui->interrupt_thread->start(0);
1400 channel_info->toggle_scan();
1403 if( !remote_control->deactivate() )
1404 remote_control->activate();
1414 void MWindowGUI::use_android_remote(int on)
1417 delete android_control;
1418 android_control = 0;
1421 if( android_control ) return;
1422 android_control = new AndroidControl(this);
1425 int MWindowGUI::close_event()
1431 void MWindowGUI::stop_drawing()
1433 resource_thread->stop_draw(1);
1436 int MWindowGUI::menu_w()
1438 return mainmenu->get_w();
1441 int MWindowGUI::menu_h()
1443 return mainmenu->get_h();
1446 void MWindowGUI::start_x_pane_drag()
1450 x_pane_drag = new BC_Popup(this,
1451 get_abs_cursor_x(0) - mwindow->theme->pane_w,
1452 BC_DisplayInfo::get_top_border() +
1454 mwindow->theme->mcanvas_y,
1455 mwindow->theme->pane_w,
1456 mwindow->theme->mcanvas_h,
1457 mwindow->theme->drag_pane_color);
1458 x_pane_drag->draw_3segmentv(0,
1460 x_pane_drag->get_h(),
1461 mwindow->theme->get_image_set("xpane")[BUTTON_DOWNHI]);
1462 x_pane_drag->flash(1);
1467 void MWindowGUI::start_y_pane_drag()
1471 //printf("MWindowGUI::start_y_pane_drag %d %d %d\n", __LINE__, get_x(), get_y());
1472 y_pane_drag = new BC_Popup(this,
1473 BC_DisplayInfo::get_left_border() +
1475 mwindow->theme->mcanvas_x,
1476 get_abs_cursor_y(0) - mwindow->theme->pane_h,
1477 mwindow->theme->mcanvas_w,
1478 mwindow->theme->pane_h,
1479 mwindow->theme->drag_pane_color);
1480 y_pane_drag->draw_3segmenth(0,
1482 y_pane_drag->get_w(),
1483 mwindow->theme->get_image_set("ypane")[BUTTON_DOWNHI]);
1484 y_pane_drag->flash(1);
1489 void MWindowGUI::handle_pane_drag()
1495 x_pane_drag->reposition_window(
1496 get_abs_cursor_x(0) - mwindow->theme->pane_w,
1497 x_pane_drag->get_y());
1502 y_pane_drag->reposition_window(
1503 y_pane_drag->get_x(),
1504 get_abs_cursor_y(0) - mwindow->theme->pane_h);
1510 void MWindowGUI::create_x_pane(int cursor_x)
1512 if(total_panes() == 1)
1514 // create a horizontal pane
1515 // do this 1st so the resize_event knows there are 2 panes
1516 mwindow->edl->local_session->view_start[TOP_RIGHT_PANE] =
1517 mwindow->edl->local_session->view_start[TOP_LEFT_PANE] +
1519 mwindow->theme->patchbay_w;
1520 pane[TOP_RIGHT_PANE] = new TimelinePane(mwindow,
1522 mwindow->theme->mcanvas_x +
1524 mwindow->theme->mcanvas_y,
1525 mwindow->theme->mcanvas_x +
1526 mwindow->theme->mcanvas_w -
1528 mwindow->theme->mcanvas_h);
1529 pane[TOP_LEFT_PANE]->resize_event(
1530 mwindow->theme->mcanvas_x,
1531 mwindow->theme->mcanvas_y,
1532 cursor_x - mwindow->theme->pane_w,
1533 mwindow->theme->mcanvas_h);
1534 pane[TOP_RIGHT_PANE]->create_objects();
1537 if(vertical_panes())
1539 // create 2 horizontal panes
1540 mwindow->edl->local_session->track_start[TOP_RIGHT_PANE] =
1541 mwindow->edl->local_session->track_start[TOP_LEFT_PANE];
1542 mwindow->edl->local_session->track_start[BOTTOM_RIGHT_PANE] =
1543 mwindow->edl->local_session->track_start[BOTTOM_LEFT_PANE];
1544 mwindow->edl->local_session->view_start[TOP_RIGHT_PANE] =
1545 mwindow->edl->local_session->view_start[BOTTOM_RIGHT_PANE] =
1546 mwindow->edl->local_session->view_start[TOP_LEFT_PANE] +
1548 mwindow->theme->patchbay_w;
1549 pane[TOP_RIGHT_PANE] = new TimelinePane(mwindow,
1551 mwindow->theme->mcanvas_x +
1553 pane[TOP_LEFT_PANE]->y,
1554 mwindow->theme->mcanvas_x +
1555 mwindow->theme->mcanvas_w -
1557 pane[TOP_LEFT_PANE]->h);
1558 pane[BOTTOM_RIGHT_PANE] = new TimelinePane(mwindow,
1560 mwindow->theme->mcanvas_x +
1562 pane[BOTTOM_LEFT_PANE]->y,
1563 mwindow->theme->mcanvas_x +
1564 mwindow->theme->mcanvas_w -
1566 pane[BOTTOM_LEFT_PANE]->h);
1567 pane[TOP_LEFT_PANE]->resize_event(
1568 pane[TOP_LEFT_PANE]->x,
1569 pane[TOP_LEFT_PANE]->y,
1570 cursor_x - mwindow->theme->pane_w,
1571 pane[TOP_LEFT_PANE]->h);
1572 pane[BOTTOM_LEFT_PANE]->resize_event(
1573 pane[BOTTOM_LEFT_PANE]->x,
1574 pane[BOTTOM_LEFT_PANE]->y,
1575 cursor_x - mwindow->theme->pane_w,
1576 pane[BOTTOM_LEFT_PANE]->h);
1577 pane[TOP_RIGHT_PANE]->create_objects();
1578 pane[BOTTOM_RIGHT_PANE]->create_objects();
1581 if(horizontal_panes())
1583 // resize a horizontal pane
1584 mwindow->edl->local_session->view_start[TOP_RIGHT_PANE] +=
1586 pane[TOP_RIGHT_PANE]->x;
1587 if(mwindow->edl->local_session->view_start[TOP_RIGHT_PANE] < 0)
1588 mwindow->edl->local_session->view_start[TOP_RIGHT_PANE] = 0;
1589 pane[TOP_LEFT_PANE]->resize_event(
1590 mwindow->theme->mcanvas_x,
1591 mwindow->theme->mcanvas_y,
1592 cursor_x - mwindow->theme->pane_w,
1593 mwindow->theme->mcanvas_h);
1594 pane[TOP_RIGHT_PANE]->resize_event(
1595 mwindow->theme->mcanvas_x +
1597 pane[TOP_RIGHT_PANE]->y,
1598 mwindow->theme->mcanvas_x +
1599 mwindow->theme->mcanvas_w -
1601 mwindow->theme->mcanvas_h);
1605 // resize 2 horizontal panes
1606 mwindow->edl->local_session->view_start[TOP_RIGHT_PANE] +=
1608 pane[TOP_RIGHT_PANE]->x;
1609 if(mwindow->edl->local_session->view_start[TOP_RIGHT_PANE] < 0)
1610 mwindow->edl->local_session->view_start[TOP_RIGHT_PANE] = 0;
1611 mwindow->edl->local_session->view_start[BOTTOM_RIGHT_PANE] =
1612 mwindow->edl->local_session->view_start[TOP_RIGHT_PANE];
1614 pane[TOP_LEFT_PANE]->resize_event(
1615 mwindow->theme->mcanvas_x,
1616 pane[TOP_LEFT_PANE]->y,
1617 cursor_x - mwindow->theme->pane_w,
1618 pane[TOP_LEFT_PANE]->h);
1619 pane[TOP_RIGHT_PANE]->resize_event(
1620 mwindow->theme->mcanvas_x +
1622 pane[TOP_RIGHT_PANE]->y,
1623 mwindow->theme->mcanvas_x +
1624 mwindow->theme->mcanvas_w -
1626 pane[TOP_RIGHT_PANE]->h);
1627 pane[BOTTOM_LEFT_PANE]->resize_event(
1628 mwindow->theme->mcanvas_x,
1629 pane[BOTTOM_LEFT_PANE]->y,
1630 cursor_x - mwindow->theme->pane_w,
1631 pane[BOTTOM_LEFT_PANE]->h);
1632 pane[BOTTOM_RIGHT_PANE]->resize_event(
1633 mwindow->theme->mcanvas_x +
1635 pane[BOTTOM_RIGHT_PANE]->y,
1636 mwindow->theme->mcanvas_x +
1637 mwindow->theme->mcanvas_w -
1639 pane[BOTTOM_RIGHT_PANE]->h);
1645 void MWindowGUI::delete_x_pane(int cursor_x)
1647 // give left panes coordinates of right pane
1648 if(cursor_x < mwindow->theme->patchbay_w + PANE_DRAG_MARGIN &&
1649 pane[TOP_RIGHT_PANE])
1651 mwindow->edl->local_session->view_start[TOP_LEFT_PANE] =
1652 mwindow->edl->local_session->view_start[TOP_RIGHT_PANE] -
1653 pane[TOP_RIGHT_PANE]->x + mwindow->theme->patchbay_w;
1654 if(mwindow->edl->local_session->view_start[TOP_LEFT_PANE] < 0)
1655 mwindow->edl->local_session->view_start[TOP_LEFT_PANE] = 0;
1656 mwindow->edl->local_session->view_start[BOTTOM_LEFT_PANE] =
1657 mwindow->edl->local_session->view_start[TOP_LEFT_PANE];
1660 switch(total_panes())
1663 if(pane[TOP_LEFT_PANE] && pane[TOP_RIGHT_PANE])
1665 // delete right pane
1666 delete pane[TOP_RIGHT_PANE];
1667 pane[TOP_RIGHT_PANE] = 0;
1668 pane[TOP_LEFT_PANE]->resize_event(
1669 mwindow->theme->mcanvas_x,
1670 mwindow->theme->mcanvas_y,
1671 mwindow->theme->mcanvas_w,
1672 mwindow->theme->mcanvas_h);
1678 // delete right panes
1679 delete pane[TOP_RIGHT_PANE];
1680 pane[TOP_RIGHT_PANE] = 0;
1681 delete pane[BOTTOM_RIGHT_PANE];
1682 pane[BOTTOM_RIGHT_PANE] = 0;
1683 pane[TOP_LEFT_PANE]->resize_event(
1684 mwindow->theme->mcanvas_x,
1685 pane[TOP_LEFT_PANE]->y,
1686 mwindow->theme->mcanvas_w,
1687 pane[TOP_LEFT_PANE]->h);
1688 pane[BOTTOM_LEFT_PANE]->resize_event(
1689 mwindow->theme->mcanvas_x,
1690 pane[BOTTOM_LEFT_PANE]->y,
1691 mwindow->theme->mcanvas_w,
1692 pane[BOTTOM_LEFT_PANE]->h);
1697 void MWindowGUI::create_y_pane(int cursor_y)
1699 if(total_panes() == 1)
1701 mwindow->edl->local_session->view_start[BOTTOM_LEFT_PANE] =
1702 mwindow->edl->local_session->view_start[TOP_LEFT_PANE];
1703 mwindow->edl->local_session->track_start[BOTTOM_LEFT_PANE] =
1704 mwindow->edl->local_session->track_start[TOP_LEFT_PANE] +
1706 mwindow->theme->mtimebar_h;
1707 // do this 1st so the resize_event knows there are 2 panes
1708 pane[BOTTOM_LEFT_PANE] = new TimelinePane(mwindow,
1710 mwindow->theme->mcanvas_x,
1711 mwindow->theme->mcanvas_y +
1713 mwindow->theme->mcanvas_w,
1714 mwindow->theme->mcanvas_h -
1716 pane[TOP_LEFT_PANE]->resize_event(
1717 mwindow->theme->mcanvas_x,
1718 mwindow->theme->mcanvas_y,
1719 mwindow->theme->mcanvas_w,
1720 pane[BOTTOM_LEFT_PANE]->y -
1721 mwindow->theme->mcanvas_y -
1722 mwindow->theme->pane_h);
1723 pane[BOTTOM_LEFT_PANE]->create_objects();
1726 if(horizontal_panes())
1729 mwindow->edl->local_session->view_start[BOTTOM_LEFT_PANE] =
1730 mwindow->edl->local_session->view_start[TOP_LEFT_PANE];
1731 mwindow->edl->local_session->view_start[BOTTOM_RIGHT_PANE] =
1732 mwindow->edl->local_session->view_start[TOP_RIGHT_PANE];
1733 mwindow->edl->local_session->track_start[BOTTOM_LEFT_PANE] =
1734 mwindow->edl->local_session->track_start[BOTTOM_RIGHT_PANE] =
1735 mwindow->edl->local_session->track_start[TOP_LEFT_PANE] +
1737 mwindow->theme->mtimebar_h;
1739 pane[BOTTOM_LEFT_PANE] = new TimelinePane(mwindow,
1741 pane[TOP_LEFT_PANE]->x,
1742 mwindow->theme->mcanvas_y +
1744 pane[TOP_LEFT_PANE]->w,
1745 mwindow->theme->mcanvas_h -
1747 pane[BOTTOM_RIGHT_PANE] = new TimelinePane(mwindow,
1749 pane[TOP_RIGHT_PANE]->x,
1750 mwindow->theme->mcanvas_y +
1752 pane[TOP_RIGHT_PANE]->w,
1753 mwindow->theme->mcanvas_h -
1756 pane[TOP_LEFT_PANE]->resize_event(
1757 pane[TOP_LEFT_PANE]->x,
1758 pane[TOP_LEFT_PANE]->y,
1759 pane[TOP_LEFT_PANE]->w,
1760 pane[BOTTOM_LEFT_PANE]->y -
1761 mwindow->theme->mcanvas_y -
1762 mwindow->theme->pane_h);
1763 pane[TOP_RIGHT_PANE]->resize_event(
1764 pane[TOP_RIGHT_PANE]->x,
1765 pane[TOP_RIGHT_PANE]->y,
1766 pane[TOP_RIGHT_PANE]->w,
1767 pane[BOTTOM_RIGHT_PANE]->y -
1768 mwindow->theme->mcanvas_y -
1769 mwindow->theme->pane_h);
1771 pane[BOTTOM_LEFT_PANE]->create_objects();
1772 pane[BOTTOM_RIGHT_PANE]->create_objects();
1775 if(vertical_panes())
1778 mwindow->edl->local_session->track_start[BOTTOM_LEFT_PANE] +=
1780 (pane[BOTTOM_LEFT_PANE]->y - mwindow->theme->mcanvas_y);
1781 if(mwindow->edl->local_session->track_start[BOTTOM_LEFT_PANE] < 0)
1782 mwindow->edl->local_session->track_start[BOTTOM_LEFT_PANE] = 0;
1783 pane[TOP_LEFT_PANE]->resize_event(
1784 mwindow->theme->mcanvas_x,
1785 mwindow->theme->mcanvas_y,
1786 mwindow->theme->mcanvas_w,
1787 cursor_y - mwindow->theme->pane_h);
1788 pane[BOTTOM_LEFT_PANE]->resize_event(
1789 pane[BOTTOM_LEFT_PANE]->x,
1791 mwindow->theme->mcanvas_y,
1792 mwindow->theme->mcanvas_w,
1793 mwindow->theme->mcanvas_h -
1799 mwindow->edl->local_session->track_start[BOTTOM_LEFT_PANE] +=
1801 (pane[BOTTOM_LEFT_PANE]->y - mwindow->theme->mcanvas_y);
1802 if(mwindow->edl->local_session->track_start[BOTTOM_LEFT_PANE] < 0)
1803 mwindow->edl->local_session->track_start[BOTTOM_LEFT_PANE] = 0;
1804 mwindow->edl->local_session->track_start[BOTTOM_RIGHT_PANE] =
1805 mwindow->edl->local_session->track_start[BOTTOM_LEFT_PANE];
1806 pane[TOP_LEFT_PANE]->resize_event(
1807 pane[TOP_LEFT_PANE]->x,
1808 pane[TOP_LEFT_PANE]->y,
1809 pane[TOP_LEFT_PANE]->w,
1810 cursor_y - mwindow->theme->pane_h);
1811 pane[BOTTOM_LEFT_PANE]->resize_event(
1812 pane[BOTTOM_LEFT_PANE]->x,
1814 mwindow->theme->mcanvas_y,
1815 pane[BOTTOM_LEFT_PANE]->w,
1816 mwindow->theme->mcanvas_h -
1818 pane[TOP_RIGHT_PANE]->resize_event(
1819 pane[TOP_RIGHT_PANE]->x,
1820 pane[TOP_RIGHT_PANE]->y,
1821 pane[TOP_RIGHT_PANE]->w,
1822 cursor_y - mwindow->theme->pane_h);
1823 pane[BOTTOM_RIGHT_PANE]->resize_event(
1824 pane[BOTTOM_RIGHT_PANE]->x,
1826 mwindow->theme->mcanvas_y,
1827 pane[BOTTOM_RIGHT_PANE]->w,
1828 mwindow->theme->mcanvas_h -
1833 void MWindowGUI::delete_y_pane(int cursor_y)
1835 if(cursor_y < mwindow->theme->mtimebar_h +
1837 pane[BOTTOM_LEFT_PANE])
1839 // give top pane coordinates of bottom pane
1840 mwindow->edl->local_session->track_start[TOP_LEFT_PANE] =
1841 mwindow->edl->local_session->track_start[BOTTOM_LEFT_PANE] -
1842 pane[BOTTOM_LEFT_PANE]->y;
1843 if(mwindow->edl->local_session->track_start[TOP_LEFT_PANE] < 0)
1844 mwindow->edl->local_session->track_start[TOP_LEFT_PANE] = 0;
1845 mwindow->edl->local_session->track_start[TOP_RIGHT_PANE] =
1846 mwindow->edl->local_session->track_start[TOP_LEFT_PANE];
1850 switch(total_panes())
1853 delete pane[BOTTOM_LEFT_PANE];
1854 pane[BOTTOM_LEFT_PANE] = 0;
1855 pane[TOP_LEFT_PANE]->resize_event(
1856 mwindow->theme->mcanvas_x,
1857 mwindow->theme->mcanvas_y,
1858 mwindow->theme->mcanvas_w,
1859 mwindow->theme->mcanvas_h);
1863 // delete bottom 2 panes
1865 delete pane[BOTTOM_LEFT_PANE];
1866 pane[BOTTOM_LEFT_PANE] = 0;
1867 delete pane[BOTTOM_RIGHT_PANE];
1868 pane[BOTTOM_RIGHT_PANE] = 0;
1869 pane[TOP_LEFT_PANE]->resize_event(
1870 pane[TOP_LEFT_PANE]->x,
1871 mwindow->theme->mcanvas_y,
1872 pane[TOP_LEFT_PANE]->w,
1873 mwindow->theme->mcanvas_h);
1874 pane[TOP_RIGHT_PANE]->resize_event(
1875 pane[TOP_RIGHT_PANE]->x,
1876 mwindow->theme->mcanvas_y,
1877 pane[TOP_RIGHT_PANE]->w,
1878 mwindow->theme->mcanvas_h);
1883 void MWindowGUI::stop_pane_drag()
1886 resource_thread->stop_draw(1);
1890 // cursor position relative to canvas
1891 int cursor_x = x_pane_drag->get_x() -
1893 BC_DisplayInfo::get_left_border() -
1894 mwindow->theme->mcanvas_x +
1895 mwindow->theme->pane_w;
1900 if(cursor_x >= mwindow->theme->patchbay_w + PANE_DRAG_MARGIN &&
1901 cursor_x < mwindow->theme->mcanvas_w -
1902 BC_ScrollBar::get_span(SCROLL_VERT) -
1905 create_x_pane(cursor_x);
1906 mwindow->edl->local_session->x_pane = cursor_x;
1911 delete_x_pane(cursor_x);
1912 mwindow->edl->local_session->x_pane = -1;
1920 // cursor position relative to canvas
1921 int cursor_y = y_pane_drag->get_y() -
1923 BC_DisplayInfo::get_top_border() -
1924 mwindow->theme->mcanvas_y +
1925 mwindow->theme->pane_h;
1931 if(cursor_y >= mwindow->theme->mtimebar_h +
1933 cursor_y < mwindow->theme->mcanvas_h -
1934 BC_ScrollBar::get_span(SCROLL_HORIZ) -
1937 create_y_pane(cursor_y);
1938 mwindow->edl->local_session->y_pane = cursor_y;
1942 delete_y_pane(cursor_y);
1943 mwindow->edl->local_session->y_pane = -1;
1947 update_pane_dividers();
1949 // required to get new widgets to appear
1951 resource_thread->start_draw();
1954 // create panes from EDL
1955 void MWindowGUI::load_panes()
1957 int need_x_panes = 0;
1958 int need_y_panes = 0;
1959 // use names from create functions
1960 int cursor_x = mwindow->edl->local_session->x_pane;
1961 int cursor_y = mwindow->edl->local_session->y_pane;
1963 resource_thread->stop_draw(1);
1965 mwindow->theme->patchbay_w + PANE_DRAG_MARGIN &&
1967 mwindow->theme->mcanvas_w -
1968 BC_ScrollBar::get_span(SCROLL_VERT) -
1975 mwindow->theme->mtimebar_h + PANE_DRAG_MARGIN &&
1977 mwindow->theme->mcanvas_h -
1978 BC_ScrollBar::get_span(SCROLL_HORIZ) -
1984 //printf("MWindowGUI::load_panes %d %d %d\n", __LINE__, need_x_panes, need_y_panes);
1992 if(total_panes() == 1)
1995 //printf("MWindowGUI::load_panes %d\n", __LINE__);
1996 pane[TOP_RIGHT_PANE] = new TimelinePane(mwindow,
1998 mwindow->theme->mcanvas_x +
2000 mwindow->theme->mcanvas_y,
2001 mwindow->theme->mcanvas_x +
2002 mwindow->theme->mcanvas_w -
2004 cursor_y - mwindow->theme->pane_h);
2005 pane[BOTTOM_LEFT_PANE] = new TimelinePane(mwindow,
2007 mwindow->theme->mcanvas_x,
2008 mwindow->theme->mcanvas_y +
2010 cursor_x - mwindow->theme->pane_w,
2011 mwindow->theme->mcanvas_h -
2013 pane[BOTTOM_RIGHT_PANE] = new TimelinePane(mwindow,
2015 pane[TOP_RIGHT_PANE]->x,
2016 mwindow->theme->mcanvas_y +
2018 pane[TOP_RIGHT_PANE]->w,
2019 mwindow->theme->mcanvas_h -
2021 pane[TOP_LEFT_PANE]->resize_event(
2022 pane[TOP_LEFT_PANE]->x,
2023 pane[TOP_LEFT_PANE]->y,
2024 cursor_x - mwindow->theme->pane_w,
2025 cursor_y - mwindow->theme->pane_h);
2026 pane[TOP_RIGHT_PANE]->create_objects();
2027 pane[BOTTOM_LEFT_PANE]->create_objects();
2028 pane[BOTTOM_RIGHT_PANE]->create_objects();
2031 if(horizontal_panes())
2033 // create vertical panes
2034 //printf("MWindowGUI::load_panes %d\n", __LINE__);
2035 pane[BOTTOM_LEFT_PANE] = new TimelinePane(mwindow,
2037 mwindow->theme->mcanvas_x,
2038 mwindow->theme->mcanvas_y +
2040 cursor_x - mwindow->theme->pane_w,
2041 mwindow->theme->mcanvas_h -
2043 pane[BOTTOM_RIGHT_PANE] = new TimelinePane(mwindow,
2045 pane[TOP_RIGHT_PANE]->x,
2046 mwindow->theme->mcanvas_y +
2048 pane[TOP_RIGHT_PANE]->w,
2049 mwindow->theme->mcanvas_h -
2051 pane[TOP_LEFT_PANE]->resize_event(
2052 pane[TOP_LEFT_PANE]->x,
2053 pane[TOP_LEFT_PANE]->y,
2054 cursor_x - mwindow->theme->pane_w,
2055 cursor_y - mwindow->theme->pane_h);
2056 pane[TOP_RIGHT_PANE]->resize_event(
2057 mwindow->theme->mcanvas_x +
2059 mwindow->theme->mcanvas_y,
2060 mwindow->theme->mcanvas_x +
2061 mwindow->theme->mcanvas_w -
2063 cursor_y - mwindow->theme->pane_h);
2064 pane[BOTTOM_LEFT_PANE]->create_objects();
2065 pane[BOTTOM_RIGHT_PANE]->create_objects();
2068 if(vertical_panes())
2070 // create horizontal panes
2071 //printf("MWindowGUI::load_panes %d\n", __LINE__);
2072 pane[TOP_RIGHT_PANE] = new TimelinePane(mwindow,
2074 mwindow->theme->mcanvas_x +
2076 mwindow->theme->mcanvas_y,
2077 mwindow->theme->mcanvas_x +
2078 mwindow->theme->mcanvas_w -
2080 cursor_y - mwindow->theme->pane_h);
2081 pane[BOTTOM_RIGHT_PANE] = new TimelinePane(mwindow,
2083 pane[TOP_RIGHT_PANE]->x,
2084 mwindow->theme->mcanvas_y +
2086 pane[TOP_RIGHT_PANE]->w,
2087 mwindow->theme->mcanvas_h -
2089 pane[TOP_LEFT_PANE]->resize_event(
2090 pane[TOP_LEFT_PANE]->x,
2091 pane[TOP_LEFT_PANE]->y,
2092 cursor_x - mwindow->theme->pane_w,
2093 cursor_y - mwindow->theme->pane_h);
2094 pane[BOTTOM_LEFT_PANE]->resize_event(
2095 pane[TOP_LEFT_PANE]->x,
2096 mwindow->theme->mcanvas_y +
2098 mwindow->theme->mcanvas_x +
2099 mwindow->theme->mcanvas_w -
2101 mwindow->theme->mcanvas_h -
2103 pane[TOP_RIGHT_PANE]->create_objects();
2104 pane[BOTTOM_RIGHT_PANE]->create_objects();
2111 //printf("MWindowGUI::load_panes %d\n", __LINE__);
2112 pane[TOP_LEFT_PANE]->resize_event(
2113 pane[TOP_LEFT_PANE]->x,
2114 pane[TOP_LEFT_PANE]->y,
2115 cursor_x - mwindow->theme->pane_w,
2116 cursor_y - mwindow->theme->pane_h);
2117 pane[TOP_RIGHT_PANE]->resize_event(
2118 mwindow->theme->mcanvas_x +
2120 mwindow->theme->mcanvas_y,
2121 mwindow->theme->mcanvas_x +
2122 mwindow->theme->mcanvas_w -
2124 cursor_y - mwindow->theme->pane_h);
2125 pane[BOTTOM_LEFT_PANE]->resize_event(
2126 pane[TOP_LEFT_PANE]->x,
2127 mwindow->theme->mcanvas_y +
2129 mwindow->theme->mcanvas_x +
2130 mwindow->theme->mcanvas_w -
2132 mwindow->theme->mcanvas_h -
2134 pane[BOTTOM_RIGHT_PANE]->resize_event(
2135 pane[TOP_RIGHT_PANE]->x,
2136 mwindow->theme->mcanvas_y +
2138 pane[TOP_RIGHT_PANE]->w,
2139 mwindow->theme->mcanvas_h -
2148 if(pane[BOTTOM_LEFT_PANE]) delete pane[BOTTOM_LEFT_PANE];
2149 if(pane[BOTTOM_RIGHT_PANE]) delete pane[BOTTOM_RIGHT_PANE];
2150 pane[BOTTOM_LEFT_PANE] = 0;
2151 pane[BOTTOM_RIGHT_PANE] = 0;
2153 if(!pane[TOP_RIGHT_PANE])
2155 pane[TOP_RIGHT_PANE] = new TimelinePane(mwindow,
2157 mwindow->theme->mcanvas_x +
2159 mwindow->theme->mcanvas_y,
2160 mwindow->theme->mcanvas_x +
2161 mwindow->theme->mcanvas_w -
2163 mwindow->theme->mcanvas_h);
2164 pane[TOP_LEFT_PANE]->resize_event(
2165 mwindow->theme->mcanvas_x,
2166 mwindow->theme->mcanvas_y,
2167 cursor_x - mwindow->theme->pane_w,
2168 mwindow->theme->mcanvas_h);
2169 pane[TOP_RIGHT_PANE]->create_objects();
2173 pane[TOP_LEFT_PANE]->resize_event(
2174 mwindow->theme->mcanvas_x,
2175 mwindow->theme->mcanvas_y,
2176 cursor_x - mwindow->theme->pane_w,
2177 mwindow->theme->mcanvas_h);
2178 pane[TOP_RIGHT_PANE]->resize_event(
2179 mwindow->theme->mcanvas_x +
2181 pane[TOP_RIGHT_PANE]->y,
2182 mwindow->theme->mcanvas_x +
2183 mwindow->theme->mcanvas_w -
2185 mwindow->theme->mcanvas_h);
2193 if(pane[TOP_RIGHT_PANE]) delete pane[TOP_RIGHT_PANE];
2194 if(pane[BOTTOM_RIGHT_PANE]) delete pane[BOTTOM_RIGHT_PANE];
2195 pane[TOP_RIGHT_PANE] = 0;
2196 pane[BOTTOM_RIGHT_PANE] = 0;
2198 if(!pane[BOTTOM_LEFT_PANE])
2200 //printf("MWindowGUI::load_panes %d\n", __LINE__);
2201 pane[BOTTOM_LEFT_PANE] = new TimelinePane(mwindow,
2203 mwindow->theme->mcanvas_x,
2204 mwindow->theme->mcanvas_y +
2206 mwindow->theme->mcanvas_w,
2207 mwindow->theme->mcanvas_h -
2209 pane[TOP_LEFT_PANE]->resize_event(
2210 mwindow->theme->mcanvas_x,
2211 mwindow->theme->mcanvas_y,
2212 mwindow->theme->mcanvas_w,
2213 pane[BOTTOM_LEFT_PANE]->y -
2214 mwindow->theme->mcanvas_y -
2215 mwindow->theme->pane_h);
2216 pane[BOTTOM_LEFT_PANE]->create_objects();
2220 pane[TOP_LEFT_PANE]->resize_event(
2221 mwindow->theme->mcanvas_x,
2222 mwindow->theme->mcanvas_y,
2223 mwindow->theme->mcanvas_w,
2224 cursor_y - mwindow->theme->pane_h);
2225 pane[BOTTOM_LEFT_PANE]->resize_event(
2226 pane[BOTTOM_LEFT_PANE]->x,
2228 mwindow->theme->mcanvas_y,
2229 mwindow->theme->mcanvas_w,
2230 mwindow->theme->mcanvas_h -
2237 if(pane[TOP_RIGHT_PANE]) delete pane[TOP_RIGHT_PANE];
2238 if(pane[BOTTOM_RIGHT_PANE]) delete pane[BOTTOM_RIGHT_PANE];
2239 if(pane[BOTTOM_LEFT_PANE]) delete pane[BOTTOM_LEFT_PANE];
2240 pane[TOP_RIGHT_PANE] = 0;
2241 pane[BOTTOM_RIGHT_PANE] = 0;
2242 pane[BOTTOM_LEFT_PANE] = 0;
2243 pane[TOP_LEFT_PANE]->resize_event(
2244 mwindow->theme->mcanvas_x,
2245 mwindow->theme->mcanvas_y,
2246 mwindow->theme->mcanvas_w,
2247 mwindow->theme->mcanvas_h);
2250 update_pane_dividers();
2253 resource_thread->start_draw();
2256 void MWindowGUI::update_pane_dividers()
2259 if(horizontal_panes() || total_panes() == 4)
2261 int x = pane[TOP_RIGHT_PANE]->x - mwindow->theme->pane_w;
2262 int y = mwindow->theme->mcanvas_y;
2263 int h = mwindow->theme->mcanvas_h;
2267 add_subwindow(x_divider = new PaneDivider(
2268 mwindow, x, y, h, 1));
2269 x_divider->create_objects();
2273 x_divider->reposition_window(x, y, h);
2286 if(vertical_panes() || total_panes() == 4)
2288 int x = mwindow->theme->mcanvas_x;
2289 int y = pane[BOTTOM_LEFT_PANE]->y -
2290 mwindow->theme->pane_h;
2291 int w = mwindow->theme->mcanvas_w;
2294 add_subwindow(y_divider = new PaneDivider(
2295 mwindow, x, y, w, 0));
2296 y_divider->create_objects();
2300 y_divider->reposition_window(x, y, w);
2314 void MWindowGUI::draw_samplemovement()
2321 update_scrollbars(1);
2324 void MWindowGUI::draw_trackmovement()
2326 update_scrollbars(0);
2334 PaneButton::PaneButton(MWindow *mwindow, int x, int y)
2335 : BC_Button(x, y, mwindow->theme->get_image_set("pane"))
2337 this->mwindow = mwindow;
2340 int PaneButton::cursor_motion_event()
2342 if(get_top_level()->get_button_down() &&
2344 get_status() == BUTTON_DOWNHI &&
2347 // printf("PaneButton::cursor_motion_event %d\n", __LINE__);
2349 if(get_cursor_x() < 0 && !mwindow->gui->dragging_pane)
2351 mwindow->gui->start_x_pane_drag();
2354 if(get_cursor_y() < 0 && !mwindow->gui->dragging_pane)
2356 mwindow->gui->start_y_pane_drag();
2360 mwindow->gui->handle_pane_drag();
2362 int result = BC_Button::cursor_motion_event();
2366 int PaneButton::button_release_event()
2368 mwindow->gui->stop_pane_drag();
2371 int result = BC_Button::button_release_event();
2376 FFMpegToggle::FFMpegToggle(MWindow *mwindow, MButtons *mbuttons, int x, int y)
2377 : BC_Toggle(x, y, mwindow->theme->ffmpeg_toggle, mwindow->preferences->ffmpeg_early_probe)
2379 this->mwindow = mwindow;
2380 this->mbuttons = mbuttons;
2381 set_tooltip(_("FFMpeg early probe"));
2384 FFMpegToggle::~FFMpegToggle()
2388 int FFMpegToggle::handle_event()
2390 mwindow->preferences->ffmpeg_early_probe = get_value();
2391 mwindow->show_warning(&mwindow->preferences->warn_indecies,
2392 _("Changing the base codecs may require rebuilding indecies."));