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(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);
404 NewPresets::NewPresets(MWindow *mwindow, NewWindow *gui, int x, int y)
405 : FormatPresets(mwindow, gui, 0, x, y)
409 NewPresets::~NewPresets()
413 int NewPresets::handle_event()
419 EDL* NewPresets::get_edl()
421 return new_gui->new_edl;
426 NewATracks::NewATracks(NewWindow *nwindow, char *text, int x, int y)
427 : BC_TextBox(x, y, 90, 1, text)
429 this->nwindow = nwindow;
432 int NewATracks::handle_event()
434 nwindow->new_edl->session->audio_tracks = atol(get_text());
438 NewATracksTumbler::NewATracksTumbler(NewWindow *nwindow, int x, int y)
441 this->nwindow = nwindow;
443 int NewATracksTumbler::handle_up_event()
445 nwindow->new_edl->session->audio_tracks++;
446 nwindow->new_edl->boundaries();
450 int NewATracksTumbler::handle_down_event()
452 nwindow->new_edl->session->audio_tracks--;
453 nwindow->new_edl->boundaries();
458 NewAChannels::NewAChannels(NewWindow *nwindow, char *text, int x, int y)
459 : BC_TextBox(x, y, 90, 1, text)
461 this->nwindow = nwindow;
464 int NewAChannels::handle_event()
466 nwindow->new_edl->session->audio_channels = atol(get_text());
470 NewAChannelsTumbler::NewAChannelsTumbler(NewWindow *nwindow, int x, int y)
473 this->nwindow = nwindow;
475 int NewAChannelsTumbler::handle_up_event()
477 nwindow->new_edl->session->audio_channels++;
478 nwindow->new_edl->boundaries();
482 int NewAChannelsTumbler::handle_down_event()
484 nwindow->new_edl->session->audio_channels--;
485 nwindow->new_edl->boundaries();
491 NewSampleRate::NewSampleRate(NewWindow *nwindow, char *text, int x, int y)
492 : BC_TextBox(x, y, 90, 1, text)
494 this->nwindow = nwindow;
497 int NewSampleRate::handle_event()
499 nwindow->new_edl->session->sample_rate = atol(get_text());
503 SampleRatePulldown::SampleRatePulldown(MWindow *mwindow, BC_TextBox *output, int x, int y)
509 &mwindow->theme->sample_rates,
516 this->mwindow = mwindow;
517 this->output = output;
519 int SampleRatePulldown::handle_event()
521 char *text = get_selection(0, 0)->get_text();
522 output->update(text);
523 output->handle_event();
541 NewVTracks::NewVTracks(NewWindow *nwindow, char *text, int x, int y)
542 : BC_TextBox(x, y, 90, 1, text)
544 this->nwindow = nwindow;
547 int NewVTracks::handle_event()
549 nwindow->new_edl->session->video_tracks = atol(get_text());
553 NewVTracksTumbler::NewVTracksTumbler(NewWindow *nwindow, int x, int y)
556 this->nwindow = nwindow;
558 int NewVTracksTumbler::handle_up_event()
560 nwindow->new_edl->session->video_tracks++;
561 nwindow->new_edl->boundaries();
565 int NewVTracksTumbler::handle_down_event()
567 nwindow->new_edl->session->video_tracks--;
568 nwindow->new_edl->boundaries();
573 NewVChannels::NewVChannels(NewWindow *nwindow, char *text, int x, int y)
574 : BC_TextBox(x, y, 90, 1, text)
576 this->nwindow = nwindow;
579 int NewVChannels::handle_event()
581 nwindow->new_edl->session->video_channels = atol(get_text());
585 NewVChannelsTumbler::NewVChannelsTumbler(NewWindow *nwindow, int x, int y)
588 this->nwindow = nwindow;
590 int NewVChannelsTumbler::handle_up_event()
592 nwindow->new_edl->session->video_channels++;
593 nwindow->new_edl->boundaries();
597 int NewVChannelsTumbler::handle_down_event()
599 nwindow->new_edl->session->video_channels--;
600 nwindow->new_edl->boundaries();
605 NewFrameRate::NewFrameRate(NewWindow *nwindow, char *text, int x, int y)
606 : BC_TextBox(x, y, 90, 1, text)
608 this->nwindow = nwindow;
611 int NewFrameRate::handle_event()
613 nwindow->new_edl->session->frame_rate = Units::atoframerate(get_text());
617 FrameRatePulldown::FrameRatePulldown(MWindow *mwindow,
626 &mwindow->theme->frame_rates,
633 this->mwindow = mwindow;
634 this->output = output;
636 int FrameRatePulldown::handle_event()
638 char *text = get_selection(0, 0)->get_text();
639 output->update(text);
640 output->handle_event();
644 FrameSizePulldown::FrameSizePulldown(MWindow *mwindow,
645 BC_TextBox *output_w,
646 BC_TextBox *output_h,
654 &mwindow->theme->frame_sizes,
661 this->mwindow = mwindow;
662 this->output_w = output_w;
663 this->output_h = output_h;
665 int FrameSizePulldown::handle_event()
667 char *text = get_selection(0, 0)->get_text();
668 char string[BCTEXTLEN];
672 strcpy(string, text);
673 ptr = strrchr(string, 'x');
683 output_w->handle_event();
684 output_h->handle_event();
689 NewOutputW::NewOutputW(NewWindow *nwindow, int x, int y)
690 : BC_TextBox(x, y, 70, 1, nwindow->new_edl->session->output_w)
692 this->nwindow = nwindow;
694 int NewOutputW::handle_event()
696 nwindow->new_edl->session->output_w = MAX(1,atol(get_text()));
697 nwindow->new_thread->update_aspect();
701 NewOutputH::NewOutputH(NewWindow *nwindow, int x, int y)
702 : BC_TextBox(x, y, 70, 1, nwindow->new_edl->session->output_h)
704 this->nwindow = nwindow;
706 int NewOutputH::handle_event()
708 nwindow->new_edl->session->output_h = MAX(1, atol(get_text()));
709 nwindow->new_thread->update_aspect();
713 NewAspectW::NewAspectW(NewWindow *nwindow, char *text, int x, int y)
714 : BC_TextBox(x, y, 70, 1, text)
716 this->nwindow = nwindow;
719 int NewAspectW::handle_event()
721 nwindow->new_edl->session->aspect_w = atof(get_text());
725 NewAspectH::NewAspectH(NewWindow *nwindow, char *text, int x, int y)
726 : BC_TextBox(x, y, 70, 1, text)
728 this->nwindow = nwindow;
731 int NewAspectH::handle_event()
733 nwindow->new_edl->session->aspect_h = atof(get_text());
737 AspectPulldown::AspectPulldown(MWindow *mwindow,
738 BC_TextBox *output_w,
739 BC_TextBox *output_h,
747 &mwindow->theme->aspect_ratios,
754 this->mwindow = mwindow;
755 this->output_w = output_w;
756 this->output_h = output_h;
758 int AspectPulldown::handle_event()
760 char *text = get_selection(0, 0)->get_text();
761 char string[BCTEXTLEN];
765 strcpy(string, text);
766 ptr = strrchr(string, ':');
776 output_w->handle_event();
777 output_h->handle_event();
782 ColormodelItem::ColormodelItem(char *text, int value)
783 : BC_ListBoxItem(text)
788 ColormodelPulldown::ColormodelPulldown(MWindow *mwindow,
789 BC_TextBox *output_text,
798 (ArrayList<BC_ListBoxItem*>*)&mwindow->colormodels,
805 this->mwindow = mwindow;
806 this->output_text = output_text;
807 this->output_value = output_value;
808 output_text->update(colormodel_to_text());
811 int ColormodelPulldown::handle_event()
813 output_text->update(get_selection(0, 0)->get_text());
814 *output_value = ((ColormodelItem*)get_selection(0, 0))->value;
818 char* ColormodelPulldown::colormodel_to_text()
820 for(int i = 0; i < mwindow->colormodels.total; i++)
821 if(mwindow->colormodels.values[i]->value == *output_value)
822 return mwindow->colormodels.values[i]->get_text();
826 InterlacemodeItem::InterlacemodeItem(char *text, int value)
827 : BC_ListBoxItem(text)
832 InterlacemodePulldown::InterlacemodePulldown(MWindow *mwindow,
833 BC_TextBox *output_text,
835 ArrayList<BC_ListBoxItem*> *data,
850 char string[BCTEXTLEN];
851 this->mwindow = mwindow;
852 this->output_text = output_text;
853 this->output_value = output_value;
854 output_text->update(interlacemode_to_text());
857 int InterlacemodePulldown::handle_event()
859 output_text->update(get_selection(0, 0)->get_text());
860 *output_value = ((InterlacemodeItem*)get_selection(0, 0))->value;
864 char* InterlacemodePulldown::interlacemode_to_text()
866 ilacemode_to_text(this->string,*output_value);
867 return (this->string);
870 NewAspectAuto::NewAspectAuto(NewWindow *nwindow, int x, int y)
871 : BC_CheckBox(x, y, nwindow->new_thread->auto_aspect, _("Auto aspect ratio"))
873 this->nwindow = nwindow;
875 NewAspectAuto::~NewAspectAuto()
878 int NewAspectAuto::handle_event()
880 nwindow->new_thread->auto_aspect = get_value();
881 nwindow->new_thread->update_aspect();
892 NewSwapExtents::NewSwapExtents(MWindow *mwindow, NewWindow *gui, int x, int y)
893 : BC_Button(x, y, mwindow->theme->get_image_set("swap_extents"))
895 this->mwindow = mwindow;
897 set_tooltip("Swap dimensions");
900 int NewSwapExtents::handle_event()
902 int w = gui->new_edl->session->output_w;
903 int h = gui->new_edl->session->output_h;
904 gui->new_edl->session->output_w = h;
905 gui->new_edl->session->output_h = w;
906 gui->output_w_text->update((int64_t)h);
907 gui->output_h_text->update((int64_t)w);
908 gui->new_thread->update_aspect();