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