r807: Minor fix...
[cinelerra_cv/mob.git] / cinelerra / formatpresets.C
blob848f34f62dec7be4afc3ee24cdf828b21eaf9014
1 #include "edl.h"
2 #include "edlsession.h"
3 #include "formatpresets.h"
4 #include "new.h"
5 #include "setformat.h"
11 FormatPresets::FormatPresets(MWindow *mwindow,
12         NewWindow *new_gui, 
13         SetFormatWindow *format_gui, 
14         int x, 
15         int y)
17         this->mwindow = mwindow;
18         this->new_gui = new_gui;
19         this->format_gui = format_gui;
20         gui_base = new_gui ? (BC_WindowBase*)new_gui : (BC_WindowBase*)(format_gui);
21         this->x = x;
22         this->y = y;
23         text = 0;
24         pulldown = 0;
27 FormatPresets::~FormatPresets()
29         if(text) delete text;
30         if(pulldown) delete pulldown;
31         for(int i = 0; i < preset_items.total; i++)
32                 delete preset_items.values[i];
35 void FormatPresets::create_objects()
37 // Create preset items
38         FormatPresetItem *item;
39         item = new FormatPresetItem(mwindow, this, _("User Defined"));
40         preset_items.append(item);
42         item = new FormatPresetItem(mwindow, this, _("1080P"));
43         item->edl->session->audio_channels = 2;
44         item->edl->session->audio_tracks = 2;
45         item->edl->session->sample_rate = 48000;
46         item->edl->session->video_channels = 1;
47         item->edl->session->video_tracks = 1;
48         item->edl->session->frame_rate = (double)60000.0 / 1001;
49 //      item->edl->session->track_w = 1920;
50 //      item->edl->session->track_h = 1080;
51         item->edl->session->output_w = 1920;
52         item->edl->session->output_h = 1080;
53         item->edl->session->aspect_w = 16;
54         item->edl->session->aspect_h = 9;
55         preset_items.append(item);
57         item = new FormatPresetItem(mwindow, this, _("1080I"));
58         item->edl->session->audio_channels = 2;
59         item->edl->session->audio_tracks = 2;
60         item->edl->session->sample_rate = 48000;
61         item->edl->session->video_channels = 1;
62         item->edl->session->video_tracks = 1;
63         item->edl->session->frame_rate = (double)30000.0 / 1001;
64 //      item->edl->session->track_w = 1920;
65 //      item->edl->session->track_h = 1080;
66         item->edl->session->output_w = 1920;
67         item->edl->session->output_h = 1080;
68         item->edl->session->aspect_w = 16;
69         item->edl->session->aspect_h = 9;
70         preset_items.append(item);
72         item = new FormatPresetItem(mwindow, this, _("720P"));
73         item->edl->session->audio_channels = 2;
74         item->edl->session->audio_tracks = 2;
75         item->edl->session->sample_rate = 48000;
76         item->edl->session->video_channels = 1;
77         item->edl->session->video_tracks = 1;
78         item->edl->session->frame_rate = (double)60000.0 / 1001;
79 //      item->edl->session->track_w = 1280;
80 //      item->edl->session->track_h = 720;
81         item->edl->session->output_w = 1280;
82         item->edl->session->output_h = 720;
83         item->edl->session->aspect_w = 16;
84         item->edl->session->aspect_h = 9;
85         preset_items.append(item);
87         item = new FormatPresetItem(mwindow, this, _("480P"));
88         item->edl->session->audio_channels = 2;
89         item->edl->session->audio_tracks = 2;
90         item->edl->session->sample_rate = 48000;
91         item->edl->session->video_channels = 1;
92         item->edl->session->video_tracks = 1;
93         item->edl->session->frame_rate = (double)60000.0 / 1001;
94 //      item->edl->session->track_w = 720;
95 //      item->edl->session->track_h = 480;
96         item->edl->session->output_w = 720;
97         item->edl->session->output_h = 480;
98         item->edl->session->aspect_w = 4;
99         item->edl->session->aspect_h = 3;
100         preset_items.append(item);
102         item = new FormatPresetItem(mwindow, this, _("480I"));
103         item->edl->session->audio_channels = 2;
104         item->edl->session->audio_tracks = 2;
105         item->edl->session->sample_rate = 48000;
106         item->edl->session->video_channels = 1;
107         item->edl->session->video_tracks = 1;
108         item->edl->session->frame_rate = (double)30000.0 / 1001;
109 //      item->edl->session->track_w = 720;
110 //      item->edl->session->track_h = 480;
111         item->edl->session->output_w = 720;
112         item->edl->session->output_h = 480;
113         item->edl->session->aspect_w = 4;
114         item->edl->session->aspect_h = 3;
115         preset_items.append(item);
117         item = new FormatPresetItem(mwindow, this, _("Half D-1 NTSC"));
118         item->edl->session->audio_channels = 2;
119         item->edl->session->audio_tracks = 2;
120         item->edl->session->sample_rate = 48000;
121         item->edl->session->video_channels = 1;
122         item->edl->session->video_tracks = 1;
123         item->edl->session->frame_rate = (double)30000.0 / 1001;
124 //      item->edl->session->track_w = 360;
125 //      item->edl->session->track_h = 240;
126         item->edl->session->output_w = 360;
127         item->edl->session->output_h = 240;
128         item->edl->session->aspect_w = 4;
129         item->edl->session->aspect_h = 3;
130         preset_items.append(item);
132         item = new FormatPresetItem(mwindow, this, _("Internet"));
133         item->edl->session->audio_channels = 1;
134         item->edl->session->audio_tracks = 1;
135         item->edl->session->sample_rate = 22050;
136         item->edl->session->video_channels = 1;
137         item->edl->session->video_tracks = 1;
138         item->edl->session->frame_rate = 15;
139 //      item->edl->session->track_w = 320;
140 //      item->edl->session->track_h = 240;
141         item->edl->session->output_w = 320;
142         item->edl->session->output_h = 240;
143         item->edl->session->aspect_w = 4;
144         item->edl->session->aspect_h = 3;
145         preset_items.append(item);
147         item = new FormatPresetItem(mwindow, this, _("CD Audio"));
148         item->edl->session->audio_channels = 2;
149         item->edl->session->audio_tracks = 2;
150         item->edl->session->sample_rate = 44100;
151         item->edl->session->video_channels = 1;
152         item->edl->session->video_tracks = 0;
153         item->edl->session->frame_rate = (double)30000.0 / 1001;
154 //      item->edl->session->track_w = 720;
155 //      item->edl->session->track_h = 480;
156         item->edl->session->output_w = 720;
157         item->edl->session->output_h = 480;
158         item->edl->session->aspect_w = 4;
159         item->edl->session->aspect_h = 3;
160         preset_items.append(item);
162         item = new FormatPresetItem(mwindow, this, _("DAT Audio"));
163         item->edl->session->audio_channels = 2;
164         item->edl->session->audio_tracks = 2;
165         item->edl->session->sample_rate = 48000;
166         item->edl->session->video_channels = 1;
167         item->edl->session->video_tracks = 0;
168         item->edl->session->frame_rate = (double)30000.0 / 1001;
169 //      item->edl->session->track_w = 720;
170 //      item->edl->session->track_h = 480;
171         item->edl->session->output_w = 720;
172         item->edl->session->output_h = 480;
173         item->edl->session->aspect_w = 4;
174         item->edl->session->aspect_h = 3;
175         preset_items.append(item);
179         gui_base->add_subwindow(new BC_Title(x, y, _("Presets:")));
180         int x1 = x;
181         y += 20;
184         gui_base->add_subwindow(text = new FormatPresetsText(mwindow, 
185                 this, 
186                 x, 
187                 y));
188         x += text->get_w();
189         gui_base->add_subwindow(pulldown = new FormatPresetsPulldown(mwindow, 
190                 this, 
191                 x, 
192                 y));
193         x = x1;
196 FormatPresetItem* FormatPresets::find_preset(EDL *edl)
198         for(int i = 1; i < preset_items.total; i++)
199         {
200                 FormatPresetItem *preset = preset_items.values[i];
201                 if(edl->session->audio_tracks == preset->edl->session->audio_tracks &&
202                         edl->session->audio_channels == preset->edl->session->audio_channels &&
203                         edl->session->sample_rate == preset->edl->session->sample_rate &&
204                         edl->session->video_tracks == preset->edl->session->video_tracks &&
205                         edl->session->frame_rate == preset->edl->session->frame_rate &&
206                         edl->session->output_w == preset->edl->session->output_w &&
207                         edl->session->output_h == preset->edl->session->output_h &&
208                         edl->session->aspect_w == preset->edl->session->aspect_w &&
209                         edl->session->aspect_h == preset->edl->session->aspect_h)
210                 {
211                         return preset;
212                 }
213         }
214         return 0;
217 char* FormatPresets::get_preset_text(EDL *edl)
219         FormatPresetItem *item = find_preset(edl);
220         if(item) 
221                 return item->get_text();
222         else
223                 return "Custom";
227 int FormatPresets::handle_event()
229         return 0;
232 EDL* FormatPresets::get_edl()
234         return 0;
241 FormatPresetsText::FormatPresetsText(MWindow *mwindow, 
242         FormatPresets *gui,
243         int x, 
244         int y)
245  : BC_TextBox(x, 
246         y, 
247         200, 
248         1, 
249         gui->get_preset_text(gui->get_edl()))
251         this->gui =  gui;
252         this->mwindow = mwindow;
255 int FormatPresetsText::handle_event()
257         return 1;
269 FormatPresetsPulldown::FormatPresetsPulldown(MWindow *mwindow, 
270         FormatPresets *gui, 
271         int x, 
272         int y)
273  : BC_ListBox(x, 
274                 y, 
275                 200, 
276                 200,
277                 LISTBOX_TEXT,                   // Display text list or icons
278                 (ArrayList<BC_ListBoxItem*>*)&gui->preset_items, // Each column has an ArrayList of BC_ListBoxItems.
279                 0,             // Titles for columns.  Set to 0 for no titles
280                 0,                // width of each column
281                 1,                      // Total columns.
282                 0,                    // Pixel of top of window.
283                 1)
285         this->mwindow = mwindow;
286         this->gui = gui;
289 int FormatPresetsPulldown::handle_event()
291         gui->handle_event();
292         FormatPresetItem *preset = ((FormatPresetItem*)get_selection(0, 0));
293         gui->get_edl()->copy_all(preset->edl);
294         gui->text->update(preset->get_text());
295         gui->handle_event();
296         return 1;
299 FormatPresetItem::FormatPresetItem(MWindow *mwindow, 
300         FormatPresets *gui, 
301         char *text)
302  : BC_ListBoxItem(text)
304         this->mwindow = mwindow;
305         this->gui = gui;
306         edl = new EDL;
307         edl->create_objects();
308         edl->copy_all(gui->get_edl());
311 FormatPresetItem::~FormatPresetItem()
313         delete edl;