initial commit
[goodguy/history.git] / cinelerra-5.0 / cinelerra / formatwindow.C
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 #include "assets.h"
23 #include "file.h"
24 #include "formatwindow.h"
25 #include <string.h>
26
27
28 FormatAWindow::FormatAWindow(Asset *asset, int *dither)
29  : BC_Window(PROGRAM_NAME ": File format", 410, 
30         (asset->format == FILE_WAV || asset->format == FILE_MOV) ? 115 : 185, 
31         0, 0)
32 { this->asset = asset; this->dither = dither; }
33
34 FormatAWindow::~FormatAWindow()
35 {
36 }
37
38 int FormatAWindow::create_objects()
39 {
40         int x;
41         int init_x;
42         int y = 10;
43         File file;
44         x = init_x = 10;
45
46         add_subwindow(new BC_Title(x, y, _("Set parameters for this audio format:")));
47         y += 30;
48         add_subwindow(new BC_Title(x, y, _("Bits:")));
49         x += 45;
50         add_subwindow(new FormatBits(x, y, asset));
51         x += 100;
52         add_subwindow(new FormatDither(x, y, this->dither));
53
54         if(asset->format == FILE_PCM || asset->format == FILE_MOV)
55         {
56                 x += 90;
57                 add_subwindow(new FormatSigned(x, y, asset));
58         }
59         y += 40;
60         x = init_x;
61
62         if(asset->format == FILE_PCM)
63         {
64                 add_subwindow(new BC_Title(x, y, _("Byte order:")));
65                 y += 25;
66                 add_subwindow(new BC_Title(x, y, _("HiLo:"), SMALLFONT));
67                 add_subwindow(hilo_button = new FormatHILO(x + 30, y, asset));
68                 x += 50;
69                 add_subwindow(new BC_Title(x, y, _("LoHi:"), SMALLFONT));
70                 add_subwindow(lohi_button = new FormatLOHI(x + 30, y, hilo_button, asset));
71                 hilo_button->lohi = lohi_button;
72                 y += 30;
73         }
74
75         x = init_x;
76
77         add_subwindow(new BC_OKButton(x + 170, y));
78 }
79
80
81 int FormatAWindow::close_event()
82 {
83         set_done(0);
84 }
85
86
87
88
89 FormatVWindow::FormatVWindow(Asset *asset, int recording)
90  : BC_Window(PROGRAM_NAME ": File format", 410, 115, 0, 0)
91 { this->asset = asset; this->recording = recording; }
92
93 FormatVWindow::~FormatVWindow()
94 {
95 }
96
97 int FormatVWindow::create_objects()
98 {
99         int x, y = 10;
100         int init_x;
101
102         init_x = x = 10;
103
104         if(asset->format == FILE_MOV)
105         {
106                 add_subwindow(new BC_Title(x, y, _("Set parameters for this video format:")));
107                 y += 30;
108                 add_subwindow(new BC_Title(x, y, _("Compression:")));
109                 x += 110;
110                 add_subwindow(new FormatCompress(x, y, recording, asset, asset->compression));
111                 x += 90;
112                 add_subwindow(new BC_Title(x, y, _("Quality:")));
113                 x += 70;
114                 add_subwindow(new FormatQuality(x, y, asset, asset->quality));
115                 y += 40;
116                 x = init_x;
117         }
118         else
119         if(asset->format == FILE_JPEG_LIST)
120         {
121                 add_subwindow(new BC_Title(x, y, _("Set parameters for this video format:")));
122                 y += 30;
123                 add_subwindow(new BC_Title(x, y, _("Quality:")));
124                 x += 70;
125                 add_subwindow(new FormatQuality(x, y, asset, asset->quality));
126                 y += 40;
127                 x = init_x;
128         }
129         else
130         {
131                 add_subwindow(new BC_Title(x, y, _("Video is not supported in this format.")));
132                 y += 40;
133         }
134
135         add_subwindow(new BC_OKButton(x + 170, y));
136 }
137
138 int FormatVWindow::close_event()
139 {
140         set_done(0);
141 }
142
143
144
145
146
147
148
149 FormatCompress::FormatCompress(int x, int y, int recording, Asset *asset, char* default_)
150  : CompressPopup(x, y, recording, default_)
151
152         this->asset = asset; 
153 }
154 FormatCompress::~FormatCompress() 
155 {
156 }
157 int FormatCompress::handle_event()
158 {
159         strcpy(asset->compression, get_compression());
160 }
161
162 FormatQuality::FormatQuality(int x, int y, Asset *asset, int default_)
163  : BC_ISlider(x, 
164         y, 
165         0,
166         100, 
167         100, 
168         0, 
169         100, 
170         default_, 
171         1)
172
173         this->asset = asset; 
174 }
175 FormatQuality::~FormatQuality() 
176 {
177 }
178 int FormatQuality::handle_event()
179 {
180         asset->quality = get_value();
181 }
182
183
184
185 FormatBits::FormatBits(int x, int y, Asset *asset)
186  : BitsPopup(x, y, asset)
187 { this->asset = asset; }
188 FormatBits::~FormatBits() {}
189 int FormatBits::handle_event()
190 {
191         asset->bits = get_bits();
192 }
193
194
195
196 FormatDither::FormatDither(int x, int y, int *dither)
197  : BC_CheckBox(x, y, *dither, _("Dither"))
198 { this->dither = dither; }
199 FormatDither::~FormatDither() {}
200 int FormatDither::handle_event()
201 {
202         *dither = get_value();
203 }
204
205
206
207
208 FormatSigned::FormatSigned(int x, int y, Asset *asset)
209  : BC_CheckBox(x, y, asset->signed_, _("Signed"))
210 { this->asset = asset; }
211 FormatSigned::~FormatSigned() {}
212 int FormatSigned::handle_event()
213 {
214         asset->signed_ = get_value();
215 }
216
217
218
219
220
221
222 FormatHILO::FormatHILO(int x, int y, Asset *asset)
223  : BC_Radial(x, y, asset->byte_order ^ 1)
224 {
225         this->asset = asset;
226 }
227 FormatHILO::~FormatHILO() {}
228
229 int FormatHILO::handle_event()
230 {
231         asset->byte_order = get_value() ^ 1;
232         lohi->update(get_value() ^ 1);
233 }
234
235 FormatLOHI::FormatLOHI(int x, int y, FormatHILO *hilo, Asset *asset)
236  : BC_Radial(x, y, asset->byte_order)
237 {
238         this->hilo = hilo;
239         this->asset = asset;
240 }
241 FormatLOHI::~FormatLOHI() {}
242
243 int FormatLOHI::handle_event()
244 {
245         asset->byte_order = get_value();
246         hilo->update(get_value() ^ 1);
247 }
248