prevent popup deactivation while button_down
[goodguy/history.git] / cinelerra-5.0 / cinelerra / timelinepane.C
1 #include "bcsignals.h"
2 #include "edl.h"
3 #include "timelinepane.h"
4 #include "localsession.h"
5 #include "maincursor.h"
6 #include "mtimebar.h"
7 #include "mwindow.h"
8 #include "mwindowgui.h"
9 #include "patchbay.h"
10 #include "samplescroll.h"
11 #include "theme.h"
12 #include "trackcanvas.h"
13 #include "trackscroll.h"
14
15
16 // coordinates are relative to the main window
17 TimelinePane::TimelinePane(MWindow *mwindow, 
18         int number,
19         int x,
20         int y,
21         int w, 
22         int h)
23 {
24 // printf("TimelinePane::TimelinePane %d number=%d %d %d %d %d\n",
25 // __LINE__,
26 // number,
27 // x,
28 // y,
29 // w,
30 // h);
31         this->mwindow = mwindow;
32         this->number = number;
33         this->x = x;
34         this->y = y;
35         this->w = w;
36         this->h = h;
37         patchbay = 0;
38         timebar = 0;
39         samplescroll = 0;
40         trackscroll = 0;
41         cursor = 0;
42 }
43
44 TimelinePane::~TimelinePane()
45 {
46         delete canvas;
47         delete cursor;
48         delete patchbay;
49         delete timebar;
50         delete samplescroll;
51         delete trackscroll;
52 }
53
54 void TimelinePane::create_objects()
55 {
56         this->gui = mwindow->gui;
57         mwindow->theme->get_pane_sizes(gui,
58                 &view_x,
59                 &view_y,
60                 &view_w, 
61                 &view_h, 
62                 number,
63                 x,
64                 y,
65                 w, 
66                 h);
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", 
70 // __LINE__, 
71 // number,
72 // x, 
73 // y, 
74 // w,
75 // h,
76 // view_x,
77 // view_w);
78
79
80         gui->add_subwindow(canvas = new TrackCanvas(mwindow, 
81                 this,
82                 view_x,
83                 view_y,
84                 view_w,
85                 view_h));
86         canvas->create_objects();
87
88         if(number == TOP_LEFT_PANE ||
89                 number == BOTTOM_LEFT_PANE)
90         {
91                 int patchbay_y = y;
92                 int patchbay_h = h;
93                 
94                 if(number == TOP_LEFT_PANE)
95                 {
96                         patchbay_y += mwindow->theme->mtimebar_h;
97                         patchbay_h -= mwindow->theme->mtimebar_h;
98                 }
99                 
100                 gui->add_subwindow(patchbay = new PatchBay(mwindow, 
101                         this,
102                         x, 
103                         patchbay_y,
104                         mwindow->theme->patchbay_w,
105                         patchbay_h));
106                 patchbay->create_objects();
107         }
108         
109         if(number == TOP_LEFT_PANE || 
110                 number == TOP_RIGHT_PANE)
111         {
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);
117
118                 gui->add_subwindow(timebar = new MTimeBar(mwindow, 
119                         this,
120                         view_x,
121                         y,
122                         timebar_w,
123                         mwindow->theme->mtimebar_h));
124                 timebar->create_objects();
125         }
126         
127         create_sample_scroll(view_x, view_y, view_w, view_h);
128
129         create_track_scroll(view_x, view_y, view_w, view_h);
130 }
131
132
133
134 void TimelinePane::resize_event(int x, int y, int w, int h)
135 {
136         this->x = x;
137         this->y = y;
138         this->w = w;
139         this->h = h;
140         mwindow->theme->get_pane_sizes(
141                 gui,
142                 &view_x,
143                 &view_y,
144                 &view_w, 
145                 &view_h, 
146                 number,
147                 x,
148                 y,
149                 w, 
150                 h);
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",
152 // __LINE__,
153 // number,
154 // x,
155 // y,
156 // w,
157 // h,
158 // view_x,
159 // view_y,
160 // view_w,
161 // view_h);
162
163         if(timebar)
164         {
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, 
175                         y, 
176                         timebar_w, 
177                         mwindow->theme->mtimebar_h);
178         }
179         
180         if(patchbay)
181         {
182                 int patchbay_y = y;
183                 int patchbay_h = h;
184                 
185                 if(number == TOP_LEFT_PANE)
186                 {
187                         patchbay_y += mwindow->theme->mtimebar_h;
188                         patchbay_h -= mwindow->theme->mtimebar_h;
189                 }
190                 else
191                 {
192                 }
193                 
194                 patchbay->resize_event(x,
195                         patchbay_y,
196                         mwindow->theme->patchbay_w,
197                         patchbay_h);
198         }
199         
200         if(samplescroll)
201         {
202                 if(gui->pane[TOP_LEFT_PANE] &&
203                         gui->pane[BOTTOM_LEFT_PANE] &&
204                         (number == TOP_LEFT_PANE ||
205                                 number == TOP_RIGHT_PANE))
206                 {
207                         delete samplescroll;
208                         samplescroll = 0;
209                 }
210                 else
211                 {
212                         samplescroll->resize_event(view_x, 
213                                 view_y + view_h,
214                                 view_w);
215                         samplescroll->set_position();
216                 }
217         }
218         else
219                 create_sample_scroll(view_x, view_y, view_w, view_h);
220         
221         if(trackscroll) 
222         {
223                 if(gui->pane[TOP_LEFT_PANE] &&
224                         gui->pane[TOP_RIGHT_PANE] && 
225                         (number == TOP_LEFT_PANE ||
226                         number == BOTTOM_LEFT_PANE))
227                 {
228                         delete trackscroll;
229                         trackscroll = 0;
230                 }
231                 else
232                 {
233                         trackscroll->resize_event(view_x + view_w,
234                                 view_y,
235                                 view_h);
236                         trackscroll->set_position();
237                 }
238         }
239         else
240                 create_track_scroll(view_x, view_y, view_w, view_h);
241
242         canvas->reposition_window(view_x, view_y, view_w, view_h);
243         canvas->resize_event();
244 }
245
246 void TimelinePane::create_sample_scroll(int view_x, int view_y, int view_w, int view_h)
247 {
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)
255         {
256 //printf("TimelinePane::create_sample_scroll %d %d %d\n", __LINE__, y, h);
257                 gui->add_subwindow(samplescroll = new SampleScroll(mwindow, 
258                         this, 
259                         view_x, 
260                         y + h - BC_ScrollBar::get_span(SCROLL_VERT), 
261                         view_w));
262                 samplescroll->set_position();
263         }
264 }
265
266 void TimelinePane::create_track_scroll(int view_x, int view_y, int view_w, int view_h)
267 {
268         if(number == TOP_RIGHT_PANE ||
269                 number == BOTTOM_RIGHT_PANE ||
270                 gui->vertical_panes() ||
271                 gui->total_panes() == 1)
272         {
273                 gui->add_subwindow(trackscroll = new TrackScroll(mwindow, 
274                         this,
275                         view_x + view_w,
276                         view_y,
277                         view_h));
278                 trackscroll->set_position();
279         }
280 }
281
282
283 void TimelinePane::update(int scrollbars,
284         int do_canvas,
285         int timebar,
286         int patchbay)
287 {
288         if(timebar && this->timebar) this->timebar->update(0);
289         if(patchbay && this->patchbay) this->patchbay->update();
290         if(scrollbars) 
291         {
292                 if(samplescroll && this->samplescroll) samplescroll->set_position();
293                 if(trackscroll && this->trackscroll) trackscroll->set_position();
294         }
295
296         if(do_canvas)
297         {
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
302 // picon thread.
303 //              if(do_canvas != IGNORE_THREAD) this->canvas->activate();
304         }
305 }
306
307 void TimelinePane::activate()
308 {
309         canvas->activate();
310         gui->focused_pane = number;
311 }
312
313
314
315
316
317
318
319
320
321
322