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