Main Page | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Class Members | File Members

formatpresets.C

Go to the documentation of this file.
00001 #include "edl.h"
00002 #include "edlsession.h"
00003 #include "formatpresets.h"
00004 #include "new.h"
00005 #include "setformat.h"
00006 
00007 
00008 
00009 
00010 
00011 FormatPresets::FormatPresets(MWindow *mwindow,
00012         NewWindow *new_gui, 
00013         SetFormatWindow *format_gui, 
00014         int x, 
00015         int y)
00016 {
00017         this->mwindow = mwindow;
00018         this->new_gui = new_gui;
00019         this->format_gui = format_gui;
00020         gui_base = new_gui ? (BC_WindowBase*)new_gui : (BC_WindowBase*)(format_gui);
00021         this->x = x;
00022         this->y = y;
00023         text = 0;
00024         pulldown = 0;
00025 }
00026 
00027 FormatPresets::~FormatPresets()
00028 {
00029         if(text) delete text;
00030         if(pulldown) delete pulldown;
00031         for(int i = 0; i < preset_items.total; i++)
00032                 delete preset_items.values[i];
00033 }
00034 
00035 void FormatPresets::create_objects()
00036 {
00037 // Create preset items
00038         FormatPresetItem *item;
00039         item = new FormatPresetItem(mwindow, this, _("User Defined"));
00040         preset_items.append(item);
00041 
00042         item = new FormatPresetItem(mwindow, this, _("1080P"));
00043         item->edl->session->audio_channels = 2;
00044         item->edl->session->audio_tracks = 2;
00045         item->edl->session->sample_rate = 48000;
00046         item->edl->session->video_channels = 1;
00047         item->edl->session->video_tracks = 1;
00048         item->edl->session->frame_rate = (double)60000.0 / 1001;
00049 //      item->edl->session->track_w = 1920;
00050 //      item->edl->session->track_h = 1080;
00051         item->edl->session->output_w = 1920;
00052         item->edl->session->output_h = 1080;
00053         item->edl->session->aspect_w = 16;
00054         item->edl->session->aspect_h = 9;
00055         preset_items.append(item);
00056 
00057         item = new FormatPresetItem(mwindow, this, _("1080I"));
00058         item->edl->session->audio_channels = 2;
00059         item->edl->session->audio_tracks = 2;
00060         item->edl->session->sample_rate = 48000;
00061         item->edl->session->video_channels = 1;
00062         item->edl->session->video_tracks = 1;
00063         item->edl->session->frame_rate = (double)30000.0 / 1001;
00064 //      item->edl->session->track_w = 1920;
00065 //      item->edl->session->track_h = 1080;
00066         item->edl->session->output_w = 1920;
00067         item->edl->session->output_h = 1080;
00068         item->edl->session->aspect_w = 16;
00069         item->edl->session->aspect_h = 9;
00070         preset_items.append(item);
00071 
00072         item = new FormatPresetItem(mwindow, this, _("720P"));
00073         item->edl->session->audio_channels = 2;
00074         item->edl->session->audio_tracks = 2;
00075         item->edl->session->sample_rate = 48000;
00076         item->edl->session->video_channels = 1;
00077         item->edl->session->video_tracks = 1;
00078         item->edl->session->frame_rate = (double)60000.0 / 1001;
00079 //      item->edl->session->track_w = 1280;
00080 //      item->edl->session->track_h = 720;
00081         item->edl->session->output_w = 1280;
00082         item->edl->session->output_h = 720;
00083         item->edl->session->aspect_w = 16;
00084         item->edl->session->aspect_h = 9;
00085         preset_items.append(item);
00086 
00087         item = new FormatPresetItem(mwindow, this, _("480P"));
00088         item->edl->session->audio_channels = 2;
00089         item->edl->session->audio_tracks = 2;
00090         item->edl->session->sample_rate = 48000;
00091         item->edl->session->video_channels = 1;
00092         item->edl->session->video_tracks = 1;
00093         item->edl->session->frame_rate = (double)60000.0 / 1001;
00094 //      item->edl->session->track_w = 720;
00095 //      item->edl->session->track_h = 480;
00096         item->edl->session->output_w = 720;
00097         item->edl->session->output_h = 480;
00098         item->edl->session->aspect_w = 4;
00099         item->edl->session->aspect_h = 3;
00100         preset_items.append(item);
00101 
00102         item = new FormatPresetItem(mwindow, this, _("480I"));
00103         item->edl->session->audio_channels = 2;
00104         item->edl->session->audio_tracks = 2;
00105         item->edl->session->sample_rate = 48000;
00106         item->edl->session->video_channels = 1;
00107         item->edl->session->video_tracks = 1;
00108         item->edl->session->frame_rate = (double)30000.0 / 1001;
00109 //      item->edl->session->track_w = 720;
00110 //      item->edl->session->track_h = 480;
00111         item->edl->session->output_w = 720;
00112         item->edl->session->output_h = 480;
00113         item->edl->session->aspect_w = 4;
00114         item->edl->session->aspect_h = 3;
00115         preset_items.append(item);
00116 
00117         item = new FormatPresetItem(mwindow, this, _("Half D-1 NTSC"));
00118         item->edl->session->audio_channels = 2;
00119         item->edl->session->audio_tracks = 2;
00120         item->edl->session->sample_rate = 48000;
00121         item->edl->session->video_channels = 1;
00122         item->edl->session->video_tracks = 1;
00123         item->edl->session->frame_rate = (double)30000.0 / 1001;
00124 //      item->edl->session->track_w = 360;
00125 //      item->edl->session->track_h = 240;
00126         item->edl->session->output_w = 360;
00127         item->edl->session->output_h = 240;
00128         item->edl->session->aspect_w = 4;
00129         item->edl->session->aspect_h = 3;
00130         preset_items.append(item);
00131 
00132         item = new FormatPresetItem(mwindow, this, _("Internet"));
00133         item->edl->session->audio_channels = 1;
00134         item->edl->session->audio_tracks = 1;
00135         item->edl->session->sample_rate = 22050;
00136         item->edl->session->video_channels = 1;
00137         item->edl->session->video_tracks = 1;
00138         item->edl->session->frame_rate = 15;
00139 //      item->edl->session->track_w = 320;
00140 //      item->edl->session->track_h = 240;
00141         item->edl->session->output_w = 320;
00142         item->edl->session->output_h = 240;
00143         item->edl->session->aspect_w = 4;
00144         item->edl->session->aspect_h = 3;
00145         preset_items.append(item);
00146 
00147         item = new FormatPresetItem(mwindow, this, _("CD Audio"));
00148         item->edl->session->audio_channels = 2;
00149         item->edl->session->audio_tracks = 2;
00150         item->edl->session->sample_rate = 44100;
00151         item->edl->session->video_channels = 1;
00152         item->edl->session->video_tracks = 0;
00153         item->edl->session->frame_rate = (double)30000.0 / 1001;
00154 //      item->edl->session->track_w = 720;
00155 //      item->edl->session->track_h = 480;
00156         item->edl->session->output_w = 720;
00157         item->edl->session->output_h = 480;
00158         item->edl->session->aspect_w = 4;
00159         item->edl->session->aspect_h = 3;
00160         preset_items.append(item);
00161 
00162         item = new FormatPresetItem(mwindow, this, _("DAT Audio"));
00163         item->edl->session->audio_channels = 2;
00164         item->edl->session->audio_tracks = 2;
00165         item->edl->session->sample_rate = 48000;
00166         item->edl->session->video_channels = 1;
00167         item->edl->session->video_tracks = 0;
00168         item->edl->session->frame_rate = (double)30000.0 / 1001;
00169 //      item->edl->session->track_w = 720;
00170 //      item->edl->session->track_h = 480;
00171         item->edl->session->output_w = 720;
00172         item->edl->session->output_h = 480;
00173         item->edl->session->aspect_w = 4;
00174         item->edl->session->aspect_h = 3;
00175         preset_items.append(item);
00176 
00177 
00178 
00179         gui_base->add_subwindow(new BC_Title(x, y, _("Presets:")));
00180         int x1 = x;
00181         y += 20;
00182 
00183 
00184         gui_base->add_subwindow(text = new FormatPresetsText(mwindow, 
00185                 this, 
00186                 x, 
00187                 y));
00188         x += text->get_w();
00189         gui_base->add_subwindow(pulldown = new FormatPresetsPulldown(mwindow, 
00190                 this, 
00191                 x, 
00192                 y));
00193         x = x1;
00194 }
00195 
00196 FormatPresetItem* FormatPresets::find_preset(EDL *edl)
00197 {
00198         for(int i = 1; i < preset_items.total; i++)
00199         {
00200                 FormatPresetItem *preset = preset_items.values[i];
00201                 if(edl->session->audio_tracks == preset->edl->session->audio_tracks &&
00202                         edl->session->audio_channels == preset->edl->session->audio_channels &&
00203                         edl->session->sample_rate == preset->edl->session->sample_rate &&
00204                         edl->session->video_tracks == preset->edl->session->video_tracks &&
00205                         edl->session->frame_rate == preset->edl->session->frame_rate &&
00206                         edl->session->output_w == preset->edl->session->output_w &&
00207                         edl->session->output_h == preset->edl->session->output_h &&
00208                         edl->session->aspect_w == preset->edl->session->aspect_w &&
00209                         edl->session->aspect_h == preset->edl->session->aspect_h)
00210                 {
00211                         return preset;
00212                 }
00213         }
00214         return 0;
00215 }
00216 
00217 char* FormatPresets::get_preset_text(EDL *edl)
00218 {
00219         FormatPresetItem *item = find_preset(edl);
00220         if(item) 
00221                 return item->get_text();
00222         else
00223                 return "Custom";
00224 }
00225 
00226 
00227 int FormatPresets::handle_event()
00228 {
00229         return 0;
00230 }
00231 
00232 EDL* FormatPresets::get_edl()
00233 {
00234         return 0;
00235 }
00236 
00237 
00238 
00239 
00240 
00241 FormatPresetsText::FormatPresetsText(MWindow *mwindow, 
00242         FormatPresets *gui,
00243         int x, 
00244         int y)
00245  : BC_TextBox(x, 
00246         y, 
00247         200, 
00248         1, 
00249         gui->get_preset_text(gui->get_edl()))
00250 {
00251         this->gui =  gui;
00252         this->mwindow = mwindow;
00253 }
00254 
00255 int FormatPresetsText::handle_event()
00256 {
00257         return 1;
00258 }
00259 
00260 
00261 
00262 
00263 
00264 
00265 
00266 
00267 
00268 
00269 FormatPresetsPulldown::FormatPresetsPulldown(MWindow *mwindow, 
00270         FormatPresets *gui, 
00271         int x, 
00272         int y)
00273  : BC_ListBox(x, 
00274                 y, 
00275                 200, 
00276                 200,
00277                 LISTBOX_TEXT,                   // Display text list or icons
00278                 (ArrayList<BC_ListBoxItem*>*)&gui->preset_items, // Each column has an ArrayList of BC_ListBoxItems.
00279                 0,             // Titles for columns.  Set to 0 for no titles
00280                 0,                // width of each column
00281                 1,                      // Total columns.
00282                 0,                    // Pixel of top of window.
00283                 1)
00284 {
00285         this->mwindow = mwindow;
00286         this->gui = gui;
00287 }
00288 
00289 int FormatPresetsPulldown::handle_event()
00290 {
00291         gui->handle_event();
00292         FormatPresetItem *preset = ((FormatPresetItem*)get_selection(0, 0));
00293         gui->get_edl()->copy_all(preset->edl);
00294         gui->text->update(preset->get_text());
00295         gui->handle_event();
00296         return 1;
00297 }
00298 
00299 FormatPresetItem::FormatPresetItem(MWindow *mwindow, 
00300         FormatPresets *gui, 
00301         char *text)
00302  : BC_ListBoxItem(text)
00303 {
00304         this->mwindow = mwindow;
00305         this->gui = gui;
00306         edl = new EDL;
00307         edl->create_objects();
00308         edl->copy_all(gui->get_edl());
00309 }
00310 
00311 FormatPresetItem::~FormatPresetItem()
00312 {
00313         delete edl;
00314 }
00315 
00316 

Generated on Sun Jan 8 13:38:55 2006 for Cinelerra-svn by  doxygen 1.4.4