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