3 #include "edlsession.h"
5 #include "localsession.h"
6 #include "maincursor.h"
8 #include "mwindowgui.h"
9 #include "mainsession.h"
11 #include "preferences.h"
13 #include "trackcanvas.h"
21 ZoomBar::ZoomBar(MWindow *mwindow, MWindowGUI *gui)
22 : BC_SubWindow(mwindow->theme->mzoom_x,
23 mwindow->theme->mzoom_y,
24 mwindow->theme->mzoom_w,
25 mwindow->theme->mzoom_h)
28 this->mwindow = mwindow;
39 int ZoomBar::create_objects()
43 mwindow->theme->get_image_set("zoombar_menu", 0)[0]->get_h() / 2;
45 draw_top_background(get_parent(), 0, 0, get_w(), get_h());
46 sample_zoom = new SampleZoomPanel(mwindow, this, x, y);
47 sample_zoom->set_menu_images(mwindow->theme->get_image_set("zoombar_menu", 0));
48 sample_zoom->set_tumbler_images(mwindow->theme->get_image_set("zoombar_tumbler", 0));
49 sample_zoom->create_objects();
50 x += sample_zoom->get_w();
51 amp_zoom = new AmpZoomPanel(mwindow, this, x, y);
52 amp_zoom->set_menu_images(mwindow->theme->get_image_set("zoombar_menu", 0));
53 amp_zoom->set_tumbler_images(mwindow->theme->get_image_set("zoombar_tumbler", 0));
54 amp_zoom->create_objects();
55 x += amp_zoom->get_w();
56 track_zoom = new TrackZoomPanel(mwindow, this, x, y);
57 track_zoom->set_menu_images(mwindow->theme->get_image_set("zoombar_menu", 0));
58 track_zoom->set_tumbler_images(mwindow->theme->get_image_set("zoombar_tumbler", 0));
59 track_zoom->create_objects();
60 x += track_zoom->get_w() + 10;
62 #define DEFAULT_TEXT "000.00 to 000.00"
63 add_subwindow(auto_zoom_text = new ZoomTextBox(
67 get_h() / 2 - BC_Title::calculate_h(this, "0") / 2,
69 x += auto_zoom_text->get_w() + 5;
70 add_subwindow(auto_zoom = new AutoZoom(mwindow, this, x, y));
72 x += auto_zoom->get_w() + 5;
74 add_subwindow(from_value = new FromTextBox(mwindow, this, x, y));
75 x += from_value->get_w() + 5;
76 add_subwindow(length_value = new LengthTextBox(mwindow, this, x, y));
77 x += length_value->get_w() + 5;
78 add_subwindow(to_value = new ToTextBox(mwindow, this, x, y));
79 x += to_value->get_w() + 5;
81 update_formatting(from_value);
82 update_formatting(length_value);
83 update_formatting(to_value);
85 add_subwindow(playback_value = new BC_Title(x, 100, _("--"), MEDIUMFONT, RED));
87 add_subwindow(zoom_value = new BC_Title(x, 100, _("--"), MEDIUMFONT, BLACK));
93 void ZoomBar::update_formatting(BC_TextBox *dst)
96 Units::format_to_separators(mwindow->edl->session->time_format));
99 void ZoomBar::resize_event()
101 reposition_window(mwindow->theme->mzoom_x,
102 mwindow->theme->mzoom_y,
103 mwindow->theme->mzoom_w,
104 mwindow->theme->mzoom_h);
106 draw_top_background(get_parent(), 0, 0, get_w(), get_h());
108 // sample_zoom->reposition_window(x, y);
109 // x += sample_zoom->get_w();
110 // amp_zoom->reposition_window(x, y);
111 // x += amp_zoom->get_w();
112 // track_zoom->reposition_window(x, y);
116 void ZoomBar::redraw_time_dependancies()
118 // Recalculate sample zoom menu
119 sample_zoom->update_menu();
120 sample_zoom->update(mwindow->edl->local_session->zoom_sample);
121 update_formatting(from_value);
122 update_formatting(length_value);
123 update_formatting(to_value);
134 void ZoomBar::update_autozoom()
136 char string[BCTEXTLEN];
137 sprintf(string, "%0.02f to %0.02f\n",
138 mwindow->edl->local_session->automation_min,
139 mwindow->edl->local_session->automation_max);
140 auto_zoom_text->update(string);
143 int ZoomBar::update()
145 sample_zoom->update(mwindow->edl->local_session->zoom_sample);
146 amp_zoom->update(mwindow->edl->local_session->zoom_y);
147 track_zoom->update(mwindow->edl->local_session->zoom_track);
153 int ZoomBar::update_clocks()
155 from_value->update_position(mwindow->edl->local_session->get_selectionstart(1));
156 length_value->update_position(mwindow->edl->local_session->get_selectionend(1) -
157 mwindow->edl->local_session->get_selectionstart(1));
158 to_value->update_position(mwindow->edl->local_session->get_selectionend(1));
162 int ZoomBar::update_playback(int64_t new_position)
164 if(new_position != old_position)
166 Units::totext(string,
168 mwindow->edl->session->sample_rate,
169 mwindow->edl->session->time_format,
170 mwindow->edl->session->frame_rate,
171 mwindow->edl->session->frames_per_foot);
172 playback_value->update(string);
173 old_position = new_position;
178 int ZoomBar::resize_event(int w, int h)
180 // don't change anything but y and width
181 reposition_window(0, h - this->get_h(), w, this->get_h());
186 // Values for which_one
192 int ZoomBar::set_selection(int which_one)
194 double start_position = mwindow->edl->local_session->get_selectionstart(1);
195 double end_position = mwindow->edl->local_session->get_selectionend(1);
196 double length = end_position - start_position;
203 start_position = Units::text_to_seconds(from_value->get_text(),
204 mwindow->edl->session->sample_rate,
205 mwindow->edl->session->time_format,
206 mwindow->edl->session->frame_rate,
207 mwindow->edl->session->frames_per_foot);
208 length = Units::text_to_seconds(length_value->get_text(),
209 mwindow->edl->session->sample_rate,
210 mwindow->edl->session->time_format,
211 mwindow->edl->session->frame_rate,
212 mwindow->edl->session->frames_per_foot);
213 end_position = start_position + length;
215 if(end_position < start_position)
217 start_position = end_position;
218 mwindow->edl->local_session->set_selectionend(
219 mwindow->edl->local_session->get_selectionstart(1));
224 start_position = Units::text_to_seconds(from_value->get_text(),
225 mwindow->edl->session->sample_rate,
226 mwindow->edl->session->time_format,
227 mwindow->edl->session->frame_rate,
228 mwindow->edl->session->frames_per_foot);
229 end_position = Units::text_to_seconds(to_value->get_text(),
230 mwindow->edl->session->sample_rate,
231 mwindow->edl->session->time_format,
232 mwindow->edl->session->frame_rate,
233 mwindow->edl->session->frames_per_foot);
235 if(end_position < start_position)
237 end_position = start_position;
238 mwindow->edl->local_session->set_selectionend(
239 mwindow->edl->local_session->get_selectionstart(1));
244 start_position = Units::text_to_seconds(from_value->get_text(),
245 mwindow->edl->session->sample_rate,
246 mwindow->edl->session->time_format,
247 mwindow->edl->session->frame_rate,
248 mwindow->edl->session->frames_per_foot);
249 end_position = Units::text_to_seconds(to_value->get_text(),
250 mwindow->edl->session->sample_rate,
251 mwindow->edl->session->time_format,
252 mwindow->edl->session->frame_rate,
253 mwindow->edl->session->frames_per_foot);
255 if(end_position < start_position)
257 start_position = end_position;
258 mwindow->edl->local_session->set_selectionend(
259 mwindow->edl->local_session->get_selectionstart(1));
264 mwindow->edl->local_session->set_selectionstart(
265 mwindow->edl->align_to_frame(start_position, 1));
266 mwindow->edl->local_session->set_selectionend(
267 mwindow->edl->align_to_frame(end_position, 1));
270 mwindow->gui->timebar->update_highlights();
271 mwindow->gui->cursor->hide();
272 mwindow->gui->cursor->show();
274 mwindow->sync_parameters(CHANGE_PARAMS);
275 mwindow->gui->canvas->flash();
291 SampleZoomPanel::SampleZoomPanel(MWindow *mwindow,
297 mwindow->edl->local_session->zoom_sample,
305 this->mwindow = mwindow;
306 this->zoombar = zoombar;
308 int SampleZoomPanel::handle_event()
310 mwindow->zoom_sample((int64_t)get_value());
324 AmpZoomPanel::AmpZoomPanel(MWindow *mwindow, ZoomBar *zoombar, int x, int y)
327 mwindow->edl->local_session->zoom_y,
335 this->mwindow = mwindow;
336 this->zoombar = zoombar;
338 int AmpZoomPanel::handle_event()
340 mwindow->zoom_amp((int64_t)get_value());
344 TrackZoomPanel::TrackZoomPanel(MWindow *mwindow, ZoomBar *zoombar, int x, int y)
347 mwindow->edl->local_session->zoom_track,
355 this->mwindow = mwindow;
356 this->zoombar = zoombar;
358 int TrackZoomPanel::handle_event()
360 mwindow->zoom_track((int64_t)get_value());
361 zoombar->amp_zoom->update(mwindow->edl->local_session->zoom_y);
368 AutoZoom::AutoZoom(MWindow *mwindow, ZoomBar *zoombar, int x, int y)
371 mwindow->theme->get_image_set("zoombar_tumbler"))
373 this->mwindow = mwindow;
374 this->zoombar = zoombar;
377 int AutoZoom::handle_up_event()
379 mwindow->expand_autos();
383 int AutoZoom::handle_down_event()
385 mwindow->shrink_autos();
391 ZoomTextBox::ZoomTextBox(MWindow *mwindow, ZoomBar *zoombar, int x, int y, char *text)
392 : BC_TextBox(x, y, 130, 1, text)
394 this->mwindow = mwindow;
395 this->zoombar = zoombar;
398 int ZoomTextBox::handle_event()
401 sscanf(this->get_text(),"%f to %f",&min, &max);
403 mwindow->edl->local_session->automation_min = min;
404 mwindow->edl->local_session->automation_max = max;
405 mwindow->gui->zoombar->update_autozoom();
406 mwindow->gui->canvas->draw_overlays();
407 mwindow->gui->canvas->flash();
416 FromTextBox::FromTextBox(MWindow *mwindow, ZoomBar *zoombar, int x, int y)
417 : BC_TextBox(x, y, 90, 1, "")
419 this->mwindow = mwindow;
420 this->zoombar = zoombar;
423 int FromTextBox::handle_event()
425 if(get_keypress() == 13)
427 zoombar->set_selection(SET_FROM);
433 int FromTextBox::update_position(double new_position)
435 new_position += mwindow->edl->session->get_frame_offset() /
436 mwindow->edl->session->frame_rate;;
437 Units::totext(string,
439 mwindow->edl->session->time_format,
440 mwindow->edl->session->sample_rate,
441 mwindow->edl->session->frame_rate,
442 mwindow->edl->session->frames_per_foot);
443 //printf("FromTextBox::update_position %f %s\n", new_position, string);
453 LengthTextBox::LengthTextBox(MWindow *mwindow, ZoomBar *zoombar, int x, int y)
454 : BC_TextBox(x, y, 90, 1, "")
456 this->mwindow = mwindow;
457 this->zoombar = zoombar;
460 int LengthTextBox::handle_event()
462 if(get_keypress() == 13)
464 zoombar->set_selection(SET_LENGTH);
470 int LengthTextBox::update_position(double new_position)
472 Units::totext(string,
474 mwindow->edl->session->time_format,
475 mwindow->edl->session->sample_rate,
476 mwindow->edl->session->frame_rate,
477 mwindow->edl->session->frames_per_foot);
486 ToTextBox::ToTextBox(MWindow *mwindow, ZoomBar *zoombar, int x, int y)
487 : BC_TextBox(x, y, 90, 1, "")
489 this->mwindow = mwindow;
490 this->zoombar = zoombar;
493 int ToTextBox::handle_event()
495 if(get_keypress() == 13)
497 zoombar->set_selection(SET_TO);
503 int ToTextBox::update_position(double new_position)
505 new_position += mwindow->edl->session->get_frame_offset() /
506 mwindow->edl->session->frame_rate;
507 Units::totext(string,
509 mwindow->edl->session->time_format,
510 mwindow->edl->session->sample_rate,
511 mwindow->edl->session->frame_rate,
512 mwindow->edl->session->frames_per_foot);