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++)
125 cwindow_remote_handler = 0;
126 record_remote_handler = 0;
131 MWindowGUI::~MWindowGUI()
133 delete android_control;
134 delete cwindow_remote_handler;
135 delete record_remote_handler;
136 delete remote_control;
137 // delete samplescroll;
138 // delete trackscroll;
139 for(int i = 0; i < TOTAL_PANES; i++)
140 if(pane[i]) delete pane[i];
142 delete render_engine;
143 delete resource_thread;
144 resource_pixmaps.remove_all_objects();
155 void MWindowGUI::get_scrollbars(int flush)
157 //int64_t h_needed = mwindow->edl->get_tracks_height(mwindow->theme);
158 //int64_t w_needed = mwindow->edl->get_tracks_width();
159 int need_xscroll = 0;
160 int need_yscroll = 0;
161 view_w = mwindow->theme->mcanvas_w;
162 view_h = mwindow->theme->mcanvas_h;
164 // Scrollbars are constitutive
165 need_xscroll = need_yscroll = 1;
166 view_h = mwindow->theme->mcanvas_h;
167 view_w = mwindow->theme->mcanvas_w;
169 // for(int i = 0; i < 2; i++)
171 // if(w_needed > view_w)
174 // view_h = mwindow->theme->mcanvas_h - SCROLL_SPAN;
179 // if(h_needed > view_h)
182 // view_w = mwindow->theme->mcanvas_w - SCROLL_SPAN;
187 //printf("MWindowGUI::get_scrollbars 1\n");
189 if(canvas && (view_w != canvas->get_w() || view_h != canvas->get_h()))
191 canvas->reposition_window(mwindow->theme->mcanvas_x,
192 mwindow->theme->mcanvas_y,
200 add_subwindow(samplescroll = new SampleScroll(mwindow,
202 mwindow->theme->mhscroll_x,
203 mwindow->theme->mhscroll_y,
204 mwindow->theme->mhscroll_w));
206 samplescroll->resize_event();
208 samplescroll->set_position(0);
212 if(samplescroll) delete samplescroll;
214 mwindow->edl->local_session->view_start = 0;
220 //printf("MWindowGUI::get_scrollbars 1.1 %p %p\n", this, canvas);
222 add_subwindow(trackscroll = new TrackScroll(mwindow,
224 mwindow->theme->mvscroll_x,
225 mwindow->theme->mvscroll_y,
226 mwindow->theme->mvscroll_h));
228 trackscroll->resize_event();
231 //printf("MWindowGUI::get_scrollbars 1.2\n");
232 trackscroll->update_length(mwindow->edl->get_tracks_height(mwindow->theme),
233 mwindow->edl->local_session->track_start,
236 //printf("MWindowGUI::get_scrollbars 1.3\n");
240 if(trackscroll) delete trackscroll;
242 mwindow->edl->local_session->track_start = 0;
245 if(flush) this->flush();
250 void MWindowGUI::create_objects()
254 resource_thread = new ResourceThread(mwindow, this);
255 resource_thread->create_objects();
258 if(debug) printf("MWindowGUI::create_objects %d\n", __LINE__);
259 set_icon(mwindow->theme->get_image("mwindow_icon"));
260 remote_control = new RemoteControl(this);
261 cwindow_remote_handler = new CWindowRemoteHandler(remote_control);
262 record_remote_handler = new RecordRemoteHandler(remote_control);
263 mwindow->reset_android_remote();
265 if(debug) printf("MWindowGUI::create_objects %d\n", __LINE__);
267 int x = get_w() - MainShBtns::calculate_w(0);
268 add_subwindow(mainmenu = new MainMenu(mwindow, this, x));
269 mainmenu->create_objects();
270 add_subwindow(mainshbtns = new MainShBtns(mwindow, x, -1));
271 mainshbtns->load(mwindow->preferences);
272 mwindow->theme->get_mwindow_sizes(this, get_w(), get_h());
273 mwindow->theme->draw_mwindow_bg(this);
274 if(debug) printf("MWindowGUI::create_objects %d\n", __LINE__);
276 add_subwindow(mbuttons = new MButtons(mwindow, this));
277 mbuttons->create_objects();
278 add_subwindow(ffmpeg_toggle = new FFMpegToggle(mwindow, mbuttons, menu_w(), menu_h()+2));
280 pane[TOP_LEFT_PANE] = new TimelinePane(mwindow,
282 mwindow->theme->mcanvas_x,
283 mwindow->theme->mcanvas_y,
284 mwindow->theme->mcanvas_w,
285 mwindow->theme->mcanvas_h);
286 pane[TOP_LEFT_PANE]->create_objects();
288 // add_subwindow(timebar = new MTimeBar(mwindow,
290 // mwindow->theme->mtimebar_x,
291 // mwindow->theme->mtimebar_y,
292 // mwindow->theme->mtimebar_w,
293 // mwindow->theme->mtimebar_h));
294 // timebar->create_objects();
296 // if(debug) printf("MWindowGUI::create_objects %d\n", __LINE__);
297 // add_subwindow(patchbay = new PatchBay(mwindow, this));
298 // patchbay->create_objects();
300 // if(debug) printf("MWindowGUI::create_objects %d\n", __LINE__);
301 // get_scrollbars(0);
303 // if(debug) printf("MWindowGUI::create_objects %d\n", __LINE__);
304 // mwindow->gui->add_subwindow(canvas = new TrackCanvas(mwindow, this));
305 // canvas->create_objects();
308 if(debug) printf("MWindowGUI::create_objects %d\n", __LINE__);
309 add_subwindow(zoombar = new ZoomBar(mwindow, this));
310 zoombar->create_objects();
313 if(debug) printf("MWindowGUI::create_objects %d\n", __LINE__);
314 add_subwindow(statusbar = new StatusBar(mwindow, this));
315 statusbar->create_objects();
319 if(debug) printf("MWindowGUI::create_objects %d\n", __LINE__);
320 add_subwindow(mainclock = new MainClock(mwindow,
321 mwindow->theme->mclock_x,
322 mwindow->theme->mclock_y,
323 mwindow->theme->mclock_w));
324 mainclock->set_position_offset( (double)
325 (mwindow->edl->session->get_frame_offset() /
326 mwindow->edl->session->frame_rate));
327 if(debug) printf("MWindowGUI::create_objects %d\n", __LINE__);
328 mainclock->update(0);
332 // if(debug) printf("MWindowGUI::create_objects %d\n", __LINE__);
333 // cursor = new MainCursor(mwindow, this);
334 // cursor->create_objects();
337 if(debug) printf("MWindowGUI::create_objects %d\n", __LINE__);
338 add_subwindow(edit_menu = new EditPopup(mwindow, this));
339 edit_menu->create_objects();
342 if(debug) printf("MWindowGUI::create_objects %d\n", __LINE__);
343 add_subwindow(plugin_menu = new PluginPopup(mwindow, this));
344 plugin_menu->create_objects();
347 if(debug) printf("MWindowGUI::create_objects %d\n", __LINE__);
348 add_subwindow(keyframe_menu = new KeyframePopup(mwindow, this));
349 keyframe_menu->create_objects();
350 add_subwindow(keyframe_hide = new KeyframeHidePopup(mwindow, this));
351 keyframe_hide->create_objects();
354 if(debug) printf("MWindowGUI::create_objects %d\n", __LINE__);
355 add_subwindow(transition_menu = new TransitionPopup(mwindow, this));
356 transition_menu->create_objects();
359 channel_info = new ChannelInfo(mwindow);
361 db_window = new DbWindow(mwindow);
362 swindow = new SWindow(mwindow);
364 if(debug) printf("MWindowGUI::create_objects %d\n", __LINE__);
366 add_subwindow(pane_button = new PaneButton(mwindow,
367 get_w() - mwindow->theme->get_image_set("pane")[0]->get_w(),
368 mwindow->theme->mzoom_y + 1 - mwindow->theme->get_image_set("pane")[0]->get_h()));
370 pane[TOP_LEFT_PANE]->canvas->activate();
372 if(debug) printf("MWindowGUI::create_objects %d\n", __LINE__);
375 void MWindowGUI::redraw_time_dependancies()
377 zoombar->redraw_time_dependancies();
378 for(int i = 0; i < TOTAL_PANES; i++)
379 if(pane[i] && pane[i]->timebar) pane[i]->timebar->update(0);
380 mainclock->update(mwindow->edl->local_session->get_selectionstart(1));
383 int MWindowGUI::focus_in_event()
385 for(int i = 0; i < TOTAL_PANES; i++)
386 if(pane[i]) pane[i]->cursor->focus_in_event();
390 int MWindowGUI::focus_out_event()
392 for(int i = 0; i < TOTAL_PANES; i++)
393 if(pane[i]) pane[i]->cursor->focus_out_event();
398 int MWindowGUI::resize_event(int w, int h)
400 //printf("MWindowGUI::resize_event %d\n", __LINE__);
401 mwindow->session->mwindow_w = w;
402 mwindow->session->mwindow_h = h;
403 int x = w - MainShBtns::calculate_w(0);
404 mainmenu->resize_event(x, mainmenu->get_h());
405 mainshbtns->reposition_window(x, -1);
406 mwindow->theme->get_mwindow_sizes(this, w, h);
407 mwindow->theme->draw_mwindow_bg(this);
408 mbuttons->resize_event();
409 ffmpeg_toggle->reposition_window(menu_w(), menu_h()+2);
410 statusbar->resize_event();
412 resource_thread->stop_draw(1);
414 if(total_panes() > 1)
416 if(horizontal_panes())
418 // printf("MWindowGUI::resize_event %d %d %d\n",
420 // pane[TOP_RIGHT_PANE]->x,
421 // mwindow->theme->mcanvas_w -
422 // BC_ScrollBar::get_span(SCROLL_VERT) -
423 // PANE_DRAG_MARGIN);
424 if(pane[TOP_RIGHT_PANE]->x >= mwindow->theme->mcanvas_w -
425 BC_ScrollBar::get_span(SCROLL_VERT) -
428 delete_x_pane(pane[TOP_RIGHT_PANE]->x);
429 mwindow->edl->local_session->x_pane = -1;
435 if(pane[BOTTOM_LEFT_PANE]->y >= mwindow->theme->mzoom_y -
436 BC_ScrollBar::get_span(SCROLL_HORIZ) -
439 delete_y_pane(pane[BOTTOM_LEFT_PANE]->y);
440 mwindow->edl->local_session->y_pane = -1;
445 if(pane[TOP_RIGHT_PANE]->x >= mwindow->theme->mcanvas_w -
446 BC_ScrollBar::get_span(SCROLL_VERT) -
449 delete_x_pane(pane[TOP_RIGHT_PANE]->x);
450 mwindow->edl->local_session->x_pane = -1;
453 if(pane[BOTTOM_LEFT_PANE]->y >= mwindow->theme->mzoom_y -
454 BC_ScrollBar::get_span(SCROLL_HORIZ) -
457 delete_y_pane(pane[BOTTOM_LEFT_PANE]->y);
458 mwindow->edl->local_session->y_pane = -1;
463 if(total_panes() == 1)
465 pane[TOP_LEFT_PANE]->resize_event(
466 mwindow->theme->mcanvas_x,
467 mwindow->theme->mcanvas_y,
468 mwindow->theme->mcanvas_w,
469 mwindow->theme->mcanvas_h);
472 if(horizontal_panes())
474 pane[TOP_LEFT_PANE]->resize_event(
475 pane[TOP_LEFT_PANE]->x,
476 pane[TOP_LEFT_PANE]->y,
477 pane[TOP_LEFT_PANE]->w,
478 mwindow->theme->mcanvas_h);
479 pane[TOP_RIGHT_PANE]->resize_event(
480 pane[TOP_RIGHT_PANE]->x,
481 pane[TOP_RIGHT_PANE]->y,
482 mwindow->theme->mcanvas_w - pane[TOP_RIGHT_PANE]->x,
483 mwindow->theme->mcanvas_h);
488 pane[TOP_LEFT_PANE]->resize_event(
489 pane[TOP_LEFT_PANE]->x,
490 pane[TOP_LEFT_PANE]->y,
491 mwindow->theme->mcanvas_w,
492 pane[TOP_LEFT_PANE]->h);
493 pane[BOTTOM_LEFT_PANE]->resize_event(
494 pane[BOTTOM_LEFT_PANE]->x,
495 pane[BOTTOM_LEFT_PANE]->y,
496 mwindow->theme->mcanvas_w,
497 mwindow->theme->mcanvas_y +
498 mwindow->theme->mcanvas_h -
499 pane[BOTTOM_LEFT_PANE]->y);
503 pane[TOP_LEFT_PANE]->resize_event(
504 pane[TOP_LEFT_PANE]->x,
505 pane[TOP_LEFT_PANE]->y,
506 pane[TOP_LEFT_PANE]->w,
507 pane[TOP_LEFT_PANE]->h);
508 pane[TOP_RIGHT_PANE]->resize_event(
509 pane[TOP_RIGHT_PANE]->x,
510 pane[TOP_RIGHT_PANE]->y,
511 mwindow->theme->mcanvas_w - pane[TOP_RIGHT_PANE]->x,
512 pane[TOP_RIGHT_PANE]->h);
513 pane[BOTTOM_LEFT_PANE]->resize_event(
514 pane[BOTTOM_LEFT_PANE]->x,
515 pane[BOTTOM_LEFT_PANE]->y,
516 pane[BOTTOM_LEFT_PANE]->w,
517 mwindow->theme->mcanvas_y +
518 mwindow->theme->mcanvas_h -
519 pane[BOTTOM_LEFT_PANE]->y);
520 pane[BOTTOM_RIGHT_PANE]->resize_event(
521 pane[BOTTOM_RIGHT_PANE]->x,
522 pane[BOTTOM_RIGHT_PANE]->y,
523 mwindow->theme->mcanvas_w -
524 pane[BOTTOM_RIGHT_PANE]->x,
525 mwindow->theme->mcanvas_y +
526 mwindow->theme->mcanvas_h -
527 pane[BOTTOM_RIGHT_PANE]->y);
530 resource_thread->start_draw();
532 update_pane_dividers();
533 zoombar->resize_event();
534 pane_button->reposition_window(w - mwindow->theme->get_image_set("pane")[0]->get_w(),
535 mwindow->theme->mzoom_y + 1 - mwindow->theme->get_image_set("pane")[0]->get_h());
536 // get_scrollbars(0);
537 // canvas->resize_event();
538 //printf("MWindowGUI::resize_event %d\n", __LINE__);
539 // required to get new widgets to appear after a pane deletion
544 int MWindowGUI::total_panes()
547 for(int i = 0; i < TOTAL_PANES; i++)
552 int MWindowGUI::vertical_panes()
554 return total_panes() == 2 &&
555 pane[TOP_LEFT_PANE] &&
556 pane[BOTTOM_LEFT_PANE];
559 int MWindowGUI::horizontal_panes()
561 return total_panes() == 2 &&
562 pane[TOP_LEFT_PANE] &&
563 pane[TOP_RIGHT_PANE];
566 TimelinePane* MWindowGUI::get_focused_pane()
568 if(pane[focused_pane]) return pane[focused_pane];
569 for(int i = 0; i < TOTAL_PANES; i++)
571 if(pane[i]) return pane[i];
576 void MWindowGUI::activate_timeline()
578 if(pane[focused_pane])
580 pane[focused_pane]->activate();
584 for(int i = 0; i < TOTAL_PANES; i++)
595 void MWindowGUI::deactivate_timeline()
597 for(int i = 0; i < TOTAL_PANES; i++)
601 pane[i]->canvas->deactivate();
606 void MWindowGUI::update_title(char *path)
609 char filename[BCTEXTLEN], string[BCTEXTLEN];
610 fs.extract_name(filename, path);
611 sprintf(string, _(PROGRAM_NAME ": %s"), filename);
613 //printf("MWindowGUI::update_title %s\n", string);
617 void MWindowGUI::draw_overlays(int flash_it)
619 for(int i = 0; i < TOTAL_PANES; i++)
623 pane[i]->canvas->draw_overlays();
624 if(flash_it) pane[i]->canvas->flash();
629 void MWindowGUI::update_timebar(int flush_it)
631 for(int i = 0; i < TOTAL_PANES; i++)
633 if(pane[i] && pane[i]->timebar)
635 pane[i]->timebar->update(flush_it);
640 void MWindowGUI::update_timebar_highlights()
642 for(int i = 0; i < TOTAL_PANES; i++)
644 if(pane[i] && pane[i]->timebar)
646 pane[i]->timebar->update_highlights();
652 void MWindowGUI::update_patchbay()
654 for(int i = 0; i < TOTAL_PANES; i++)
656 if(pane[i] && pane[i]->patchbay)
658 pane[i]->patchbay->update();
663 void MWindowGUI::draw_indexes(Indexable *indexable)
665 for(int i = 0; i < TOTAL_PANES; i++)
669 pane[i]->canvas->draw_indexes(indexable);
674 void MWindowGUI::draw_canvas(int mode /* = 0 */, int hide_cursor /* = 1 */)
676 if(mode != IGNORE_THREAD)
678 resource_thread->stop_draw(1);
682 for(int i = 0; i < TOTAL_PANES; i++)
686 pane[i]->canvas->draw(mode, hide_cursor);
691 if(mode != IGNORE_THREAD)
693 resource_thread->start_draw();
698 void MWindowGUI::flash_canvas(int flush)
700 for(int i = 0; i < TOTAL_PANES; i++)
704 pane[i]->canvas->flash(flush);
709 void MWindowGUI::draw_cursor(int do_plugintoggles)
711 for(int i = 0; i < TOTAL_PANES; i++)
715 pane[i]->cursor->draw(do_plugintoggles);
720 void MWindowGUI::show_cursor(int do_plugintoggles)
722 for(int i = 0; i < TOTAL_PANES; i++)
726 pane[i]->cursor->show(do_plugintoggles);
731 void MWindowGUI::hide_cursor(int do_plugintoggles)
733 for(int i = 0; i < TOTAL_PANES; i++)
737 pane[i]->cursor->hide(do_plugintoggles);
742 void MWindowGUI::update_cursor()
744 for(int i = 0; i < TOTAL_PANES; i++)
748 pane[i]->cursor->update();
753 void MWindowGUI::set_playing_back(int value)
755 for(int i = 0; i < TOTAL_PANES; i++)
759 pane[i]->cursor->playing_back = value;
764 void MWindowGUI::update_plugintoggles()
766 for(int i = 0; i < TOTAL_PANES; i++)
770 pane[i]->canvas->refresh_plugintoggles();
776 void MWindowGUI::update_scrollbars(int flush)
778 for(int i = 0; i < TOTAL_PANES; i++)
782 pane[i]->update(1, 0, 0, 0);
785 if(flush) this->flush();
788 void MWindowGUI::reset_meters()
790 for(int i = 0; i < TOTAL_PANES; i++)
792 if(pane[i] && pane[i]->patchbay)
794 pane[i]->patchbay->reset_meters();
799 void MWindowGUI::stop_meters()
801 for(int i = 0; i < TOTAL_PANES; i++)
803 if(pane[i] && pane[i]->patchbay)
805 pane[i]->patchbay->stop_meters();
810 void MWindowGUI::update_meters(ArrayList<double> *module_levels)
812 for(int i = 0; i < TOTAL_PANES; i++)
814 if(pane[i] && pane[i]->patchbay)
816 pane[i]->patchbay->update_meters(module_levels);
821 void MWindowGUI::set_editing_mode(int flush)
823 for(int i = 0; i < TOTAL_PANES; i++)
827 pane[i]->canvas->update_cursor(flush);
832 void MWindowGUI::set_meter_format(int mode, int min, int max)
834 for(int i = 0; i < TOTAL_PANES; i++)
836 if(pane[i] && pane[i]->patchbay)
838 pane[i]->patchbay->set_meter_format(mode, min, max);
843 void MWindowGUI::update(int scrollbars,
852 if(debug) PRINT_TRACE
856 mwindow->edl->tracks->update_y_pixels(mwindow->theme);
858 if(do_canvas && do_canvas != IGNORE_THREAD)
860 resource_thread->stop_draw(1);
863 for(int i = 0; i < TOTAL_PANES; i++)
865 if(pane[i]) pane[i]->update(scrollbars,
871 if(do_canvas && do_canvas != IGNORE_THREAD)
873 resource_thread->start_draw();
876 // if(scrollbars) this->get_scrollbars(0);
877 // if(timebar) this->timebar->update(0);
878 if(zoombar) this->zoombar->update();
879 // if(patchbay) this->patchbay->update();
880 if(clock) this->mainclock->update(
881 mwindow->edl->local_session->get_selectionstart(1));
882 if(debug) PRINT_TRACE
888 // this->canvas->draw(do_canvas);
889 // this->cursor->show();
890 // this->canvas->flash(0);
891 // Activate causes the menubar to deactivate. Don't want this for
893 // if(canvas != IGNORE_THREAD) this->canvas->activate();
895 if(debug) PRINT_TRACE
899 if(buttonbar) mbuttons->update();
900 if(debug) PRINT_TRACE
902 // Can't age if the cache called this to draw missing picons
903 // or the GUI is updating the status of the draw toggle.
904 if(do_canvas != FORCE_REDRAW && do_canvas != IGNORE_THREAD)
907 mwindow->age_caches();
908 lock_window("MWindowGUI::update");
912 if(debug) PRINT_TRACE
915 int MWindowGUI::visible(int64_t x1, int64_t x2, int64_t view_x1, int64_t view_x2)
917 return (x1 >= view_x1 && x1 < view_x2) ||
918 (x2 > view_x1 && x2 <= view_x2) ||
919 (x1 <= view_x1 && x2 >= view_x2);
923 int MWindowGUI::show_message(char *message, int color)
925 // printf("MWindowGUI::show_message %d: %s 0x%08x 0x%08x\n",
926 // __LINE__, message, color, mwindow->theme->message_normal);
927 if(color < 0) color = mwindow->theme->message_normal;
928 statusbar->status_text->set_color(color);
929 statusbar->status_text->update(message);
934 // Drag motion called from other window
935 int MWindowGUI::drag_motion()
937 if(get_hidden()) return 0;
939 Track *over_track = 0;
941 PluginSet *over_pluginset = 0;
942 Plugin *over_plugin = 0;
947 drag_popup->cursor_motion_event();
951 // there's no point in drawing highlights has until drag operation has been set
952 if (!mwindow->session->current_operation)
955 for(int i = 0; i < TOTAL_PANES; i++)
957 if(pane[i]) pane[i]->canvas->drag_motion(
964 if(mwindow->session->track_highlighted != over_track)
966 mwindow->session->track_highlighted = over_track;
970 if(mwindow->session->edit_highlighted != over_edit)
972 mwindow->session->edit_highlighted = over_edit;
976 if(mwindow->session->pluginset_highlighted != over_pluginset)
978 mwindow->session->pluginset_highlighted = over_pluginset;
982 if(mwindow->session->plugin_highlighted != over_plugin)
984 mwindow->session->plugin_highlighted = over_plugin;
988 if( mwindow->session->current_operation == DRAG_ASSET ||
989 mwindow->session->current_operation == DRAG_EDIT ||
990 mwindow->session->current_operation == DRAG_AEFFECT_COPY ||
991 mwindow->session->current_operation == DRAG_VEFFECT_COPY )
997 // printf("drag_motion %d %d over_track=%p over_edit=%p\n",
1004 lock_window("MWindowGUI::drag_motion");
1011 int MWindowGUI::drag_stop()
1013 if(get_hidden()) return 0;
1014 int result = 0, redraw = 0;
1016 for(int i = 0; i < TOTAL_PANES; i++)
1018 if(pane[i]) result |= pane[i]->canvas->drag_stop(
1021 mwindow->edl->optimize();
1023 // since we don't have subwindows we have to terminate any drag operation
1026 if (mwindow->session->track_highlighted
1027 || mwindow->session->edit_highlighted
1028 || mwindow->session->plugin_highlighted
1029 || mwindow->session->pluginset_highlighted)
1031 mwindow->session->track_highlighted = 0;
1032 mwindow->session->edit_highlighted = 0;
1033 mwindow->session->plugin_highlighted = 0;
1034 mwindow->session->pluginset_highlighted = 0;
1035 mwindow->session->current_operation = NO_OPERATION;
1039 //printf("TrackCanvas::drag_stop %d %d\n", redraw, mwindow->session->current_operation);
1042 mwindow->edl->tracks->update_y_pixels(mwindow->theme);
1043 update_scrollbars(0);
1058 void MWindowGUI::default_positions()
1060 //printf("MWindowGUI::default_positions 1\n");
1061 VWindow *vwindow = mwindow->vwindows.size() > DEFAULT_VWINDOW ?
1062 mwindow->vwindows.get(0) : 0;
1063 if( vwindow ) vwindow->gui->lock_window("MWindowGUI::default_positions");
1064 mwindow->cwindow->gui->lock_window("MWindowGUI::default_positions");
1065 mwindow->awindow->gui->lock_window("MWindowGUI::default_positions");
1067 // printf("MWindowGUI::default_positions 1 %d %d %d %d\n", mwindow->session->vwindow_x,
1068 // mwindow->session->vwindow_y,
1069 // mwindow->session->vwindow_w,
1070 // mwindow->session->vwindow_h);
1071 reposition_window(mwindow->session->mwindow_x,
1072 mwindow->session->mwindow_y,
1073 mwindow->session->mwindow_w,
1074 mwindow->session->mwindow_h);
1075 if( vwindow ) vwindow->gui->reposition_window(mwindow->session->vwindow_x,
1076 mwindow->session->vwindow_y,
1077 mwindow->session->vwindow_w,
1078 mwindow->session->vwindow_h);
1079 mwindow->cwindow->gui->reposition_window(mwindow->session->cwindow_x,
1080 mwindow->session->cwindow_y,
1081 mwindow->session->cwindow_w,
1082 mwindow->session->cwindow_h);
1083 mwindow->awindow->gui->reposition_window(mwindow->session->awindow_x,
1084 mwindow->session->awindow_y,
1085 mwindow->session->awindow_w,
1086 mwindow->session->awindow_h);
1087 //printf("MWindowGUI::default_positions 1\n");
1089 resize_event(mwindow->session->mwindow_w,
1090 mwindow->session->mwindow_h);
1091 //printf("MWindowGUI::default_positions 1\n");
1092 if( vwindow ) vwindow->gui->resize_event(mwindow->session->vwindow_w,
1093 mwindow->session->vwindow_h);
1094 //printf("MWindowGUI::default_positions 1\n");
1095 mwindow->cwindow->gui->resize_event(mwindow->session->cwindow_w,
1096 mwindow->session->cwindow_h);
1097 //printf("MWindowGUI::default_positions 1\n");
1098 mwindow->awindow->gui->resize_event(mwindow->session->awindow_w,
1099 mwindow->session->awindow_h);
1101 //printf("MWindowGUI::default_positions 1\n");
1104 if( vwindow ) vwindow->gui->flush();
1105 mwindow->cwindow->gui->flush();
1106 mwindow->awindow->gui->flush();
1108 if( vwindow ) vwindow->gui->unlock_window();
1109 mwindow->cwindow->gui->unlock_window();
1110 mwindow->awindow->gui->unlock_window();
1111 //printf("MWindowGUI::default_positions 2\n");
1130 int MWindowGUI::repeat_event(int64_t duration)
1132 // if(duration == 100)
1133 // mwindow->sync_parameters(CHANGE_ALL);
1135 for(int i = 0; i < TOTAL_PANES; i++)
1137 if(pane[i]) result = pane[i]->cursor->repeat_event(duration);
1143 int MWindowGUI::translation_event()
1145 //printf("MWindowGUI::translation_event 1 %d %d\n", get_x(), get_y());
1146 mwindow->session->mwindow_x = get_x();
1147 mwindow->session->mwindow_y = get_y();
1152 int MWindowGUI::save_defaults(BC_Hash *defaults)
1154 defaults->update("MWINDOWWIDTH", get_w());
1155 defaults->update("MWINDOWHEIGHT", get_h());
1156 mainmenu->save_defaults(defaults);
1157 BC_WindowBase::save_defaults(defaults);
1161 int MWindowGUI::keypress_event()
1163 //printf("MWindowGUI::keypress_event 1 %d\n", get_keypress());
1165 result = mbuttons->keypress_event();
1169 switch(get_keypress())
1172 mwindow->toggle_editing_mode();
1175 case '1': case '2': case '3': case '4':
1176 case '5': case '6': case '7': case '8':
1177 if( !alt_down() || shift_down() ) break;
1178 if( !mwindow->select_asset(get_keypress()-'1',1) )
1187 mbuttons->transport->handle_transport(STOP, 1, 0, 0);
1188 lock_window("MWindowGUI::keypress_event 1");
1189 mwindow->prev_edit_handle(shift_down());
1192 mwindow->move_left();
1202 mbuttons->transport->handle_transport(STOP, 1, 0, 0);
1203 lock_window("MWindowGUI::keypress_event 2");
1204 mwindow->next_edit_handle(shift_down());
1207 mwindow->move_right();
1213 if(ctrl_down() && !alt_down())
1215 mwindow->expand_y();
1219 if(!ctrl_down() && alt_down())
1221 mwindow->expand_autos(0,1,1);
1225 if(ctrl_down() && alt_down())
1227 mwindow->expand_autos(1,1,1);
1232 mwindow->expand_sample();
1238 if(ctrl_down() && !alt_down())
1240 mwindow->zoom_in_y();
1244 if(!ctrl_down() && alt_down())
1246 mwindow->shrink_autos(0,1,1);
1250 if(ctrl_down() && alt_down())
1252 mwindow->shrink_autos(1,1,1);
1257 mwindow->zoom_in_sample();
1270 mwindow->expand_t();
1278 mwindow->move_down();
1283 mwindow->zoom_in_t();
1290 // //int cursor_x = 0;
1291 // int cursor_y = 0;
1292 // for(int i = 0; i < TOTAL_PANES; i++)
1296 // //cursor_x = pane[i]->canvas->get_relative_cursor_x();
1297 // cursor_y = pane[i]->canvas->get_relative_cursor_y();
1302 // if(get_keypress() == TAB)
1304 // // Switch the record button
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 // if (track->record)
1314 // track->record = 0;
1316 // track->record = 1;
1324 // Track *this_track = 0;
1325 // for(Track *track = mwindow->edl->tracks->first; track; track = track->next)
1327 // int64_t track_x, track_y, track_w, track_h;
1328 // canvas->track_dimensions(track, track_x, track_y, track_w, track_h);
1330 // if(cursor_y >= track_y &&
1331 // cursor_y < track_y + track_h)
1333 // // This is our track
1334 // this_track = track;
1339 // int total_selected = mwindow->edl->tracks->total_of(Tracks::RECORD);
1341 // // nothing previously selected
1342 // if(total_selected == 0)
1344 // mwindow->edl->tracks->select_all(Tracks::RECORD,
1348 // if(total_selected == 1)
1350 // // this patch was previously the only one on
1351 // if(this_track && this_track->record)
1353 // mwindow->edl->tracks->select_all(Tracks::RECORD,
1356 // // another patch was previously the only one on
1359 // mwindow->edl->tracks->select_all(Tracks::RECORD,
1362 // this_track->record = 1;
1367 // if(total_selected > 1)
1369 // mwindow->edl->tracks->select_all(Tracks::RECORD,
1372 // this_track->record = 1;
1385 // mwindow->cwindow->update(0, 1, 1);
1386 // lock_window("TrackCanvas::keypress_event 3");
1392 // since things under cursor have changed...
1394 cursor_motion_event();
1401 int MWindowGUI::keyboard_listener(BC_WindowBase *wp)
1403 return key_listener(wp->get_keypress());
1406 int MWindowGUI::key_listener(int key)
1411 if( !record->running() )
1414 record->record_gui->interrupt_thread->start(0);
1421 channel_info->toggle_scan();
1425 if( !remote_control->deactivate() )
1426 remote_control->activate();
1436 void MWindowGUI::use_android_remote(int on)
1439 delete android_control;
1440 android_control = 0;
1443 if( android_control ) return;
1444 android_control = new AndroidControl(this);
1447 int MWindowGUI::close_event()
1453 void MWindowGUI::stop_drawing()
1455 resource_thread->stop_draw(1);
1458 int MWindowGUI::menu_w()
1460 return mainmenu->get_w();
1463 int MWindowGUI::menu_h()
1465 return mainmenu->get_h();
1468 void MWindowGUI::start_x_pane_drag()
1472 x_pane_drag = new BC_Popup(this,
1473 get_abs_cursor_x(0) - mwindow->theme->pane_w,
1474 BC_DisplayInfo::get_top_border() +
1476 mwindow->theme->mcanvas_y,
1477 mwindow->theme->pane_w,
1478 mwindow->theme->mcanvas_h,
1479 mwindow->theme->drag_pane_color);
1480 x_pane_drag->draw_3segmentv(0,
1482 x_pane_drag->get_h(),
1483 mwindow->theme->get_image_set("xpane")[BUTTON_DOWNHI]);
1484 x_pane_drag->flash(1);
1489 void MWindowGUI::start_y_pane_drag()
1493 //printf("MWindowGUI::start_y_pane_drag %d %d %d\n", __LINE__, get_x(), get_y());
1494 y_pane_drag = new BC_Popup(this,
1495 BC_DisplayInfo::get_left_border() +
1497 mwindow->theme->mcanvas_x,
1498 get_abs_cursor_y(0) - mwindow->theme->pane_h,
1499 mwindow->theme->mcanvas_w,
1500 mwindow->theme->pane_h,
1501 mwindow->theme->drag_pane_color);
1502 y_pane_drag->draw_3segmenth(0,
1504 y_pane_drag->get_w(),
1505 mwindow->theme->get_image_set("ypane")[BUTTON_DOWNHI]);
1506 y_pane_drag->flash(1);
1511 void MWindowGUI::handle_pane_drag()
1517 x_pane_drag->reposition_window(
1518 get_abs_cursor_x(0) - mwindow->theme->pane_w,
1519 x_pane_drag->get_y());
1524 y_pane_drag->reposition_window(
1525 y_pane_drag->get_x(),
1526 get_abs_cursor_y(0) - mwindow->theme->pane_h);
1532 void MWindowGUI::create_x_pane(int cursor_x)
1534 if(total_panes() == 1)
1536 // create a horizontal pane
1537 // do this 1st so the resize_event knows there are 2 panes
1538 mwindow->edl->local_session->view_start[TOP_RIGHT_PANE] =
1539 mwindow->edl->local_session->view_start[TOP_LEFT_PANE] +
1541 mwindow->theme->patchbay_w;
1542 pane[TOP_RIGHT_PANE] = new TimelinePane(mwindow,
1544 mwindow->theme->mcanvas_x +
1546 mwindow->theme->mcanvas_y,
1547 mwindow->theme->mcanvas_x +
1548 mwindow->theme->mcanvas_w -
1550 mwindow->theme->mcanvas_h);
1551 pane[TOP_LEFT_PANE]->resize_event(
1552 mwindow->theme->mcanvas_x,
1553 mwindow->theme->mcanvas_y,
1554 cursor_x - mwindow->theme->pane_w,
1555 mwindow->theme->mcanvas_h);
1556 pane[TOP_RIGHT_PANE]->create_objects();
1559 if(vertical_panes())
1561 // create 2 horizontal panes
1562 mwindow->edl->local_session->track_start[TOP_RIGHT_PANE] =
1563 mwindow->edl->local_session->track_start[TOP_LEFT_PANE];
1564 mwindow->edl->local_session->track_start[BOTTOM_RIGHT_PANE] =
1565 mwindow->edl->local_session->track_start[BOTTOM_LEFT_PANE];
1566 mwindow->edl->local_session->view_start[TOP_RIGHT_PANE] =
1567 mwindow->edl->local_session->view_start[BOTTOM_RIGHT_PANE] =
1568 mwindow->edl->local_session->view_start[TOP_LEFT_PANE] +
1570 mwindow->theme->patchbay_w;
1571 pane[TOP_RIGHT_PANE] = new TimelinePane(mwindow,
1573 mwindow->theme->mcanvas_x +
1575 pane[TOP_LEFT_PANE]->y,
1576 mwindow->theme->mcanvas_x +
1577 mwindow->theme->mcanvas_w -
1579 pane[TOP_LEFT_PANE]->h);
1580 pane[BOTTOM_RIGHT_PANE] = new TimelinePane(mwindow,
1582 mwindow->theme->mcanvas_x +
1584 pane[BOTTOM_LEFT_PANE]->y,
1585 mwindow->theme->mcanvas_x +
1586 mwindow->theme->mcanvas_w -
1588 pane[BOTTOM_LEFT_PANE]->h);
1589 pane[TOP_LEFT_PANE]->resize_event(
1590 pane[TOP_LEFT_PANE]->x,
1591 pane[TOP_LEFT_PANE]->y,
1592 cursor_x - mwindow->theme->pane_w,
1593 pane[TOP_LEFT_PANE]->h);
1594 pane[BOTTOM_LEFT_PANE]->resize_event(
1595 pane[BOTTOM_LEFT_PANE]->x,
1596 pane[BOTTOM_LEFT_PANE]->y,
1597 cursor_x - mwindow->theme->pane_w,
1598 pane[BOTTOM_LEFT_PANE]->h);
1599 pane[TOP_RIGHT_PANE]->create_objects();
1600 pane[BOTTOM_RIGHT_PANE]->create_objects();
1603 if(horizontal_panes())
1605 // resize a horizontal pane
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 pane[TOP_LEFT_PANE]->resize_event(
1612 mwindow->theme->mcanvas_x,
1613 mwindow->theme->mcanvas_y,
1614 cursor_x - mwindow->theme->pane_w,
1615 mwindow->theme->mcanvas_h);
1616 pane[TOP_RIGHT_PANE]->resize_event(
1617 mwindow->theme->mcanvas_x +
1619 pane[TOP_RIGHT_PANE]->y,
1620 mwindow->theme->mcanvas_x +
1621 mwindow->theme->mcanvas_w -
1623 mwindow->theme->mcanvas_h);
1627 // resize 2 horizontal panes
1628 mwindow->edl->local_session->view_start[TOP_RIGHT_PANE] +=
1630 pane[TOP_RIGHT_PANE]->x;
1631 if(mwindow->edl->local_session->view_start[TOP_RIGHT_PANE] < 0)
1632 mwindow->edl->local_session->view_start[TOP_RIGHT_PANE] = 0;
1633 mwindow->edl->local_session->view_start[BOTTOM_RIGHT_PANE] =
1634 mwindow->edl->local_session->view_start[TOP_RIGHT_PANE];
1636 pane[TOP_LEFT_PANE]->resize_event(
1637 mwindow->theme->mcanvas_x,
1638 pane[TOP_LEFT_PANE]->y,
1639 cursor_x - mwindow->theme->pane_w,
1640 pane[TOP_LEFT_PANE]->h);
1641 pane[TOP_RIGHT_PANE]->resize_event(
1642 mwindow->theme->mcanvas_x +
1644 pane[TOP_RIGHT_PANE]->y,
1645 mwindow->theme->mcanvas_x +
1646 mwindow->theme->mcanvas_w -
1648 pane[TOP_RIGHT_PANE]->h);
1649 pane[BOTTOM_LEFT_PANE]->resize_event(
1650 mwindow->theme->mcanvas_x,
1651 pane[BOTTOM_LEFT_PANE]->y,
1652 cursor_x - mwindow->theme->pane_w,
1653 pane[BOTTOM_LEFT_PANE]->h);
1654 pane[BOTTOM_RIGHT_PANE]->resize_event(
1655 mwindow->theme->mcanvas_x +
1657 pane[BOTTOM_RIGHT_PANE]->y,
1658 mwindow->theme->mcanvas_x +
1659 mwindow->theme->mcanvas_w -
1661 pane[BOTTOM_RIGHT_PANE]->h);
1667 void MWindowGUI::delete_x_pane(int cursor_x)
1669 // give left panes coordinates of right pane
1670 if(cursor_x < mwindow->theme->patchbay_w + PANE_DRAG_MARGIN &&
1671 pane[TOP_RIGHT_PANE])
1673 mwindow->edl->local_session->view_start[TOP_LEFT_PANE] =
1674 mwindow->edl->local_session->view_start[TOP_RIGHT_PANE] -
1675 pane[TOP_RIGHT_PANE]->x + mwindow->theme->patchbay_w;
1676 if(mwindow->edl->local_session->view_start[TOP_LEFT_PANE] < 0)
1677 mwindow->edl->local_session->view_start[TOP_LEFT_PANE] = 0;
1678 mwindow->edl->local_session->view_start[BOTTOM_LEFT_PANE] =
1679 mwindow->edl->local_session->view_start[TOP_LEFT_PANE];
1682 switch(total_panes())
1685 if(pane[TOP_LEFT_PANE] && pane[TOP_RIGHT_PANE])
1687 // delete right pane
1688 delete pane[TOP_RIGHT_PANE];
1689 pane[TOP_RIGHT_PANE] = 0;
1690 pane[TOP_LEFT_PANE]->resize_event(
1691 mwindow->theme->mcanvas_x,
1692 mwindow->theme->mcanvas_y,
1693 mwindow->theme->mcanvas_w,
1694 mwindow->theme->mcanvas_h);
1700 // delete right panes
1701 delete pane[TOP_RIGHT_PANE];
1702 pane[TOP_RIGHT_PANE] = 0;
1703 delete pane[BOTTOM_RIGHT_PANE];
1704 pane[BOTTOM_RIGHT_PANE] = 0;
1705 pane[TOP_LEFT_PANE]->resize_event(
1706 mwindow->theme->mcanvas_x,
1707 pane[TOP_LEFT_PANE]->y,
1708 mwindow->theme->mcanvas_w,
1709 pane[TOP_LEFT_PANE]->h);
1710 pane[BOTTOM_LEFT_PANE]->resize_event(
1711 mwindow->theme->mcanvas_x,
1712 pane[BOTTOM_LEFT_PANE]->y,
1713 mwindow->theme->mcanvas_w,
1714 pane[BOTTOM_LEFT_PANE]->h);
1719 void MWindowGUI::create_y_pane(int cursor_y)
1721 if(total_panes() == 1)
1723 mwindow->edl->local_session->view_start[BOTTOM_LEFT_PANE] =
1724 mwindow->edl->local_session->view_start[TOP_LEFT_PANE];
1725 mwindow->edl->local_session->track_start[BOTTOM_LEFT_PANE] =
1726 mwindow->edl->local_session->track_start[TOP_LEFT_PANE] +
1728 mwindow->theme->mtimebar_h;
1729 // do this 1st so the resize_event knows there are 2 panes
1730 pane[BOTTOM_LEFT_PANE] = new TimelinePane(mwindow,
1732 mwindow->theme->mcanvas_x,
1733 mwindow->theme->mcanvas_y +
1735 mwindow->theme->mcanvas_w,
1736 mwindow->theme->mcanvas_h -
1738 pane[TOP_LEFT_PANE]->resize_event(
1739 mwindow->theme->mcanvas_x,
1740 mwindow->theme->mcanvas_y,
1741 mwindow->theme->mcanvas_w,
1742 pane[BOTTOM_LEFT_PANE]->y -
1743 mwindow->theme->mcanvas_y -
1744 mwindow->theme->pane_h);
1745 pane[BOTTOM_LEFT_PANE]->create_objects();
1748 if(horizontal_panes())
1751 mwindow->edl->local_session->view_start[BOTTOM_LEFT_PANE] =
1752 mwindow->edl->local_session->view_start[TOP_LEFT_PANE];
1753 mwindow->edl->local_session->view_start[BOTTOM_RIGHT_PANE] =
1754 mwindow->edl->local_session->view_start[TOP_RIGHT_PANE];
1755 mwindow->edl->local_session->track_start[BOTTOM_LEFT_PANE] =
1756 mwindow->edl->local_session->track_start[BOTTOM_RIGHT_PANE] =
1757 mwindow->edl->local_session->track_start[TOP_LEFT_PANE] +
1759 mwindow->theme->mtimebar_h;
1761 pane[BOTTOM_LEFT_PANE] = new TimelinePane(mwindow,
1763 pane[TOP_LEFT_PANE]->x,
1764 mwindow->theme->mcanvas_y +
1766 pane[TOP_LEFT_PANE]->w,
1767 mwindow->theme->mcanvas_h -
1769 pane[BOTTOM_RIGHT_PANE] = new TimelinePane(mwindow,
1771 pane[TOP_RIGHT_PANE]->x,
1772 mwindow->theme->mcanvas_y +
1774 pane[TOP_RIGHT_PANE]->w,
1775 mwindow->theme->mcanvas_h -
1778 pane[TOP_LEFT_PANE]->resize_event(
1779 pane[TOP_LEFT_PANE]->x,
1780 pane[TOP_LEFT_PANE]->y,
1781 pane[TOP_LEFT_PANE]->w,
1782 pane[BOTTOM_LEFT_PANE]->y -
1783 mwindow->theme->mcanvas_y -
1784 mwindow->theme->pane_h);
1785 pane[TOP_RIGHT_PANE]->resize_event(
1786 pane[TOP_RIGHT_PANE]->x,
1787 pane[TOP_RIGHT_PANE]->y,
1788 pane[TOP_RIGHT_PANE]->w,
1789 pane[BOTTOM_RIGHT_PANE]->y -
1790 mwindow->theme->mcanvas_y -
1791 mwindow->theme->pane_h);
1793 pane[BOTTOM_LEFT_PANE]->create_objects();
1794 pane[BOTTOM_RIGHT_PANE]->create_objects();
1797 if(vertical_panes())
1800 mwindow->edl->local_session->track_start[BOTTOM_LEFT_PANE] +=
1802 (pane[BOTTOM_LEFT_PANE]->y - mwindow->theme->mcanvas_y);
1803 if(mwindow->edl->local_session->track_start[BOTTOM_LEFT_PANE] < 0)
1804 mwindow->edl->local_session->track_start[BOTTOM_LEFT_PANE] = 0;
1805 pane[TOP_LEFT_PANE]->resize_event(
1806 mwindow->theme->mcanvas_x,
1807 mwindow->theme->mcanvas_y,
1808 mwindow->theme->mcanvas_w,
1809 cursor_y - mwindow->theme->pane_h);
1810 pane[BOTTOM_LEFT_PANE]->resize_event(
1811 pane[BOTTOM_LEFT_PANE]->x,
1813 mwindow->theme->mcanvas_y,
1814 mwindow->theme->mcanvas_w,
1815 mwindow->theme->mcanvas_h -
1821 mwindow->edl->local_session->track_start[BOTTOM_LEFT_PANE] +=
1823 (pane[BOTTOM_LEFT_PANE]->y - mwindow->theme->mcanvas_y);
1824 if(mwindow->edl->local_session->track_start[BOTTOM_LEFT_PANE] < 0)
1825 mwindow->edl->local_session->track_start[BOTTOM_LEFT_PANE] = 0;
1826 mwindow->edl->local_session->track_start[BOTTOM_RIGHT_PANE] =
1827 mwindow->edl->local_session->track_start[BOTTOM_LEFT_PANE];
1828 pane[TOP_LEFT_PANE]->resize_event(
1829 pane[TOP_LEFT_PANE]->x,
1830 pane[TOP_LEFT_PANE]->y,
1831 pane[TOP_LEFT_PANE]->w,
1832 cursor_y - mwindow->theme->pane_h);
1833 pane[BOTTOM_LEFT_PANE]->resize_event(
1834 pane[BOTTOM_LEFT_PANE]->x,
1836 mwindow->theme->mcanvas_y,
1837 pane[BOTTOM_LEFT_PANE]->w,
1838 mwindow->theme->mcanvas_h -
1840 pane[TOP_RIGHT_PANE]->resize_event(
1841 pane[TOP_RIGHT_PANE]->x,
1842 pane[TOP_RIGHT_PANE]->y,
1843 pane[TOP_RIGHT_PANE]->w,
1844 cursor_y - mwindow->theme->pane_h);
1845 pane[BOTTOM_RIGHT_PANE]->resize_event(
1846 pane[BOTTOM_RIGHT_PANE]->x,
1848 mwindow->theme->mcanvas_y,
1849 pane[BOTTOM_RIGHT_PANE]->w,
1850 mwindow->theme->mcanvas_h -
1855 void MWindowGUI::delete_y_pane(int cursor_y)
1857 if(cursor_y < mwindow->theme->mtimebar_h +
1859 pane[BOTTOM_LEFT_PANE])
1861 // give top pane coordinates of bottom pane
1862 mwindow->edl->local_session->track_start[TOP_LEFT_PANE] =
1863 mwindow->edl->local_session->track_start[BOTTOM_LEFT_PANE] -
1864 pane[BOTTOM_LEFT_PANE]->y;
1865 if(mwindow->edl->local_session->track_start[TOP_LEFT_PANE] < 0)
1866 mwindow->edl->local_session->track_start[TOP_LEFT_PANE] = 0;
1867 mwindow->edl->local_session->track_start[TOP_RIGHT_PANE] =
1868 mwindow->edl->local_session->track_start[TOP_LEFT_PANE];
1872 switch(total_panes())
1875 delete pane[BOTTOM_LEFT_PANE];
1876 pane[BOTTOM_LEFT_PANE] = 0;
1877 pane[TOP_LEFT_PANE]->resize_event(
1878 mwindow->theme->mcanvas_x,
1879 mwindow->theme->mcanvas_y,
1880 mwindow->theme->mcanvas_w,
1881 mwindow->theme->mcanvas_h);
1885 // delete bottom 2 panes
1887 delete pane[BOTTOM_LEFT_PANE];
1888 pane[BOTTOM_LEFT_PANE] = 0;
1889 delete pane[BOTTOM_RIGHT_PANE];
1890 pane[BOTTOM_RIGHT_PANE] = 0;
1891 pane[TOP_LEFT_PANE]->resize_event(
1892 pane[TOP_LEFT_PANE]->x,
1893 mwindow->theme->mcanvas_y,
1894 pane[TOP_LEFT_PANE]->w,
1895 mwindow->theme->mcanvas_h);
1896 pane[TOP_RIGHT_PANE]->resize_event(
1897 pane[TOP_RIGHT_PANE]->x,
1898 mwindow->theme->mcanvas_y,
1899 pane[TOP_RIGHT_PANE]->w,
1900 mwindow->theme->mcanvas_h);
1905 void MWindowGUI::stop_pane_drag()
1908 resource_thread->stop_draw(1);
1912 // cursor position relative to canvas
1913 int cursor_x = x_pane_drag->get_x() -
1915 BC_DisplayInfo::get_left_border() -
1916 mwindow->theme->mcanvas_x +
1917 mwindow->theme->pane_w;
1922 if(cursor_x >= mwindow->theme->patchbay_w + PANE_DRAG_MARGIN &&
1923 cursor_x < mwindow->theme->mcanvas_w -
1924 BC_ScrollBar::get_span(SCROLL_VERT) -
1927 create_x_pane(cursor_x);
1928 mwindow->edl->local_session->x_pane = cursor_x;
1933 delete_x_pane(cursor_x);
1934 mwindow->edl->local_session->x_pane = -1;
1942 // cursor position relative to canvas
1943 int cursor_y = y_pane_drag->get_y() -
1945 BC_DisplayInfo::get_top_border() -
1946 mwindow->theme->mcanvas_y +
1947 mwindow->theme->pane_h;
1953 if(cursor_y >= mwindow->theme->mtimebar_h +
1955 cursor_y < mwindow->theme->mcanvas_h -
1956 BC_ScrollBar::get_span(SCROLL_HORIZ) -
1959 create_y_pane(cursor_y);
1960 mwindow->edl->local_session->y_pane = cursor_y;
1964 delete_y_pane(cursor_y);
1965 mwindow->edl->local_session->y_pane = -1;
1969 update_pane_dividers();
1971 // required to get new widgets to appear
1973 resource_thread->start_draw();
1976 // create panes from EDL
1977 void MWindowGUI::load_panes()
1979 int need_x_panes = 0;
1980 int need_y_panes = 0;
1981 // use names from create functions
1982 int cursor_x = mwindow->edl->local_session->x_pane;
1983 int cursor_y = mwindow->edl->local_session->y_pane;
1985 resource_thread->stop_draw(1);
1987 mwindow->theme->patchbay_w + PANE_DRAG_MARGIN &&
1989 mwindow->theme->mcanvas_w -
1990 BC_ScrollBar::get_span(SCROLL_VERT) -
1997 mwindow->theme->mtimebar_h + PANE_DRAG_MARGIN &&
1999 mwindow->theme->mcanvas_h -
2000 BC_ScrollBar::get_span(SCROLL_HORIZ) -
2006 //printf("MWindowGUI::load_panes %d %d %d\n", __LINE__, need_x_panes, need_y_panes);
2014 if(total_panes() == 1)
2017 //printf("MWindowGUI::load_panes %d\n", __LINE__);
2018 pane[TOP_RIGHT_PANE] = new TimelinePane(mwindow,
2020 mwindow->theme->mcanvas_x +
2022 mwindow->theme->mcanvas_y,
2023 mwindow->theme->mcanvas_x +
2024 mwindow->theme->mcanvas_w -
2026 cursor_y - mwindow->theme->pane_h);
2027 pane[BOTTOM_LEFT_PANE] = new TimelinePane(mwindow,
2029 mwindow->theme->mcanvas_x,
2030 mwindow->theme->mcanvas_y +
2032 cursor_x - mwindow->theme->pane_w,
2033 mwindow->theme->mcanvas_h -
2035 pane[BOTTOM_RIGHT_PANE] = new TimelinePane(mwindow,
2037 pane[TOP_RIGHT_PANE]->x,
2038 mwindow->theme->mcanvas_y +
2040 pane[TOP_RIGHT_PANE]->w,
2041 mwindow->theme->mcanvas_h -
2043 pane[TOP_LEFT_PANE]->resize_event(
2044 pane[TOP_LEFT_PANE]->x,
2045 pane[TOP_LEFT_PANE]->y,
2046 cursor_x - mwindow->theme->pane_w,
2047 cursor_y - mwindow->theme->pane_h);
2048 pane[TOP_RIGHT_PANE]->create_objects();
2049 pane[BOTTOM_LEFT_PANE]->create_objects();
2050 pane[BOTTOM_RIGHT_PANE]->create_objects();
2053 if(horizontal_panes())
2055 // create vertical panes
2056 //printf("MWindowGUI::load_panes %d\n", __LINE__);
2057 pane[BOTTOM_LEFT_PANE] = new TimelinePane(mwindow,
2059 mwindow->theme->mcanvas_x,
2060 mwindow->theme->mcanvas_y +
2062 cursor_x - mwindow->theme->pane_w,
2063 mwindow->theme->mcanvas_h -
2065 pane[BOTTOM_RIGHT_PANE] = new TimelinePane(mwindow,
2067 pane[TOP_RIGHT_PANE]->x,
2068 mwindow->theme->mcanvas_y +
2070 pane[TOP_RIGHT_PANE]->w,
2071 mwindow->theme->mcanvas_h -
2073 pane[TOP_LEFT_PANE]->resize_event(
2074 pane[TOP_LEFT_PANE]->x,
2075 pane[TOP_LEFT_PANE]->y,
2076 cursor_x - mwindow->theme->pane_w,
2077 cursor_y - mwindow->theme->pane_h);
2078 pane[TOP_RIGHT_PANE]->resize_event(
2079 mwindow->theme->mcanvas_x +
2081 mwindow->theme->mcanvas_y,
2082 mwindow->theme->mcanvas_x +
2083 mwindow->theme->mcanvas_w -
2085 cursor_y - mwindow->theme->pane_h);
2086 pane[BOTTOM_LEFT_PANE]->create_objects();
2087 pane[BOTTOM_RIGHT_PANE]->create_objects();
2090 if(vertical_panes())
2092 // create horizontal panes
2093 //printf("MWindowGUI::load_panes %d\n", __LINE__);
2094 pane[TOP_RIGHT_PANE] = new TimelinePane(mwindow,
2096 mwindow->theme->mcanvas_x +
2098 mwindow->theme->mcanvas_y,
2099 mwindow->theme->mcanvas_x +
2100 mwindow->theme->mcanvas_w -
2102 cursor_y - mwindow->theme->pane_h);
2103 pane[BOTTOM_RIGHT_PANE] = new TimelinePane(mwindow,
2105 pane[TOP_RIGHT_PANE]->x,
2106 mwindow->theme->mcanvas_y +
2108 pane[TOP_RIGHT_PANE]->w,
2109 mwindow->theme->mcanvas_h -
2111 pane[TOP_LEFT_PANE]->resize_event(
2112 pane[TOP_LEFT_PANE]->x,
2113 pane[TOP_LEFT_PANE]->y,
2114 cursor_x - mwindow->theme->pane_w,
2115 cursor_y - mwindow->theme->pane_h);
2116 pane[BOTTOM_LEFT_PANE]->resize_event(
2117 pane[TOP_LEFT_PANE]->x,
2118 mwindow->theme->mcanvas_y +
2120 mwindow->theme->mcanvas_x +
2121 mwindow->theme->mcanvas_w -
2123 mwindow->theme->mcanvas_h -
2125 pane[TOP_RIGHT_PANE]->create_objects();
2126 pane[BOTTOM_RIGHT_PANE]->create_objects();
2133 //printf("MWindowGUI::load_panes %d\n", __LINE__);
2134 pane[TOP_LEFT_PANE]->resize_event(
2135 pane[TOP_LEFT_PANE]->x,
2136 pane[TOP_LEFT_PANE]->y,
2137 cursor_x - mwindow->theme->pane_w,
2138 cursor_y - mwindow->theme->pane_h);
2139 pane[TOP_RIGHT_PANE]->resize_event(
2140 mwindow->theme->mcanvas_x +
2142 mwindow->theme->mcanvas_y,
2143 mwindow->theme->mcanvas_x +
2144 mwindow->theme->mcanvas_w -
2146 cursor_y - mwindow->theme->pane_h);
2147 pane[BOTTOM_LEFT_PANE]->resize_event(
2148 pane[TOP_LEFT_PANE]->x,
2149 mwindow->theme->mcanvas_y +
2151 mwindow->theme->mcanvas_x +
2152 mwindow->theme->mcanvas_w -
2154 mwindow->theme->mcanvas_h -
2156 pane[BOTTOM_RIGHT_PANE]->resize_event(
2157 pane[TOP_RIGHT_PANE]->x,
2158 mwindow->theme->mcanvas_y +
2160 pane[TOP_RIGHT_PANE]->w,
2161 mwindow->theme->mcanvas_h -
2170 if(pane[BOTTOM_LEFT_PANE]) delete pane[BOTTOM_LEFT_PANE];
2171 if(pane[BOTTOM_RIGHT_PANE]) delete pane[BOTTOM_RIGHT_PANE];
2172 pane[BOTTOM_LEFT_PANE] = 0;
2173 pane[BOTTOM_RIGHT_PANE] = 0;
2175 if(!pane[TOP_RIGHT_PANE])
2177 pane[TOP_RIGHT_PANE] = new TimelinePane(mwindow,
2179 mwindow->theme->mcanvas_x +
2181 mwindow->theme->mcanvas_y,
2182 mwindow->theme->mcanvas_x +
2183 mwindow->theme->mcanvas_w -
2185 mwindow->theme->mcanvas_h);
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]->create_objects();
2195 pane[TOP_LEFT_PANE]->resize_event(
2196 mwindow->theme->mcanvas_x,
2197 mwindow->theme->mcanvas_y,
2198 cursor_x - mwindow->theme->pane_w,
2199 mwindow->theme->mcanvas_h);
2200 pane[TOP_RIGHT_PANE]->resize_event(
2201 mwindow->theme->mcanvas_x +
2203 pane[TOP_RIGHT_PANE]->y,
2204 mwindow->theme->mcanvas_x +
2205 mwindow->theme->mcanvas_w -
2207 mwindow->theme->mcanvas_h);
2215 if(pane[TOP_RIGHT_PANE]) delete pane[TOP_RIGHT_PANE];
2216 if(pane[BOTTOM_RIGHT_PANE]) delete pane[BOTTOM_RIGHT_PANE];
2217 pane[TOP_RIGHT_PANE] = 0;
2218 pane[BOTTOM_RIGHT_PANE] = 0;
2220 if(!pane[BOTTOM_LEFT_PANE])
2222 //printf("MWindowGUI::load_panes %d\n", __LINE__);
2223 pane[BOTTOM_LEFT_PANE] = new TimelinePane(mwindow,
2225 mwindow->theme->mcanvas_x,
2226 mwindow->theme->mcanvas_y +
2228 mwindow->theme->mcanvas_w,
2229 mwindow->theme->mcanvas_h -
2231 pane[TOP_LEFT_PANE]->resize_event(
2232 mwindow->theme->mcanvas_x,
2233 mwindow->theme->mcanvas_y,
2234 mwindow->theme->mcanvas_w,
2235 pane[BOTTOM_LEFT_PANE]->y -
2236 mwindow->theme->mcanvas_y -
2237 mwindow->theme->pane_h);
2238 pane[BOTTOM_LEFT_PANE]->create_objects();
2242 pane[TOP_LEFT_PANE]->resize_event(
2243 mwindow->theme->mcanvas_x,
2244 mwindow->theme->mcanvas_y,
2245 mwindow->theme->mcanvas_w,
2246 cursor_y - mwindow->theme->pane_h);
2247 pane[BOTTOM_LEFT_PANE]->resize_event(
2248 pane[BOTTOM_LEFT_PANE]->x,
2250 mwindow->theme->mcanvas_y,
2251 mwindow->theme->mcanvas_w,
2252 mwindow->theme->mcanvas_h -
2259 if(pane[TOP_RIGHT_PANE]) delete pane[TOP_RIGHT_PANE];
2260 if(pane[BOTTOM_RIGHT_PANE]) delete pane[BOTTOM_RIGHT_PANE];
2261 if(pane[BOTTOM_LEFT_PANE]) delete pane[BOTTOM_LEFT_PANE];
2262 pane[TOP_RIGHT_PANE] = 0;
2263 pane[BOTTOM_RIGHT_PANE] = 0;
2264 pane[BOTTOM_LEFT_PANE] = 0;
2265 pane[TOP_LEFT_PANE]->resize_event(
2266 mwindow->theme->mcanvas_x,
2267 mwindow->theme->mcanvas_y,
2268 mwindow->theme->mcanvas_w,
2269 mwindow->theme->mcanvas_h);
2272 update_pane_dividers();
2275 resource_thread->start_draw();
2278 void MWindowGUI::update_pane_dividers()
2281 if(horizontal_panes() || total_panes() == 4)
2283 int x = pane[TOP_RIGHT_PANE]->x - mwindow->theme->pane_w;
2284 int y = mwindow->theme->mcanvas_y;
2285 int h = mwindow->theme->mcanvas_h;
2289 add_subwindow(x_divider = new PaneDivider(
2290 mwindow, x, y, h, 1));
2291 x_divider->create_objects();
2295 x_divider->reposition_window(x, y, h);
2308 if(vertical_panes() || total_panes() == 4)
2310 int x = mwindow->theme->mcanvas_x;
2311 int y = pane[BOTTOM_LEFT_PANE]->y -
2312 mwindow->theme->pane_h;
2313 int w = mwindow->theme->mcanvas_w;
2316 add_subwindow(y_divider = new PaneDivider(
2317 mwindow, x, y, w, 0));
2318 y_divider->create_objects();
2322 y_divider->reposition_window(x, y, w);
2336 void MWindowGUI::draw_samplemovement()
2343 update_scrollbars(1);
2346 void MWindowGUI::draw_trackmovement()
2348 update_scrollbars(0);
2355 PaneButton::PaneButton(MWindow *mwindow, int x, int y)
2356 : BC_Button(x, y, mwindow->theme->get_image_set("pane"))
2358 this->mwindow = mwindow;
2361 int PaneButton::cursor_motion_event()
2363 if(get_top_level()->get_button_down() &&
2365 get_status() == BUTTON_DOWNHI &&
2368 // printf("PaneButton::cursor_motion_event %d\n", __LINE__);
2370 if(get_cursor_x() < 0 && !mwindow->gui->dragging_pane)
2372 mwindow->gui->start_x_pane_drag();
2375 if(get_cursor_y() < 0 && !mwindow->gui->dragging_pane)
2377 mwindow->gui->start_y_pane_drag();
2381 mwindow->gui->handle_pane_drag();
2383 int result = BC_Button::cursor_motion_event();
2387 int PaneButton::button_release_event()
2389 mwindow->gui->stop_pane_drag();
2391 int result = BC_Button::button_release_event();
2396 FFMpegToggle::FFMpegToggle(MWindow *mwindow, MButtons *mbuttons, int x, int y)
2397 : BC_Toggle(x, y, mwindow->theme->ffmpeg_toggle, mwindow->preferences->ffmpeg_early_probe)
2399 this->mwindow = mwindow;
2400 this->mbuttons = mbuttons;
2401 set_tooltip( mwindow->preferences->ffmpeg_early_probe ?
2402 _("Try FFMpeg first") : _("Try FFMpeg last"));
2405 FFMpegToggle::~FFMpegToggle()
2409 int FFMpegToggle::handle_event()
2411 mwindow->preferences->ffmpeg_early_probe = get_value();
2412 set_tooltip( mwindow->preferences->ffmpeg_early_probe ?
2413 _("Try FFMpeg first") : _("Try FFMpeg last"));
2414 mwindow->show_warning(&mwindow->preferences->warn_indexes,
2415 _("Changing the base codecs may require rebuilding indexes."));