3 #include "timelinepane.h"
4 #include "localsession.h"
5 #include "maincursor.h"
8 #include "mwindowgui.h"
10 #include "samplescroll.h"
14 #include "trackcanvas.h"
15 #include "trackscroll.h"
18 // coordinates are relative to the main window
19 TimelinePane::TimelinePane(MWindow *mwindow,
26 // printf("TimelinePane::TimelinePane %d number=%d %d %d %d %d\n",
33 this->mwindow = mwindow;
34 this->number = number;
46 TimelinePane::~TimelinePane()
56 void TimelinePane::create_objects()
58 this->gui = mwindow->gui;
59 mwindow->theme->get_pane_sizes(gui,
69 cursor = new MainCursor(mwindow, this);
70 cursor->create_objects();
71 // printf("TimelinePane::create_objects %d number=%d x=%d y=%d w=%d h=%d view_x=%d view_w=%d\n",
82 gui->add_subwindow(canvas = new TrackCanvas(mwindow,
88 canvas->create_objects();
90 if(number == TOP_LEFT_PANE ||
91 number == BOTTOM_LEFT_PANE)
96 if(number == TOP_LEFT_PANE)
98 patchbay_y += mwindow->theme->mtimebar_h;
99 patchbay_h -= mwindow->theme->mtimebar_h;
102 gui->add_subwindow(patchbay = new PatchBay(mwindow,
106 mwindow->theme->patchbay_w,
108 patchbay->create_objects();
111 if(number == TOP_LEFT_PANE ||
112 number == TOP_RIGHT_PANE)
114 int timebar_w = view_w;
115 // Overlap right scrollbar
116 if(gui->total_panes() == 1 ||
117 number == TOP_RIGHT_PANE)
118 timebar_w += BC_ScrollBar::get_span(SCROLL_VERT);
120 gui->add_subwindow(timebar = new MTimeBar(mwindow,
125 mwindow->theme->mtimebar_h));
126 timebar->create_objects();
129 create_sample_scroll(view_x, view_y, view_w, view_h);
131 create_track_scroll(view_x, view_y, view_w, view_h);
136 void TimelinePane::resize_event(int x, int y, int w, int h)
142 mwindow->theme->get_pane_sizes(
153 // printf("TimelinePane::resize_event %d number=%d x=%d y=%d w=%d h=%d view_x=%d view_y=%d view_w=%d view_h=%d\n",
167 int timebar_w = view_w;
168 // Overlap right scrollbar
169 if(gui->total_panes() == 1 ||
170 (gui->total_panes() == 2 &&
171 (number == TOP_LEFT_PANE ||
172 number == BOTTOM_LEFT_PANE)) ||
173 number == TOP_RIGHT_PANE ||
174 number == BOTTOM_RIGHT_PANE)
175 timebar_w += BC_ScrollBar::get_span(SCROLL_VERT);
176 timebar->resize_event(view_x,
179 mwindow->theme->mtimebar_h);
187 if(number == TOP_LEFT_PANE)
189 patchbay_y += mwindow->theme->mtimebar_h;
190 patchbay_h -= mwindow->theme->mtimebar_h;
196 patchbay->resize_event(x,
198 mwindow->theme->patchbay_w,
204 if(gui->pane[TOP_LEFT_PANE] &&
205 gui->pane[BOTTOM_LEFT_PANE] &&
206 (number == TOP_LEFT_PANE ||
207 number == TOP_RIGHT_PANE))
214 samplescroll->resize_event(view_x,
217 samplescroll->set_position();
221 create_sample_scroll(view_x, view_y, view_w, view_h);
225 if(gui->pane[TOP_LEFT_PANE] &&
226 gui->pane[TOP_RIGHT_PANE] &&
227 (number == TOP_LEFT_PANE ||
228 number == BOTTOM_LEFT_PANE))
235 trackscroll->resize_event(view_x + view_w,
238 trackscroll->set_position();
242 create_track_scroll(view_x, view_y, view_w, view_h);
244 canvas->reposition_window(view_x, view_y, view_w, view_h);
245 canvas->resize_event();
248 void TimelinePane::create_sample_scroll(int view_x, int view_y, int view_w, int view_h)
250 //printf("TimelinePane::create_sample_scroll %d %d\n", __LINE__, number);
251 if(number == BOTTOM_LEFT_PANE ||
252 number == BOTTOM_RIGHT_PANE ||
253 (gui->total_panes() == 2 &&
254 gui->pane[TOP_LEFT_PANE] &&
255 gui->pane[TOP_RIGHT_PANE]) ||
256 gui->total_panes() == 1)
258 //printf("TimelinePane::create_sample_scroll %d %d %d\n", __LINE__, y, h);
259 gui->add_subwindow(samplescroll = new SampleScroll(mwindow,
262 y + h - BC_ScrollBar::get_span(SCROLL_VERT),
264 samplescroll->set_position();
268 void TimelinePane::create_track_scroll(int view_x, int view_y, int view_w, int view_h)
270 if(number == TOP_RIGHT_PANE ||
271 number == BOTTOM_RIGHT_PANE ||
272 gui->vertical_panes() ||
273 gui->total_panes() == 1)
275 gui->add_subwindow(trackscroll = new TrackScroll(mwindow,
280 trackscroll->set_position();
285 void TimelinePane::update(int scrollbars,
290 if(timebar && this->timebar) this->timebar->update(0);
293 if(samplescroll && this->samplescroll) samplescroll->set_position();
294 if(trackscroll && this->trackscroll) trackscroll->set_position();
296 if(patchbay && this->patchbay) this->patchbay->update();
300 this->canvas->draw(do_canvas, 1);
301 this->cursor->show();
302 this->canvas->flash(0);
303 // Activate causes the menubar to deactivate. Don't want this for
305 // if(do_canvas != IGNORE_THREAD) this->canvas->activate();
309 void TimelinePane::activate()
312 gui->focused_pane = number;
315 Track *TimelinePane::over_track()
317 int canvas_x = canvas->get_relative_cursor_x();
318 if( canvas_x < 0 || canvas_x >= canvas->get_w() ) return 0;
319 int canvas_y = canvas->get_relative_cursor_y();
320 if( canvas_y < 0 || canvas_y >= canvas->get_h() ) return 0;
321 int pane_y = canvas_y + mwindow->edl->local_session->track_start[number];
322 for( Track *track=mwindow->edl->tracks->first; track; track=track->next ) {
323 int track_y = track->y_pixel;
324 if( pane_y < track_y ) continue;
325 track_y += track->vertical_span(mwindow->theme);
326 if( pane_y < track_y )
333 Track *TimelinePane::over_patchbay()
335 if( !patchbay ) return 0;
336 int patch_x = patchbay->get_relative_cursor_x() ;
337 if( patch_x < 0 || patch_x >= patchbay->get_w() ) return 0;
338 int patch_y = patchbay->get_relative_cursor_y();
339 if( patch_y < 0 || patch_y >= patchbay->get_h() ) return 0;
340 // int canvas_x = patch_x + patchbay->get_x() - canvas->get_x();
341 int canvas_y = patch_y + patchbay->get_y() - canvas->get_y();
342 int pane_y = canvas_y + mwindow->edl->local_session->track_start[number];
343 for( Track *track=mwindow->edl->tracks->first; track; track=track->next ) {
344 int track_y = track->y_pixel;
345 if( pane_y < track_y ) continue;
346 track_y += track->vertical_span(mwindow->theme);
347 if( pane_y < track_y )