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( !cwindow_remote_handler )
190 cwindow_remote_handler = (RemoteHandler*)
191 new CWindowKeyEvHandler(mwindow->gui->remote_control);
192 if( !record_remote_handler )
193 record_remote_handler = (RemoteHandler*)
194 new RecordKeyEvHandler(mwindow->gui->remote_control);
195 if(debug) printf("MWindowGUI::create_objects %d\n", __LINE__);
197 int x1 = get_w() - MainShBtns::calculate_w(-1, 0, -1) - xS(5);
198 add_subwindow(mainshbtns = new MainShBtns(mwindow, x1, -1));
199 mainshbtns->load(mwindow->preferences);
200 int x2 = x1 - mwindow->theme->stack_button_w - xS(5);
201 add_subwindow(stack_button = new StackButton(mwindow, x2, yS(2)));
202 add_subwindow(mainmenu = new MainMenu(mwindow, this, x2));
203 mainmenu->create_objects();
204 mwindow->theme->get_mwindow_sizes(this, get_w(), get_h());
205 mwindow->theme->draw_mwindow_bg(this);
206 if(debug) printf("MWindowGUI::create_objects %d\n", __LINE__);
208 add_subwindow(mbuttons = new MButtons(mwindow, this));
209 mbuttons->create_objects();
210 int y1 = mbuttons->get_y()+yS(2);
211 add_subwindow(proxy_toggle = new ProxyToggle(mwindow, mbuttons, x2, y1));
212 add_subwindow(ffmpeg_toggle = new FFMpegToggle(mwindow, mbuttons, x1, y1));
214 pane[TOP_LEFT_PANE] = new TimelinePane(mwindow,
216 mwindow->theme->mcanvas_x,
217 mwindow->theme->mcanvas_y,
218 mwindow->theme->mcanvas_w,
219 mwindow->theme->mcanvas_h);
220 pane[TOP_LEFT_PANE]->create_objects();
222 if(debug) printf("MWindowGUI::create_objects %d\n", __LINE__);
223 add_subwindow(zoombar = new ZoomBar(mwindow, this));
224 zoombar->create_objects();
227 if(debug) printf("MWindowGUI::create_objects %d\n", __LINE__);
228 add_subwindow(statusbar = new StatusBar(mwindow, this));
229 statusbar->create_objects();
233 if(debug) printf("MWindowGUI::create_objects %d\n", __LINE__);
234 add_subwindow(mainclock = new MainClock(mwindow,
235 mwindow->theme->mclock_x, mwindow->theme->mclock_y,
236 mwindow->theme->mclock_w));
237 if(debug) printf("MWindowGUI::create_objects %d\n", __LINE__);
238 mainclock->update(0);
242 // if(debug) printf("MWindowGUI::create_objects %d\n", __LINE__);
243 // cursor = new MainCursor(mwindow, this);
244 // cursor->create_objects();
247 if(debug) printf("MWindowGUI::create_objects %d\n", __LINE__);
248 add_subwindow(track_menu = new TrackPopup(mwindow, this));
249 track_menu->create_objects();
250 if(debug) printf("MWindowGUI::create_objects %d\n", __LINE__);
251 add_subwindow(edit_menu = new EditPopup(mwindow, this));
252 edit_menu->create_objects();
255 if(debug) printf("MWindowGUI::create_objects %d\n", __LINE__);
256 add_subwindow(plugin_menu = new PluginPopup(mwindow, this));
257 plugin_menu->create_objects();
260 if(debug) printf("MWindowGUI::create_objects %d\n", __LINE__);
261 add_subwindow(keyframe_menu = new KeyframePopup(mwindow, this));
262 keyframe_menu->create_objects();
263 add_subwindow(keyframe_hide = new KeyframeHidePopup(mwindow, this));
264 keyframe_hide->create_objects();
267 if(debug) printf("MWindowGUI::create_objects %d\n", __LINE__);
268 add_subwindow(transition_menu = new TransitionPopup(mwindow, this));
269 transition_menu->create_objects();
272 channel_info = new ChannelInfo(mwindow);
274 #ifdef HAVE_COMMERCIAL
275 db_window = new DbWindow(mwindow);
277 swindow = new SWindow(mwindow);
279 if(debug) printf("MWindowGUI::create_objects %d\n", __LINE__);
281 add_subwindow(pane_button = new PaneButton(mwindow,
282 get_w() - mwindow->theme->get_image_set("pane")[0]->get_w(),
283 mwindow->theme->mzoom_y + 1 - mwindow->theme->get_image_set("pane")[0]->get_h()));
285 pane[TOP_LEFT_PANE]->canvas->activate();
287 if(debug) printf("MWindowGUI::create_objects %d\n", __LINE__);
291 void MWindowGUI::redraw_time_dependancies()
293 zoombar->redraw_time_dependancies();
294 for(int i = 0; i < TOTAL_PANES; i++)
295 if(pane[i] && pane[i]->timebar) pane[i]->timebar->update(0);
296 mainclock->update(mwindow->edl->local_session->get_selectionstart(1));
299 int MWindowGUI::focus_in_event()
301 for(int i = 0; i < TOTAL_PANES; i++)
302 if(pane[i]) pane[i]->cursor->focus_in_event();
306 int MWindowGUI::focus_out_event()
308 for(int i = 0; i < TOTAL_PANES; i++)
309 if(pane[i]) pane[i]->cursor->focus_out_event();
314 int MWindowGUI::resize_event(int w, int h)
316 //printf("MWindowGUI::resize_event %d\n", __LINE__);
317 mwindow->session->mwindow_w = w;
318 mwindow->session->mwindow_h = h;
319 int x1 = get_w() - MainShBtns::calculate_w(-1, 0, -1) - xS(5);
320 mainshbtns->reposition_window(x1, -1);
321 int x2 = x1 - mwindow->theme->stack_button_w - xS(5);
322 stack_button->reposition_window(x2, stack_button->get_y());
323 mainmenu->resize_event(x2, mainmenu->get_h());
324 mwindow->theme->get_mwindow_sizes(this, w, h);
325 mwindow->theme->draw_mwindow_bg(this);
326 mbuttons->resize_event();
327 int y1 = mbuttons->get_y()+yS(2);
328 proxy_toggle->reposition_window(x2, y1);
329 ffmpeg_toggle->reposition_window(x1, y1);
330 statusbar->resize_event();
331 zoombar->resize_event();
333 resource_thread->stop_draw(1);
335 if(total_panes() > 1)
337 if(horizontal_panes())
339 // printf("MWindowGUI::resize_event %d %d %d\n",
341 // pane[TOP_RIGHT_PANE]->x,
342 // mwindow->theme->mcanvas_w -
343 // BC_ScrollBar::get_span(SCROLL_VERT) -
344 // PANE_DRAG_MARGIN);
345 if(pane[TOP_RIGHT_PANE]->x >= mwindow->theme->mcanvas_w -
346 BC_ScrollBar::get_span(SCROLL_VERT) -
349 delete_x_pane(pane[TOP_RIGHT_PANE]->x);
350 mwindow->edl->local_session->x_pane = -1;
356 if(pane[BOTTOM_LEFT_PANE]->y >= mwindow->theme->mzoom_y -
357 BC_ScrollBar::get_span(SCROLL_HORIZ) -
360 delete_y_pane(pane[BOTTOM_LEFT_PANE]->y);
361 mwindow->edl->local_session->y_pane = -1;
366 if(pane[TOP_RIGHT_PANE]->x >= mwindow->theme->mcanvas_w -
367 BC_ScrollBar::get_span(SCROLL_VERT) -
370 delete_x_pane(pane[TOP_RIGHT_PANE]->x);
371 mwindow->edl->local_session->x_pane = -1;
374 if(pane[BOTTOM_LEFT_PANE]->y >= mwindow->theme->mzoom_y -
375 BC_ScrollBar::get_span(SCROLL_HORIZ) -
378 delete_y_pane(pane[BOTTOM_LEFT_PANE]->y);
379 mwindow->edl->local_session->y_pane = -1;
384 if(total_panes() == 1)
386 pane[TOP_LEFT_PANE]->resize_event(
387 mwindow->theme->mcanvas_x,
388 mwindow->theme->mcanvas_y,
389 mwindow->theme->mcanvas_w,
390 mwindow->theme->mcanvas_h);
393 if(horizontal_panes())
395 pane[TOP_LEFT_PANE]->resize_event(
396 pane[TOP_LEFT_PANE]->x,
397 pane[TOP_LEFT_PANE]->y,
398 pane[TOP_LEFT_PANE]->w,
399 mwindow->theme->mcanvas_h);
400 pane[TOP_RIGHT_PANE]->resize_event(
401 pane[TOP_RIGHT_PANE]->x,
402 pane[TOP_RIGHT_PANE]->y,
403 mwindow->theme->mcanvas_w - pane[TOP_RIGHT_PANE]->x,
404 mwindow->theme->mcanvas_h);
409 pane[TOP_LEFT_PANE]->resize_event(
410 pane[TOP_LEFT_PANE]->x,
411 pane[TOP_LEFT_PANE]->y,
412 mwindow->theme->mcanvas_w,
413 pane[TOP_LEFT_PANE]->h);
414 pane[BOTTOM_LEFT_PANE]->resize_event(
415 pane[BOTTOM_LEFT_PANE]->x,
416 pane[BOTTOM_LEFT_PANE]->y,
417 mwindow->theme->mcanvas_w,
418 mwindow->theme->mcanvas_y +
419 mwindow->theme->mcanvas_h -
420 pane[BOTTOM_LEFT_PANE]->y);
424 pane[TOP_LEFT_PANE]->resize_event(
425 pane[TOP_LEFT_PANE]->x,
426 pane[TOP_LEFT_PANE]->y,
427 pane[TOP_LEFT_PANE]->w,
428 pane[TOP_LEFT_PANE]->h);
429 pane[TOP_RIGHT_PANE]->resize_event(
430 pane[TOP_RIGHT_PANE]->x,
431 pane[TOP_RIGHT_PANE]->y,
432 mwindow->theme->mcanvas_w - pane[TOP_RIGHT_PANE]->x,
433 pane[TOP_RIGHT_PANE]->h);
434 pane[BOTTOM_LEFT_PANE]->resize_event(
435 pane[BOTTOM_LEFT_PANE]->x,
436 pane[BOTTOM_LEFT_PANE]->y,
437 pane[BOTTOM_LEFT_PANE]->w,
438 mwindow->theme->mcanvas_y +
439 mwindow->theme->mcanvas_h -
440 pane[BOTTOM_LEFT_PANE]->y);
441 pane[BOTTOM_RIGHT_PANE]->resize_event(
442 pane[BOTTOM_RIGHT_PANE]->x,
443 pane[BOTTOM_RIGHT_PANE]->y,
444 mwindow->theme->mcanvas_w -
445 pane[BOTTOM_RIGHT_PANE]->x,
446 mwindow->theme->mcanvas_y +
447 mwindow->theme->mcanvas_h -
448 pane[BOTTOM_RIGHT_PANE]->y);
451 update_pane_dividers();
452 pane_button->reposition_window(w - mwindow->theme->get_image_set("pane")[0]->get_w(),
453 mwindow->theme->mzoom_y + 1 - mwindow->theme->get_image_set("pane")[0]->get_h());
454 resource_thread->start_draw();
460 int MWindowGUI::total_panes()
463 for(int i = 0; i < TOTAL_PANES; i++)
468 int MWindowGUI::vertical_panes()
470 return total_panes() == 2 &&
471 pane[TOP_LEFT_PANE] &&
472 pane[BOTTOM_LEFT_PANE];
475 int MWindowGUI::horizontal_panes()
477 return total_panes() == 2 &&
478 pane[TOP_LEFT_PANE] &&
479 pane[TOP_RIGHT_PANE];
482 TimelinePane* MWindowGUI::get_focused_pane()
484 if(pane[focused_pane]) return pane[focused_pane];
485 for(int i = 0; i < TOTAL_PANES; i++)
487 if(pane[i]) return pane[i];
492 void MWindowGUI::activate_timeline()
494 if(pane[focused_pane])
496 pane[focused_pane]->activate();
500 for(int i = 0; i < TOTAL_PANES; i++)
511 void MWindowGUI::deactivate_timeline()
513 for(int i = 0; i < TOTAL_PANES; i++)
517 pane[i]->canvas->deactivate();
522 void MWindowGUI::update_title(char *path)
525 char filename[BCTEXTLEN], string[BCTEXTLEN];
526 fs.extract_name(filename, path);
527 sprintf(string, _(PROGRAM_NAME ": %s"), filename);
529 //printf("MWindowGUI::update_title %s\n", string);
533 void MWindowGUI::draw_overlays(int flash_it)
535 for(int i = 0; i < TOTAL_PANES; i++)
539 pane[i]->canvas->draw_overlays();
540 if(flash_it) pane[i]->canvas->flash();
545 void MWindowGUI::update_timebar(int flush_it)
547 for(int i = 0; i < TOTAL_PANES; i++)
549 if(pane[i] && pane[i]->timebar)
551 pane[i]->timebar->update(flush_it);
556 void MWindowGUI::update_timebar_highlights()
558 for(int i = 0; i < TOTAL_PANES; i++)
560 if(pane[i] && pane[i]->timebar)
562 pane[i]->timebar->update_highlights();
568 void MWindowGUI::update_patchbay()
570 for(int i = 0; i < TOTAL_PANES; i++)
572 if(pane[i] && pane[i]->patchbay)
574 pane[i]->patchbay->update();
579 void MWindowGUI::update_proxy_toggle()
581 int value = mwindow->edl->session->proxy_scale == 1 ? 1 : 0;
582 proxy_toggle->set_value(value);
583 if( mwindow->edl->session->proxy_scale == 1 &&
584 mwindow->edl->session->proxy_disabled_scale == 1 )
585 proxy_toggle->hide();
587 proxy_toggle->show();
590 void MWindowGUI::update_plugintoggles()
592 for(int i = 0; i < TOTAL_PANES; i++)
596 pane[i]->canvas->refresh_plugintoggles();
602 void MWindowGUI::draw_indexes(Indexable *indexable)
604 for(int i = 0; i < TOTAL_PANES; i++)
608 pane[i]->canvas->draw_indexes(indexable);
613 void MWindowGUI::draw_canvas(int redraw, int hide_cursor)
615 resource_thread->stop_draw(0);
617 int mode = redraw ? FORCE_REDRAW : NORMAL_DRAW;
618 for(int i = 0; i < TOTAL_PANES; i++) {
620 pane[i]->canvas->draw(mode, hide_cursor);
623 resource_thread->start_draw();
626 void MWindowGUI::flash_canvas(int flush)
628 for(int i = 0; i < TOTAL_PANES; i++)
632 pane[i]->canvas->flash(flush);
637 int MWindowGUI::show_window(int flush)
639 int ret = BC_WindowBase::show_window(flush);
640 stack_button->update();
641 update_proxy_toggle();
645 void MWindowGUI::draw_cursor(int do_plugintoggles)
647 for(int i = 0; i < TOTAL_PANES; i++)
651 pane[i]->cursor->draw(do_plugintoggles);
656 void MWindowGUI::show_cursor(int do_plugintoggles)
658 for(int i = 0; i < TOTAL_PANES; i++)
662 pane[i]->cursor->show(do_plugintoggles);
667 void MWindowGUI::hide_cursor(int do_plugintoggles)
669 for(int i = 0; i < TOTAL_PANES; i++)
673 pane[i]->cursor->hide(do_plugintoggles);
678 void MWindowGUI::update_cursor()
680 for(int i = 0; i < TOTAL_PANES; i++)
684 pane[i]->cursor->update();
689 void MWindowGUI::set_playing_back(int value)
691 for(int i = 0; i < TOTAL_PANES; i++)
695 pane[i]->cursor->playing_back = value;
700 void MWindowGUI::update_scrollbars(int flush)
702 for(int i = 0; i < TOTAL_PANES; i++)
706 pane[i]->update(1, NO_DRAW, 0, 0);
709 if(flush) this->flush();
712 void MWindowGUI::reset_meters()
714 for(int i = 0; i < TOTAL_PANES; i++)
716 if(pane[i] && pane[i]->patchbay)
718 pane[i]->patchbay->reset_meters();
723 void MWindowGUI::stop_meters()
725 for(int i = 0; i < TOTAL_PANES; i++)
727 if(pane[i] && pane[i]->patchbay)
729 pane[i]->patchbay->stop_meters();
734 void MWindowGUI::update_meters(ArrayList<double> *module_levels)
736 for(int i = 0; i < TOTAL_PANES; i++)
738 if(pane[i] && pane[i]->patchbay)
740 pane[i]->patchbay->update_meters(module_levels);
745 void MWindowGUI::set_editing_mode(int flush)
747 for(int i = 0; i < TOTAL_PANES; i++)
751 pane[i]->canvas->update_cursor(flush);
756 void MWindowGUI::set_meter_format(int mode, int min, int max)
758 for(int i = 0; i < TOTAL_PANES; i++)
760 if(pane[i] && pane[i]->patchbay)
762 pane[i]->patchbay->set_meter_format(mode, min, max);
767 void MWindowGUI::update(int scrollbars,
776 if(debug) PRINT_TRACE
780 mwindow->edl->tracks->update_y_pixels(mwindow->theme);
782 if( do_canvas != NO_DRAW && do_canvas != IGNORE_THREAD )
783 resource_thread->stop_draw(1);
785 for(int i = 0; i < TOTAL_PANES; i++)
787 if(pane[i]) pane[i]->update(scrollbars,
793 if( do_canvas != NO_DRAW && do_canvas != IGNORE_THREAD )
794 resource_thread->start_draw();
796 // if(scrollbars) this->get_scrollbars(0);
797 // if(timebar) this->timebar->update(0);
798 if(zoombar) this->zoombar->update();
799 // if(patchbay) this->patchbay->update();
800 if(clock) this->mainclock->update(
801 mwindow->edl->local_session->get_selectionstart(1));
802 if(debug) PRINT_TRACE
808 // this->canvas->draw(do_canvas);
809 // this->cursor->show();
810 // this->canvas->flash(0);
811 // Activate causes the menubar to deactivate. Don't want this for
813 // if(canvas != IGNORE_THREAD) this->canvas->activate();
815 if(debug) PRINT_TRACE
819 if(buttonbar) mbuttons->update();
820 if(debug) PRINT_TRACE
822 // Can't age if the cache called this to draw missing picons
823 // or the GUI is updating the status of the draw toggle.
824 if( do_canvas != FORCE_REDRAW && do_canvas != IGNORE_THREAD ) {
826 mwindow->age_caches();
827 lock_window("MWindowGUI::update");
831 if(debug) PRINT_TRACE
834 int MWindowGUI::visible(int64_t x1, int64_t x2, int64_t view_x1, int64_t view_x2)
836 return (x1 >= view_x1 && x1 < view_x2) ||
837 (x2 > view_x1 && x2 <= view_x2) ||
838 (x1 <= view_x1 && x2 >= view_x2);
842 void MWindowGUI::show_message(const char *message, int msg_color, int bar_color)
844 statusbar->show_message(message, msg_color, bar_color);
847 void MWindowGUI::update_default_message()
849 statusbar->update_default_message();
852 void MWindowGUI::reset_default_message()
854 statusbar->reset_default_message();
857 void MWindowGUI::default_message()
859 statusbar->default_message();
862 // Drag motion called from other window
863 int MWindowGUI::drag_motion()
865 if(get_hidden()) return 0;
867 Track *over_track = 0;
869 PluginSet *over_pluginset = 0;
870 Plugin *over_plugin = 0;
875 drag_popup->cursor_motion_event();
879 // there's no point in drawing highlights has until drag operation has been set
880 if (!mwindow->session->current_operation)
883 for(int i = 0; i < TOTAL_PANES; i++)
885 if(pane[i]) pane[i]->canvas->drag_motion(
892 if(mwindow->session->track_highlighted != over_track)
894 mwindow->session->track_highlighted = over_track;
898 if(mwindow->session->edit_highlighted != over_edit)
900 mwindow->session->edit_highlighted = over_edit;
904 if(mwindow->session->pluginset_highlighted != over_pluginset)
906 mwindow->session->pluginset_highlighted = over_pluginset;
910 if(mwindow->session->plugin_highlighted != over_plugin)
912 mwindow->session->plugin_highlighted = over_plugin;
916 if( mwindow->session->current_operation == DRAG_ASSET ||
917 mwindow->session->current_operation == DRAG_EDIT ||
918 mwindow->session->current_operation == DRAG_GROUP ||
919 mwindow->session->current_operation == DRAG_AEFFECT_COPY ||
920 mwindow->session->current_operation == DRAG_VEFFECT_COPY ) {
925 // printf("drag_motion %d %d over_track=%p over_edit=%p\n",
932 lock_window("MWindowGUI::drag_motion");
939 int MWindowGUI::drag_stop()
941 if(get_hidden()) return 0;
942 int result = 0, redraw = 0;
944 for(int i = 0; i < TOTAL_PANES; i++)
946 if(pane[i]) result |= pane[i]->canvas->drag_stop(
949 mwindow->edl->optimize();
951 // since we don't have subwindows we have to terminate any drag operation
954 if (mwindow->session->track_highlighted
955 || mwindow->session->edit_highlighted
956 || mwindow->session->plugin_highlighted
957 || mwindow->session->pluginset_highlighted)
959 mwindow->session->track_highlighted = 0;
960 mwindow->session->edit_highlighted = 0;
961 mwindow->session->plugin_highlighted = 0;
962 mwindow->session->pluginset_highlighted = 0;
963 mwindow->session->current_operation = NO_OPERATION;
967 //printf("MWindowGUI::drag_stop %d %d\n", redraw, mwindow->session->current_operation);
970 mwindow->edl->tracks->update_y_pixels(mwindow->theme);
971 update_scrollbars(0);
986 void MWindowGUI::default_positions()
988 //printf("MWindowGUI::default_positions 1\n");
989 VWindow *vwindow = mwindow->vwindows.size() > DEFAULT_VWINDOW ?
990 mwindow->vwindows.get(DEFAULT_VWINDOW) : 0;
991 if( vwindow && !vwindow->is_running() ) vwindow = 0;
992 if( vwindow ) vwindow->gui->lock_window("MWindowGUI::default_positions");
993 mwindow->cwindow->gui->lock_window("MWindowGUI::default_positions");
994 mwindow->awindow->gui->lock_window("MWindowGUI::default_positions");
996 // printf("MWindowGUI::default_positions 1 %d %d %d %d\n", mwindow->session->vwindow_x,
997 // mwindow->session->vwindow_y,
998 // mwindow->session->vwindow_w,
999 // mwindow->session->vwindow_h);
1000 reposition_window(mwindow->session->mwindow_x,
1001 mwindow->session->mwindow_y,
1002 mwindow->session->mwindow_w,
1003 mwindow->session->mwindow_h);
1004 if( vwindow ) vwindow->gui->reposition_window(mwindow->session->vwindow_x,
1005 mwindow->session->vwindow_y,
1006 mwindow->session->vwindow_w,
1007 mwindow->session->vwindow_h);
1008 mwindow->cwindow->gui->reposition_window(mwindow->session->cwindow_x,
1009 mwindow->session->cwindow_y,
1010 mwindow->session->cwindow_w,
1011 mwindow->session->cwindow_h);
1012 mwindow->awindow->gui->reposition_window(mwindow->session->awindow_x,
1013 mwindow->session->awindow_y,
1014 mwindow->session->awindow_w,
1015 mwindow->session->awindow_h);
1016 //printf("MWindowGUI::default_positions 1\n");
1018 resize_event(mwindow->session->mwindow_w,
1019 mwindow->session->mwindow_h);
1020 //printf("MWindowGUI::default_positions 1\n");
1021 if( vwindow ) vwindow->gui->resize_event(mwindow->session->vwindow_w,
1022 mwindow->session->vwindow_h);
1023 //printf("MWindowGUI::default_positions 1\n");
1024 mwindow->cwindow->gui->resize_event(mwindow->session->cwindow_w,
1025 mwindow->session->cwindow_h);
1026 //printf("MWindowGUI::default_positions 1\n");
1027 mwindow->awindow->gui->resize_event(mwindow->session->awindow_w,
1028 mwindow->session->awindow_h);
1030 //printf("MWindowGUI::default_positions 1\n");
1033 if( vwindow ) vwindow->gui->flush();
1034 mwindow->cwindow->gui->flush();
1035 mwindow->awindow->gui->flush();
1037 if( vwindow ) vwindow->gui->unlock_window();
1038 mwindow->cwindow->gui->unlock_window();
1039 mwindow->awindow->gui->unlock_window();
1040 //printf("MWindowGUI::default_positions 2\n");
1044 int MWindowGUI::repeat_event(int64_t duration)
1046 // if(duration == 100)
1047 // mwindow->sync_parameters(CHANGE_ALL);
1049 for(int i = 0; i < TOTAL_PANES; i++)
1051 if(pane[i]) result = pane[i]->cursor->repeat_event(duration);
1057 int MWindowGUI::translation_event()
1059 //printf("MWindowGUI::translation_event 1 %d %d\n", get_x(), get_y());
1060 mwindow->session->mwindow_x = get_x();
1061 mwindow->session->mwindow_y = get_y();
1066 int MWindowGUI::save_defaults(BC_Hash *defaults)
1068 defaults->update("MWINDOWWIDTH", get_w());
1069 defaults->update("MWINDOWHEIGHT", get_h());
1070 mainmenu->save_defaults(defaults);
1071 BC_WindowBase::save_defaults(defaults);
1075 int MWindowGUI::keypress_event()
1077 //printf("MWindowGUI::keypress_event 1 %d\n", get_keypress());
1078 int result = mbuttons->keypress_event();
1079 if( result ) return result;
1081 Track *this_track = 0, *first_track = 0;
1082 int collapse = 0, packed = 0, overwrite = 0, plugins = 0;
1083 double position = 0;
1085 switch( get_keypress() ) {
1088 if( !ctrl_down() || !shift_down() ) break;
1089 mwindow->edl->tracks->clear_selected_edits();
1095 if( !alt_down() ) break;
1096 stop_transport("MWindowGUI::keypress_event 1");
1097 mwindow->nearest_auto_keyframe(shift_down(),
1098 !ctrl_down() ? PLAY_FORWARD : PLAY_REVERSE);
1103 mwindow->toggle_editing_mode();
1108 if( alt_down() ) break;
1109 stop_transport("MWindowGUI::keypress_event 2");
1110 mwindow->nearest_plugin_keyframe(shift_down(),
1111 !ctrl_down() ? PLAY_FORWARD : PLAY_REVERSE);
1118 if( !ctrl_down() || alt_down() ) break;
1119 mwindow->selected_edits_to_clipboard(packed);
1125 overwrite = -1; // fall thru
1127 if( !ctrl_down() || alt_down() ) break;
1128 if( mwindow->session->current_operation == DROP_TARGETING ) {
1129 mwindow->session->current_operation = NO_OPERATION;
1130 mwindow->gui->set_editing_mode(1);
1132 for( ; pane_no<TOTAL_PANES; ++pane_no ) {
1133 if( !pane[pane_no] ) continue;
1134 first_track = pane[pane_no]->over_track();
1135 if( first_track ) break;
1138 int cursor_x = pane[pane_no]->canvas->get_relative_cursor_x();
1139 position = mwindow->edl->get_cursor_position(cursor_x, pane_no);
1143 position = mwindow->edl->local_session->get_selectionstart();
1145 mwindow->paste(position, first_track, 0, overwrite);
1147 mwindow->paste_clipboard(first_track, position, 1, 0, 1, 1, 1);
1148 mwindow->edl->tracks->clear_selected_edits();
1156 mwindow->cut_selected_edits(0, collapse);
1162 if( !ctrl_down() || alt_down() ) break;
1163 mwindow->cut_selected_edits(1, collapse);
1168 if( !alt_down() || shift_down() ) break;
1169 if( !mwindow->select_asset(get_keypress()-'1',1) )
1174 if( !ctrl_down() ) {
1176 stop_transport("MWindowGUI::keypress_event 1");
1177 mwindow->prev_edit_handle(shift_down());
1180 mwindow->move_left();
1186 if( !ctrl_down() && !alt_down() ) {
1187 mwindow->move_left();
1193 if( !ctrl_down() ) {
1195 stop_transport("MWindowGUI::keypress_event 2");
1196 mwindow->next_edit_handle(shift_down());
1199 mwindow->move_right();
1205 if( !ctrl_down() && !alt_down() ) {
1206 mwindow->move_right();
1212 if( ctrl_down() && !alt_down() )
1213 mwindow->expand_y();
1214 else if( !ctrl_down() && alt_down() )
1215 mwindow->expand_autos(0,1,1);
1216 else if( ctrl_down() && alt_down() )
1217 mwindow->expand_autos(1,1,1);
1219 mwindow->expand_sample();
1224 if( ctrl_down() && !alt_down() )
1225 mwindow->zoom_in_y();
1226 else if( !ctrl_down() && alt_down() )
1227 mwindow->shrink_autos(0,1,1);
1228 else if( ctrl_down() && alt_down() )
1229 mwindow->shrink_autos(1,1,1);
1231 mwindow->zoom_in_sample();
1239 mwindow->expand_t();
1245 mwindow->move_down();
1247 mwindow->zoom_in_t();
1253 for( int i=0; i<TOTAL_PANES; ++i ) {
1254 if( !pane[i] ) continue;
1255 if( (this_track = pane[i]->over_track()) != 0 ) break;
1256 if( (this_track = pane[i]->over_patchbay()) != 0 ) break;
1259 if( get_keypress() == TAB ) { // Switch the record button
1261 this_track->record = !this_track->record ? 1 : 0;
1264 int total_selected = mwindow->edl->tracks->total_of(Tracks::RECORD);
1265 // all selected if nothing previously selected or
1266 // if this patch was previously the only one selected and armed
1267 int selected = !total_selected || (total_selected == 1 &&
1268 this_track && this_track->record ) ? 1 : 0;
1269 mwindow->edl->tracks->select_all(Tracks::RECORD, selected);
1270 if( !selected && this_track ) this_track->record = 1;
1273 update(0, NORMAL_DRAW, 0, 0, 1, 0, 1);
1275 mwindow->cwindow->update(0, 1, 1);
1276 lock_window("MWindowGUI::keypress_event 3");
1281 case KEY_F1 ... KEY_F12:
1282 resend_event(mwindow->cwindow->gui);
1286 // since things under cursor have changed...
1288 cursor_motion_event();
1293 int MWindowGUI::keyboard_listener(BC_WindowBase *wp)
1295 return key_listener(wp->get_keypress());
1298 int MWindowGUI::key_listener(int key)
1303 if( !record->running() )
1306 record->record_gui->interrupt_thread->start(0);
1313 channel_info->toggle_scan();
1317 if( !remote_control->deactivate() )
1318 remote_control->activate();
1328 void MWindowGUI::use_android_remote(int on)
1331 delete android_control;
1332 android_control = 0;
1335 if( android_control ) return;
1336 android_control = new AndroidControl(this);
1338 int MWindowGUI::keyev_grab_remote()
1340 if( cwindow_remote_handler && cwindow_remote_handler->is_keytv() &&
1341 record_remote_handler && record_remote_handler->is_keytv() )
1343 delete cwindow_remote_handler;
1344 delete record_remote_handler;
1345 cwindow_remote_handler = (RemoteHandler*)
1346 new CWindowKeyEvHandler(mwindow->gui->remote_control);
1347 record_remote_handler = (RemoteHandler*)
1348 new RecordKeyEvHandler(mwindow->gui->remote_control);
1352 int MWindowGUI::close_event()
1358 void MWindowGUI::stop_drawing()
1360 resource_thread->stop_draw(1);
1363 int MWindowGUI::menu_w()
1365 return mainmenu->get_w();
1368 int MWindowGUI::menu_h()
1370 return mainmenu->get_h();
1373 void MWindowGUI::start_x_pane_drag()
1377 x_pane_drag = new BC_Popup(this,
1378 get_abs_cursor_x(0) - mwindow->theme->pane_w,
1379 BC_DisplayInfo::get_top_border() +
1381 mwindow->theme->mcanvas_y,
1382 mwindow->theme->pane_w,
1383 mwindow->theme->mcanvas_h,
1384 mwindow->theme->drag_pane_color);
1385 x_pane_drag->draw_3segmentv(0,
1387 x_pane_drag->get_h(),
1388 mwindow->theme->get_image_set("xpane")[BUTTON_DOWNHI]);
1389 x_pane_drag->flash(1);
1394 void MWindowGUI::start_y_pane_drag()
1398 //printf("MWindowGUI::start_y_pane_drag %d %d %d\n", __LINE__, get_x(), get_y());
1399 y_pane_drag = new BC_Popup(this,
1400 BC_DisplayInfo::get_left_border() +
1402 mwindow->theme->mcanvas_x,
1403 get_abs_cursor_y(0) - mwindow->theme->pane_h,
1404 mwindow->theme->mcanvas_w,
1405 mwindow->theme->pane_h,
1406 mwindow->theme->drag_pane_color);
1407 y_pane_drag->draw_3segmenth(0,
1409 y_pane_drag->get_w(),
1410 mwindow->theme->get_image_set("ypane")[BUTTON_DOWNHI]);
1411 y_pane_drag->flash(1);
1416 void MWindowGUI::handle_pane_drag()
1422 x_pane_drag->reposition_window(
1423 get_abs_cursor_x(0) - mwindow->theme->pane_w,
1424 x_pane_drag->get_y());
1429 y_pane_drag->reposition_window(
1430 y_pane_drag->get_x(),
1431 get_abs_cursor_y(0) - mwindow->theme->pane_h);
1437 void MWindowGUI::create_x_pane(int cursor_x)
1439 if(total_panes() == 1)
1441 // create a horizontal pane
1442 // do this 1st so the resize_event knows there are 2 panes
1443 mwindow->edl->local_session->view_start[TOP_RIGHT_PANE] =
1444 mwindow->edl->local_session->view_start[TOP_LEFT_PANE] +
1446 mwindow->theme->patchbay_w;
1447 pane[TOP_RIGHT_PANE] = new TimelinePane(mwindow,
1449 mwindow->theme->mcanvas_x +
1451 mwindow->theme->mcanvas_y,
1452 mwindow->theme->mcanvas_x +
1453 mwindow->theme->mcanvas_w -
1455 mwindow->theme->mcanvas_h);
1456 pane[TOP_LEFT_PANE]->resize_event(
1457 mwindow->theme->mcanvas_x,
1458 mwindow->theme->mcanvas_y,
1459 cursor_x - mwindow->theme->pane_w,
1460 mwindow->theme->mcanvas_h);
1461 pane[TOP_RIGHT_PANE]->create_objects();
1464 if(vertical_panes())
1466 // create 2 horizontal panes
1467 mwindow->edl->local_session->track_start[TOP_RIGHT_PANE] =
1468 mwindow->edl->local_session->track_start[TOP_LEFT_PANE];
1469 mwindow->edl->local_session->track_start[BOTTOM_RIGHT_PANE] =
1470 mwindow->edl->local_session->track_start[BOTTOM_LEFT_PANE];
1471 mwindow->edl->local_session->view_start[TOP_RIGHT_PANE] =
1472 mwindow->edl->local_session->view_start[BOTTOM_RIGHT_PANE] =
1473 mwindow->edl->local_session->view_start[TOP_LEFT_PANE] +
1475 mwindow->theme->patchbay_w;
1476 pane[TOP_RIGHT_PANE] = new TimelinePane(mwindow,
1478 mwindow->theme->mcanvas_x +
1480 pane[TOP_LEFT_PANE]->y,
1481 mwindow->theme->mcanvas_x +
1482 mwindow->theme->mcanvas_w -
1484 pane[TOP_LEFT_PANE]->h);
1485 pane[BOTTOM_RIGHT_PANE] = new TimelinePane(mwindow,
1487 mwindow->theme->mcanvas_x +
1489 pane[BOTTOM_LEFT_PANE]->y,
1490 mwindow->theme->mcanvas_x +
1491 mwindow->theme->mcanvas_w -
1493 pane[BOTTOM_LEFT_PANE]->h);
1494 pane[TOP_LEFT_PANE]->resize_event(
1495 pane[TOP_LEFT_PANE]->x,
1496 pane[TOP_LEFT_PANE]->y,
1497 cursor_x - mwindow->theme->pane_w,
1498 pane[TOP_LEFT_PANE]->h);
1499 pane[BOTTOM_LEFT_PANE]->resize_event(
1500 pane[BOTTOM_LEFT_PANE]->x,
1501 pane[BOTTOM_LEFT_PANE]->y,
1502 cursor_x - mwindow->theme->pane_w,
1503 pane[BOTTOM_LEFT_PANE]->h);
1504 pane[TOP_RIGHT_PANE]->create_objects();
1505 pane[BOTTOM_RIGHT_PANE]->create_objects();
1508 if(horizontal_panes())
1510 // resize a horizontal pane
1511 mwindow->edl->local_session->view_start[TOP_RIGHT_PANE] +=
1513 pane[TOP_RIGHT_PANE]->x;
1514 if(mwindow->edl->local_session->view_start[TOP_RIGHT_PANE] < 0)
1515 mwindow->edl->local_session->view_start[TOP_RIGHT_PANE] = 0;
1516 pane[TOP_LEFT_PANE]->resize_event(
1517 mwindow->theme->mcanvas_x,
1518 mwindow->theme->mcanvas_y,
1519 cursor_x - mwindow->theme->pane_w,
1520 mwindow->theme->mcanvas_h);
1521 pane[TOP_RIGHT_PANE]->resize_event(
1522 mwindow->theme->mcanvas_x +
1524 pane[TOP_RIGHT_PANE]->y,
1525 mwindow->theme->mcanvas_x +
1526 mwindow->theme->mcanvas_w -
1528 mwindow->theme->mcanvas_h);
1532 // resize 2 horizontal panes
1533 mwindow->edl->local_session->view_start[TOP_RIGHT_PANE] +=
1535 pane[TOP_RIGHT_PANE]->x;
1536 if(mwindow->edl->local_session->view_start[TOP_RIGHT_PANE] < 0)
1537 mwindow->edl->local_session->view_start[TOP_RIGHT_PANE] = 0;
1538 mwindow->edl->local_session->view_start[BOTTOM_RIGHT_PANE] =
1539 mwindow->edl->local_session->view_start[TOP_RIGHT_PANE];
1541 pane[TOP_LEFT_PANE]->resize_event(
1542 mwindow->theme->mcanvas_x,
1543 pane[TOP_LEFT_PANE]->y,
1544 cursor_x - mwindow->theme->pane_w,
1545 pane[TOP_LEFT_PANE]->h);
1546 pane[TOP_RIGHT_PANE]->resize_event(
1547 mwindow->theme->mcanvas_x +
1549 pane[TOP_RIGHT_PANE]->y,
1550 mwindow->theme->mcanvas_x +
1551 mwindow->theme->mcanvas_w -
1553 pane[TOP_RIGHT_PANE]->h);
1554 pane[BOTTOM_LEFT_PANE]->resize_event(
1555 mwindow->theme->mcanvas_x,
1556 pane[BOTTOM_LEFT_PANE]->y,
1557 cursor_x - mwindow->theme->pane_w,
1558 pane[BOTTOM_LEFT_PANE]->h);
1559 pane[BOTTOM_RIGHT_PANE]->resize_event(
1560 mwindow->theme->mcanvas_x +
1562 pane[BOTTOM_RIGHT_PANE]->y,
1563 mwindow->theme->mcanvas_x +
1564 mwindow->theme->mcanvas_w -
1566 pane[BOTTOM_RIGHT_PANE]->h);
1572 void MWindowGUI::delete_x_pane(int cursor_x)
1574 // give left panes coordinates of right pane
1575 if(cursor_x < mwindow->theme->patchbay_w + PANE_DRAG_MARGIN &&
1576 pane[TOP_RIGHT_PANE])
1578 mwindow->edl->local_session->view_start[TOP_LEFT_PANE] =
1579 mwindow->edl->local_session->view_start[TOP_RIGHT_PANE] -
1580 pane[TOP_RIGHT_PANE]->x + mwindow->theme->patchbay_w;
1581 if(mwindow->edl->local_session->view_start[TOP_LEFT_PANE] < 0)
1582 mwindow->edl->local_session->view_start[TOP_LEFT_PANE] = 0;
1583 mwindow->edl->local_session->view_start[BOTTOM_LEFT_PANE] =
1584 mwindow->edl->local_session->view_start[TOP_LEFT_PANE];
1587 switch(total_panes())
1590 if(pane[TOP_LEFT_PANE] && pane[TOP_RIGHT_PANE])
1592 // delete right pane
1593 delete pane[TOP_RIGHT_PANE];
1594 pane[TOP_RIGHT_PANE] = 0;
1595 pane[TOP_LEFT_PANE]->resize_event(
1596 mwindow->theme->mcanvas_x,
1597 mwindow->theme->mcanvas_y,
1598 mwindow->theme->mcanvas_w,
1599 mwindow->theme->mcanvas_h);
1605 // delete right panes
1606 delete pane[TOP_RIGHT_PANE];
1607 pane[TOP_RIGHT_PANE] = 0;
1608 delete pane[BOTTOM_RIGHT_PANE];
1609 pane[BOTTOM_RIGHT_PANE] = 0;
1610 pane[TOP_LEFT_PANE]->resize_event(
1611 mwindow->theme->mcanvas_x,
1612 pane[TOP_LEFT_PANE]->y,
1613 mwindow->theme->mcanvas_w,
1614 pane[TOP_LEFT_PANE]->h);
1615 pane[BOTTOM_LEFT_PANE]->resize_event(
1616 mwindow->theme->mcanvas_x,
1617 pane[BOTTOM_LEFT_PANE]->y,
1618 mwindow->theme->mcanvas_w,
1619 pane[BOTTOM_LEFT_PANE]->h);
1624 void MWindowGUI::create_y_pane(int cursor_y)
1626 if(total_panes() == 1)
1628 mwindow->edl->local_session->view_start[BOTTOM_LEFT_PANE] =
1629 mwindow->edl->local_session->view_start[TOP_LEFT_PANE];
1630 mwindow->edl->local_session->track_start[BOTTOM_LEFT_PANE] =
1631 mwindow->edl->local_session->track_start[TOP_LEFT_PANE] +
1633 mwindow->theme->mtimebar_h;
1634 // do this 1st so the resize_event knows there are 2 panes
1635 pane[BOTTOM_LEFT_PANE] = new TimelinePane(mwindow,
1637 mwindow->theme->mcanvas_x,
1638 mwindow->theme->mcanvas_y +
1640 mwindow->theme->mcanvas_w,
1641 mwindow->theme->mcanvas_h -
1643 pane[TOP_LEFT_PANE]->resize_event(
1644 mwindow->theme->mcanvas_x,
1645 mwindow->theme->mcanvas_y,
1646 mwindow->theme->mcanvas_w,
1647 pane[BOTTOM_LEFT_PANE]->y -
1648 mwindow->theme->mcanvas_y -
1649 mwindow->theme->pane_h);
1650 pane[BOTTOM_LEFT_PANE]->create_objects();
1653 if(horizontal_panes())
1656 mwindow->edl->local_session->view_start[BOTTOM_LEFT_PANE] =
1657 mwindow->edl->local_session->view_start[TOP_LEFT_PANE];
1658 mwindow->edl->local_session->view_start[BOTTOM_RIGHT_PANE] =
1659 mwindow->edl->local_session->view_start[TOP_RIGHT_PANE];
1660 mwindow->edl->local_session->track_start[BOTTOM_LEFT_PANE] =
1661 mwindow->edl->local_session->track_start[BOTTOM_RIGHT_PANE] =
1662 mwindow->edl->local_session->track_start[TOP_LEFT_PANE] +
1664 mwindow->theme->mtimebar_h;
1666 pane[BOTTOM_LEFT_PANE] = new TimelinePane(mwindow,
1668 pane[TOP_LEFT_PANE]->x,
1669 mwindow->theme->mcanvas_y +
1671 pane[TOP_LEFT_PANE]->w,
1672 mwindow->theme->mcanvas_h -
1674 pane[BOTTOM_RIGHT_PANE] = new TimelinePane(mwindow,
1676 pane[TOP_RIGHT_PANE]->x,
1677 mwindow->theme->mcanvas_y +
1679 pane[TOP_RIGHT_PANE]->w,
1680 mwindow->theme->mcanvas_h -
1683 pane[TOP_LEFT_PANE]->resize_event(
1684 pane[TOP_LEFT_PANE]->x,
1685 pane[TOP_LEFT_PANE]->y,
1686 pane[TOP_LEFT_PANE]->w,
1687 pane[BOTTOM_LEFT_PANE]->y -
1688 mwindow->theme->mcanvas_y -
1689 mwindow->theme->pane_h);
1690 pane[TOP_RIGHT_PANE]->resize_event(
1691 pane[TOP_RIGHT_PANE]->x,
1692 pane[TOP_RIGHT_PANE]->y,
1693 pane[TOP_RIGHT_PANE]->w,
1694 pane[BOTTOM_RIGHT_PANE]->y -
1695 mwindow->theme->mcanvas_y -
1696 mwindow->theme->pane_h);
1698 pane[BOTTOM_LEFT_PANE]->create_objects();
1699 pane[BOTTOM_RIGHT_PANE]->create_objects();
1702 if(vertical_panes())
1705 mwindow->edl->local_session->track_start[BOTTOM_LEFT_PANE] +=
1707 (pane[BOTTOM_LEFT_PANE]->y - mwindow->theme->mcanvas_y);
1708 if(mwindow->edl->local_session->track_start[BOTTOM_LEFT_PANE] < 0)
1709 mwindow->edl->local_session->track_start[BOTTOM_LEFT_PANE] = 0;
1710 pane[TOP_LEFT_PANE]->resize_event(
1711 mwindow->theme->mcanvas_x,
1712 mwindow->theme->mcanvas_y,
1713 mwindow->theme->mcanvas_w,
1714 cursor_y - mwindow->theme->pane_h);
1715 pane[BOTTOM_LEFT_PANE]->resize_event(
1716 pane[BOTTOM_LEFT_PANE]->x,
1718 mwindow->theme->mcanvas_y,
1719 mwindow->theme->mcanvas_w,
1720 mwindow->theme->mcanvas_h -
1726 mwindow->edl->local_session->track_start[BOTTOM_LEFT_PANE] +=
1728 (pane[BOTTOM_LEFT_PANE]->y - mwindow->theme->mcanvas_y);
1729 if(mwindow->edl->local_session->track_start[BOTTOM_LEFT_PANE] < 0)
1730 mwindow->edl->local_session->track_start[BOTTOM_LEFT_PANE] = 0;
1731 mwindow->edl->local_session->track_start[BOTTOM_RIGHT_PANE] =
1732 mwindow->edl->local_session->track_start[BOTTOM_LEFT_PANE];
1733 pane[TOP_LEFT_PANE]->resize_event(
1734 pane[TOP_LEFT_PANE]->x,
1735 pane[TOP_LEFT_PANE]->y,
1736 pane[TOP_LEFT_PANE]->w,
1737 cursor_y - mwindow->theme->pane_h);
1738 pane[BOTTOM_LEFT_PANE]->resize_event(
1739 pane[BOTTOM_LEFT_PANE]->x,
1741 mwindow->theme->mcanvas_y,
1742 pane[BOTTOM_LEFT_PANE]->w,
1743 mwindow->theme->mcanvas_h -
1745 pane[TOP_RIGHT_PANE]->resize_event(
1746 pane[TOP_RIGHT_PANE]->x,
1747 pane[TOP_RIGHT_PANE]->y,
1748 pane[TOP_RIGHT_PANE]->w,
1749 cursor_y - mwindow->theme->pane_h);
1750 pane[BOTTOM_RIGHT_PANE]->resize_event(
1751 pane[BOTTOM_RIGHT_PANE]->x,
1753 mwindow->theme->mcanvas_y,
1754 pane[BOTTOM_RIGHT_PANE]->w,
1755 mwindow->theme->mcanvas_h -
1760 void MWindowGUI::delete_y_pane(int cursor_y)
1762 if(cursor_y < mwindow->theme->mtimebar_h +
1764 pane[BOTTOM_LEFT_PANE])
1766 // give top pane coordinates of bottom pane
1767 mwindow->edl->local_session->track_start[TOP_LEFT_PANE] =
1768 mwindow->edl->local_session->track_start[BOTTOM_LEFT_PANE] -
1769 pane[BOTTOM_LEFT_PANE]->y;
1770 if(mwindow->edl->local_session->track_start[TOP_LEFT_PANE] < 0)
1771 mwindow->edl->local_session->track_start[TOP_LEFT_PANE] = 0;
1772 mwindow->edl->local_session->track_start[TOP_RIGHT_PANE] =
1773 mwindow->edl->local_session->track_start[TOP_LEFT_PANE];
1777 switch(total_panes())
1780 delete pane[BOTTOM_LEFT_PANE];
1781 pane[BOTTOM_LEFT_PANE] = 0;
1782 pane[TOP_LEFT_PANE]->resize_event(
1783 mwindow->theme->mcanvas_x,
1784 mwindow->theme->mcanvas_y,
1785 mwindow->theme->mcanvas_w,
1786 mwindow->theme->mcanvas_h);
1790 // delete bottom 2 panes
1792 delete pane[BOTTOM_LEFT_PANE];
1793 pane[BOTTOM_LEFT_PANE] = 0;
1794 delete pane[BOTTOM_RIGHT_PANE];
1795 pane[BOTTOM_RIGHT_PANE] = 0;
1796 pane[TOP_LEFT_PANE]->resize_event(
1797 pane[TOP_LEFT_PANE]->x,
1798 mwindow->theme->mcanvas_y,
1799 pane[TOP_LEFT_PANE]->w,
1800 mwindow->theme->mcanvas_h);
1801 pane[TOP_RIGHT_PANE]->resize_event(
1802 pane[TOP_RIGHT_PANE]->x,
1803 mwindow->theme->mcanvas_y,
1804 pane[TOP_RIGHT_PANE]->w,
1805 mwindow->theme->mcanvas_h);
1810 void MWindowGUI::stop_pane_drag()
1813 resource_thread->stop_draw(0);
1817 // cursor position relative to canvas
1818 int cursor_x = x_pane_drag->get_x() -
1820 BC_DisplayInfo::get_left_border() -
1821 mwindow->theme->mcanvas_x +
1822 mwindow->theme->pane_w;
1827 if(cursor_x >= mwindow->theme->patchbay_w + PANE_DRAG_MARGIN &&
1828 cursor_x < mwindow->theme->mcanvas_w -
1829 BC_ScrollBar::get_span(SCROLL_VERT) -
1832 create_x_pane(cursor_x);
1833 mwindow->edl->local_session->x_pane = cursor_x;
1838 delete_x_pane(cursor_x);
1839 mwindow->edl->local_session->x_pane = -1;
1847 // cursor position relative to canvas
1848 int cursor_y = y_pane_drag->get_y() -
1850 BC_DisplayInfo::get_top_border() -
1851 mwindow->theme->mcanvas_y +
1852 mwindow->theme->pane_h;
1858 if(cursor_y >= mwindow->theme->mtimebar_h +
1860 cursor_y < mwindow->theme->mcanvas_h -
1861 BC_ScrollBar::get_span(SCROLL_HORIZ) -
1864 create_y_pane(cursor_y);
1865 mwindow->edl->local_session->y_pane = cursor_y;
1869 delete_y_pane(cursor_y);
1870 mwindow->edl->local_session->y_pane = -1;
1874 update_pane_dividers();
1876 // required to get new widgets to appear
1878 resource_thread->start_draw();
1881 // create panes from EDL
1882 void MWindowGUI::load_panes()
1884 int need_x_panes = 0;
1885 int need_y_panes = 0;
1886 // use names from create functions
1887 int cursor_x = mwindow->edl->local_session->x_pane;
1888 int cursor_y = mwindow->edl->local_session->y_pane;
1890 resource_thread->stop_draw(1);
1892 mwindow->theme->patchbay_w + PANE_DRAG_MARGIN &&
1894 mwindow->theme->mcanvas_w -
1895 BC_ScrollBar::get_span(SCROLL_VERT) -
1902 mwindow->theme->mtimebar_h + PANE_DRAG_MARGIN &&
1904 mwindow->theme->mcanvas_h -
1905 BC_ScrollBar::get_span(SCROLL_HORIZ) -
1911 //printf("MWindowGUI::load_panes %d %d %d\n", __LINE__, need_x_panes, need_y_panes);
1919 if(total_panes() == 1)
1922 //printf("MWindowGUI::load_panes %d\n", __LINE__);
1923 pane[TOP_RIGHT_PANE] = new TimelinePane(mwindow,
1925 mwindow->theme->mcanvas_x +
1927 mwindow->theme->mcanvas_y,
1928 mwindow->theme->mcanvas_x +
1929 mwindow->theme->mcanvas_w -
1931 cursor_y - mwindow->theme->pane_h);
1932 pane[BOTTOM_LEFT_PANE] = new TimelinePane(mwindow,
1934 mwindow->theme->mcanvas_x,
1935 mwindow->theme->mcanvas_y +
1937 cursor_x - mwindow->theme->pane_w,
1938 mwindow->theme->mcanvas_h -
1940 pane[BOTTOM_RIGHT_PANE] = new TimelinePane(mwindow,
1942 pane[TOP_RIGHT_PANE]->x,
1943 mwindow->theme->mcanvas_y +
1945 pane[TOP_RIGHT_PANE]->w,
1946 mwindow->theme->mcanvas_h -
1948 pane[TOP_LEFT_PANE]->resize_event(
1949 pane[TOP_LEFT_PANE]->x,
1950 pane[TOP_LEFT_PANE]->y,
1951 cursor_x - mwindow->theme->pane_w,
1952 cursor_y - mwindow->theme->pane_h);
1953 pane[TOP_RIGHT_PANE]->create_objects();
1954 pane[BOTTOM_LEFT_PANE]->create_objects();
1955 pane[BOTTOM_RIGHT_PANE]->create_objects();
1958 if(horizontal_panes())
1960 // create vertical panes
1961 //printf("MWindowGUI::load_panes %d\n", __LINE__);
1962 pane[BOTTOM_LEFT_PANE] = new TimelinePane(mwindow,
1964 mwindow->theme->mcanvas_x,
1965 mwindow->theme->mcanvas_y +
1967 cursor_x - mwindow->theme->pane_w,
1968 mwindow->theme->mcanvas_h -
1970 pane[BOTTOM_RIGHT_PANE] = new TimelinePane(mwindow,
1972 pane[TOP_RIGHT_PANE]->x,
1973 mwindow->theme->mcanvas_y +
1975 pane[TOP_RIGHT_PANE]->w,
1976 mwindow->theme->mcanvas_h -
1978 pane[TOP_LEFT_PANE]->resize_event(
1979 pane[TOP_LEFT_PANE]->x,
1980 pane[TOP_LEFT_PANE]->y,
1981 cursor_x - mwindow->theme->pane_w,
1982 cursor_y - mwindow->theme->pane_h);
1983 pane[TOP_RIGHT_PANE]->resize_event(
1984 mwindow->theme->mcanvas_x +
1986 mwindow->theme->mcanvas_y,
1987 mwindow->theme->mcanvas_x +
1988 mwindow->theme->mcanvas_w -
1990 cursor_y - mwindow->theme->pane_h);
1991 pane[BOTTOM_LEFT_PANE]->create_objects();
1992 pane[BOTTOM_RIGHT_PANE]->create_objects();
1995 if(vertical_panes())
1997 // create horizontal panes
1998 //printf("MWindowGUI::load_panes %d\n", __LINE__);
1999 pane[TOP_RIGHT_PANE] = new TimelinePane(mwindow,
2001 mwindow->theme->mcanvas_x +
2003 mwindow->theme->mcanvas_y,
2004 mwindow->theme->mcanvas_x +
2005 mwindow->theme->mcanvas_w -
2007 cursor_y - mwindow->theme->pane_h);
2008 pane[BOTTOM_RIGHT_PANE] = new TimelinePane(mwindow,
2010 pane[TOP_RIGHT_PANE]->x,
2011 mwindow->theme->mcanvas_y +
2013 pane[TOP_RIGHT_PANE]->w,
2014 mwindow->theme->mcanvas_h -
2016 pane[TOP_LEFT_PANE]->resize_event(
2017 pane[TOP_LEFT_PANE]->x,
2018 pane[TOP_LEFT_PANE]->y,
2019 cursor_x - mwindow->theme->pane_w,
2020 cursor_y - mwindow->theme->pane_h);
2021 pane[BOTTOM_LEFT_PANE]->resize_event(
2022 pane[TOP_LEFT_PANE]->x,
2023 mwindow->theme->mcanvas_y +
2025 mwindow->theme->mcanvas_x +
2026 mwindow->theme->mcanvas_w -
2027 cursor_x - mwindow->theme->pane_w,
2028 mwindow->theme->mcanvas_h -
2030 pane[TOP_RIGHT_PANE]->create_objects();
2031 pane[BOTTOM_RIGHT_PANE]->create_objects();
2038 //printf("MWindowGUI::load_panes %d\n", __LINE__);
2039 pane[TOP_LEFT_PANE]->resize_event(
2040 pane[TOP_LEFT_PANE]->x,
2041 pane[TOP_LEFT_PANE]->y,
2042 cursor_x - mwindow->theme->pane_w,
2043 cursor_y - mwindow->theme->pane_h);
2044 pane[TOP_RIGHT_PANE]->resize_event(
2045 mwindow->theme->mcanvas_x +
2047 mwindow->theme->mcanvas_y,
2048 mwindow->theme->mcanvas_x +
2049 mwindow->theme->mcanvas_w -
2051 cursor_y - mwindow->theme->pane_h);
2052 pane[BOTTOM_LEFT_PANE]->resize_event(
2053 pane[TOP_LEFT_PANE]->x,
2054 mwindow->theme->mcanvas_y +
2056 mwindow->theme->mcanvas_x +
2057 mwindow->theme->mcanvas_w -
2058 cursor_x - mwindow->theme->pane_w,
2059 mwindow->theme->mcanvas_h -
2061 pane[BOTTOM_RIGHT_PANE]->resize_event(
2062 pane[TOP_RIGHT_PANE]->x,
2063 mwindow->theme->mcanvas_y +
2065 pane[TOP_RIGHT_PANE]->w,
2066 mwindow->theme->mcanvas_h -
2075 if(pane[BOTTOM_LEFT_PANE]) delete pane[BOTTOM_LEFT_PANE];
2076 if(pane[BOTTOM_RIGHT_PANE]) delete pane[BOTTOM_RIGHT_PANE];
2077 pane[BOTTOM_LEFT_PANE] = 0;
2078 pane[BOTTOM_RIGHT_PANE] = 0;
2080 if(!pane[TOP_RIGHT_PANE])
2082 pane[TOP_RIGHT_PANE] = new TimelinePane(mwindow,
2084 mwindow->theme->mcanvas_x +
2086 mwindow->theme->mcanvas_y,
2087 mwindow->theme->mcanvas_x +
2088 mwindow->theme->mcanvas_w -
2090 mwindow->theme->mcanvas_h);
2091 pane[TOP_LEFT_PANE]->resize_event(
2092 mwindow->theme->mcanvas_x,
2093 mwindow->theme->mcanvas_y,
2094 cursor_x - mwindow->theme->pane_w,
2095 mwindow->theme->mcanvas_h);
2096 pane[TOP_RIGHT_PANE]->create_objects();
2100 pane[TOP_LEFT_PANE]->resize_event(
2101 mwindow->theme->mcanvas_x,
2102 mwindow->theme->mcanvas_y,
2103 cursor_x - mwindow->theme->pane_w,
2104 mwindow->theme->mcanvas_h);
2105 pane[TOP_RIGHT_PANE]->resize_event(
2106 mwindow->theme->mcanvas_x +
2108 pane[TOP_RIGHT_PANE]->y,
2109 mwindow->theme->mcanvas_x +
2110 mwindow->theme->mcanvas_w -
2112 mwindow->theme->mcanvas_h);
2120 if(pane[TOP_RIGHT_PANE]) delete pane[TOP_RIGHT_PANE];
2121 if(pane[BOTTOM_RIGHT_PANE]) delete pane[BOTTOM_RIGHT_PANE];
2122 pane[TOP_RIGHT_PANE] = 0;
2123 pane[BOTTOM_RIGHT_PANE] = 0;
2125 if(!pane[BOTTOM_LEFT_PANE])
2127 //printf("MWindowGUI::load_panes %d\n", __LINE__);
2128 pane[BOTTOM_LEFT_PANE] = new TimelinePane(mwindow,
2130 mwindow->theme->mcanvas_x,
2131 mwindow->theme->mcanvas_y +
2133 mwindow->theme->mcanvas_w,
2134 mwindow->theme->mcanvas_h -
2136 pane[TOP_LEFT_PANE]->resize_event(
2137 mwindow->theme->mcanvas_x,
2138 mwindow->theme->mcanvas_y,
2139 mwindow->theme->mcanvas_w,
2140 pane[BOTTOM_LEFT_PANE]->y -
2141 mwindow->theme->mcanvas_y -
2142 mwindow->theme->pane_h);
2143 pane[BOTTOM_LEFT_PANE]->create_objects();
2147 pane[TOP_LEFT_PANE]->resize_event(
2148 mwindow->theme->mcanvas_x,
2149 mwindow->theme->mcanvas_y,
2150 mwindow->theme->mcanvas_w,
2151 cursor_y - mwindow->theme->pane_h);
2152 pane[BOTTOM_LEFT_PANE]->resize_event(
2153 pane[BOTTOM_LEFT_PANE]->x,
2155 mwindow->theme->mcanvas_y,
2156 mwindow->theme->mcanvas_w,
2157 mwindow->theme->mcanvas_h -
2164 if(pane[TOP_RIGHT_PANE]) delete pane[TOP_RIGHT_PANE];
2165 if(pane[BOTTOM_RIGHT_PANE]) delete pane[BOTTOM_RIGHT_PANE];
2166 if(pane[BOTTOM_LEFT_PANE]) delete pane[BOTTOM_LEFT_PANE];
2167 pane[TOP_RIGHT_PANE] = 0;
2168 pane[BOTTOM_RIGHT_PANE] = 0;
2169 pane[BOTTOM_LEFT_PANE] = 0;
2170 pane[TOP_LEFT_PANE]->resize_event(
2171 mwindow->theme->mcanvas_x,
2172 mwindow->theme->mcanvas_y,
2173 mwindow->theme->mcanvas_w,
2174 mwindow->theme->mcanvas_h);
2177 update_pane_dividers();
2180 resource_thread->start_draw();
2183 void MWindowGUI::update_pane_dividers()
2186 if(horizontal_panes() || total_panes() == 4)
2188 int x = pane[TOP_RIGHT_PANE]->x - mwindow->theme->pane_w;
2189 int y = mwindow->theme->mcanvas_y;
2190 int h = mwindow->theme->mcanvas_h;
2194 add_subwindow(x_divider = new PaneDivider(
2195 mwindow, x, y, h, 1));
2196 x_divider->create_objects();
2200 x_divider->reposition_window(x, y, h);
2213 if(vertical_panes() || total_panes() == 4)
2215 int x = mwindow->theme->mcanvas_x;
2216 int y = pane[BOTTOM_LEFT_PANE]->y -
2217 mwindow->theme->pane_h;
2218 int w = mwindow->theme->mcanvas_w;
2221 add_subwindow(y_divider = new PaneDivider(
2222 mwindow, x, y, w, 0));
2223 y_divider->create_objects();
2227 y_divider->reposition_window(x, y, w);
2241 void MWindowGUI::draw_samplemovement()
2248 update_scrollbars(1);
2251 void MWindowGUI::draw_trackmovement()
2253 update_scrollbars(0);
2260 void MWindowGUI::update_mixers(Track *track, int v)
2262 for( int i=0; i<TOTAL_PANES; ++i ) {
2263 if( !pane[i] ) continue;
2264 PatchBay *patchbay = pane[i]->patchbay;
2265 if( !patchbay ) continue;
2266 for( int j=0; j<patchbay->patches.total; ++j ) {
2267 PatchGUI *patchgui = patchbay->patches.values[j];
2268 if( !patchgui->mix ) continue;
2269 if( !track || patchgui->track == track ) {
2270 patchgui->mix->update(v>=0 ? v :
2271 mwindow->mixer_track_active(patchgui->track));
2277 void MWindowGUI::stop_transport(const char *lock_msg)
2279 if( !mbuttons->transport->is_stopped() ) {
2280 if( lock_msg ) unlock_window();
2281 mbuttons->transport->handle_transport(STOP, 1);
2282 if( lock_msg ) lock_window(lock_msg);
2286 PaneButton::PaneButton(MWindow *mwindow, int x, int y)
2287 : BC_Button(x, y, mwindow->theme->get_image_set("pane"))
2289 this->mwindow = mwindow;
2292 int PaneButton::cursor_motion_event()
2294 if(get_top_level()->get_button_down() &&
2296 get_status() == BUTTON_DOWNHI &&
2299 // printf("PaneButton::cursor_motion_event %d\n", __LINE__);
2301 if(get_cursor_x() < 0 && !mwindow->gui->dragging_pane)
2303 mwindow->gui->start_x_pane_drag();
2306 if(get_cursor_y() < 0 && !mwindow->gui->dragging_pane)
2308 mwindow->gui->start_y_pane_drag();
2312 mwindow->gui->handle_pane_drag();
2314 int result = BC_Button::cursor_motion_event();
2318 int PaneButton::button_release_event()
2320 if( get_buttonpress() != WHEEL_DOWN && get_buttonpress() != WHEEL_UP )
2321 mwindow->gui->stop_pane_drag();
2322 int result = BC_Button::button_release_event();
2327 FFMpegToggle::FFMpegToggle(MWindow *mwindow, MButtons *mbuttons, int x, int y)
2328 : BC_Toggle(x, y, mwindow->theme->ffmpeg_toggle,
2329 mwindow->preferences->get_file_probe_armed("FFMPEG_Early") > 0 ? 1 : 0)
2331 this->mwindow = mwindow;
2332 this->mbuttons = mbuttons;
2333 set_tooltip(get_value() ? FFMPEG_EARLY_TIP : FFMPEG_LATE_TIP);
2336 FFMpegToggle::~FFMpegToggle()
2340 int FFMpegToggle::handle_event()
2342 int ffmpeg_early_probe = get_value();
2343 set_tooltip(ffmpeg_early_probe ? FFMPEG_EARLY_TIP : FFMPEG_LATE_TIP);
2344 mwindow->preferences->set_file_probe_armed("FFMPEG_Early", ffmpeg_early_probe);
2345 mwindow->preferences->set_file_probe_armed("FFMPEG_Late", !ffmpeg_early_probe);
2346 mwindow->update_preferences(mwindow->preferences);
2347 mwindow->show_warning(&mwindow->preferences->warn_indexes,
2348 _("Changing the base codecs may require rebuilding indexes."));
2353 StackButton::StackButton(MWindow *mwindow, int x, int y)
2354 : BC_GenericButton(x, y, mwindow->theme->stack_button_w, "0")
2356 this->mwindow = mwindow;
2357 set_tooltip(_("Close EDL"));
2360 int StackButton::handle_event()
2362 mwindow->save_backup();
2363 mwindow->stack_pop();
2367 void StackButton::update()
2369 char text[BCSTRLEN];
2370 int i = mwindow->stack.size();
2371 sprintf(text, "%d", i);
2377 ProxyToggle::ProxyToggle(MWindow *mwindow, MButtons *mbuttons, int x, int y)
2378 : BC_Toggle(x, y, ( !mwindow->edl->session->proxy_use_scaler ?
2379 mwindow->theme->proxy_p_toggle :
2380 mwindow->theme->proxy_s_toggle ),
2381 mwindow->edl->session->proxy_disabled_scale != 1)
2383 this->mwindow = mwindow;
2384 this->mbuttons = mbuttons;
2385 scaler_images = mwindow->edl->session->proxy_use_scaler;
2386 set_tooltip(mwindow->edl->session->proxy_disabled_scale==1 ?
2387 _("Disable proxy") : _("Enable proxy"));
2390 void ProxyToggle::show()
2392 int use_scaler = mwindow->edl->session->proxy_use_scaler;
2393 if( scaler_images != use_scaler )
2394 set_images(!(scaler_images=use_scaler) ?
2395 mwindow->theme->proxy_p_toggle :
2396 mwindow->theme->proxy_s_toggle );
2402 void ProxyToggle::hide()
2408 ProxyToggle::~ProxyToggle()
2412 int ProxyToggle::handle_event()
2414 int disabled = get_value();
2415 mwindow->gui->unlock_window();
2417 mwindow->disable_proxy();
2419 mwindow->enable_proxy();
2420 mwindow->gui->lock_window("ProxyToggle::handle_event");
2421 set_tooltip(!disabled ? _("Disable proxy") : _("Enable proxy"));
2425 int ProxyToggle::keypress_event()
2427 if( ctrl_down() && !shift_down() && !alt_down() ) {
2428 int key = get_keypress();
2430 int value = get_value() ? 0 : 1;
2432 return handle_event();