3 #include "edlsession.h"
4 #include "localsession.h"
5 #include "mainsession.h"
8 #include "mwindowgui.h"
10 #include "preferences.h"
12 #include "trackcanvas.h"
14 #include "transportque.h"
19 MTimeBar::MTimeBar(MWindow *mwindow,
25 : TimeBar(mwindow, gui, x, y, w, h)
31 int64_t MTimeBar::position_to_pixel(double position)
33 return (int64_t)(position *
34 mwindow->edl->session->sample_rate /
35 mwindow->edl->local_session->zoom_sample -
36 mwindow->edl->local_session->view_start);
40 void MTimeBar::stop_playback()
43 gui->mbuttons->transport->handle_transport(STOP, 1);
48 void MTimeBar::draw_time()
50 //printf("TimeBar::draw_time 1\n");
52 //printf("TimeBar::draw_time 2\n");
55 int64_t windowspan, timescale1, timescale2, sample_rate, sample;
59 #define TIMESPACING 100
61 sample_rate = mwindow->edl->session->sample_rate;
62 windowspan = mwindow->edl->local_session->zoom_sample * get_w();
63 timescale2 = TIMESPACING * mwindow->edl->local_session->zoom_sample;
65 if(timescale2 <= sample_rate / 4) timescale1 = sample_rate / 4;
67 if(timescale2 <= sample_rate / 2) timescale1 = sample_rate / 2;
69 if(timescale2 <= sample_rate) timescale1 = sample_rate;
71 if(timescale2 <= sample_rate * 10) timescale1 = sample_rate * 10;
73 if(timescale2 <= sample_rate * 60) timescale1 = sample_rate * 60;
75 if(timescale2 <= sample_rate * 600) timescale1 = sample_rate * 600;
77 timescale1 = sample_rate * 3600;
79 for(timescale3 = timescale1; timescale3 > timescale2; timescale3 /= 2)
82 timescale1 = (int64_t)(timescale3 * 2);
84 sample = (int64_t)(mwindow->edl->local_session->view_start *
85 mwindow->edl->local_session->zoom_sample +
90 pixel = (int64_t)(sample /
91 mwindow->edl->local_session->zoom_sample -
92 mwindow->edl->local_session->view_start);
94 for( ; pixel < get_w(); pixel += timescale1 / mwindow->edl->local_session->zoom_sample, sample += timescale1)
99 mwindow->edl->session->time_format,
100 mwindow->edl->session->frame_rate,
101 mwindow->edl->session->frames_per_foot);
103 set_font(MEDIUMFONT);
104 draw_text(pixel + 4, get_text_ascent(MEDIUMFONT), string);
105 draw_line(pixel, 3, pixel, get_h() - 4);
109 void MTimeBar::draw_range()
112 if(mwindow->edl->tracks->total_playable_vtracks() &&
113 mwindow->preferences->use_brender)
115 double time_per_pixel = (double)mwindow->edl->local_session->zoom_sample /
116 mwindow->edl->session->sample_rate;
117 x1 = (int)(mwindow->edl->session->brender_start / time_per_pixel) -
118 mwindow->edl->local_session->view_start;
119 x2 = (int)(mwindow->session->brender_end / time_per_pixel) -
120 mwindow->edl->local_session->view_start;
123 //printf("MTimeBar::draw_range 1 %f %f\n", mwindow->edl->session->brender_start, mwindow->session->brender_end);
128 draw_top_background(get_parent(), 0, 0, x1, get_h());
129 draw_3segmenth(x1, 0, x2 - x1, mwindow->theme->timebar_brender_data);
130 draw_top_background(get_parent(), x2, 0, get_w() - x2, get_h());
133 draw_top_background(get_parent(), 0, 0, get_w(), get_h());
134 //printf("MTimeBar::draw_range %f %f\n", mwindow->session->brender_end, time_per_pixel);
137 void MTimeBar::select_label(double position)
139 EDL *edl = mwindow->edl;
141 mwindow->gui->unlock_window();
142 mwindow->gui->mbuttons->transport->handle_transport(STOP, 1);
143 mwindow->gui->lock_window();
145 position = mwindow->edl->align_to_frame(position, 1);
149 if(position > edl->local_session->selectionend / 2 + edl->local_session->selectionstart / 2)
152 edl->local_session->selectionend = position;
156 edl->local_session->selectionstart = position;
161 edl->local_session->selectionstart = edl->local_session->selectionend = position;
165 mwindow->cwindow->update(1, 0, 0);
166 mwindow->gui->cursor->hide();
167 mwindow->gui->cursor->draw();
168 mwindow->gui->canvas->activate();
169 mwindow->gui->zoombar->update();
171 mwindow->gui->canvas->flash();
175 int MTimeBar::resize_event()
177 reposition_window(mwindow->theme->mtimebar_x,
178 mwindow->theme->mtimebar_y,
179 mwindow->theme->mtimebar_w,
180 mwindow->theme->mtimebar_h);
185 int MTimeBar::test_preview(int buttonpress)