4 * Copyright (C) 2008 Adam Williams <broadcast at earthling dot net>
5 * Copyright (C) 2003-2016 Cinelerra CV contributors
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
25 #include "edlsession.h"
26 #include "formatpresets.h"
29 #include "setformat.h"
32 FormatPresets::FormatPresets(MWindow *mwindow,
34 SetFormatWindow *format_gui,
38 this->mwindow = mwindow;
39 this->new_gui = new_gui;
40 this->format_gui = format_gui;
41 gui_base = new_gui ? (BC_WindowBase*)new_gui : (BC_WindowBase*)(format_gui);
48 FormatPresets::~FormatPresets()
51 if(pulldown) delete pulldown;
52 for(int i = 0; i < preset_items.total; i++)
53 delete preset_items.values[i];
56 void FormatPresets::create_objects()
58 FormatPresetItem * item = new FormatPresetItem(mwindow, this, _("User Defined"));
59 preset_items.append(item);
62 for(i = 0; (p = mwindow->get_preset_name(i)) != 0; i++) {
63 item = new FormatPresetItem(mwindow, this, p);
64 mwindow->fill_preset_defaults(p, item->edl->session);
65 preset_items.append(item);
68 gui_base->add_subwindow(new BC_Title(x, y, _("Presets:")));
73 gui_base->add_subwindow(text = new FormatPresetsText(mwindow,
78 gui_base->add_subwindow(pulldown = new FormatPresetsPulldown(mwindow,
85 FormatPresetItem* FormatPresets::find_preset(EDL *edl)
87 for(int i = 1; i < preset_items.total; i++)
89 FormatPresetItem *preset = preset_items.values[i];
90 if(edl->session->audio_tracks == preset->edl->session->audio_tracks &&
91 edl->session->audio_channels == preset->edl->session->audio_channels &&
92 edl->session->sample_rate == preset->edl->session->sample_rate &&
93 edl->session->video_tracks == preset->edl->session->video_tracks &&
94 EQUIV(edl->session->frame_rate, preset->edl->session->frame_rate) &&
95 edl->session->output_w == preset->edl->session->output_w &&
96 edl->session->output_h == preset->edl->session->output_h &&
97 EQUIV(edl->session->aspect_w, preset->edl->session->aspect_w) &&
98 EQUIV(edl->session->aspect_h, preset->edl->session->aspect_h) &&
99 edl->session->interlace_mode == preset->edl->session->interlace_mode &&
100 edl->session->color_model == preset->edl->session->color_model)
108 const char* FormatPresets::get_preset_text(EDL *edl)
110 FormatPresetItem *item = edl ? find_preset(edl) : 0;
111 return item ? item->get_text() : _("User Defined");
115 int FormatPresets::handle_event()
120 EDL* FormatPresets::get_edl()
129 FormatPresetsText::FormatPresetsText(MWindow *mwindow,
133 : BC_TextBox(x, y, xS(200), 1,
134 gui->get_preset_text(gui->get_edl()))
137 this->mwindow = mwindow;
140 int FormatPresetsText::handle_event()
154 FormatPresetsPulldown::FormatPresetsPulldown(MWindow *mwindow,
158 : BC_ListBox(x, y, xS(200), yS(250),
159 LISTBOX_TEXT, // Display text list or icons
160 (ArrayList<BC_ListBoxItem*>*)&gui->preset_items, // Each column has an ArrayList of BC_ListBoxItems.
161 0, // Titles for columns. Set to 0 for no titles
162 0, // width of each column
164 0, // Pixel of top of window.
167 this->mwindow = mwindow;
171 int FormatPresetsPulldown::handle_event()
174 FormatPresetItem *preset = ((FormatPresetItem*)get_selection(0, 0));
175 gui->get_edl()->copy_all(preset->edl);
176 gui->text->update(preset->get_text());
181 FormatPresetItem::FormatPresetItem(MWindow *mwindow,
184 : BC_ListBoxItem(text)
186 this->mwindow = mwindow;
189 edl->create_objects();
190 edl->copy_all(gui->get_edl());
193 FormatPresetItem::~FormatPresetItem()
195 edl->Garbage::remove_user();