2 #include "edlsession.h"
4 #include "localsession.h"
5 #include "maincursor.h"
7 #include "mwindowgui.h"
8 #include "mainsession.h"
10 #include "preferences.h"
12 #include "trackcanvas.h"
20 ZoomBar::ZoomBar(MWindow *mwindow, MWindowGUI *gui)
21 : BC_SubWindow(mwindow->theme->mzoom_x,
22 mwindow->theme->mzoom_y,
23 mwindow->theme->mzoom_w,
24 mwindow->theme->mzoom_h)
27 this->mwindow = mwindow;
38 int ZoomBar::create_objects()
42 draw_top_background(get_parent(), 0, 0, get_w(), get_h());
43 sample_zoom = new SampleZoomPanel(mwindow, this, x, y);
44 sample_zoom->create_objects();
45 x += sample_zoom->get_w();
46 amp_zoom = new AmpZoomPanel(mwindow, this, x, y);
47 amp_zoom->create_objects();
48 x += amp_zoom->get_w();
49 track_zoom = new TrackZoomPanel(mwindow, this, x, y);
50 track_zoom->create_objects();
51 x += track_zoom->get_w() + 5;
54 add_subwindow(from_value = new FromTextBox(mwindow, this, x, y));
55 x += from_value->get_w() + 5;
56 add_subwindow(length_value = new LengthTextBox(mwindow, this, x, y));
57 x += length_value->get_w() + 5;
58 add_subwindow(to_value = new ToTextBox(mwindow, this, x, y));
59 x += to_value->get_w() + 5;
61 update_formatting(from_value);
62 update_formatting(length_value);
63 update_formatting(to_value);
65 add_subwindow(playback_value = new BC_Title(x, 100, _("--"), MEDIUMFONT, RED));
67 add_subwindow(zoom_value = new BC_Title(x, 100, _("--"), MEDIUMFONT, BLACK));
73 void ZoomBar::update_formatting(BC_TextBox *dst)
76 Units::format_to_separators(mwindow->edl->session->time_format));
79 void ZoomBar::resize_event()
81 reposition_window(mwindow->theme->mzoom_x,
82 mwindow->theme->mzoom_y,
83 mwindow->theme->mzoom_w,
84 mwindow->theme->mzoom_h);
86 draw_top_background(get_parent(), 0, 0, get_w(), get_h());
88 sample_zoom->reposition_window(x, y);
89 x += sample_zoom->get_w();
90 amp_zoom->reposition_window(x, y);
91 x += amp_zoom->get_w();
92 track_zoom->reposition_window(x, y);
96 void ZoomBar::redraw_time_dependancies()
98 // Recalculate sample zoom menu
99 sample_zoom->update_menu();
100 sample_zoom->update(mwindow->edl->local_session->zoom_sample);
101 update_formatting(from_value);
102 update_formatting(length_value);
103 update_formatting(to_value);
113 int ZoomBar::update()
115 //printf("ZoomBar::update 1 %f\n", mwindow->edl->local_session->selectionstart);
116 sample_zoom->update(mwindow->edl->local_session->zoom_sample);
117 amp_zoom->update(mwindow->edl->local_session->zoom_y);
118 track_zoom->update(mwindow->edl->local_session->zoom_track);
123 int ZoomBar::update_clocks()
125 //printf("ZoomBar::update_clocks 1 %f\n", mwindow->edl->local_session->selectionstart);
126 from_value->update_position(mwindow->edl->local_session->selectionstart);
127 length_value->update_position(mwindow->edl->local_session->selectionend -
128 mwindow->edl->local_session->selectionstart);
129 to_value->update_position(mwindow->edl->local_session->selectionend);
133 int ZoomBar::update_playback(int64_t new_position)
135 if(new_position != old_position)
137 Units::totext(string,
139 mwindow->edl->session->sample_rate,
140 mwindow->edl->session->time_format,
141 mwindow->edl->session->frame_rate,
142 mwindow->edl->session->frames_per_foot);
143 playback_value->update(string);
144 old_position = new_position;
149 int ZoomBar::resize_event(int w, int h)
151 // don't change anything but y and width
152 reposition_window(0, h - this->get_h(), w, this->get_h());
157 // Values for which_one
163 int ZoomBar::set_selection(int which_one)
165 double start_position = mwindow->edl->local_session->selectionstart;
166 double end_position = mwindow->edl->local_session->selectionend;
167 double length = end_position - start_position;
170 // printf("ZoomBar::set_selection 1 %f %f %f\n",
171 // mwindow->edl->local_session->selectionstart,
172 // mwindow->edl->local_session->selectionend,
178 start_position = Units::text_to_seconds(from_value->get_text(),
179 mwindow->edl->session->sample_rate,
180 mwindow->edl->session->time_format,
181 mwindow->edl->session->frame_rate,
182 mwindow->edl->session->frames_per_foot);
183 length = Units::text_to_seconds(length_value->get_text(),
184 mwindow->edl->session->sample_rate,
185 mwindow->edl->session->time_format,
186 mwindow->edl->session->frame_rate,
187 mwindow->edl->session->frames_per_foot);
188 end_position = start_position + length;
190 if(end_position < start_position)
192 start_position = end_position;
193 mwindow->edl->local_session->selectionend = mwindow->edl->local_session->selectionstart;
198 start_position = Units::text_to_seconds(from_value->get_text(),
199 mwindow->edl->session->sample_rate,
200 mwindow->edl->session->time_format,
201 mwindow->edl->session->frame_rate,
202 mwindow->edl->session->frames_per_foot);
203 end_position = Units::text_to_seconds(to_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);
209 if(end_position < start_position)
211 end_position = start_position;
212 mwindow->edl->local_session->selectionend = mwindow->edl->local_session->selectionstart;
217 start_position = Units::text_to_seconds(from_value->get_text(),
218 mwindow->edl->session->sample_rate,
219 mwindow->edl->session->time_format,
220 mwindow->edl->session->frame_rate,
221 mwindow->edl->session->frames_per_foot);
222 end_position = Units::text_to_seconds(to_value->get_text(),
223 mwindow->edl->session->sample_rate,
224 mwindow->edl->session->time_format,
225 mwindow->edl->session->frame_rate,
226 mwindow->edl->session->frames_per_foot);
228 if(end_position < start_position)
230 start_position = end_position;
231 mwindow->edl->local_session->selectionend = mwindow->edl->local_session->selectionstart;
236 mwindow->edl->local_session->selectionstart =
237 mwindow->edl->align_to_frame(start_position, 1);
238 mwindow->edl->local_session->selectionend =
239 mwindow->edl->align_to_frame(end_position, 1);
241 // printf("ZoomBar::set_selection 2 %f %f\n",
242 // mwindow->edl->local_session->selectionstart,
243 // mwindow->edl->local_session->selectionend);
245 mwindow->gui->timebar->update_highlights();
246 mwindow->gui->cursor->hide();
247 mwindow->gui->cursor->show();
249 mwindow->sync_parameters(CHANGE_PARAMS);
250 mwindow->gui->canvas->flash();
266 SampleZoomPanel::SampleZoomPanel(MWindow *mwindow,
272 mwindow->edl->local_session->zoom_sample,
280 this->mwindow = mwindow;
281 this->zoombar = zoombar;
283 SampleZoomPanel::~SampleZoomPanel()
286 int SampleZoomPanel::handle_event()
288 mwindow->zoom_sample((int64_t)get_value());
302 AmpZoomPanel::AmpZoomPanel(MWindow *mwindow, ZoomBar *zoombar, int x, int y)
305 mwindow->edl->local_session->zoom_y,
313 this->mwindow = mwindow;
314 this->zoombar = zoombar;
316 AmpZoomPanel::~AmpZoomPanel()
319 int AmpZoomPanel::handle_event()
321 mwindow->zoom_amp((int64_t)get_value());
325 TrackZoomPanel::TrackZoomPanel(MWindow *mwindow, ZoomBar *zoombar, int x, int y)
328 mwindow->edl->local_session->zoom_track,
336 this->mwindow = mwindow;
337 this->zoombar = zoombar;
339 TrackZoomPanel::~TrackZoomPanel()
342 int TrackZoomPanel::handle_event()
344 mwindow->zoom_track((int64_t)get_value());
345 zoombar->amp_zoom->update(mwindow->edl->local_session->zoom_y);
354 FromTextBox::FromTextBox(MWindow *mwindow, ZoomBar *zoombar, int x, int y)
355 : BC_TextBox(x, y, 90, 1, "")
357 this->mwindow = mwindow;
358 this->zoombar = zoombar;
361 int FromTextBox::handle_event()
363 if(get_keypress() == 13)
365 zoombar->set_selection(SET_FROM);
371 int FromTextBox::update_position(double new_position)
373 Units::totext(string,
375 mwindow->edl->session->time_format,
376 mwindow->edl->session->sample_rate,
377 mwindow->edl->session->frame_rate,
378 mwindow->edl->session->frames_per_foot);
379 //printf("FromTextBox::update_position %f %s\n", new_position, string);
389 LengthTextBox::LengthTextBox(MWindow *mwindow, ZoomBar *zoombar, int x, int y)
390 : BC_TextBox(x, y, 90, 1, "")
392 this->mwindow = mwindow;
393 this->zoombar = zoombar;
396 int LengthTextBox::handle_event()
398 if(get_keypress() == 13)
400 zoombar->set_selection(SET_LENGTH);
406 int LengthTextBox::update_position(double new_position)
408 Units::totext(string,
410 mwindow->edl->session->time_format,
411 mwindow->edl->session->sample_rate,
412 mwindow->edl->session->frame_rate,
413 mwindow->edl->session->frames_per_foot);
422 ToTextBox::ToTextBox(MWindow *mwindow, ZoomBar *zoombar, int x, int y)
423 : BC_TextBox(x, y, 90, 1, "")
425 this->mwindow = mwindow;
426 this->zoombar = zoombar;
429 int ToTextBox::handle_event()
431 if(get_keypress() == 13)
433 zoombar->set_selection(SET_TO);
439 int ToTextBox::update_position(double new_position)
441 Units::totext(string,
443 mwindow->edl->session->time_format,
444 mwindow->edl->session->sample_rate,
445 mwindow->edl->session->frame_rate,
446 mwindow->edl->session->frames_per_foot);