4 * Copyright (C) 2008 Adam Williams <broadcast at earthling dot net>
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 #include "bcsignals.h"
25 #include "cwindowgui.h"
27 #include "localsession.h"
28 #include "maincursor.h"
31 #include "mwindowgui.h"
33 #include "trackcanvas.inc"
36 CTimeBar::CTimeBar(MWindow *mwindow, CWindowGUI *gui,
37 int x, int y, int w, int h)
38 : TimeBar(mwindow, gui, x, y, w, h)
40 this->mwindow = mwindow;
44 int CTimeBar::resize_event()
46 reposition_window(mwindow->theme->ctimebar_x,
47 mwindow->theme->ctimebar_y,
48 mwindow->theme->ctimebar_w,
49 mwindow->theme->ctimebar_h);
55 EDL* CTimeBar::get_edl()
60 void CTimeBar::draw_time()
66 double CTimeBar::pixel_to_position(int pixel)
68 double start = 0, end = get_edl_length();
71 double preview_start = edl->local_session->preview_start;
72 double preview_end = edl->local_session->preview_end;
73 if( preview_end >= 0 || preview_start > 0 )
74 start = preview_start;
75 if( preview_end >= 0 && preview_end < end )
78 if( start > end ) start = end;
79 return start + (double)pixel * (end - start) / get_w();
83 void CTimeBar::update_cursor()
85 int rx = get_relative_cursor_x();
86 double position = pixel_to_position(rx);
87 mwindow->cwindow->update_position(position);
92 void CTimeBar::select_label(double position)
94 gui->stop_transport("CTimeBar::select_label");
96 EDL *edl = mwindow->edl;
97 position = edl->align_to_frame(position, 1);
100 if( position > edl->local_session->get_selectionend(1) / 2 +
101 edl->local_session->get_selectionstart(1) / 2 ) {
103 edl->local_session->set_selectionend(position);
106 edl->local_session->set_selectionstart(position);
110 edl->local_session->set_selectionstart(position);
111 edl->local_session->set_selectionend(position);
116 mwindow->cwindow->update(1, 0, 0, 0, 1);
117 mwindow->gui->lock_window();
118 mwindow->gui->hide_cursor(0);
119 mwindow->gui->draw_cursor(1);
120 mwindow->gui->update(0, NORMAL_DRAW, 1, 0, 1, 1, 0);
121 mwindow->gui->unlock_window();
122 mwindow->update_plugin_guis();
123 lock_window("CTimeBar::select_label");