4 #include "edlsession.h"
5 #include "localsession.h"
6 #include "maincursor.h"
7 #include "mainsession.h"
10 #include "mwindowgui.h"
12 #include "preferences.h"
14 #include "trackcanvas.h"
16 #include "transportque.h"
21 MTimeBar::MTimeBar(MWindow *mwindow,
27 : TimeBar(mwindow, gui, x, y, w, h)
33 int64_t MTimeBar::position_to_pixel(double position)
35 return (int64_t)(position *
36 mwindow->edl->session->sample_rate /
37 mwindow->edl->local_session->zoom_sample -
38 mwindow->edl->local_session->view_start);
42 void MTimeBar::stop_playback()
45 gui->mbuttons->transport->handle_transport(STOP, 1);
50 void MTimeBar::draw_time()
55 int64_t windowspan = 0;
56 int64_t timescale1 = 0;
57 int64_t timescale2 = 0;
58 int64_t sample_rate = 0;
62 char string[BCTEXTLEN];
63 #define TIMESPACING 100
65 sample_rate = mwindow->edl->session->sample_rate;
66 windowspan = mwindow->edl->local_session->zoom_sample * get_w();
67 timescale2 = TIMESPACING * mwindow->edl->local_session->zoom_sample;
69 if(timescale2 <= sample_rate / 4) timescale1 = sample_rate / 4;
71 if(timescale2 <= sample_rate / 2) timescale1 = sample_rate / 2;
73 if(timescale2 <= sample_rate) timescale1 = sample_rate;
75 if(timescale2 <= sample_rate * 10) timescale1 = sample_rate * 10;
77 if(timescale2 <= sample_rate * 60) timescale1 = sample_rate * 60;
79 if(timescale2 <= sample_rate * 600) timescale1 = sample_rate * 600;
81 timescale1 = sample_rate * 3600;
83 for(timescale3 = timescale1; timescale3 > timescale2; timescale3 /= 2)
86 timescale1 = (int64_t)(timescale3 * 2);
88 sample = (int64_t)(mwindow->edl->local_session->view_start *
89 mwindow->edl->local_session->zoom_sample +
94 pixel = (int64_t)(sample /
95 mwindow->edl->local_session->zoom_sample -
96 mwindow->edl->local_session->view_start);
97 sample += (int64_t) ((mwindow->edl->session->get_frame_offset() /
98 mwindow->edl->session->frame_rate) *
103 for( ; pixel < get_w(); pixel += timescale1 / mwindow->edl->local_session->zoom_sample, sample += timescale1)
105 Units::totext(string,
108 mwindow->edl->session->time_format,
109 mwindow->edl->session->frame_rate,
110 mwindow->edl->session->frames_per_foot);
111 set_color(get_resources()->default_text_color);
112 set_font(MEDIUMFONT);
113 draw_text(pixel + 4, get_text_ascent(MEDIUMFONT), string);
114 draw_line(pixel, 3, pixel, get_h() - 4);
118 void MTimeBar::draw_range()
121 if(mwindow->edl->tracks->total_playable_vtracks() &&
122 mwindow->preferences->use_brender)
124 double time_per_pixel = (double)mwindow->edl->local_session->zoom_sample /
125 mwindow->edl->session->sample_rate;
126 x1 = (int)(mwindow->edl->session->brender_start / time_per_pixel) -
127 mwindow->edl->local_session->view_start;
128 x2 = (int)(mwindow->session->brender_end / time_per_pixel) -
129 mwindow->edl->local_session->view_start;
136 draw_top_background(get_parent(), 0, 0, x1, get_h());
138 draw_3segmenth(x1, 0, x2 - x1, mwindow->theme->get_image("timebar_brender"));
140 draw_top_background(get_parent(), x2, 0, get_w() - x2, get_h());
143 draw_top_background(get_parent(), 0, 0, get_w(), get_h());
144 //printf("MTimeBar::draw_range %f %f\n", mwindow->session->brender_end, time_per_pixel);
147 void MTimeBar::select_label(double position)
149 EDL *edl = mwindow->edl;
151 mwindow->gui->unlock_window();
152 mwindow->gui->mbuttons->transport->handle_transport(STOP, 1);
153 mwindow->gui->lock_window();
155 position = mwindow->edl->align_to_frame(position, 1);
159 if(position > edl->local_session->get_selectionend(1) / 2 +
160 edl->local_session->get_selectionstart(1) / 2)
163 edl->local_session->set_selectionend(position);
167 edl->local_session->set_selectionstart(position);
172 edl->local_session->set_selectionstart(position);
173 edl->local_session->set_selectionend(position);
177 mwindow->cwindow->update(1, 0, 0);
178 mwindow->gui->cursor->hide(0);
179 mwindow->gui->cursor->draw(1);
180 mwindow->gui->canvas->activate();
181 mwindow->gui->zoombar->update();
183 mwindow->gui->canvas->flash();
187 int MTimeBar::resize_event()
189 reposition_window(mwindow->theme->mtimebar_x,
190 mwindow->theme->mtimebar_y,
191 mwindow->theme->mtimebar_w,
192 mwindow->theme->mtimebar_h);
197 int MTimeBar::test_preview(int buttonpress)