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 "remotecontrol.h"
63 #include "resourcethread.h"
64 #include "samplescroll.h"
65 #include "shbtnprefs.h"
66 #include "statusbar.h"
69 #include "trackcanvas.h"
70 #include "trackpopup.h"
71 #include "trackscroll.h"
73 #include "transitionpopup.h"
74 #include "vwindowgui.h"
80 #define PANE_DRAG_MARGIN MAX(mwindow->theme->pane_w, mwindow->theme->pane_h)
83 // the main window uses its own private colormap for video
84 MWindowGUI::MWindowGUI(MWindow *mwindow)
85 : BC_Window(_(PROGRAM_NAME ": Program"),
86 mwindow->session->mwindow_x, mwindow->session->mwindow_y,
87 mwindow->session->mwindow_w, mwindow->session->mwindow_h,
88 xS(100), yS(100), 1, 1, 1)
90 this->mwindow = mwindow;
97 focused_pane = TOP_LEFT_PANE;
106 render_engine_id = -1;
107 for(int i = 0; i < TOTAL_PANES; i++)
127 cwindow_remote_handler = 0;
128 record_remote_handler = 0;
133 MWindowGUI::~MWindowGUI()
135 delete android_control;
136 delete cwindow_remote_handler;
137 delete record_remote_handler;
138 delete remote_control;
139 delete keyvalue_popup;
140 // delete samplescroll;
141 // delete trackscroll;
142 for(int i = 0; i < TOTAL_PANES; i++)
143 if(pane[i]) delete pane[i];
145 delete render_engine;
146 delete resource_thread;
147 resource_pixmaps.remove_all_objects();
157 void MWindowGUI::create_objects()
159 lock_window("MWindowGUI::create_objects");
162 resource_thread = new ResourceThread(mwindow, this);
163 resource_thread->create_objects();
166 if(debug) printf("MWindowGUI::create_objects %d\n", __LINE__);
167 set_icon(mwindow->theme->get_image("mwindow_icon"));
168 remote_control = new RemoteControl(this);
169 cwindow_remote_handler = 0;
170 record_remote_handler = 0;
172 // should be first, use if plugged
173 if( !cwindow_remote_handler && mwindow->x10tv ) {
174 cwindow_remote_handler = (RemoteHandler*)
175 new X10TVCWindowHandler(mwindow->x10tv, remote_control);
176 record_remote_handler = (RemoteHandler*)
177 new X10TVRecordHandler(mwindow->x10tv, remote_control);
181 if( !cwindow_remote_handler && mwindow->wintv ) {
182 cwindow_remote_handler = (RemoteHandler*)
183 new WinTVCWindowHandler(mwindow->wintv, remote_control);
184 record_remote_handler = (RemoteHandler*)
185 new WinTVRecordHandler(mwindow->wintv, remote_control);
188 mwindow->reset_android_remote();
189 if(debug) printf("MWindowGUI::create_objects %d\n", __LINE__);
191 int x1 = get_w() - MainShBtns::calculate_w(-1, 0, -1) - xS(5);
192 add_subwindow(mainshbtns = new MainShBtns(mwindow, x1, -1));
193 mainshbtns->load(mwindow->preferences);
194 int x2 = x1 - mwindow->theme->stack_button_w - xS(5);
195 add_subwindow(stack_button = new StackButton(mwindow, x2, yS(2)));
196 add_subwindow(mainmenu = new MainMenu(mwindow, this, x2));
197 mainmenu->create_objects();
198 mwindow->theme->get_mwindow_sizes(this, get_w(), get_h());
199 mwindow->theme->draw_mwindow_bg(this);
200 if(debug) printf("MWindowGUI::create_objects %d\n", __LINE__);
202 add_subwindow(mbuttons = new MButtons(mwindow, this));
203 mbuttons->create_objects();
204 int y1 = mbuttons->get_y()+yS(2);
205 add_subwindow(proxy_toggle = new ProxyToggle(mwindow, mbuttons, x2, y1));
206 add_subwindow(ffmpeg_toggle = new FFMpegToggle(mwindow, mbuttons, x1, y1));
208 pane[TOP_LEFT_PANE] = new TimelinePane(mwindow,
210 mwindow->theme->mcanvas_x,
211 mwindow->theme->mcanvas_y,
212 mwindow->theme->mcanvas_w,
213 mwindow->theme->mcanvas_h);
214 pane[TOP_LEFT_PANE]->create_objects();
216 if(debug) printf("MWindowGUI::create_objects %d\n", __LINE__);
217 add_subwindow(zoombar = new ZoomBar(mwindow, this));
218 zoombar->create_objects();
221 if(debug) printf("MWindowGUI::create_objects %d\n", __LINE__);
222 add_subwindow(statusbar = new StatusBar(mwindow, this));
223 statusbar->create_objects();
227 if(debug) printf("MWindowGUI::create_objects %d\n", __LINE__);
228 add_subwindow(mainclock = new MainClock(mwindow,
229 mwindow->theme->mclock_x, mwindow->theme->mclock_y,
230 mwindow->theme->mclock_w));
231 if(debug) printf("MWindowGUI::create_objects %d\n", __LINE__);
232 mainclock->update(0);
236 // if(debug) printf("MWindowGUI::create_objects %d\n", __LINE__);
237 // cursor = new MainCursor(mwindow, this);
238 // cursor->create_objects();
241 if(debug) printf("MWindowGUI::create_objects %d\n", __LINE__);
242 add_subwindow(track_menu = new TrackPopup(mwindow, this));
243 track_menu->create_objects();
244 if(debug) printf("MWindowGUI::create_objects %d\n", __LINE__);
245 add_subwindow(edit_menu = new EditPopup(mwindow, this));
246 edit_menu->create_objects();
249 if(debug) printf("MWindowGUI::create_objects %d\n", __LINE__);
250 add_subwindow(plugin_menu = new PluginPopup(mwindow, this));
251 plugin_menu->create_objects();
254 if(debug) printf("MWindowGUI::create_objects %d\n", __LINE__);
255 add_subwindow(keyframe_menu = new KeyframePopup(mwindow, this));
256 keyframe_menu->create_objects();
257 add_subwindow(keyframe_hide = new KeyframeHidePopup(mwindow, this));
258 keyframe_hide->create_objects();
261 if(debug) printf("MWindowGUI::create_objects %d\n", __LINE__);
262 add_subwindow(transition_menu = new TransitionPopup(mwindow, this));
263 transition_menu->create_objects();
266 channel_info = new ChannelInfo(mwindow);
268 #ifdef HAVE_COMMERCIAL
269 db_window = new DbWindow(mwindow);
271 swindow = new SWindow(mwindow);
273 if(debug) printf("MWindowGUI::create_objects %d\n", __LINE__);
275 add_subwindow(pane_button = new PaneButton(mwindow,
276 get_w() - mwindow->theme->get_image_set("pane")[0]->get_w(),
277 mwindow->theme->mzoom_y + 1 - mwindow->theme->get_image_set("pane")[0]->get_h()));
279 pane[TOP_LEFT_PANE]->canvas->activate();
281 if(debug) printf("MWindowGUI::create_objects %d\n", __LINE__);
285 void MWindowGUI::redraw_time_dependancies()
287 zoombar->redraw_time_dependancies();
288 for(int i = 0; i < TOTAL_PANES; i++)
289 if(pane[i] && pane[i]->timebar) pane[i]->timebar->update(0);
290 mainclock->update(mwindow->edl->local_session->get_selectionstart(1));
293 int MWindowGUI::focus_in_event()
295 for(int i = 0; i < TOTAL_PANES; i++)
296 if(pane[i]) pane[i]->cursor->focus_in_event();
300 int MWindowGUI::focus_out_event()
302 for(int i = 0; i < TOTAL_PANES; i++)
303 if(pane[i]) pane[i]->cursor->focus_out_event();
308 int MWindowGUI::resize_event(int w, int h)
310 //printf("MWindowGUI::resize_event %d\n", __LINE__);
311 mwindow->session->mwindow_w = w;
312 mwindow->session->mwindow_h = h;
313 int x1 = get_w() - MainShBtns::calculate_w(-1, 0, -1) - xS(5);
314 mainshbtns->reposition_window(x1, -1);
315 int x2 = x1 - mwindow->theme->stack_button_w - xS(5);
316 stack_button->reposition_window(x2, stack_button->get_y());
317 mainmenu->resize_event(x2, mainmenu->get_h());
318 mwindow->theme->get_mwindow_sizes(this, w, h);
319 mwindow->theme->draw_mwindow_bg(this);
320 mbuttons->resize_event();
321 int y1 = mbuttons->get_y()+yS(2);
322 proxy_toggle->reposition_window(x2, y1);
323 ffmpeg_toggle->reposition_window(x1, y1);
324 statusbar->resize_event();
325 zoombar->resize_event();
327 resource_thread->stop_draw(1);
329 if(total_panes() > 1)
331 if(horizontal_panes())
333 // printf("MWindowGUI::resize_event %d %d %d\n",
335 // pane[TOP_RIGHT_PANE]->x,
336 // mwindow->theme->mcanvas_w -
337 // BC_ScrollBar::get_span(SCROLL_VERT) -
338 // PANE_DRAG_MARGIN);
339 if(pane[TOP_RIGHT_PANE]->x >= mwindow->theme->mcanvas_w -
340 BC_ScrollBar::get_span(SCROLL_VERT) -
343 delete_x_pane(pane[TOP_RIGHT_PANE]->x);
344 mwindow->edl->local_session->x_pane = -1;
350 if(pane[BOTTOM_LEFT_PANE]->y >= mwindow->theme->mzoom_y -
351 BC_ScrollBar::get_span(SCROLL_HORIZ) -
354 delete_y_pane(pane[BOTTOM_LEFT_PANE]->y);
355 mwindow->edl->local_session->y_pane = -1;
360 if(pane[TOP_RIGHT_PANE]->x >= mwindow->theme->mcanvas_w -
361 BC_ScrollBar::get_span(SCROLL_VERT) -
364 delete_x_pane(pane[TOP_RIGHT_PANE]->x);
365 mwindow->edl->local_session->x_pane = -1;
368 if(pane[BOTTOM_LEFT_PANE]->y >= mwindow->theme->mzoom_y -
369 BC_ScrollBar::get_span(SCROLL_HORIZ) -
372 delete_y_pane(pane[BOTTOM_LEFT_PANE]->y);
373 mwindow->edl->local_session->y_pane = -1;
378 if(total_panes() == 1)
380 pane[TOP_LEFT_PANE]->resize_event(
381 mwindow->theme->mcanvas_x,
382 mwindow->theme->mcanvas_y,
383 mwindow->theme->mcanvas_w,
384 mwindow->theme->mcanvas_h);
387 if(horizontal_panes())
389 pane[TOP_LEFT_PANE]->resize_event(
390 pane[TOP_LEFT_PANE]->x,
391 pane[TOP_LEFT_PANE]->y,
392 pane[TOP_LEFT_PANE]->w,
393 mwindow->theme->mcanvas_h);
394 pane[TOP_RIGHT_PANE]->resize_event(
395 pane[TOP_RIGHT_PANE]->x,
396 pane[TOP_RIGHT_PANE]->y,
397 mwindow->theme->mcanvas_w - pane[TOP_RIGHT_PANE]->x,
398 mwindow->theme->mcanvas_h);
403 pane[TOP_LEFT_PANE]->resize_event(
404 pane[TOP_LEFT_PANE]->x,
405 pane[TOP_LEFT_PANE]->y,
406 mwindow->theme->mcanvas_w,
407 pane[TOP_LEFT_PANE]->h);
408 pane[BOTTOM_LEFT_PANE]->resize_event(
409 pane[BOTTOM_LEFT_PANE]->x,
410 pane[BOTTOM_LEFT_PANE]->y,
411 mwindow->theme->mcanvas_w,
412 mwindow->theme->mcanvas_y +
413 mwindow->theme->mcanvas_h -
414 pane[BOTTOM_LEFT_PANE]->y);
418 pane[TOP_LEFT_PANE]->resize_event(
419 pane[TOP_LEFT_PANE]->x,
420 pane[TOP_LEFT_PANE]->y,
421 pane[TOP_LEFT_PANE]->w,
422 pane[TOP_LEFT_PANE]->h);
423 pane[TOP_RIGHT_PANE]->resize_event(
424 pane[TOP_RIGHT_PANE]->x,
425 pane[TOP_RIGHT_PANE]->y,
426 mwindow->theme->mcanvas_w - pane[TOP_RIGHT_PANE]->x,
427 pane[TOP_RIGHT_PANE]->h);
428 pane[BOTTOM_LEFT_PANE]->resize_event(
429 pane[BOTTOM_LEFT_PANE]->x,
430 pane[BOTTOM_LEFT_PANE]->y,
431 pane[BOTTOM_LEFT_PANE]->w,
432 mwindow->theme->mcanvas_y +
433 mwindow->theme->mcanvas_h -
434 pane[BOTTOM_LEFT_PANE]->y);
435 pane[BOTTOM_RIGHT_PANE]->resize_event(
436 pane[BOTTOM_RIGHT_PANE]->x,
437 pane[BOTTOM_RIGHT_PANE]->y,
438 mwindow->theme->mcanvas_w -
439 pane[BOTTOM_RIGHT_PANE]->x,
440 mwindow->theme->mcanvas_y +
441 mwindow->theme->mcanvas_h -
442 pane[BOTTOM_RIGHT_PANE]->y);
445 update_pane_dividers();
446 pane_button->reposition_window(w - mwindow->theme->get_image_set("pane")[0]->get_w(),
447 mwindow->theme->mzoom_y + 1 - mwindow->theme->get_image_set("pane")[0]->get_h());
448 resource_thread->start_draw();
454 int MWindowGUI::total_panes()
457 for(int i = 0; i < TOTAL_PANES; i++)
462 int MWindowGUI::vertical_panes()
464 return total_panes() == 2 &&
465 pane[TOP_LEFT_PANE] &&
466 pane[BOTTOM_LEFT_PANE];
469 int MWindowGUI::horizontal_panes()
471 return total_panes() == 2 &&
472 pane[TOP_LEFT_PANE] &&
473 pane[TOP_RIGHT_PANE];
476 TimelinePane* MWindowGUI::get_focused_pane()
478 if(pane[focused_pane]) return pane[focused_pane];
479 for(int i = 0; i < TOTAL_PANES; i++)
481 if(pane[i]) return pane[i];
486 void MWindowGUI::activate_timeline()
488 if(pane[focused_pane])
490 pane[focused_pane]->activate();
494 for(int i = 0; i < TOTAL_PANES; i++)
505 void MWindowGUI::deactivate_timeline()
507 for(int i = 0; i < TOTAL_PANES; i++)
511 pane[i]->canvas->deactivate();
516 void MWindowGUI::update_title(char *path)
519 char filename[BCTEXTLEN], string[BCTEXTLEN];
520 fs.extract_name(filename, path);
521 sprintf(string, _(PROGRAM_NAME ": %s"), filename);
523 //printf("MWindowGUI::update_title %s\n", string);
527 void MWindowGUI::draw_overlays(int flash_it)
529 for(int i = 0; i < TOTAL_PANES; i++)
533 pane[i]->canvas->draw_overlays();
534 if(flash_it) pane[i]->canvas->flash();
539 void MWindowGUI::update_timebar(int flush_it)
541 for(int i = 0; i < TOTAL_PANES; i++)
543 if(pane[i] && pane[i]->timebar)
545 pane[i]->timebar->update(flush_it);
550 void MWindowGUI::update_timebar_highlights()
552 for(int i = 0; i < TOTAL_PANES; i++)
554 if(pane[i] && pane[i]->timebar)
556 pane[i]->timebar->update_highlights();
562 void MWindowGUI::update_patchbay()
564 for(int i = 0; i < TOTAL_PANES; i++)
566 if(pane[i] && pane[i]->patchbay)
568 pane[i]->patchbay->update();
573 void MWindowGUI::update_proxy_toggle()
575 int value = mwindow->edl->session->proxy_scale == 1 ? 1 : 0;
576 proxy_toggle->set_value(value);
577 if( mwindow->edl->session->proxy_scale == 1 &&
578 mwindow->edl->session->proxy_disabled_scale == 1 )
579 proxy_toggle->hide();
581 proxy_toggle->show();
584 void MWindowGUI::update_plugintoggles()
586 for(int i = 0; i < TOTAL_PANES; i++)
590 pane[i]->canvas->refresh_plugintoggles();
596 void MWindowGUI::draw_indexes(Indexable *indexable)
598 for(int i = 0; i < TOTAL_PANES; i++)
602 pane[i]->canvas->draw_indexes(indexable);
607 void MWindowGUI::draw_canvas(int redraw, int hide_cursor)
609 resource_thread->stop_draw(0);
611 int mode = redraw ? FORCE_REDRAW : NORMAL_DRAW;
612 for(int i = 0; i < TOTAL_PANES; i++) {
614 pane[i]->canvas->draw(mode, hide_cursor);
617 resource_thread->start_draw();
620 void MWindowGUI::flash_canvas(int flush)
622 for(int i = 0; i < TOTAL_PANES; i++)
626 pane[i]->canvas->flash(flush);
631 int MWindowGUI::show_window(int flush)
633 int ret = BC_WindowBase::show_window(flush);
634 stack_button->update();
635 update_proxy_toggle();
639 void MWindowGUI::draw_cursor(int do_plugintoggles)
641 for(int i = 0; i < TOTAL_PANES; i++)
645 pane[i]->cursor->draw(do_plugintoggles);
650 void MWindowGUI::show_cursor(int do_plugintoggles)
652 for(int i = 0; i < TOTAL_PANES; i++)
656 pane[i]->cursor->show(do_plugintoggles);
661 void MWindowGUI::hide_cursor(int do_plugintoggles)
663 for(int i = 0; i < TOTAL_PANES; i++)
667 pane[i]->cursor->hide(do_plugintoggles);
672 void MWindowGUI::update_cursor()
674 for(int i = 0; i < TOTAL_PANES; i++)
678 pane[i]->cursor->update();
683 void MWindowGUI::set_playing_back(int value)
685 for(int i = 0; i < TOTAL_PANES; i++)
689 pane[i]->cursor->playing_back = value;
694 void MWindowGUI::update_scrollbars(int flush)
696 for(int i = 0; i < TOTAL_PANES; i++)
700 pane[i]->update(1, NO_DRAW, 0, 0);
703 if(flush) this->flush();
706 void MWindowGUI::reset_meters()
708 for(int i = 0; i < TOTAL_PANES; i++)
710 if(pane[i] && pane[i]->patchbay)
712 pane[i]->patchbay->reset_meters();
717 void MWindowGUI::stop_meters()
719 for(int i = 0; i < TOTAL_PANES; i++)
721 if(pane[i] && pane[i]->patchbay)
723 pane[i]->patchbay->stop_meters();
728 void MWindowGUI::update_meters(ArrayList<double> *module_levels)
730 for(int i = 0; i < TOTAL_PANES; i++)
732 if(pane[i] && pane[i]->patchbay)
734 pane[i]->patchbay->update_meters(module_levels);
739 void MWindowGUI::set_editing_mode(int flush)
741 for(int i = 0; i < TOTAL_PANES; i++)
745 pane[i]->canvas->update_cursor(flush);
750 void MWindowGUI::set_meter_format(int mode, int min, int max)
752 for(int i = 0; i < TOTAL_PANES; i++)
754 if(pane[i] && pane[i]->patchbay)
756 pane[i]->patchbay->set_meter_format(mode, min, max);
761 void MWindowGUI::update(int scrollbars,
770 if(debug) PRINT_TRACE
774 mwindow->edl->tracks->update_y_pixels(mwindow->theme);
776 if( do_canvas != NO_DRAW && do_canvas != IGNORE_THREAD )
777 resource_thread->stop_draw(1);
779 for(int i = 0; i < TOTAL_PANES; i++)
781 if(pane[i]) pane[i]->update(scrollbars,
787 if( do_canvas != NO_DRAW && do_canvas != IGNORE_THREAD )
788 resource_thread->start_draw();
790 // if(scrollbars) this->get_scrollbars(0);
791 // if(timebar) this->timebar->update(0);
792 if(zoombar) this->zoombar->update();
793 // if(patchbay) this->patchbay->update();
794 if(clock) this->mainclock->update(
795 mwindow->edl->local_session->get_selectionstart(1));
796 if(debug) PRINT_TRACE
802 // this->canvas->draw(do_canvas);
803 // this->cursor->show();
804 // this->canvas->flash(0);
805 // Activate causes the menubar to deactivate. Don't want this for
807 // if(canvas != IGNORE_THREAD) this->canvas->activate();
809 if(debug) PRINT_TRACE
813 if(buttonbar) mbuttons->update();
814 if(debug) PRINT_TRACE
816 // Can't age if the cache called this to draw missing picons
817 // or the GUI is updating the status of the draw toggle.
818 if( do_canvas != FORCE_REDRAW && do_canvas != IGNORE_THREAD ) {
820 mwindow->age_caches();
821 lock_window("MWindowGUI::update");
825 if(debug) PRINT_TRACE
828 int MWindowGUI::visible(int64_t x1, int64_t x2, int64_t view_x1, int64_t view_x2)
830 return (x1 >= view_x1 && x1 < view_x2) ||
831 (x2 > view_x1 && x2 <= view_x2) ||
832 (x1 <= view_x1 && x2 >= view_x2);
836 void MWindowGUI::show_message(const char *message, int msg_color, int bar_color)
838 statusbar->show_message(message, msg_color, bar_color);
841 void MWindowGUI::update_default_message()
843 statusbar->update_default_message();
846 void MWindowGUI::reset_default_message()
848 statusbar->reset_default_message();
851 void MWindowGUI::default_message()
853 statusbar->default_message();
856 // Drag motion called from other window
857 int MWindowGUI::drag_motion()
859 if(get_hidden()) return 0;
861 Track *over_track = 0;
863 PluginSet *over_pluginset = 0;
864 Plugin *over_plugin = 0;
869 drag_popup->cursor_motion_event();
873 // there's no point in drawing highlights has until drag operation has been set
874 if (!mwindow->session->current_operation)
877 for(int i = 0; i < TOTAL_PANES; i++)
879 if(pane[i]) pane[i]->canvas->drag_motion(
886 if(mwindow->session->track_highlighted != over_track)
888 mwindow->session->track_highlighted = over_track;
892 if(mwindow->session->edit_highlighted != over_edit)
894 mwindow->session->edit_highlighted = over_edit;
898 if(mwindow->session->pluginset_highlighted != over_pluginset)
900 mwindow->session->pluginset_highlighted = over_pluginset;
904 if(mwindow->session->plugin_highlighted != over_plugin)
906 mwindow->session->plugin_highlighted = over_plugin;
910 if( mwindow->session->current_operation == DRAG_ASSET ||
911 mwindow->session->current_operation == DRAG_EDIT ||
912 mwindow->session->current_operation == DRAG_GROUP ||
913 mwindow->session->current_operation == DRAG_AEFFECT_COPY ||
914 mwindow->session->current_operation == DRAG_VEFFECT_COPY ) {
919 // printf("drag_motion %d %d over_track=%p over_edit=%p\n",
926 lock_window("MWindowGUI::drag_motion");
933 int MWindowGUI::drag_stop()
935 if(get_hidden()) return 0;
936 int result = 0, redraw = 0;
938 for(int i = 0; i < TOTAL_PANES; i++)
940 if(pane[i]) result |= pane[i]->canvas->drag_stop(
943 mwindow->edl->optimize();
945 // since we don't have subwindows we have to terminate any drag operation
948 if (mwindow->session->track_highlighted
949 || mwindow->session->edit_highlighted
950 || mwindow->session->plugin_highlighted
951 || mwindow->session->pluginset_highlighted)
953 mwindow->session->track_highlighted = 0;
954 mwindow->session->edit_highlighted = 0;
955 mwindow->session->plugin_highlighted = 0;
956 mwindow->session->pluginset_highlighted = 0;
957 mwindow->session->current_operation = NO_OPERATION;
961 //printf("MWindowGUI::drag_stop %d %d\n", redraw, mwindow->session->current_operation);
964 mwindow->edl->tracks->update_y_pixels(mwindow->theme);
965 update_scrollbars(0);
980 void MWindowGUI::default_positions()
982 //printf("MWindowGUI::default_positions 1\n");
983 VWindow *vwindow = mwindow->vwindows.size() > DEFAULT_VWINDOW ?
984 mwindow->vwindows.get(DEFAULT_VWINDOW) : 0;
985 if( vwindow && !vwindow->is_running() ) vwindow = 0;
986 if( vwindow ) vwindow->gui->lock_window("MWindowGUI::default_positions");
987 mwindow->cwindow->gui->lock_window("MWindowGUI::default_positions");
988 mwindow->awindow->gui->lock_window("MWindowGUI::default_positions");
990 // printf("MWindowGUI::default_positions 1 %d %d %d %d\n", mwindow->session->vwindow_x,
991 // mwindow->session->vwindow_y,
992 // mwindow->session->vwindow_w,
993 // mwindow->session->vwindow_h);
994 reposition_window(mwindow->session->mwindow_x,
995 mwindow->session->mwindow_y,
996 mwindow->session->mwindow_w,
997 mwindow->session->mwindow_h);
998 if( vwindow ) vwindow->gui->reposition_window(mwindow->session->vwindow_x,
999 mwindow->session->vwindow_y,
1000 mwindow->session->vwindow_w,
1001 mwindow->session->vwindow_h);
1002 mwindow->cwindow->gui->reposition_window(mwindow->session->cwindow_x,
1003 mwindow->session->cwindow_y,
1004 mwindow->session->cwindow_w,
1005 mwindow->session->cwindow_h);
1006 mwindow->awindow->gui->reposition_window(mwindow->session->awindow_x,
1007 mwindow->session->awindow_y,
1008 mwindow->session->awindow_w,
1009 mwindow->session->awindow_h);
1010 //printf("MWindowGUI::default_positions 1\n");
1012 resize_event(mwindow->session->mwindow_w,
1013 mwindow->session->mwindow_h);
1014 //printf("MWindowGUI::default_positions 1\n");
1015 if( vwindow ) vwindow->gui->resize_event(mwindow->session->vwindow_w,
1016 mwindow->session->vwindow_h);
1017 //printf("MWindowGUI::default_positions 1\n");
1018 mwindow->cwindow->gui->resize_event(mwindow->session->cwindow_w,
1019 mwindow->session->cwindow_h);
1020 //printf("MWindowGUI::default_positions 1\n");
1021 mwindow->awindow->gui->resize_event(mwindow->session->awindow_w,
1022 mwindow->session->awindow_h);
1024 //printf("MWindowGUI::default_positions 1\n");
1027 if( vwindow ) vwindow->gui->flush();
1028 mwindow->cwindow->gui->flush();
1029 mwindow->awindow->gui->flush();
1031 if( vwindow ) vwindow->gui->unlock_window();
1032 mwindow->cwindow->gui->unlock_window();
1033 mwindow->awindow->gui->unlock_window();
1034 //printf("MWindowGUI::default_positions 2\n");
1038 int MWindowGUI::repeat_event(int64_t duration)
1040 // if(duration == 100)
1041 // mwindow->sync_parameters(CHANGE_ALL);
1043 for(int i = 0; i < TOTAL_PANES; i++)
1045 if(pane[i]) result = pane[i]->cursor->repeat_event(duration);
1051 int MWindowGUI::translation_event()
1053 //printf("MWindowGUI::translation_event 1 %d %d\n", get_x(), get_y());
1054 mwindow->session->mwindow_x = get_x();
1055 mwindow->session->mwindow_y = get_y();
1060 int MWindowGUI::save_defaults(BC_Hash *defaults)
1062 defaults->update("MWINDOWWIDTH", get_w());
1063 defaults->update("MWINDOWHEIGHT", get_h());
1064 mainmenu->save_defaults(defaults);
1065 BC_WindowBase::save_defaults(defaults);
1069 int MWindowGUI::keypress_event()
1071 //printf("MWindowGUI::keypress_event 1 %d\n", get_keypress());
1072 int result = mbuttons->keypress_event();
1073 if( result ) return result;
1075 Track *this_track = 0, *first_track = 0;
1076 int collapse = 0, packed = 0, overwrite = 0, plugins = 0;
1077 double position = 0;
1079 switch( get_keypress() ) {
1081 if( !ctrl_down() || !shift_down() || alt_down() ) break;
1082 mwindow->edl->tracks->clear_selected_edits();
1087 mwindow->toggle_editing_mode();
1092 if( alt_down() ) break;
1093 stop_transport("MWindowGUI::keypress_event 1");
1094 mwindow->nearest_plugin_keyframe(shift_down(),
1095 !ctrl_down() ? PLAY_FORWARD : PLAY_REVERSE);
1102 if( !ctrl_down() || alt_down() ) break;
1103 mwindow->selected_edits_to_clipboard(packed);
1109 overwrite = -1; // fall thru
1111 if( !ctrl_down() || alt_down() ) break;
1112 if( mwindow->session->current_operation == DROP_TARGETING ) {
1113 mwindow->session->current_operation = NO_OPERATION;
1114 mwindow->gui->set_editing_mode(1);
1116 for( ; pane_no<TOTAL_PANES; ++pane_no ) {
1117 if( !pane[pane_no] ) continue;
1118 first_track = pane[pane_no]->over_track();
1119 if( first_track ) break;
1122 int cursor_x = pane[pane_no]->canvas->get_relative_cursor_x();
1123 position = mwindow->edl->get_cursor_position(cursor_x, pane_no);
1127 position = mwindow->edl->local_session->get_selectionstart();
1129 mwindow->paste(position, first_track, 0, overwrite);
1131 mwindow->paste_clipboard(first_track, position, 1, 0, 1, 1, 1);
1132 mwindow->edl->tracks->clear_selected_edits();
1140 mwindow->cut_selected_edits(0, collapse);
1146 if( !ctrl_down() || alt_down() ) break;
1147 mwindow->cut_selected_edits(1, collapse);
1152 if( !alt_down() || shift_down() ) break;
1153 if( !mwindow->select_asset(get_keypress()-'1',1) )
1158 if( !ctrl_down() ) {
1160 stop_transport("MWindowGUI::keypress_event 1");
1161 mwindow->prev_edit_handle(shift_down());
1164 mwindow->move_left();
1170 if( !ctrl_down() && !alt_down() ) {
1171 mwindow->move_left();
1177 if( !ctrl_down() ) {
1179 stop_transport("MWindowGUI::keypress_event 2");
1180 mwindow->next_edit_handle(shift_down());
1183 mwindow->move_right();
1189 if( !ctrl_down() && !alt_down() ) {
1190 mwindow->move_right();
1196 if( ctrl_down() && !alt_down() )
1197 mwindow->expand_y();
1198 else if( !ctrl_down() && alt_down() )
1199 mwindow->expand_autos(0,1,1);
1200 else if( ctrl_down() && alt_down() )
1201 mwindow->expand_autos(1,1,1);
1203 mwindow->expand_sample();
1208 if( ctrl_down() && !alt_down() )
1209 mwindow->zoom_in_y();
1210 else if( !ctrl_down() && alt_down() )
1211 mwindow->shrink_autos(0,1,1);
1212 else if( ctrl_down() && alt_down() )
1213 mwindow->shrink_autos(1,1,1);
1215 mwindow->zoom_in_sample();
1223 mwindow->expand_t();
1229 mwindow->move_down();
1231 mwindow->zoom_in_t();
1237 for( int i=0; i<TOTAL_PANES; ++i ) {
1238 if( !pane[i] ) continue;
1239 if( (this_track = pane[i]->over_track()) != 0 ) break;
1240 if( (this_track = pane[i]->over_patchbay()) != 0 ) break;
1243 if( get_keypress() == TAB ) { // Switch the record button
1245 this_track->record = !this_track->record ? 1 : 0;
1248 int total_selected = mwindow->edl->tracks->total_of(Tracks::RECORD);
1249 // all selected if nothing previously selected or
1250 // if this patch was previously the only one selected and armed
1251 int selected = !total_selected || (total_selected == 1 &&
1252 this_track && this_track->record ) ? 1 : 0;
1253 mwindow->edl->tracks->select_all(Tracks::RECORD, selected);
1254 if( !selected && this_track ) this_track->record = 1;
1257 update(0, NORMAL_DRAW, 0, 0, 1, 0, 1);
1259 mwindow->cwindow->update(0, 1, 1);
1260 lock_window("MWindowGUI::keypress_event 3");
1265 case KEY_F1 ... KEY_F12:
1266 resend_event(mwindow->cwindow->gui);
1270 // since things under cursor have changed...
1272 cursor_motion_event();
1277 int MWindowGUI::keyboard_listener(BC_WindowBase *wp)
1279 return key_listener(wp->get_keypress());
1282 int MWindowGUI::key_listener(int key)
1287 if( !record->running() )
1290 record->record_gui->interrupt_thread->start(0);
1297 channel_info->toggle_scan();
1301 if( !remote_control->deactivate() )
1302 remote_control->activate();
1312 void MWindowGUI::use_android_remote(int on)
1315 delete android_control;
1316 android_control = 0;
1319 if( android_control ) return;
1320 android_control = new AndroidControl(this);
1322 int MWindowGUI::keyev_grab_remote()
1324 if( cwindow_remote_handler && cwindow_remote_handler->is_keytv() &&
1325 record_remote_handler && record_remote_handler->is_keytv() )
1327 delete cwindow_remote_handler;
1328 delete record_remote_handler;
1329 cwindow_remote_handler = (RemoteHandler*)
1330 new CWindowKeyEvHandler(mwindow->gui->remote_control);
1331 record_remote_handler = (RemoteHandler*)
1332 new RecordKeyEvHandler(mwindow->gui->remote_control);
1336 int MWindowGUI::close_event()
1342 void MWindowGUI::stop_drawing()
1344 resource_thread->stop_draw(1);
1347 int MWindowGUI::menu_w()
1349 return mainmenu->get_w();
1352 int MWindowGUI::menu_h()
1354 return mainmenu->get_h();
1357 void MWindowGUI::start_x_pane_drag()
1361 x_pane_drag = new BC_Popup(this,
1362 get_abs_cursor_x(0) - mwindow->theme->pane_w,
1363 BC_DisplayInfo::get_top_border() +
1365 mwindow->theme->mcanvas_y,
1366 mwindow->theme->pane_w,
1367 mwindow->theme->mcanvas_h,
1368 mwindow->theme->drag_pane_color);
1369 x_pane_drag->draw_3segmentv(0,
1371 x_pane_drag->get_h(),
1372 mwindow->theme->get_image_set("xpane")[BUTTON_DOWNHI]);
1373 x_pane_drag->flash(1);
1378 void MWindowGUI::start_y_pane_drag()
1382 //printf("MWindowGUI::start_y_pane_drag %d %d %d\n", __LINE__, get_x(), get_y());
1383 y_pane_drag = new BC_Popup(this,
1384 BC_DisplayInfo::get_left_border() +
1386 mwindow->theme->mcanvas_x,
1387 get_abs_cursor_y(0) - mwindow->theme->pane_h,
1388 mwindow->theme->mcanvas_w,
1389 mwindow->theme->pane_h,
1390 mwindow->theme->drag_pane_color);
1391 y_pane_drag->draw_3segmenth(0,
1393 y_pane_drag->get_w(),
1394 mwindow->theme->get_image_set("ypane")[BUTTON_DOWNHI]);
1395 y_pane_drag->flash(1);
1400 void MWindowGUI::handle_pane_drag()
1406 x_pane_drag->reposition_window(
1407 get_abs_cursor_x(0) - mwindow->theme->pane_w,
1408 x_pane_drag->get_y());
1413 y_pane_drag->reposition_window(
1414 y_pane_drag->get_x(),
1415 get_abs_cursor_y(0) - mwindow->theme->pane_h);
1421 void MWindowGUI::create_x_pane(int cursor_x)
1423 if(total_panes() == 1)
1425 // create a horizontal pane
1426 // do this 1st so the resize_event knows there are 2 panes
1427 mwindow->edl->local_session->view_start[TOP_RIGHT_PANE] =
1428 mwindow->edl->local_session->view_start[TOP_LEFT_PANE] +
1430 mwindow->theme->patchbay_w;
1431 pane[TOP_RIGHT_PANE] = new TimelinePane(mwindow,
1433 mwindow->theme->mcanvas_x +
1435 mwindow->theme->mcanvas_y,
1436 mwindow->theme->mcanvas_x +
1437 mwindow->theme->mcanvas_w -
1439 mwindow->theme->mcanvas_h);
1440 pane[TOP_LEFT_PANE]->resize_event(
1441 mwindow->theme->mcanvas_x,
1442 mwindow->theme->mcanvas_y,
1443 cursor_x - mwindow->theme->pane_w,
1444 mwindow->theme->mcanvas_h);
1445 pane[TOP_RIGHT_PANE]->create_objects();
1448 if(vertical_panes())
1450 // create 2 horizontal panes
1451 mwindow->edl->local_session->track_start[TOP_RIGHT_PANE] =
1452 mwindow->edl->local_session->track_start[TOP_LEFT_PANE];
1453 mwindow->edl->local_session->track_start[BOTTOM_RIGHT_PANE] =
1454 mwindow->edl->local_session->track_start[BOTTOM_LEFT_PANE];
1455 mwindow->edl->local_session->view_start[TOP_RIGHT_PANE] =
1456 mwindow->edl->local_session->view_start[BOTTOM_RIGHT_PANE] =
1457 mwindow->edl->local_session->view_start[TOP_LEFT_PANE] +
1459 mwindow->theme->patchbay_w;
1460 pane[TOP_RIGHT_PANE] = new TimelinePane(mwindow,
1462 mwindow->theme->mcanvas_x +
1464 pane[TOP_LEFT_PANE]->y,
1465 mwindow->theme->mcanvas_x +
1466 mwindow->theme->mcanvas_w -
1468 pane[TOP_LEFT_PANE]->h);
1469 pane[BOTTOM_RIGHT_PANE] = new TimelinePane(mwindow,
1471 mwindow->theme->mcanvas_x +
1473 pane[BOTTOM_LEFT_PANE]->y,
1474 mwindow->theme->mcanvas_x +
1475 mwindow->theme->mcanvas_w -
1477 pane[BOTTOM_LEFT_PANE]->h);
1478 pane[TOP_LEFT_PANE]->resize_event(
1479 pane[TOP_LEFT_PANE]->x,
1480 pane[TOP_LEFT_PANE]->y,
1481 cursor_x - mwindow->theme->pane_w,
1482 pane[TOP_LEFT_PANE]->h);
1483 pane[BOTTOM_LEFT_PANE]->resize_event(
1484 pane[BOTTOM_LEFT_PANE]->x,
1485 pane[BOTTOM_LEFT_PANE]->y,
1486 cursor_x - mwindow->theme->pane_w,
1487 pane[BOTTOM_LEFT_PANE]->h);
1488 pane[TOP_RIGHT_PANE]->create_objects();
1489 pane[BOTTOM_RIGHT_PANE]->create_objects();
1492 if(horizontal_panes())
1494 // resize a horizontal pane
1495 mwindow->edl->local_session->view_start[TOP_RIGHT_PANE] +=
1497 pane[TOP_RIGHT_PANE]->x;
1498 if(mwindow->edl->local_session->view_start[TOP_RIGHT_PANE] < 0)
1499 mwindow->edl->local_session->view_start[TOP_RIGHT_PANE] = 0;
1500 pane[TOP_LEFT_PANE]->resize_event(
1501 mwindow->theme->mcanvas_x,
1502 mwindow->theme->mcanvas_y,
1503 cursor_x - mwindow->theme->pane_w,
1504 mwindow->theme->mcanvas_h);
1505 pane[TOP_RIGHT_PANE]->resize_event(
1506 mwindow->theme->mcanvas_x +
1508 pane[TOP_RIGHT_PANE]->y,
1509 mwindow->theme->mcanvas_x +
1510 mwindow->theme->mcanvas_w -
1512 mwindow->theme->mcanvas_h);
1516 // resize 2 horizontal panes
1517 mwindow->edl->local_session->view_start[TOP_RIGHT_PANE] +=
1519 pane[TOP_RIGHT_PANE]->x;
1520 if(mwindow->edl->local_session->view_start[TOP_RIGHT_PANE] < 0)
1521 mwindow->edl->local_session->view_start[TOP_RIGHT_PANE] = 0;
1522 mwindow->edl->local_session->view_start[BOTTOM_RIGHT_PANE] =
1523 mwindow->edl->local_session->view_start[TOP_RIGHT_PANE];
1525 pane[TOP_LEFT_PANE]->resize_event(
1526 mwindow->theme->mcanvas_x,
1527 pane[TOP_LEFT_PANE]->y,
1528 cursor_x - mwindow->theme->pane_w,
1529 pane[TOP_LEFT_PANE]->h);
1530 pane[TOP_RIGHT_PANE]->resize_event(
1531 mwindow->theme->mcanvas_x +
1533 pane[TOP_RIGHT_PANE]->y,
1534 mwindow->theme->mcanvas_x +
1535 mwindow->theme->mcanvas_w -
1537 pane[TOP_RIGHT_PANE]->h);
1538 pane[BOTTOM_LEFT_PANE]->resize_event(
1539 mwindow->theme->mcanvas_x,
1540 pane[BOTTOM_LEFT_PANE]->y,
1541 cursor_x - mwindow->theme->pane_w,
1542 pane[BOTTOM_LEFT_PANE]->h);
1543 pane[BOTTOM_RIGHT_PANE]->resize_event(
1544 mwindow->theme->mcanvas_x +
1546 pane[BOTTOM_RIGHT_PANE]->y,
1547 mwindow->theme->mcanvas_x +
1548 mwindow->theme->mcanvas_w -
1550 pane[BOTTOM_RIGHT_PANE]->h);
1556 void MWindowGUI::delete_x_pane(int cursor_x)
1558 // give left panes coordinates of right pane
1559 if(cursor_x < mwindow->theme->patchbay_w + PANE_DRAG_MARGIN &&
1560 pane[TOP_RIGHT_PANE])
1562 mwindow->edl->local_session->view_start[TOP_LEFT_PANE] =
1563 mwindow->edl->local_session->view_start[TOP_RIGHT_PANE] -
1564 pane[TOP_RIGHT_PANE]->x + mwindow->theme->patchbay_w;
1565 if(mwindow->edl->local_session->view_start[TOP_LEFT_PANE] < 0)
1566 mwindow->edl->local_session->view_start[TOP_LEFT_PANE] = 0;
1567 mwindow->edl->local_session->view_start[BOTTOM_LEFT_PANE] =
1568 mwindow->edl->local_session->view_start[TOP_LEFT_PANE];
1571 switch(total_panes())
1574 if(pane[TOP_LEFT_PANE] && pane[TOP_RIGHT_PANE])
1576 // delete right pane
1577 delete pane[TOP_RIGHT_PANE];
1578 pane[TOP_RIGHT_PANE] = 0;
1579 pane[TOP_LEFT_PANE]->resize_event(
1580 mwindow->theme->mcanvas_x,
1581 mwindow->theme->mcanvas_y,
1582 mwindow->theme->mcanvas_w,
1583 mwindow->theme->mcanvas_h);
1589 // delete right panes
1590 delete pane[TOP_RIGHT_PANE];
1591 pane[TOP_RIGHT_PANE] = 0;
1592 delete pane[BOTTOM_RIGHT_PANE];
1593 pane[BOTTOM_RIGHT_PANE] = 0;
1594 pane[TOP_LEFT_PANE]->resize_event(
1595 mwindow->theme->mcanvas_x,
1596 pane[TOP_LEFT_PANE]->y,
1597 mwindow->theme->mcanvas_w,
1598 pane[TOP_LEFT_PANE]->h);
1599 pane[BOTTOM_LEFT_PANE]->resize_event(
1600 mwindow->theme->mcanvas_x,
1601 pane[BOTTOM_LEFT_PANE]->y,
1602 mwindow->theme->mcanvas_w,
1603 pane[BOTTOM_LEFT_PANE]->h);
1608 void MWindowGUI::create_y_pane(int cursor_y)
1610 if(total_panes() == 1)
1612 mwindow->edl->local_session->view_start[BOTTOM_LEFT_PANE] =
1613 mwindow->edl->local_session->view_start[TOP_LEFT_PANE];
1614 mwindow->edl->local_session->track_start[BOTTOM_LEFT_PANE] =
1615 mwindow->edl->local_session->track_start[TOP_LEFT_PANE] +
1617 mwindow->theme->mtimebar_h;
1618 // do this 1st so the resize_event knows there are 2 panes
1619 pane[BOTTOM_LEFT_PANE] = new TimelinePane(mwindow,
1621 mwindow->theme->mcanvas_x,
1622 mwindow->theme->mcanvas_y +
1624 mwindow->theme->mcanvas_w,
1625 mwindow->theme->mcanvas_h -
1627 pane[TOP_LEFT_PANE]->resize_event(
1628 mwindow->theme->mcanvas_x,
1629 mwindow->theme->mcanvas_y,
1630 mwindow->theme->mcanvas_w,
1631 pane[BOTTOM_LEFT_PANE]->y -
1632 mwindow->theme->mcanvas_y -
1633 mwindow->theme->pane_h);
1634 pane[BOTTOM_LEFT_PANE]->create_objects();
1637 if(horizontal_panes())
1640 mwindow->edl->local_session->view_start[BOTTOM_LEFT_PANE] =
1641 mwindow->edl->local_session->view_start[TOP_LEFT_PANE];
1642 mwindow->edl->local_session->view_start[BOTTOM_RIGHT_PANE] =
1643 mwindow->edl->local_session->view_start[TOP_RIGHT_PANE];
1644 mwindow->edl->local_session->track_start[BOTTOM_LEFT_PANE] =
1645 mwindow->edl->local_session->track_start[BOTTOM_RIGHT_PANE] =
1646 mwindow->edl->local_session->track_start[TOP_LEFT_PANE] +
1648 mwindow->theme->mtimebar_h;
1650 pane[BOTTOM_LEFT_PANE] = new TimelinePane(mwindow,
1652 pane[TOP_LEFT_PANE]->x,
1653 mwindow->theme->mcanvas_y +
1655 pane[TOP_LEFT_PANE]->w,
1656 mwindow->theme->mcanvas_h -
1658 pane[BOTTOM_RIGHT_PANE] = new TimelinePane(mwindow,
1660 pane[TOP_RIGHT_PANE]->x,
1661 mwindow->theme->mcanvas_y +
1663 pane[TOP_RIGHT_PANE]->w,
1664 mwindow->theme->mcanvas_h -
1667 pane[TOP_LEFT_PANE]->resize_event(
1668 pane[TOP_LEFT_PANE]->x,
1669 pane[TOP_LEFT_PANE]->y,
1670 pane[TOP_LEFT_PANE]->w,
1671 pane[BOTTOM_LEFT_PANE]->y -
1672 mwindow->theme->mcanvas_y -
1673 mwindow->theme->pane_h);
1674 pane[TOP_RIGHT_PANE]->resize_event(
1675 pane[TOP_RIGHT_PANE]->x,
1676 pane[TOP_RIGHT_PANE]->y,
1677 pane[TOP_RIGHT_PANE]->w,
1678 pane[BOTTOM_RIGHT_PANE]->y -
1679 mwindow->theme->mcanvas_y -
1680 mwindow->theme->pane_h);
1682 pane[BOTTOM_LEFT_PANE]->create_objects();
1683 pane[BOTTOM_RIGHT_PANE]->create_objects();
1686 if(vertical_panes())
1689 mwindow->edl->local_session->track_start[BOTTOM_LEFT_PANE] +=
1691 (pane[BOTTOM_LEFT_PANE]->y - mwindow->theme->mcanvas_y);
1692 if(mwindow->edl->local_session->track_start[BOTTOM_LEFT_PANE] < 0)
1693 mwindow->edl->local_session->track_start[BOTTOM_LEFT_PANE] = 0;
1694 pane[TOP_LEFT_PANE]->resize_event(
1695 mwindow->theme->mcanvas_x,
1696 mwindow->theme->mcanvas_y,
1697 mwindow->theme->mcanvas_w,
1698 cursor_y - mwindow->theme->pane_h);
1699 pane[BOTTOM_LEFT_PANE]->resize_event(
1700 pane[BOTTOM_LEFT_PANE]->x,
1702 mwindow->theme->mcanvas_y,
1703 mwindow->theme->mcanvas_w,
1704 mwindow->theme->mcanvas_h -
1710 mwindow->edl->local_session->track_start[BOTTOM_LEFT_PANE] +=
1712 (pane[BOTTOM_LEFT_PANE]->y - mwindow->theme->mcanvas_y);
1713 if(mwindow->edl->local_session->track_start[BOTTOM_LEFT_PANE] < 0)
1714 mwindow->edl->local_session->track_start[BOTTOM_LEFT_PANE] = 0;
1715 mwindow->edl->local_session->track_start[BOTTOM_RIGHT_PANE] =
1716 mwindow->edl->local_session->track_start[BOTTOM_LEFT_PANE];
1717 pane[TOP_LEFT_PANE]->resize_event(
1718 pane[TOP_LEFT_PANE]->x,
1719 pane[TOP_LEFT_PANE]->y,
1720 pane[TOP_LEFT_PANE]->w,
1721 cursor_y - mwindow->theme->pane_h);
1722 pane[BOTTOM_LEFT_PANE]->resize_event(
1723 pane[BOTTOM_LEFT_PANE]->x,
1725 mwindow->theme->mcanvas_y,
1726 pane[BOTTOM_LEFT_PANE]->w,
1727 mwindow->theme->mcanvas_h -
1729 pane[TOP_RIGHT_PANE]->resize_event(
1730 pane[TOP_RIGHT_PANE]->x,
1731 pane[TOP_RIGHT_PANE]->y,
1732 pane[TOP_RIGHT_PANE]->w,
1733 cursor_y - mwindow->theme->pane_h);
1734 pane[BOTTOM_RIGHT_PANE]->resize_event(
1735 pane[BOTTOM_RIGHT_PANE]->x,
1737 mwindow->theme->mcanvas_y,
1738 pane[BOTTOM_RIGHT_PANE]->w,
1739 mwindow->theme->mcanvas_h -
1744 void MWindowGUI::delete_y_pane(int cursor_y)
1746 if(cursor_y < mwindow->theme->mtimebar_h +
1748 pane[BOTTOM_LEFT_PANE])
1750 // give top pane coordinates of bottom pane
1751 mwindow->edl->local_session->track_start[TOP_LEFT_PANE] =
1752 mwindow->edl->local_session->track_start[BOTTOM_LEFT_PANE] -
1753 pane[BOTTOM_LEFT_PANE]->y;
1754 if(mwindow->edl->local_session->track_start[TOP_LEFT_PANE] < 0)
1755 mwindow->edl->local_session->track_start[TOP_LEFT_PANE] = 0;
1756 mwindow->edl->local_session->track_start[TOP_RIGHT_PANE] =
1757 mwindow->edl->local_session->track_start[TOP_LEFT_PANE];
1761 switch(total_panes())
1764 delete pane[BOTTOM_LEFT_PANE];
1765 pane[BOTTOM_LEFT_PANE] = 0;
1766 pane[TOP_LEFT_PANE]->resize_event(
1767 mwindow->theme->mcanvas_x,
1768 mwindow->theme->mcanvas_y,
1769 mwindow->theme->mcanvas_w,
1770 mwindow->theme->mcanvas_h);
1774 // delete bottom 2 panes
1776 delete pane[BOTTOM_LEFT_PANE];
1777 pane[BOTTOM_LEFT_PANE] = 0;
1778 delete pane[BOTTOM_RIGHT_PANE];
1779 pane[BOTTOM_RIGHT_PANE] = 0;
1780 pane[TOP_LEFT_PANE]->resize_event(
1781 pane[TOP_LEFT_PANE]->x,
1782 mwindow->theme->mcanvas_y,
1783 pane[TOP_LEFT_PANE]->w,
1784 mwindow->theme->mcanvas_h);
1785 pane[TOP_RIGHT_PANE]->resize_event(
1786 pane[TOP_RIGHT_PANE]->x,
1787 mwindow->theme->mcanvas_y,
1788 pane[TOP_RIGHT_PANE]->w,
1789 mwindow->theme->mcanvas_h);
1794 void MWindowGUI::stop_pane_drag()
1797 resource_thread->stop_draw(0);
1801 // cursor position relative to canvas
1802 int cursor_x = x_pane_drag->get_x() -
1804 BC_DisplayInfo::get_left_border() -
1805 mwindow->theme->mcanvas_x +
1806 mwindow->theme->pane_w;
1811 if(cursor_x >= mwindow->theme->patchbay_w + PANE_DRAG_MARGIN &&
1812 cursor_x < mwindow->theme->mcanvas_w -
1813 BC_ScrollBar::get_span(SCROLL_VERT) -
1816 create_x_pane(cursor_x);
1817 mwindow->edl->local_session->x_pane = cursor_x;
1822 delete_x_pane(cursor_x);
1823 mwindow->edl->local_session->x_pane = -1;
1831 // cursor position relative to canvas
1832 int cursor_y = y_pane_drag->get_y() -
1834 BC_DisplayInfo::get_top_border() -
1835 mwindow->theme->mcanvas_y +
1836 mwindow->theme->pane_h;
1842 if(cursor_y >= mwindow->theme->mtimebar_h +
1844 cursor_y < mwindow->theme->mcanvas_h -
1845 BC_ScrollBar::get_span(SCROLL_HORIZ) -
1848 create_y_pane(cursor_y);
1849 mwindow->edl->local_session->y_pane = cursor_y;
1853 delete_y_pane(cursor_y);
1854 mwindow->edl->local_session->y_pane = -1;
1858 update_pane_dividers();
1860 // required to get new widgets to appear
1862 resource_thread->start_draw();
1865 // create panes from EDL
1866 void MWindowGUI::load_panes()
1868 int need_x_panes = 0;
1869 int need_y_panes = 0;
1870 // use names from create functions
1871 int cursor_x = mwindow->edl->local_session->x_pane;
1872 int cursor_y = mwindow->edl->local_session->y_pane;
1874 resource_thread->stop_draw(1);
1876 mwindow->theme->patchbay_w + PANE_DRAG_MARGIN &&
1878 mwindow->theme->mcanvas_w -
1879 BC_ScrollBar::get_span(SCROLL_VERT) -
1886 mwindow->theme->mtimebar_h + PANE_DRAG_MARGIN &&
1888 mwindow->theme->mcanvas_h -
1889 BC_ScrollBar::get_span(SCROLL_HORIZ) -
1895 //printf("MWindowGUI::load_panes %d %d %d\n", __LINE__, need_x_panes, need_y_panes);
1903 if(total_panes() == 1)
1906 //printf("MWindowGUI::load_panes %d\n", __LINE__);
1907 pane[TOP_RIGHT_PANE] = new TimelinePane(mwindow,
1909 mwindow->theme->mcanvas_x +
1911 mwindow->theme->mcanvas_y,
1912 mwindow->theme->mcanvas_x +
1913 mwindow->theme->mcanvas_w -
1915 cursor_y - mwindow->theme->pane_h);
1916 pane[BOTTOM_LEFT_PANE] = new TimelinePane(mwindow,
1918 mwindow->theme->mcanvas_x,
1919 mwindow->theme->mcanvas_y +
1921 cursor_x - mwindow->theme->pane_w,
1922 mwindow->theme->mcanvas_h -
1924 pane[BOTTOM_RIGHT_PANE] = new TimelinePane(mwindow,
1926 pane[TOP_RIGHT_PANE]->x,
1927 mwindow->theme->mcanvas_y +
1929 pane[TOP_RIGHT_PANE]->w,
1930 mwindow->theme->mcanvas_h -
1932 pane[TOP_LEFT_PANE]->resize_event(
1933 pane[TOP_LEFT_PANE]->x,
1934 pane[TOP_LEFT_PANE]->y,
1935 cursor_x - mwindow->theme->pane_w,
1936 cursor_y - mwindow->theme->pane_h);
1937 pane[TOP_RIGHT_PANE]->create_objects();
1938 pane[BOTTOM_LEFT_PANE]->create_objects();
1939 pane[BOTTOM_RIGHT_PANE]->create_objects();
1942 if(horizontal_panes())
1944 // create vertical panes
1945 //printf("MWindowGUI::load_panes %d\n", __LINE__);
1946 pane[BOTTOM_LEFT_PANE] = new TimelinePane(mwindow,
1948 mwindow->theme->mcanvas_x,
1949 mwindow->theme->mcanvas_y +
1951 cursor_x - mwindow->theme->pane_w,
1952 mwindow->theme->mcanvas_h -
1954 pane[BOTTOM_RIGHT_PANE] = new TimelinePane(mwindow,
1956 pane[TOP_RIGHT_PANE]->x,
1957 mwindow->theme->mcanvas_y +
1959 pane[TOP_RIGHT_PANE]->w,
1960 mwindow->theme->mcanvas_h -
1962 pane[TOP_LEFT_PANE]->resize_event(
1963 pane[TOP_LEFT_PANE]->x,
1964 pane[TOP_LEFT_PANE]->y,
1965 cursor_x - mwindow->theme->pane_w,
1966 cursor_y - mwindow->theme->pane_h);
1967 pane[TOP_RIGHT_PANE]->resize_event(
1968 mwindow->theme->mcanvas_x +
1970 mwindow->theme->mcanvas_y,
1971 mwindow->theme->mcanvas_x +
1972 mwindow->theme->mcanvas_w -
1974 cursor_y - mwindow->theme->pane_h);
1975 pane[BOTTOM_LEFT_PANE]->create_objects();
1976 pane[BOTTOM_RIGHT_PANE]->create_objects();
1979 if(vertical_panes())
1981 // create horizontal panes
1982 //printf("MWindowGUI::load_panes %d\n", __LINE__);
1983 pane[TOP_RIGHT_PANE] = new TimelinePane(mwindow,
1985 mwindow->theme->mcanvas_x +
1987 mwindow->theme->mcanvas_y,
1988 mwindow->theme->mcanvas_x +
1989 mwindow->theme->mcanvas_w -
1991 cursor_y - mwindow->theme->pane_h);
1992 pane[BOTTOM_RIGHT_PANE] = new TimelinePane(mwindow,
1994 pane[TOP_RIGHT_PANE]->x,
1995 mwindow->theme->mcanvas_y +
1997 pane[TOP_RIGHT_PANE]->w,
1998 mwindow->theme->mcanvas_h -
2000 pane[TOP_LEFT_PANE]->resize_event(
2001 pane[TOP_LEFT_PANE]->x,
2002 pane[TOP_LEFT_PANE]->y,
2003 cursor_x - mwindow->theme->pane_w,
2004 cursor_y - mwindow->theme->pane_h);
2005 pane[BOTTOM_LEFT_PANE]->resize_event(
2006 pane[TOP_LEFT_PANE]->x,
2007 mwindow->theme->mcanvas_y +
2009 mwindow->theme->mcanvas_x +
2010 mwindow->theme->mcanvas_w -
2011 cursor_x - mwindow->theme->pane_w,
2012 mwindow->theme->mcanvas_h -
2014 pane[TOP_RIGHT_PANE]->create_objects();
2015 pane[BOTTOM_RIGHT_PANE]->create_objects();
2022 //printf("MWindowGUI::load_panes %d\n", __LINE__);
2023 pane[TOP_LEFT_PANE]->resize_event(
2024 pane[TOP_LEFT_PANE]->x,
2025 pane[TOP_LEFT_PANE]->y,
2026 cursor_x - mwindow->theme->pane_w,
2027 cursor_y - mwindow->theme->pane_h);
2028 pane[TOP_RIGHT_PANE]->resize_event(
2029 mwindow->theme->mcanvas_x +
2031 mwindow->theme->mcanvas_y,
2032 mwindow->theme->mcanvas_x +
2033 mwindow->theme->mcanvas_w -
2035 cursor_y - mwindow->theme->pane_h);
2036 pane[BOTTOM_LEFT_PANE]->resize_event(
2037 pane[TOP_LEFT_PANE]->x,
2038 mwindow->theme->mcanvas_y +
2040 mwindow->theme->mcanvas_x +
2041 mwindow->theme->mcanvas_w -
2042 cursor_x - mwindow->theme->pane_w,
2043 mwindow->theme->mcanvas_h -
2045 pane[BOTTOM_RIGHT_PANE]->resize_event(
2046 pane[TOP_RIGHT_PANE]->x,
2047 mwindow->theme->mcanvas_y +
2049 pane[TOP_RIGHT_PANE]->w,
2050 mwindow->theme->mcanvas_h -
2059 if(pane[BOTTOM_LEFT_PANE]) delete pane[BOTTOM_LEFT_PANE];
2060 if(pane[BOTTOM_RIGHT_PANE]) delete pane[BOTTOM_RIGHT_PANE];
2061 pane[BOTTOM_LEFT_PANE] = 0;
2062 pane[BOTTOM_RIGHT_PANE] = 0;
2064 if(!pane[TOP_RIGHT_PANE])
2066 pane[TOP_RIGHT_PANE] = new TimelinePane(mwindow,
2068 mwindow->theme->mcanvas_x +
2070 mwindow->theme->mcanvas_y,
2071 mwindow->theme->mcanvas_x +
2072 mwindow->theme->mcanvas_w -
2074 mwindow->theme->mcanvas_h);
2075 pane[TOP_LEFT_PANE]->resize_event(
2076 mwindow->theme->mcanvas_x,
2077 mwindow->theme->mcanvas_y,
2078 cursor_x - mwindow->theme->pane_w,
2079 mwindow->theme->mcanvas_h);
2080 pane[TOP_RIGHT_PANE]->create_objects();
2084 pane[TOP_LEFT_PANE]->resize_event(
2085 mwindow->theme->mcanvas_x,
2086 mwindow->theme->mcanvas_y,
2087 cursor_x - mwindow->theme->pane_w,
2088 mwindow->theme->mcanvas_h);
2089 pane[TOP_RIGHT_PANE]->resize_event(
2090 mwindow->theme->mcanvas_x +
2092 pane[TOP_RIGHT_PANE]->y,
2093 mwindow->theme->mcanvas_x +
2094 mwindow->theme->mcanvas_w -
2096 mwindow->theme->mcanvas_h);
2104 if(pane[TOP_RIGHT_PANE]) delete pane[TOP_RIGHT_PANE];
2105 if(pane[BOTTOM_RIGHT_PANE]) delete pane[BOTTOM_RIGHT_PANE];
2106 pane[TOP_RIGHT_PANE] = 0;
2107 pane[BOTTOM_RIGHT_PANE] = 0;
2109 if(!pane[BOTTOM_LEFT_PANE])
2111 //printf("MWindowGUI::load_panes %d\n", __LINE__);
2112 pane[BOTTOM_LEFT_PANE] = new TimelinePane(mwindow,
2114 mwindow->theme->mcanvas_x,
2115 mwindow->theme->mcanvas_y +
2117 mwindow->theme->mcanvas_w,
2118 mwindow->theme->mcanvas_h -
2120 pane[TOP_LEFT_PANE]->resize_event(
2121 mwindow->theme->mcanvas_x,
2122 mwindow->theme->mcanvas_y,
2123 mwindow->theme->mcanvas_w,
2124 pane[BOTTOM_LEFT_PANE]->y -
2125 mwindow->theme->mcanvas_y -
2126 mwindow->theme->pane_h);
2127 pane[BOTTOM_LEFT_PANE]->create_objects();
2131 pane[TOP_LEFT_PANE]->resize_event(
2132 mwindow->theme->mcanvas_x,
2133 mwindow->theme->mcanvas_y,
2134 mwindow->theme->mcanvas_w,
2135 cursor_y - mwindow->theme->pane_h);
2136 pane[BOTTOM_LEFT_PANE]->resize_event(
2137 pane[BOTTOM_LEFT_PANE]->x,
2139 mwindow->theme->mcanvas_y,
2140 mwindow->theme->mcanvas_w,
2141 mwindow->theme->mcanvas_h -
2148 if(pane[TOP_RIGHT_PANE]) delete pane[TOP_RIGHT_PANE];
2149 if(pane[BOTTOM_RIGHT_PANE]) delete pane[BOTTOM_RIGHT_PANE];
2150 if(pane[BOTTOM_LEFT_PANE]) delete pane[BOTTOM_LEFT_PANE];
2151 pane[TOP_RIGHT_PANE] = 0;
2152 pane[BOTTOM_RIGHT_PANE] = 0;
2153 pane[BOTTOM_LEFT_PANE] = 0;
2154 pane[TOP_LEFT_PANE]->resize_event(
2155 mwindow->theme->mcanvas_x,
2156 mwindow->theme->mcanvas_y,
2157 mwindow->theme->mcanvas_w,
2158 mwindow->theme->mcanvas_h);
2161 update_pane_dividers();
2164 resource_thread->start_draw();
2167 void MWindowGUI::update_pane_dividers()
2170 if(horizontal_panes() || total_panes() == 4)
2172 int x = pane[TOP_RIGHT_PANE]->x - mwindow->theme->pane_w;
2173 int y = mwindow->theme->mcanvas_y;
2174 int h = mwindow->theme->mcanvas_h;
2178 add_subwindow(x_divider = new PaneDivider(
2179 mwindow, x, y, h, 1));
2180 x_divider->create_objects();
2184 x_divider->reposition_window(x, y, h);
2197 if(vertical_panes() || total_panes() == 4)
2199 int x = mwindow->theme->mcanvas_x;
2200 int y = pane[BOTTOM_LEFT_PANE]->y -
2201 mwindow->theme->pane_h;
2202 int w = mwindow->theme->mcanvas_w;
2205 add_subwindow(y_divider = new PaneDivider(
2206 mwindow, x, y, w, 0));
2207 y_divider->create_objects();
2211 y_divider->reposition_window(x, y, w);
2225 void MWindowGUI::draw_samplemovement()
2232 update_scrollbars(1);
2235 void MWindowGUI::draw_trackmovement()
2237 update_scrollbars(0);
2244 void MWindowGUI::update_mixers(Track *track, int v)
2246 for( int i=0; i<TOTAL_PANES; ++i ) {
2247 if( !pane[i] ) continue;
2248 PatchBay *patchbay = pane[i]->patchbay;
2249 if( !patchbay ) continue;
2250 for( int j=0; j<patchbay->patches.total; ++j ) {
2251 PatchGUI *patchgui = patchbay->patches.values[j];
2252 if( !patchgui->mix ) continue;
2253 if( !track || patchgui->track == track ) {
2254 patchgui->mix->update(v>=0 ? v :
2255 mwindow->mixer_track_active(patchgui->track));
2261 void MWindowGUI::stop_transport(const char *lock_msg)
2263 if( !mbuttons->transport->is_stopped() ) {
2264 if( lock_msg ) unlock_window();
2265 mbuttons->transport->handle_transport(STOP, 1);
2266 if( lock_msg ) lock_window(lock_msg);
2270 PaneButton::PaneButton(MWindow *mwindow, int x, int y)
2271 : BC_Button(x, y, mwindow->theme->get_image_set("pane"))
2273 this->mwindow = mwindow;
2276 int PaneButton::cursor_motion_event()
2278 if(get_top_level()->get_button_down() &&
2280 get_status() == BUTTON_DOWNHI &&
2283 // printf("PaneButton::cursor_motion_event %d\n", __LINE__);
2285 if(get_cursor_x() < 0 && !mwindow->gui->dragging_pane)
2287 mwindow->gui->start_x_pane_drag();
2290 if(get_cursor_y() < 0 && !mwindow->gui->dragging_pane)
2292 mwindow->gui->start_y_pane_drag();
2296 mwindow->gui->handle_pane_drag();
2298 int result = BC_Button::cursor_motion_event();
2302 int PaneButton::button_release_event()
2304 if( get_buttonpress() != WHEEL_DOWN && get_buttonpress() != WHEEL_UP )
2305 mwindow->gui->stop_pane_drag();
2306 int result = BC_Button::button_release_event();
2311 FFMpegToggle::FFMpegToggle(MWindow *mwindow, MButtons *mbuttons, int x, int y)
2312 : BC_Toggle(x, y, mwindow->theme->ffmpeg_toggle,
2313 mwindow->preferences->get_file_probe_armed("FFMPEG_Early") > 0 ? 1 : 0)
2315 this->mwindow = mwindow;
2316 this->mbuttons = mbuttons;
2317 set_tooltip(get_value() ? FFMPEG_EARLY_TIP : FFMPEG_LATE_TIP);
2320 FFMpegToggle::~FFMpegToggle()
2324 int FFMpegToggle::handle_event()
2326 int ffmpeg_early_probe = get_value();
2327 set_tooltip(ffmpeg_early_probe ? FFMPEG_EARLY_TIP : FFMPEG_LATE_TIP);
2328 mwindow->preferences->set_file_probe_armed("FFMPEG_Early", ffmpeg_early_probe);
2329 mwindow->preferences->set_file_probe_armed("FFMPEG_Late", !ffmpeg_early_probe);
2330 mwindow->update_preferences(mwindow->preferences);
2331 mwindow->show_warning(&mwindow->preferences->warn_indexes,
2332 _("Changing the base codecs may require rebuilding indexes."));
2337 StackButton::StackButton(MWindow *mwindow, int x, int y)
2338 : BC_GenericButton(x, y, mwindow->theme->stack_button_w, "0")
2340 this->mwindow = mwindow;
2341 set_tooltip(_("Close EDL"));
2344 int StackButton::handle_event()
2346 mwindow->save_backup();
2347 mwindow->stack_pop();
2351 void StackButton::update()
2353 char text[BCSTRLEN];
2354 int i = mwindow->stack.size();
2355 sprintf(text, "%d", i);
2361 ProxyToggle::ProxyToggle(MWindow *mwindow, MButtons *mbuttons, int x, int y)
2362 : BC_Toggle(x, y, ( !mwindow->edl->session->proxy_use_scaler ?
2363 mwindow->theme->proxy_p_toggle :
2364 mwindow->theme->proxy_s_toggle ),
2365 mwindow->edl->session->proxy_disabled_scale != 1)
2367 this->mwindow = mwindow;
2368 this->mbuttons = mbuttons;
2369 scaler_images = mwindow->edl->session->proxy_use_scaler;
2370 set_tooltip(mwindow->edl->session->proxy_disabled_scale==1 ?
2371 _("Disable proxy") : _("Enable proxy"));
2374 void ProxyToggle::show()
2376 int use_scaler = mwindow->edl->session->proxy_use_scaler;
2377 if( scaler_images != use_scaler )
2378 set_images(!(scaler_images=use_scaler) ?
2379 mwindow->theme->proxy_p_toggle :
2380 mwindow->theme->proxy_s_toggle );
2386 void ProxyToggle::hide()
2392 ProxyToggle::~ProxyToggle()
2396 int ProxyToggle::handle_event()
2398 int disabled = get_value();
2399 mwindow->gui->unlock_window();
2401 mwindow->disable_proxy();
2403 mwindow->enable_proxy();
2404 mwindow->gui->lock_window("ProxyToggle::handle_event");
2405 set_tooltip(!disabled ? _("Disable proxy") : _("Enable proxy"));
2409 int ProxyToggle::keypress_event()
2411 if( ctrl_down() && !shift_down() && !alt_down() ) {
2412 int key = get_keypress();
2414 int value = get_value() ? 0 : 1;
2416 return handle_event();