add edit clear submenu/clear hard_edges, fix tessy gl segv, mask toolgui layout,...
[goodguy/cinelerra.git] / cinelerra-5.1 / 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) ? 115 : 185,
31         0, 0)
32 { this->asset = asset; this->dither = dither; }
33
34 FormatAWindow::~FormatAWindow()
35 {
36 }
37
38 void FormatAWindow::create_objects()
39 {
40         lock_window("FormatAWindow::create_objects");
41         int x;
42         int init_x;
43         int y = 10;
44         File file;
45         x = init_x = 10;
46
47         add_subwindow(new BC_Title(x, y, _("Set parameters for this audio format:")));
48         y += 30;
49         add_subwindow(new BC_Title(x, y, _("Bits:")));
50         x += 45;
51         add_subwindow(new FormatBits(x, y, asset));
52         x += 100;
53         add_subwindow(new FormatDither(x, y, this->dither));
54
55         if(asset->format == FILE_PCM)
56         {
57                 x += 90;
58                 add_subwindow(new FormatSigned(x, y, asset));
59         }
60         y += 40;
61         x = init_x;
62
63         if(asset->format == FILE_PCM)
64         {
65                 add_subwindow(new BC_Title(x, y, _("Byte order:")));
66                 y += 25;
67                 add_subwindow(new BC_Title(x, y, _("HiLo:"), SMALLFONT));
68                 add_subwindow(hilo_button = new FormatHILO(x + 30, y, asset));
69                 x += 50;
70                 add_subwindow(new BC_Title(x, y, _("LoHi:"), SMALLFONT));
71                 add_subwindow(lohi_button = new FormatLOHI(x + 30, y, hilo_button, asset));
72                 hilo_button->lohi = lohi_button;
73                 y += 30;
74         }
75
76         x = init_x;
77
78         add_subwindow(new BC_OKButton(x + 170, y));
79         unlock_window();
80 }
81
82
83 int FormatAWindow::close_event()
84 {
85         set_done(0);
86 }
87
88
89
90 FormatVWindow::FormatVWindow(Asset *asset, int recording)
91  : BC_Window(_(PROGRAM_NAME ": File format"), 410, 115, 0, 0)
92 { this->asset = asset; this->recording = recording; }
93
94 FormatVWindow::~FormatVWindow()
95 {
96 }
97
98 void FormatVWindow::create_objects()
99 {
100         lock_window("FormatVWindow::create_objects");
101         int x, y = 10;
102         int init_x;
103
104         init_x = x = 10;
105
106         if(asset->format == FILE_JPEG_LIST)
107         {
108                 add_subwindow(new BC_Title(x, y, _("Set parameters for this video format:")));
109                 y += 30;
110                 add_subwindow(new BC_Title(x, y, _("Quality:")));
111                 x += 70;
112                 add_subwindow(new FormatQuality(x, y, asset, asset->quality));
113                 y += 40;
114                 x = init_x;
115         }
116         else
117         {
118                 add_subwindow(new BC_Title(x, y, _("Video is not supported in this format.")));
119                 y += 40;
120         }
121
122         add_subwindow(new BC_OKButton(x + 170, y));
123         unlock_window();
124 }
125
126 int FormatVWindow::close_event()
127 {
128         set_done(0);
129 }
130
131
132 FormatQuality::FormatQuality(int x, int y, Asset *asset, int default_)
133  : BC_ISlider(x, y, 0, 100, 100, 0, 100, default_, 1)
134 {
135         this->asset = asset;
136 }
137 FormatQuality::~FormatQuality()
138 {
139 }
140 int FormatQuality::handle_event()
141 {
142         asset->quality = get_value();
143 }
144
145
146 FormatBits::FormatBits(int x, int y, Asset *asset)
147  : BitsPopup(x, y, asset)
148 { this->asset = asset; }
149 FormatBits::~FormatBits() {}
150 int FormatBits::handle_event()
151 {
152         asset->bits = get_bits();
153 }
154
155
156 FormatDither::FormatDither(int x, int y, int *dither)
157  : BC_CheckBox(x, y, *dither, _("Dither"))
158 { this->dither = dither; }
159 FormatDither::~FormatDither() {}
160 int FormatDither::handle_event()
161 {
162         *dither = get_value();
163 }
164
165
166
167
168 FormatSigned::FormatSigned(int x, int y, Asset *asset)
169  : BC_CheckBox(x, y, asset->signed_, _("Signed"))
170 { this->asset = asset; }
171 FormatSigned::~FormatSigned() {}
172 int FormatSigned::handle_event()
173 {
174         asset->signed_ = get_value();
175 }
176
177
178 FormatHILO::FormatHILO(int x, int y, Asset *asset)
179  : BC_Radial(x, y, asset->byte_order ^ 1)
180 {
181         this->asset = asset;
182 }
183 FormatHILO::~FormatHILO() {}
184
185 int FormatHILO::handle_event()
186 {
187         asset->byte_order = get_value() ^ 1;
188         lohi->update(get_value() ^ 1);
189 }
190
191 FormatLOHI::FormatLOHI(int x, int y, FormatHILO *hilo, Asset *asset)
192  : BC_Radial(x, y, asset->byte_order)
193 {
194         this->hilo = hilo;
195         this->asset = asset;
196 }
197 FormatLOHI::~FormatLOHI() {}
198
199 int FormatLOHI::handle_event()
200 {
201         asset->byte_order = get_value();
202         hilo->update(get_value() ^ 1);
203 }
204