4 * Copyright (C) 2008 Adam Williams <broadcast at earthling dot net>
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.
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.
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
24 #include "edlsession.h"
25 #include "formatpresets.h"
28 #include "setformat.h"
31 FormatPresets::FormatPresets(MWindow *mwindow,
33 SetFormatWindow *format_gui,
37 this->mwindow = mwindow;
38 this->new_gui = new_gui;
39 this->format_gui = format_gui;
40 gui_base = new_gui ? (BC_WindowBase*)new_gui : (BC_WindowBase*)(format_gui);
47 FormatPresets::~FormatPresets()
50 if(pulldown) delete pulldown;
51 for(int i = 0; i < preset_items.total; i++)
52 delete preset_items.values[i];
55 void FormatPresets::create_objects()
57 FormatPresetItem * item = new FormatPresetItem(mwindow, this, _("User Defined"));
58 preset_items.append(item);
61 for(i = 0; (p = mwindow->get_preset_name(i)) != 0; i++) {
62 item = new FormatPresetItem(mwindow, this, p);
63 mwindow->fill_preset_defaults(p, item->edl->session);
64 preset_items.append(item);
67 gui_base->add_subwindow(new BC_Title(x, y, _("Presets:")));
72 gui_base->add_subwindow(text = new FormatPresetsText(mwindow,
77 gui_base->add_subwindow(pulldown = new FormatPresetsPulldown(mwindow,
84 FormatPresetItem* FormatPresets::find_preset(EDL *edl)
86 for(int i = 1; i < preset_items.total; i++)
88 FormatPresetItem *preset = preset_items.values[i];
89 if(edl->session->audio_tracks == preset->edl->session->audio_tracks &&
90 edl->session->audio_channels == preset->edl->session->audio_channels &&
91 edl->session->sample_rate == preset->edl->session->sample_rate &&
92 edl->session->video_tracks == preset->edl->session->video_tracks &&
93 EQUIV(edl->session->frame_rate, preset->edl->session->frame_rate) &&
94 edl->session->output_w == preset->edl->session->output_w &&
95 edl->session->output_h == preset->edl->session->output_h &&
96 EQUIV(edl->session->aspect_w, preset->edl->session->aspect_w) &&
97 EQUIV(edl->session->aspect_h, preset->edl->session->aspect_h) &&
98 edl->session->interlace_mode == preset->edl->session->interlace_mode &&
99 edl->session->color_model == preset->edl->session->color_model)
107 const char* FormatPresets::get_preset_text(EDL *edl)
109 FormatPresetItem *item = edl ? find_preset(edl) : 0;
110 return item ? item->get_text() : _("User Defined");
114 int FormatPresets::handle_event()
119 EDL* FormatPresets::get_edl()
128 FormatPresetsText::FormatPresetsText(MWindow *mwindow,
132 : BC_TextBox(x, y, xS(200), 1,
133 gui->get_preset_text(gui->get_edl()))
136 this->mwindow = mwindow;
139 int FormatPresetsText::handle_event()
153 FormatPresetsPulldown::FormatPresetsPulldown(MWindow *mwindow,
157 : BC_ListBox(x, y, xS(200), yS(250),
158 LISTBOX_TEXT, // Display text list or icons
159 (ArrayList<BC_ListBoxItem*>*)&gui->preset_items, // Each column has an ArrayList of BC_ListBoxItems.
160 0, // Titles for columns. Set to 0 for no titles
161 0, // width of each column
163 0, // Pixel of top of window.
166 this->mwindow = mwindow;
170 int FormatPresetsPulldown::handle_event()
173 FormatPresetItem *preset = ((FormatPresetItem*)get_selection(0, 0));
174 gui->get_edl()->copy_all(preset->edl);
175 gui->text->update(preset->get_text());
180 FormatPresetItem::FormatPresetItem(MWindow *mwindow,
183 : BC_ListBoxItem(text)
185 this->mwindow = mwindow;
188 edl->create_objects();
189 edl->copy_all(gui->get_edl());
192 FormatPresetItem::~FormatPresetItem()
194 edl->Garbage::remove_user();