6 #include "edlsession.h"
8 #include "interlacemodes.h"
10 #include "levelwindow.h"
14 #include "mwindowgui.h"
16 #include "newpresets.h"
17 #include "mainsession.h"
20 #include "transportque.h"
21 #include "videowindow.h"
22 #include "vplayback.h"
32 New::New(MWindow *mwindow)
33 : BC_MenuItem(_("New..."), "n", 'n')
35 this->mwindow = mwindow;
39 int New::create_objects()
41 thread = new NewThread(mwindow, this);
45 int New::handle_event()
49 thread->window_lock->lock("New::handle_event");
52 thread->nwindow->lock_window("New::handle_event");
53 thread->nwindow->raise_window();
54 thread->nwindow->unlock_window();
56 thread->window_lock->unlock();
59 mwindow->edl->save_defaults(mwindow->defaults);
66 void New::create_new_edl()
69 new_edl->create_objects();
70 new_edl->load_defaults(mwindow->defaults);
74 int New::create_new_project()
76 mwindow->cwindow->playback_engine->que->send_command(STOP,
80 mwindow->vwindow->playback_engine->que->send_command(STOP,
84 mwindow->cwindow->playback_engine->interrupt_playback(0);
85 mwindow->vwindow->playback_engine->interrupt_playback(0);
87 mwindow->gui->lock_window();
89 new_edl->session->boundaries();
90 new_edl->create_default_tracks();
92 mwindow->set_filename("");
93 mwindow->undo->update_undo(_("New"), LOAD_ALL);
95 mwindow->hide_plugins();
97 mwindow->edl = new_edl;
98 mwindow->save_defaults();
100 // Load file sequence
101 mwindow->update_project(LOAD_REPLACE);
102 mwindow->session->changes_made = 0;
103 mwindow->gui->unlock_window();
107 NewThread::NewThread(MWindow *mwindow, New *new_project)
110 this->mwindow = mwindow;
111 this->new_project = new_project;
112 window_lock = new Mutex("NewThread::window_lock");
115 NewThread::~NewThread()
121 void NewThread::run()
126 int x = mwindow->gui->get_root_w(0, 1) / 2 - WIDTH / 2;
127 int y = mwindow->gui->get_root_h(1) / 2 - HEIGHT / 2;
129 window_lock->lock("NewThread::run 1\n");
130 nwindow = new NewWindow(mwindow, this, x, y);
131 nwindow->create_objects();
132 window_lock->unlock();
134 result = nwindow->run_window();
136 window_lock->lock("NewThread::run 2\n");
139 window_lock->unlock();
141 new_project->new_edl->save_defaults(mwindow->defaults);
142 mwindow->defaults->save();
147 delete new_project->new_edl;
151 //printf("NewThread::run 4\n");
152 new_project->create_new_project();
153 //printf("NewThread::run 5\n");
157 int NewThread::load_defaults()
159 auto_aspect = mwindow->defaults->get("AUTOASPECT", 0);
163 int NewThread::save_defaults()
165 mwindow->defaults->update("AUTOASPECT", auto_aspect);
169 int NewThread::update_aspect()
173 char string[BCTEXTLEN];
174 mwindow->create_aspect_ratio(new_project->new_edl->session->aspect_w,
175 new_project->new_edl->session->aspect_h,
176 new_project->new_edl->session->output_w,
177 new_project->new_edl->session->output_h);
178 sprintf(string, "%.02f", new_project->new_edl->session->aspect_w);
179 nwindow->aspect_w_text->update(string);
180 sprintf(string, "%.02f", new_project->new_edl->session->aspect_h);
181 nwindow->aspect_h_text->update(string);
190 N_("Cinelerra: New Project");
193 NewWindow::NewWindow(MWindow *mwindow, NewThread *new_thread, int x, int y)
194 : BC_Window(_(PROGRAM_NAME ": New Project"),
205 this->mwindow = mwindow;
206 this->new_thread = new_thread;
207 this->new_edl = new_thread->new_project->new_edl;
211 NewWindow::~NewWindow()
213 if(format_presets) delete format_presets;
216 int NewWindow::create_objects()
218 int x = 10, y = 10, x1, y1;
221 mwindow->theme->draw_new_bg(this);
223 add_subwindow(new BC_Title(x, y, _("Parameters for the new project:")));
226 format_presets = new NewPresets(mwindow,
230 format_presets->create_objects();
231 x = format_presets->x;
232 y = format_presets->y;
238 add_subwindow(new BC_Title(x, y, _("Audio"), LARGEFONT));
242 add_subwindow(new BC_Title(x1, y, _("Tracks:")));
244 add_subwindow(atracks = new NewATracks(this, "", x1, y));
245 x1 += atracks->get_w();
246 add_subwindow(new NewATracksTumbler(this, x1, y));
247 y += atracks->get_h() + 5;
250 add_subwindow(new BC_Title(x1, y, _("Channels:")));
252 add_subwindow(achannels = new NewAChannels(this, "", x1, y));
253 x1 += achannels->get_w();
254 add_subwindow(new NewAChannelsTumbler(this, x1, y));
255 y += achannels->get_h() + 5;
258 add_subwindow(new BC_Title(x1, y, _("Samplerate:")));
260 add_subwindow(sample_rate = new NewSampleRate(this, "", x1, y));
261 x1 += sample_rate->get_w();
262 add_subwindow(new SampleRatePulldown(mwindow, sample_rate, x1, y));
266 add_subwindow(new BC_Title(x, y, _("Video"), LARGEFONT));
269 add_subwindow(new BC_Title(x1, y, _("Tracks:")));
271 add_subwindow(vtracks = new NewVTracks(this, "", x1, y));
272 x1 += vtracks->get_w();
273 add_subwindow(new NewVTracksTumbler(this, x1, y));
274 y += vtracks->get_h() + 5;
277 // add_subwindow(new BC_Title(x1, y, _("Channels:")));
279 // add_subwindow(vchannels = new NewVChannels(this, "", x1, y));
280 // x1 += vchannels->get_w();
281 // add_subwindow(new NewVChannelsTumbler(this, x1, y));
282 // y += vchannels->get_h() + 5;
284 add_subwindow(new BC_Title(x1, y, _("Framerate:")));
286 add_subwindow(frame_rate = new NewFrameRate(this, "", x1, y));
287 x1 += frame_rate->get_w();
288 add_subwindow(new FrameRatePulldown(mwindow, frame_rate, x1, y));
289 y += frame_rate->get_h() + 5;
292 // add_subwindow(new BC_Title(x1, y, _("Canvas size:")));
294 // add_subwindow(canvas_w_text = new NewTrackW(this, x1, y));
295 // x1 += canvas_w_text->get_w() + 2;
296 // add_subwindow(new BC_Title(x1, y, "x"));
298 // add_subwindow(canvas_h_text = new NewTrackH(this, x1, y));
299 // x1 += canvas_h_text->get_w();
300 // add_subwindow(new FrameSizePulldown(mwindow,
306 // add_subwindow(new NewCloneToggle(mwindow, this, x1, y));
307 // y += canvas_h_text->get_h() + 5;
310 add_subwindow(new BC_Title(x1, y, _("Canvas size:")));
312 add_subwindow(output_w_text = new NewOutputW(this, x1, y));
313 x1 += output_w_text->get_w() + 2;
314 add_subwindow(new BC_Title(x1, y, "x"));
316 add_subwindow(output_h_text = new NewOutputH(this, x1, y));
317 x1 += output_h_text->get_w();
318 add_subwindow(new FrameSizePulldown(mwindow,
323 y += output_h_text->get_h() + 5;
326 add_subwindow(new BC_Title(x1, y, _("Aspect ratio:")));
328 add_subwindow(aspect_w_text = new NewAspectW(this, "", x1, y));
329 x1 += aspect_w_text->get_w() + 2;
330 add_subwindow(new BC_Title(x1, y, ":"));
332 add_subwindow(aspect_h_text = new NewAspectH(this, "", x1, y));
333 x1 += aspect_h_text->get_w();
334 add_subwindow(new AspectPulldown(mwindow,
340 x1 = aspect_w_text->get_x();
341 y += aspect_w_text->get_h() + 5;
342 add_subwindow(new NewAspectAuto(this, x1, y));
344 add_subwindow(new BC_Title(x, y, _("Color model:")));
345 add_subwindow(textbox = new BC_TextBox(x + 100, y, 200, 1, ""));
346 add_subwindow(new ColormodelPulldown(mwindow,
348 &new_edl->session->color_model,
349 x + 100 + textbox->get_w(),
351 y += textbox->get_h() + 5;
353 // --------------------
354 add_subwindow(new BC_Title(x, y, _("Interlace mode:")));
355 add_subwindow(textbox = new BC_TextBox(x + 100, y, 140, 1, ""));
356 add_subwindow(new InterlacemodePulldown(mwindow,
358 &new_edl->session->interlace_mode,
359 (ArrayList<BC_ListBoxItem*>*)&mwindow->interlace_project_modes,
360 x + 100 + textbox->get_w(),
362 y += textbox->get_h() + 5;
364 add_subwindow(new BC_OKButton(this,
365 mwindow->theme->get_image_set("new_ok_images")));
366 add_subwindow(new BC_CancelButton(this,
367 mwindow->theme->get_image_set("new_cancel_images")));
374 int NewWindow::update()
376 char string[BCTEXTLEN];
377 atracks->update((int64_t)new_edl->session->audio_tracks);
378 achannels->update((int64_t)new_edl->session->audio_channels);
379 sample_rate->update((int64_t)new_edl->session->sample_rate);
380 vtracks->update((int64_t)new_edl->session->video_tracks);
381 frame_rate->update((float)new_edl->session->frame_rate);
382 output_w_text->update((int64_t)new_edl->session->output_w);
383 output_h_text->update((int64_t)new_edl->session->output_h);
384 aspect_w_text->update((float)new_edl->session->aspect_w);
385 aspect_h_text->update((float)new_edl->session->aspect_h);
395 NewPresets::NewPresets(MWindow *mwindow, NewWindow *gui, int x, int y)
396 : FormatPresets(mwindow, gui, 0, x, y)
400 NewPresets::~NewPresets()
404 int NewPresets::handle_event()
410 EDL* NewPresets::get_edl()
412 return new_gui->new_edl;
417 NewATracks::NewATracks(NewWindow *nwindow, char *text, int x, int y)
418 : BC_TextBox(x, y, 90, 1, text)
420 this->nwindow = nwindow;
423 int NewATracks::handle_event()
425 nwindow->new_edl->session->audio_tracks = atol(get_text());
429 NewATracksTumbler::NewATracksTumbler(NewWindow *nwindow, int x, int y)
432 this->nwindow = nwindow;
434 int NewATracksTumbler::handle_up_event()
436 nwindow->new_edl->session->audio_tracks++;
437 nwindow->new_edl->boundaries();
441 int NewATracksTumbler::handle_down_event()
443 nwindow->new_edl->session->audio_tracks--;
444 nwindow->new_edl->boundaries();
449 NewAChannels::NewAChannels(NewWindow *nwindow, char *text, int x, int y)
450 : BC_TextBox(x, y, 90, 1, text)
452 this->nwindow = nwindow;
455 int NewAChannels::handle_event()
457 nwindow->new_edl->session->audio_channels = atol(get_text());
461 NewAChannelsTumbler::NewAChannelsTumbler(NewWindow *nwindow, int x, int y)
464 this->nwindow = nwindow;
466 int NewAChannelsTumbler::handle_up_event()
468 nwindow->new_edl->session->audio_channels++;
469 nwindow->new_edl->boundaries();
473 int NewAChannelsTumbler::handle_down_event()
475 nwindow->new_edl->session->audio_channels--;
476 nwindow->new_edl->boundaries();
482 NewSampleRate::NewSampleRate(NewWindow *nwindow, char *text, int x, int y)
483 : BC_TextBox(x, y, 90, 1, text)
485 this->nwindow = nwindow;
488 int NewSampleRate::handle_event()
490 nwindow->new_edl->session->sample_rate = atol(get_text());
494 SampleRatePulldown::SampleRatePulldown(MWindow *mwindow, BC_TextBox *output, int x, int y)
500 &mwindow->theme->sample_rates,
507 this->mwindow = mwindow;
508 this->output = output;
510 int SampleRatePulldown::handle_event()
512 char *text = get_selection(0, 0)->get_text();
513 output->update(text);
514 output->handle_event();
532 NewVTracks::NewVTracks(NewWindow *nwindow, char *text, int x, int y)
533 : BC_TextBox(x, y, 90, 1, text)
535 this->nwindow = nwindow;
538 int NewVTracks::handle_event()
540 nwindow->new_edl->session->video_tracks = atol(get_text());
544 NewVTracksTumbler::NewVTracksTumbler(NewWindow *nwindow, int x, int y)
547 this->nwindow = nwindow;
549 int NewVTracksTumbler::handle_up_event()
551 nwindow->new_edl->session->video_tracks++;
552 nwindow->new_edl->boundaries();
556 int NewVTracksTumbler::handle_down_event()
558 nwindow->new_edl->session->video_tracks--;
559 nwindow->new_edl->boundaries();
564 NewVChannels::NewVChannels(NewWindow *nwindow, char *text, int x, int y)
565 : BC_TextBox(x, y, 90, 1, text)
567 this->nwindow = nwindow;
570 int NewVChannels::handle_event()
572 nwindow->new_edl->session->video_channels = atol(get_text());
576 NewVChannelsTumbler::NewVChannelsTumbler(NewWindow *nwindow, int x, int y)
579 this->nwindow = nwindow;
581 int NewVChannelsTumbler::handle_up_event()
583 nwindow->new_edl->session->video_channels++;
584 nwindow->new_edl->boundaries();
588 int NewVChannelsTumbler::handle_down_event()
590 nwindow->new_edl->session->video_channels--;
591 nwindow->new_edl->boundaries();
596 NewFrameRate::NewFrameRate(NewWindow *nwindow, char *text, int x, int y)
597 : BC_TextBox(x, y, 90, 1, text)
599 this->nwindow = nwindow;
602 int NewFrameRate::handle_event()
604 nwindow->new_edl->session->frame_rate = Units::atoframerate(get_text());
608 FrameRatePulldown::FrameRatePulldown(MWindow *mwindow,
617 &mwindow->theme->frame_rates,
624 this->mwindow = mwindow;
625 this->output = output;
627 int FrameRatePulldown::handle_event()
629 char *text = get_selection(0, 0)->get_text();
630 output->update(text);
631 output->handle_event();
635 FrameSizePulldown::FrameSizePulldown(MWindow *mwindow,
636 BC_TextBox *output_w,
637 BC_TextBox *output_h,
645 &mwindow->theme->frame_sizes,
652 this->mwindow = mwindow;
653 this->output_w = output_w;
654 this->output_h = output_h;
656 int FrameSizePulldown::handle_event()
658 char *text = get_selection(0, 0)->get_text();
659 char string[BCTEXTLEN];
663 strcpy(string, text);
664 ptr = strrchr(string, 'x');
674 output_w->handle_event();
675 output_h->handle_event();
680 NewOutputW::NewOutputW(NewWindow *nwindow, int x, int y)
681 : BC_TextBox(x, y, 70, 1, nwindow->new_edl->session->output_w)
683 this->nwindow = nwindow;
685 int NewOutputW::handle_event()
687 nwindow->new_edl->session->output_w = MAX(1,atol(get_text()));
688 nwindow->new_thread->update_aspect();
692 NewOutputH::NewOutputH(NewWindow *nwindow, int x, int y)
693 : BC_TextBox(x, y, 70, 1, nwindow->new_edl->session->output_h)
695 this->nwindow = nwindow;
697 int NewOutputH::handle_event()
699 nwindow->new_edl->session->output_h = MAX(1, atol(get_text()));
700 nwindow->new_thread->update_aspect();
704 NewAspectW::NewAspectW(NewWindow *nwindow, char *text, int x, int y)
705 : BC_TextBox(x, y, 70, 1, text)
707 this->nwindow = nwindow;
710 int NewAspectW::handle_event()
712 nwindow->new_edl->session->aspect_w = atof(get_text());
716 NewAspectH::NewAspectH(NewWindow *nwindow, char *text, int x, int y)
717 : BC_TextBox(x, y, 70, 1, text)
719 this->nwindow = nwindow;
722 int NewAspectH::handle_event()
724 nwindow->new_edl->session->aspect_h = atof(get_text());
728 AspectPulldown::AspectPulldown(MWindow *mwindow,
729 BC_TextBox *output_w,
730 BC_TextBox *output_h,
738 &mwindow->theme->aspect_ratios,
745 this->mwindow = mwindow;
746 this->output_w = output_w;
747 this->output_h = output_h;
749 int AspectPulldown::handle_event()
751 char *text = get_selection(0, 0)->get_text();
752 char string[BCTEXTLEN];
756 strcpy(string, text);
757 ptr = strrchr(string, ':');
767 output_w->handle_event();
768 output_h->handle_event();
773 ColormodelItem::ColormodelItem(char *text, int value)
774 : BC_ListBoxItem(text)
779 ColormodelPulldown::ColormodelPulldown(MWindow *mwindow,
780 BC_TextBox *output_text,
789 (ArrayList<BC_ListBoxItem*>*)&mwindow->colormodels,
796 this->mwindow = mwindow;
797 this->output_text = output_text;
798 this->output_value = output_value;
799 output_text->update(colormodel_to_text());
802 int ColormodelPulldown::handle_event()
804 output_text->update(get_selection(0, 0)->get_text());
805 *output_value = ((ColormodelItem*)get_selection(0, 0))->value;
809 char* ColormodelPulldown::colormodel_to_text()
811 for(int i = 0; i < mwindow->colormodels.total; i++)
812 if(mwindow->colormodels.values[i]->value == *output_value)
813 return mwindow->colormodels.values[i]->get_text();
817 InterlacemodeItem::InterlacemodeItem(char *text, int value)
818 : BC_ListBoxItem(text)
823 InterlacemodePulldown::InterlacemodePulldown(MWindow *mwindow,
824 BC_TextBox *output_text,
826 ArrayList<BC_ListBoxItem*> *data,
841 char string[BCTEXTLEN];
842 this->mwindow = mwindow;
843 this->output_text = output_text;
844 this->output_value = output_value;
845 output_text->update(interlacemode_to_text());
848 int InterlacemodePulldown::handle_event()
850 output_text->update(get_selection(0, 0)->get_text());
851 *output_value = ((InterlacemodeItem*)get_selection(0, 0))->value;
855 char* InterlacemodePulldown::interlacemode_to_text()
857 ilacemode_to_text(this->string,*output_value);
858 return (this->string);
861 NewAspectAuto::NewAspectAuto(NewWindow *nwindow, int x, int y)
862 : BC_CheckBox(x, y, nwindow->new_thread->auto_aspect, _("Auto aspect ratio"))
864 this->nwindow = nwindow;
866 NewAspectAuto::~NewAspectAuto()
869 int NewAspectAuto::handle_event()
871 nwindow->new_thread->auto_aspect = get_value();
872 nwindow->new_thread->update_aspect();
879 NewCloneToggle::NewCloneToggle(MWindow *mwindow, NewWindow *nwindow, int x, int y)
882 mwindow->theme->chain_data,
883 nwindow->new_thread->auto_sizes,
889 this->mwindow = mwindow;
890 this->nwindow = nwindow;
893 int NewCloneToggle::handle_event()
895 nwindow->canvas_w_text->update((int64_t)nwindow->new_edl->session->track_w);
896 nwindow->canvas_h_text->update((int64_t)nwindow->new_edl->session->track_h);
897 nwindow->new_edl->session->output_w = nwindow->new_edl->session->track_w;
898 nwindow->new_edl->session->output_h = nwindow->new_edl->session->track_h;
899 nwindow->new_thread->update_aspect();