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