add Autosave continuous backups by Andras Reuss and Andrew-R
[goodguy/cinelerra.git] / cinelerra-5.1 / cinelerra / swindow.h
1 #ifndef __SWINDOW_H__
2 #define __SWINDOW_H__
3
4 #include <stdio.h>
5 #include <stdint.h>
6
7 #include "arraylist.h"
8 #include "guicast.h"
9 #include "mwindow.inc"
10 #include "swindow.inc"
11
12 #define SUB_FORMAT_SRT  1
13 #define SUB_FORMAT_RIP  2
14 #define SUB_FORMAT_UDVD 3
15
16 class SWindow : public Thread
17 {
18 public:
19         MWindow *mwindow;
20         Mutex *window_lock;
21         Condition *swin_lock;
22         SWindowGUI *gui;
23
24         void start();
25         void stop();
26         void run();
27         void run_swin();
28         void paste_subttl();
29         int update_selection();
30         int done, gui_done;
31
32         SWindow(MWindow *mwindow);
33         ~SWindow();
34 };
35
36
37 class SWindowOK : public BC_OKButton
38 {
39 public:
40         SWindowGUI *gui;
41
42         int button_press_event();
43         int keypress_event();
44
45         SWindowOK(SWindowGUI *gui, int x, int y);
46         ~SWindowOK();
47 };
48
49 class SWindowCancel : public BC_CancelButton
50 {
51 public:
52         SWindowGUI *gui;
53
54         int button_press_event();
55
56         SWindowCancel(SWindowGUI *gui, int x, int y);
57         ~SWindowCancel();
58 };
59
60 class SWindowLoadPath : public BC_TextBox
61 {
62 public:
63         SWindowGUI *sw_gui;
64
65         SWindowLoadPath(SWindowGUI *gui, int x, int y, char *path);
66         ~SWindowLoadPath();
67
68         int handle_event();
69 };
70
71 class SWindowLoadFile : public BC_GenericButton
72 {
73 public:
74         SWindowGUI *sw_gui;
75
76         int handle_event();
77
78         SWindowLoadFile(SWindowGUI *gui, int x, int y);
79         ~SWindowLoadFile();
80 };
81
82 class SWindowSaveFile : public BC_GenericButton
83 {
84 public:
85         SWindowGUI *sw_gui;
86
87         int handle_event();
88
89         SWindowSaveFile(SWindowGUI *gui, int x, int y);
90         ~SWindowSaveFile();
91 };
92
93 class SWindowItemFormat : public BC_MenuItem
94 {
95 public:
96         SWindowItemFormat(SWindowSaveFormat *save_format, const char *text, int id);
97         int handle_event();
98
99         SWindowSaveFormat *save_format;
100         int id;
101 };
102
103 class SWindowSaveFormat : public BC_PopupMenu
104 {
105 public:
106         SWindowSaveFormat(SWindowGUI *sw_gui, int x, int y);
107         void create_objects();
108         void update_toggles();
109
110         SWindowGUI *sw_gui;
111         SWindowItemFormat *srt;
112         SWindowItemFormat *rip;
113         SWindowItemFormat *udvd;
114 };
115
116
117 class ScriptLines
118 {
119         int allocated, used;
120 public:
121         int lines;
122         char *text;
123         void append(char *cp);
124         int size() { return used; }
125         int break_lines();
126         int get_text_rows();
127         char *get_text_row(int n);
128
129         ScriptLines();
130         ~ScriptLines();
131 };
132
133 class ScriptScroll : public BC_ScrollBar
134 {
135 public:
136         SWindowGUI *sw_gui;
137
138         int handle_event();
139
140         ScriptScroll(SWindowGUI *gui, int x, int y, int w);
141         ~ScriptScroll();
142 };
143
144 class ScriptPosition : public BC_TumbleTextBox
145 {
146 public:
147         SWindowGUI *sw_gui;
148
149         int handle_event();
150
151         ScriptPosition(SWindowGUI *gui, int x, int y, int w, int v=0, int mn=0, int mx=0);
152         ~ScriptPosition();
153 };
154
155 class ScriptEntry : public BC_ScrollTextBox
156 {
157 public:
158         SWindowGUI *sw_gui;
159
160         char *ttext;
161         void set_text(char *text, int isz=-1);
162         int handle_event();
163
164         ScriptEntry(SWindowGUI *gui, int x, int y, int w, int rows, char *text);
165         ScriptEntry(SWindowGUI *gui, int x, int y, int w, int rows);
166         ~ScriptEntry();
167 };
168
169 class ScriptPrev : public BC_GenericButton
170 {
171 public:
172         SWindowGUI *sw_gui;
173
174         int handle_event();
175         ScriptPrev(SWindowGUI *gui, int x, int y);
176         ~ScriptPrev();
177 };
178
179 class ScriptNext : public BC_GenericButton
180 {
181 public:
182         SWindowGUI *sw_gui;
183
184         int handle_event();
185         ScriptNext(SWindowGUI *gui, int x, int y);
186         ~ScriptNext();
187 };
188
189 class ScriptPaste : public BC_GenericButton
190 {
191 public:
192         SWindowGUI *sw_gui;
193
194         int handle_event();
195         ScriptPaste(SWindowGUI *gui, int x, int y);
196         ~ScriptPaste();
197 };
198
199 class ScriptClear : public BC_GenericButton
200 {
201 public:
202         SWindowGUI *sw_gui;
203
204         int handle_event();
205         ScriptClear(SWindowGUI *gui, int x, int y);
206         ~ScriptClear();
207 };
208
209 class SWindowGUI : public BC_Window
210 {
211         static int max(int a,int b) { return a>b ? a : b; }
212 public:
213         SWindow *swindow;
214         BC_OKButton *ok;
215         BC_CancelButton *cancel;
216         SWindowLoadPath *load_path;
217         SWindowLoadFile *load_file;
218         SWindowSaveFile *save_file;
219         SWindowSaveFormat *save_format;
220         BC_Title *script_filesz;
221         BC_Title *script_lines;
222         BC_Title *script_entries;
223         BC_Title *script_texts;
224         BC_Title *script_title;
225         BC_Title *line_title;
226         ScriptPrev *prev_script;
227         ScriptNext *next_script;
228         ScriptPaste *paste_script;
229         ScriptClear *clear_script;
230         ScriptPosition *script_position;
231         ScriptEntry *script_entry;
232         ScriptEntry *line_entry;
233         ScriptScroll *script_scroll;
234         int xpad, ypad;
235         char *blank_line;
236         int sub_format;
237
238         char script_path[BCTEXTLEN];
239         ArrayList<ScriptLines *> script;
240
241         void create_objects();
242         void load();
243         void stop(int v);
244         int translation_event();
245         int resize_event(int w, int h);
246         void load_defaults();
247         void save_defaults();
248         void load_script();
249         void load_script(FILE *fp);
250         int load_script_line(FILE *fp);
251         void set_script_pos(int64_t entry_no, int text_no=0);
252         int load_selection();
253         int load_selection(int pos, int row);
254         int load_prev_selection();
255         int load_next_selection();
256         int update_selection();
257         int paste_text(const char *text, double start, double end);
258         int paste_selection();
259         int clear_selection();
260         void save_spumux_data();
261
262         int ok_x, ok_y, ok_w, ok_h;
263         int cancel_x, cancel_y, cancel_w, cancel_h;
264         int64_t script_entry_no, script_text_no;
265         int64_t script_line_no, script_text_lines;
266         int text_font, text_rowsz;
267
268         SWindowGUI(SWindow *swindow, int x, int y, int w, int h);
269         ~SWindowGUI();
270
271 };
272
273
274 class SubttlSWin : public BC_MenuItem
275 {
276 public:
277         MWindow *mwindow;
278         int handle_event();
279
280         SubttlSWin(MWindow *mwindow);
281         ~SubttlSWin();
282 };
283
284
285 #endif