3 #include "timelinepane.h"
4 #include "localsession.h"
5 #include "maincursor.h"
8 #include "mwindowgui.h"
10 #include "samplescroll.h"
12 #include "trackcanvas.h"
13 #include "trackscroll.h"
16 // coordinates are relative to the main window
17 TimelinePane::TimelinePane(MWindow *mwindow,
24 // printf("TimelinePane::TimelinePane %d number=%d %d %d %d %d\n",
31 this->mwindow = mwindow;
32 this->number = number;
44 TimelinePane::~TimelinePane()
54 void TimelinePane::create_objects()
56 this->gui = mwindow->gui;
57 mwindow->theme->get_pane_sizes(gui,
67 cursor = new MainCursor(mwindow, this);
68 cursor->create_objects();
69 // printf("TimelinePane::create_objects %d number=%d x=%d y=%d w=%d h=%d view_x=%d view_w=%d\n",
80 gui->add_subwindow(canvas = new TrackCanvas(mwindow,
86 canvas->create_objects();
88 if(number == TOP_LEFT_PANE ||
89 number == BOTTOM_LEFT_PANE)
94 if(number == TOP_LEFT_PANE)
96 patchbay_y += mwindow->theme->mtimebar_h;
97 patchbay_h -= mwindow->theme->mtimebar_h;
100 gui->add_subwindow(patchbay = new PatchBay(mwindow,
104 mwindow->theme->patchbay_w,
106 patchbay->create_objects();
109 if(number == TOP_LEFT_PANE ||
110 number == TOP_RIGHT_PANE)
112 int timebar_w = view_w;
113 // Overlap right scrollbar
114 if(gui->total_panes() == 1 ||
115 number == TOP_RIGHT_PANE)
116 timebar_w += BC_ScrollBar::get_span(SCROLL_VERT);
118 gui->add_subwindow(timebar = new MTimeBar(mwindow,
123 mwindow->theme->mtimebar_h));
124 timebar->create_objects();
127 create_sample_scroll(view_x, view_y, view_w, view_h);
129 create_track_scroll(view_x, view_y, view_w, view_h);
134 void TimelinePane::resize_event(int x, int y, int w, int h)
140 mwindow->theme->get_pane_sizes(
151 // 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",
165 int timebar_w = view_w;
166 // Overlap right scrollbar
167 if(gui->total_panes() == 1 ||
168 (gui->total_panes() == 2 &&
169 (number == TOP_LEFT_PANE ||
170 number == BOTTOM_LEFT_PANE)) ||
171 number == TOP_RIGHT_PANE ||
172 number == BOTTOM_RIGHT_PANE)
173 timebar_w += BC_ScrollBar::get_span(SCROLL_VERT);
174 timebar->resize_event(view_x,
177 mwindow->theme->mtimebar_h);
185 if(number == TOP_LEFT_PANE)
187 patchbay_y += mwindow->theme->mtimebar_h;
188 patchbay_h -= mwindow->theme->mtimebar_h;
194 patchbay->resize_event(x,
196 mwindow->theme->patchbay_w,
202 if(gui->pane[TOP_LEFT_PANE] &&
203 gui->pane[BOTTOM_LEFT_PANE] &&
204 (number == TOP_LEFT_PANE ||
205 number == TOP_RIGHT_PANE))
212 samplescroll->resize_event(view_x,
215 samplescroll->set_position();
219 create_sample_scroll(view_x, view_y, view_w, view_h);
223 if(gui->pane[TOP_LEFT_PANE] &&
224 gui->pane[TOP_RIGHT_PANE] &&
225 (number == TOP_LEFT_PANE ||
226 number == BOTTOM_LEFT_PANE))
233 trackscroll->resize_event(view_x + view_w,
236 trackscroll->set_position();
240 create_track_scroll(view_x, view_y, view_w, view_h);
242 canvas->reposition_window(view_x, view_y, view_w, view_h);
243 canvas->resize_event();
246 void TimelinePane::create_sample_scroll(int view_x, int view_y, int view_w, int view_h)
248 //printf("TimelinePane::create_sample_scroll %d %d\n", __LINE__, number);
249 if(number == BOTTOM_LEFT_PANE ||
250 number == BOTTOM_RIGHT_PANE ||
251 (gui->total_panes() == 2 &&
252 gui->pane[TOP_LEFT_PANE] &&
253 gui->pane[TOP_RIGHT_PANE]) ||
254 gui->total_panes() == 1)
256 //printf("TimelinePane::create_sample_scroll %d %d %d\n", __LINE__, y, h);
257 gui->add_subwindow(samplescroll = new SampleScroll(mwindow,
260 y + h - BC_ScrollBar::get_span(SCROLL_VERT),
262 samplescroll->set_position();
266 void TimelinePane::create_track_scroll(int view_x, int view_y, int view_w, int view_h)
268 if(number == TOP_RIGHT_PANE ||
269 number == BOTTOM_RIGHT_PANE ||
270 gui->vertical_panes() ||
271 gui->total_panes() == 1)
273 gui->add_subwindow(trackscroll = new TrackScroll(mwindow,
278 trackscroll->set_position();
283 void TimelinePane::update(int scrollbars,
288 if(timebar && this->timebar) this->timebar->update(0);
289 if(patchbay && this->patchbay) this->patchbay->update();
292 if(samplescroll && this->samplescroll) samplescroll->set_position();
293 if(trackscroll && this->trackscroll) trackscroll->set_position();
298 this->canvas->draw(do_canvas, 1);
299 this->cursor->show();
300 this->canvas->flash(0);
301 // Activate causes the menubar to deactivate. Don't want this for
303 // if(do_canvas != IGNORE_THREAD) this->canvas->activate();
307 void TimelinePane::activate()
310 gui->focused_pane = number;