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());
1164 int result = mbuttons->keypress_event();
1165 if( result ) return result;
1167 switch(get_keypress()) {
1169 mwindow->toggle_editing_mode();
1173 case '1': case '2': case '3': case '4':
1174 case '5': case '6': case '7': case '8':
1175 if( !alt_down() || shift_down() ) break;
1176 if( !mwindow->select_asset(get_keypress()-'1',1) )
1181 if( !ctrl_down() ) {
1184 mbuttons->transport->handle_transport(STOP, 1, 0, 0);
1185 lock_window("MWindowGUI::keypress_event 1");
1186 mwindow->prev_edit_handle(shift_down());
1189 mwindow->move_left();
1195 if( !ctrl_down() ) {
1198 mbuttons->transport->handle_transport(STOP, 1, 0, 0);
1199 lock_window("MWindowGUI::keypress_event 2");
1200 mwindow->next_edit_handle(shift_down());
1203 mwindow->move_right();
1209 if( ctrl_down() && !alt_down() )
1210 mwindow->expand_y();
1211 else if( !ctrl_down() && alt_down() )
1212 mwindow->expand_autos(0,1,1);
1213 else if( ctrl_down() && alt_down() )
1214 mwindow->expand_autos(1,1,1);
1216 mwindow->expand_sample();
1221 if( ctrl_down() && !alt_down() )
1222 mwindow->zoom_in_y();
1223 else if( !ctrl_down() && alt_down() )
1224 mwindow->shrink_autos(0,1,1);
1225 else if( ctrl_down() && alt_down() )
1226 mwindow->shrink_autos(1,1,1);
1228 mwindow->zoom_in_sample();
1236 mwindow->expand_t();
1242 mwindow->move_down();
1244 mwindow->zoom_in_t();
1250 Track *this_track = 0;
1251 for( int i=0; i<TOTAL_PANES; ++i ) {
1252 if( (this_track = pane[i]->over_track()) != 0 ) break;
1253 if( (this_track = pane[i]->over_patchbay()) != 0 ) break;
1256 if( get_keypress() == TAB ) { // Switch the record button
1258 this_track->record = !this_track->record ? 1 : 0;
1261 int total_selected = mwindow->edl->tracks->total_of(Tracks::RECORD);
1262 // all selected if nothing previously selected or
1263 // if this patch was previously the only one selected and armed
1264 int selected = !total_selected || (total_selected == 1 &&
1265 this_track && this_track->record ) ? 1 : 0;
1266 mwindow->edl->tracks->select_all(Tracks::RECORD, selected);
1267 if( !selected && this_track ) this_track->record = 1;
1270 update(0, 1, 0, 0, 1, 0, 1);
1272 mwindow->cwindow->update(0, 1, 1);
1273 lock_window("TrackCanvas::keypress_event 3");
1279 // since things under cursor have changed...
1281 cursor_motion_event();
1287 int MWindowGUI::keyboard_listener(BC_WindowBase *wp)
1289 return key_listener(wp->get_keypress());
1292 int MWindowGUI::key_listener(int key)
1297 if( !record->running() )
1300 record->record_gui->interrupt_thread->start(0);
1307 channel_info->toggle_scan();
1311 if( !remote_control->deactivate() )
1312 remote_control->activate();
1322 void MWindowGUI::use_android_remote(int on)
1325 delete android_control;
1326 android_control = 0;
1329 if( android_control ) return;
1330 android_control = new AndroidControl(this);
1333 int MWindowGUI::close_event()
1339 void MWindowGUI::stop_drawing()
1341 resource_thread->stop_draw(1);
1344 int MWindowGUI::menu_w()
1346 return mainmenu->get_w();
1349 int MWindowGUI::menu_h()
1351 return mainmenu->get_h();
1354 void MWindowGUI::start_x_pane_drag()
1358 x_pane_drag = new BC_Popup(this,
1359 get_abs_cursor_x(0) - mwindow->theme->pane_w,
1360 BC_DisplayInfo::get_top_border() +
1362 mwindow->theme->mcanvas_y,
1363 mwindow->theme->pane_w,
1364 mwindow->theme->mcanvas_h,
1365 mwindow->theme->drag_pane_color);
1366 x_pane_drag->draw_3segmentv(0,
1368 x_pane_drag->get_h(),
1369 mwindow->theme->get_image_set("xpane")[BUTTON_DOWNHI]);
1370 x_pane_drag->flash(1);
1375 void MWindowGUI::start_y_pane_drag()
1379 //printf("MWindowGUI::start_y_pane_drag %d %d %d\n", __LINE__, get_x(), get_y());
1380 y_pane_drag = new BC_Popup(this,
1381 BC_DisplayInfo::get_left_border() +
1383 mwindow->theme->mcanvas_x,
1384 get_abs_cursor_y(0) - mwindow->theme->pane_h,
1385 mwindow->theme->mcanvas_w,
1386 mwindow->theme->pane_h,
1387 mwindow->theme->drag_pane_color);
1388 y_pane_drag->draw_3segmenth(0,
1390 y_pane_drag->get_w(),
1391 mwindow->theme->get_image_set("ypane")[BUTTON_DOWNHI]);
1392 y_pane_drag->flash(1);
1397 void MWindowGUI::handle_pane_drag()
1403 x_pane_drag->reposition_window(
1404 get_abs_cursor_x(0) - mwindow->theme->pane_w,
1405 x_pane_drag->get_y());
1410 y_pane_drag->reposition_window(
1411 y_pane_drag->get_x(),
1412 get_abs_cursor_y(0) - mwindow->theme->pane_h);
1418 void MWindowGUI::create_x_pane(int cursor_x)
1420 if(total_panes() == 1)
1422 // create a horizontal pane
1423 // do this 1st so the resize_event knows there are 2 panes
1424 mwindow->edl->local_session->view_start[TOP_RIGHT_PANE] =
1425 mwindow->edl->local_session->view_start[TOP_LEFT_PANE] +
1427 mwindow->theme->patchbay_w;
1428 pane[TOP_RIGHT_PANE] = new TimelinePane(mwindow,
1430 mwindow->theme->mcanvas_x +
1432 mwindow->theme->mcanvas_y,
1433 mwindow->theme->mcanvas_x +
1434 mwindow->theme->mcanvas_w -
1436 mwindow->theme->mcanvas_h);
1437 pane[TOP_LEFT_PANE]->resize_event(
1438 mwindow->theme->mcanvas_x,
1439 mwindow->theme->mcanvas_y,
1440 cursor_x - mwindow->theme->pane_w,
1441 mwindow->theme->mcanvas_h);
1442 pane[TOP_RIGHT_PANE]->create_objects();
1445 if(vertical_panes())
1447 // create 2 horizontal panes
1448 mwindow->edl->local_session->track_start[TOP_RIGHT_PANE] =
1449 mwindow->edl->local_session->track_start[TOP_LEFT_PANE];
1450 mwindow->edl->local_session->track_start[BOTTOM_RIGHT_PANE] =
1451 mwindow->edl->local_session->track_start[BOTTOM_LEFT_PANE];
1452 mwindow->edl->local_session->view_start[TOP_RIGHT_PANE] =
1453 mwindow->edl->local_session->view_start[BOTTOM_RIGHT_PANE] =
1454 mwindow->edl->local_session->view_start[TOP_LEFT_PANE] +
1456 mwindow->theme->patchbay_w;
1457 pane[TOP_RIGHT_PANE] = new TimelinePane(mwindow,
1459 mwindow->theme->mcanvas_x +
1461 pane[TOP_LEFT_PANE]->y,
1462 mwindow->theme->mcanvas_x +
1463 mwindow->theme->mcanvas_w -
1465 pane[TOP_LEFT_PANE]->h);
1466 pane[BOTTOM_RIGHT_PANE] = new TimelinePane(mwindow,
1468 mwindow->theme->mcanvas_x +
1470 pane[BOTTOM_LEFT_PANE]->y,
1471 mwindow->theme->mcanvas_x +
1472 mwindow->theme->mcanvas_w -
1474 pane[BOTTOM_LEFT_PANE]->h);
1475 pane[TOP_LEFT_PANE]->resize_event(
1476 pane[TOP_LEFT_PANE]->x,
1477 pane[TOP_LEFT_PANE]->y,
1478 cursor_x - mwindow->theme->pane_w,
1479 pane[TOP_LEFT_PANE]->h);
1480 pane[BOTTOM_LEFT_PANE]->resize_event(
1481 pane[BOTTOM_LEFT_PANE]->x,
1482 pane[BOTTOM_LEFT_PANE]->y,
1483 cursor_x - mwindow->theme->pane_w,
1484 pane[BOTTOM_LEFT_PANE]->h);
1485 pane[TOP_RIGHT_PANE]->create_objects();
1486 pane[BOTTOM_RIGHT_PANE]->create_objects();
1489 if(horizontal_panes())
1491 // resize a horizontal pane
1492 mwindow->edl->local_session->view_start[TOP_RIGHT_PANE] +=
1494 pane[TOP_RIGHT_PANE]->x;
1495 if(mwindow->edl->local_session->view_start[TOP_RIGHT_PANE] < 0)
1496 mwindow->edl->local_session->view_start[TOP_RIGHT_PANE] = 0;
1497 pane[TOP_LEFT_PANE]->resize_event(
1498 mwindow->theme->mcanvas_x,
1499 mwindow->theme->mcanvas_y,
1500 cursor_x - mwindow->theme->pane_w,
1501 mwindow->theme->mcanvas_h);
1502 pane[TOP_RIGHT_PANE]->resize_event(
1503 mwindow->theme->mcanvas_x +
1505 pane[TOP_RIGHT_PANE]->y,
1506 mwindow->theme->mcanvas_x +
1507 mwindow->theme->mcanvas_w -
1509 mwindow->theme->mcanvas_h);
1513 // resize 2 horizontal panes
1514 mwindow->edl->local_session->view_start[TOP_RIGHT_PANE] +=
1516 pane[TOP_RIGHT_PANE]->x;
1517 if(mwindow->edl->local_session->view_start[TOP_RIGHT_PANE] < 0)
1518 mwindow->edl->local_session->view_start[TOP_RIGHT_PANE] = 0;
1519 mwindow->edl->local_session->view_start[BOTTOM_RIGHT_PANE] =
1520 mwindow->edl->local_session->view_start[TOP_RIGHT_PANE];
1522 pane[TOP_LEFT_PANE]->resize_event(
1523 mwindow->theme->mcanvas_x,
1524 pane[TOP_LEFT_PANE]->y,
1525 cursor_x - mwindow->theme->pane_w,
1526 pane[TOP_LEFT_PANE]->h);
1527 pane[TOP_RIGHT_PANE]->resize_event(
1528 mwindow->theme->mcanvas_x +
1530 pane[TOP_RIGHT_PANE]->y,
1531 mwindow->theme->mcanvas_x +
1532 mwindow->theme->mcanvas_w -
1534 pane[TOP_RIGHT_PANE]->h);
1535 pane[BOTTOM_LEFT_PANE]->resize_event(
1536 mwindow->theme->mcanvas_x,
1537 pane[BOTTOM_LEFT_PANE]->y,
1538 cursor_x - mwindow->theme->pane_w,
1539 pane[BOTTOM_LEFT_PANE]->h);
1540 pane[BOTTOM_RIGHT_PANE]->resize_event(
1541 mwindow->theme->mcanvas_x +
1543 pane[BOTTOM_RIGHT_PANE]->y,
1544 mwindow->theme->mcanvas_x +
1545 mwindow->theme->mcanvas_w -
1547 pane[BOTTOM_RIGHT_PANE]->h);
1553 void MWindowGUI::delete_x_pane(int cursor_x)
1555 // give left panes coordinates of right pane
1556 if(cursor_x < mwindow->theme->patchbay_w + PANE_DRAG_MARGIN &&
1557 pane[TOP_RIGHT_PANE])
1559 mwindow->edl->local_session->view_start[TOP_LEFT_PANE] =
1560 mwindow->edl->local_session->view_start[TOP_RIGHT_PANE] -
1561 pane[TOP_RIGHT_PANE]->x + mwindow->theme->patchbay_w;
1562 if(mwindow->edl->local_session->view_start[TOP_LEFT_PANE] < 0)
1563 mwindow->edl->local_session->view_start[TOP_LEFT_PANE] = 0;
1564 mwindow->edl->local_session->view_start[BOTTOM_LEFT_PANE] =
1565 mwindow->edl->local_session->view_start[TOP_LEFT_PANE];
1568 switch(total_panes())
1571 if(pane[TOP_LEFT_PANE] && pane[TOP_RIGHT_PANE])
1573 // delete right pane
1574 delete pane[TOP_RIGHT_PANE];
1575 pane[TOP_RIGHT_PANE] = 0;
1576 pane[TOP_LEFT_PANE]->resize_event(
1577 mwindow->theme->mcanvas_x,
1578 mwindow->theme->mcanvas_y,
1579 mwindow->theme->mcanvas_w,
1580 mwindow->theme->mcanvas_h);
1586 // delete right panes
1587 delete pane[TOP_RIGHT_PANE];
1588 pane[TOP_RIGHT_PANE] = 0;
1589 delete pane[BOTTOM_RIGHT_PANE];
1590 pane[BOTTOM_RIGHT_PANE] = 0;
1591 pane[TOP_LEFT_PANE]->resize_event(
1592 mwindow->theme->mcanvas_x,
1593 pane[TOP_LEFT_PANE]->y,
1594 mwindow->theme->mcanvas_w,
1595 pane[TOP_LEFT_PANE]->h);
1596 pane[BOTTOM_LEFT_PANE]->resize_event(
1597 mwindow->theme->mcanvas_x,
1598 pane[BOTTOM_LEFT_PANE]->y,
1599 mwindow->theme->mcanvas_w,
1600 pane[BOTTOM_LEFT_PANE]->h);
1605 void MWindowGUI::create_y_pane(int cursor_y)
1607 if(total_panes() == 1)
1609 mwindow->edl->local_session->view_start[BOTTOM_LEFT_PANE] =
1610 mwindow->edl->local_session->view_start[TOP_LEFT_PANE];
1611 mwindow->edl->local_session->track_start[BOTTOM_LEFT_PANE] =
1612 mwindow->edl->local_session->track_start[TOP_LEFT_PANE] +
1614 mwindow->theme->mtimebar_h;
1615 // do this 1st so the resize_event knows there are 2 panes
1616 pane[BOTTOM_LEFT_PANE] = new TimelinePane(mwindow,
1618 mwindow->theme->mcanvas_x,
1619 mwindow->theme->mcanvas_y +
1621 mwindow->theme->mcanvas_w,
1622 mwindow->theme->mcanvas_h -
1624 pane[TOP_LEFT_PANE]->resize_event(
1625 mwindow->theme->mcanvas_x,
1626 mwindow->theme->mcanvas_y,
1627 mwindow->theme->mcanvas_w,
1628 pane[BOTTOM_LEFT_PANE]->y -
1629 mwindow->theme->mcanvas_y -
1630 mwindow->theme->pane_h);
1631 pane[BOTTOM_LEFT_PANE]->create_objects();
1634 if(horizontal_panes())
1637 mwindow->edl->local_session->view_start[BOTTOM_LEFT_PANE] =
1638 mwindow->edl->local_session->view_start[TOP_LEFT_PANE];
1639 mwindow->edl->local_session->view_start[BOTTOM_RIGHT_PANE] =
1640 mwindow->edl->local_session->view_start[TOP_RIGHT_PANE];
1641 mwindow->edl->local_session->track_start[BOTTOM_LEFT_PANE] =
1642 mwindow->edl->local_session->track_start[BOTTOM_RIGHT_PANE] =
1643 mwindow->edl->local_session->track_start[TOP_LEFT_PANE] +
1645 mwindow->theme->mtimebar_h;
1647 pane[BOTTOM_LEFT_PANE] = new TimelinePane(mwindow,
1649 pane[TOP_LEFT_PANE]->x,
1650 mwindow->theme->mcanvas_y +
1652 pane[TOP_LEFT_PANE]->w,
1653 mwindow->theme->mcanvas_h -
1655 pane[BOTTOM_RIGHT_PANE] = new TimelinePane(mwindow,
1657 pane[TOP_RIGHT_PANE]->x,
1658 mwindow->theme->mcanvas_y +
1660 pane[TOP_RIGHT_PANE]->w,
1661 mwindow->theme->mcanvas_h -
1664 pane[TOP_LEFT_PANE]->resize_event(
1665 pane[TOP_LEFT_PANE]->x,
1666 pane[TOP_LEFT_PANE]->y,
1667 pane[TOP_LEFT_PANE]->w,
1668 pane[BOTTOM_LEFT_PANE]->y -
1669 mwindow->theme->mcanvas_y -
1670 mwindow->theme->pane_h);
1671 pane[TOP_RIGHT_PANE]->resize_event(
1672 pane[TOP_RIGHT_PANE]->x,
1673 pane[TOP_RIGHT_PANE]->y,
1674 pane[TOP_RIGHT_PANE]->w,
1675 pane[BOTTOM_RIGHT_PANE]->y -
1676 mwindow->theme->mcanvas_y -
1677 mwindow->theme->pane_h);
1679 pane[BOTTOM_LEFT_PANE]->create_objects();
1680 pane[BOTTOM_RIGHT_PANE]->create_objects();
1683 if(vertical_panes())
1686 mwindow->edl->local_session->track_start[BOTTOM_LEFT_PANE] +=
1688 (pane[BOTTOM_LEFT_PANE]->y - mwindow->theme->mcanvas_y);
1689 if(mwindow->edl->local_session->track_start[BOTTOM_LEFT_PANE] < 0)
1690 mwindow->edl->local_session->track_start[BOTTOM_LEFT_PANE] = 0;
1691 pane[TOP_LEFT_PANE]->resize_event(
1692 mwindow->theme->mcanvas_x,
1693 mwindow->theme->mcanvas_y,
1694 mwindow->theme->mcanvas_w,
1695 cursor_y - mwindow->theme->pane_h);
1696 pane[BOTTOM_LEFT_PANE]->resize_event(
1697 pane[BOTTOM_LEFT_PANE]->x,
1699 mwindow->theme->mcanvas_y,
1700 mwindow->theme->mcanvas_w,
1701 mwindow->theme->mcanvas_h -
1707 mwindow->edl->local_session->track_start[BOTTOM_LEFT_PANE] +=
1709 (pane[BOTTOM_LEFT_PANE]->y - mwindow->theme->mcanvas_y);
1710 if(mwindow->edl->local_session->track_start[BOTTOM_LEFT_PANE] < 0)
1711 mwindow->edl->local_session->track_start[BOTTOM_LEFT_PANE] = 0;
1712 mwindow->edl->local_session->track_start[BOTTOM_RIGHT_PANE] =
1713 mwindow->edl->local_session->track_start[BOTTOM_LEFT_PANE];
1714 pane[TOP_LEFT_PANE]->resize_event(
1715 pane[TOP_LEFT_PANE]->x,
1716 pane[TOP_LEFT_PANE]->y,
1717 pane[TOP_LEFT_PANE]->w,
1718 cursor_y - mwindow->theme->pane_h);
1719 pane[BOTTOM_LEFT_PANE]->resize_event(
1720 pane[BOTTOM_LEFT_PANE]->x,
1722 mwindow->theme->mcanvas_y,
1723 pane[BOTTOM_LEFT_PANE]->w,
1724 mwindow->theme->mcanvas_h -
1726 pane[TOP_RIGHT_PANE]->resize_event(
1727 pane[TOP_RIGHT_PANE]->x,
1728 pane[TOP_RIGHT_PANE]->y,
1729 pane[TOP_RIGHT_PANE]->w,
1730 cursor_y - mwindow->theme->pane_h);
1731 pane[BOTTOM_RIGHT_PANE]->resize_event(
1732 pane[BOTTOM_RIGHT_PANE]->x,
1734 mwindow->theme->mcanvas_y,
1735 pane[BOTTOM_RIGHT_PANE]->w,
1736 mwindow->theme->mcanvas_h -
1741 void MWindowGUI::delete_y_pane(int cursor_y)
1743 if(cursor_y < mwindow->theme->mtimebar_h +
1745 pane[BOTTOM_LEFT_PANE])
1747 // give top pane coordinates of bottom pane
1748 mwindow->edl->local_session->track_start[TOP_LEFT_PANE] =
1749 mwindow->edl->local_session->track_start[BOTTOM_LEFT_PANE] -
1750 pane[BOTTOM_LEFT_PANE]->y;
1751 if(mwindow->edl->local_session->track_start[TOP_LEFT_PANE] < 0)
1752 mwindow->edl->local_session->track_start[TOP_LEFT_PANE] = 0;
1753 mwindow->edl->local_session->track_start[TOP_RIGHT_PANE] =
1754 mwindow->edl->local_session->track_start[TOP_LEFT_PANE];
1758 switch(total_panes())
1761 delete pane[BOTTOM_LEFT_PANE];
1762 pane[BOTTOM_LEFT_PANE] = 0;
1763 pane[TOP_LEFT_PANE]->resize_event(
1764 mwindow->theme->mcanvas_x,
1765 mwindow->theme->mcanvas_y,
1766 mwindow->theme->mcanvas_w,
1767 mwindow->theme->mcanvas_h);
1771 // delete bottom 2 panes
1773 delete pane[BOTTOM_LEFT_PANE];
1774 pane[BOTTOM_LEFT_PANE] = 0;
1775 delete pane[BOTTOM_RIGHT_PANE];
1776 pane[BOTTOM_RIGHT_PANE] = 0;
1777 pane[TOP_LEFT_PANE]->resize_event(
1778 pane[TOP_LEFT_PANE]->x,
1779 mwindow->theme->mcanvas_y,
1780 pane[TOP_LEFT_PANE]->w,
1781 mwindow->theme->mcanvas_h);
1782 pane[TOP_RIGHT_PANE]->resize_event(
1783 pane[TOP_RIGHT_PANE]->x,
1784 mwindow->theme->mcanvas_y,
1785 pane[TOP_RIGHT_PANE]->w,
1786 mwindow->theme->mcanvas_h);
1791 void MWindowGUI::stop_pane_drag()
1794 resource_thread->stop_draw(1);
1798 // cursor position relative to canvas
1799 int cursor_x = x_pane_drag->get_x() -
1801 BC_DisplayInfo::get_left_border() -
1802 mwindow->theme->mcanvas_x +
1803 mwindow->theme->pane_w;
1808 if(cursor_x >= mwindow->theme->patchbay_w + PANE_DRAG_MARGIN &&
1809 cursor_x < mwindow->theme->mcanvas_w -
1810 BC_ScrollBar::get_span(SCROLL_VERT) -
1813 create_x_pane(cursor_x);
1814 mwindow->edl->local_session->x_pane = cursor_x;
1819 delete_x_pane(cursor_x);
1820 mwindow->edl->local_session->x_pane = -1;
1828 // cursor position relative to canvas
1829 int cursor_y = y_pane_drag->get_y() -
1831 BC_DisplayInfo::get_top_border() -
1832 mwindow->theme->mcanvas_y +
1833 mwindow->theme->pane_h;
1839 if(cursor_y >= mwindow->theme->mtimebar_h +
1841 cursor_y < mwindow->theme->mcanvas_h -
1842 BC_ScrollBar::get_span(SCROLL_HORIZ) -
1845 create_y_pane(cursor_y);
1846 mwindow->edl->local_session->y_pane = cursor_y;
1850 delete_y_pane(cursor_y);
1851 mwindow->edl->local_session->y_pane = -1;
1855 update_pane_dividers();
1857 // required to get new widgets to appear
1859 resource_thread->start_draw();
1862 // create panes from EDL
1863 void MWindowGUI::load_panes()
1865 int need_x_panes = 0;
1866 int need_y_panes = 0;
1867 // use names from create functions
1868 int cursor_x = mwindow->edl->local_session->x_pane;
1869 int cursor_y = mwindow->edl->local_session->y_pane;
1871 resource_thread->stop_draw(1);
1873 mwindow->theme->patchbay_w + PANE_DRAG_MARGIN &&
1875 mwindow->theme->mcanvas_w -
1876 BC_ScrollBar::get_span(SCROLL_VERT) -
1883 mwindow->theme->mtimebar_h + PANE_DRAG_MARGIN &&
1885 mwindow->theme->mcanvas_h -
1886 BC_ScrollBar::get_span(SCROLL_HORIZ) -
1892 //printf("MWindowGUI::load_panes %d %d %d\n", __LINE__, need_x_panes, need_y_panes);
1900 if(total_panes() == 1)
1903 //printf("MWindowGUI::load_panes %d\n", __LINE__);
1904 pane[TOP_RIGHT_PANE] = new TimelinePane(mwindow,
1906 mwindow->theme->mcanvas_x +
1908 mwindow->theme->mcanvas_y,
1909 mwindow->theme->mcanvas_x +
1910 mwindow->theme->mcanvas_w -
1912 cursor_y - mwindow->theme->pane_h);
1913 pane[BOTTOM_LEFT_PANE] = new TimelinePane(mwindow,
1915 mwindow->theme->mcanvas_x,
1916 mwindow->theme->mcanvas_y +
1918 cursor_x - mwindow->theme->pane_w,
1919 mwindow->theme->mcanvas_h -
1921 pane[BOTTOM_RIGHT_PANE] = new TimelinePane(mwindow,
1923 pane[TOP_RIGHT_PANE]->x,
1924 mwindow->theme->mcanvas_y +
1926 pane[TOP_RIGHT_PANE]->w,
1927 mwindow->theme->mcanvas_h -
1929 pane[TOP_LEFT_PANE]->resize_event(
1930 pane[TOP_LEFT_PANE]->x,
1931 pane[TOP_LEFT_PANE]->y,
1932 cursor_x - mwindow->theme->pane_w,
1933 cursor_y - mwindow->theme->pane_h);
1934 pane[TOP_RIGHT_PANE]->create_objects();
1935 pane[BOTTOM_LEFT_PANE]->create_objects();
1936 pane[BOTTOM_RIGHT_PANE]->create_objects();
1939 if(horizontal_panes())
1941 // create vertical panes
1942 //printf("MWindowGUI::load_panes %d\n", __LINE__);
1943 pane[BOTTOM_LEFT_PANE] = new TimelinePane(mwindow,
1945 mwindow->theme->mcanvas_x,
1946 mwindow->theme->mcanvas_y +
1948 cursor_x - mwindow->theme->pane_w,
1949 mwindow->theme->mcanvas_h -
1951 pane[BOTTOM_RIGHT_PANE] = new TimelinePane(mwindow,
1953 pane[TOP_RIGHT_PANE]->x,
1954 mwindow->theme->mcanvas_y +
1956 pane[TOP_RIGHT_PANE]->w,
1957 mwindow->theme->mcanvas_h -
1959 pane[TOP_LEFT_PANE]->resize_event(
1960 pane[TOP_LEFT_PANE]->x,
1961 pane[TOP_LEFT_PANE]->y,
1962 cursor_x - mwindow->theme->pane_w,
1963 cursor_y - mwindow->theme->pane_h);
1964 pane[TOP_RIGHT_PANE]->resize_event(
1965 mwindow->theme->mcanvas_x +
1967 mwindow->theme->mcanvas_y,
1968 mwindow->theme->mcanvas_x +
1969 mwindow->theme->mcanvas_w -
1971 cursor_y - mwindow->theme->pane_h);
1972 pane[BOTTOM_LEFT_PANE]->create_objects();
1973 pane[BOTTOM_RIGHT_PANE]->create_objects();
1976 if(vertical_panes())
1978 // create horizontal panes
1979 //printf("MWindowGUI::load_panes %d\n", __LINE__);
1980 pane[TOP_RIGHT_PANE] = new TimelinePane(mwindow,
1982 mwindow->theme->mcanvas_x +
1984 mwindow->theme->mcanvas_y,
1985 mwindow->theme->mcanvas_x +
1986 mwindow->theme->mcanvas_w -
1988 cursor_y - mwindow->theme->pane_h);
1989 pane[BOTTOM_RIGHT_PANE] = new TimelinePane(mwindow,
1991 pane[TOP_RIGHT_PANE]->x,
1992 mwindow->theme->mcanvas_y +
1994 pane[TOP_RIGHT_PANE]->w,
1995 mwindow->theme->mcanvas_h -
1997 pane[TOP_LEFT_PANE]->resize_event(
1998 pane[TOP_LEFT_PANE]->x,
1999 pane[TOP_LEFT_PANE]->y,
2000 cursor_x - mwindow->theme->pane_w,
2001 cursor_y - mwindow->theme->pane_h);
2002 pane[BOTTOM_LEFT_PANE]->resize_event(
2003 pane[TOP_LEFT_PANE]->x,
2004 mwindow->theme->mcanvas_y +
2006 mwindow->theme->mcanvas_x +
2007 mwindow->theme->mcanvas_w -
2009 mwindow->theme->mcanvas_h -
2011 pane[TOP_RIGHT_PANE]->create_objects();
2012 pane[BOTTOM_RIGHT_PANE]->create_objects();
2019 //printf("MWindowGUI::load_panes %d\n", __LINE__);
2020 pane[TOP_LEFT_PANE]->resize_event(
2021 pane[TOP_LEFT_PANE]->x,
2022 pane[TOP_LEFT_PANE]->y,
2023 cursor_x - mwindow->theme->pane_w,
2024 cursor_y - mwindow->theme->pane_h);
2025 pane[TOP_RIGHT_PANE]->resize_event(
2026 mwindow->theme->mcanvas_x +
2028 mwindow->theme->mcanvas_y,
2029 mwindow->theme->mcanvas_x +
2030 mwindow->theme->mcanvas_w -
2032 cursor_y - mwindow->theme->pane_h);
2033 pane[BOTTOM_LEFT_PANE]->resize_event(
2034 pane[TOP_LEFT_PANE]->x,
2035 mwindow->theme->mcanvas_y +
2037 mwindow->theme->mcanvas_x +
2038 mwindow->theme->mcanvas_w -
2040 mwindow->theme->mcanvas_h -
2042 pane[BOTTOM_RIGHT_PANE]->resize_event(
2043 pane[TOP_RIGHT_PANE]->x,
2044 mwindow->theme->mcanvas_y +
2046 pane[TOP_RIGHT_PANE]->w,
2047 mwindow->theme->mcanvas_h -
2056 if(pane[BOTTOM_LEFT_PANE]) delete pane[BOTTOM_LEFT_PANE];
2057 if(pane[BOTTOM_RIGHT_PANE]) delete pane[BOTTOM_RIGHT_PANE];
2058 pane[BOTTOM_LEFT_PANE] = 0;
2059 pane[BOTTOM_RIGHT_PANE] = 0;
2061 if(!pane[TOP_RIGHT_PANE])
2063 pane[TOP_RIGHT_PANE] = new TimelinePane(mwindow,
2065 mwindow->theme->mcanvas_x +
2067 mwindow->theme->mcanvas_y,
2068 mwindow->theme->mcanvas_x +
2069 mwindow->theme->mcanvas_w -
2071 mwindow->theme->mcanvas_h);
2072 pane[TOP_LEFT_PANE]->resize_event(
2073 mwindow->theme->mcanvas_x,
2074 mwindow->theme->mcanvas_y,
2075 cursor_x - mwindow->theme->pane_w,
2076 mwindow->theme->mcanvas_h);
2077 pane[TOP_RIGHT_PANE]->create_objects();
2081 pane[TOP_LEFT_PANE]->resize_event(
2082 mwindow->theme->mcanvas_x,
2083 mwindow->theme->mcanvas_y,
2084 cursor_x - mwindow->theme->pane_w,
2085 mwindow->theme->mcanvas_h);
2086 pane[TOP_RIGHT_PANE]->resize_event(
2087 mwindow->theme->mcanvas_x +
2089 pane[TOP_RIGHT_PANE]->y,
2090 mwindow->theme->mcanvas_x +
2091 mwindow->theme->mcanvas_w -
2093 mwindow->theme->mcanvas_h);
2101 if(pane[TOP_RIGHT_PANE]) delete pane[TOP_RIGHT_PANE];
2102 if(pane[BOTTOM_RIGHT_PANE]) delete pane[BOTTOM_RIGHT_PANE];
2103 pane[TOP_RIGHT_PANE] = 0;
2104 pane[BOTTOM_RIGHT_PANE] = 0;
2106 if(!pane[BOTTOM_LEFT_PANE])
2108 //printf("MWindowGUI::load_panes %d\n", __LINE__);
2109 pane[BOTTOM_LEFT_PANE] = new TimelinePane(mwindow,
2111 mwindow->theme->mcanvas_x,
2112 mwindow->theme->mcanvas_y +
2114 mwindow->theme->mcanvas_w,
2115 mwindow->theme->mcanvas_h -
2117 pane[TOP_LEFT_PANE]->resize_event(
2118 mwindow->theme->mcanvas_x,
2119 mwindow->theme->mcanvas_y,
2120 mwindow->theme->mcanvas_w,
2121 pane[BOTTOM_LEFT_PANE]->y -
2122 mwindow->theme->mcanvas_y -
2123 mwindow->theme->pane_h);
2124 pane[BOTTOM_LEFT_PANE]->create_objects();
2128 pane[TOP_LEFT_PANE]->resize_event(
2129 mwindow->theme->mcanvas_x,
2130 mwindow->theme->mcanvas_y,
2131 mwindow->theme->mcanvas_w,
2132 cursor_y - mwindow->theme->pane_h);
2133 pane[BOTTOM_LEFT_PANE]->resize_event(
2134 pane[BOTTOM_LEFT_PANE]->x,
2136 mwindow->theme->mcanvas_y,
2137 mwindow->theme->mcanvas_w,
2138 mwindow->theme->mcanvas_h -
2145 if(pane[TOP_RIGHT_PANE]) delete pane[TOP_RIGHT_PANE];
2146 if(pane[BOTTOM_RIGHT_PANE]) delete pane[BOTTOM_RIGHT_PANE];
2147 if(pane[BOTTOM_LEFT_PANE]) delete pane[BOTTOM_LEFT_PANE];
2148 pane[TOP_RIGHT_PANE] = 0;
2149 pane[BOTTOM_RIGHT_PANE] = 0;
2150 pane[BOTTOM_LEFT_PANE] = 0;
2151 pane[TOP_LEFT_PANE]->resize_event(
2152 mwindow->theme->mcanvas_x,
2153 mwindow->theme->mcanvas_y,
2154 mwindow->theme->mcanvas_w,
2155 mwindow->theme->mcanvas_h);
2158 update_pane_dividers();
2161 resource_thread->start_draw();
2164 void MWindowGUI::update_pane_dividers()
2167 if(horizontal_panes() || total_panes() == 4)
2169 int x = pane[TOP_RIGHT_PANE]->x - mwindow->theme->pane_w;
2170 int y = mwindow->theme->mcanvas_y;
2171 int h = mwindow->theme->mcanvas_h;
2175 add_subwindow(x_divider = new PaneDivider(
2176 mwindow, x, y, h, 1));
2177 x_divider->create_objects();
2181 x_divider->reposition_window(x, y, h);
2194 if(vertical_panes() || total_panes() == 4)
2196 int x = mwindow->theme->mcanvas_x;
2197 int y = pane[BOTTOM_LEFT_PANE]->y -
2198 mwindow->theme->pane_h;
2199 int w = mwindow->theme->mcanvas_w;
2202 add_subwindow(y_divider = new PaneDivider(
2203 mwindow, x, y, w, 0));
2204 y_divider->create_objects();
2208 y_divider->reposition_window(x, y, w);
2222 void MWindowGUI::draw_samplemovement()
2229 update_scrollbars(1);
2232 void MWindowGUI::draw_trackmovement()
2234 update_scrollbars(0);
2241 PaneButton::PaneButton(MWindow *mwindow, int x, int y)
2242 : BC_Button(x, y, mwindow->theme->get_image_set("pane"))
2244 this->mwindow = mwindow;
2247 int PaneButton::cursor_motion_event()
2249 if(get_top_level()->get_button_down() &&
2251 get_status() == BUTTON_DOWNHI &&
2254 // printf("PaneButton::cursor_motion_event %d\n", __LINE__);
2256 if(get_cursor_x() < 0 && !mwindow->gui->dragging_pane)
2258 mwindow->gui->start_x_pane_drag();
2261 if(get_cursor_y() < 0 && !mwindow->gui->dragging_pane)
2263 mwindow->gui->start_y_pane_drag();
2267 mwindow->gui->handle_pane_drag();
2269 int result = BC_Button::cursor_motion_event();
2273 int PaneButton::button_release_event()
2275 mwindow->gui->stop_pane_drag();
2277 int result = BC_Button::button_release_event();
2282 FFMpegToggle::FFMpegToggle(MWindow *mwindow, MButtons *mbuttons, int x, int y)
2283 : BC_Toggle(x, y, mwindow->theme->ffmpeg_toggle, mwindow->preferences->ffmpeg_early_probe)
2285 this->mwindow = mwindow;
2286 this->mbuttons = mbuttons;
2287 set_tooltip( mwindow->preferences->ffmpeg_early_probe ?
2288 _("Try FFMpeg first") : _("Try FFMpeg last"));
2291 FFMpegToggle::~FFMpegToggle()
2295 int FFMpegToggle::handle_event()
2297 mwindow->preferences->ffmpeg_early_probe = get_value();
2298 set_tooltip( mwindow->preferences->ffmpeg_early_probe ?
2299 _("Try FFMpeg first") : _("Try FFMpeg last"));
2300 mwindow->show_warning(&mwindow->preferences->warn_indexes,
2301 _("Changing the base codecs may require rebuilding indexes."));