ripple edge drag_handle tweaks, sync_parameter fix, shuttlerc, shortcuts
[goodguy/cinelerra.git] / cinelerra-5.1 / cinelerra / fileformat.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 "asset.h"
23 #include "assets.h"
24 #include "bitspopup.h"
25 #include "fileformat.h"
26 #include "language.h"
27 #include "mwindow.h"
28 #include "mwindowgui.h"
29 #include "new.h"
30
31
32
33 FileFormat::FileFormat(MWindow *mwindow)
34  : BC_Window(_(PROGRAM_NAME ": File Format"),
35                 mwindow->gui->get_abs_cursor_x(0),
36                 mwindow->gui->get_abs_cursor_y(0),
37                 375,
38                 300,
39                 375,
40                 300)
41 {
42         this->mwindow = mwindow;
43 }
44
45 FileFormat::~FileFormat()
46 {
47         lock_window("FileFormat::~FileFormat");
48         delete lohi;
49         delete hilo;
50         delete signed_button;
51         delete header_button;
52         delete rate_button;
53         delete channels_button;
54         delete bitspopup;
55         unlock_window();
56 }
57
58 void FileFormat::create_objects(Asset *asset, char *string2)
59 {
60 // ================================= copy values
61         this->asset = asset;
62         create_objects_(string2);
63 }
64
65 void FileFormat::create_objects_(char *string2)
66 {
67         char string[1024];
68         int x1 = 10, x2 = 180;
69         int x = x1, y = 10;
70
71         lock_window("FileFormat::create_objects_");
72         add_subwindow(new BC_Title(x, y, string2));
73         y += 20;
74         add_subwindow(new BC_Title(x, y, _("Assuming raw PCM:")));
75
76         y += 30;
77         add_subwindow(new BC_Title(x, y, _("Channels:")));
78         sprintf(string, "%d", asset->channels);
79         channels_button = new FileFormatChannels(x2, y, this, string);
80         channels_button->create_objects();
81
82         y += 30;
83         add_subwindow(new BC_Title(x, y, _("Sample rate:")));
84         sprintf(string, "%d", asset->sample_rate);
85         add_subwindow(rate_button = new FileFormatRate(x2, y, this, string));
86         add_subwindow(new SampleRatePulldown(mwindow, rate_button, x2 + 100, y));
87
88         y += 30;
89         add_subwindow(new BC_Title(x, y, _("Bits:")));
90         bitspopup = new BitsPopup(this, x2, y,
91                 &asset->bits, 0, 1, 1, 0, 1);
92         bitspopup->create_objects();
93
94         y += 30;
95         add_subwindow(new BC_Title(x, y, _("Header length:")));
96         sprintf(string, "%d", asset->header);
97         add_subwindow(header_button = new FileFormatHeader(x2, y, this, string));
98
99         y += 30;
100
101 //printf("FileFormat::create_objects_ 1 %d\n", asset->byte_order);
102         add_subwindow(new BC_Title(x, y, _("Byte order:")));
103         add_subwindow(lohi = new FileFormatByteOrderLOHI(x2, y, this, asset->byte_order));
104         add_subwindow(hilo = new FileFormatByteOrderHILO(x2 + 70, y, this, !asset->byte_order));
105
106         y += 30;
107         add_subwindow(signed_button = new FileFormatSigned(x, y, this, asset->signed_));
108
109         add_subwindow(new BC_OKButton(this));
110         add_subwindow(new BC_CancelButton(this));
111
112         show_window(1);
113         unlock_window();
114 }
115
116 FileFormatChannels::FileFormatChannels(int x, int y, FileFormat *fwindow, char *text)
117  : BC_TumbleTextBox(fwindow, (int)atol(text), (int)1, (int)MAXCHANNELS, x, y, 50)
118 {
119         this->fwindow = fwindow;
120 }
121
122 int FileFormatChannels::handle_event()
123 {
124         fwindow->asset->channels = atol(get_text());
125         return 0;
126 }
127
128 FileFormatRate::FileFormatRate(int x, int y, FileFormat *fwindow, char *text)
129  : BC_TextBox(x, y, 100, 1, text)
130 {
131         this->fwindow = fwindow;
132 }
133
134 int FileFormatRate::handle_event()
135 {
136         fwindow->asset->sample_rate = atol(get_text());
137         return 0;
138 }
139
140 FileFormatHeader::FileFormatHeader(int x, int y, FileFormat *fwindow, char *text)
141  : BC_TextBox(x, y, 100, 1, text)
142 {
143         this->fwindow = fwindow;
144 }
145
146 int FileFormatHeader::handle_event()
147 {
148         fwindow->asset->header = atol(get_text());
149         return 0;
150 }
151
152 FileFormatByteOrderLOHI::FileFormatByteOrderLOHI(int x, int y, FileFormat *fwindow, int value)
153  : BC_Radial(x, y, value, _("Lo Hi"))
154 {
155         this->fwindow = fwindow;
156 }
157
158 int FileFormatByteOrderLOHI::handle_event()
159 {
160         update(1);
161         fwindow->asset->byte_order = 1;
162         fwindow->hilo->update(0);
163         return 1;
164 }
165
166 FileFormatByteOrderHILO::FileFormatByteOrderHILO(int x, int y, FileFormat *fwindow, int value)
167  : BC_Radial(x, y, value, _("Hi Lo"))
168 {
169         this->fwindow = fwindow;
170 }
171
172 int FileFormatByteOrderHILO::handle_event()
173 {
174         update(1);
175         fwindow->asset->byte_order = 0;
176         fwindow->lohi->update(0);
177         return 1;
178 }
179
180 FileFormatSigned::FileFormatSigned(int x, int y, FileFormat *fwindow, int value)
181  : BC_CheckBox(x, y, value, _("Values are signed"))
182 {
183         this->fwindow = fwindow;
184 }
185
186 int FileFormatSigned::handle_event()
187 {
188         fwindow->asset->signed_ = get_value();
189         return 1;
190 }