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
23 #include "localsession.h"
28 #include "vwindowgui.h"
31 VTimeBar::VTimeBar(MWindow *mwindow,
44 this->mwindow = mwindow;
46 // *** CONTEXT_HELP ***
47 context_help_set_keyword("Preview Region Usage");
50 int VTimeBar::resize_event()
52 reposition_window(mwindow->theme->vtimebar_x,
53 mwindow->theme->vtimebar_y,
54 mwindow->theme->vtimebar_w,
55 mwindow->theme->vtimebar_h);
60 EDL* VTimeBar::get_edl()
62 return gui->vwindow->get_edl();
65 void VTimeBar::draw_time()
70 void VTimeBar::select_label(double position)
74 gui->stop_transport();
75 position = mwindow->edl->align_to_frame(position, 1);
79 if(position > edl->local_session->get_selectionend(1) / 2 +
80 edl->local_session->get_selectionstart(1) / 2)
83 edl->local_session->set_selectionend(position);
87 edl->local_session->set_selectionstart(position);
92 edl->local_session->set_selectionstart(position);
93 edl->local_session->set_selectionend(position);
97 gui->vwindow->update_position();
102 double VTimeBar::pixel_to_position(int pixel)
104 double start = 0, end = get_edl_length();
105 EDL *edl = get_edl();
107 double preview_start = edl->local_session->preview_start;
108 double preview_end = edl->local_session->preview_end;
109 if( preview_end >= 0 || preview_start > 0 )
110 start = preview_start;
111 if( preview_end >= 0 && preview_end < end )
114 if( start > end ) start = end;
115 return start + (double)pixel * (end - start) / get_w();
119 void VTimeBar::update_cursor()
121 int rx = get_relative_cursor_x();
122 double position = pixel_to_position(rx);
123 gui->vwindow->update_position(position);
127 double VTimeBar::test_highlight()
129 return gui->edit_panel->get_position();