4 * Copyright (C) 1997-2014 Adam Williams <broadcast at earthling dot net>
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 #include "androidcontrol.h"
23 #include "awindowgui.h"
25 #include "bcdisplayinfo.h"
27 #include "bcsignals.h"
29 #include "cwindowgui.h"
31 #include "channelinfo.h"
34 #include "editpopup.h"
37 #include "edlsession.h"
38 #include "filesystem.h"
40 #include "keyframepopup.h"
43 #include "localsession.h"
44 #include "mainclock.h"
45 #include "maincursor.h"
47 #include "mainsession.h"
51 #include "mwindowgui.h"
53 #include "panedividers.h"
56 #include "pluginpopup.h"
57 #include "pluginset.h"
58 #include "preferences.h"
60 #include "recordgui.h"
61 #include "renderengine.h"
62 #include "resourcethread.h"
63 #include "samplescroll.h"
64 #include "shbtnprefs.h"
65 #include "statusbar.h"
68 #include "trackcanvas.h"
69 #include "trackpopup.h"
70 #include "trackscroll.h"
72 #include "transitionpopup.h"
73 #include "vwindowgui.h"
77 #define PANE_DRAG_MARGIN MAX(mwindow->theme->pane_w, mwindow->theme->pane_h)
80 // the main window uses its own private colormap for video
81 MWindowGUI::MWindowGUI(MWindow *mwindow)
82 : BC_Window(_(PROGRAM_NAME ": Program"),
83 mwindow->session->mwindow_x, mwindow->session->mwindow_y,
84 mwindow->session->mwindow_w, mwindow->session->mwindow_h,
85 xS(100), yS(100), 1, 1, 1)
87 this->mwindow = mwindow;
94 focused_pane = TOP_LEFT_PANE;
103 render_engine_id = -1;
104 for(int i = 0; i < TOTAL_PANES; i++)
124 cwindow_remote_handler = 0;
125 record_remote_handler = 0;
130 MWindowGUI::~MWindowGUI()
132 delete android_control;
133 delete cwindow_remote_handler;
134 delete record_remote_handler;
135 delete remote_control;
136 delete keyvalue_popup;
137 // delete samplescroll;
138 // delete trackscroll;
139 for(int i = 0; i < TOTAL_PANES; i++)
140 if(pane[i]) delete pane[i];
142 delete render_engine;
143 delete resource_thread;
144 resource_pixmaps.remove_all_objects();
154 void MWindowGUI::create_objects()
156 lock_window("MWindowGUI::create_objects");
159 resource_thread = new ResourceThread(mwindow, this);
160 resource_thread->create_objects();
163 if(debug) printf("MWindowGUI::create_objects %d\n", __LINE__);
164 set_icon(mwindow->theme->get_image("mwindow_icon"));
165 remote_control = new RemoteControl(this);
166 cwindow_remote_handler = new CWindowRemoteHandler(remote_control);
167 record_remote_handler = new RecordRemoteHandler(remote_control);
168 mwindow->reset_android_remote();
170 if(debug) printf("MWindowGUI::create_objects %d\n", __LINE__);
172 int x1 = get_w() - MainShBtns::calculate_w(-1, 0, -1) - xS(5);
173 add_subwindow(mainshbtns = new MainShBtns(mwindow, x1, -1));
174 mainshbtns->load(mwindow->preferences);
175 int x2 = x1 - mwindow->theme->stack_button_w - xS(5);
176 add_subwindow(stack_button = new StackButton(mwindow, x2, yS(2)));
177 add_subwindow(mainmenu = new MainMenu(mwindow, this, x2));
178 mainmenu->create_objects();
179 mwindow->theme->get_mwindow_sizes(this, get_w(), get_h());
180 mwindow->theme->draw_mwindow_bg(this);
181 if(debug) printf("MWindowGUI::create_objects %d\n", __LINE__);
183 add_subwindow(mbuttons = new MButtons(mwindow, this));
184 mbuttons->create_objects();
185 int y1 = mbuttons->get_y()+yS(2);
186 add_subwindow(proxy_toggle = new ProxyToggle(mwindow, mbuttons, x2, y1));
187 add_subwindow(ffmpeg_toggle = new FFMpegToggle(mwindow, mbuttons, x1, y1));
189 pane[TOP_LEFT_PANE] = new TimelinePane(mwindow,
191 mwindow->theme->mcanvas_x,
192 mwindow->theme->mcanvas_y,
193 mwindow->theme->mcanvas_w,
194 mwindow->theme->mcanvas_h);
195 pane[TOP_LEFT_PANE]->create_objects();
197 if(debug) printf("MWindowGUI::create_objects %d\n", __LINE__);
198 add_subwindow(zoombar = new ZoomBar(mwindow, this));
199 zoombar->create_objects();
202 if(debug) printf("MWindowGUI::create_objects %d\n", __LINE__);
203 add_subwindow(statusbar = new StatusBar(mwindow, this));
204 statusbar->create_objects();
208 if(debug) printf("MWindowGUI::create_objects %d\n", __LINE__);
209 add_subwindow(mainclock = new MainClock(mwindow,
210 mwindow->theme->mclock_x, mwindow->theme->mclock_y,
211 mwindow->theme->mclock_w));
212 if(debug) printf("MWindowGUI::create_objects %d\n", __LINE__);
213 mainclock->update(0);
217 // if(debug) printf("MWindowGUI::create_objects %d\n", __LINE__);
218 // cursor = new MainCursor(mwindow, this);
219 // cursor->create_objects();
222 if(debug) printf("MWindowGUI::create_objects %d\n", __LINE__);
223 add_subwindow(track_menu = new TrackPopup(mwindow, this));
224 track_menu->create_objects();
225 if(debug) printf("MWindowGUI::create_objects %d\n", __LINE__);
226 add_subwindow(edit_menu = new EditPopup(mwindow, this));
227 edit_menu->create_objects();
230 if(debug) printf("MWindowGUI::create_objects %d\n", __LINE__);
231 add_subwindow(plugin_menu = new PluginPopup(mwindow, this));
232 plugin_menu->create_objects();
235 if(debug) printf("MWindowGUI::create_objects %d\n", __LINE__);
236 add_subwindow(keyframe_menu = new KeyframePopup(mwindow, this));
237 keyframe_menu->create_objects();
238 add_subwindow(keyframe_hide = new KeyframeHidePopup(mwindow, this));
239 keyframe_hide->create_objects();
242 if(debug) printf("MWindowGUI::create_objects %d\n", __LINE__);
243 add_subwindow(transition_menu = new TransitionPopup(mwindow, this));
244 transition_menu->create_objects();
247 channel_info = new ChannelInfo(mwindow);
249 #ifdef HAVE_COMMERCIAL
250 db_window = new DbWindow(mwindow);
252 swindow = new SWindow(mwindow);
254 if(debug) printf("MWindowGUI::create_objects %d\n", __LINE__);
256 add_subwindow(pane_button = new PaneButton(mwindow,
257 get_w() - mwindow->theme->get_image_set("pane")[0]->get_w(),
258 mwindow->theme->mzoom_y + 1 - mwindow->theme->get_image_set("pane")[0]->get_h()));
260 pane[TOP_LEFT_PANE]->canvas->activate();
262 if(debug) printf("MWindowGUI::create_objects %d\n", __LINE__);
266 void MWindowGUI::redraw_time_dependancies()
268 zoombar->redraw_time_dependancies();
269 for(int i = 0; i < TOTAL_PANES; i++)
270 if(pane[i] && pane[i]->timebar) pane[i]->timebar->update(0);
271 mainclock->update(mwindow->edl->local_session->get_selectionstart(1));
274 int MWindowGUI::focus_in_event()
276 for(int i = 0; i < TOTAL_PANES; i++)
277 if(pane[i]) pane[i]->cursor->focus_in_event();
281 int MWindowGUI::focus_out_event()
283 for(int i = 0; i < TOTAL_PANES; i++)
284 if(pane[i]) pane[i]->cursor->focus_out_event();
289 int MWindowGUI::resize_event(int w, int h)
291 //printf("MWindowGUI::resize_event %d\n", __LINE__);
292 mwindow->session->mwindow_w = w;
293 mwindow->session->mwindow_h = h;
294 int x1 = get_w() - MainShBtns::calculate_w(-1, 0, -1) - xS(5);
295 mainshbtns->reposition_window(x1, -1);
296 int x2 = x1 - mwindow->theme->stack_button_w - xS(5);
297 stack_button->reposition_window(x2, stack_button->get_y());
298 mainmenu->resize_event(x2, mainmenu->get_h());
299 mwindow->theme->get_mwindow_sizes(this, w, h);
300 mwindow->theme->draw_mwindow_bg(this);
301 mbuttons->resize_event();
302 int y1 = mbuttons->get_y()+yS(2);
303 proxy_toggle->reposition_window(x2, y1);
304 ffmpeg_toggle->reposition_window(x1, y1);
305 statusbar->resize_event();
306 zoombar->resize_event();
308 resource_thread->stop_draw(1);
310 if(total_panes() > 1)
312 if(horizontal_panes())
314 // printf("MWindowGUI::resize_event %d %d %d\n",
316 // pane[TOP_RIGHT_PANE]->x,
317 // mwindow->theme->mcanvas_w -
318 // BC_ScrollBar::get_span(SCROLL_VERT) -
319 // PANE_DRAG_MARGIN);
320 if(pane[TOP_RIGHT_PANE]->x >= mwindow->theme->mcanvas_w -
321 BC_ScrollBar::get_span(SCROLL_VERT) -
324 delete_x_pane(pane[TOP_RIGHT_PANE]->x);
325 mwindow->edl->local_session->x_pane = -1;
331 if(pane[BOTTOM_LEFT_PANE]->y >= mwindow->theme->mzoom_y -
332 BC_ScrollBar::get_span(SCROLL_HORIZ) -
335 delete_y_pane(pane[BOTTOM_LEFT_PANE]->y);
336 mwindow->edl->local_session->y_pane = -1;
341 if(pane[TOP_RIGHT_PANE]->x >= mwindow->theme->mcanvas_w -
342 BC_ScrollBar::get_span(SCROLL_VERT) -
345 delete_x_pane(pane[TOP_RIGHT_PANE]->x);
346 mwindow->edl->local_session->x_pane = -1;
349 if(pane[BOTTOM_LEFT_PANE]->y >= mwindow->theme->mzoom_y -
350 BC_ScrollBar::get_span(SCROLL_HORIZ) -
353 delete_y_pane(pane[BOTTOM_LEFT_PANE]->y);
354 mwindow->edl->local_session->y_pane = -1;
359 if(total_panes() == 1)
361 pane[TOP_LEFT_PANE]->resize_event(
362 mwindow->theme->mcanvas_x,
363 mwindow->theme->mcanvas_y,
364 mwindow->theme->mcanvas_w,
365 mwindow->theme->mcanvas_h);
368 if(horizontal_panes())
370 pane[TOP_LEFT_PANE]->resize_event(
371 pane[TOP_LEFT_PANE]->x,
372 pane[TOP_LEFT_PANE]->y,
373 pane[TOP_LEFT_PANE]->w,
374 mwindow->theme->mcanvas_h);
375 pane[TOP_RIGHT_PANE]->resize_event(
376 pane[TOP_RIGHT_PANE]->x,
377 pane[TOP_RIGHT_PANE]->y,
378 mwindow->theme->mcanvas_w - pane[TOP_RIGHT_PANE]->x,
379 mwindow->theme->mcanvas_h);
384 pane[TOP_LEFT_PANE]->resize_event(
385 pane[TOP_LEFT_PANE]->x,
386 pane[TOP_LEFT_PANE]->y,
387 mwindow->theme->mcanvas_w,
388 pane[TOP_LEFT_PANE]->h);
389 pane[BOTTOM_LEFT_PANE]->resize_event(
390 pane[BOTTOM_LEFT_PANE]->x,
391 pane[BOTTOM_LEFT_PANE]->y,
392 mwindow->theme->mcanvas_w,
393 mwindow->theme->mcanvas_y +
394 mwindow->theme->mcanvas_h -
395 pane[BOTTOM_LEFT_PANE]->y);
399 pane[TOP_LEFT_PANE]->resize_event(
400 pane[TOP_LEFT_PANE]->x,
401 pane[TOP_LEFT_PANE]->y,
402 pane[TOP_LEFT_PANE]->w,
403 pane[TOP_LEFT_PANE]->h);
404 pane[TOP_RIGHT_PANE]->resize_event(
405 pane[TOP_RIGHT_PANE]->x,
406 pane[TOP_RIGHT_PANE]->y,
407 mwindow->theme->mcanvas_w - pane[TOP_RIGHT_PANE]->x,
408 pane[TOP_RIGHT_PANE]->h);
409 pane[BOTTOM_LEFT_PANE]->resize_event(
410 pane[BOTTOM_LEFT_PANE]->x,
411 pane[BOTTOM_LEFT_PANE]->y,
412 pane[BOTTOM_LEFT_PANE]->w,
413 mwindow->theme->mcanvas_y +
414 mwindow->theme->mcanvas_h -
415 pane[BOTTOM_LEFT_PANE]->y);
416 pane[BOTTOM_RIGHT_PANE]->resize_event(
417 pane[BOTTOM_RIGHT_PANE]->x,
418 pane[BOTTOM_RIGHT_PANE]->y,
419 mwindow->theme->mcanvas_w -
420 pane[BOTTOM_RIGHT_PANE]->x,
421 mwindow->theme->mcanvas_y +
422 mwindow->theme->mcanvas_h -
423 pane[BOTTOM_RIGHT_PANE]->y);
426 update_pane_dividers();
427 pane_button->reposition_window(w - mwindow->theme->get_image_set("pane")[0]->get_w(),
428 mwindow->theme->mzoom_y + 1 - mwindow->theme->get_image_set("pane")[0]->get_h());
429 resource_thread->start_draw();
435 int MWindowGUI::total_panes()
438 for(int i = 0; i < TOTAL_PANES; i++)
443 int MWindowGUI::vertical_panes()
445 return total_panes() == 2 &&
446 pane[TOP_LEFT_PANE] &&
447 pane[BOTTOM_LEFT_PANE];
450 int MWindowGUI::horizontal_panes()
452 return total_panes() == 2 &&
453 pane[TOP_LEFT_PANE] &&
454 pane[TOP_RIGHT_PANE];
457 TimelinePane* MWindowGUI::get_focused_pane()
459 if(pane[focused_pane]) return pane[focused_pane];
460 for(int i = 0; i < TOTAL_PANES; i++)
462 if(pane[i]) return pane[i];
467 void MWindowGUI::activate_timeline()
469 if(pane[focused_pane])
471 pane[focused_pane]->activate();
475 for(int i = 0; i < TOTAL_PANES; i++)
486 void MWindowGUI::deactivate_timeline()
488 for(int i = 0; i < TOTAL_PANES; i++)
492 pane[i]->canvas->deactivate();
497 void MWindowGUI::update_title(char *path)
500 char filename[BCTEXTLEN], string[BCTEXTLEN];
501 fs.extract_name(filename, path);
502 sprintf(string, _(PROGRAM_NAME ": %s"), filename);
504 //printf("MWindowGUI::update_title %s\n", string);
508 void MWindowGUI::draw_overlays(int flash_it)
510 for(int i = 0; i < TOTAL_PANES; i++)
514 pane[i]->canvas->draw_overlays();
515 if(flash_it) pane[i]->canvas->flash();
520 void MWindowGUI::update_timebar(int flush_it)
522 for(int i = 0; i < TOTAL_PANES; i++)
524 if(pane[i] && pane[i]->timebar)
526 pane[i]->timebar->update(flush_it);
531 void MWindowGUI::update_timebar_highlights()
533 for(int i = 0; i < TOTAL_PANES; i++)
535 if(pane[i] && pane[i]->timebar)
537 pane[i]->timebar->update_highlights();
543 void MWindowGUI::update_patchbay()
545 for(int i = 0; i < TOTAL_PANES; i++)
547 if(pane[i] && pane[i]->patchbay)
549 pane[i]->patchbay->update();
554 void MWindowGUI::update_proxy_toggle()
556 int value = mwindow->edl->session->proxy_scale == 1 ? 1 : 0;
557 proxy_toggle->set_value(value);
558 if( mwindow->edl->session->proxy_scale == 1 &&
559 mwindow->edl->session->proxy_disabled_scale == 1 )
560 proxy_toggle->hide();
562 proxy_toggle->show();
565 void MWindowGUI::update_plugintoggles()
567 for(int i = 0; i < TOTAL_PANES; i++)
571 pane[i]->canvas->refresh_plugintoggles();
577 void MWindowGUI::draw_indexes(Indexable *indexable)
579 for(int i = 0; i < TOTAL_PANES; i++)
583 pane[i]->canvas->draw_indexes(indexable);
588 void MWindowGUI::draw_canvas(int redraw, int hide_cursor)
590 resource_thread->stop_draw(0);
592 int mode = redraw ? FORCE_REDRAW : NORMAL_DRAW;
593 for(int i = 0; i < TOTAL_PANES; i++) {
595 pane[i]->canvas->draw(mode, hide_cursor);
598 resource_thread->start_draw();
601 void MWindowGUI::flash_canvas(int flush)
603 for(int i = 0; i < TOTAL_PANES; i++)
607 pane[i]->canvas->flash(flush);
612 int MWindowGUI::show_window(int flush)
614 int ret = BC_WindowBase::show_window(flush);
615 stack_button->update();
616 update_proxy_toggle();
620 void MWindowGUI::draw_cursor(int do_plugintoggles)
622 for(int i = 0; i < TOTAL_PANES; i++)
626 pane[i]->cursor->draw(do_plugintoggles);
631 void MWindowGUI::show_cursor(int do_plugintoggles)
633 for(int i = 0; i < TOTAL_PANES; i++)
637 pane[i]->cursor->show(do_plugintoggles);
642 void MWindowGUI::hide_cursor(int do_plugintoggles)
644 for(int i = 0; i < TOTAL_PANES; i++)
648 pane[i]->cursor->hide(do_plugintoggles);
653 void MWindowGUI::update_cursor()
655 for(int i = 0; i < TOTAL_PANES; i++)
659 pane[i]->cursor->update();
664 void MWindowGUI::set_playing_back(int value)
666 for(int i = 0; i < TOTAL_PANES; i++)
670 pane[i]->cursor->playing_back = value;
675 void MWindowGUI::update_scrollbars(int flush)
677 for(int i = 0; i < TOTAL_PANES; i++)
681 pane[i]->update(1, NO_DRAW, 0, 0);
684 if(flush) this->flush();
687 void MWindowGUI::reset_meters()
689 for(int i = 0; i < TOTAL_PANES; i++)
691 if(pane[i] && pane[i]->patchbay)
693 pane[i]->patchbay->reset_meters();
698 void MWindowGUI::stop_meters()
700 for(int i = 0; i < TOTAL_PANES; i++)
702 if(pane[i] && pane[i]->patchbay)
704 pane[i]->patchbay->stop_meters();
709 void MWindowGUI::update_meters(ArrayList<double> *module_levels)
711 for(int i = 0; i < TOTAL_PANES; i++)
713 if(pane[i] && pane[i]->patchbay)
715 pane[i]->patchbay->update_meters(module_levels);
720 void MWindowGUI::set_editing_mode(int flush)
722 for(int i = 0; i < TOTAL_PANES; i++)
726 pane[i]->canvas->update_cursor(flush);
731 void MWindowGUI::set_meter_format(int mode, int min, int max)
733 for(int i = 0; i < TOTAL_PANES; i++)
735 if(pane[i] && pane[i]->patchbay)
737 pane[i]->patchbay->set_meter_format(mode, min, max);
742 void MWindowGUI::update(int scrollbars,
751 if(debug) PRINT_TRACE
755 mwindow->edl->tracks->update_y_pixels(mwindow->theme);
757 if( do_canvas != NO_DRAW && do_canvas != IGNORE_THREAD )
758 resource_thread->stop_draw(1);
760 for(int i = 0; i < TOTAL_PANES; i++)
762 if(pane[i]) pane[i]->update(scrollbars,
768 if( do_canvas != NO_DRAW && do_canvas != IGNORE_THREAD )
769 resource_thread->start_draw();
771 // if(scrollbars) this->get_scrollbars(0);
772 // if(timebar) this->timebar->update(0);
773 if(zoombar) this->zoombar->update();
774 // if(patchbay) this->patchbay->update();
775 if(clock) this->mainclock->update(
776 mwindow->edl->local_session->get_selectionstart(1));
777 if(debug) PRINT_TRACE
783 // this->canvas->draw(do_canvas);
784 // this->cursor->show();
785 // this->canvas->flash(0);
786 // Activate causes the menubar to deactivate. Don't want this for
788 // if(canvas != IGNORE_THREAD) this->canvas->activate();
790 if(debug) PRINT_TRACE
794 if(buttonbar) mbuttons->update();
795 if(debug) PRINT_TRACE
797 // Can't age if the cache called this to draw missing picons
798 // or the GUI is updating the status of the draw toggle.
799 if( do_canvas != FORCE_REDRAW && do_canvas != IGNORE_THREAD ) {
801 mwindow->age_caches();
802 lock_window("MWindowGUI::update");
806 if(debug) PRINT_TRACE
809 int MWindowGUI::visible(int64_t x1, int64_t x2, int64_t view_x1, int64_t view_x2)
811 return (x1 >= view_x1 && x1 < view_x2) ||
812 (x2 > view_x1 && x2 <= view_x2) ||
813 (x1 <= view_x1 && x2 >= view_x2);
817 void MWindowGUI::show_message(const char *message, int msg_color, int bar_color)
819 statusbar->show_message(message, msg_color, bar_color);
822 void MWindowGUI::update_default_message()
824 statusbar->update_default_message();
827 void MWindowGUI::reset_default_message()
829 statusbar->reset_default_message();
832 void MWindowGUI::default_message()
834 statusbar->default_message();
837 // Drag motion called from other window
838 int MWindowGUI::drag_motion()
840 if(get_hidden()) return 0;
842 Track *over_track = 0;
844 PluginSet *over_pluginset = 0;
845 Plugin *over_plugin = 0;
850 drag_popup->cursor_motion_event();
854 // there's no point in drawing highlights has until drag operation has been set
855 if (!mwindow->session->current_operation)
858 for(int i = 0; i < TOTAL_PANES; i++)
860 if(pane[i]) pane[i]->canvas->drag_motion(
867 if(mwindow->session->track_highlighted != over_track)
869 mwindow->session->track_highlighted = over_track;
873 if(mwindow->session->edit_highlighted != over_edit)
875 mwindow->session->edit_highlighted = over_edit;
879 if(mwindow->session->pluginset_highlighted != over_pluginset)
881 mwindow->session->pluginset_highlighted = over_pluginset;
885 if(mwindow->session->plugin_highlighted != over_plugin)
887 mwindow->session->plugin_highlighted = over_plugin;
891 if( mwindow->session->current_operation == DRAG_ASSET ||
892 mwindow->session->current_operation == DRAG_EDIT ||
893 mwindow->session->current_operation == DRAG_GROUP ||
894 mwindow->session->current_operation == DRAG_AEFFECT_COPY ||
895 mwindow->session->current_operation == DRAG_VEFFECT_COPY ) {
900 // printf("drag_motion %d %d over_track=%p over_edit=%p\n",
907 lock_window("MWindowGUI::drag_motion");
914 int MWindowGUI::drag_stop()
916 if(get_hidden()) return 0;
917 int result = 0, redraw = 0;
919 for(int i = 0; i < TOTAL_PANES; i++)
921 if(pane[i]) result |= pane[i]->canvas->drag_stop(
924 mwindow->edl->optimize();
926 // since we don't have subwindows we have to terminate any drag operation
929 if (mwindow->session->track_highlighted
930 || mwindow->session->edit_highlighted
931 || mwindow->session->plugin_highlighted
932 || mwindow->session->pluginset_highlighted)
934 mwindow->session->track_highlighted = 0;
935 mwindow->session->edit_highlighted = 0;
936 mwindow->session->plugin_highlighted = 0;
937 mwindow->session->pluginset_highlighted = 0;
938 mwindow->session->current_operation = NO_OPERATION;
942 //printf("MWindowGUI::drag_stop %d %d\n", redraw, mwindow->session->current_operation);
945 mwindow->edl->tracks->update_y_pixels(mwindow->theme);
946 update_scrollbars(0);
961 void MWindowGUI::default_positions()
963 //printf("MWindowGUI::default_positions 1\n");
964 VWindow *vwindow = mwindow->vwindows.size() > DEFAULT_VWINDOW ?
965 mwindow->vwindows.get(DEFAULT_VWINDOW) : 0;
966 if( vwindow && !vwindow->is_running() ) vwindow = 0;
967 if( vwindow ) vwindow->gui->lock_window("MWindowGUI::default_positions");
968 mwindow->cwindow->gui->lock_window("MWindowGUI::default_positions");
969 mwindow->awindow->gui->lock_window("MWindowGUI::default_positions");
971 // printf("MWindowGUI::default_positions 1 %d %d %d %d\n", mwindow->session->vwindow_x,
972 // mwindow->session->vwindow_y,
973 // mwindow->session->vwindow_w,
974 // mwindow->session->vwindow_h);
975 reposition_window(mwindow->session->mwindow_x,
976 mwindow->session->mwindow_y,
977 mwindow->session->mwindow_w,
978 mwindow->session->mwindow_h);
979 if( vwindow ) vwindow->gui->reposition_window(mwindow->session->vwindow_x,
980 mwindow->session->vwindow_y,
981 mwindow->session->vwindow_w,
982 mwindow->session->vwindow_h);
983 mwindow->cwindow->gui->reposition_window(mwindow->session->cwindow_x,
984 mwindow->session->cwindow_y,
985 mwindow->session->cwindow_w,
986 mwindow->session->cwindow_h);
987 mwindow->awindow->gui->reposition_window(mwindow->session->awindow_x,
988 mwindow->session->awindow_y,
989 mwindow->session->awindow_w,
990 mwindow->session->awindow_h);
991 //printf("MWindowGUI::default_positions 1\n");
993 resize_event(mwindow->session->mwindow_w,
994 mwindow->session->mwindow_h);
995 //printf("MWindowGUI::default_positions 1\n");
996 if( vwindow ) vwindow->gui->resize_event(mwindow->session->vwindow_w,
997 mwindow->session->vwindow_h);
998 //printf("MWindowGUI::default_positions 1\n");
999 mwindow->cwindow->gui->resize_event(mwindow->session->cwindow_w,
1000 mwindow->session->cwindow_h);
1001 //printf("MWindowGUI::default_positions 1\n");
1002 mwindow->awindow->gui->resize_event(mwindow->session->awindow_w,
1003 mwindow->session->awindow_h);
1005 //printf("MWindowGUI::default_positions 1\n");
1008 if( vwindow ) vwindow->gui->flush();
1009 mwindow->cwindow->gui->flush();
1010 mwindow->awindow->gui->flush();
1012 if( vwindow ) vwindow->gui->unlock_window();
1013 mwindow->cwindow->gui->unlock_window();
1014 mwindow->awindow->gui->unlock_window();
1015 //printf("MWindowGUI::default_positions 2\n");
1019 int MWindowGUI::repeat_event(int64_t duration)
1021 // if(duration == 100)
1022 // mwindow->sync_parameters(CHANGE_ALL);
1024 for(int i = 0; i < TOTAL_PANES; i++)
1026 if(pane[i]) result = pane[i]->cursor->repeat_event(duration);
1032 int MWindowGUI::translation_event()
1034 //printf("MWindowGUI::translation_event 1 %d %d\n", get_x(), get_y());
1035 mwindow->session->mwindow_x = get_x();
1036 mwindow->session->mwindow_y = get_y();
1041 int MWindowGUI::save_defaults(BC_Hash *defaults)
1043 defaults->update("MWINDOWWIDTH", get_w());
1044 defaults->update("MWINDOWHEIGHT", get_h());
1045 mainmenu->save_defaults(defaults);
1046 BC_WindowBase::save_defaults(defaults);
1050 int MWindowGUI::keypress_event()
1052 //printf("MWindowGUI::keypress_event 1 %d\n", get_keypress());
1053 int result = mbuttons->keypress_event();
1054 if( result ) return result;
1056 Track *this_track = 0, *first_track = 0;
1057 int collapse = 0, packed = 0, overwrite = 0, plugins = 0;
1058 double position = 0;
1060 switch( get_keypress() ) {
1062 if( !ctrl_down() || !shift_down() || alt_down() ) break;
1063 mwindow->edl->tracks->clear_selected_edits();
1068 mwindow->toggle_editing_mode();
1073 if( alt_down() ) break;
1074 stop_transport("MWindowGUI::keypress_event 1");
1075 mwindow->nearest_plugin_keyframe(shift_down(),
1076 !ctrl_down() ? PLAY_FORWARD : PLAY_REVERSE);
1083 if( !ctrl_down() || alt_down() ) break;
1084 mwindow->selected_edits_to_clipboard(packed);
1090 overwrite = -1; // fall thru
1092 if( !ctrl_down() || alt_down() ) break;
1093 if( mwindow->session->current_operation == DROP_TARGETING ) {
1094 mwindow->session->current_operation = NO_OPERATION;
1095 mwindow->gui->set_editing_mode(1);
1097 for( ; pane_no<TOTAL_PANES; ++pane_no ) {
1098 if( !pane[pane_no] ) continue;
1099 first_track = pane[pane_no]->over_track();
1100 if( first_track ) break;
1103 int cursor_x = pane[pane_no]->canvas->get_relative_cursor_x();
1104 position = mwindow->edl->get_cursor_position(cursor_x, pane_no);
1108 position = mwindow->edl->local_session->get_selectionstart();
1110 mwindow->paste(position, first_track, 0, overwrite);
1112 mwindow->paste_clipboard(first_track, position, 1, 0, 1, 1, 1);
1113 mwindow->edl->tracks->clear_selected_edits();
1121 mwindow->cut_selected_edits(0, collapse);
1127 if( !ctrl_down() || alt_down() ) break;
1128 mwindow->cut_selected_edits(1, collapse);
1133 if( !alt_down() || shift_down() ) break;
1134 if( !mwindow->select_asset(get_keypress()-'1',1) )
1139 if( !ctrl_down() ) {
1141 stop_transport("MWindowGUI::keypress_event 1");
1142 mwindow->prev_edit_handle(shift_down());
1145 mwindow->move_left();
1151 if( !ctrl_down() && !alt_down() ) {
1152 mwindow->move_left();
1158 if( !ctrl_down() ) {
1160 stop_transport("MWindowGUI::keypress_event 2");
1161 mwindow->next_edit_handle(shift_down());
1164 mwindow->move_right();
1170 if( !ctrl_down() && !alt_down() ) {
1171 mwindow->move_right();
1177 if( ctrl_down() && !alt_down() )
1178 mwindow->expand_y();
1179 else if( !ctrl_down() && alt_down() )
1180 mwindow->expand_autos(0,1,1);
1181 else if( ctrl_down() && alt_down() )
1182 mwindow->expand_autos(1,1,1);
1184 mwindow->expand_sample();
1189 if( ctrl_down() && !alt_down() )
1190 mwindow->zoom_in_y();
1191 else if( !ctrl_down() && alt_down() )
1192 mwindow->shrink_autos(0,1,1);
1193 else if( ctrl_down() && alt_down() )
1194 mwindow->shrink_autos(1,1,1);
1196 mwindow->zoom_in_sample();
1204 mwindow->expand_t();
1210 mwindow->move_down();
1212 mwindow->zoom_in_t();
1218 for( int i=0; i<TOTAL_PANES; ++i ) {
1219 if( !pane[i] ) continue;
1220 if( (this_track = pane[i]->over_track()) != 0 ) break;
1221 if( (this_track = pane[i]->over_patchbay()) != 0 ) break;
1224 if( get_keypress() == TAB ) { // Switch the record button
1226 this_track->record = !this_track->record ? 1 : 0;
1229 int total_selected = mwindow->edl->tracks->total_of(Tracks::RECORD);
1230 // all selected if nothing previously selected or
1231 // if this patch was previously the only one selected and armed
1232 int selected = !total_selected || (total_selected == 1 &&
1233 this_track && this_track->record ) ? 1 : 0;
1234 mwindow->edl->tracks->select_all(Tracks::RECORD, selected);
1235 if( !selected && this_track ) this_track->record = 1;
1238 update(0, NORMAL_DRAW, 0, 0, 1, 0, 1);
1240 mwindow->cwindow->update(0, 1, 1);
1241 lock_window("MWindowGUI::keypress_event 3");
1246 case KEY_F1 ... KEY_F12:
1247 resend_event(mwindow->cwindow->gui);
1251 // since things under cursor have changed...
1253 cursor_motion_event();
1258 int MWindowGUI::keyboard_listener(BC_WindowBase *wp)
1260 return key_listener(wp->get_keypress());
1263 int MWindowGUI::key_listener(int key)
1268 if( !record->running() )
1271 record->record_gui->interrupt_thread->start(0);
1278 channel_info->toggle_scan();
1282 if( !remote_control->deactivate() )
1283 remote_control->activate();
1293 void MWindowGUI::use_android_remote(int on)
1296 delete android_control;
1297 android_control = 0;
1300 if( android_control ) return;
1301 android_control = new AndroidControl(this);
1304 int MWindowGUI::close_event()
1310 void MWindowGUI::stop_drawing()
1312 resource_thread->stop_draw(1);
1315 int MWindowGUI::menu_w()
1317 return mainmenu->get_w();
1320 int MWindowGUI::menu_h()
1322 return mainmenu->get_h();
1325 void MWindowGUI::start_x_pane_drag()
1329 x_pane_drag = new BC_Popup(this,
1330 get_abs_cursor_x(0) - mwindow->theme->pane_w,
1331 BC_DisplayInfo::get_top_border() +
1333 mwindow->theme->mcanvas_y,
1334 mwindow->theme->pane_w,
1335 mwindow->theme->mcanvas_h,
1336 mwindow->theme->drag_pane_color);
1337 x_pane_drag->draw_3segmentv(0,
1339 x_pane_drag->get_h(),
1340 mwindow->theme->get_image_set("xpane")[BUTTON_DOWNHI]);
1341 x_pane_drag->flash(1);
1346 void MWindowGUI::start_y_pane_drag()
1350 //printf("MWindowGUI::start_y_pane_drag %d %d %d\n", __LINE__, get_x(), get_y());
1351 y_pane_drag = new BC_Popup(this,
1352 BC_DisplayInfo::get_left_border() +
1354 mwindow->theme->mcanvas_x,
1355 get_abs_cursor_y(0) - mwindow->theme->pane_h,
1356 mwindow->theme->mcanvas_w,
1357 mwindow->theme->pane_h,
1358 mwindow->theme->drag_pane_color);
1359 y_pane_drag->draw_3segmenth(0,
1361 y_pane_drag->get_w(),
1362 mwindow->theme->get_image_set("ypane")[BUTTON_DOWNHI]);
1363 y_pane_drag->flash(1);
1368 void MWindowGUI::handle_pane_drag()
1374 x_pane_drag->reposition_window(
1375 get_abs_cursor_x(0) - mwindow->theme->pane_w,
1376 x_pane_drag->get_y());
1381 y_pane_drag->reposition_window(
1382 y_pane_drag->get_x(),
1383 get_abs_cursor_y(0) - mwindow->theme->pane_h);
1389 void MWindowGUI::create_x_pane(int cursor_x)
1391 if(total_panes() == 1)
1393 // create a horizontal pane
1394 // do this 1st so the resize_event knows there are 2 panes
1395 mwindow->edl->local_session->view_start[TOP_RIGHT_PANE] =
1396 mwindow->edl->local_session->view_start[TOP_LEFT_PANE] +
1398 mwindow->theme->patchbay_w;
1399 pane[TOP_RIGHT_PANE] = new TimelinePane(mwindow,
1401 mwindow->theme->mcanvas_x +
1403 mwindow->theme->mcanvas_y,
1404 mwindow->theme->mcanvas_x +
1405 mwindow->theme->mcanvas_w -
1407 mwindow->theme->mcanvas_h);
1408 pane[TOP_LEFT_PANE]->resize_event(
1409 mwindow->theme->mcanvas_x,
1410 mwindow->theme->mcanvas_y,
1411 cursor_x - mwindow->theme->pane_w,
1412 mwindow->theme->mcanvas_h);
1413 pane[TOP_RIGHT_PANE]->create_objects();
1416 if(vertical_panes())
1418 // create 2 horizontal panes
1419 mwindow->edl->local_session->track_start[TOP_RIGHT_PANE] =
1420 mwindow->edl->local_session->track_start[TOP_LEFT_PANE];
1421 mwindow->edl->local_session->track_start[BOTTOM_RIGHT_PANE] =
1422 mwindow->edl->local_session->track_start[BOTTOM_LEFT_PANE];
1423 mwindow->edl->local_session->view_start[TOP_RIGHT_PANE] =
1424 mwindow->edl->local_session->view_start[BOTTOM_RIGHT_PANE] =
1425 mwindow->edl->local_session->view_start[TOP_LEFT_PANE] +
1427 mwindow->theme->patchbay_w;
1428 pane[TOP_RIGHT_PANE] = new TimelinePane(mwindow,
1430 mwindow->theme->mcanvas_x +
1432 pane[TOP_LEFT_PANE]->y,
1433 mwindow->theme->mcanvas_x +
1434 mwindow->theme->mcanvas_w -
1436 pane[TOP_LEFT_PANE]->h);
1437 pane[BOTTOM_RIGHT_PANE] = new TimelinePane(mwindow,
1439 mwindow->theme->mcanvas_x +
1441 pane[BOTTOM_LEFT_PANE]->y,
1442 mwindow->theme->mcanvas_x +
1443 mwindow->theme->mcanvas_w -
1445 pane[BOTTOM_LEFT_PANE]->h);
1446 pane[TOP_LEFT_PANE]->resize_event(
1447 pane[TOP_LEFT_PANE]->x,
1448 pane[TOP_LEFT_PANE]->y,
1449 cursor_x - mwindow->theme->pane_w,
1450 pane[TOP_LEFT_PANE]->h);
1451 pane[BOTTOM_LEFT_PANE]->resize_event(
1452 pane[BOTTOM_LEFT_PANE]->x,
1453 pane[BOTTOM_LEFT_PANE]->y,
1454 cursor_x - mwindow->theme->pane_w,
1455 pane[BOTTOM_LEFT_PANE]->h);
1456 pane[TOP_RIGHT_PANE]->create_objects();
1457 pane[BOTTOM_RIGHT_PANE]->create_objects();
1460 if(horizontal_panes())
1462 // resize a horizontal pane
1463 mwindow->edl->local_session->view_start[TOP_RIGHT_PANE] +=
1465 pane[TOP_RIGHT_PANE]->x;
1466 if(mwindow->edl->local_session->view_start[TOP_RIGHT_PANE] < 0)
1467 mwindow->edl->local_session->view_start[TOP_RIGHT_PANE] = 0;
1468 pane[TOP_LEFT_PANE]->resize_event(
1469 mwindow->theme->mcanvas_x,
1470 mwindow->theme->mcanvas_y,
1471 cursor_x - mwindow->theme->pane_w,
1472 mwindow->theme->mcanvas_h);
1473 pane[TOP_RIGHT_PANE]->resize_event(
1474 mwindow->theme->mcanvas_x +
1476 pane[TOP_RIGHT_PANE]->y,
1477 mwindow->theme->mcanvas_x +
1478 mwindow->theme->mcanvas_w -
1480 mwindow->theme->mcanvas_h);
1484 // resize 2 horizontal panes
1485 mwindow->edl->local_session->view_start[TOP_RIGHT_PANE] +=
1487 pane[TOP_RIGHT_PANE]->x;
1488 if(mwindow->edl->local_session->view_start[TOP_RIGHT_PANE] < 0)
1489 mwindow->edl->local_session->view_start[TOP_RIGHT_PANE] = 0;
1490 mwindow->edl->local_session->view_start[BOTTOM_RIGHT_PANE] =
1491 mwindow->edl->local_session->view_start[TOP_RIGHT_PANE];
1493 pane[TOP_LEFT_PANE]->resize_event(
1494 mwindow->theme->mcanvas_x,
1495 pane[TOP_LEFT_PANE]->y,
1496 cursor_x - mwindow->theme->pane_w,
1497 pane[TOP_LEFT_PANE]->h);
1498 pane[TOP_RIGHT_PANE]->resize_event(
1499 mwindow->theme->mcanvas_x +
1501 pane[TOP_RIGHT_PANE]->y,
1502 mwindow->theme->mcanvas_x +
1503 mwindow->theme->mcanvas_w -
1505 pane[TOP_RIGHT_PANE]->h);
1506 pane[BOTTOM_LEFT_PANE]->resize_event(
1507 mwindow->theme->mcanvas_x,
1508 pane[BOTTOM_LEFT_PANE]->y,
1509 cursor_x - mwindow->theme->pane_w,
1510 pane[BOTTOM_LEFT_PANE]->h);
1511 pane[BOTTOM_RIGHT_PANE]->resize_event(
1512 mwindow->theme->mcanvas_x +
1514 pane[BOTTOM_RIGHT_PANE]->y,
1515 mwindow->theme->mcanvas_x +
1516 mwindow->theme->mcanvas_w -
1518 pane[BOTTOM_RIGHT_PANE]->h);
1524 void MWindowGUI::delete_x_pane(int cursor_x)
1526 // give left panes coordinates of right pane
1527 if(cursor_x < mwindow->theme->patchbay_w + PANE_DRAG_MARGIN &&
1528 pane[TOP_RIGHT_PANE])
1530 mwindow->edl->local_session->view_start[TOP_LEFT_PANE] =
1531 mwindow->edl->local_session->view_start[TOP_RIGHT_PANE] -
1532 pane[TOP_RIGHT_PANE]->x + mwindow->theme->patchbay_w;
1533 if(mwindow->edl->local_session->view_start[TOP_LEFT_PANE] < 0)
1534 mwindow->edl->local_session->view_start[TOP_LEFT_PANE] = 0;
1535 mwindow->edl->local_session->view_start[BOTTOM_LEFT_PANE] =
1536 mwindow->edl->local_session->view_start[TOP_LEFT_PANE];
1539 switch(total_panes())
1542 if(pane[TOP_LEFT_PANE] && pane[TOP_RIGHT_PANE])
1544 // delete right pane
1545 delete pane[TOP_RIGHT_PANE];
1546 pane[TOP_RIGHT_PANE] = 0;
1547 pane[TOP_LEFT_PANE]->resize_event(
1548 mwindow->theme->mcanvas_x,
1549 mwindow->theme->mcanvas_y,
1550 mwindow->theme->mcanvas_w,
1551 mwindow->theme->mcanvas_h);
1557 // delete right panes
1558 delete pane[TOP_RIGHT_PANE];
1559 pane[TOP_RIGHT_PANE] = 0;
1560 delete pane[BOTTOM_RIGHT_PANE];
1561 pane[BOTTOM_RIGHT_PANE] = 0;
1562 pane[TOP_LEFT_PANE]->resize_event(
1563 mwindow->theme->mcanvas_x,
1564 pane[TOP_LEFT_PANE]->y,
1565 mwindow->theme->mcanvas_w,
1566 pane[TOP_LEFT_PANE]->h);
1567 pane[BOTTOM_LEFT_PANE]->resize_event(
1568 mwindow->theme->mcanvas_x,
1569 pane[BOTTOM_LEFT_PANE]->y,
1570 mwindow->theme->mcanvas_w,
1571 pane[BOTTOM_LEFT_PANE]->h);
1576 void MWindowGUI::create_y_pane(int cursor_y)
1578 if(total_panes() == 1)
1580 mwindow->edl->local_session->view_start[BOTTOM_LEFT_PANE] =
1581 mwindow->edl->local_session->view_start[TOP_LEFT_PANE];
1582 mwindow->edl->local_session->track_start[BOTTOM_LEFT_PANE] =
1583 mwindow->edl->local_session->track_start[TOP_LEFT_PANE] +
1585 mwindow->theme->mtimebar_h;
1586 // do this 1st so the resize_event knows there are 2 panes
1587 pane[BOTTOM_LEFT_PANE] = new TimelinePane(mwindow,
1589 mwindow->theme->mcanvas_x,
1590 mwindow->theme->mcanvas_y +
1592 mwindow->theme->mcanvas_w,
1593 mwindow->theme->mcanvas_h -
1595 pane[TOP_LEFT_PANE]->resize_event(
1596 mwindow->theme->mcanvas_x,
1597 mwindow->theme->mcanvas_y,
1598 mwindow->theme->mcanvas_w,
1599 pane[BOTTOM_LEFT_PANE]->y -
1600 mwindow->theme->mcanvas_y -
1601 mwindow->theme->pane_h);
1602 pane[BOTTOM_LEFT_PANE]->create_objects();
1605 if(horizontal_panes())
1608 mwindow->edl->local_session->view_start[BOTTOM_LEFT_PANE] =
1609 mwindow->edl->local_session->view_start[TOP_LEFT_PANE];
1610 mwindow->edl->local_session->view_start[BOTTOM_RIGHT_PANE] =
1611 mwindow->edl->local_session->view_start[TOP_RIGHT_PANE];
1612 mwindow->edl->local_session->track_start[BOTTOM_LEFT_PANE] =
1613 mwindow->edl->local_session->track_start[BOTTOM_RIGHT_PANE] =
1614 mwindow->edl->local_session->track_start[TOP_LEFT_PANE] +
1616 mwindow->theme->mtimebar_h;
1618 pane[BOTTOM_LEFT_PANE] = new TimelinePane(mwindow,
1620 pane[TOP_LEFT_PANE]->x,
1621 mwindow->theme->mcanvas_y +
1623 pane[TOP_LEFT_PANE]->w,
1624 mwindow->theme->mcanvas_h -
1626 pane[BOTTOM_RIGHT_PANE] = new TimelinePane(mwindow,
1628 pane[TOP_RIGHT_PANE]->x,
1629 mwindow->theme->mcanvas_y +
1631 pane[TOP_RIGHT_PANE]->w,
1632 mwindow->theme->mcanvas_h -
1635 pane[TOP_LEFT_PANE]->resize_event(
1636 pane[TOP_LEFT_PANE]->x,
1637 pane[TOP_LEFT_PANE]->y,
1638 pane[TOP_LEFT_PANE]->w,
1639 pane[BOTTOM_LEFT_PANE]->y -
1640 mwindow->theme->mcanvas_y -
1641 mwindow->theme->pane_h);
1642 pane[TOP_RIGHT_PANE]->resize_event(
1643 pane[TOP_RIGHT_PANE]->x,
1644 pane[TOP_RIGHT_PANE]->y,
1645 pane[TOP_RIGHT_PANE]->w,
1646 pane[BOTTOM_RIGHT_PANE]->y -
1647 mwindow->theme->mcanvas_y -
1648 mwindow->theme->pane_h);
1650 pane[BOTTOM_LEFT_PANE]->create_objects();
1651 pane[BOTTOM_RIGHT_PANE]->create_objects();
1654 if(vertical_panes())
1657 mwindow->edl->local_session->track_start[BOTTOM_LEFT_PANE] +=
1659 (pane[BOTTOM_LEFT_PANE]->y - mwindow->theme->mcanvas_y);
1660 if(mwindow->edl->local_session->track_start[BOTTOM_LEFT_PANE] < 0)
1661 mwindow->edl->local_session->track_start[BOTTOM_LEFT_PANE] = 0;
1662 pane[TOP_LEFT_PANE]->resize_event(
1663 mwindow->theme->mcanvas_x,
1664 mwindow->theme->mcanvas_y,
1665 mwindow->theme->mcanvas_w,
1666 cursor_y - mwindow->theme->pane_h);
1667 pane[BOTTOM_LEFT_PANE]->resize_event(
1668 pane[BOTTOM_LEFT_PANE]->x,
1670 mwindow->theme->mcanvas_y,
1671 mwindow->theme->mcanvas_w,
1672 mwindow->theme->mcanvas_h -
1678 mwindow->edl->local_session->track_start[BOTTOM_LEFT_PANE] +=
1680 (pane[BOTTOM_LEFT_PANE]->y - mwindow->theme->mcanvas_y);
1681 if(mwindow->edl->local_session->track_start[BOTTOM_LEFT_PANE] < 0)
1682 mwindow->edl->local_session->track_start[BOTTOM_LEFT_PANE] = 0;
1683 mwindow->edl->local_session->track_start[BOTTOM_RIGHT_PANE] =
1684 mwindow->edl->local_session->track_start[BOTTOM_LEFT_PANE];
1685 pane[TOP_LEFT_PANE]->resize_event(
1686 pane[TOP_LEFT_PANE]->x,
1687 pane[TOP_LEFT_PANE]->y,
1688 pane[TOP_LEFT_PANE]->w,
1689 cursor_y - mwindow->theme->pane_h);
1690 pane[BOTTOM_LEFT_PANE]->resize_event(
1691 pane[BOTTOM_LEFT_PANE]->x,
1693 mwindow->theme->mcanvas_y,
1694 pane[BOTTOM_LEFT_PANE]->w,
1695 mwindow->theme->mcanvas_h -
1697 pane[TOP_RIGHT_PANE]->resize_event(
1698 pane[TOP_RIGHT_PANE]->x,
1699 pane[TOP_RIGHT_PANE]->y,
1700 pane[TOP_RIGHT_PANE]->w,
1701 cursor_y - mwindow->theme->pane_h);
1702 pane[BOTTOM_RIGHT_PANE]->resize_event(
1703 pane[BOTTOM_RIGHT_PANE]->x,
1705 mwindow->theme->mcanvas_y,
1706 pane[BOTTOM_RIGHT_PANE]->w,
1707 mwindow->theme->mcanvas_h -
1712 void MWindowGUI::delete_y_pane(int cursor_y)
1714 if(cursor_y < mwindow->theme->mtimebar_h +
1716 pane[BOTTOM_LEFT_PANE])
1718 // give top pane coordinates of bottom pane
1719 mwindow->edl->local_session->track_start[TOP_LEFT_PANE] =
1720 mwindow->edl->local_session->track_start[BOTTOM_LEFT_PANE] -
1721 pane[BOTTOM_LEFT_PANE]->y;
1722 if(mwindow->edl->local_session->track_start[TOP_LEFT_PANE] < 0)
1723 mwindow->edl->local_session->track_start[TOP_LEFT_PANE] = 0;
1724 mwindow->edl->local_session->track_start[TOP_RIGHT_PANE] =
1725 mwindow->edl->local_session->track_start[TOP_LEFT_PANE];
1729 switch(total_panes())
1732 delete pane[BOTTOM_LEFT_PANE];
1733 pane[BOTTOM_LEFT_PANE] = 0;
1734 pane[TOP_LEFT_PANE]->resize_event(
1735 mwindow->theme->mcanvas_x,
1736 mwindow->theme->mcanvas_y,
1737 mwindow->theme->mcanvas_w,
1738 mwindow->theme->mcanvas_h);
1742 // delete bottom 2 panes
1744 delete pane[BOTTOM_LEFT_PANE];
1745 pane[BOTTOM_LEFT_PANE] = 0;
1746 delete pane[BOTTOM_RIGHT_PANE];
1747 pane[BOTTOM_RIGHT_PANE] = 0;
1748 pane[TOP_LEFT_PANE]->resize_event(
1749 pane[TOP_LEFT_PANE]->x,
1750 mwindow->theme->mcanvas_y,
1751 pane[TOP_LEFT_PANE]->w,
1752 mwindow->theme->mcanvas_h);
1753 pane[TOP_RIGHT_PANE]->resize_event(
1754 pane[TOP_RIGHT_PANE]->x,
1755 mwindow->theme->mcanvas_y,
1756 pane[TOP_RIGHT_PANE]->w,
1757 mwindow->theme->mcanvas_h);
1762 void MWindowGUI::stop_pane_drag()
1765 resource_thread->stop_draw(0);
1769 // cursor position relative to canvas
1770 int cursor_x = x_pane_drag->get_x() -
1772 BC_DisplayInfo::get_left_border() -
1773 mwindow->theme->mcanvas_x +
1774 mwindow->theme->pane_w;
1779 if(cursor_x >= mwindow->theme->patchbay_w + PANE_DRAG_MARGIN &&
1780 cursor_x < mwindow->theme->mcanvas_w -
1781 BC_ScrollBar::get_span(SCROLL_VERT) -
1784 create_x_pane(cursor_x);
1785 mwindow->edl->local_session->x_pane = cursor_x;
1790 delete_x_pane(cursor_x);
1791 mwindow->edl->local_session->x_pane = -1;
1799 // cursor position relative to canvas
1800 int cursor_y = y_pane_drag->get_y() -
1802 BC_DisplayInfo::get_top_border() -
1803 mwindow->theme->mcanvas_y +
1804 mwindow->theme->pane_h;
1810 if(cursor_y >= mwindow->theme->mtimebar_h +
1812 cursor_y < mwindow->theme->mcanvas_h -
1813 BC_ScrollBar::get_span(SCROLL_HORIZ) -
1816 create_y_pane(cursor_y);
1817 mwindow->edl->local_session->y_pane = cursor_y;
1821 delete_y_pane(cursor_y);
1822 mwindow->edl->local_session->y_pane = -1;
1826 update_pane_dividers();
1828 // required to get new widgets to appear
1830 resource_thread->start_draw();
1833 // create panes from EDL
1834 void MWindowGUI::load_panes()
1836 int need_x_panes = 0;
1837 int need_y_panes = 0;
1838 // use names from create functions
1839 int cursor_x = mwindow->edl->local_session->x_pane;
1840 int cursor_y = mwindow->edl->local_session->y_pane;
1842 resource_thread->stop_draw(1);
1844 mwindow->theme->patchbay_w + PANE_DRAG_MARGIN &&
1846 mwindow->theme->mcanvas_w -
1847 BC_ScrollBar::get_span(SCROLL_VERT) -
1854 mwindow->theme->mtimebar_h + PANE_DRAG_MARGIN &&
1856 mwindow->theme->mcanvas_h -
1857 BC_ScrollBar::get_span(SCROLL_HORIZ) -
1863 //printf("MWindowGUI::load_panes %d %d %d\n", __LINE__, need_x_panes, need_y_panes);
1871 if(total_panes() == 1)
1874 //printf("MWindowGUI::load_panes %d\n", __LINE__);
1875 pane[TOP_RIGHT_PANE] = new TimelinePane(mwindow,
1877 mwindow->theme->mcanvas_x +
1879 mwindow->theme->mcanvas_y,
1880 mwindow->theme->mcanvas_x +
1881 mwindow->theme->mcanvas_w -
1883 cursor_y - mwindow->theme->pane_h);
1884 pane[BOTTOM_LEFT_PANE] = new TimelinePane(mwindow,
1886 mwindow->theme->mcanvas_x,
1887 mwindow->theme->mcanvas_y +
1889 cursor_x - mwindow->theme->pane_w,
1890 mwindow->theme->mcanvas_h -
1892 pane[BOTTOM_RIGHT_PANE] = new TimelinePane(mwindow,
1894 pane[TOP_RIGHT_PANE]->x,
1895 mwindow->theme->mcanvas_y +
1897 pane[TOP_RIGHT_PANE]->w,
1898 mwindow->theme->mcanvas_h -
1900 pane[TOP_LEFT_PANE]->resize_event(
1901 pane[TOP_LEFT_PANE]->x,
1902 pane[TOP_LEFT_PANE]->y,
1903 cursor_x - mwindow->theme->pane_w,
1904 cursor_y - mwindow->theme->pane_h);
1905 pane[TOP_RIGHT_PANE]->create_objects();
1906 pane[BOTTOM_LEFT_PANE]->create_objects();
1907 pane[BOTTOM_RIGHT_PANE]->create_objects();
1910 if(horizontal_panes())
1912 // create vertical panes
1913 //printf("MWindowGUI::load_panes %d\n", __LINE__);
1914 pane[BOTTOM_LEFT_PANE] = new TimelinePane(mwindow,
1916 mwindow->theme->mcanvas_x,
1917 mwindow->theme->mcanvas_y +
1919 cursor_x - mwindow->theme->pane_w,
1920 mwindow->theme->mcanvas_h -
1922 pane[BOTTOM_RIGHT_PANE] = new TimelinePane(mwindow,
1924 pane[TOP_RIGHT_PANE]->x,
1925 mwindow->theme->mcanvas_y +
1927 pane[TOP_RIGHT_PANE]->w,
1928 mwindow->theme->mcanvas_h -
1930 pane[TOP_LEFT_PANE]->resize_event(
1931 pane[TOP_LEFT_PANE]->x,
1932 pane[TOP_LEFT_PANE]->y,
1933 cursor_x - mwindow->theme->pane_w,
1934 cursor_y - mwindow->theme->pane_h);
1935 pane[TOP_RIGHT_PANE]->resize_event(
1936 mwindow->theme->mcanvas_x +
1938 mwindow->theme->mcanvas_y,
1939 mwindow->theme->mcanvas_x +
1940 mwindow->theme->mcanvas_w -
1942 cursor_y - mwindow->theme->pane_h);
1943 pane[BOTTOM_LEFT_PANE]->create_objects();
1944 pane[BOTTOM_RIGHT_PANE]->create_objects();
1947 if(vertical_panes())
1949 // create horizontal panes
1950 //printf("MWindowGUI::load_panes %d\n", __LINE__);
1951 pane[TOP_RIGHT_PANE] = new TimelinePane(mwindow,
1953 mwindow->theme->mcanvas_x +
1955 mwindow->theme->mcanvas_y,
1956 mwindow->theme->mcanvas_x +
1957 mwindow->theme->mcanvas_w -
1959 cursor_y - mwindow->theme->pane_h);
1960 pane[BOTTOM_RIGHT_PANE] = new TimelinePane(mwindow,
1962 pane[TOP_RIGHT_PANE]->x,
1963 mwindow->theme->mcanvas_y +
1965 pane[TOP_RIGHT_PANE]->w,
1966 mwindow->theme->mcanvas_h -
1968 pane[TOP_LEFT_PANE]->resize_event(
1969 pane[TOP_LEFT_PANE]->x,
1970 pane[TOP_LEFT_PANE]->y,
1971 cursor_x - mwindow->theme->pane_w,
1972 cursor_y - mwindow->theme->pane_h);
1973 pane[BOTTOM_LEFT_PANE]->resize_event(
1974 pane[TOP_LEFT_PANE]->x,
1975 mwindow->theme->mcanvas_y +
1977 mwindow->theme->mcanvas_x +
1978 mwindow->theme->mcanvas_w -
1979 cursor_x - mwindow->theme->pane_w,
1980 mwindow->theme->mcanvas_h -
1982 pane[TOP_RIGHT_PANE]->create_objects();
1983 pane[BOTTOM_RIGHT_PANE]->create_objects();
1990 //printf("MWindowGUI::load_panes %d\n", __LINE__);
1991 pane[TOP_LEFT_PANE]->resize_event(
1992 pane[TOP_LEFT_PANE]->x,
1993 pane[TOP_LEFT_PANE]->y,
1994 cursor_x - mwindow->theme->pane_w,
1995 cursor_y - mwindow->theme->pane_h);
1996 pane[TOP_RIGHT_PANE]->resize_event(
1997 mwindow->theme->mcanvas_x +
1999 mwindow->theme->mcanvas_y,
2000 mwindow->theme->mcanvas_x +
2001 mwindow->theme->mcanvas_w -
2003 cursor_y - mwindow->theme->pane_h);
2004 pane[BOTTOM_LEFT_PANE]->resize_event(
2005 pane[TOP_LEFT_PANE]->x,
2006 mwindow->theme->mcanvas_y +
2008 mwindow->theme->mcanvas_x +
2009 mwindow->theme->mcanvas_w -
2010 cursor_x - mwindow->theme->pane_w,
2011 mwindow->theme->mcanvas_h -
2013 pane[BOTTOM_RIGHT_PANE]->resize_event(
2014 pane[TOP_RIGHT_PANE]->x,
2015 mwindow->theme->mcanvas_y +
2017 pane[TOP_RIGHT_PANE]->w,
2018 mwindow->theme->mcanvas_h -
2027 if(pane[BOTTOM_LEFT_PANE]) delete pane[BOTTOM_LEFT_PANE];
2028 if(pane[BOTTOM_RIGHT_PANE]) delete pane[BOTTOM_RIGHT_PANE];
2029 pane[BOTTOM_LEFT_PANE] = 0;
2030 pane[BOTTOM_RIGHT_PANE] = 0;
2032 if(!pane[TOP_RIGHT_PANE])
2034 pane[TOP_RIGHT_PANE] = new TimelinePane(mwindow,
2036 mwindow->theme->mcanvas_x +
2038 mwindow->theme->mcanvas_y,
2039 mwindow->theme->mcanvas_x +
2040 mwindow->theme->mcanvas_w -
2042 mwindow->theme->mcanvas_h);
2043 pane[TOP_LEFT_PANE]->resize_event(
2044 mwindow->theme->mcanvas_x,
2045 mwindow->theme->mcanvas_y,
2046 cursor_x - mwindow->theme->pane_w,
2047 mwindow->theme->mcanvas_h);
2048 pane[TOP_RIGHT_PANE]->create_objects();
2052 pane[TOP_LEFT_PANE]->resize_event(
2053 mwindow->theme->mcanvas_x,
2054 mwindow->theme->mcanvas_y,
2055 cursor_x - mwindow->theme->pane_w,
2056 mwindow->theme->mcanvas_h);
2057 pane[TOP_RIGHT_PANE]->resize_event(
2058 mwindow->theme->mcanvas_x +
2060 pane[TOP_RIGHT_PANE]->y,
2061 mwindow->theme->mcanvas_x +
2062 mwindow->theme->mcanvas_w -
2064 mwindow->theme->mcanvas_h);
2072 if(pane[TOP_RIGHT_PANE]) delete pane[TOP_RIGHT_PANE];
2073 if(pane[BOTTOM_RIGHT_PANE]) delete pane[BOTTOM_RIGHT_PANE];
2074 pane[TOP_RIGHT_PANE] = 0;
2075 pane[BOTTOM_RIGHT_PANE] = 0;
2077 if(!pane[BOTTOM_LEFT_PANE])
2079 //printf("MWindowGUI::load_panes %d\n", __LINE__);
2080 pane[BOTTOM_LEFT_PANE] = new TimelinePane(mwindow,
2082 mwindow->theme->mcanvas_x,
2083 mwindow->theme->mcanvas_y +
2085 mwindow->theme->mcanvas_w,
2086 mwindow->theme->mcanvas_h -
2088 pane[TOP_LEFT_PANE]->resize_event(
2089 mwindow->theme->mcanvas_x,
2090 mwindow->theme->mcanvas_y,
2091 mwindow->theme->mcanvas_w,
2092 pane[BOTTOM_LEFT_PANE]->y -
2093 mwindow->theme->mcanvas_y -
2094 mwindow->theme->pane_h);
2095 pane[BOTTOM_LEFT_PANE]->create_objects();
2099 pane[TOP_LEFT_PANE]->resize_event(
2100 mwindow->theme->mcanvas_x,
2101 mwindow->theme->mcanvas_y,
2102 mwindow->theme->mcanvas_w,
2103 cursor_y - mwindow->theme->pane_h);
2104 pane[BOTTOM_LEFT_PANE]->resize_event(
2105 pane[BOTTOM_LEFT_PANE]->x,
2107 mwindow->theme->mcanvas_y,
2108 mwindow->theme->mcanvas_w,
2109 mwindow->theme->mcanvas_h -
2116 if(pane[TOP_RIGHT_PANE]) delete pane[TOP_RIGHT_PANE];
2117 if(pane[BOTTOM_RIGHT_PANE]) delete pane[BOTTOM_RIGHT_PANE];
2118 if(pane[BOTTOM_LEFT_PANE]) delete pane[BOTTOM_LEFT_PANE];
2119 pane[TOP_RIGHT_PANE] = 0;
2120 pane[BOTTOM_RIGHT_PANE] = 0;
2121 pane[BOTTOM_LEFT_PANE] = 0;
2122 pane[TOP_LEFT_PANE]->resize_event(
2123 mwindow->theme->mcanvas_x,
2124 mwindow->theme->mcanvas_y,
2125 mwindow->theme->mcanvas_w,
2126 mwindow->theme->mcanvas_h);
2129 update_pane_dividers();
2132 resource_thread->start_draw();
2135 void MWindowGUI::update_pane_dividers()
2138 if(horizontal_panes() || total_panes() == 4)
2140 int x = pane[TOP_RIGHT_PANE]->x - mwindow->theme->pane_w;
2141 int y = mwindow->theme->mcanvas_y;
2142 int h = mwindow->theme->mcanvas_h;
2146 add_subwindow(x_divider = new PaneDivider(
2147 mwindow, x, y, h, 1));
2148 x_divider->create_objects();
2152 x_divider->reposition_window(x, y, h);
2165 if(vertical_panes() || total_panes() == 4)
2167 int x = mwindow->theme->mcanvas_x;
2168 int y = pane[BOTTOM_LEFT_PANE]->y -
2169 mwindow->theme->pane_h;
2170 int w = mwindow->theme->mcanvas_w;
2173 add_subwindow(y_divider = new PaneDivider(
2174 mwindow, x, y, w, 0));
2175 y_divider->create_objects();
2179 y_divider->reposition_window(x, y, w);
2193 void MWindowGUI::draw_samplemovement()
2200 update_scrollbars(1);
2203 void MWindowGUI::draw_trackmovement()
2205 update_scrollbars(0);
2212 void MWindowGUI::update_mixers(Track *track, int v)
2214 for( int i=0; i<TOTAL_PANES; ++i ) {
2215 if( !pane[i] ) continue;
2216 PatchBay *patchbay = pane[i]->patchbay;
2217 if( !patchbay ) continue;
2218 for( int j=0; j<patchbay->patches.total; ++j ) {
2219 PatchGUI *patchgui = patchbay->patches.values[j];
2220 if( !patchgui->mix ) continue;
2221 if( !track || patchgui->track == track ) {
2222 patchgui->mix->update(v>=0 ? v :
2223 mwindow->mixer_track_active(patchgui->track));
2229 void MWindowGUI::stop_transport(const char *lock_msg)
2231 if( !mbuttons->transport->is_stopped() ) {
2232 if( lock_msg ) unlock_window();
2233 mbuttons->transport->handle_transport(STOP, 1);
2234 if( lock_msg ) lock_window(lock_msg);
2238 PaneButton::PaneButton(MWindow *mwindow, int x, int y)
2239 : BC_Button(x, y, mwindow->theme->get_image_set("pane"))
2241 this->mwindow = mwindow;
2244 int PaneButton::cursor_motion_event()
2246 if(get_top_level()->get_button_down() &&
2248 get_status() == BUTTON_DOWNHI &&
2251 // printf("PaneButton::cursor_motion_event %d\n", __LINE__);
2253 if(get_cursor_x() < 0 && !mwindow->gui->dragging_pane)
2255 mwindow->gui->start_x_pane_drag();
2258 if(get_cursor_y() < 0 && !mwindow->gui->dragging_pane)
2260 mwindow->gui->start_y_pane_drag();
2264 mwindow->gui->handle_pane_drag();
2266 int result = BC_Button::cursor_motion_event();
2270 int PaneButton::button_release_event()
2272 if( get_buttonpress() != WHEEL_DOWN && get_buttonpress() != WHEEL_UP )
2273 mwindow->gui->stop_pane_drag();
2274 int result = BC_Button::button_release_event();
2279 FFMpegToggle::FFMpegToggle(MWindow *mwindow, MButtons *mbuttons, int x, int y)
2280 : BC_Toggle(x, y, mwindow->theme->ffmpeg_toggle,
2281 mwindow->preferences->get_file_probe_armed("FFMPEG_Early") > 0 ? 1 : 0)
2283 this->mwindow = mwindow;
2284 this->mbuttons = mbuttons;
2285 set_tooltip(get_value() ? FFMPEG_EARLY_TIP : FFMPEG_LATE_TIP);
2288 FFMpegToggle::~FFMpegToggle()
2292 int FFMpegToggle::handle_event()
2294 int ffmpeg_early_probe = get_value();
2295 set_tooltip(ffmpeg_early_probe ? FFMPEG_EARLY_TIP : FFMPEG_LATE_TIP);
2296 mwindow->preferences->set_file_probe_armed("FFMPEG_Early", ffmpeg_early_probe);
2297 mwindow->preferences->set_file_probe_armed("FFMPEG_Late", !ffmpeg_early_probe);
2298 mwindow->update_preferences(mwindow->preferences);
2299 mwindow->show_warning(&mwindow->preferences->warn_indexes,
2300 _("Changing the base codecs may require rebuilding indexes."));
2305 StackButton::StackButton(MWindow *mwindow, int x, int y)
2306 : BC_GenericButton(x, y, mwindow->theme->stack_button_w, "0")
2308 this->mwindow = mwindow;
2309 set_tooltip(_("Return to previous EDL"));
2312 int StackButton::handle_event()
2314 mwindow->stack_pop();
2318 void StackButton::update()
2320 char text[BCSTRLEN];
2321 int i = mwindow->stack.size();
2322 sprintf(text, "%d", i);
2325 int hidden = is_hidden();
2333 ProxyToggle::ProxyToggle(MWindow *mwindow, MButtons *mbuttons, int x, int y)
2334 : BC_Toggle(x, y, ( !mwindow->edl->session->proxy_use_scaler ?
2335 mwindow->theme->proxy_p_toggle :
2336 mwindow->theme->proxy_s_toggle ),
2337 mwindow->edl->session->proxy_disabled_scale != 1)
2339 this->mwindow = mwindow;
2340 this->mbuttons = mbuttons;
2341 scaler_images = mwindow->edl->session->proxy_use_scaler;
2342 set_tooltip(mwindow->edl->session->proxy_disabled_scale==1 ?
2343 _("Disable proxy") : _("Enable proxy"));
2346 void ProxyToggle::show()
2348 int use_scaler = mwindow->edl->session->proxy_use_scaler;
2349 if( scaler_images != use_scaler )
2350 set_images(!(scaler_images=use_scaler) ?
2351 mwindow->theme->proxy_p_toggle :
2352 mwindow->theme->proxy_s_toggle );
2358 void ProxyToggle::hide()
2364 ProxyToggle::~ProxyToggle()
2368 int ProxyToggle::handle_event()
2370 int disabled = get_value();
2371 mwindow->gui->unlock_window();
2373 mwindow->disable_proxy();
2375 mwindow->enable_proxy();
2376 mwindow->gui->lock_window("ProxyToggle::handle_event");
2377 set_tooltip(!disabled ? _("Disable proxy") : _("Enable proxy"));
2381 int ProxyToggle::keypress_event()
2383 if( ctrl_down() && !shift_down() && !alt_down() ) {
2384 int key = get_keypress();
2386 int value = get_value() ? 0 : 1;
2388 return handle_event();