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();
92 memcpy(new_edl->session->achannel_positions,
93 &mwindow->preferences->channel_positions[
94 MAXCHANNELS * (new_edl->session->audio_channels - 1)],
95 sizeof(int) * MAXCHANNELS);
96 new_edl->session->boundaries();
97 new_edl->create_default_tracks();
99 mwindow->set_filename("");
100 mwindow->undo->update_undo(_("New"), LOAD_ALL);
102 mwindow->hide_plugins();
104 mwindow->edl = new_edl;
105 mwindow->save_defaults();
107 // Load file sequence
108 mwindow->update_project(LOAD_REPLACE);
109 mwindow->session->changes_made = 0;
110 mwindow->gui->unlock_window();
114 NewThread::NewThread(MWindow *mwindow, New *new_project)
117 this->mwindow = mwindow;
118 this->new_project = new_project;
119 window_lock = new Mutex("NewThread::window_lock");
122 NewThread::~NewThread()
128 void NewThread::run()
133 int x = mwindow->gui->get_root_w(0, 1) / 2 - WIDTH / 2;
134 int y = mwindow->gui->get_root_h(1) / 2 - HEIGHT / 2;
136 window_lock->lock("NewThread::run 1\n");
137 nwindow = new NewWindow(mwindow, this, x, y);
138 nwindow->create_objects();
139 window_lock->unlock();
141 result = nwindow->run_window();
143 window_lock->lock("NewThread::run 2\n");
146 window_lock->unlock();
148 new_project->new_edl->save_defaults(mwindow->defaults);
149 mwindow->defaults->save();
154 delete new_project->new_edl;
158 new_project->create_new_project();
162 int NewThread::load_defaults()
164 auto_aspect = mwindow->defaults->get("AUTOASPECT", 0);
168 int NewThread::save_defaults()
170 mwindow->defaults->update("AUTOASPECT", auto_aspect);
174 int NewThread::update_aspect()
178 char string[BCTEXTLEN];
179 mwindow->create_aspect_ratio(new_project->new_edl->session->aspect_w,
180 new_project->new_edl->session->aspect_h,
181 new_project->new_edl->session->output_w,
182 new_project->new_edl->session->output_h);
183 sprintf(string, "%.02f", new_project->new_edl->session->aspect_w);
184 nwindow->aspect_w_text->update(string);
185 sprintf(string, "%.02f", new_project->new_edl->session->aspect_h);
186 nwindow->aspect_h_text->update(string);
195 N_("Cinelerra: New Project");
198 NewWindow::NewWindow(MWindow *mwindow, NewThread *new_thread, int x, int y)
199 : BC_Window(_(PROGRAM_NAME ": New Project"),
210 this->mwindow = mwindow;
211 this->new_thread = new_thread;
212 this->new_edl = new_thread->new_project->new_edl;
216 NewWindow::~NewWindow()
218 if(format_presets) delete format_presets;
221 int NewWindow::create_objects()
223 int x = 10, y = 10, x1, y1;
226 mwindow->theme->draw_new_bg(this);
228 add_subwindow(new BC_Title(x, y, _("Parameters for the new project:")));
231 format_presets = new NewPresets(mwindow,
235 format_presets->create_objects();
236 x = format_presets->x;
237 y = format_presets->y;
243 add_subwindow(new BC_Title(x, y, _("Audio"), LARGEFONT));
247 add_subwindow(new BC_Title(x1, y, _("Tracks:")));
249 add_subwindow(atracks = new NewATracks(this, "", x1, y));
250 x1 += atracks->get_w();
251 add_subwindow(new NewATracksTumbler(this, x1, y));
252 y += atracks->get_h() + 5;
255 add_subwindow(new BC_Title(x1, y, _("Channels:")));
257 add_subwindow(achannels = new NewAChannels(this, "", x1, y));
258 x1 += achannels->get_w();
259 add_subwindow(new NewAChannelsTumbler(this, x1, y));
260 y += achannels->get_h() + 5;
263 add_subwindow(new BC_Title(x1, y, _("Samplerate:")));
265 add_subwindow(sample_rate = new NewSampleRate(this, "", x1, y));
266 x1 += sample_rate->get_w();
267 add_subwindow(new SampleRatePulldown(mwindow, sample_rate, x1, y));
271 add_subwindow(new BC_Title(x, y, _("Video"), LARGEFONT));
274 add_subwindow(new BC_Title(x1, y, _("Tracks:")));
276 add_subwindow(vtracks = new NewVTracks(this, "", x1, y));
277 x1 += vtracks->get_w();
278 add_subwindow(new NewVTracksTumbler(this, x1, y));
279 y += vtracks->get_h() + 5;
282 // add_subwindow(new BC_Title(x1, y, _("Channels:")));
284 // add_subwindow(vchannels = new NewVChannels(this, "", x1, y));
285 // x1 += vchannels->get_w();
286 // add_subwindow(new NewVChannelsTumbler(this, x1, y));
287 // y += vchannels->get_h() + 5;
289 add_subwindow(new BC_Title(x1, y, _("Framerate:")));
291 add_subwindow(frame_rate = new NewFrameRate(this, "", x1, y));
292 x1 += frame_rate->get_w();
293 add_subwindow(new FrameRatePulldown(mwindow, frame_rate, x1, y));
294 y += frame_rate->get_h() + 5;
297 // add_subwindow(new BC_Title(x1, y, _("Canvas size:")));
299 // add_subwindow(canvas_w_text = new NewTrackW(this, x1, y));
300 // x1 += canvas_w_text->get_w() + 2;
301 // add_subwindow(new BC_Title(x1, y, "x"));
303 // add_subwindow(canvas_h_text = new NewTrackH(this, x1, y));
304 // x1 += canvas_h_text->get_w();
305 // add_subwindow(new FrameSizePulldown(mwindow,
311 // add_subwindow(new NewCloneToggle(mwindow, this, x1, y));
312 // y += canvas_h_text->get_h() + 5;
315 add_subwindow(new BC_Title(x1, y, _("Canvas size:")));
317 add_subwindow(output_w_text = new NewOutputW(this, x1, y));
318 x1 += output_w_text->get_w() + 2;
319 add_subwindow(new BC_Title(x1, y, "x"));
321 add_subwindow(output_h_text = new NewOutputH(this, x1, y));
322 x1 += output_h_text->get_w();
323 FrameSizePulldown *pulldown;
324 add_subwindow(pulldown = new FrameSizePulldown(mwindow,
329 x1 += pulldown->get_w() + 5;
330 add_subwindow(new NewSwapExtents(mwindow, this, x1, y));
331 y += output_h_text->get_h() + 5;
334 add_subwindow(new BC_Title(x1, y, _("Aspect ratio:")));
336 add_subwindow(aspect_w_text = new NewAspectW(this, "", x1, y));
337 x1 += aspect_w_text->get_w() + 2;
338 add_subwindow(new BC_Title(x1, y, ":"));
340 add_subwindow(aspect_h_text = new NewAspectH(this, "", x1, y));
341 x1 += aspect_h_text->get_w();
342 add_subwindow(new AspectPulldown(mwindow,
348 x1 = aspect_w_text->get_x();
349 y += aspect_w_text->get_h() + 5;
350 add_subwindow(new NewAspectAuto(this, x1, y));
352 add_subwindow(new BC_Title(x, y, _("Color model:")));
353 add_subwindow(textbox = new BC_TextBox(x + 100, y, 200, 1, ""));
354 add_subwindow(new ColormodelPulldown(mwindow,
356 &new_edl->session->color_model,
357 x + 100 + textbox->get_w(),
359 y += textbox->get_h() + 5;
361 // --------------------
362 add_subwindow(new BC_Title(x, y, _("Interlace mode:")));
363 add_subwindow(textbox = new BC_TextBox(x + 100, y, 140, 1, ""));
364 add_subwindow(new InterlacemodePulldown(mwindow,
366 &new_edl->session->interlace_mode,
367 (ArrayList<BC_ListBoxItem*>*)&mwindow->interlace_project_modes,
368 x + 100 + textbox->get_w(),
370 y += textbox->get_h() + 5;
372 add_subwindow(new BC_OKButton(this,
373 mwindow->theme->get_image_set("new_ok_images")));
374 add_subwindow(new BC_CancelButton(this,
375 mwindow->theme->get_image_set("new_cancel_images")));
382 int NewWindow::update()
384 char string[BCTEXTLEN];
385 atracks->update((int64_t)new_edl->session->audio_tracks);
386 achannels->update((int64_t)new_edl->session->audio_channels);
387 sample_rate->update((int64_t)new_edl->session->sample_rate);
388 vtracks->update((int64_t)new_edl->session->video_tracks);
389 frame_rate->update((float)new_edl->session->frame_rate);
390 output_w_text->update((int64_t)new_edl->session->output_w);
391 output_h_text->update((int64_t)new_edl->session->output_h);
392 aspect_w_text->update((float)new_edl->session->aspect_w);
393 aspect_h_text->update((float)new_edl->session->aspect_h);
403 NewPresets::NewPresets(MWindow *mwindow, NewWindow *gui, int x, int y)
404 : FormatPresets(mwindow, gui, 0, x, y)
408 NewPresets::~NewPresets()
412 int NewPresets::handle_event()
418 EDL* NewPresets::get_edl()
420 return new_gui->new_edl;
425 NewATracks::NewATracks(NewWindow *nwindow, char *text, int x, int y)
426 : BC_TextBox(x, y, 90, 1, text)
428 this->nwindow = nwindow;
431 int NewATracks::handle_event()
433 nwindow->new_edl->session->audio_tracks = atol(get_text());
437 NewATracksTumbler::NewATracksTumbler(NewWindow *nwindow, int x, int y)
440 this->nwindow = nwindow;
442 int NewATracksTumbler::handle_up_event()
444 nwindow->new_edl->session->audio_tracks++;
445 nwindow->new_edl->boundaries();
449 int NewATracksTumbler::handle_down_event()
451 nwindow->new_edl->session->audio_tracks--;
452 nwindow->new_edl->boundaries();
457 NewAChannels::NewAChannels(NewWindow *nwindow, char *text, int x, int y)
458 : BC_TextBox(x, y, 90, 1, text)
460 this->nwindow = nwindow;
463 int NewAChannels::handle_event()
465 nwindow->new_edl->session->audio_channels = atol(get_text());
469 NewAChannelsTumbler::NewAChannelsTumbler(NewWindow *nwindow, int x, int y)
472 this->nwindow = nwindow;
474 int NewAChannelsTumbler::handle_up_event()
476 nwindow->new_edl->session->audio_channels++;
477 nwindow->new_edl->boundaries();
481 int NewAChannelsTumbler::handle_down_event()
483 nwindow->new_edl->session->audio_channels--;
484 nwindow->new_edl->boundaries();
490 NewSampleRate::NewSampleRate(NewWindow *nwindow, char *text, int x, int y)
491 : BC_TextBox(x, y, 90, 1, text)
493 this->nwindow = nwindow;
496 int NewSampleRate::handle_event()
498 nwindow->new_edl->session->sample_rate = atol(get_text());
502 SampleRatePulldown::SampleRatePulldown(MWindow *mwindow, BC_TextBox *output, int x, int y)
508 &mwindow->theme->sample_rates,
515 this->mwindow = mwindow;
516 this->output = output;
518 int SampleRatePulldown::handle_event()
520 char *text = get_selection(0, 0)->get_text();
521 output->update(text);
522 output->handle_event();
540 NewVTracks::NewVTracks(NewWindow *nwindow, char *text, int x, int y)
541 : BC_TextBox(x, y, 90, 1, text)
543 this->nwindow = nwindow;
546 int NewVTracks::handle_event()
548 nwindow->new_edl->session->video_tracks = atol(get_text());
552 NewVTracksTumbler::NewVTracksTumbler(NewWindow *nwindow, int x, int y)
555 this->nwindow = nwindow;
557 int NewVTracksTumbler::handle_up_event()
559 nwindow->new_edl->session->video_tracks++;
560 nwindow->new_edl->boundaries();
564 int NewVTracksTumbler::handle_down_event()
566 nwindow->new_edl->session->video_tracks--;
567 nwindow->new_edl->boundaries();
572 NewVChannels::NewVChannels(NewWindow *nwindow, char *text, int x, int y)
573 : BC_TextBox(x, y, 90, 1, text)
575 this->nwindow = nwindow;
578 int NewVChannels::handle_event()
580 nwindow->new_edl->session->video_channels = atol(get_text());
584 NewVChannelsTumbler::NewVChannelsTumbler(NewWindow *nwindow, int x, int y)
587 this->nwindow = nwindow;
589 int NewVChannelsTumbler::handle_up_event()
591 nwindow->new_edl->session->video_channels++;
592 nwindow->new_edl->boundaries();
596 int NewVChannelsTumbler::handle_down_event()
598 nwindow->new_edl->session->video_channels--;
599 nwindow->new_edl->boundaries();
604 NewFrameRate::NewFrameRate(NewWindow *nwindow, char *text, int x, int y)
605 : BC_TextBox(x, y, 90, 1, text)
607 this->nwindow = nwindow;
610 int NewFrameRate::handle_event()
612 nwindow->new_edl->session->frame_rate = Units::atoframerate(get_text());
616 FrameRatePulldown::FrameRatePulldown(MWindow *mwindow,
625 &mwindow->theme->frame_rates,
632 this->mwindow = mwindow;
633 this->output = output;
635 int FrameRatePulldown::handle_event()
637 char *text = get_selection(0, 0)->get_text();
638 output->update(text);
639 output->handle_event();
643 FrameSizePulldown::FrameSizePulldown(MWindow *mwindow,
644 BC_TextBox *output_w,
645 BC_TextBox *output_h,
653 &mwindow->theme->frame_sizes,
660 this->mwindow = mwindow;
661 this->output_w = output_w;
662 this->output_h = output_h;
664 int FrameSizePulldown::handle_event()
666 char *text = get_selection(0, 0)->get_text();
667 char string[BCTEXTLEN];
671 strcpy(string, text);
672 ptr = strrchr(string, 'x');
682 output_w->handle_event();
683 output_h->handle_event();
688 NewOutputW::NewOutputW(NewWindow *nwindow, int x, int y)
689 : BC_TextBox(x, y, 70, 1, nwindow->new_edl->session->output_w)
691 this->nwindow = nwindow;
693 int NewOutputW::handle_event()
695 nwindow->new_edl->session->output_w = MAX(1,atol(get_text()));
696 nwindow->new_thread->update_aspect();
700 NewOutputH::NewOutputH(NewWindow *nwindow, int x, int y)
701 : BC_TextBox(x, y, 70, 1, nwindow->new_edl->session->output_h)
703 this->nwindow = nwindow;
705 int NewOutputH::handle_event()
707 nwindow->new_edl->session->output_h = MAX(1, atol(get_text()));
708 nwindow->new_thread->update_aspect();
712 NewAspectW::NewAspectW(NewWindow *nwindow, char *text, int x, int y)
713 : BC_TextBox(x, y, 70, 1, text)
715 this->nwindow = nwindow;
718 int NewAspectW::handle_event()
720 nwindow->new_edl->session->aspect_w = atof(get_text());
724 NewAspectH::NewAspectH(NewWindow *nwindow, char *text, int x, int y)
725 : BC_TextBox(x, y, 70, 1, text)
727 this->nwindow = nwindow;
730 int NewAspectH::handle_event()
732 nwindow->new_edl->session->aspect_h = atof(get_text());
736 AspectPulldown::AspectPulldown(MWindow *mwindow,
737 BC_TextBox *output_w,
738 BC_TextBox *output_h,
746 &mwindow->theme->aspect_ratios,
753 this->mwindow = mwindow;
754 this->output_w = output_w;
755 this->output_h = output_h;
757 int AspectPulldown::handle_event()
759 char *text = get_selection(0, 0)->get_text();
760 char string[BCTEXTLEN];
764 strcpy(string, text);
765 ptr = strrchr(string, ':');
775 output_w->handle_event();
776 output_h->handle_event();
781 ColormodelItem::ColormodelItem(char *text, int value)
782 : BC_ListBoxItem(text)
787 ColormodelPulldown::ColormodelPulldown(MWindow *mwindow,
788 BC_TextBox *output_text,
797 (ArrayList<BC_ListBoxItem*>*)&mwindow->colormodels,
804 this->mwindow = mwindow;
805 this->output_text = output_text;
806 this->output_value = output_value;
807 output_text->update(colormodel_to_text());
810 int ColormodelPulldown::handle_event()
812 output_text->update(get_selection(0, 0)->get_text());
813 *output_value = ((ColormodelItem*)get_selection(0, 0))->value;
817 char* ColormodelPulldown::colormodel_to_text()
819 for(int i = 0; i < mwindow->colormodels.total; i++)
820 if(mwindow->colormodels.values[i]->value == *output_value)
821 return mwindow->colormodels.values[i]->get_text();
825 InterlacemodeItem::InterlacemodeItem(char *text, int value)
826 : BC_ListBoxItem(text)
831 InterlacemodePulldown::InterlacemodePulldown(MWindow *mwindow,
832 BC_TextBox *output_text,
834 ArrayList<BC_ListBoxItem*> *data,
849 char string[BCTEXTLEN];
850 this->mwindow = mwindow;
851 this->output_text = output_text;
852 this->output_value = output_value;
853 output_text->update(interlacemode_to_text());
856 int InterlacemodePulldown::handle_event()
858 output_text->update(get_selection(0, 0)->get_text());
859 *output_value = ((InterlacemodeItem*)get_selection(0, 0))->value;
863 char* InterlacemodePulldown::interlacemode_to_text()
865 ilacemode_to_text(this->string,*output_value);
866 return (this->string);
869 NewAspectAuto::NewAspectAuto(NewWindow *nwindow, int x, int y)
870 : BC_CheckBox(x, y, nwindow->new_thread->auto_aspect, _("Auto aspect ratio"))
872 this->nwindow = nwindow;
874 NewAspectAuto::~NewAspectAuto()
877 int NewAspectAuto::handle_event()
879 nwindow->new_thread->auto_aspect = get_value();
880 nwindow->new_thread->update_aspect();
891 NewSwapExtents::NewSwapExtents(MWindow *mwindow, NewWindow *gui, int x, int y)
892 : BC_Button(x, y, mwindow->theme->get_image_set("swap_extents"))
894 this->mwindow = mwindow;
896 set_tooltip("Swap dimensions");
899 int NewSwapExtents::handle_event()
901 int w = gui->new_edl->session->output_w;
902 int h = gui->new_edl->session->output_h;
903 gui->new_edl->session->output_w = h;
904 gui->new_edl->session->output_h = w;
905 gui->output_w_text->update((int64_t)h);
906 gui->output_h_text->update((int64_t)w);
907 gui->new_thread->update_aspect();