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"
79 #define PANE_DRAG_MARGIN MAX(mwindow->theme->pane_w, mwindow->theme->pane_h)
82 // the main window uses its own private colormap for video
83 MWindowGUI::MWindowGUI(MWindow *mwindow)
84 : BC_Window(_(PROGRAM_NAME ": Program"),
85 mwindow->session->mwindow_x, mwindow->session->mwindow_y,
86 mwindow->session->mwindow_w, mwindow->session->mwindow_h,
87 xS(100), yS(100), 1, 1, 1)
89 this->mwindow = mwindow;
96 focused_pane = TOP_LEFT_PANE;
105 render_engine_id = -1;
106 for(int i = 0; i < TOTAL_PANES; i++)
126 cwindow_remote_handler = 0;
127 record_remote_handler = 0;
132 MWindowGUI::~MWindowGUI()
134 delete android_control;
135 delete cwindow_remote_handler;
136 delete record_remote_handler;
137 delete remote_control;
138 delete keyvalue_popup;
139 // delete samplescroll;
140 // delete trackscroll;
141 for(int i = 0; i < TOTAL_PANES; i++)
142 if(pane[i]) delete pane[i];
144 delete render_engine;
145 delete resource_thread;
146 resource_pixmaps.remove_all_objects();
156 void MWindowGUI::create_objects()
158 lock_window("MWindowGUI::create_objects");
161 resource_thread = new ResourceThread(mwindow, this);
162 resource_thread->create_objects();
165 if(debug) printf("MWindowGUI::create_objects %d\n", __LINE__);
166 set_icon(mwindow->theme->get_image("mwindow_icon"));
167 remote_control = new RemoteControl(this);
169 WinTV *wintv = mwindow->wintv;
171 cwindow_remote_handler = (RemoteHandler*)
172 new WinTVCWindowHandler(wintv, remote_control);
173 record_remote_handler = (RemoteHandler*)
174 new WinTVRecordHandler(wintv, remote_control);
177 if( !cwindow_remote_handler ) cwindow_remote_handler =
178 (RemoteHandler*)new CWindowRemoteHandler(remote_control);
179 if( !record_remote_handler ) record_remote_handler =
180 (RemoteHandler*)new RecordRemoteHandler(remote_control);
181 mwindow->reset_android_remote();
183 if(debug) printf("MWindowGUI::create_objects %d\n", __LINE__);
185 int x1 = get_w() - MainShBtns::calculate_w(-1, 0, -1) - xS(5);
186 add_subwindow(mainshbtns = new MainShBtns(mwindow, x1, -1));
187 mainshbtns->load(mwindow->preferences);
188 int x2 = x1 - mwindow->theme->stack_button_w - xS(5);
189 add_subwindow(stack_button = new StackButton(mwindow, x2, yS(2)));
190 add_subwindow(mainmenu = new MainMenu(mwindow, this, x2));
191 mainmenu->create_objects();
192 mwindow->theme->get_mwindow_sizes(this, get_w(), get_h());
193 mwindow->theme->draw_mwindow_bg(this);
194 if(debug) printf("MWindowGUI::create_objects %d\n", __LINE__);
196 add_subwindow(mbuttons = new MButtons(mwindow, this));
197 mbuttons->create_objects();
198 int y1 = mbuttons->get_y()+yS(2);
199 add_subwindow(proxy_toggle = new ProxyToggle(mwindow, mbuttons, x2, y1));
200 add_subwindow(ffmpeg_toggle = new FFMpegToggle(mwindow, mbuttons, x1, y1));
202 pane[TOP_LEFT_PANE] = new TimelinePane(mwindow,
204 mwindow->theme->mcanvas_x,
205 mwindow->theme->mcanvas_y,
206 mwindow->theme->mcanvas_w,
207 mwindow->theme->mcanvas_h);
208 pane[TOP_LEFT_PANE]->create_objects();
210 if(debug) printf("MWindowGUI::create_objects %d\n", __LINE__);
211 add_subwindow(zoombar = new ZoomBar(mwindow, this));
212 zoombar->create_objects();
215 if(debug) printf("MWindowGUI::create_objects %d\n", __LINE__);
216 add_subwindow(statusbar = new StatusBar(mwindow, this));
217 statusbar->create_objects();
221 if(debug) printf("MWindowGUI::create_objects %d\n", __LINE__);
222 add_subwindow(mainclock = new MainClock(mwindow,
223 mwindow->theme->mclock_x, mwindow->theme->mclock_y,
224 mwindow->theme->mclock_w));
225 if(debug) printf("MWindowGUI::create_objects %d\n", __LINE__);
226 mainclock->update(0);
230 // if(debug) printf("MWindowGUI::create_objects %d\n", __LINE__);
231 // cursor = new MainCursor(mwindow, this);
232 // cursor->create_objects();
235 if(debug) printf("MWindowGUI::create_objects %d\n", __LINE__);
236 add_subwindow(track_menu = new TrackPopup(mwindow, this));
237 track_menu->create_objects();
238 if(debug) printf("MWindowGUI::create_objects %d\n", __LINE__);
239 add_subwindow(edit_menu = new EditPopup(mwindow, this));
240 edit_menu->create_objects();
243 if(debug) printf("MWindowGUI::create_objects %d\n", __LINE__);
244 add_subwindow(plugin_menu = new PluginPopup(mwindow, this));
245 plugin_menu->create_objects();
248 if(debug) printf("MWindowGUI::create_objects %d\n", __LINE__);
249 add_subwindow(keyframe_menu = new KeyframePopup(mwindow, this));
250 keyframe_menu->create_objects();
251 add_subwindow(keyframe_hide = new KeyframeHidePopup(mwindow, this));
252 keyframe_hide->create_objects();
255 if(debug) printf("MWindowGUI::create_objects %d\n", __LINE__);
256 add_subwindow(transition_menu = new TransitionPopup(mwindow, this));
257 transition_menu->create_objects();
260 channel_info = new ChannelInfo(mwindow);
262 #ifdef HAVE_COMMERCIAL
263 db_window = new DbWindow(mwindow);
265 swindow = new SWindow(mwindow);
267 if(debug) printf("MWindowGUI::create_objects %d\n", __LINE__);
269 add_subwindow(pane_button = new PaneButton(mwindow,
270 get_w() - mwindow->theme->get_image_set("pane")[0]->get_w(),
271 mwindow->theme->mzoom_y + 1 - mwindow->theme->get_image_set("pane")[0]->get_h()));
273 pane[TOP_LEFT_PANE]->canvas->activate();
275 if(debug) printf("MWindowGUI::create_objects %d\n", __LINE__);
279 void MWindowGUI::redraw_time_dependancies()
281 zoombar->redraw_time_dependancies();
282 for(int i = 0; i < TOTAL_PANES; i++)
283 if(pane[i] && pane[i]->timebar) pane[i]->timebar->update(0);
284 mainclock->update(mwindow->edl->local_session->get_selectionstart(1));
287 int MWindowGUI::focus_in_event()
289 for(int i = 0; i < TOTAL_PANES; i++)
290 if(pane[i]) pane[i]->cursor->focus_in_event();
294 int MWindowGUI::focus_out_event()
296 for(int i = 0; i < TOTAL_PANES; i++)
297 if(pane[i]) pane[i]->cursor->focus_out_event();
302 int MWindowGUI::resize_event(int w, int h)
304 //printf("MWindowGUI::resize_event %d\n", __LINE__);
305 mwindow->session->mwindow_w = w;
306 mwindow->session->mwindow_h = h;
307 int x1 = get_w() - MainShBtns::calculate_w(-1, 0, -1) - xS(5);
308 mainshbtns->reposition_window(x1, -1);
309 int x2 = x1 - mwindow->theme->stack_button_w - xS(5);
310 stack_button->reposition_window(x2, stack_button->get_y());
311 mainmenu->resize_event(x2, mainmenu->get_h());
312 mwindow->theme->get_mwindow_sizes(this, w, h);
313 mwindow->theme->draw_mwindow_bg(this);
314 mbuttons->resize_event();
315 int y1 = mbuttons->get_y()+yS(2);
316 proxy_toggle->reposition_window(x2, y1);
317 ffmpeg_toggle->reposition_window(x1, y1);
318 statusbar->resize_event();
319 zoombar->resize_event();
321 resource_thread->stop_draw(1);
323 if(total_panes() > 1)
325 if(horizontal_panes())
327 // printf("MWindowGUI::resize_event %d %d %d\n",
329 // pane[TOP_RIGHT_PANE]->x,
330 // mwindow->theme->mcanvas_w -
331 // BC_ScrollBar::get_span(SCROLL_VERT) -
332 // PANE_DRAG_MARGIN);
333 if(pane[TOP_RIGHT_PANE]->x >= mwindow->theme->mcanvas_w -
334 BC_ScrollBar::get_span(SCROLL_VERT) -
337 delete_x_pane(pane[TOP_RIGHT_PANE]->x);
338 mwindow->edl->local_session->x_pane = -1;
344 if(pane[BOTTOM_LEFT_PANE]->y >= mwindow->theme->mzoom_y -
345 BC_ScrollBar::get_span(SCROLL_HORIZ) -
348 delete_y_pane(pane[BOTTOM_LEFT_PANE]->y);
349 mwindow->edl->local_session->y_pane = -1;
354 if(pane[TOP_RIGHT_PANE]->x >= mwindow->theme->mcanvas_w -
355 BC_ScrollBar::get_span(SCROLL_VERT) -
358 delete_x_pane(pane[TOP_RIGHT_PANE]->x);
359 mwindow->edl->local_session->x_pane = -1;
362 if(pane[BOTTOM_LEFT_PANE]->y >= mwindow->theme->mzoom_y -
363 BC_ScrollBar::get_span(SCROLL_HORIZ) -
366 delete_y_pane(pane[BOTTOM_LEFT_PANE]->y);
367 mwindow->edl->local_session->y_pane = -1;
372 if(total_panes() == 1)
374 pane[TOP_LEFT_PANE]->resize_event(
375 mwindow->theme->mcanvas_x,
376 mwindow->theme->mcanvas_y,
377 mwindow->theme->mcanvas_w,
378 mwindow->theme->mcanvas_h);
381 if(horizontal_panes())
383 pane[TOP_LEFT_PANE]->resize_event(
384 pane[TOP_LEFT_PANE]->x,
385 pane[TOP_LEFT_PANE]->y,
386 pane[TOP_LEFT_PANE]->w,
387 mwindow->theme->mcanvas_h);
388 pane[TOP_RIGHT_PANE]->resize_event(
389 pane[TOP_RIGHT_PANE]->x,
390 pane[TOP_RIGHT_PANE]->y,
391 mwindow->theme->mcanvas_w - pane[TOP_RIGHT_PANE]->x,
392 mwindow->theme->mcanvas_h);
397 pane[TOP_LEFT_PANE]->resize_event(
398 pane[TOP_LEFT_PANE]->x,
399 pane[TOP_LEFT_PANE]->y,
400 mwindow->theme->mcanvas_w,
401 pane[TOP_LEFT_PANE]->h);
402 pane[BOTTOM_LEFT_PANE]->resize_event(
403 pane[BOTTOM_LEFT_PANE]->x,
404 pane[BOTTOM_LEFT_PANE]->y,
405 mwindow->theme->mcanvas_w,
406 mwindow->theme->mcanvas_y +
407 mwindow->theme->mcanvas_h -
408 pane[BOTTOM_LEFT_PANE]->y);
412 pane[TOP_LEFT_PANE]->resize_event(
413 pane[TOP_LEFT_PANE]->x,
414 pane[TOP_LEFT_PANE]->y,
415 pane[TOP_LEFT_PANE]->w,
416 pane[TOP_LEFT_PANE]->h);
417 pane[TOP_RIGHT_PANE]->resize_event(
418 pane[TOP_RIGHT_PANE]->x,
419 pane[TOP_RIGHT_PANE]->y,
420 mwindow->theme->mcanvas_w - pane[TOP_RIGHT_PANE]->x,
421 pane[TOP_RIGHT_PANE]->h);
422 pane[BOTTOM_LEFT_PANE]->resize_event(
423 pane[BOTTOM_LEFT_PANE]->x,
424 pane[BOTTOM_LEFT_PANE]->y,
425 pane[BOTTOM_LEFT_PANE]->w,
426 mwindow->theme->mcanvas_y +
427 mwindow->theme->mcanvas_h -
428 pane[BOTTOM_LEFT_PANE]->y);
429 pane[BOTTOM_RIGHT_PANE]->resize_event(
430 pane[BOTTOM_RIGHT_PANE]->x,
431 pane[BOTTOM_RIGHT_PANE]->y,
432 mwindow->theme->mcanvas_w -
433 pane[BOTTOM_RIGHT_PANE]->x,
434 mwindow->theme->mcanvas_y +
435 mwindow->theme->mcanvas_h -
436 pane[BOTTOM_RIGHT_PANE]->y);
439 update_pane_dividers();
440 pane_button->reposition_window(w - mwindow->theme->get_image_set("pane")[0]->get_w(),
441 mwindow->theme->mzoom_y + 1 - mwindow->theme->get_image_set("pane")[0]->get_h());
442 resource_thread->start_draw();
448 int MWindowGUI::total_panes()
451 for(int i = 0; i < TOTAL_PANES; i++)
456 int MWindowGUI::vertical_panes()
458 return total_panes() == 2 &&
459 pane[TOP_LEFT_PANE] &&
460 pane[BOTTOM_LEFT_PANE];
463 int MWindowGUI::horizontal_panes()
465 return total_panes() == 2 &&
466 pane[TOP_LEFT_PANE] &&
467 pane[TOP_RIGHT_PANE];
470 TimelinePane* MWindowGUI::get_focused_pane()
472 if(pane[focused_pane]) return pane[focused_pane];
473 for(int i = 0; i < TOTAL_PANES; i++)
475 if(pane[i]) return pane[i];
480 void MWindowGUI::activate_timeline()
482 if(pane[focused_pane])
484 pane[focused_pane]->activate();
488 for(int i = 0; i < TOTAL_PANES; i++)
499 void MWindowGUI::deactivate_timeline()
501 for(int i = 0; i < TOTAL_PANES; i++)
505 pane[i]->canvas->deactivate();
510 void MWindowGUI::update_title(char *path)
513 char filename[BCTEXTLEN], string[BCTEXTLEN];
514 fs.extract_name(filename, path);
515 sprintf(string, _(PROGRAM_NAME ": %s"), filename);
517 //printf("MWindowGUI::update_title %s\n", string);
521 void MWindowGUI::draw_overlays(int flash_it)
523 for(int i = 0; i < TOTAL_PANES; i++)
527 pane[i]->canvas->draw_overlays();
528 if(flash_it) pane[i]->canvas->flash();
533 void MWindowGUI::update_timebar(int flush_it)
535 for(int i = 0; i < TOTAL_PANES; i++)
537 if(pane[i] && pane[i]->timebar)
539 pane[i]->timebar->update(flush_it);
544 void MWindowGUI::update_timebar_highlights()
546 for(int i = 0; i < TOTAL_PANES; i++)
548 if(pane[i] && pane[i]->timebar)
550 pane[i]->timebar->update_highlights();
556 void MWindowGUI::update_patchbay()
558 for(int i = 0; i < TOTAL_PANES; i++)
560 if(pane[i] && pane[i]->patchbay)
562 pane[i]->patchbay->update();
567 void MWindowGUI::update_proxy_toggle()
569 int value = mwindow->edl->session->proxy_scale == 1 ? 1 : 0;
570 proxy_toggle->set_value(value);
571 if( mwindow->edl->session->proxy_scale == 1 &&
572 mwindow->edl->session->proxy_disabled_scale == 1 )
573 proxy_toggle->hide();
575 proxy_toggle->show();
578 void MWindowGUI::update_plugintoggles()
580 for(int i = 0; i < TOTAL_PANES; i++)
584 pane[i]->canvas->refresh_plugintoggles();
590 void MWindowGUI::draw_indexes(Indexable *indexable)
592 for(int i = 0; i < TOTAL_PANES; i++)
596 pane[i]->canvas->draw_indexes(indexable);
601 void MWindowGUI::draw_canvas(int redraw, int hide_cursor)
603 resource_thread->stop_draw(0);
605 int mode = redraw ? FORCE_REDRAW : NORMAL_DRAW;
606 for(int i = 0; i < TOTAL_PANES; i++) {
608 pane[i]->canvas->draw(mode, hide_cursor);
611 resource_thread->start_draw();
614 void MWindowGUI::flash_canvas(int flush)
616 for(int i = 0; i < TOTAL_PANES; i++)
620 pane[i]->canvas->flash(flush);
625 int MWindowGUI::show_window(int flush)
627 int ret = BC_WindowBase::show_window(flush);
628 stack_button->update();
629 update_proxy_toggle();
633 void MWindowGUI::draw_cursor(int do_plugintoggles)
635 for(int i = 0; i < TOTAL_PANES; i++)
639 pane[i]->cursor->draw(do_plugintoggles);
644 void MWindowGUI::show_cursor(int do_plugintoggles)
646 for(int i = 0; i < TOTAL_PANES; i++)
650 pane[i]->cursor->show(do_plugintoggles);
655 void MWindowGUI::hide_cursor(int do_plugintoggles)
657 for(int i = 0; i < TOTAL_PANES; i++)
661 pane[i]->cursor->hide(do_plugintoggles);
666 void MWindowGUI::update_cursor()
668 for(int i = 0; i < TOTAL_PANES; i++)
672 pane[i]->cursor->update();
677 void MWindowGUI::set_playing_back(int value)
679 for(int i = 0; i < TOTAL_PANES; i++)
683 pane[i]->cursor->playing_back = value;
688 void MWindowGUI::update_scrollbars(int flush)
690 for(int i = 0; i < TOTAL_PANES; i++)
694 pane[i]->update(1, NO_DRAW, 0, 0);
697 if(flush) this->flush();
700 void MWindowGUI::reset_meters()
702 for(int i = 0; i < TOTAL_PANES; i++)
704 if(pane[i] && pane[i]->patchbay)
706 pane[i]->patchbay->reset_meters();
711 void MWindowGUI::stop_meters()
713 for(int i = 0; i < TOTAL_PANES; i++)
715 if(pane[i] && pane[i]->patchbay)
717 pane[i]->patchbay->stop_meters();
722 void MWindowGUI::update_meters(ArrayList<double> *module_levels)
724 for(int i = 0; i < TOTAL_PANES; i++)
726 if(pane[i] && pane[i]->patchbay)
728 pane[i]->patchbay->update_meters(module_levels);
733 void MWindowGUI::set_editing_mode(int flush)
735 for(int i = 0; i < TOTAL_PANES; i++)
739 pane[i]->canvas->update_cursor(flush);
744 void MWindowGUI::set_meter_format(int mode, int min, int max)
746 for(int i = 0; i < TOTAL_PANES; i++)
748 if(pane[i] && pane[i]->patchbay)
750 pane[i]->patchbay->set_meter_format(mode, min, max);
755 void MWindowGUI::update(int scrollbars,
764 if(debug) PRINT_TRACE
768 mwindow->edl->tracks->update_y_pixels(mwindow->theme);
770 if( do_canvas != NO_DRAW && do_canvas != IGNORE_THREAD )
771 resource_thread->stop_draw(1);
773 for(int i = 0; i < TOTAL_PANES; i++)
775 if(pane[i]) pane[i]->update(scrollbars,
781 if( do_canvas != NO_DRAW && do_canvas != IGNORE_THREAD )
782 resource_thread->start_draw();
784 // if(scrollbars) this->get_scrollbars(0);
785 // if(timebar) this->timebar->update(0);
786 if(zoombar) this->zoombar->update();
787 // if(patchbay) this->patchbay->update();
788 if(clock) this->mainclock->update(
789 mwindow->edl->local_session->get_selectionstart(1));
790 if(debug) PRINT_TRACE
796 // this->canvas->draw(do_canvas);
797 // this->cursor->show();
798 // this->canvas->flash(0);
799 // Activate causes the menubar to deactivate. Don't want this for
801 // if(canvas != IGNORE_THREAD) this->canvas->activate();
803 if(debug) PRINT_TRACE
807 if(buttonbar) mbuttons->update();
808 if(debug) PRINT_TRACE
810 // Can't age if the cache called this to draw missing picons
811 // or the GUI is updating the status of the draw toggle.
812 if( do_canvas != FORCE_REDRAW && do_canvas != IGNORE_THREAD ) {
814 mwindow->age_caches();
815 lock_window("MWindowGUI::update");
819 if(debug) PRINT_TRACE
822 int MWindowGUI::visible(int64_t x1, int64_t x2, int64_t view_x1, int64_t view_x2)
824 return (x1 >= view_x1 && x1 < view_x2) ||
825 (x2 > view_x1 && x2 <= view_x2) ||
826 (x1 <= view_x1 && x2 >= view_x2);
830 void MWindowGUI::show_message(const char *message, int msg_color, int bar_color)
832 statusbar->show_message(message, msg_color, bar_color);
835 void MWindowGUI::update_default_message()
837 statusbar->update_default_message();
840 void MWindowGUI::reset_default_message()
842 statusbar->reset_default_message();
845 void MWindowGUI::default_message()
847 statusbar->default_message();
850 // Drag motion called from other window
851 int MWindowGUI::drag_motion()
853 if(get_hidden()) return 0;
855 Track *over_track = 0;
857 PluginSet *over_pluginset = 0;
858 Plugin *over_plugin = 0;
863 drag_popup->cursor_motion_event();
867 // there's no point in drawing highlights has until drag operation has been set
868 if (!mwindow->session->current_operation)
871 for(int i = 0; i < TOTAL_PANES; i++)
873 if(pane[i]) pane[i]->canvas->drag_motion(
880 if(mwindow->session->track_highlighted != over_track)
882 mwindow->session->track_highlighted = over_track;
886 if(mwindow->session->edit_highlighted != over_edit)
888 mwindow->session->edit_highlighted = over_edit;
892 if(mwindow->session->pluginset_highlighted != over_pluginset)
894 mwindow->session->pluginset_highlighted = over_pluginset;
898 if(mwindow->session->plugin_highlighted != over_plugin)
900 mwindow->session->plugin_highlighted = over_plugin;
904 if( mwindow->session->current_operation == DRAG_ASSET ||
905 mwindow->session->current_operation == DRAG_EDIT ||
906 mwindow->session->current_operation == DRAG_GROUP ||
907 mwindow->session->current_operation == DRAG_AEFFECT_COPY ||
908 mwindow->session->current_operation == DRAG_VEFFECT_COPY ) {
913 // printf("drag_motion %d %d over_track=%p over_edit=%p\n",
920 lock_window("MWindowGUI::drag_motion");
927 int MWindowGUI::drag_stop()
929 if(get_hidden()) return 0;
930 int result = 0, redraw = 0;
932 for(int i = 0; i < TOTAL_PANES; i++)
934 if(pane[i]) result |= pane[i]->canvas->drag_stop(
937 mwindow->edl->optimize();
939 // since we don't have subwindows we have to terminate any drag operation
942 if (mwindow->session->track_highlighted
943 || mwindow->session->edit_highlighted
944 || mwindow->session->plugin_highlighted
945 || mwindow->session->pluginset_highlighted)
947 mwindow->session->track_highlighted = 0;
948 mwindow->session->edit_highlighted = 0;
949 mwindow->session->plugin_highlighted = 0;
950 mwindow->session->pluginset_highlighted = 0;
951 mwindow->session->current_operation = NO_OPERATION;
955 //printf("MWindowGUI::drag_stop %d %d\n", redraw, mwindow->session->current_operation);
958 mwindow->edl->tracks->update_y_pixels(mwindow->theme);
959 update_scrollbars(0);
974 void MWindowGUI::default_positions()
976 //printf("MWindowGUI::default_positions 1\n");
977 VWindow *vwindow = mwindow->vwindows.size() > DEFAULT_VWINDOW ?
978 mwindow->vwindows.get(DEFAULT_VWINDOW) : 0;
979 if( vwindow && !vwindow->is_running() ) vwindow = 0;
980 if( vwindow ) vwindow->gui->lock_window("MWindowGUI::default_positions");
981 mwindow->cwindow->gui->lock_window("MWindowGUI::default_positions");
982 mwindow->awindow->gui->lock_window("MWindowGUI::default_positions");
984 // printf("MWindowGUI::default_positions 1 %d %d %d %d\n", mwindow->session->vwindow_x,
985 // mwindow->session->vwindow_y,
986 // mwindow->session->vwindow_w,
987 // mwindow->session->vwindow_h);
988 reposition_window(mwindow->session->mwindow_x,
989 mwindow->session->mwindow_y,
990 mwindow->session->mwindow_w,
991 mwindow->session->mwindow_h);
992 if( vwindow ) vwindow->gui->reposition_window(mwindow->session->vwindow_x,
993 mwindow->session->vwindow_y,
994 mwindow->session->vwindow_w,
995 mwindow->session->vwindow_h);
996 mwindow->cwindow->gui->reposition_window(mwindow->session->cwindow_x,
997 mwindow->session->cwindow_y,
998 mwindow->session->cwindow_w,
999 mwindow->session->cwindow_h);
1000 mwindow->awindow->gui->reposition_window(mwindow->session->awindow_x,
1001 mwindow->session->awindow_y,
1002 mwindow->session->awindow_w,
1003 mwindow->session->awindow_h);
1004 //printf("MWindowGUI::default_positions 1\n");
1006 resize_event(mwindow->session->mwindow_w,
1007 mwindow->session->mwindow_h);
1008 //printf("MWindowGUI::default_positions 1\n");
1009 if( vwindow ) vwindow->gui->resize_event(mwindow->session->vwindow_w,
1010 mwindow->session->vwindow_h);
1011 //printf("MWindowGUI::default_positions 1\n");
1012 mwindow->cwindow->gui->resize_event(mwindow->session->cwindow_w,
1013 mwindow->session->cwindow_h);
1014 //printf("MWindowGUI::default_positions 1\n");
1015 mwindow->awindow->gui->resize_event(mwindow->session->awindow_w,
1016 mwindow->session->awindow_h);
1018 //printf("MWindowGUI::default_positions 1\n");
1021 if( vwindow ) vwindow->gui->flush();
1022 mwindow->cwindow->gui->flush();
1023 mwindow->awindow->gui->flush();
1025 if( vwindow ) vwindow->gui->unlock_window();
1026 mwindow->cwindow->gui->unlock_window();
1027 mwindow->awindow->gui->unlock_window();
1028 //printf("MWindowGUI::default_positions 2\n");
1032 int MWindowGUI::repeat_event(int64_t duration)
1034 // if(duration == 100)
1035 // mwindow->sync_parameters(CHANGE_ALL);
1037 for(int i = 0; i < TOTAL_PANES; i++)
1039 if(pane[i]) result = pane[i]->cursor->repeat_event(duration);
1045 int MWindowGUI::translation_event()
1047 //printf("MWindowGUI::translation_event 1 %d %d\n", get_x(), get_y());
1048 mwindow->session->mwindow_x = get_x();
1049 mwindow->session->mwindow_y = get_y();
1054 int MWindowGUI::save_defaults(BC_Hash *defaults)
1056 defaults->update("MWINDOWWIDTH", get_w());
1057 defaults->update("MWINDOWHEIGHT", get_h());
1058 mainmenu->save_defaults(defaults);
1059 BC_WindowBase::save_defaults(defaults);
1063 int MWindowGUI::keypress_event()
1065 //printf("MWindowGUI::keypress_event 1 %d\n", get_keypress());
1066 int result = mbuttons->keypress_event();
1067 if( result ) return result;
1069 Track *this_track = 0, *first_track = 0;
1070 int collapse = 0, packed = 0, overwrite = 0, plugins = 0;
1071 double position = 0;
1073 switch( get_keypress() ) {
1075 if( !ctrl_down() || !shift_down() || alt_down() ) break;
1076 mwindow->edl->tracks->clear_selected_edits();
1081 mwindow->toggle_editing_mode();
1086 if( alt_down() ) break;
1087 stop_transport("MWindowGUI::keypress_event 1");
1088 mwindow->nearest_plugin_keyframe(shift_down(),
1089 !ctrl_down() ? PLAY_FORWARD : PLAY_REVERSE);
1096 if( !ctrl_down() || alt_down() ) break;
1097 mwindow->selected_edits_to_clipboard(packed);
1103 overwrite = -1; // fall thru
1105 if( !ctrl_down() || alt_down() ) break;
1106 if( mwindow->session->current_operation == DROP_TARGETING ) {
1107 mwindow->session->current_operation = NO_OPERATION;
1108 mwindow->gui->set_editing_mode(1);
1110 for( ; pane_no<TOTAL_PANES; ++pane_no ) {
1111 if( !pane[pane_no] ) continue;
1112 first_track = pane[pane_no]->over_track();
1113 if( first_track ) break;
1116 int cursor_x = pane[pane_no]->canvas->get_relative_cursor_x();
1117 position = mwindow->edl->get_cursor_position(cursor_x, pane_no);
1121 position = mwindow->edl->local_session->get_selectionstart();
1123 mwindow->paste(position, first_track, 0, overwrite);
1125 mwindow->paste_clipboard(first_track, position, 1, 0, 1, 1, 1);
1126 mwindow->edl->tracks->clear_selected_edits();
1134 mwindow->cut_selected_edits(0, collapse);
1140 if( !ctrl_down() || alt_down() ) break;
1141 mwindow->cut_selected_edits(1, collapse);
1146 if( !alt_down() || shift_down() ) break;
1147 if( !mwindow->select_asset(get_keypress()-'1',1) )
1152 if( !ctrl_down() ) {
1154 stop_transport("MWindowGUI::keypress_event 1");
1155 mwindow->prev_edit_handle(shift_down());
1158 mwindow->move_left();
1164 if( !ctrl_down() && !alt_down() ) {
1165 mwindow->move_left();
1171 if( !ctrl_down() ) {
1173 stop_transport("MWindowGUI::keypress_event 2");
1174 mwindow->next_edit_handle(shift_down());
1177 mwindow->move_right();
1183 if( !ctrl_down() && !alt_down() ) {
1184 mwindow->move_right();
1190 if( ctrl_down() && !alt_down() )
1191 mwindow->expand_y();
1192 else if( !ctrl_down() && alt_down() )
1193 mwindow->expand_autos(0,1,1);
1194 else if( ctrl_down() && alt_down() )
1195 mwindow->expand_autos(1,1,1);
1197 mwindow->expand_sample();
1202 if( ctrl_down() && !alt_down() )
1203 mwindow->zoom_in_y();
1204 else if( !ctrl_down() && alt_down() )
1205 mwindow->shrink_autos(0,1,1);
1206 else if( ctrl_down() && alt_down() )
1207 mwindow->shrink_autos(1,1,1);
1209 mwindow->zoom_in_sample();
1217 mwindow->expand_t();
1223 mwindow->move_down();
1225 mwindow->zoom_in_t();
1231 for( int i=0; i<TOTAL_PANES; ++i ) {
1232 if( !pane[i] ) continue;
1233 if( (this_track = pane[i]->over_track()) != 0 ) break;
1234 if( (this_track = pane[i]->over_patchbay()) != 0 ) break;
1237 if( get_keypress() == TAB ) { // Switch the record button
1239 this_track->record = !this_track->record ? 1 : 0;
1242 int total_selected = mwindow->edl->tracks->total_of(Tracks::RECORD);
1243 // all selected if nothing previously selected or
1244 // if this patch was previously the only one selected and armed
1245 int selected = !total_selected || (total_selected == 1 &&
1246 this_track && this_track->record ) ? 1 : 0;
1247 mwindow->edl->tracks->select_all(Tracks::RECORD, selected);
1248 if( !selected && this_track ) this_track->record = 1;
1251 update(0, NORMAL_DRAW, 0, 0, 1, 0, 1);
1253 mwindow->cwindow->update(0, 1, 1);
1254 lock_window("MWindowGUI::keypress_event 3");
1259 case KEY_F1 ... KEY_F12:
1260 resend_event(mwindow->cwindow->gui);
1264 // since things under cursor have changed...
1266 cursor_motion_event();
1271 int MWindowGUI::keyboard_listener(BC_WindowBase *wp)
1273 return key_listener(wp->get_keypress());
1276 int MWindowGUI::key_listener(int key)
1281 if( !record->running() )
1284 record->record_gui->interrupt_thread->start(0);
1291 channel_info->toggle_scan();
1295 if( !remote_control->deactivate() )
1296 remote_control->activate();
1306 void MWindowGUI::use_android_remote(int on)
1309 delete android_control;
1310 android_control = 0;
1313 if( android_control ) return;
1314 android_control = new AndroidControl(this);
1317 int MWindowGUI::close_event()
1323 void MWindowGUI::stop_drawing()
1325 resource_thread->stop_draw(1);
1328 int MWindowGUI::menu_w()
1330 return mainmenu->get_w();
1333 int MWindowGUI::menu_h()
1335 return mainmenu->get_h();
1338 void MWindowGUI::start_x_pane_drag()
1342 x_pane_drag = new BC_Popup(this,
1343 get_abs_cursor_x(0) - mwindow->theme->pane_w,
1344 BC_DisplayInfo::get_top_border() +
1346 mwindow->theme->mcanvas_y,
1347 mwindow->theme->pane_w,
1348 mwindow->theme->mcanvas_h,
1349 mwindow->theme->drag_pane_color);
1350 x_pane_drag->draw_3segmentv(0,
1352 x_pane_drag->get_h(),
1353 mwindow->theme->get_image_set("xpane")[BUTTON_DOWNHI]);
1354 x_pane_drag->flash(1);
1359 void MWindowGUI::start_y_pane_drag()
1363 //printf("MWindowGUI::start_y_pane_drag %d %d %d\n", __LINE__, get_x(), get_y());
1364 y_pane_drag = new BC_Popup(this,
1365 BC_DisplayInfo::get_left_border() +
1367 mwindow->theme->mcanvas_x,
1368 get_abs_cursor_y(0) - mwindow->theme->pane_h,
1369 mwindow->theme->mcanvas_w,
1370 mwindow->theme->pane_h,
1371 mwindow->theme->drag_pane_color);
1372 y_pane_drag->draw_3segmenth(0,
1374 y_pane_drag->get_w(),
1375 mwindow->theme->get_image_set("ypane")[BUTTON_DOWNHI]);
1376 y_pane_drag->flash(1);
1381 void MWindowGUI::handle_pane_drag()
1387 x_pane_drag->reposition_window(
1388 get_abs_cursor_x(0) - mwindow->theme->pane_w,
1389 x_pane_drag->get_y());
1394 y_pane_drag->reposition_window(
1395 y_pane_drag->get_x(),
1396 get_abs_cursor_y(0) - mwindow->theme->pane_h);
1402 void MWindowGUI::create_x_pane(int cursor_x)
1404 if(total_panes() == 1)
1406 // create a horizontal pane
1407 // do this 1st so the resize_event knows there are 2 panes
1408 mwindow->edl->local_session->view_start[TOP_RIGHT_PANE] =
1409 mwindow->edl->local_session->view_start[TOP_LEFT_PANE] +
1411 mwindow->theme->patchbay_w;
1412 pane[TOP_RIGHT_PANE] = new TimelinePane(mwindow,
1414 mwindow->theme->mcanvas_x +
1416 mwindow->theme->mcanvas_y,
1417 mwindow->theme->mcanvas_x +
1418 mwindow->theme->mcanvas_w -
1420 mwindow->theme->mcanvas_h);
1421 pane[TOP_LEFT_PANE]->resize_event(
1422 mwindow->theme->mcanvas_x,
1423 mwindow->theme->mcanvas_y,
1424 cursor_x - mwindow->theme->pane_w,
1425 mwindow->theme->mcanvas_h);
1426 pane[TOP_RIGHT_PANE]->create_objects();
1429 if(vertical_panes())
1431 // create 2 horizontal panes
1432 mwindow->edl->local_session->track_start[TOP_RIGHT_PANE] =
1433 mwindow->edl->local_session->track_start[TOP_LEFT_PANE];
1434 mwindow->edl->local_session->track_start[BOTTOM_RIGHT_PANE] =
1435 mwindow->edl->local_session->track_start[BOTTOM_LEFT_PANE];
1436 mwindow->edl->local_session->view_start[TOP_RIGHT_PANE] =
1437 mwindow->edl->local_session->view_start[BOTTOM_RIGHT_PANE] =
1438 mwindow->edl->local_session->view_start[TOP_LEFT_PANE] +
1440 mwindow->theme->patchbay_w;
1441 pane[TOP_RIGHT_PANE] = new TimelinePane(mwindow,
1443 mwindow->theme->mcanvas_x +
1445 pane[TOP_LEFT_PANE]->y,
1446 mwindow->theme->mcanvas_x +
1447 mwindow->theme->mcanvas_w -
1449 pane[TOP_LEFT_PANE]->h);
1450 pane[BOTTOM_RIGHT_PANE] = new TimelinePane(mwindow,
1452 mwindow->theme->mcanvas_x +
1454 pane[BOTTOM_LEFT_PANE]->y,
1455 mwindow->theme->mcanvas_x +
1456 mwindow->theme->mcanvas_w -
1458 pane[BOTTOM_LEFT_PANE]->h);
1459 pane[TOP_LEFT_PANE]->resize_event(
1460 pane[TOP_LEFT_PANE]->x,
1461 pane[TOP_LEFT_PANE]->y,
1462 cursor_x - mwindow->theme->pane_w,
1463 pane[TOP_LEFT_PANE]->h);
1464 pane[BOTTOM_LEFT_PANE]->resize_event(
1465 pane[BOTTOM_LEFT_PANE]->x,
1466 pane[BOTTOM_LEFT_PANE]->y,
1467 cursor_x - mwindow->theme->pane_w,
1468 pane[BOTTOM_LEFT_PANE]->h);
1469 pane[TOP_RIGHT_PANE]->create_objects();
1470 pane[BOTTOM_RIGHT_PANE]->create_objects();
1473 if(horizontal_panes())
1475 // resize a horizontal pane
1476 mwindow->edl->local_session->view_start[TOP_RIGHT_PANE] +=
1478 pane[TOP_RIGHT_PANE]->x;
1479 if(mwindow->edl->local_session->view_start[TOP_RIGHT_PANE] < 0)
1480 mwindow->edl->local_session->view_start[TOP_RIGHT_PANE] = 0;
1481 pane[TOP_LEFT_PANE]->resize_event(
1482 mwindow->theme->mcanvas_x,
1483 mwindow->theme->mcanvas_y,
1484 cursor_x - mwindow->theme->pane_w,
1485 mwindow->theme->mcanvas_h);
1486 pane[TOP_RIGHT_PANE]->resize_event(
1487 mwindow->theme->mcanvas_x +
1489 pane[TOP_RIGHT_PANE]->y,
1490 mwindow->theme->mcanvas_x +
1491 mwindow->theme->mcanvas_w -
1493 mwindow->theme->mcanvas_h);
1497 // resize 2 horizontal panes
1498 mwindow->edl->local_session->view_start[TOP_RIGHT_PANE] +=
1500 pane[TOP_RIGHT_PANE]->x;
1501 if(mwindow->edl->local_session->view_start[TOP_RIGHT_PANE] < 0)
1502 mwindow->edl->local_session->view_start[TOP_RIGHT_PANE] = 0;
1503 mwindow->edl->local_session->view_start[BOTTOM_RIGHT_PANE] =
1504 mwindow->edl->local_session->view_start[TOP_RIGHT_PANE];
1506 pane[TOP_LEFT_PANE]->resize_event(
1507 mwindow->theme->mcanvas_x,
1508 pane[TOP_LEFT_PANE]->y,
1509 cursor_x - mwindow->theme->pane_w,
1510 pane[TOP_LEFT_PANE]->h);
1511 pane[TOP_RIGHT_PANE]->resize_event(
1512 mwindow->theme->mcanvas_x +
1514 pane[TOP_RIGHT_PANE]->y,
1515 mwindow->theme->mcanvas_x +
1516 mwindow->theme->mcanvas_w -
1518 pane[TOP_RIGHT_PANE]->h);
1519 pane[BOTTOM_LEFT_PANE]->resize_event(
1520 mwindow->theme->mcanvas_x,
1521 pane[BOTTOM_LEFT_PANE]->y,
1522 cursor_x - mwindow->theme->pane_w,
1523 pane[BOTTOM_LEFT_PANE]->h);
1524 pane[BOTTOM_RIGHT_PANE]->resize_event(
1525 mwindow->theme->mcanvas_x +
1527 pane[BOTTOM_RIGHT_PANE]->y,
1528 mwindow->theme->mcanvas_x +
1529 mwindow->theme->mcanvas_w -
1531 pane[BOTTOM_RIGHT_PANE]->h);
1537 void MWindowGUI::delete_x_pane(int cursor_x)
1539 // give left panes coordinates of right pane
1540 if(cursor_x < mwindow->theme->patchbay_w + PANE_DRAG_MARGIN &&
1541 pane[TOP_RIGHT_PANE])
1543 mwindow->edl->local_session->view_start[TOP_LEFT_PANE] =
1544 mwindow->edl->local_session->view_start[TOP_RIGHT_PANE] -
1545 pane[TOP_RIGHT_PANE]->x + mwindow->theme->patchbay_w;
1546 if(mwindow->edl->local_session->view_start[TOP_LEFT_PANE] < 0)
1547 mwindow->edl->local_session->view_start[TOP_LEFT_PANE] = 0;
1548 mwindow->edl->local_session->view_start[BOTTOM_LEFT_PANE] =
1549 mwindow->edl->local_session->view_start[TOP_LEFT_PANE];
1552 switch(total_panes())
1555 if(pane[TOP_LEFT_PANE] && pane[TOP_RIGHT_PANE])
1557 // delete right pane
1558 delete pane[TOP_RIGHT_PANE];
1559 pane[TOP_RIGHT_PANE] = 0;
1560 pane[TOP_LEFT_PANE]->resize_event(
1561 mwindow->theme->mcanvas_x,
1562 mwindow->theme->mcanvas_y,
1563 mwindow->theme->mcanvas_w,
1564 mwindow->theme->mcanvas_h);
1570 // delete right panes
1571 delete pane[TOP_RIGHT_PANE];
1572 pane[TOP_RIGHT_PANE] = 0;
1573 delete pane[BOTTOM_RIGHT_PANE];
1574 pane[BOTTOM_RIGHT_PANE] = 0;
1575 pane[TOP_LEFT_PANE]->resize_event(
1576 mwindow->theme->mcanvas_x,
1577 pane[TOP_LEFT_PANE]->y,
1578 mwindow->theme->mcanvas_w,
1579 pane[TOP_LEFT_PANE]->h);
1580 pane[BOTTOM_LEFT_PANE]->resize_event(
1581 mwindow->theme->mcanvas_x,
1582 pane[BOTTOM_LEFT_PANE]->y,
1583 mwindow->theme->mcanvas_w,
1584 pane[BOTTOM_LEFT_PANE]->h);
1589 void MWindowGUI::create_y_pane(int cursor_y)
1591 if(total_panes() == 1)
1593 mwindow->edl->local_session->view_start[BOTTOM_LEFT_PANE] =
1594 mwindow->edl->local_session->view_start[TOP_LEFT_PANE];
1595 mwindow->edl->local_session->track_start[BOTTOM_LEFT_PANE] =
1596 mwindow->edl->local_session->track_start[TOP_LEFT_PANE] +
1598 mwindow->theme->mtimebar_h;
1599 // do this 1st so the resize_event knows there are 2 panes
1600 pane[BOTTOM_LEFT_PANE] = new TimelinePane(mwindow,
1602 mwindow->theme->mcanvas_x,
1603 mwindow->theme->mcanvas_y +
1605 mwindow->theme->mcanvas_w,
1606 mwindow->theme->mcanvas_h -
1608 pane[TOP_LEFT_PANE]->resize_event(
1609 mwindow->theme->mcanvas_x,
1610 mwindow->theme->mcanvas_y,
1611 mwindow->theme->mcanvas_w,
1612 pane[BOTTOM_LEFT_PANE]->y -
1613 mwindow->theme->mcanvas_y -
1614 mwindow->theme->pane_h);
1615 pane[BOTTOM_LEFT_PANE]->create_objects();
1618 if(horizontal_panes())
1621 mwindow->edl->local_session->view_start[BOTTOM_LEFT_PANE] =
1622 mwindow->edl->local_session->view_start[TOP_LEFT_PANE];
1623 mwindow->edl->local_session->view_start[BOTTOM_RIGHT_PANE] =
1624 mwindow->edl->local_session->view_start[TOP_RIGHT_PANE];
1625 mwindow->edl->local_session->track_start[BOTTOM_LEFT_PANE] =
1626 mwindow->edl->local_session->track_start[BOTTOM_RIGHT_PANE] =
1627 mwindow->edl->local_session->track_start[TOP_LEFT_PANE] +
1629 mwindow->theme->mtimebar_h;
1631 pane[BOTTOM_LEFT_PANE] = new TimelinePane(mwindow,
1633 pane[TOP_LEFT_PANE]->x,
1634 mwindow->theme->mcanvas_y +
1636 pane[TOP_LEFT_PANE]->w,
1637 mwindow->theme->mcanvas_h -
1639 pane[BOTTOM_RIGHT_PANE] = new TimelinePane(mwindow,
1641 pane[TOP_RIGHT_PANE]->x,
1642 mwindow->theme->mcanvas_y +
1644 pane[TOP_RIGHT_PANE]->w,
1645 mwindow->theme->mcanvas_h -
1648 pane[TOP_LEFT_PANE]->resize_event(
1649 pane[TOP_LEFT_PANE]->x,
1650 pane[TOP_LEFT_PANE]->y,
1651 pane[TOP_LEFT_PANE]->w,
1652 pane[BOTTOM_LEFT_PANE]->y -
1653 mwindow->theme->mcanvas_y -
1654 mwindow->theme->pane_h);
1655 pane[TOP_RIGHT_PANE]->resize_event(
1656 pane[TOP_RIGHT_PANE]->x,
1657 pane[TOP_RIGHT_PANE]->y,
1658 pane[TOP_RIGHT_PANE]->w,
1659 pane[BOTTOM_RIGHT_PANE]->y -
1660 mwindow->theme->mcanvas_y -
1661 mwindow->theme->pane_h);
1663 pane[BOTTOM_LEFT_PANE]->create_objects();
1664 pane[BOTTOM_RIGHT_PANE]->create_objects();
1667 if(vertical_panes())
1670 mwindow->edl->local_session->track_start[BOTTOM_LEFT_PANE] +=
1672 (pane[BOTTOM_LEFT_PANE]->y - mwindow->theme->mcanvas_y);
1673 if(mwindow->edl->local_session->track_start[BOTTOM_LEFT_PANE] < 0)
1674 mwindow->edl->local_session->track_start[BOTTOM_LEFT_PANE] = 0;
1675 pane[TOP_LEFT_PANE]->resize_event(
1676 mwindow->theme->mcanvas_x,
1677 mwindow->theme->mcanvas_y,
1678 mwindow->theme->mcanvas_w,
1679 cursor_y - mwindow->theme->pane_h);
1680 pane[BOTTOM_LEFT_PANE]->resize_event(
1681 pane[BOTTOM_LEFT_PANE]->x,
1683 mwindow->theme->mcanvas_y,
1684 mwindow->theme->mcanvas_w,
1685 mwindow->theme->mcanvas_h -
1691 mwindow->edl->local_session->track_start[BOTTOM_LEFT_PANE] +=
1693 (pane[BOTTOM_LEFT_PANE]->y - mwindow->theme->mcanvas_y);
1694 if(mwindow->edl->local_session->track_start[BOTTOM_LEFT_PANE] < 0)
1695 mwindow->edl->local_session->track_start[BOTTOM_LEFT_PANE] = 0;
1696 mwindow->edl->local_session->track_start[BOTTOM_RIGHT_PANE] =
1697 mwindow->edl->local_session->track_start[BOTTOM_LEFT_PANE];
1698 pane[TOP_LEFT_PANE]->resize_event(
1699 pane[TOP_LEFT_PANE]->x,
1700 pane[TOP_LEFT_PANE]->y,
1701 pane[TOP_LEFT_PANE]->w,
1702 cursor_y - mwindow->theme->pane_h);
1703 pane[BOTTOM_LEFT_PANE]->resize_event(
1704 pane[BOTTOM_LEFT_PANE]->x,
1706 mwindow->theme->mcanvas_y,
1707 pane[BOTTOM_LEFT_PANE]->w,
1708 mwindow->theme->mcanvas_h -
1710 pane[TOP_RIGHT_PANE]->resize_event(
1711 pane[TOP_RIGHT_PANE]->x,
1712 pane[TOP_RIGHT_PANE]->y,
1713 pane[TOP_RIGHT_PANE]->w,
1714 cursor_y - mwindow->theme->pane_h);
1715 pane[BOTTOM_RIGHT_PANE]->resize_event(
1716 pane[BOTTOM_RIGHT_PANE]->x,
1718 mwindow->theme->mcanvas_y,
1719 pane[BOTTOM_RIGHT_PANE]->w,
1720 mwindow->theme->mcanvas_h -
1725 void MWindowGUI::delete_y_pane(int cursor_y)
1727 if(cursor_y < mwindow->theme->mtimebar_h +
1729 pane[BOTTOM_LEFT_PANE])
1731 // give top pane coordinates of bottom pane
1732 mwindow->edl->local_session->track_start[TOP_LEFT_PANE] =
1733 mwindow->edl->local_session->track_start[BOTTOM_LEFT_PANE] -
1734 pane[BOTTOM_LEFT_PANE]->y;
1735 if(mwindow->edl->local_session->track_start[TOP_LEFT_PANE] < 0)
1736 mwindow->edl->local_session->track_start[TOP_LEFT_PANE] = 0;
1737 mwindow->edl->local_session->track_start[TOP_RIGHT_PANE] =
1738 mwindow->edl->local_session->track_start[TOP_LEFT_PANE];
1742 switch(total_panes())
1745 delete pane[BOTTOM_LEFT_PANE];
1746 pane[BOTTOM_LEFT_PANE] = 0;
1747 pane[TOP_LEFT_PANE]->resize_event(
1748 mwindow->theme->mcanvas_x,
1749 mwindow->theme->mcanvas_y,
1750 mwindow->theme->mcanvas_w,
1751 mwindow->theme->mcanvas_h);
1755 // delete bottom 2 panes
1757 delete pane[BOTTOM_LEFT_PANE];
1758 pane[BOTTOM_LEFT_PANE] = 0;
1759 delete pane[BOTTOM_RIGHT_PANE];
1760 pane[BOTTOM_RIGHT_PANE] = 0;
1761 pane[TOP_LEFT_PANE]->resize_event(
1762 pane[TOP_LEFT_PANE]->x,
1763 mwindow->theme->mcanvas_y,
1764 pane[TOP_LEFT_PANE]->w,
1765 mwindow->theme->mcanvas_h);
1766 pane[TOP_RIGHT_PANE]->resize_event(
1767 pane[TOP_RIGHT_PANE]->x,
1768 mwindow->theme->mcanvas_y,
1769 pane[TOP_RIGHT_PANE]->w,
1770 mwindow->theme->mcanvas_h);
1775 void MWindowGUI::stop_pane_drag()
1778 resource_thread->stop_draw(0);
1782 // cursor position relative to canvas
1783 int cursor_x = x_pane_drag->get_x() -
1785 BC_DisplayInfo::get_left_border() -
1786 mwindow->theme->mcanvas_x +
1787 mwindow->theme->pane_w;
1792 if(cursor_x >= mwindow->theme->patchbay_w + PANE_DRAG_MARGIN &&
1793 cursor_x < mwindow->theme->mcanvas_w -
1794 BC_ScrollBar::get_span(SCROLL_VERT) -
1797 create_x_pane(cursor_x);
1798 mwindow->edl->local_session->x_pane = cursor_x;
1803 delete_x_pane(cursor_x);
1804 mwindow->edl->local_session->x_pane = -1;
1812 // cursor position relative to canvas
1813 int cursor_y = y_pane_drag->get_y() -
1815 BC_DisplayInfo::get_top_border() -
1816 mwindow->theme->mcanvas_y +
1817 mwindow->theme->pane_h;
1823 if(cursor_y >= mwindow->theme->mtimebar_h +
1825 cursor_y < mwindow->theme->mcanvas_h -
1826 BC_ScrollBar::get_span(SCROLL_HORIZ) -
1829 create_y_pane(cursor_y);
1830 mwindow->edl->local_session->y_pane = cursor_y;
1834 delete_y_pane(cursor_y);
1835 mwindow->edl->local_session->y_pane = -1;
1839 update_pane_dividers();
1841 // required to get new widgets to appear
1843 resource_thread->start_draw();
1846 // create panes from EDL
1847 void MWindowGUI::load_panes()
1849 int need_x_panes = 0;
1850 int need_y_panes = 0;
1851 // use names from create functions
1852 int cursor_x = mwindow->edl->local_session->x_pane;
1853 int cursor_y = mwindow->edl->local_session->y_pane;
1855 resource_thread->stop_draw(1);
1857 mwindow->theme->patchbay_w + PANE_DRAG_MARGIN &&
1859 mwindow->theme->mcanvas_w -
1860 BC_ScrollBar::get_span(SCROLL_VERT) -
1867 mwindow->theme->mtimebar_h + PANE_DRAG_MARGIN &&
1869 mwindow->theme->mcanvas_h -
1870 BC_ScrollBar::get_span(SCROLL_HORIZ) -
1876 //printf("MWindowGUI::load_panes %d %d %d\n", __LINE__, need_x_panes, need_y_panes);
1884 if(total_panes() == 1)
1887 //printf("MWindowGUI::load_panes %d\n", __LINE__);
1888 pane[TOP_RIGHT_PANE] = new TimelinePane(mwindow,
1890 mwindow->theme->mcanvas_x +
1892 mwindow->theme->mcanvas_y,
1893 mwindow->theme->mcanvas_x +
1894 mwindow->theme->mcanvas_w -
1896 cursor_y - mwindow->theme->pane_h);
1897 pane[BOTTOM_LEFT_PANE] = new TimelinePane(mwindow,
1899 mwindow->theme->mcanvas_x,
1900 mwindow->theme->mcanvas_y +
1902 cursor_x - mwindow->theme->pane_w,
1903 mwindow->theme->mcanvas_h -
1905 pane[BOTTOM_RIGHT_PANE] = new TimelinePane(mwindow,
1907 pane[TOP_RIGHT_PANE]->x,
1908 mwindow->theme->mcanvas_y +
1910 pane[TOP_RIGHT_PANE]->w,
1911 mwindow->theme->mcanvas_h -
1913 pane[TOP_LEFT_PANE]->resize_event(
1914 pane[TOP_LEFT_PANE]->x,
1915 pane[TOP_LEFT_PANE]->y,
1916 cursor_x - mwindow->theme->pane_w,
1917 cursor_y - mwindow->theme->pane_h);
1918 pane[TOP_RIGHT_PANE]->create_objects();
1919 pane[BOTTOM_LEFT_PANE]->create_objects();
1920 pane[BOTTOM_RIGHT_PANE]->create_objects();
1923 if(horizontal_panes())
1925 // create vertical panes
1926 //printf("MWindowGUI::load_panes %d\n", __LINE__);
1927 pane[BOTTOM_LEFT_PANE] = new TimelinePane(mwindow,
1929 mwindow->theme->mcanvas_x,
1930 mwindow->theme->mcanvas_y +
1932 cursor_x - mwindow->theme->pane_w,
1933 mwindow->theme->mcanvas_h -
1935 pane[BOTTOM_RIGHT_PANE] = new TimelinePane(mwindow,
1937 pane[TOP_RIGHT_PANE]->x,
1938 mwindow->theme->mcanvas_y +
1940 pane[TOP_RIGHT_PANE]->w,
1941 mwindow->theme->mcanvas_h -
1943 pane[TOP_LEFT_PANE]->resize_event(
1944 pane[TOP_LEFT_PANE]->x,
1945 pane[TOP_LEFT_PANE]->y,
1946 cursor_x - mwindow->theme->pane_w,
1947 cursor_y - mwindow->theme->pane_h);
1948 pane[TOP_RIGHT_PANE]->resize_event(
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_LEFT_PANE]->create_objects();
1957 pane[BOTTOM_RIGHT_PANE]->create_objects();
1960 if(vertical_panes())
1962 // create horizontal panes
1963 //printf("MWindowGUI::load_panes %d\n", __LINE__);
1964 pane[TOP_RIGHT_PANE] = new TimelinePane(mwindow,
1966 mwindow->theme->mcanvas_x +
1968 mwindow->theme->mcanvas_y,
1969 mwindow->theme->mcanvas_x +
1970 mwindow->theme->mcanvas_w -
1972 cursor_y - mwindow->theme->pane_h);
1973 pane[BOTTOM_RIGHT_PANE] = new TimelinePane(mwindow,
1975 pane[TOP_RIGHT_PANE]->x,
1976 mwindow->theme->mcanvas_y +
1978 pane[TOP_RIGHT_PANE]->w,
1979 mwindow->theme->mcanvas_h -
1981 pane[TOP_LEFT_PANE]->resize_event(
1982 pane[TOP_LEFT_PANE]->x,
1983 pane[TOP_LEFT_PANE]->y,
1984 cursor_x - mwindow->theme->pane_w,
1985 cursor_y - mwindow->theme->pane_h);
1986 pane[BOTTOM_LEFT_PANE]->resize_event(
1987 pane[TOP_LEFT_PANE]->x,
1988 mwindow->theme->mcanvas_y +
1990 mwindow->theme->mcanvas_x +
1991 mwindow->theme->mcanvas_w -
1992 cursor_x - mwindow->theme->pane_w,
1993 mwindow->theme->mcanvas_h -
1995 pane[TOP_RIGHT_PANE]->create_objects();
1996 pane[BOTTOM_RIGHT_PANE]->create_objects();
2003 //printf("MWindowGUI::load_panes %d\n", __LINE__);
2004 pane[TOP_LEFT_PANE]->resize_event(
2005 pane[TOP_LEFT_PANE]->x,
2006 pane[TOP_LEFT_PANE]->y,
2007 cursor_x - mwindow->theme->pane_w,
2008 cursor_y - mwindow->theme->pane_h);
2009 pane[TOP_RIGHT_PANE]->resize_event(
2010 mwindow->theme->mcanvas_x +
2012 mwindow->theme->mcanvas_y,
2013 mwindow->theme->mcanvas_x +
2014 mwindow->theme->mcanvas_w -
2016 cursor_y - mwindow->theme->pane_h);
2017 pane[BOTTOM_LEFT_PANE]->resize_event(
2018 pane[TOP_LEFT_PANE]->x,
2019 mwindow->theme->mcanvas_y +
2021 mwindow->theme->mcanvas_x +
2022 mwindow->theme->mcanvas_w -
2023 cursor_x - mwindow->theme->pane_w,
2024 mwindow->theme->mcanvas_h -
2026 pane[BOTTOM_RIGHT_PANE]->resize_event(
2027 pane[TOP_RIGHT_PANE]->x,
2028 mwindow->theme->mcanvas_y +
2030 pane[TOP_RIGHT_PANE]->w,
2031 mwindow->theme->mcanvas_h -
2040 if(pane[BOTTOM_LEFT_PANE]) delete pane[BOTTOM_LEFT_PANE];
2041 if(pane[BOTTOM_RIGHT_PANE]) delete pane[BOTTOM_RIGHT_PANE];
2042 pane[BOTTOM_LEFT_PANE] = 0;
2043 pane[BOTTOM_RIGHT_PANE] = 0;
2045 if(!pane[TOP_RIGHT_PANE])
2047 pane[TOP_RIGHT_PANE] = new TimelinePane(mwindow,
2049 mwindow->theme->mcanvas_x +
2051 mwindow->theme->mcanvas_y,
2052 mwindow->theme->mcanvas_x +
2053 mwindow->theme->mcanvas_w -
2055 mwindow->theme->mcanvas_h);
2056 pane[TOP_LEFT_PANE]->resize_event(
2057 mwindow->theme->mcanvas_x,
2058 mwindow->theme->mcanvas_y,
2059 cursor_x - mwindow->theme->pane_w,
2060 mwindow->theme->mcanvas_h);
2061 pane[TOP_RIGHT_PANE]->create_objects();
2065 pane[TOP_LEFT_PANE]->resize_event(
2066 mwindow->theme->mcanvas_x,
2067 mwindow->theme->mcanvas_y,
2068 cursor_x - mwindow->theme->pane_w,
2069 mwindow->theme->mcanvas_h);
2070 pane[TOP_RIGHT_PANE]->resize_event(
2071 mwindow->theme->mcanvas_x +
2073 pane[TOP_RIGHT_PANE]->y,
2074 mwindow->theme->mcanvas_x +
2075 mwindow->theme->mcanvas_w -
2077 mwindow->theme->mcanvas_h);
2085 if(pane[TOP_RIGHT_PANE]) delete pane[TOP_RIGHT_PANE];
2086 if(pane[BOTTOM_RIGHT_PANE]) delete pane[BOTTOM_RIGHT_PANE];
2087 pane[TOP_RIGHT_PANE] = 0;
2088 pane[BOTTOM_RIGHT_PANE] = 0;
2090 if(!pane[BOTTOM_LEFT_PANE])
2092 //printf("MWindowGUI::load_panes %d\n", __LINE__);
2093 pane[BOTTOM_LEFT_PANE] = new TimelinePane(mwindow,
2095 mwindow->theme->mcanvas_x,
2096 mwindow->theme->mcanvas_y +
2098 mwindow->theme->mcanvas_w,
2099 mwindow->theme->mcanvas_h -
2101 pane[TOP_LEFT_PANE]->resize_event(
2102 mwindow->theme->mcanvas_x,
2103 mwindow->theme->mcanvas_y,
2104 mwindow->theme->mcanvas_w,
2105 pane[BOTTOM_LEFT_PANE]->y -
2106 mwindow->theme->mcanvas_y -
2107 mwindow->theme->pane_h);
2108 pane[BOTTOM_LEFT_PANE]->create_objects();
2112 pane[TOP_LEFT_PANE]->resize_event(
2113 mwindow->theme->mcanvas_x,
2114 mwindow->theme->mcanvas_y,
2115 mwindow->theme->mcanvas_w,
2116 cursor_y - mwindow->theme->pane_h);
2117 pane[BOTTOM_LEFT_PANE]->resize_event(
2118 pane[BOTTOM_LEFT_PANE]->x,
2120 mwindow->theme->mcanvas_y,
2121 mwindow->theme->mcanvas_w,
2122 mwindow->theme->mcanvas_h -
2129 if(pane[TOP_RIGHT_PANE]) delete pane[TOP_RIGHT_PANE];
2130 if(pane[BOTTOM_RIGHT_PANE]) delete pane[BOTTOM_RIGHT_PANE];
2131 if(pane[BOTTOM_LEFT_PANE]) delete pane[BOTTOM_LEFT_PANE];
2132 pane[TOP_RIGHT_PANE] = 0;
2133 pane[BOTTOM_RIGHT_PANE] = 0;
2134 pane[BOTTOM_LEFT_PANE] = 0;
2135 pane[TOP_LEFT_PANE]->resize_event(
2136 mwindow->theme->mcanvas_x,
2137 mwindow->theme->mcanvas_y,
2138 mwindow->theme->mcanvas_w,
2139 mwindow->theme->mcanvas_h);
2142 update_pane_dividers();
2145 resource_thread->start_draw();
2148 void MWindowGUI::update_pane_dividers()
2151 if(horizontal_panes() || total_panes() == 4)
2153 int x = pane[TOP_RIGHT_PANE]->x - mwindow->theme->pane_w;
2154 int y = mwindow->theme->mcanvas_y;
2155 int h = mwindow->theme->mcanvas_h;
2159 add_subwindow(x_divider = new PaneDivider(
2160 mwindow, x, y, h, 1));
2161 x_divider->create_objects();
2165 x_divider->reposition_window(x, y, h);
2178 if(vertical_panes() || total_panes() == 4)
2180 int x = mwindow->theme->mcanvas_x;
2181 int y = pane[BOTTOM_LEFT_PANE]->y -
2182 mwindow->theme->pane_h;
2183 int w = mwindow->theme->mcanvas_w;
2186 add_subwindow(y_divider = new PaneDivider(
2187 mwindow, x, y, w, 0));
2188 y_divider->create_objects();
2192 y_divider->reposition_window(x, y, w);
2206 void MWindowGUI::draw_samplemovement()
2213 update_scrollbars(1);
2216 void MWindowGUI::draw_trackmovement()
2218 update_scrollbars(0);
2225 void MWindowGUI::update_mixers(Track *track, int v)
2227 for( int i=0; i<TOTAL_PANES; ++i ) {
2228 if( !pane[i] ) continue;
2229 PatchBay *patchbay = pane[i]->patchbay;
2230 if( !patchbay ) continue;
2231 for( int j=0; j<patchbay->patches.total; ++j ) {
2232 PatchGUI *patchgui = patchbay->patches.values[j];
2233 if( !patchgui->mix ) continue;
2234 if( !track || patchgui->track == track ) {
2235 patchgui->mix->update(v>=0 ? v :
2236 mwindow->mixer_track_active(patchgui->track));
2242 void MWindowGUI::stop_transport(const char *lock_msg)
2244 if( !mbuttons->transport->is_stopped() ) {
2245 if( lock_msg ) unlock_window();
2246 mbuttons->transport->handle_transport(STOP, 1);
2247 if( lock_msg ) lock_window(lock_msg);
2251 PaneButton::PaneButton(MWindow *mwindow, int x, int y)
2252 : BC_Button(x, y, mwindow->theme->get_image_set("pane"))
2254 this->mwindow = mwindow;
2257 int PaneButton::cursor_motion_event()
2259 if(get_top_level()->get_button_down() &&
2261 get_status() == BUTTON_DOWNHI &&
2264 // printf("PaneButton::cursor_motion_event %d\n", __LINE__);
2266 if(get_cursor_x() < 0 && !mwindow->gui->dragging_pane)
2268 mwindow->gui->start_x_pane_drag();
2271 if(get_cursor_y() < 0 && !mwindow->gui->dragging_pane)
2273 mwindow->gui->start_y_pane_drag();
2277 mwindow->gui->handle_pane_drag();
2279 int result = BC_Button::cursor_motion_event();
2283 int PaneButton::button_release_event()
2285 if( get_buttonpress() != WHEEL_DOWN && get_buttonpress() != WHEEL_UP )
2286 mwindow->gui->stop_pane_drag();
2287 int result = BC_Button::button_release_event();
2292 FFMpegToggle::FFMpegToggle(MWindow *mwindow, MButtons *mbuttons, int x, int y)
2293 : BC_Toggle(x, y, mwindow->theme->ffmpeg_toggle,
2294 mwindow->preferences->get_file_probe_armed("FFMPEG_Early") > 0 ? 1 : 0)
2296 this->mwindow = mwindow;
2297 this->mbuttons = mbuttons;
2298 set_tooltip(get_value() ? FFMPEG_EARLY_TIP : FFMPEG_LATE_TIP);
2301 FFMpegToggle::~FFMpegToggle()
2305 int FFMpegToggle::handle_event()
2307 int ffmpeg_early_probe = get_value();
2308 set_tooltip(ffmpeg_early_probe ? FFMPEG_EARLY_TIP : FFMPEG_LATE_TIP);
2309 mwindow->preferences->set_file_probe_armed("FFMPEG_Early", ffmpeg_early_probe);
2310 mwindow->preferences->set_file_probe_armed("FFMPEG_Late", !ffmpeg_early_probe);
2311 mwindow->update_preferences(mwindow->preferences);
2312 mwindow->show_warning(&mwindow->preferences->warn_indexes,
2313 _("Changing the base codecs may require rebuilding indexes."));
2318 StackButton::StackButton(MWindow *mwindow, int x, int y)
2319 : BC_GenericButton(x, y, mwindow->theme->stack_button_w, "0")
2321 this->mwindow = mwindow;
2322 set_tooltip(_("Close EDL"));
2325 int StackButton::handle_event()
2327 mwindow->save_backup();
2328 mwindow->stack_pop();
2332 void StackButton::update()
2334 char text[BCSTRLEN];
2335 int i = mwindow->stack.size();
2336 sprintf(text, "%d", i);
2342 ProxyToggle::ProxyToggle(MWindow *mwindow, MButtons *mbuttons, int x, int y)
2343 : BC_Toggle(x, y, ( !mwindow->edl->session->proxy_use_scaler ?
2344 mwindow->theme->proxy_p_toggle :
2345 mwindow->theme->proxy_s_toggle ),
2346 mwindow->edl->session->proxy_disabled_scale != 1)
2348 this->mwindow = mwindow;
2349 this->mbuttons = mbuttons;
2350 scaler_images = mwindow->edl->session->proxy_use_scaler;
2351 set_tooltip(mwindow->edl->session->proxy_disabled_scale==1 ?
2352 _("Disable proxy") : _("Enable proxy"));
2355 void ProxyToggle::show()
2357 int use_scaler = mwindow->edl->session->proxy_use_scaler;
2358 if( scaler_images != use_scaler )
2359 set_images(!(scaler_images=use_scaler) ?
2360 mwindow->theme->proxy_p_toggle :
2361 mwindow->theme->proxy_s_toggle );
2367 void ProxyToggle::hide()
2373 ProxyToggle::~ProxyToggle()
2377 int ProxyToggle::handle_event()
2379 int disabled = get_value();
2380 mwindow->gui->unlock_window();
2382 mwindow->disable_proxy();
2384 mwindow->enable_proxy();
2385 mwindow->gui->lock_window("ProxyToggle::handle_event");
2386 set_tooltip(!disabled ? _("Disable proxy") : _("Enable proxy"));
2390 int ProxyToggle::keypress_event()
2392 if( ctrl_down() && !shift_down() && !alt_down() ) {
2393 int key = get_keypress();
2395 int value = get_value() ? 0 : 1;
2397 return handle_event();