rework restore_windows for layout
[goodguy/cinelerra.git] / cinelerra-5.1 / cinelerra / formattools.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 FORMATTOOLS_H
23 #define FORMATTOOLS_H
24
25 #include "asset.inc"
26 #include "guicast.h"
27 #include "bitspopup.h"
28 #include "browsebutton.h"
29 #include "compresspopup.h"
30 #include "file.inc"
31 #include "ffmpeg.h"
32 #include "formatpopup.h"
33 #include "formattools.inc"
34 #include "mwindow.inc"
35
36 class FormatTools
37 {
38 public:
39         FormatTools(MWindow *mwindow, BC_WindowBase *window, Asset *asset);
40         virtual ~FormatTools();
41
42         void create_objects(int &init_x, int &init_y,
43                 int do_audio, int do_video,   // Include tools for audio, video
44                 int prompt_audio,  int prompt_video,  // Include checkbox for audio, video
45                 int prompt_audio_channels, int prompt_video_compression,
46                 const char *locked_compressor,  // Select compressors to be offered
47                 int recording, // Change captions for recording
48                 int *file_per_label,  // prompt if nonzero
49                 int brender,   // Supply file formats for background rendering
50                 int horizontal_layout = 0);
51 // In recording preferences, aspects of the format are locked
52 // depending on the driver used.
53         void update_driver(int driver);
54         virtual void update_format();
55
56
57         void reposition_window(int &init_x, int &init_y);
58 // Put new asset's parameters in and change asset.
59         void update(Asset *asset, int *file_per_label);
60 // Update filename extension when format is changed.
61         void update_extension();
62         void close_format_windows();
63         Asset* get_asset();
64
65 // Handle change in path text.  Used in BatchRender.
66         virtual int handle_event();
67
68         int set_audio_options();
69         int set_video_options();
70         void set_w(int w);
71         int get_w();
72
73         BC_WindowBase *window;
74         Asset *asset;
75
76         FormatAParams *aparams_button;
77         FormatVParams *vparams_button;
78         FormatAThread *aparams_thread;
79         FormatVThread *vparams_thread;
80         BrowseButton *path_button;
81         FormatPathText *path_textbox;
82         BC_RecentList *path_recent;
83         BC_Title *format_title;
84         FormatFormat *format_button;
85         BC_TextBox *format_text;
86         FormatFFMPEG *format_ffmpeg;
87         FFMpegType *ffmpeg_type;
88
89         BC_Title *audio_title;
90         FormatAudio *audio_switch;
91
92         BC_Title *video_title;
93         FormatVideo *video_switch;
94
95         FormatFilePerLabel *labeled_files;
96
97         MWindow *mwindow;
98         const char *locked_compressor;
99         int recording;
100         int use_brender;
101         int do_audio;
102         int do_video;
103         int prompt_audio;
104         int prompt_audio_channels;
105         int prompt_video;
106         int prompt_video_compression;
107         int *file_per_label;
108         int w;
109 // Determines what the configuration buttons do.
110         int video_driver;
111 };
112
113
114
115 class FormatPathText : public BC_TextBox
116 {
117 public:
118         FormatPathText(int x, int y, FormatTools *format);
119         ~FormatPathText();
120         int handle_event();
121
122         FormatTools *format;
123 };
124
125
126
127 class FormatFormat : public FormatPopup
128 {
129 public:
130         FormatFormat(int x, int y, FormatTools *format);
131         ~FormatFormat();
132
133         int handle_event();
134         FormatTools *format;
135 };
136
137 class FormatFFMPEG : public FFMPEGPopup
138 {
139 public:
140         FormatFFMPEG(int x, int y, FormatTools *format);
141         ~FormatFFMPEG();
142
143         int handle_event();
144         FormatTools *format;
145
146 // squash show/hide window
147         int show_window(int flush=1) { return 0; }
148         int hide_window(int flush=1) { return 0; }
149         int show(int flush=1) { return BC_SubWindow::show_window(flush); }
150         int hide(int flush=1) { return BC_SubWindow::hide_window(flush); }
151 };
152
153 class FFMpegType : public BC_TextBox
154 {
155 public:
156         FFMpegType(int x, int y, int w, int h, const char *text)
157          : BC_TextBox(x, y, w, h, text) {}
158         ~FFMpegType() {}
159 // squash show/hide window
160         int show_window(int flush=1) { return 0; }
161         int hide_window(int flush=1) { return 0; }
162         int show(int flush=1) { return BC_SubWindow::show_window(flush); }
163         int hide(int flush=1) { return BC_SubWindow::hide_window(flush); }
164 };
165
166 class FormatAParams : public BC_Button
167 {
168 public:
169         FormatAParams(MWindow *mwindow, FormatTools *format, int x, int y);
170         ~FormatAParams();
171         int handle_event();
172         FormatTools *format;
173 };
174
175 class FormatVParams : public BC_Button
176 {
177 public:
178         FormatVParams(MWindow *mwindow, FormatTools *format, int x, int y);
179         ~FormatVParams();
180         int handle_event();
181         FormatTools *format;
182 };
183
184
185 class FormatAThread : public Thread
186 {
187 public:
188         FormatAThread(FormatTools *format);
189         ~FormatAThread();
190
191         void run();
192         void start();
193         void join() { if( !joined ) { joined = 1; Thread::join(); } }
194
195         FormatTools *format;
196         File *file;
197         int joined;
198 };
199
200 class FormatVThread : public Thread
201 {
202 public:
203         FormatVThread(FormatTools *format);
204         ~FormatVThread();
205
206         void run();
207         void start();
208         void join() { if( !joined ) { joined = 1; Thread::join(); } }
209
210         FormatTools *format;
211         File *file;
212         int joined;
213 };
214
215 class FormatAudio : public BC_CheckBox
216 {
217 public:
218         FormatAudio(int x, int y, FormatTools *format, int default_);
219         ~FormatAudio();
220         int handle_event();
221         FormatTools *format;
222 };
223
224 class FormatVideo : public BC_CheckBox
225 {
226 public:
227         FormatVideo(int x, int y, FormatTools *format, int default_);
228         ~FormatVideo();
229         int handle_event();
230         FormatTools *format;
231 };
232
233
234 class FormatFilePerLabel : public BC_CheckBox
235 {
236 public:
237         FormatFilePerLabel(FormatTools *format, int x, int y, int *output);
238         ~FormatFilePerLabel();
239         int handle_event();
240         void update(int *output);
241
242         FormatTools *format;
243         int *output;
244 };
245
246
247 #endif