4 * Copyright (C) 2008 Adam Williams <broadcast at earthling dot net>
5 * Copyright (C) 2003-2016 Cinelerra CV contributors
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23 #include "bcsignals.h"
26 #include "cwindowgui.h"
28 #include "localsession.h"
29 #include "maincursor.h"
32 #include "mwindowgui.h"
34 #include "trackcanvas.inc"
37 CTimeBar::CTimeBar(MWindow *mwindow, CWindowGUI *gui,
38 int x, int y, int w, int h)
39 : TimeBar(mwindow, gui, x, y, w, h)
41 this->mwindow = mwindow;
43 // *** CONTEXT_HELP ***
44 context_help_set_keyword("Preview Region Usage");
47 int CTimeBar::resize_event()
49 reposition_window(mwindow->theme->ctimebar_x,
50 mwindow->theme->ctimebar_y,
51 mwindow->theme->ctimebar_w,
52 mwindow->theme->ctimebar_h);
58 EDL* CTimeBar::get_edl()
63 void CTimeBar::draw_time()
69 double CTimeBar::pixel_to_position(int pixel)
71 double start = 0, end = get_edl_length();
74 double preview_start = edl->local_session->preview_start;
75 double preview_end = edl->local_session->preview_end;
76 if( preview_end >= 0 || preview_start > 0 )
77 start = preview_start;
78 if( preview_end >= 0 && preview_end < end )
81 if( start > end ) start = end;
82 return start + (double)pixel * (end - start) / get_w();
86 void CTimeBar::update_cursor()
88 int rx = get_relative_cursor_x();
89 double position = pixel_to_position(rx);
90 mwindow->cwindow->update_position(position);
95 void CTimeBar::select_label(double position)
97 gui->stop_transport("CTimeBar::select_label");
99 EDL *edl = mwindow->edl;
100 position = edl->align_to_frame(position, 1);
103 if( position > edl->local_session->get_selectionend(1) / 2 +
104 edl->local_session->get_selectionstart(1) / 2 ) {
106 edl->local_session->set_selectionend(position);
109 edl->local_session->set_selectionstart(position);
113 edl->local_session->set_selectionstart(position);
114 edl->local_session->set_selectionend(position);
119 mwindow->cwindow->update(1, 0, 0, 0, 1);
120 mwindow->gui->lock_window();
121 mwindow->gui->hide_cursor(0);
122 mwindow->gui->draw_cursor(1);
123 mwindow->gui->update(0, NORMAL_DRAW, 1, 0, 1, 1, 0);
124 mwindow->gui->unlock_window();
125 mwindow->update_plugin_guis();
126 lock_window("CTimeBar::select_label");