6 #include "edlsession.h"
8 #include "interlacemodes.h"
10 #include "levelwindow.h"
15 #include "mwindowgui.h"
17 #include "newpresets.h"
18 #include "mainsession.h"
20 #include "preferences.h"
22 #include "transportque.h"
23 #include "videowindow.h"
24 #include "vplayback.h"
35 New::New(MWindow *mwindow)
36 : BC_MenuItem(_("New..."), "n", 'n')
38 this->mwindow = mwindow;
42 int New::create_objects()
44 thread = new NewThread(mwindow, this);
48 int New::handle_event()
52 thread->window_lock->lock("New::handle_event");
55 thread->nwindow->lock_window("New::handle_event");
56 thread->nwindow->raise_window();
57 thread->nwindow->unlock_window();
59 thread->window_lock->unlock();
62 mwindow->edl->save_defaults(mwindow->defaults);
69 void New::create_new_edl()
72 new_edl->create_objects();
73 new_edl->load_defaults(mwindow->defaults);
77 int New::create_new_project()
79 mwindow->cwindow->playback_engine->que->send_command(STOP,
83 mwindow->vwindow->playback_engine->que->send_command(STOP,
87 mwindow->cwindow->playback_engine->interrupt_playback(0);
88 mwindow->vwindow->playback_engine->interrupt_playback(0);
90 mwindow->gui->lock_window();
91 mwindow->reset_caches();
93 memcpy(new_edl->session->achannel_positions,
94 &mwindow->preferences->channel_positions[
95 MAXCHANNELS * (new_edl->session->audio_channels - 1)],
96 sizeof(int) * MAXCHANNELS);
97 new_edl->session->boundaries();
98 new_edl->create_default_tracks();
100 mwindow->set_filename("");
101 mwindow->undo->update_undo(_("New"), LOAD_ALL);
103 mwindow->hide_plugins();
105 mwindow->edl = new_edl;
106 mwindow->save_defaults();
108 // Load file sequence
109 mwindow->update_project(LOAD_REPLACE);
110 mwindow->session->changes_made = 0;
111 mwindow->gui->unlock_window();
115 NewThread::NewThread(MWindow *mwindow, New *new_project)
118 this->mwindow = mwindow;
119 this->new_project = new_project;
120 window_lock = new Mutex("NewThread::window_lock");
123 NewThread::~NewThread()
129 void NewThread::run()
134 int x = mwindow->gui->get_root_w(0, 1) / 2 - WIDTH / 2;
135 int y = mwindow->gui->get_root_h(1) / 2 - HEIGHT / 2;
137 window_lock->lock("NewThread::run 1\n");
138 nwindow = new NewWindow(mwindow, this, x, y);
139 nwindow->create_objects();
140 window_lock->unlock();
142 result = nwindow->run_window();
144 window_lock->lock("NewThread::run 2\n");
147 window_lock->unlock();
149 new_project->new_edl->save_defaults(mwindow->defaults);
150 mwindow->defaults->save();
155 delete new_project->new_edl;
159 new_project->create_new_project();
163 int NewThread::load_defaults()
165 auto_aspect = mwindow->defaults->get("AUTOASPECT", 0);
169 int NewThread::save_defaults()
171 mwindow->defaults->update("AUTOASPECT", auto_aspect);
175 int NewThread::update_aspect()
179 char string[BCTEXTLEN];
180 mwindow->create_aspect_ratio(new_project->new_edl->session->aspect_w,
181 new_project->new_edl->session->aspect_h,
182 new_project->new_edl->session->output_w,
183 new_project->new_edl->session->output_h);
184 sprintf(string, "%.02f", new_project->new_edl->session->aspect_w);
185 nwindow->aspect_w_text->update(string);
186 sprintf(string, "%.02f", new_project->new_edl->session->aspect_h);
187 nwindow->aspect_h_text->update(string);
196 N_("Cinelerra: New Project");
199 NewWindow::NewWindow(MWindow *mwindow, NewThread *new_thread, int x, int y)
200 : BC_Window(_(PROGRAM_NAME ": New Project"),
211 this->mwindow = mwindow;
212 this->new_thread = new_thread;
213 this->new_edl = new_thread->new_project->new_edl;
217 NewWindow::~NewWindow()
219 if(format_presets) delete format_presets;
222 int NewWindow::create_objects()
224 int x = 10, y = 10, x1, y1;
227 mwindow->theme->draw_new_bg(this);
229 add_subwindow(new BC_Title(x, y, _("Parameters for the new project:")));
232 format_presets = new NewPresets(mwindow,
236 format_presets->create_objects();
237 x = format_presets->x;
238 y = format_presets->y;
244 add_subwindow(new BC_Title(x, y, _("Audio"), LARGEFONT));
248 add_subwindow(new BC_Title(x1, y, _("Tracks:")));
250 add_subwindow(atracks = new NewATracks(this, "", x1, y));
251 x1 += atracks->get_w();
252 add_subwindow(new NewATracksTumbler(this, x1, y));
253 y += atracks->get_h() + 5;
256 add_subwindow(new BC_Title(x1, y, _("Channels:")));
258 add_subwindow(achannels = new NewAChannels(this, "", x1, y));
259 x1 += achannels->get_w();
260 add_subwindow(new NewAChannelsTumbler(this, x1, y));
261 y += achannels->get_h() + 5;
264 add_subwindow(new BC_Title(x1, y, _("Samplerate:")));
266 add_subwindow(sample_rate = new NewSampleRate(this, "", x1, y));
267 x1 += sample_rate->get_w();
268 add_subwindow(new SampleRatePulldown(mwindow, sample_rate, x1, y));
272 add_subwindow(new BC_Title(x, y, _("Video"), LARGEFONT));
275 add_subwindow(new BC_Title(x1, y, _("Tracks:")));
277 add_subwindow(vtracks = new NewVTracks(this, "", x1, y));
278 x1 += vtracks->get_w();
279 add_subwindow(new NewVTracksTumbler(this, x1, y));
280 y += vtracks->get_h() + 5;
283 // add_subwindow(new BC_Title(x1, y, _("Channels:")));
285 // add_subwindow(vchannels = new NewVChannels(this, "", x1, y));
286 // x1 += vchannels->get_w();
287 // add_subwindow(new NewVChannelsTumbler(this, x1, y));
288 // y += vchannels->get_h() + 5;
290 add_subwindow(new BC_Title(x1, y, _("Framerate:")));
292 add_subwindow(frame_rate = new NewFrameRate(this, "", x1, y));
293 x1 += frame_rate->get_w();
294 add_subwindow(new FrameRatePulldown(mwindow, frame_rate, x1, y));
295 y += frame_rate->get_h() + 5;
298 // add_subwindow(new BC_Title(x1, y, _("Canvas size:")));
300 // add_subwindow(canvas_w_text = new NewTrackW(this, x1, y));
301 // x1 += canvas_w_text->get_w() + 2;
302 // add_subwindow(new BC_Title(x1, y, "x"));
304 // add_subwindow(canvas_h_text = new NewTrackH(this, x1, y));
305 // x1 += canvas_h_text->get_w();
306 // add_subwindow(new FrameSizePulldown(mwindow,
312 // add_subwindow(new NewCloneToggle(mwindow, this, x1, y));
313 // y += canvas_h_text->get_h() + 5;
316 add_subwindow(new BC_Title(x1, y, _("Canvas size:")));
318 add_subwindow(output_w_text = new NewOutputW(this, x1, y));
319 x1 += output_w_text->get_w() + 2;
320 add_subwindow(new BC_Title(x1, y, "x"));
322 add_subwindow(output_h_text = new NewOutputH(this, x1, y));
323 x1 += output_h_text->get_w();
324 FrameSizePulldown *pulldown;
325 add_subwindow(pulldown = new FrameSizePulldown(mwindow,
330 x1 += pulldown->get_w() + 5;
331 add_subwindow(new NewSwapExtents(mwindow, this, x1, y));
332 y += output_h_text->get_h() + 5;
335 add_subwindow(new BC_Title(x1, y, _("Aspect ratio:")));
337 add_subwindow(aspect_w_text = new NewAspectW(this, "", x1, y));
338 x1 += aspect_w_text->get_w() + 2;
339 add_subwindow(new BC_Title(x1, y, ":"));
341 add_subwindow(aspect_h_text = new NewAspectH(this, "", x1, y));
342 x1 += aspect_h_text->get_w();
343 add_subwindow(new AspectPulldown(mwindow,
349 x1 = aspect_w_text->get_x();
350 y += aspect_w_text->get_h() + 5;
351 add_subwindow(new NewAspectAuto(this, x1, y));
353 add_subwindow(new BC_Title(x, y, _("Color model:")));
354 add_subwindow(textbox = new BC_TextBox(x + 100, y, 200, 1, ""));
355 add_subwindow(new ColormodelPulldown(mwindow,
357 &new_edl->session->color_model,
358 x + 100 + textbox->get_w(),
360 y += textbox->get_h() + 5;
362 // --------------------
363 add_subwindow(new BC_Title(x, y, _("Interlace mode:")));
364 add_subwindow(textbox = new BC_TextBox(x + 100, y, 140, 1, ""));
365 add_subwindow(interlace_pulldown = new InterlacemodePulldown(mwindow,
367 &new_edl->session->interlace_mode,
368 (ArrayList<BC_ListBoxItem*>*)&mwindow->interlace_project_modes,
369 x + 100 + textbox->get_w(),
371 y += textbox->get_h() + 5;
373 add_subwindow(new BC_OKButton(this,
374 mwindow->theme->get_image_set("new_ok_images")));
375 add_subwindow(new BC_CancelButton(this,
376 mwindow->theme->get_image_set("new_cancel_images")));
383 int NewWindow::update()
385 char string[BCTEXTLEN];
386 atracks->update((int64_t)new_edl->session->audio_tracks);
387 achannels->update((int64_t)new_edl->session->audio_channels);
388 sample_rate->update((int64_t)new_edl->session->sample_rate);
389 vtracks->update((int64_t)new_edl->session->video_tracks);
390 frame_rate->update((float)new_edl->session->frame_rate);
391 output_w_text->update((int64_t)new_edl->session->output_w);
392 output_h_text->update((int64_t)new_edl->session->output_h);
393 aspect_w_text->update((float)new_edl->session->aspect_w);
394 aspect_h_text->update((float)new_edl->session->aspect_h);
395 interlace_pulldown->update(new_edl->session->interlace_mode);
405 NewPresets::NewPresets(MWindow *mwindow, NewWindow *gui, int x, int y)
406 : FormatPresets(mwindow, gui, 0, x, y)
410 NewPresets::~NewPresets()
414 int NewPresets::handle_event()
420 EDL* NewPresets::get_edl()
422 return new_gui->new_edl;
427 NewATracks::NewATracks(NewWindow *nwindow, char *text, int x, int y)
428 : BC_TextBox(x, y, 90, 1, text)
430 this->nwindow = nwindow;
433 int NewATracks::handle_event()
435 nwindow->new_edl->session->audio_tracks = atol(get_text());
439 NewATracksTumbler::NewATracksTumbler(NewWindow *nwindow, int x, int y)
442 this->nwindow = nwindow;
444 int NewATracksTumbler::handle_up_event()
446 nwindow->new_edl->session->audio_tracks++;
447 nwindow->new_edl->boundaries();
451 int NewATracksTumbler::handle_down_event()
453 nwindow->new_edl->session->audio_tracks--;
454 nwindow->new_edl->boundaries();
459 NewAChannels::NewAChannels(NewWindow *nwindow, char *text, int x, int y)
460 : BC_TextBox(x, y, 90, 1, text)
462 this->nwindow = nwindow;
465 int NewAChannels::handle_event()
467 nwindow->new_edl->session->audio_channels = atol(get_text());
471 NewAChannelsTumbler::NewAChannelsTumbler(NewWindow *nwindow, int x, int y)
474 this->nwindow = nwindow;
476 int NewAChannelsTumbler::handle_up_event()
478 nwindow->new_edl->session->audio_channels++;
479 nwindow->new_edl->boundaries();
483 int NewAChannelsTumbler::handle_down_event()
485 nwindow->new_edl->session->audio_channels--;
486 nwindow->new_edl->boundaries();
492 NewSampleRate::NewSampleRate(NewWindow *nwindow, char *text, int x, int y)
493 : BC_TextBox(x, y, 90, 1, text)
495 this->nwindow = nwindow;
498 int NewSampleRate::handle_event()
500 nwindow->new_edl->session->sample_rate = atol(get_text());
504 SampleRatePulldown::SampleRatePulldown(MWindow *mwindow, BC_TextBox *output, int x, int y)
510 &mwindow->theme->sample_rates,
517 this->mwindow = mwindow;
518 this->output = output;
520 int SampleRatePulldown::handle_event()
522 char *text = get_selection(0, 0)->get_text();
523 output->update(text);
524 output->handle_event();
542 NewVTracks::NewVTracks(NewWindow *nwindow, char *text, int x, int y)
543 : BC_TextBox(x, y, 90, 1, text)
545 this->nwindow = nwindow;
548 int NewVTracks::handle_event()
550 nwindow->new_edl->session->video_tracks = atol(get_text());
554 NewVTracksTumbler::NewVTracksTumbler(NewWindow *nwindow, int x, int y)
557 this->nwindow = nwindow;
559 int NewVTracksTumbler::handle_up_event()
561 nwindow->new_edl->session->video_tracks++;
562 nwindow->new_edl->boundaries();
566 int NewVTracksTumbler::handle_down_event()
568 nwindow->new_edl->session->video_tracks--;
569 nwindow->new_edl->boundaries();
574 NewVChannels::NewVChannels(NewWindow *nwindow, char *text, int x, int y)
575 : BC_TextBox(x, y, 90, 1, text)
577 this->nwindow = nwindow;
580 int NewVChannels::handle_event()
582 nwindow->new_edl->session->video_channels = atol(get_text());
586 NewVChannelsTumbler::NewVChannelsTumbler(NewWindow *nwindow, int x, int y)
589 this->nwindow = nwindow;
591 int NewVChannelsTumbler::handle_up_event()
593 nwindow->new_edl->session->video_channels++;
594 nwindow->new_edl->boundaries();
598 int NewVChannelsTumbler::handle_down_event()
600 nwindow->new_edl->session->video_channels--;
601 nwindow->new_edl->boundaries();
606 NewFrameRate::NewFrameRate(NewWindow *nwindow, char *text, int x, int y)
607 : BC_TextBox(x, y, 90, 1, text)
609 this->nwindow = nwindow;
612 int NewFrameRate::handle_event()
614 nwindow->new_edl->session->frame_rate = Units::atoframerate(get_text());
618 FrameRatePulldown::FrameRatePulldown(MWindow *mwindow,
627 &mwindow->theme->frame_rates,
634 this->mwindow = mwindow;
635 this->output = output;
637 int FrameRatePulldown::handle_event()
639 char *text = get_selection(0, 0)->get_text();
640 output->update(text);
641 output->handle_event();
645 FrameSizePulldown::FrameSizePulldown(MWindow *mwindow,
646 BC_TextBox *output_w,
647 BC_TextBox *output_h,
655 &mwindow->theme->frame_sizes,
662 this->mwindow = mwindow;
663 this->output_w = output_w;
664 this->output_h = output_h;
666 int FrameSizePulldown::handle_event()
668 char *text = get_selection(0, 0)->get_text();
669 char string[BCTEXTLEN];
673 strcpy(string, text);
674 ptr = strrchr(string, 'x');
684 output_w->handle_event();
685 output_h->handle_event();
690 NewOutputW::NewOutputW(NewWindow *nwindow, int x, int y)
691 : BC_TextBox(x, y, 70, 1, nwindow->new_edl->session->output_w)
693 this->nwindow = nwindow;
695 int NewOutputW::handle_event()
697 nwindow->new_edl->session->output_w = MAX(1,atol(get_text()));
698 nwindow->new_thread->update_aspect();
702 NewOutputH::NewOutputH(NewWindow *nwindow, int x, int y)
703 : BC_TextBox(x, y, 70, 1, nwindow->new_edl->session->output_h)
705 this->nwindow = nwindow;
707 int NewOutputH::handle_event()
709 nwindow->new_edl->session->output_h = MAX(1, atol(get_text()));
710 nwindow->new_thread->update_aspect();
714 NewAspectW::NewAspectW(NewWindow *nwindow, char *text, int x, int y)
715 : BC_TextBox(x, y, 70, 1, text)
717 this->nwindow = nwindow;
720 int NewAspectW::handle_event()
722 nwindow->new_edl->session->aspect_w = atof(get_text());
726 NewAspectH::NewAspectH(NewWindow *nwindow, char *text, int x, int y)
727 : BC_TextBox(x, y, 70, 1, text)
729 this->nwindow = nwindow;
732 int NewAspectH::handle_event()
734 nwindow->new_edl->session->aspect_h = atof(get_text());
738 AspectPulldown::AspectPulldown(MWindow *mwindow,
739 BC_TextBox *output_w,
740 BC_TextBox *output_h,
748 &mwindow->theme->aspect_ratios,
755 this->mwindow = mwindow;
756 this->output_w = output_w;
757 this->output_h = output_h;
759 int AspectPulldown::handle_event()
761 char *text = get_selection(0, 0)->get_text();
762 char string[BCTEXTLEN];
766 strcpy(string, text);
767 ptr = strrchr(string, ':');
777 output_w->handle_event();
778 output_h->handle_event();
783 ColormodelItem::ColormodelItem(char *text, int value)
784 : BC_ListBoxItem(text)
789 ColormodelPulldown::ColormodelPulldown(MWindow *mwindow,
790 BC_TextBox *output_text,
799 (ArrayList<BC_ListBoxItem*>*)&mwindow->colormodels,
806 this->mwindow = mwindow;
807 this->output_text = output_text;
808 this->output_value = output_value;
809 output_text->update(colormodel_to_text());
812 int ColormodelPulldown::handle_event()
814 output_text->update(get_selection(0, 0)->get_text());
815 *output_value = ((ColormodelItem*)get_selection(0, 0))->value;
819 char* ColormodelPulldown::colormodel_to_text()
821 for(int i = 0; i < mwindow->colormodels.total; i++)
822 if(mwindow->colormodels.values[i]->value == *output_value)
823 return mwindow->colormodels.values[i]->get_text();
827 InterlacemodeItem::InterlacemodeItem(char *text, int value)
828 : BC_ListBoxItem(text)
833 InterlacemodePulldown::InterlacemodePulldown(MWindow *mwindow,
834 BC_TextBox *output_text,
836 ArrayList<BC_ListBoxItem*> *data,
851 char string[BCTEXTLEN];
852 this->mwindow = mwindow;
853 this->output_text = output_text;
854 this->output_value = output_value;
855 output_text->update(interlacemode_to_text());
858 int InterlacemodePulldown::handle_event()
860 output_text->update(get_selection(0, 0)->get_text());
861 *output_value = ((InterlacemodeItem*)get_selection(0, 0))->value;
865 char* InterlacemodePulldown::interlacemode_to_text()
867 ilacemode_to_text(this->string,*output_value);
868 return (this->string);
871 int InterlacemodePulldown::update(int interlace_mode)
873 *output_value = interlace_mode;
874 output_text->update(interlacemode_to_text());
879 NewAspectAuto::NewAspectAuto(NewWindow *nwindow, int x, int y)
880 : BC_CheckBox(x, y, nwindow->new_thread->auto_aspect, _("Auto aspect ratio"))
882 this->nwindow = nwindow;
884 NewAspectAuto::~NewAspectAuto()
887 int NewAspectAuto::handle_event()
889 nwindow->new_thread->auto_aspect = get_value();
890 nwindow->new_thread->update_aspect();
901 NewSwapExtents::NewSwapExtents(MWindow *mwindow, NewWindow *gui, int x, int y)
902 : BC_Button(x, y, mwindow->theme->get_image_set("swap_extents"))
904 this->mwindow = mwindow;
906 set_tooltip("Swap dimensions");
909 int NewSwapExtents::handle_event()
911 int w = gui->new_edl->session->output_w;
912 int h = gui->new_edl->session->output_h;
913 gui->new_edl->session->output_w = h;
914 gui->new_edl->session->output_h = w;
915 gui->output_w_text->update((int64_t)h);
916 gui->output_h_text->update((int64_t)w);
917 gui->new_thread->update_aspect();