Credit Andrew - fix vorbis audio which was scratchy and ensure aging plugin does...
[goodguy/cinelerra.git] / cinelerra-5.1 / cinelerra / timebar.h
1
2 /*
3  * CINELERRA
4  * Copyright (C) 1997-2014 Adam Williams <broadcast at earthling dot net>
5  * Copyright (C) 2003-2016 Cinelerra CV contributors
6  *
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.
11  *
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.
16  *
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
20  *
21  */
22
23 #ifndef TIMEBAR_H
24 #define TIMEBAR_H
25
26 #include "edl.inc"
27 #include "guicast.h"
28 #include "filexml.inc"
29 #include "labels.inc"
30 #include "labeledit.inc"
31 #include "mwindow.inc"
32 #include "recordlabel.inc"
33 #include "testobject.h"
34 #include "timebar.inc"
35 #include "timelinepane.inc"
36 #include "vwindowgui.inc"
37
38 class TimeBarLeftArrow;
39 class TimeBarRightArrow;
40
41 class LabelGUI;
42 class InPointGUI;
43 class OutPointGUI;
44 class PresentationGUI;
45
46 // Operations for cursor
47 #define TIMEBAR_NONE        0
48 #define TIMEBAR_DRAG        1
49 #define TIMEBAR_DRAG_LEFT   2
50 #define TIMEBAR_DRAG_RIGHT  3
51 #define TIMEBAR_DRAG_CENTER 4
52 #define TIMEBAR_DRAG_LABEL  5
53
54 class LabelGUI : public BC_Toggle
55 {
56 public:
57         LabelGUI(MWindow *mwindow,
58                 TimeBar *timebar,
59                 int64_t pixel,
60                 int y,
61                 double position,
62                 VFrame **data = 0);
63         virtual ~LabelGUI();
64
65         static int translate_pixel(MWindow *mwindow, int pixel);
66         virtual int handle_event();
67         static int get_y(MWindow *mwindow, TimeBar *timebar);
68         void reposition(int flush = 1);
69         void update_value();
70         int test_drag_label(int press);
71
72         Label *label;
73         int button_press_event();
74         int button_release_event();
75         MWindow *mwindow;
76         VWindowGUI *gui;
77         TimeBar *timebar;
78         int64_t pixel;
79         double position;
80 };
81
82 class TestPointGUI : public LabelGUI
83 {
84 public:
85         TestPointGUI(MWindow *mwindow,
86                 TimeBar *timebar,
87                 int64_t pixel,
88                 double position);
89 };
90
91 class InPointGUI : public LabelGUI
92 {
93 public:
94         InPointGUI(MWindow *mwindow,
95                 TimeBar *timebar,
96                 int64_t pixel,
97                 double position);
98         virtual ~InPointGUI();
99         static int get_y(MWindow *mwindow, TimeBar *timebar);
100 };
101
102 class OutPointGUI : public LabelGUI
103 {
104 public:
105         OutPointGUI(MWindow *mwindow,
106                 TimeBar *timebar,
107                 int64_t pixel,
108                 double position);
109         virtual ~OutPointGUI();
110         static int get_y(MWindow *mwindow, TimeBar *timebar);
111 };
112
113 class PresentationGUI : public LabelGUI
114 {
115 public:
116         PresentationGUI(MWindow *mwindow,
117                 TimeBar *timebar,
118                 int64_t pixel,
119                 double position);
120         ~PresentationGUI();
121 };
122
123 class TimeBar : public BC_SubWindow
124 {
125 public:
126         TimeBar(MWindow *mwindow,
127                 BC_WindowBase *gui,
128                 int x,
129                 int y,
130                 int w,
131                 int h);
132         virtual ~TimeBar();
133
134         virtual void create_objects();
135         int update_defaults();
136         virtual int button_press_event();
137         virtual int button_release_event();
138         int cursor_motion_event();
139         int cursor_leave_event();
140         virtual void update_clock(double position);
141
142         LabelEdit *label_edit;
143
144 // Synchronize label, in/out, presentation display with master EDL
145         virtual void update(int flush);
146         virtual void draw_time();
147 // Called by update and draw_time.
148         virtual void draw_range();
149         virtual void select_label(double position);
150         virtual void stop_playback();
151         virtual EDL* get_edl();
152         virtual int test_preview(int buttonpress);
153         virtual void update_preview();
154         virtual int64_t position_to_pixel(double position);
155         virtual double pixel_to_position(int pixel);
156         virtual void handle_mwindow_drag();
157         virtual void activate_timeline();
158         int move_preview(int &redraw);
159 // Get highlight status when the cursor is over the timeline.
160         virtual double test_highlight();
161         virtual int has_preview() { return 0; }
162         virtual int is_vwindow() { return 0; }
163
164
165         void update_labels();
166         void update_points();
167 // Make sure widgets are highlighted according to selection status
168         void update_highlights();
169         void draw_inout_highlight();
170 // Update highlight cursor during a drag
171         virtual void update_cursor();
172
173 // ================================= file operations
174
175         int save(FileXML *xml);
176         int load(FileXML *xml, int undo_type);
177
178         int delete_project();        // clear timebar of labels
179
180         int draw();                  // draw everything over
181         int samplemovement();
182         int refresh_labels();
183
184 // ========================================= editing
185
186         int select_region(double position);
187         double get_edl_length();
188
189         MWindow *mwindow;
190         BC_WindowBase *gui;
191         TimelinePane *pane;
192         int flip_vertical(int w, int h);
193         int delete_arrows();    // for flipping vertical
194
195 // Operation started by a buttonpress
196         int current_operation;
197         LabelGUI *drag_label;
198
199 private:
200         int get_preview_pixels(int &x1, int &x2);
201         int draw_bevel();
202         ArrayList<LabelGUI*> labels;
203         InPointGUI *in_point;
204         OutPointGUI *out_point;
205         ArrayList<PresentationGUI*> presentations;
206
207
208
209 // Records for dragging operations
210         double start_position;
211         double starting_start_position;
212         double starting_end_position;
213         double time_per_pixel;
214         double edl_length;
215         int start_cursor_x;
216         int highlighted;
217 };
218
219
220 #endif