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"
40 #include "keyframepopup.h"
43 #include "localsession.h"
44 #include "mainclock.h"
45 #include "maincursor.h"
47 #include "mainsession.h"
51 #include "mwindowgui.h"
53 #include "panedividers.h"
56 #include "pluginpopup.h"
57 #include "pluginset.h"
58 #include "preferences.h"
60 #include "recordgui.h"
61 #include "renderengine.h"
62 #include "resourcethread.h"
63 #include "samplescroll.h"
64 #include "shbtnprefs.h"
65 #include "statusbar.h"
68 #include "trackcanvas.h"
69 #include "trackpopup.h"
70 #include "trackscroll.h"
72 #include "transitionpopup.h"
73 #include "vwindowgui.h"
77 #define PANE_DRAG_MARGIN MAX(mwindow->theme->pane_w, mwindow->theme->pane_h)
80 // the main window uses its own private colormap for video
81 MWindowGUI::MWindowGUI(MWindow *mwindow)
82 : BC_Window(_(PROGRAM_NAME ": Program"),
83 mwindow->session->mwindow_x, mwindow->session->mwindow_y,
84 mwindow->session->mwindow_w, mwindow->session->mwindow_h,
85 xS(100), yS(100), 1, 1, 1)
87 this->mwindow = mwindow;
94 focused_pane = TOP_LEFT_PANE;
103 for(int i = 0; i < TOTAL_PANES; i++)
123 cwindow_remote_handler = 0;
124 record_remote_handler = 0;
129 MWindowGUI::~MWindowGUI()
131 delete android_control;
132 delete cwindow_remote_handler;
133 delete record_remote_handler;
134 delete remote_control;
135 delete keyvalue_popup;
136 // delete samplescroll;
137 // delete trackscroll;
138 for(int i = 0; i < TOTAL_PANES; i++)
139 if(pane[i]) delete pane[i];
141 delete render_engine;
142 delete resource_thread;
143 resource_pixmaps.remove_all_objects();
153 void MWindowGUI::create_objects()
155 lock_window("MWindowGUI::create_objects");
158 resource_thread = new ResourceThread(mwindow, this);
159 resource_thread->create_objects();
162 if(debug) printf("MWindowGUI::create_objects %d\n", __LINE__);
163 set_icon(mwindow->theme->get_image("mwindow_icon"));
164 remote_control = new RemoteControl(this);
165 cwindow_remote_handler = new CWindowRemoteHandler(remote_control);
166 record_remote_handler = new RecordRemoteHandler(remote_control);
167 mwindow->reset_android_remote();
169 if(debug) printf("MWindowGUI::create_objects %d\n", __LINE__);
171 int x = get_w() - MainShBtns::calculate_w(-1, 0, -1);
172 add_subwindow(mainmenu = new MainMenu(mwindow, this, x));
173 mainmenu->create_objects();
174 add_subwindow(mainshbtns = new MainShBtns(mwindow, x, -1));
175 mainshbtns->load(mwindow->preferences);
176 mwindow->theme->get_mwindow_sizes(this, get_w(), get_h());
177 mwindow->theme->draw_mwindow_bg(this);
178 if(debug) printf("MWindowGUI::create_objects %d\n", __LINE__);
180 add_subwindow(mbuttons = new MButtons(mwindow, this));
181 mbuttons->create_objects();
182 int x1 = mbuttons->get_x() + mbuttons->get_w(), y1 = mbuttons->get_y()+yS(2);
183 add_subwindow(proxy_toggle = new ProxyToggle(mwindow, mbuttons, x1, y1));
184 x1 += proxy_toggle->get_w() + xS(3);
185 add_subwindow(ffmpeg_toggle = new FFMpegToggle(mwindow, mbuttons, x1, y1));
187 pane[TOP_LEFT_PANE] = new TimelinePane(mwindow,
189 mwindow->theme->mcanvas_x,
190 mwindow->theme->mcanvas_y,
191 mwindow->theme->mcanvas_w,
192 mwindow->theme->mcanvas_h);
193 pane[TOP_LEFT_PANE]->create_objects();
195 if(debug) printf("MWindowGUI::create_objects %d\n", __LINE__);
196 add_subwindow(zoombar = new ZoomBar(mwindow, this));
197 zoombar->create_objects();
200 if(debug) printf("MWindowGUI::create_objects %d\n", __LINE__);
201 add_subwindow(statusbar = new StatusBar(mwindow, this));
202 statusbar->create_objects();
206 if(debug) printf("MWindowGUI::create_objects %d\n", __LINE__);
207 add_subwindow(mainclock = new MainClock(mwindow,
208 mwindow->theme->mclock_x, mwindow->theme->mclock_y,
209 mwindow->theme->mclock_w));
210 if(debug) printf("MWindowGUI::create_objects %d\n", __LINE__);
211 mainclock->update(0);
215 // if(debug) printf("MWindowGUI::create_objects %d\n", __LINE__);
216 // cursor = new MainCursor(mwindow, this);
217 // cursor->create_objects();
220 if(debug) printf("MWindowGUI::create_objects %d\n", __LINE__);
221 add_subwindow(track_menu = new TrackPopup(mwindow, this));
222 track_menu->create_objects();
223 if(debug) printf("MWindowGUI::create_objects %d\n", __LINE__);
224 add_subwindow(edit_menu = new EditPopup(mwindow, this));
225 edit_menu->create_objects();
228 if(debug) printf("MWindowGUI::create_objects %d\n", __LINE__);
229 add_subwindow(plugin_menu = new PluginPopup(mwindow, this));
230 plugin_menu->create_objects();
233 if(debug) printf("MWindowGUI::create_objects %d\n", __LINE__);
234 add_subwindow(keyframe_menu = new KeyframePopup(mwindow, this));
235 keyframe_menu->create_objects();
236 add_subwindow(keyframe_hide = new KeyframeHidePopup(mwindow, this));
237 keyframe_hide->create_objects();
240 if(debug) printf("MWindowGUI::create_objects %d\n", __LINE__);
241 add_subwindow(transition_menu = new TransitionPopup(mwindow, this));
242 transition_menu->create_objects();
245 channel_info = new ChannelInfo(mwindow);
247 #ifdef HAVE_COMMERCIAL
248 db_window = new DbWindow(mwindow);
250 swindow = new SWindow(mwindow);
252 if(debug) printf("MWindowGUI::create_objects %d\n", __LINE__);
254 add_subwindow(pane_button = new PaneButton(mwindow,
255 get_w() - mwindow->theme->get_image_set("pane")[0]->get_w(),
256 mwindow->theme->mzoom_y + 1 - mwindow->theme->get_image_set("pane")[0]->get_h()));
258 pane[TOP_LEFT_PANE]->canvas->activate();
260 if(debug) printf("MWindowGUI::create_objects %d\n", __LINE__);
264 void MWindowGUI::redraw_time_dependancies()
266 zoombar->redraw_time_dependancies();
267 for(int i = 0; i < TOTAL_PANES; i++)
268 if(pane[i] && pane[i]->timebar) pane[i]->timebar->update(0);
269 mainclock->update(mwindow->edl->local_session->get_selectionstart(1));
272 int MWindowGUI::focus_in_event()
274 for(int i = 0; i < TOTAL_PANES; i++)
275 if(pane[i]) pane[i]->cursor->focus_in_event();
279 int MWindowGUI::focus_out_event()
281 for(int i = 0; i < TOTAL_PANES; i++)
282 if(pane[i]) pane[i]->cursor->focus_out_event();
287 int MWindowGUI::resize_event(int w, int h)
289 //printf("MWindowGUI::resize_event %d\n", __LINE__);
290 mwindow->session->mwindow_w = w;
291 mwindow->session->mwindow_h = h;
292 int x = w - MainShBtns::calculate_w(-1, 0, -1);
293 mainmenu->resize_event(x, mainmenu->get_h());
294 mainshbtns->reposition_window(x, -1);
295 mwindow->theme->get_mwindow_sizes(this, w, h);
296 mwindow->theme->draw_mwindow_bg(this);
297 mbuttons->resize_event();
298 int x1 = mbuttons->get_x() + mbuttons->get_w(), y1 = mbuttons->get_y()+yS(2);
299 proxy_toggle->reposition_window(x1, y1);
300 x1 += proxy_toggle->get_w() + xS(3);
301 ffmpeg_toggle->reposition_window(x1, y1);
302 statusbar->resize_event();
303 zoombar->resize_event();
305 resource_thread->stop_draw(1);
307 if(total_panes() > 1)
309 if(horizontal_panes())
311 // printf("MWindowGUI::resize_event %d %d %d\n",
313 // pane[TOP_RIGHT_PANE]->x,
314 // mwindow->theme->mcanvas_w -
315 // BC_ScrollBar::get_span(SCROLL_VERT) -
316 // PANE_DRAG_MARGIN);
317 if(pane[TOP_RIGHT_PANE]->x >= mwindow->theme->mcanvas_w -
318 BC_ScrollBar::get_span(SCROLL_VERT) -
321 delete_x_pane(pane[TOP_RIGHT_PANE]->x);
322 mwindow->edl->local_session->x_pane = -1;
328 if(pane[BOTTOM_LEFT_PANE]->y >= mwindow->theme->mzoom_y -
329 BC_ScrollBar::get_span(SCROLL_HORIZ) -
332 delete_y_pane(pane[BOTTOM_LEFT_PANE]->y);
333 mwindow->edl->local_session->y_pane = -1;
338 if(pane[TOP_RIGHT_PANE]->x >= mwindow->theme->mcanvas_w -
339 BC_ScrollBar::get_span(SCROLL_VERT) -
342 delete_x_pane(pane[TOP_RIGHT_PANE]->x);
343 mwindow->edl->local_session->x_pane = -1;
346 if(pane[BOTTOM_LEFT_PANE]->y >= mwindow->theme->mzoom_y -
347 BC_ScrollBar::get_span(SCROLL_HORIZ) -
350 delete_y_pane(pane[BOTTOM_LEFT_PANE]->y);
351 mwindow->edl->local_session->y_pane = -1;
356 if(total_panes() == 1)
358 pane[TOP_LEFT_PANE]->resize_event(
359 mwindow->theme->mcanvas_x,
360 mwindow->theme->mcanvas_y,
361 mwindow->theme->mcanvas_w,
362 mwindow->theme->mcanvas_h);
365 if(horizontal_panes())
367 pane[TOP_LEFT_PANE]->resize_event(
368 pane[TOP_LEFT_PANE]->x,
369 pane[TOP_LEFT_PANE]->y,
370 pane[TOP_LEFT_PANE]->w,
371 mwindow->theme->mcanvas_h);
372 pane[TOP_RIGHT_PANE]->resize_event(
373 pane[TOP_RIGHT_PANE]->x,
374 pane[TOP_RIGHT_PANE]->y,
375 mwindow->theme->mcanvas_w - pane[TOP_RIGHT_PANE]->x,
376 mwindow->theme->mcanvas_h);
381 pane[TOP_LEFT_PANE]->resize_event(
382 pane[TOP_LEFT_PANE]->x,
383 pane[TOP_LEFT_PANE]->y,
384 mwindow->theme->mcanvas_w,
385 pane[TOP_LEFT_PANE]->h);
386 pane[BOTTOM_LEFT_PANE]->resize_event(
387 pane[BOTTOM_LEFT_PANE]->x,
388 pane[BOTTOM_LEFT_PANE]->y,
389 mwindow->theme->mcanvas_w,
390 mwindow->theme->mcanvas_y +
391 mwindow->theme->mcanvas_h -
392 pane[BOTTOM_LEFT_PANE]->y);
396 pane[TOP_LEFT_PANE]->resize_event(
397 pane[TOP_LEFT_PANE]->x,
398 pane[TOP_LEFT_PANE]->y,
399 pane[TOP_LEFT_PANE]->w,
400 pane[TOP_LEFT_PANE]->h);
401 pane[TOP_RIGHT_PANE]->resize_event(
402 pane[TOP_RIGHT_PANE]->x,
403 pane[TOP_RIGHT_PANE]->y,
404 mwindow->theme->mcanvas_w - pane[TOP_RIGHT_PANE]->x,
405 pane[TOP_RIGHT_PANE]->h);
406 pane[BOTTOM_LEFT_PANE]->resize_event(
407 pane[BOTTOM_LEFT_PANE]->x,
408 pane[BOTTOM_LEFT_PANE]->y,
409 pane[BOTTOM_LEFT_PANE]->w,
410 mwindow->theme->mcanvas_y +
411 mwindow->theme->mcanvas_h -
412 pane[BOTTOM_LEFT_PANE]->y);
413 pane[BOTTOM_RIGHT_PANE]->resize_event(
414 pane[BOTTOM_RIGHT_PANE]->x,
415 pane[BOTTOM_RIGHT_PANE]->y,
416 mwindow->theme->mcanvas_w -
417 pane[BOTTOM_RIGHT_PANE]->x,
418 mwindow->theme->mcanvas_y +
419 mwindow->theme->mcanvas_h -
420 pane[BOTTOM_RIGHT_PANE]->y);
423 update_pane_dividers();
424 pane_button->reposition_window(w - mwindow->theme->get_image_set("pane")[0]->get_w(),
425 mwindow->theme->mzoom_y + 1 - mwindow->theme->get_image_set("pane")[0]->get_h());
426 resource_thread->start_draw();
432 int MWindowGUI::total_panes()
435 for(int i = 0; i < TOTAL_PANES; i++)
440 int MWindowGUI::vertical_panes()
442 return total_panes() == 2 &&
443 pane[TOP_LEFT_PANE] &&
444 pane[BOTTOM_LEFT_PANE];
447 int MWindowGUI::horizontal_panes()
449 return total_panes() == 2 &&
450 pane[TOP_LEFT_PANE] &&
451 pane[TOP_RIGHT_PANE];
454 TimelinePane* MWindowGUI::get_focused_pane()
456 if(pane[focused_pane]) return pane[focused_pane];
457 for(int i = 0; i < TOTAL_PANES; i++)
459 if(pane[i]) return pane[i];
464 void MWindowGUI::activate_timeline()
466 if(pane[focused_pane])
468 pane[focused_pane]->activate();
472 for(int i = 0; i < TOTAL_PANES; i++)
483 void MWindowGUI::deactivate_timeline()
485 for(int i = 0; i < TOTAL_PANES; i++)
489 pane[i]->canvas->deactivate();
494 void MWindowGUI::update_title(char *path)
497 char filename[BCTEXTLEN], string[BCTEXTLEN];
498 fs.extract_name(filename, path);
499 sprintf(string, _(PROGRAM_NAME ": %s"), filename);
501 //printf("MWindowGUI::update_title %s\n", string);
505 void MWindowGUI::draw_overlays(int flash_it)
507 for(int i = 0; i < TOTAL_PANES; i++)
511 pane[i]->canvas->draw_overlays();
512 if(flash_it) pane[i]->canvas->flash();
517 void MWindowGUI::update_timebar(int flush_it)
519 for(int i = 0; i < TOTAL_PANES; i++)
521 if(pane[i] && pane[i]->timebar)
523 pane[i]->timebar->update(flush_it);
528 void MWindowGUI::update_timebar_highlights()
530 for(int i = 0; i < TOTAL_PANES; i++)
532 if(pane[i] && pane[i]->timebar)
534 pane[i]->timebar->update_highlights();
540 void MWindowGUI::update_patchbay()
542 for(int i = 0; i < TOTAL_PANES; i++)
544 if(pane[i] && pane[i]->patchbay)
546 pane[i]->patchbay->update();
551 void MWindowGUI::update_proxy_toggle()
553 int value = mwindow->edl->session->proxy_scale == 1 ? 1 : 0;
554 proxy_toggle->set_value(value);
555 if( mwindow->edl->session->proxy_scale == 1 &&
556 mwindow->edl->session->proxy_disabled_scale == 1 )
557 proxy_toggle->hide();
559 proxy_toggle->show();
562 void MWindowGUI::update_plugintoggles()
564 for(int i = 0; i < TOTAL_PANES; i++)
568 pane[i]->canvas->refresh_plugintoggles();
574 void MWindowGUI::draw_indexes(Indexable *indexable)
576 for(int i = 0; i < TOTAL_PANES; i++)
580 pane[i]->canvas->draw_indexes(indexable);
585 void MWindowGUI::draw_canvas(int redraw, int hide_cursor)
587 resource_thread->stop_draw(0);
589 int mode = redraw ? FORCE_REDRAW : NORMAL_DRAW;
590 for(int i = 0; i < TOTAL_PANES; i++) {
592 pane[i]->canvas->draw(mode, hide_cursor);
595 resource_thread->start_draw();
598 void MWindowGUI::flash_canvas(int flush)
600 for(int i = 0; i < TOTAL_PANES; i++)
604 pane[i]->canvas->flash(flush);
609 int MWindowGUI::show_window(int flush)
611 int ret = BC_WindowBase::show_window(flush);
612 update_proxy_toggle();
616 void MWindowGUI::draw_cursor(int do_plugintoggles)
618 for(int i = 0; i < TOTAL_PANES; i++)
622 pane[i]->cursor->draw(do_plugintoggles);
627 void MWindowGUI::show_cursor(int do_plugintoggles)
629 for(int i = 0; i < TOTAL_PANES; i++)
633 pane[i]->cursor->show(do_plugintoggles);
638 void MWindowGUI::hide_cursor(int do_plugintoggles)
640 for(int i = 0; i < TOTAL_PANES; i++)
644 pane[i]->cursor->hide(do_plugintoggles);
649 void MWindowGUI::update_cursor()
651 for(int i = 0; i < TOTAL_PANES; i++)
655 pane[i]->cursor->update();
660 void MWindowGUI::set_playing_back(int value)
662 for(int i = 0; i < TOTAL_PANES; i++)
666 pane[i]->cursor->playing_back = value;
671 void MWindowGUI::update_scrollbars(int flush)
673 for(int i = 0; i < TOTAL_PANES; i++)
677 pane[i]->update(1, NO_DRAW, 0, 0);
680 if(flush) this->flush();
683 void MWindowGUI::reset_meters()
685 for(int i = 0; i < TOTAL_PANES; i++)
687 if(pane[i] && pane[i]->patchbay)
689 pane[i]->patchbay->reset_meters();
694 void MWindowGUI::stop_meters()
696 for(int i = 0; i < TOTAL_PANES; i++)
698 if(pane[i] && pane[i]->patchbay)
700 pane[i]->patchbay->stop_meters();
705 void MWindowGUI::update_meters(ArrayList<double> *module_levels)
707 for(int i = 0; i < TOTAL_PANES; i++)
709 if(pane[i] && pane[i]->patchbay)
711 pane[i]->patchbay->update_meters(module_levels);
716 void MWindowGUI::set_editing_mode(int flush)
718 for(int i = 0; i < TOTAL_PANES; i++)
722 pane[i]->canvas->update_cursor(flush);
727 void MWindowGUI::set_meter_format(int mode, int min, int max)
729 for(int i = 0; i < TOTAL_PANES; i++)
731 if(pane[i] && pane[i]->patchbay)
733 pane[i]->patchbay->set_meter_format(mode, min, max);
738 void MWindowGUI::update(int scrollbars,
747 if(debug) PRINT_TRACE
751 mwindow->edl->tracks->update_y_pixels(mwindow->theme);
753 if( do_canvas != NO_DRAW && do_canvas != IGNORE_THREAD )
754 resource_thread->stop_draw(1);
756 for(int i = 0; i < TOTAL_PANES; i++)
758 if(pane[i]) pane[i]->update(scrollbars,
764 if( do_canvas != NO_DRAW && do_canvas != IGNORE_THREAD )
765 resource_thread->start_draw();
767 // if(scrollbars) this->get_scrollbars(0);
768 // if(timebar) this->timebar->update(0);
769 if(zoombar) this->zoombar->update();
770 // if(patchbay) this->patchbay->update();
771 if(clock) this->mainclock->update(
772 mwindow->edl->local_session->get_selectionstart(1));
773 if(debug) PRINT_TRACE
779 // this->canvas->draw(do_canvas);
780 // this->cursor->show();
781 // this->canvas->flash(0);
782 // Activate causes the menubar to deactivate. Don't want this for
784 // if(canvas != IGNORE_THREAD) this->canvas->activate();
786 if(debug) PRINT_TRACE
790 if(buttonbar) mbuttons->update();
791 if(debug) PRINT_TRACE
793 // Can't age if the cache called this to draw missing picons
794 // or the GUI is updating the status of the draw toggle.
795 if( do_canvas != FORCE_REDRAW && do_canvas != IGNORE_THREAD ) {
797 mwindow->age_caches();
798 lock_window("MWindowGUI::update");
802 if(debug) PRINT_TRACE
805 int MWindowGUI::visible(int64_t x1, int64_t x2, int64_t view_x1, int64_t view_x2)
807 return (x1 >= view_x1 && x1 < view_x2) ||
808 (x2 > view_x1 && x2 <= view_x2) ||
809 (x1 <= view_x1 && x2 >= view_x2);
813 void MWindowGUI::show_message(const char *message, int msg_color, int bar_color)
815 statusbar->show_message(message, msg_color, bar_color);
818 void MWindowGUI::update_default_message()
820 statusbar->update_default_message();
823 void MWindowGUI::reset_default_message()
825 statusbar->reset_default_message();
828 void MWindowGUI::default_message()
830 statusbar->default_message();
833 // Drag motion called from other window
834 int MWindowGUI::drag_motion()
836 if(get_hidden()) return 0;
838 Track *over_track = 0;
840 PluginSet *over_pluginset = 0;
841 Plugin *over_plugin = 0;
846 drag_popup->cursor_motion_event();
850 // there's no point in drawing highlights has until drag operation has been set
851 if (!mwindow->session->current_operation)
854 for(int i = 0; i < TOTAL_PANES; i++)
856 if(pane[i]) pane[i]->canvas->drag_motion(
863 if(mwindow->session->track_highlighted != over_track)
865 mwindow->session->track_highlighted = over_track;
869 if(mwindow->session->edit_highlighted != over_edit)
871 mwindow->session->edit_highlighted = over_edit;
875 if(mwindow->session->pluginset_highlighted != over_pluginset)
877 mwindow->session->pluginset_highlighted = over_pluginset;
881 if(mwindow->session->plugin_highlighted != over_plugin)
883 mwindow->session->plugin_highlighted = over_plugin;
887 if( mwindow->session->current_operation == DRAG_ASSET ||
888 mwindow->session->current_operation == DRAG_EDIT ||
889 mwindow->session->current_operation == DRAG_GROUP ||
890 mwindow->session->current_operation == DRAG_AEFFECT_COPY ||
891 mwindow->session->current_operation == DRAG_VEFFECT_COPY ) {
896 // printf("drag_motion %d %d over_track=%p over_edit=%p\n",
903 lock_window("MWindowGUI::drag_motion");
910 int MWindowGUI::drag_stop()
912 if(get_hidden()) return 0;
913 int result = 0, redraw = 0;
915 for(int i = 0; i < TOTAL_PANES; i++)
917 if(pane[i]) result |= pane[i]->canvas->drag_stop(
920 mwindow->edl->optimize();
922 // since we don't have subwindows we have to terminate any drag operation
925 if (mwindow->session->track_highlighted
926 || mwindow->session->edit_highlighted
927 || mwindow->session->plugin_highlighted
928 || mwindow->session->pluginset_highlighted)
930 mwindow->session->track_highlighted = 0;
931 mwindow->session->edit_highlighted = 0;
932 mwindow->session->plugin_highlighted = 0;
933 mwindow->session->pluginset_highlighted = 0;
934 mwindow->session->current_operation = NO_OPERATION;
938 //printf("MWindowGUI::drag_stop %d %d\n", redraw, mwindow->session->current_operation);
941 mwindow->edl->tracks->update_y_pixels(mwindow->theme);
942 update_scrollbars(0);
957 void MWindowGUI::default_positions()
959 //printf("MWindowGUI::default_positions 1\n");
960 VWindow *vwindow = mwindow->vwindows.size() > DEFAULT_VWINDOW ?
961 mwindow->vwindows.get(DEFAULT_VWINDOW) : 0;
962 if( vwindow && !vwindow->is_running() ) vwindow = 0;
963 if( vwindow ) vwindow->gui->lock_window("MWindowGUI::default_positions");
964 mwindow->cwindow->gui->lock_window("MWindowGUI::default_positions");
965 mwindow->awindow->gui->lock_window("MWindowGUI::default_positions");
967 // printf("MWindowGUI::default_positions 1 %d %d %d %d\n", mwindow->session->vwindow_x,
968 // mwindow->session->vwindow_y,
969 // mwindow->session->vwindow_w,
970 // mwindow->session->vwindow_h);
971 reposition_window(mwindow->session->mwindow_x,
972 mwindow->session->mwindow_y,
973 mwindow->session->mwindow_w,
974 mwindow->session->mwindow_h);
975 if( vwindow ) vwindow->gui->reposition_window(mwindow->session->vwindow_x,
976 mwindow->session->vwindow_y,
977 mwindow->session->vwindow_w,
978 mwindow->session->vwindow_h);
979 mwindow->cwindow->gui->reposition_window(mwindow->session->cwindow_x,
980 mwindow->session->cwindow_y,
981 mwindow->session->cwindow_w,
982 mwindow->session->cwindow_h);
983 mwindow->awindow->gui->reposition_window(mwindow->session->awindow_x,
984 mwindow->session->awindow_y,
985 mwindow->session->awindow_w,
986 mwindow->session->awindow_h);
987 //printf("MWindowGUI::default_positions 1\n");
989 resize_event(mwindow->session->mwindow_w,
990 mwindow->session->mwindow_h);
991 //printf("MWindowGUI::default_positions 1\n");
992 if( vwindow ) vwindow->gui->resize_event(mwindow->session->vwindow_w,
993 mwindow->session->vwindow_h);
994 //printf("MWindowGUI::default_positions 1\n");
995 mwindow->cwindow->gui->resize_event(mwindow->session->cwindow_w,
996 mwindow->session->cwindow_h);
997 //printf("MWindowGUI::default_positions 1\n");
998 mwindow->awindow->gui->resize_event(mwindow->session->awindow_w,
999 mwindow->session->awindow_h);
1001 //printf("MWindowGUI::default_positions 1\n");
1004 if( vwindow ) vwindow->gui->flush();
1005 mwindow->cwindow->gui->flush();
1006 mwindow->awindow->gui->flush();
1008 if( vwindow ) vwindow->gui->unlock_window();
1009 mwindow->cwindow->gui->unlock_window();
1010 mwindow->awindow->gui->unlock_window();
1011 //printf("MWindowGUI::default_positions 2\n");
1015 int MWindowGUI::repeat_event(int64_t duration)
1017 // if(duration == 100)
1018 // mwindow->sync_parameters(CHANGE_ALL);
1020 for(int i = 0; i < TOTAL_PANES; i++)
1022 if(pane[i]) result = pane[i]->cursor->repeat_event(duration);
1028 int MWindowGUI::translation_event()
1030 //printf("MWindowGUI::translation_event 1 %d %d\n", get_x(), get_y());
1031 mwindow->session->mwindow_x = get_x();
1032 mwindow->session->mwindow_y = get_y();
1037 int MWindowGUI::save_defaults(BC_Hash *defaults)
1039 defaults->update("MWINDOWWIDTH", get_w());
1040 defaults->update("MWINDOWHEIGHT", get_h());
1041 mainmenu->save_defaults(defaults);
1042 BC_WindowBase::save_defaults(defaults);
1046 int MWindowGUI::keypress_event()
1048 //printf("MWindowGUI::keypress_event 1 %d\n", get_keypress());
1049 int result = mbuttons->keypress_event();
1050 if( result ) return result;
1052 Track *this_track = 0, *first_track = 0;
1053 int collapse = 0, packed = 0, overwrite = 0, plugins = 0;
1054 double position = 0;
1056 switch( get_keypress() ) {
1058 if( !ctrl_down() || !shift_down() || alt_down() ) break;
1059 mwindow->edl->tracks->clear_selected_edits();
1064 mwindow->toggle_editing_mode();
1069 if( alt_down() ) break;
1070 stop_transport("MWindowGUI::keypress_event 1");
1071 mwindow->nearest_plugin_keyframe(shift_down(),
1072 !ctrl_down() ? PLAY_FORWARD : PLAY_REVERSE);
1079 if( !ctrl_down() || alt_down() ) break;
1080 mwindow->selected_edits_to_clipboard(packed);
1086 overwrite = -1; // fall thru
1088 if( !ctrl_down() || alt_down() ) break;
1089 if( mwindow->session->current_operation == DROP_TARGETING ) {
1090 mwindow->session->current_operation = NO_OPERATION;
1091 mwindow->gui->set_editing_mode(1);
1093 for( ; pane_no<TOTAL_PANES; ++pane_no ) {
1094 if( !pane[pane_no] ) continue;
1095 first_track = pane[pane_no]->over_track();
1096 if( first_track ) break;
1099 int cursor_x = pane[pane_no]->canvas->get_relative_cursor_x();
1100 position = mwindow->edl->get_cursor_position(cursor_x, pane_no);
1104 position = mwindow->edl->local_session->get_selectionstart();
1106 mwindow->paste(position, first_track, 0, overwrite);
1108 mwindow->paste_clipboard(first_track, position, 1, 0, 1, 1, 1);
1109 mwindow->edl->tracks->clear_selected_edits();
1117 mwindow->cut_selected_edits(0, collapse);
1123 if( !ctrl_down() || alt_down() ) break;
1124 mwindow->cut_selected_edits(1, collapse);
1129 if( !alt_down() || shift_down() ) break;
1130 if( !mwindow->select_asset(get_keypress()-'1',1) )
1135 if( !ctrl_down() ) {
1137 stop_transport("MWindowGUI::keypress_event 1");
1138 mwindow->prev_edit_handle(shift_down());
1141 mwindow->move_left();
1147 if( !ctrl_down() && !alt_down() ) {
1148 mwindow->move_left();
1154 if( !ctrl_down() ) {
1156 stop_transport("MWindowGUI::keypress_event 2");
1157 mwindow->next_edit_handle(shift_down());
1160 mwindow->move_right();
1166 if( !ctrl_down() && !alt_down() ) {
1167 mwindow->move_right();
1173 if( ctrl_down() && !alt_down() )
1174 mwindow->expand_y();
1175 else if( !ctrl_down() && alt_down() )
1176 mwindow->expand_autos(0,1,1);
1177 else if( ctrl_down() && alt_down() )
1178 mwindow->expand_autos(1,1,1);
1180 mwindow->expand_sample();
1185 if( ctrl_down() && !alt_down() )
1186 mwindow->zoom_in_y();
1187 else if( !ctrl_down() && alt_down() )
1188 mwindow->shrink_autos(0,1,1);
1189 else if( ctrl_down() && alt_down() )
1190 mwindow->shrink_autos(1,1,1);
1192 mwindow->zoom_in_sample();
1200 mwindow->expand_t();
1206 mwindow->move_down();
1208 mwindow->zoom_in_t();
1214 for( int i=0; i<TOTAL_PANES; ++i ) {
1215 if( !pane[i] ) continue;
1216 if( (this_track = pane[i]->over_track()) != 0 ) break;
1217 if( (this_track = pane[i]->over_patchbay()) != 0 ) break;
1220 if( get_keypress() == TAB ) { // Switch the record button
1222 this_track->record = !this_track->record ? 1 : 0;
1225 int total_selected = mwindow->edl->tracks->total_of(Tracks::RECORD);
1226 // all selected if nothing previously selected or
1227 // if this patch was previously the only one selected and armed
1228 int selected = !total_selected || (total_selected == 1 &&
1229 this_track && this_track->record ) ? 1 : 0;
1230 mwindow->edl->tracks->select_all(Tracks::RECORD, selected);
1231 if( !selected && this_track ) this_track->record = 1;
1234 update(0, NORMAL_DRAW, 0, 0, 1, 0, 1);
1236 mwindow->cwindow->update(0, 1, 1);
1237 lock_window("MWindowGUI::keypress_event 3");
1242 case KEY_F1 ... KEY_F12:
1243 resend_event(mwindow->cwindow->gui);
1247 // since things under cursor have changed...
1249 cursor_motion_event();
1254 int MWindowGUI::keyboard_listener(BC_WindowBase *wp)
1256 return key_listener(wp->get_keypress());
1259 int MWindowGUI::key_listener(int key)
1264 if( !record->running() )
1267 record->record_gui->interrupt_thread->start(0);
1274 channel_info->toggle_scan();
1278 if( !remote_control->deactivate() )
1279 remote_control->activate();
1289 void MWindowGUI::use_android_remote(int on)
1292 delete android_control;
1293 android_control = 0;
1296 if( android_control ) return;
1297 android_control = new AndroidControl(this);
1300 int MWindowGUI::close_event()
1306 void MWindowGUI::stop_drawing()
1308 resource_thread->stop_draw(1);
1311 int MWindowGUI::menu_w()
1313 return mainmenu->get_w();
1316 int MWindowGUI::menu_h()
1318 return mainmenu->get_h();
1321 void MWindowGUI::start_x_pane_drag()
1325 x_pane_drag = new BC_Popup(this,
1326 get_abs_cursor_x(0) - mwindow->theme->pane_w,
1327 BC_DisplayInfo::get_top_border() +
1329 mwindow->theme->mcanvas_y,
1330 mwindow->theme->pane_w,
1331 mwindow->theme->mcanvas_h,
1332 mwindow->theme->drag_pane_color);
1333 x_pane_drag->draw_3segmentv(0,
1335 x_pane_drag->get_h(),
1336 mwindow->theme->get_image_set("xpane")[BUTTON_DOWNHI]);
1337 x_pane_drag->flash(1);
1342 void MWindowGUI::start_y_pane_drag()
1346 //printf("MWindowGUI::start_y_pane_drag %d %d %d\n", __LINE__, get_x(), get_y());
1347 y_pane_drag = new BC_Popup(this,
1348 BC_DisplayInfo::get_left_border() +
1350 mwindow->theme->mcanvas_x,
1351 get_abs_cursor_y(0) - mwindow->theme->pane_h,
1352 mwindow->theme->mcanvas_w,
1353 mwindow->theme->pane_h,
1354 mwindow->theme->drag_pane_color);
1355 y_pane_drag->draw_3segmenth(0,
1357 y_pane_drag->get_w(),
1358 mwindow->theme->get_image_set("ypane")[BUTTON_DOWNHI]);
1359 y_pane_drag->flash(1);
1364 void MWindowGUI::handle_pane_drag()
1370 x_pane_drag->reposition_window(
1371 get_abs_cursor_x(0) - mwindow->theme->pane_w,
1372 x_pane_drag->get_y());
1377 y_pane_drag->reposition_window(
1378 y_pane_drag->get_x(),
1379 get_abs_cursor_y(0) - mwindow->theme->pane_h);
1385 void MWindowGUI::create_x_pane(int cursor_x)
1387 if(total_panes() == 1)
1389 // create a horizontal pane
1390 // do this 1st so the resize_event knows there are 2 panes
1391 mwindow->edl->local_session->view_start[TOP_RIGHT_PANE] =
1392 mwindow->edl->local_session->view_start[TOP_LEFT_PANE] +
1394 mwindow->theme->patchbay_w;
1395 pane[TOP_RIGHT_PANE] = new TimelinePane(mwindow,
1397 mwindow->theme->mcanvas_x +
1399 mwindow->theme->mcanvas_y,
1400 mwindow->theme->mcanvas_x +
1401 mwindow->theme->mcanvas_w -
1403 mwindow->theme->mcanvas_h);
1404 pane[TOP_LEFT_PANE]->resize_event(
1405 mwindow->theme->mcanvas_x,
1406 mwindow->theme->mcanvas_y,
1407 cursor_x - mwindow->theme->pane_w,
1408 mwindow->theme->mcanvas_h);
1409 pane[TOP_RIGHT_PANE]->create_objects();
1412 if(vertical_panes())
1414 // create 2 horizontal panes
1415 mwindow->edl->local_session->track_start[TOP_RIGHT_PANE] =
1416 mwindow->edl->local_session->track_start[TOP_LEFT_PANE];
1417 mwindow->edl->local_session->track_start[BOTTOM_RIGHT_PANE] =
1418 mwindow->edl->local_session->track_start[BOTTOM_LEFT_PANE];
1419 mwindow->edl->local_session->view_start[TOP_RIGHT_PANE] =
1420 mwindow->edl->local_session->view_start[BOTTOM_RIGHT_PANE] =
1421 mwindow->edl->local_session->view_start[TOP_LEFT_PANE] +
1423 mwindow->theme->patchbay_w;
1424 pane[TOP_RIGHT_PANE] = new TimelinePane(mwindow,
1426 mwindow->theme->mcanvas_x +
1428 pane[TOP_LEFT_PANE]->y,
1429 mwindow->theme->mcanvas_x +
1430 mwindow->theme->mcanvas_w -
1432 pane[TOP_LEFT_PANE]->h);
1433 pane[BOTTOM_RIGHT_PANE] = new TimelinePane(mwindow,
1435 mwindow->theme->mcanvas_x +
1437 pane[BOTTOM_LEFT_PANE]->y,
1438 mwindow->theme->mcanvas_x +
1439 mwindow->theme->mcanvas_w -
1441 pane[BOTTOM_LEFT_PANE]->h);
1442 pane[TOP_LEFT_PANE]->resize_event(
1443 pane[TOP_LEFT_PANE]->x,
1444 pane[TOP_LEFT_PANE]->y,
1445 cursor_x - mwindow->theme->pane_w,
1446 pane[TOP_LEFT_PANE]->h);
1447 pane[BOTTOM_LEFT_PANE]->resize_event(
1448 pane[BOTTOM_LEFT_PANE]->x,
1449 pane[BOTTOM_LEFT_PANE]->y,
1450 cursor_x - mwindow->theme->pane_w,
1451 pane[BOTTOM_LEFT_PANE]->h);
1452 pane[TOP_RIGHT_PANE]->create_objects();
1453 pane[BOTTOM_RIGHT_PANE]->create_objects();
1456 if(horizontal_panes())
1458 // resize a horizontal pane
1459 mwindow->edl->local_session->view_start[TOP_RIGHT_PANE] +=
1461 pane[TOP_RIGHT_PANE]->x;
1462 if(mwindow->edl->local_session->view_start[TOP_RIGHT_PANE] < 0)
1463 mwindow->edl->local_session->view_start[TOP_RIGHT_PANE] = 0;
1464 pane[TOP_LEFT_PANE]->resize_event(
1465 mwindow->theme->mcanvas_x,
1466 mwindow->theme->mcanvas_y,
1467 cursor_x - mwindow->theme->pane_w,
1468 mwindow->theme->mcanvas_h);
1469 pane[TOP_RIGHT_PANE]->resize_event(
1470 mwindow->theme->mcanvas_x +
1472 pane[TOP_RIGHT_PANE]->y,
1473 mwindow->theme->mcanvas_x +
1474 mwindow->theme->mcanvas_w -
1476 mwindow->theme->mcanvas_h);
1480 // resize 2 horizontal panes
1481 mwindow->edl->local_session->view_start[TOP_RIGHT_PANE] +=
1483 pane[TOP_RIGHT_PANE]->x;
1484 if(mwindow->edl->local_session->view_start[TOP_RIGHT_PANE] < 0)
1485 mwindow->edl->local_session->view_start[TOP_RIGHT_PANE] = 0;
1486 mwindow->edl->local_session->view_start[BOTTOM_RIGHT_PANE] =
1487 mwindow->edl->local_session->view_start[TOP_RIGHT_PANE];
1489 pane[TOP_LEFT_PANE]->resize_event(
1490 mwindow->theme->mcanvas_x,
1491 pane[TOP_LEFT_PANE]->y,
1492 cursor_x - mwindow->theme->pane_w,
1493 pane[TOP_LEFT_PANE]->h);
1494 pane[TOP_RIGHT_PANE]->resize_event(
1495 mwindow->theme->mcanvas_x +
1497 pane[TOP_RIGHT_PANE]->y,
1498 mwindow->theme->mcanvas_x +
1499 mwindow->theme->mcanvas_w -
1501 pane[TOP_RIGHT_PANE]->h);
1502 pane[BOTTOM_LEFT_PANE]->resize_event(
1503 mwindow->theme->mcanvas_x,
1504 pane[BOTTOM_LEFT_PANE]->y,
1505 cursor_x - mwindow->theme->pane_w,
1506 pane[BOTTOM_LEFT_PANE]->h);
1507 pane[BOTTOM_RIGHT_PANE]->resize_event(
1508 mwindow->theme->mcanvas_x +
1510 pane[BOTTOM_RIGHT_PANE]->y,
1511 mwindow->theme->mcanvas_x +
1512 mwindow->theme->mcanvas_w -
1514 pane[BOTTOM_RIGHT_PANE]->h);
1520 void MWindowGUI::delete_x_pane(int cursor_x)
1522 // give left panes coordinates of right pane
1523 if(cursor_x < mwindow->theme->patchbay_w + PANE_DRAG_MARGIN &&
1524 pane[TOP_RIGHT_PANE])
1526 mwindow->edl->local_session->view_start[TOP_LEFT_PANE] =
1527 mwindow->edl->local_session->view_start[TOP_RIGHT_PANE] -
1528 pane[TOP_RIGHT_PANE]->x + mwindow->theme->patchbay_w;
1529 if(mwindow->edl->local_session->view_start[TOP_LEFT_PANE] < 0)
1530 mwindow->edl->local_session->view_start[TOP_LEFT_PANE] = 0;
1531 mwindow->edl->local_session->view_start[BOTTOM_LEFT_PANE] =
1532 mwindow->edl->local_session->view_start[TOP_LEFT_PANE];
1535 switch(total_panes())
1538 if(pane[TOP_LEFT_PANE] && pane[TOP_RIGHT_PANE])
1540 // delete right pane
1541 delete pane[TOP_RIGHT_PANE];
1542 pane[TOP_RIGHT_PANE] = 0;
1543 pane[TOP_LEFT_PANE]->resize_event(
1544 mwindow->theme->mcanvas_x,
1545 mwindow->theme->mcanvas_y,
1546 mwindow->theme->mcanvas_w,
1547 mwindow->theme->mcanvas_h);
1553 // delete right panes
1554 delete pane[TOP_RIGHT_PANE];
1555 pane[TOP_RIGHT_PANE] = 0;
1556 delete pane[BOTTOM_RIGHT_PANE];
1557 pane[BOTTOM_RIGHT_PANE] = 0;
1558 pane[TOP_LEFT_PANE]->resize_event(
1559 mwindow->theme->mcanvas_x,
1560 pane[TOP_LEFT_PANE]->y,
1561 mwindow->theme->mcanvas_w,
1562 pane[TOP_LEFT_PANE]->h);
1563 pane[BOTTOM_LEFT_PANE]->resize_event(
1564 mwindow->theme->mcanvas_x,
1565 pane[BOTTOM_LEFT_PANE]->y,
1566 mwindow->theme->mcanvas_w,
1567 pane[BOTTOM_LEFT_PANE]->h);
1572 void MWindowGUI::create_y_pane(int cursor_y)
1574 if(total_panes() == 1)
1576 mwindow->edl->local_session->view_start[BOTTOM_LEFT_PANE] =
1577 mwindow->edl->local_session->view_start[TOP_LEFT_PANE];
1578 mwindow->edl->local_session->track_start[BOTTOM_LEFT_PANE] =
1579 mwindow->edl->local_session->track_start[TOP_LEFT_PANE] +
1581 mwindow->theme->mtimebar_h;
1582 // do this 1st so the resize_event knows there are 2 panes
1583 pane[BOTTOM_LEFT_PANE] = new TimelinePane(mwindow,
1585 mwindow->theme->mcanvas_x,
1586 mwindow->theme->mcanvas_y +
1588 mwindow->theme->mcanvas_w,
1589 mwindow->theme->mcanvas_h -
1591 pane[TOP_LEFT_PANE]->resize_event(
1592 mwindow->theme->mcanvas_x,
1593 mwindow->theme->mcanvas_y,
1594 mwindow->theme->mcanvas_w,
1595 pane[BOTTOM_LEFT_PANE]->y -
1596 mwindow->theme->mcanvas_y -
1597 mwindow->theme->pane_h);
1598 pane[BOTTOM_LEFT_PANE]->create_objects();
1601 if(horizontal_panes())
1604 mwindow->edl->local_session->view_start[BOTTOM_LEFT_PANE] =
1605 mwindow->edl->local_session->view_start[TOP_LEFT_PANE];
1606 mwindow->edl->local_session->view_start[BOTTOM_RIGHT_PANE] =
1607 mwindow->edl->local_session->view_start[TOP_RIGHT_PANE];
1608 mwindow->edl->local_session->track_start[BOTTOM_LEFT_PANE] =
1609 mwindow->edl->local_session->track_start[BOTTOM_RIGHT_PANE] =
1610 mwindow->edl->local_session->track_start[TOP_LEFT_PANE] +
1612 mwindow->theme->mtimebar_h;
1614 pane[BOTTOM_LEFT_PANE] = new TimelinePane(mwindow,
1616 pane[TOP_LEFT_PANE]->x,
1617 mwindow->theme->mcanvas_y +
1619 pane[TOP_LEFT_PANE]->w,
1620 mwindow->theme->mcanvas_h -
1622 pane[BOTTOM_RIGHT_PANE] = new TimelinePane(mwindow,
1624 pane[TOP_RIGHT_PANE]->x,
1625 mwindow->theme->mcanvas_y +
1627 pane[TOP_RIGHT_PANE]->w,
1628 mwindow->theme->mcanvas_h -
1631 pane[TOP_LEFT_PANE]->resize_event(
1632 pane[TOP_LEFT_PANE]->x,
1633 pane[TOP_LEFT_PANE]->y,
1634 pane[TOP_LEFT_PANE]->w,
1635 pane[BOTTOM_LEFT_PANE]->y -
1636 mwindow->theme->mcanvas_y -
1637 mwindow->theme->pane_h);
1638 pane[TOP_RIGHT_PANE]->resize_event(
1639 pane[TOP_RIGHT_PANE]->x,
1640 pane[TOP_RIGHT_PANE]->y,
1641 pane[TOP_RIGHT_PANE]->w,
1642 pane[BOTTOM_RIGHT_PANE]->y -
1643 mwindow->theme->mcanvas_y -
1644 mwindow->theme->pane_h);
1646 pane[BOTTOM_LEFT_PANE]->create_objects();
1647 pane[BOTTOM_RIGHT_PANE]->create_objects();
1650 if(vertical_panes())
1653 mwindow->edl->local_session->track_start[BOTTOM_LEFT_PANE] +=
1655 (pane[BOTTOM_LEFT_PANE]->y - mwindow->theme->mcanvas_y);
1656 if(mwindow->edl->local_session->track_start[BOTTOM_LEFT_PANE] < 0)
1657 mwindow->edl->local_session->track_start[BOTTOM_LEFT_PANE] = 0;
1658 pane[TOP_LEFT_PANE]->resize_event(
1659 mwindow->theme->mcanvas_x,
1660 mwindow->theme->mcanvas_y,
1661 mwindow->theme->mcanvas_w,
1662 cursor_y - mwindow->theme->pane_h);
1663 pane[BOTTOM_LEFT_PANE]->resize_event(
1664 pane[BOTTOM_LEFT_PANE]->x,
1666 mwindow->theme->mcanvas_y,
1667 mwindow->theme->mcanvas_w,
1668 mwindow->theme->mcanvas_h -
1674 mwindow->edl->local_session->track_start[BOTTOM_LEFT_PANE] +=
1676 (pane[BOTTOM_LEFT_PANE]->y - mwindow->theme->mcanvas_y);
1677 if(mwindow->edl->local_session->track_start[BOTTOM_LEFT_PANE] < 0)
1678 mwindow->edl->local_session->track_start[BOTTOM_LEFT_PANE] = 0;
1679 mwindow->edl->local_session->track_start[BOTTOM_RIGHT_PANE] =
1680 mwindow->edl->local_session->track_start[BOTTOM_LEFT_PANE];
1681 pane[TOP_LEFT_PANE]->resize_event(
1682 pane[TOP_LEFT_PANE]->x,
1683 pane[TOP_LEFT_PANE]->y,
1684 pane[TOP_LEFT_PANE]->w,
1685 cursor_y - mwindow->theme->pane_h);
1686 pane[BOTTOM_LEFT_PANE]->resize_event(
1687 pane[BOTTOM_LEFT_PANE]->x,
1689 mwindow->theme->mcanvas_y,
1690 pane[BOTTOM_LEFT_PANE]->w,
1691 mwindow->theme->mcanvas_h -
1693 pane[TOP_RIGHT_PANE]->resize_event(
1694 pane[TOP_RIGHT_PANE]->x,
1695 pane[TOP_RIGHT_PANE]->y,
1696 pane[TOP_RIGHT_PANE]->w,
1697 cursor_y - mwindow->theme->pane_h);
1698 pane[BOTTOM_RIGHT_PANE]->resize_event(
1699 pane[BOTTOM_RIGHT_PANE]->x,
1701 mwindow->theme->mcanvas_y,
1702 pane[BOTTOM_RIGHT_PANE]->w,
1703 mwindow->theme->mcanvas_h -
1708 void MWindowGUI::delete_y_pane(int cursor_y)
1710 if(cursor_y < mwindow->theme->mtimebar_h +
1712 pane[BOTTOM_LEFT_PANE])
1714 // give top pane coordinates of bottom pane
1715 mwindow->edl->local_session->track_start[TOP_LEFT_PANE] =
1716 mwindow->edl->local_session->track_start[BOTTOM_LEFT_PANE] -
1717 pane[BOTTOM_LEFT_PANE]->y;
1718 if(mwindow->edl->local_session->track_start[TOP_LEFT_PANE] < 0)
1719 mwindow->edl->local_session->track_start[TOP_LEFT_PANE] = 0;
1720 mwindow->edl->local_session->track_start[TOP_RIGHT_PANE] =
1721 mwindow->edl->local_session->track_start[TOP_LEFT_PANE];
1725 switch(total_panes())
1728 delete pane[BOTTOM_LEFT_PANE];
1729 pane[BOTTOM_LEFT_PANE] = 0;
1730 pane[TOP_LEFT_PANE]->resize_event(
1731 mwindow->theme->mcanvas_x,
1732 mwindow->theme->mcanvas_y,
1733 mwindow->theme->mcanvas_w,
1734 mwindow->theme->mcanvas_h);
1738 // delete bottom 2 panes
1740 delete pane[BOTTOM_LEFT_PANE];
1741 pane[BOTTOM_LEFT_PANE] = 0;
1742 delete pane[BOTTOM_RIGHT_PANE];
1743 pane[BOTTOM_RIGHT_PANE] = 0;
1744 pane[TOP_LEFT_PANE]->resize_event(
1745 pane[TOP_LEFT_PANE]->x,
1746 mwindow->theme->mcanvas_y,
1747 pane[TOP_LEFT_PANE]->w,
1748 mwindow->theme->mcanvas_h);
1749 pane[TOP_RIGHT_PANE]->resize_event(
1750 pane[TOP_RIGHT_PANE]->x,
1751 mwindow->theme->mcanvas_y,
1752 pane[TOP_RIGHT_PANE]->w,
1753 mwindow->theme->mcanvas_h);
1758 void MWindowGUI::stop_pane_drag()
1761 resource_thread->stop_draw(0);
1765 // cursor position relative to canvas
1766 int cursor_x = x_pane_drag->get_x() -
1768 BC_DisplayInfo::get_left_border() -
1769 mwindow->theme->mcanvas_x +
1770 mwindow->theme->pane_w;
1775 if(cursor_x >= mwindow->theme->patchbay_w + PANE_DRAG_MARGIN &&
1776 cursor_x < mwindow->theme->mcanvas_w -
1777 BC_ScrollBar::get_span(SCROLL_VERT) -
1780 create_x_pane(cursor_x);
1781 mwindow->edl->local_session->x_pane = cursor_x;
1786 delete_x_pane(cursor_x);
1787 mwindow->edl->local_session->x_pane = -1;
1795 // cursor position relative to canvas
1796 int cursor_y = y_pane_drag->get_y() -
1798 BC_DisplayInfo::get_top_border() -
1799 mwindow->theme->mcanvas_y +
1800 mwindow->theme->pane_h;
1806 if(cursor_y >= mwindow->theme->mtimebar_h +
1808 cursor_y < mwindow->theme->mcanvas_h -
1809 BC_ScrollBar::get_span(SCROLL_HORIZ) -
1812 create_y_pane(cursor_y);
1813 mwindow->edl->local_session->y_pane = cursor_y;
1817 delete_y_pane(cursor_y);
1818 mwindow->edl->local_session->y_pane = -1;
1822 update_pane_dividers();
1824 // required to get new widgets to appear
1826 resource_thread->start_draw();
1829 // create panes from EDL
1830 void MWindowGUI::load_panes()
1832 int need_x_panes = 0;
1833 int need_y_panes = 0;
1834 // use names from create functions
1835 int cursor_x = mwindow->edl->local_session->x_pane;
1836 int cursor_y = mwindow->edl->local_session->y_pane;
1838 resource_thread->stop_draw(1);
1840 mwindow->theme->patchbay_w + PANE_DRAG_MARGIN &&
1842 mwindow->theme->mcanvas_w -
1843 BC_ScrollBar::get_span(SCROLL_VERT) -
1850 mwindow->theme->mtimebar_h + PANE_DRAG_MARGIN &&
1852 mwindow->theme->mcanvas_h -
1853 BC_ScrollBar::get_span(SCROLL_HORIZ) -
1859 //printf("MWindowGUI::load_panes %d %d %d\n", __LINE__, need_x_panes, need_y_panes);
1867 if(total_panes() == 1)
1870 //printf("MWindowGUI::load_panes %d\n", __LINE__);
1871 pane[TOP_RIGHT_PANE] = new TimelinePane(mwindow,
1873 mwindow->theme->mcanvas_x +
1875 mwindow->theme->mcanvas_y,
1876 mwindow->theme->mcanvas_x +
1877 mwindow->theme->mcanvas_w -
1879 cursor_y - mwindow->theme->pane_h);
1880 pane[BOTTOM_LEFT_PANE] = new TimelinePane(mwindow,
1882 mwindow->theme->mcanvas_x,
1883 mwindow->theme->mcanvas_y +
1885 cursor_x - mwindow->theme->pane_w,
1886 mwindow->theme->mcanvas_h -
1888 pane[BOTTOM_RIGHT_PANE] = new TimelinePane(mwindow,
1890 pane[TOP_RIGHT_PANE]->x,
1891 mwindow->theme->mcanvas_y +
1893 pane[TOP_RIGHT_PANE]->w,
1894 mwindow->theme->mcanvas_h -
1896 pane[TOP_LEFT_PANE]->resize_event(
1897 pane[TOP_LEFT_PANE]->x,
1898 pane[TOP_LEFT_PANE]->y,
1899 cursor_x - mwindow->theme->pane_w,
1900 cursor_y - mwindow->theme->pane_h);
1901 pane[TOP_RIGHT_PANE]->create_objects();
1902 pane[BOTTOM_LEFT_PANE]->create_objects();
1903 pane[BOTTOM_RIGHT_PANE]->create_objects();
1906 if(horizontal_panes())
1908 // create vertical panes
1909 //printf("MWindowGUI::load_panes %d\n", __LINE__);
1910 pane[BOTTOM_LEFT_PANE] = new TimelinePane(mwindow,
1912 mwindow->theme->mcanvas_x,
1913 mwindow->theme->mcanvas_y +
1915 cursor_x - mwindow->theme->pane_w,
1916 mwindow->theme->mcanvas_h -
1918 pane[BOTTOM_RIGHT_PANE] = new TimelinePane(mwindow,
1920 pane[TOP_RIGHT_PANE]->x,
1921 mwindow->theme->mcanvas_y +
1923 pane[TOP_RIGHT_PANE]->w,
1924 mwindow->theme->mcanvas_h -
1926 pane[TOP_LEFT_PANE]->resize_event(
1927 pane[TOP_LEFT_PANE]->x,
1928 pane[TOP_LEFT_PANE]->y,
1929 cursor_x - mwindow->theme->pane_w,
1930 cursor_y - mwindow->theme->pane_h);
1931 pane[TOP_RIGHT_PANE]->resize_event(
1932 mwindow->theme->mcanvas_x +
1934 mwindow->theme->mcanvas_y,
1935 mwindow->theme->mcanvas_x +
1936 mwindow->theme->mcanvas_w -
1938 cursor_y - mwindow->theme->pane_h);
1939 pane[BOTTOM_LEFT_PANE]->create_objects();
1940 pane[BOTTOM_RIGHT_PANE]->create_objects();
1943 if(vertical_panes())
1945 // create horizontal panes
1946 //printf("MWindowGUI::load_panes %d\n", __LINE__);
1947 pane[TOP_RIGHT_PANE] = new TimelinePane(mwindow,
1949 mwindow->theme->mcanvas_x +
1951 mwindow->theme->mcanvas_y,
1952 mwindow->theme->mcanvas_x +
1953 mwindow->theme->mcanvas_w -
1955 cursor_y - mwindow->theme->pane_h);
1956 pane[BOTTOM_RIGHT_PANE] = new TimelinePane(mwindow,
1958 pane[TOP_RIGHT_PANE]->x,
1959 mwindow->theme->mcanvas_y +
1961 pane[TOP_RIGHT_PANE]->w,
1962 mwindow->theme->mcanvas_h -
1964 pane[TOP_LEFT_PANE]->resize_event(
1965 pane[TOP_LEFT_PANE]->x,
1966 pane[TOP_LEFT_PANE]->y,
1967 cursor_x - mwindow->theme->pane_w,
1968 cursor_y - mwindow->theme->pane_h);
1969 pane[BOTTOM_LEFT_PANE]->resize_event(
1970 pane[TOP_LEFT_PANE]->x,
1971 mwindow->theme->mcanvas_y +
1973 mwindow->theme->mcanvas_x +
1974 mwindow->theme->mcanvas_w -
1975 cursor_x - mwindow->theme->pane_w,
1976 mwindow->theme->mcanvas_h -
1978 pane[TOP_RIGHT_PANE]->create_objects();
1979 pane[BOTTOM_RIGHT_PANE]->create_objects();
1986 //printf("MWindowGUI::load_panes %d\n", __LINE__);
1987 pane[TOP_LEFT_PANE]->resize_event(
1988 pane[TOP_LEFT_PANE]->x,
1989 pane[TOP_LEFT_PANE]->y,
1990 cursor_x - mwindow->theme->pane_w,
1991 cursor_y - mwindow->theme->pane_h);
1992 pane[TOP_RIGHT_PANE]->resize_event(
1993 mwindow->theme->mcanvas_x +
1995 mwindow->theme->mcanvas_y,
1996 mwindow->theme->mcanvas_x +
1997 mwindow->theme->mcanvas_w -
1999 cursor_y - mwindow->theme->pane_h);
2000 pane[BOTTOM_LEFT_PANE]->resize_event(
2001 pane[TOP_LEFT_PANE]->x,
2002 mwindow->theme->mcanvas_y +
2004 mwindow->theme->mcanvas_x +
2005 mwindow->theme->mcanvas_w -
2006 cursor_x - mwindow->theme->pane_w,
2007 mwindow->theme->mcanvas_h -
2009 pane[BOTTOM_RIGHT_PANE]->resize_event(
2010 pane[TOP_RIGHT_PANE]->x,
2011 mwindow->theme->mcanvas_y +
2013 pane[TOP_RIGHT_PANE]->w,
2014 mwindow->theme->mcanvas_h -
2023 if(pane[BOTTOM_LEFT_PANE]) delete pane[BOTTOM_LEFT_PANE];
2024 if(pane[BOTTOM_RIGHT_PANE]) delete pane[BOTTOM_RIGHT_PANE];
2025 pane[BOTTOM_LEFT_PANE] = 0;
2026 pane[BOTTOM_RIGHT_PANE] = 0;
2028 if(!pane[TOP_RIGHT_PANE])
2030 pane[TOP_RIGHT_PANE] = new TimelinePane(mwindow,
2032 mwindow->theme->mcanvas_x +
2034 mwindow->theme->mcanvas_y,
2035 mwindow->theme->mcanvas_x +
2036 mwindow->theme->mcanvas_w -
2038 mwindow->theme->mcanvas_h);
2039 pane[TOP_LEFT_PANE]->resize_event(
2040 mwindow->theme->mcanvas_x,
2041 mwindow->theme->mcanvas_y,
2042 cursor_x - mwindow->theme->pane_w,
2043 mwindow->theme->mcanvas_h);
2044 pane[TOP_RIGHT_PANE]->create_objects();
2048 pane[TOP_LEFT_PANE]->resize_event(
2049 mwindow->theme->mcanvas_x,
2050 mwindow->theme->mcanvas_y,
2051 cursor_x - mwindow->theme->pane_w,
2052 mwindow->theme->mcanvas_h);
2053 pane[TOP_RIGHT_PANE]->resize_event(
2054 mwindow->theme->mcanvas_x +
2056 pane[TOP_RIGHT_PANE]->y,
2057 mwindow->theme->mcanvas_x +
2058 mwindow->theme->mcanvas_w -
2060 mwindow->theme->mcanvas_h);
2068 if(pane[TOP_RIGHT_PANE]) delete pane[TOP_RIGHT_PANE];
2069 if(pane[BOTTOM_RIGHT_PANE]) delete pane[BOTTOM_RIGHT_PANE];
2070 pane[TOP_RIGHT_PANE] = 0;
2071 pane[BOTTOM_RIGHT_PANE] = 0;
2073 if(!pane[BOTTOM_LEFT_PANE])
2075 //printf("MWindowGUI::load_panes %d\n", __LINE__);
2076 pane[BOTTOM_LEFT_PANE] = new TimelinePane(mwindow,
2078 mwindow->theme->mcanvas_x,
2079 mwindow->theme->mcanvas_y +
2081 mwindow->theme->mcanvas_w,
2082 mwindow->theme->mcanvas_h -
2084 pane[TOP_LEFT_PANE]->resize_event(
2085 mwindow->theme->mcanvas_x,
2086 mwindow->theme->mcanvas_y,
2087 mwindow->theme->mcanvas_w,
2088 pane[BOTTOM_LEFT_PANE]->y -
2089 mwindow->theme->mcanvas_y -
2090 mwindow->theme->pane_h);
2091 pane[BOTTOM_LEFT_PANE]->create_objects();
2095 pane[TOP_LEFT_PANE]->resize_event(
2096 mwindow->theme->mcanvas_x,
2097 mwindow->theme->mcanvas_y,
2098 mwindow->theme->mcanvas_w,
2099 cursor_y - mwindow->theme->pane_h);
2100 pane[BOTTOM_LEFT_PANE]->resize_event(
2101 pane[BOTTOM_LEFT_PANE]->x,
2103 mwindow->theme->mcanvas_y,
2104 mwindow->theme->mcanvas_w,
2105 mwindow->theme->mcanvas_h -
2112 if(pane[TOP_RIGHT_PANE]) delete pane[TOP_RIGHT_PANE];
2113 if(pane[BOTTOM_RIGHT_PANE]) delete pane[BOTTOM_RIGHT_PANE];
2114 if(pane[BOTTOM_LEFT_PANE]) delete pane[BOTTOM_LEFT_PANE];
2115 pane[TOP_RIGHT_PANE] = 0;
2116 pane[BOTTOM_RIGHT_PANE] = 0;
2117 pane[BOTTOM_LEFT_PANE] = 0;
2118 pane[TOP_LEFT_PANE]->resize_event(
2119 mwindow->theme->mcanvas_x,
2120 mwindow->theme->mcanvas_y,
2121 mwindow->theme->mcanvas_w,
2122 mwindow->theme->mcanvas_h);
2125 update_pane_dividers();
2128 resource_thread->start_draw();
2131 void MWindowGUI::update_pane_dividers()
2134 if(horizontal_panes() || total_panes() == 4)
2136 int x = pane[TOP_RIGHT_PANE]->x - mwindow->theme->pane_w;
2137 int y = mwindow->theme->mcanvas_y;
2138 int h = mwindow->theme->mcanvas_h;
2142 add_subwindow(x_divider = new PaneDivider(
2143 mwindow, x, y, h, 1));
2144 x_divider->create_objects();
2148 x_divider->reposition_window(x, y, h);
2161 if(vertical_panes() || total_panes() == 4)
2163 int x = mwindow->theme->mcanvas_x;
2164 int y = pane[BOTTOM_LEFT_PANE]->y -
2165 mwindow->theme->pane_h;
2166 int w = mwindow->theme->mcanvas_w;
2169 add_subwindow(y_divider = new PaneDivider(
2170 mwindow, x, y, w, 0));
2171 y_divider->create_objects();
2175 y_divider->reposition_window(x, y, w);
2189 void MWindowGUI::draw_samplemovement()
2196 update_scrollbars(1);
2199 void MWindowGUI::draw_trackmovement()
2201 update_scrollbars(0);
2208 void MWindowGUI::update_mixers(Track *track, int v)
2210 for( int i=0; i<TOTAL_PANES; ++i ) {
2211 if( !pane[i] ) continue;
2212 PatchBay *patchbay = pane[i]->patchbay;
2213 if( !patchbay ) continue;
2214 for( int j=0; j<patchbay->patches.total; ++j ) {
2215 PatchGUI *patchgui = patchbay->patches.values[j];
2216 if( !patchgui->mix ) continue;
2217 if( !track || patchgui->track == track ) {
2218 patchgui->mix->update(v>=0 ? v :
2219 mwindow->mixer_track_active(patchgui->track));
2225 void MWindowGUI::stop_transport(const char *lock_msg)
2227 if( !mbuttons->transport->is_stopped() ) {
2228 if( lock_msg ) unlock_window();
2229 mbuttons->transport->handle_transport(STOP, 1);
2230 if( lock_msg ) lock_window(lock_msg);
2234 PaneButton::PaneButton(MWindow *mwindow, int x, int y)
2235 : BC_Button(x, y, mwindow->theme->get_image_set("pane"))
2237 this->mwindow = mwindow;
2240 int PaneButton::cursor_motion_event()
2242 if(get_top_level()->get_button_down() &&
2244 get_status() == BUTTON_DOWNHI &&
2247 // printf("PaneButton::cursor_motion_event %d\n", __LINE__);
2249 if(get_cursor_x() < 0 && !mwindow->gui->dragging_pane)
2251 mwindow->gui->start_x_pane_drag();
2254 if(get_cursor_y() < 0 && !mwindow->gui->dragging_pane)
2256 mwindow->gui->start_y_pane_drag();
2260 mwindow->gui->handle_pane_drag();
2262 int result = BC_Button::cursor_motion_event();
2266 int PaneButton::button_release_event()
2268 if( get_buttonpress() != WHEEL_DOWN && get_buttonpress() != WHEEL_UP )
2269 mwindow->gui->stop_pane_drag();
2270 int result = BC_Button::button_release_event();
2275 FFMpegToggle::FFMpegToggle(MWindow *mwindow, MButtons *mbuttons, int x, int y)
2276 : BC_Toggle(x, y, mwindow->theme->ffmpeg_toggle,
2277 mwindow->preferences->get_file_probe_armed("FFMPEG_Early") > 0 ? 1 : 0)
2279 this->mwindow = mwindow;
2280 this->mbuttons = mbuttons;
2281 set_tooltip(get_value() ? FFMPEG_EARLY_TIP : FFMPEG_LATE_TIP);
2284 FFMpegToggle::~FFMpegToggle()
2288 int FFMpegToggle::handle_event()
2290 int ffmpeg_early_probe = get_value();
2291 set_tooltip(ffmpeg_early_probe ? FFMPEG_EARLY_TIP : FFMPEG_LATE_TIP);
2292 mwindow->preferences->set_file_probe_armed("FFMPEG_Early", ffmpeg_early_probe);
2293 mwindow->preferences->set_file_probe_armed("FFMPEG_Late", !ffmpeg_early_probe);
2294 mwindow->update_preferences(mwindow->preferences);
2295 mwindow->show_warning(&mwindow->preferences->warn_indexes,
2296 _("Changing the base codecs may require rebuilding indexes."));
2301 ProxyToggle::ProxyToggle(MWindow *mwindow, MButtons *mbuttons, int x, int y)
2302 : BC_Toggle(x, y, ( !mwindow->edl->session->proxy_use_scaler ?
2303 mwindow->theme->proxy_p_toggle :
2304 mwindow->theme->proxy_s_toggle ),
2305 mwindow->edl->session->proxy_disabled_scale != 1)
2307 this->mwindow = mwindow;
2308 this->mbuttons = mbuttons;
2309 scaler_images = mwindow->edl->session->proxy_use_scaler;
2310 set_tooltip(mwindow->edl->session->proxy_disabled_scale==1 ?
2311 _("Disable proxy") : _("Enable proxy"));
2314 void ProxyToggle::show()
2316 int use_scaler = mwindow->edl->session->proxy_use_scaler;
2317 if( scaler_images != use_scaler )
2318 set_images(!(scaler_images=use_scaler) ?
2319 mwindow->theme->proxy_p_toggle :
2320 mwindow->theme->proxy_s_toggle );
2326 void ProxyToggle::hide()
2332 ProxyToggle::~ProxyToggle()
2336 int ProxyToggle::handle_event()
2338 int disabled = get_value();
2339 mwindow->gui->unlock_window();
2341 mwindow->disable_proxy();
2343 mwindow->enable_proxy();
2344 mwindow->gui->lock_window("ProxyToggle::handle_event");
2345 set_tooltip(!disabled ? _("Disable proxy") : _("Enable proxy"));
2349 int ProxyToggle::keypress_event()
2351 if( ctrl_down() && !shift_down() && !alt_down() ) {
2352 int key = get_keypress();
2354 int value = get_value() ? 0 : 1;
2356 return handle_event();