2 #include "edlsession.h"
3 #include "localsession.h"
5 #include "mwindowgui.h"
6 #include "mainsession.h"
8 #include "preferences.h"
10 #include "trackcanvas.h"
17 #define _(String) gettext(String)
18 #define gettext_noop(String) String
19 #define N_(String) gettext_noop (String)
24 ZoomBar::ZoomBar(MWindow *mwindow, MWindowGUI *gui)
25 : BC_SubWindow(mwindow->theme->mzoom_x,
26 mwindow->theme->mzoom_y,
27 mwindow->theme->mzoom_w,
28 mwindow->theme->mzoom_h)
31 this->mwindow = mwindow;
42 int ZoomBar::create_objects()
46 draw_top_background(get_parent(), 0, 0, get_w(), get_h());
47 sample_zoom = new SampleZoomPanel(mwindow, this, x, y);
48 sample_zoom->create_objects();
49 x += sample_zoom->get_w();
50 amp_zoom = new AmpZoomPanel(mwindow, this, x, y);
51 amp_zoom->create_objects();
52 x += amp_zoom->get_w();
53 track_zoom = new TrackZoomPanel(mwindow, this, x, y);
54 track_zoom->create_objects();
55 x += track_zoom->get_w() + 5;
58 add_subwindow(from_value = new FromTextBox(mwindow, this, x, y));
59 x += from_value->get_w() + 5;
60 add_subwindow(length_value = new LengthTextBox(mwindow, this, x, y));
61 x += length_value->get_w() + 5;
62 add_subwindow(to_value = new ToTextBox(mwindow, this, x, y));
63 x += to_value->get_w() + 5;
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::resize_event()
75 reposition_window(mwindow->theme->mzoom_x,
76 mwindow->theme->mzoom_y,
77 mwindow->theme->mzoom_w,
78 mwindow->theme->mzoom_h);
80 draw_top_background(get_parent(), 0, 0, get_w(), get_h());
82 sample_zoom->reposition_window(x, y);
83 x += sample_zoom->get_w();
84 amp_zoom->reposition_window(x, y);
85 x += amp_zoom->get_w();
86 track_zoom->reposition_window(x, y);
90 void ZoomBar::redraw_time_dependancies()
92 // Recalculate sample zoom menu
93 sample_zoom->update_menu();
94 sample_zoom->update(mwindow->edl->local_session->zoom_sample);
104 int ZoomBar::update()
106 //printf("ZoomBar::update 1 %f\n", mwindow->edl->local_session->selectionstart);
107 sample_zoom->update(mwindow->edl->local_session->zoom_sample);
108 amp_zoom->update(mwindow->edl->local_session->zoom_y);
109 track_zoom->update(mwindow->edl->local_session->zoom_track);
114 int ZoomBar::update_clocks()
116 //printf("ZoomBar::update_clocks 1 %f\n", mwindow->edl->local_session->selectionstart);
117 from_value->update_position(mwindow->edl->local_session->selectionstart);
118 length_value->update_position(mwindow->edl->local_session->selectionend -
119 mwindow->edl->local_session->selectionstart);
120 to_value->update_position(mwindow->edl->local_session->selectionend);
124 int ZoomBar::update_playback(int64_t new_position)
126 if(new_position != old_position)
128 Units::totext(string,
130 mwindow->edl->session->sample_rate,
131 mwindow->edl->session->time_format,
132 mwindow->edl->session->frame_rate,
133 mwindow->edl->session->frames_per_foot);
134 playback_value->update(string);
135 old_position = new_position;
140 int ZoomBar::resize_event(int w, int h)
142 // don't change anything but y and width
143 reposition_window(0, h - this->get_h(), w, this->get_h());
148 // Values for which_one
154 int ZoomBar::set_selection(int which_one)
156 double start_position = mwindow->edl->local_session->selectionstart;
157 double end_position = mwindow->edl->local_session->selectionend;
158 double length = end_position - start_position;
161 // printf("ZoomBar::set_selection 1 %f %f %f\n",
162 // mwindow->edl->local_session->selectionstart,
163 // mwindow->edl->local_session->selectionend,
169 start_position = Units::text_to_seconds(from_value->get_text(),
170 mwindow->edl->session->sample_rate,
171 mwindow->edl->session->time_format,
172 mwindow->edl->session->frame_rate,
173 mwindow->edl->session->frames_per_foot);
174 length = Units::text_to_seconds(length_value->get_text(),
175 mwindow->edl->session->sample_rate,
176 mwindow->edl->session->time_format,
177 mwindow->edl->session->frame_rate,
178 mwindow->edl->session->frames_per_foot);
179 end_position = start_position + length;
181 if(end_position < start_position)
183 start_position = end_position;
184 mwindow->edl->local_session->selectionend = mwindow->edl->local_session->selectionstart;
189 start_position = Units::text_to_seconds(from_value->get_text(),
190 mwindow->edl->session->sample_rate,
191 mwindow->edl->session->time_format,
192 mwindow->edl->session->frame_rate,
193 mwindow->edl->session->frames_per_foot);
194 end_position = Units::text_to_seconds(to_value->get_text(),
195 mwindow->edl->session->sample_rate,
196 mwindow->edl->session->time_format,
197 mwindow->edl->session->frame_rate,
198 mwindow->edl->session->frames_per_foot);
200 if(end_position < start_position)
202 end_position = start_position;
203 mwindow->edl->local_session->selectionend = mwindow->edl->local_session->selectionstart;
208 start_position = Units::text_to_seconds(from_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 = Units::text_to_seconds(to_value->get_text(),
214 mwindow->edl->session->sample_rate,
215 mwindow->edl->session->time_format,
216 mwindow->edl->session->frame_rate,
217 mwindow->edl->session->frames_per_foot);
219 if(end_position < start_position)
221 start_position = end_position;
222 mwindow->edl->local_session->selectionend = mwindow->edl->local_session->selectionstart;
227 mwindow->edl->local_session->selectionstart =
228 mwindow->edl->align_to_frame(start_position, 1);
229 mwindow->edl->local_session->selectionend =
230 mwindow->edl->align_to_frame(end_position, 1);
232 // printf("ZoomBar::set_selection 2 %f %f\n",
233 // mwindow->edl->local_session->selectionstart,
234 // mwindow->edl->local_session->selectionend);
236 mwindow->gui->timebar->update_highlights();
237 mwindow->gui->cursor->hide();
238 mwindow->gui->cursor->show();
240 mwindow->sync_parameters(CHANGE_PARAMS);
241 mwindow->gui->canvas->flash();
257 SampleZoomPanel::SampleZoomPanel(MWindow *mwindow,
263 mwindow->edl->local_session->zoom_sample,
271 this->mwindow = mwindow;
272 this->zoombar = zoombar;
274 SampleZoomPanel::~SampleZoomPanel()
277 int SampleZoomPanel::handle_event()
279 mwindow->zoom_sample((int64_t)get_value());
293 AmpZoomPanel::AmpZoomPanel(MWindow *mwindow, ZoomBar *zoombar, int x, int y)
296 mwindow->edl->local_session->zoom_y,
304 this->mwindow = mwindow;
305 this->zoombar = zoombar;
307 AmpZoomPanel::~AmpZoomPanel()
310 int AmpZoomPanel::handle_event()
312 mwindow->zoom_amp((int64_t)get_value());
316 TrackZoomPanel::TrackZoomPanel(MWindow *mwindow, ZoomBar *zoombar, int x, int y)
319 mwindow->edl->local_session->zoom_track,
327 this->mwindow = mwindow;
328 this->zoombar = zoombar;
330 TrackZoomPanel::~TrackZoomPanel()
333 int TrackZoomPanel::handle_event()
335 mwindow->zoom_track((int64_t)get_value());
336 zoombar->amp_zoom->update(mwindow->edl->local_session->zoom_y);
345 FromTextBox::FromTextBox(MWindow *mwindow, ZoomBar *zoombar, int x, int y)
346 : BC_TextBox(x, y, 90, 1, "")
348 this->mwindow = mwindow;
349 this->zoombar = zoombar;
352 int FromTextBox::handle_event()
354 if(get_keypress() == 13)
356 zoombar->set_selection(SET_FROM);
362 int FromTextBox::update_position(double new_position)
364 Units::totext(string,
366 mwindow->edl->session->time_format,
367 mwindow->edl->session->sample_rate,
368 mwindow->edl->session->frame_rate,
369 mwindow->edl->session->frames_per_foot);
370 //printf("FromTextBox::update_position %f %s\n", new_position, string);
380 LengthTextBox::LengthTextBox(MWindow *mwindow, ZoomBar *zoombar, int x, int y)
381 : BC_TextBox(x, y, 90, 1, "")
383 this->mwindow = mwindow;
384 this->zoombar = zoombar;
387 int LengthTextBox::handle_event()
389 if(get_keypress() == 13)
391 zoombar->set_selection(SET_LENGTH);
397 int LengthTextBox::update_position(double new_position)
399 Units::totext(string,
401 mwindow->edl->session->time_format,
402 mwindow->edl->session->sample_rate,
403 mwindow->edl->session->frame_rate,
404 mwindow->edl->session->frames_per_foot);
413 ToTextBox::ToTextBox(MWindow *mwindow, ZoomBar *zoombar, int x, int y)
414 : BC_TextBox(x, y, 90, 1, "")
416 this->mwindow = mwindow;
417 this->zoombar = zoombar;
420 int ToTextBox::handle_event()
422 if(get_keypress() == 13)
424 zoombar->set_selection(SET_TO);
430 int ToTextBox::update_position(double new_position)
432 Units::totext(string,
434 mwindow->edl->session->time_format,
435 mwindow->edl->session->sample_rate,
436 mwindow->edl->session->frame_rate,
437 mwindow->edl->session->frames_per_foot);