prevent popup deactivation while button_down
[goodguy/history.git] / cinelerra-5.0 / cinelerra / labels.h
1
2 /*
3  * CINELERRA
4  * Copyright (C) 2008 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 LABEL_H
23 #define LABEL_H
24
25 #include <stdio.h>
26 #include <stdint.h>
27
28 #include "edl.inc"
29 #include "guicast.h"
30 #include "filexml.inc"
31 #include "labels.inc"
32 #include "mwindow.inc"
33 #include "recordlabel.inc"
34 #include "stringfile.inc"
35 #include "timebar.inc"
36
37 #define LABELSIZE 15
38
39 class LabelToggle : public BC_Label
40 {
41 public:
42         LabelToggle(MWindow *mwindow, Label *label, int x, int y, long position);
43         ~LabelToggle();
44         
45         int handle_event();
46         MWindow *mwindow;
47         Label *label;
48 };
49
50 class Label : public ListItem<Label>
51 {
52 public:
53         Label(EDL *edl, Labels *labels, double position);
54         Label();
55         ~Label();
56
57
58         EDL *edl;
59         Labels *labels;
60 // Seconds
61         double position;
62 };
63
64 class Labels : public List<Label>
65 {
66 public:
67         Labels(EDL *edl, const char *xml_tag);
68         virtual ~Labels();
69
70         void dump(FILE *fp=stdout);
71
72         Labels& operator=(Labels &that);
73         void copy_from(Labels *labels);
74         int toggle_label(double start, double end);
75         int delete_all();
76         int save(FileXML *xml);
77         int load(FileXML *xml, uint32_t load_flags);
78         void insert_labels(Labels *labels, 
79                 double start, 
80                 double length, 
81                 int paste_silence = 1);
82 // Always add label without toggling
83         void insert_label(double position);
84
85         int modify_handles(double oldposition, 
86                 double newposition, 
87                 int currentend, 
88                 int handle_mode,
89                 int edit_labels);
90         int copy(double start, double end, FileXML *xml);
91         int copy_length(long start, long end); // return number of Labels in selection
92         Label *add_label(double position);
93         int insert(double start, double length);
94         int paste(long start, long end, long total_length, FileXML *xml);
95         int paste_output(long startproject, long endproject, long startsource, long endsource, RecordLabels *labels);
96 // Setting follow to 1 causes labels to move forward after clear.
97 // Setting it to 0 implies ignoring the labels follow edits setting.
98         int clear(double start, double end, int follow = 1);
99         int paste_silence(double start, double end);
100         int optimize();  // delete duplicates
101 // Get nearest labels or 0 if start or end of timeline
102         Label* prev_label(double position);
103         Label* next_label(double position);
104
105         Label* label_of(double position); // first label on or after position
106         MWindow *mwindow;
107         TimeBar *timebar;
108         EDL *edl;
109         char *xml_tag;
110 };
111
112 #endif