theme inout highlight color, drag timebar inout/labels
[goodguy/history.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         int test_drag_label(int press);
69
70         Label *label;
71         int button_press_event();
72         int button_release_event();
73         MWindow *mwindow;
74         VWindowGUI *gui;
75         TimeBar *timebar;
76         int64_t pixel;
77         double position;
78 };
79
80 class TestPointGUI : public LabelGUI
81 {
82 public:
83         TestPointGUI(MWindow *mwindow,
84                 TimeBar *timebar,
85                 int64_t pixel,
86                 double position);
87 };
88
89 class InPointGUI : public LabelGUI
90 {
91 public:
92         InPointGUI(MWindow *mwindow,
93                 TimeBar *timebar,
94                 int64_t pixel,
95                 double position);
96         virtual ~InPointGUI();
97         static int get_y(MWindow *mwindow, TimeBar *timebar);
98 };
99
100 class OutPointGUI : public LabelGUI
101 {
102 public:
103         OutPointGUI(MWindow *mwindow,
104                 TimeBar *timebar,
105                 int64_t pixel,
106                 double position);
107         virtual ~OutPointGUI();
108         static int get_y(MWindow *mwindow, TimeBar *timebar);
109 };
110
111 class PresentationGUI : public LabelGUI
112 {
113 public:
114         PresentationGUI(MWindow *mwindow,
115                 TimeBar *timebar,
116                 int64_t pixel,
117                 double position);
118         ~PresentationGUI();
119 };
120
121 class TimeBar : public BC_SubWindow
122 {
123 public:
124         TimeBar(MWindow *mwindow,
125                 BC_WindowBase *gui,
126                 int x,
127                 int y,
128                 int w,
129                 int h);
130         virtual ~TimeBar();
131
132         virtual void create_objects();
133         int update_defaults();
134         virtual int button_press_event();
135         virtual int button_release_event();
136         int cursor_motion_event();
137         int cursor_leave_event();
138         virtual void update_clock(double position);
139
140         LabelEdit *label_edit;
141
142 // Synchronize label, in/out, presentation display with master EDL
143         virtual void update(int flush);
144         virtual void draw_time();
145 // Called by update and draw_time.
146         virtual void draw_range();
147         virtual void select_label(double position);
148         virtual void stop_playback();
149         virtual EDL* get_edl();
150         virtual int test_preview(int buttonpress);
151         virtual void update_preview();
152         virtual int64_t position_to_pixel(double position);
153         virtual double pixel_to_position(int pixel);
154         virtual void handle_mwindow_drag();
155         virtual void activate_timeline();
156         int move_preview(int &redraw);
157 // Get highlight status when the cursor is over the timeline.
158         virtual double test_highlight();
159         virtual int has_preview() { return 0; }
160         virtual int is_vwindow() { return 0; }
161
162
163         void update_labels();
164         void update_points();
165 // Make sure widgets are highlighted according to selection status
166         void update_highlights();
167         void draw_inout_highlight();
168 // Update highlight cursor during a drag
169         virtual void update_cursor();
170
171 // ================================= file operations
172
173         int save(FileXML *xml);
174         int load(FileXML *xml, int undo_type);
175
176         int delete_project();        // clear timebar of labels
177
178         int draw();                  // draw everything over
179         int samplemovement();
180         int refresh_labels();
181
182 // ========================================= editing
183
184         int select_region(double position);
185         double get_edl_length();
186
187         MWindow *mwindow;
188         BC_WindowBase *gui;
189         TimelinePane *pane;
190         int flip_vertical(int w, int h);
191         int delete_arrows();    // for flipping vertical
192
193 // Operation started by a buttonpress
194         int current_operation;
195         LabelGUI *drag_label;
196
197 private:
198         int get_preview_pixels(int &x1, int &x2);
199         int draw_bevel();
200         ArrayList<LabelGUI*> labels;
201         InPointGUI *in_point;
202         OutPointGUI *out_point;
203         ArrayList<PresentationGUI*> presentations;
204
205
206
207 // Records for dragging operations
208         double start_position;
209         double starting_start_position;
210         double starting_end_position;
211         double time_per_pixel;
212         double edl_length;
213         int start_cursor_x;
214         int highlighted;
215 };
216
217
218 #endif