record batch dir path fix, handle yuv in gl masking, sync up maskengine/playback3d...
[goodguy/cinelerra.git] / cinelerra-5.1 / cinelerra / vtimebar.C
1
2 /*
3  * CINELERRA
4  * Copyright (C) 2008 Adam Williams <broadcast at earthling dot net>
5  *
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.
10  *
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.
15  *
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
19  *
20  */
21
22 #include "edl.h"
23 #include "localsession.h"
24 #include "mwindow.h"
25 #include "theme.h"
26 #include "vtimebar.h"
27 #include "vwindow.h"
28 #include "vwindowgui.h"
29
30
31 VTimeBar::VTimeBar(MWindow *mwindow,
32                 VWindowGUI *gui,
33                 int x,
34                 int y,
35                 int w,
36                 int h)
37  : TimeBar(mwindow,
38                 gui,
39                 x,
40                 y,
41                 w,
42                 h)
43 {
44         this->mwindow = mwindow;
45         this->gui = gui;
46 }
47
48 int VTimeBar::resize_event()
49 {
50         reposition_window(mwindow->theme->vtimebar_x,
51                 mwindow->theme->vtimebar_y,
52                 mwindow->theme->vtimebar_w,
53                 mwindow->theme->vtimebar_h);
54         update(0);
55         return 1;
56 }
57
58 EDL* VTimeBar::get_edl()
59 {
60         return gui->vwindow->get_edl();
61 }
62
63 void VTimeBar::draw_time()
64 {
65         draw_range();
66 }
67
68 void VTimeBar::select_label(double position)
69 {
70         EDL *edl = get_edl();
71         if( edl ) {
72                 gui->stop_transport();
73                 position = mwindow->edl->align_to_frame(position, 1);
74
75                 if(shift_down())
76                 {
77                         if(position > edl->local_session->get_selectionend(1) / 2 +
78                                 edl->local_session->get_selectionstart(1) / 2)
79                         {
80
81                                 edl->local_session->set_selectionend(position);
82                         }
83                         else
84                         {
85                                 edl->local_session->set_selectionstart(position);
86                         }
87                 }
88                 else
89                 {
90                         edl->local_session->set_selectionstart(position);
91                         edl->local_session->set_selectionend(position);
92                 }
93
94 // Que the CWindow
95                 gui->vwindow->update_position();
96                 update(1);
97         }
98 }
99
100 double VTimeBar::pixel_to_position(int pixel)
101 {
102         double start = 0, end = get_edl_length();
103         EDL *edl = get_edl();
104         if( edl ) {
105                 double preview_start = edl->local_session->preview_start;
106                 double preview_end = edl->local_session->preview_end;
107                 if( preview_end >= 0 || preview_start > 0 )
108                         start = preview_start;
109                 if( preview_end >= 0 && preview_end < end )
110                         end = preview_end;
111         }
112         if( start > end ) start = end;
113         return start + (double)pixel * (end - start) / get_w();
114 }
115
116
117 void VTimeBar::update_cursor()
118 {
119         int rx = get_relative_cursor_x();
120         double position = pixel_to_position(rx);
121         gui->vwindow->update_position(position);
122         update(1);
123 }
124
125 double VTimeBar::test_highlight()
126 {
127         return gui->edit_panel->get_position();
128 }
129