6 #include "edlsession.h"
9 #include "levelwindow.h"
13 #include "mwindowgui.h"
15 #include "newpresets.h"
16 #include "mainsession.h"
19 #include "transportque.h"
20 #include "videowindow.h"
21 #include "vplayback.h"
31 New::New(MWindow *mwindow)
32 : BC_MenuItem(_("New..."), "n", 'n')
34 this->mwindow = mwindow;
38 int New::create_objects()
40 thread = new NewThread(mwindow, this);
44 int New::handle_event()
48 thread->window_lock->lock("New::handle_event");
51 thread->nwindow->lock_window("New::handle_event");
52 thread->nwindow->raise_window();
53 thread->nwindow->unlock_window();
55 thread->window_lock->unlock();
58 mwindow->edl->save_defaults(mwindow->defaults);
65 void New::create_new_edl()
68 new_edl->create_objects();
69 new_edl->load_defaults(mwindow->defaults);
73 int New::create_new_project()
75 mwindow->cwindow->playback_engine->que->send_command(STOP,
79 mwindow->vwindow->playback_engine->que->send_command(STOP,
83 mwindow->cwindow->playback_engine->interrupt_playback(0);
84 mwindow->vwindow->playback_engine->interrupt_playback(0);
86 mwindow->gui->lock_window();
87 mwindow->undo->update_undo_before(_("New"), LOAD_ALL);
89 new_edl->session->boundaries();
90 new_edl->create_default_tracks();
92 mwindow->set_filename("");
93 mwindow->undo->update_undo_after();
95 mwindow->hide_plugins();
97 // Delete patches which are pointing to tracks which have been just deleted.
98 mwindow->patches->delete_all_patches();
99 mwindow->edl = new_edl;
100 mwindow->save_defaults();
102 // Load file sequence
103 mwindow->update_project(LOAD_REPLACE);
104 mwindow->session->changes_made = 0;
105 mwindow->gui->unlock_window();
109 NewThread::NewThread(MWindow *mwindow, New *new_project)
112 this->mwindow = mwindow;
113 this->new_project = new_project;
114 window_lock = new Mutex("NewThread::window_lock");
117 NewThread::~NewThread()
123 void NewThread::run()
128 int x = mwindow->gui->get_root_w(0, 1) / 2 - WIDTH / 2;
129 int y = mwindow->gui->get_root_h(1) / 2 - HEIGHT / 2;
131 window_lock->lock("NewThread::run 1\n");
132 nwindow = new NewWindow(mwindow, this, x, y);
133 nwindow->create_objects();
134 window_lock->unlock();
136 result = nwindow->run_window();
138 window_lock->lock("NewThread::run 2\n");
141 window_lock->unlock();
143 new_project->new_edl->save_defaults(mwindow->defaults);
144 mwindow->defaults->save();
149 delete new_project->new_edl;
153 //printf("NewThread::run 4\n");
154 new_project->create_new_project();
155 //printf("NewThread::run 5\n");
159 int NewThread::load_defaults()
161 auto_aspect = mwindow->defaults->get("AUTOASPECT", 0);
165 int NewThread::save_defaults()
167 mwindow->defaults->update("AUTOASPECT", auto_aspect);
171 int NewThread::update_aspect()
176 mwindow->create_aspect_ratio(new_project->new_edl->session->aspect_w,
177 new_project->new_edl->session->aspect_h,
178 new_project->new_edl->session->output_w,
179 new_project->new_edl->session->output_h);
180 sprintf(string, "%.02f", new_project->new_edl->session->aspect_w);
181 nwindow->aspect_w_text->update(string);
182 sprintf(string, "%.02f", new_project->new_edl->session->aspect_h);
183 nwindow->aspect_h_text->update(string);
192 N_("Cinelerra: New Project");
195 NewWindow::NewWindow(MWindow *mwindow, NewThread *new_thread, int x, int y)
196 : BC_Window(_(PROGRAM_NAME ": New Project"),
207 this->mwindow = mwindow;
208 this->new_thread = new_thread;
209 this->new_edl = new_thread->new_project->new_edl;
213 NewWindow::~NewWindow()
215 if(format_presets) delete format_presets;
218 int NewWindow::create_objects()
220 int x = 10, y = 10, x1, y1;
223 mwindow->theme->draw_new_bg(this);
225 add_subwindow(new BC_Title(x, y, _("Parameters for the new project:")));
228 format_presets = new NewPresets(mwindow,
232 format_presets->create_objects();
233 x = format_presets->x;
234 y = format_presets->y;
240 add_subwindow(new BC_Title(x, y, _("Audio"), LARGEFONT));
244 add_subwindow(new BC_Title(x1, y, _("Tracks:")));
246 add_subwindow(atracks = new NewATracks(this, "", x1, y));
247 x1 += atracks->get_w();
248 add_subwindow(new NewATracksTumbler(this, x1, y));
249 y += atracks->get_h() + 5;
252 add_subwindow(new BC_Title(x1, y, _("Channels:")));
254 add_subwindow(achannels = new NewAChannels(this, "", x1, y));
255 x1 += achannels->get_w();
256 add_subwindow(new NewAChannelsTumbler(this, x1, y));
257 y += achannels->get_h() + 5;
260 add_subwindow(new BC_Title(x1, y, _("Samplerate:")));
262 add_subwindow(sample_rate = new NewSampleRate(this, "", x1, y));
263 x1 += sample_rate->get_w();
264 add_subwindow(new SampleRatePulldown(mwindow, sample_rate, x1, y));
268 add_subwindow(new BC_Title(x, y, _("Video"), LARGEFONT));
271 add_subwindow(new BC_Title(x1, y, _("Tracks:")));
273 add_subwindow(vtracks = new NewVTracks(this, "", x1, y));
274 x1 += vtracks->get_w();
275 add_subwindow(new NewVTracksTumbler(this, x1, y));
276 y += vtracks->get_h() + 5;
279 // add_subwindow(new BC_Title(x1, y, _("Channels:")));
281 // add_subwindow(vchannels = new NewVChannels(this, "", x1, y));
282 // x1 += vchannels->get_w();
283 // add_subwindow(new NewVChannelsTumbler(this, x1, y));
284 // y += vchannels->get_h() + 5;
286 add_subwindow(new BC_Title(x1, y, _("Framerate:")));
288 add_subwindow(frame_rate = new NewFrameRate(this, "", x1, y));
289 x1 += frame_rate->get_w();
290 add_subwindow(new FrameRatePulldown(mwindow, frame_rate, x1, y));
291 y += frame_rate->get_h() + 5;
294 // add_subwindow(new BC_Title(x1, y, _("Canvas size:")));
296 // add_subwindow(canvas_w_text = new NewTrackW(this, x1, y));
297 // x1 += canvas_w_text->get_w() + 2;
298 // add_subwindow(new BC_Title(x1, y, "x"));
300 // add_subwindow(canvas_h_text = new NewTrackH(this, x1, y));
301 // x1 += canvas_h_text->get_w();
302 // add_subwindow(new FrameSizePulldown(mwindow,
308 // add_subwindow(new NewCloneToggle(mwindow, this, x1, y));
309 // y += canvas_h_text->get_h() + 5;
312 add_subwindow(new BC_Title(x1, y, _("Canvas size:")));
314 add_subwindow(output_w_text = new NewOutputW(this, x1, y));
315 x1 += output_w_text->get_w() + 2;
316 add_subwindow(new BC_Title(x1, y, "x"));
318 add_subwindow(output_h_text = new NewOutputH(this, x1, y));
319 x1 += output_h_text->get_w();
320 add_subwindow(new FrameSizePulldown(mwindow,
325 y += output_h_text->get_h() + 5;
328 add_subwindow(new BC_Title(x1, y, _("Aspect ratio:")));
330 add_subwindow(aspect_w_text = new NewAspectW(this, "", x1, y));
331 x1 += aspect_w_text->get_w() + 2;
332 add_subwindow(new BC_Title(x1, y, ":"));
334 add_subwindow(aspect_h_text = new NewAspectH(this, "", x1, y));
335 x1 += aspect_h_text->get_w();
336 add_subwindow(new AspectPulldown(mwindow,
342 x1 = aspect_w_text->get_x();
343 y += aspect_w_text->get_h() + 5;
344 add_subwindow(new NewAspectAuto(this, x1, y));
346 add_subwindow(new BC_Title(x, y, _("Color model:")));
348 add_subwindow(textbox = new BC_TextBox(x, y, 200, 1, ""));
349 x += textbox->get_w();
350 add_subwindow(new ColormodelPulldown(mwindow,
352 &new_edl->session->color_model,
356 add_subwindow(new BC_OKButton(this));
357 add_subwindow(new BC_CancelButton(this));
364 int NewWindow::update()
366 char string[BCTEXTLEN];
367 atracks->update((int64_t)new_edl->session->audio_tracks);
368 achannels->update((int64_t)new_edl->session->audio_channels);
369 sample_rate->update((int64_t)new_edl->session->sample_rate);
370 vtracks->update((int64_t)new_edl->session->video_tracks);
371 frame_rate->update((float)new_edl->session->frame_rate);
372 output_w_text->update((int64_t)new_edl->session->output_w);
373 output_h_text->update((int64_t)new_edl->session->output_h);
374 aspect_w_text->update((float)new_edl->session->aspect_w);
375 aspect_h_text->update((float)new_edl->session->aspect_h);
385 NewPresets::NewPresets(MWindow *mwindow, NewWindow *gui, int x, int y)
386 : FormatPresets(mwindow, gui, 0, x, y)
390 NewPresets::~NewPresets()
394 int NewPresets::handle_event()
400 EDL* NewPresets::get_edl()
402 return new_gui->new_edl;
407 NewATracks::NewATracks(NewWindow *nwindow, char *text, int x, int y)
408 : BC_TextBox(x, y, 90, 1, text)
410 this->nwindow = nwindow;
413 int NewATracks::handle_event()
415 nwindow->new_edl->session->audio_tracks = atol(get_text());
419 NewATracksTumbler::NewATracksTumbler(NewWindow *nwindow, int x, int y)
422 this->nwindow = nwindow;
424 int NewATracksTumbler::handle_up_event()
426 nwindow->new_edl->session->audio_tracks++;
427 nwindow->new_edl->boundaries();
431 int NewATracksTumbler::handle_down_event()
433 nwindow->new_edl->session->audio_tracks--;
434 nwindow->new_edl->boundaries();
439 NewAChannels::NewAChannels(NewWindow *nwindow, char *text, int x, int y)
440 : BC_TextBox(x, y, 90, 1, text)
442 this->nwindow = nwindow;
445 int NewAChannels::handle_event()
447 nwindow->new_edl->session->audio_channels = atol(get_text());
451 NewAChannelsTumbler::NewAChannelsTumbler(NewWindow *nwindow, int x, int y)
454 this->nwindow = nwindow;
456 int NewAChannelsTumbler::handle_up_event()
458 nwindow->new_edl->session->audio_channels++;
459 nwindow->new_edl->boundaries();
463 int NewAChannelsTumbler::handle_down_event()
465 nwindow->new_edl->session->audio_channels--;
466 nwindow->new_edl->boundaries();
472 NewSampleRate::NewSampleRate(NewWindow *nwindow, char *text, int x, int y)
473 : BC_TextBox(x, y, 90, 1, text)
475 this->nwindow = nwindow;
478 int NewSampleRate::handle_event()
480 nwindow->new_edl->session->sample_rate = atol(get_text());
484 SampleRatePulldown::SampleRatePulldown(MWindow *mwindow, BC_TextBox *output, int x, int y)
490 &mwindow->theme->sample_rates,
497 this->mwindow = mwindow;
498 this->output = output;
500 int SampleRatePulldown::handle_event()
502 char *text = get_selection(0, 0)->get_text();
503 output->update(text);
504 output->handle_event();
522 NewVTracks::NewVTracks(NewWindow *nwindow, char *text, int x, int y)
523 : BC_TextBox(x, y, 90, 1, text)
525 this->nwindow = nwindow;
528 int NewVTracks::handle_event()
530 nwindow->new_edl->session->video_tracks = atol(get_text());
534 NewVTracksTumbler::NewVTracksTumbler(NewWindow *nwindow, int x, int y)
537 this->nwindow = nwindow;
539 int NewVTracksTumbler::handle_up_event()
541 nwindow->new_edl->session->video_tracks++;
542 nwindow->new_edl->boundaries();
546 int NewVTracksTumbler::handle_down_event()
548 nwindow->new_edl->session->video_tracks--;
549 nwindow->new_edl->boundaries();
554 NewVChannels::NewVChannels(NewWindow *nwindow, char *text, int x, int y)
555 : BC_TextBox(x, y, 90, 1, text)
557 this->nwindow = nwindow;
560 int NewVChannels::handle_event()
562 nwindow->new_edl->session->video_channels = atol(get_text());
566 NewVChannelsTumbler::NewVChannelsTumbler(NewWindow *nwindow, int x, int y)
569 this->nwindow = nwindow;
571 int NewVChannelsTumbler::handle_up_event()
573 nwindow->new_edl->session->video_channels++;
574 nwindow->new_edl->boundaries();
578 int NewVChannelsTumbler::handle_down_event()
580 nwindow->new_edl->session->video_channels--;
581 nwindow->new_edl->boundaries();
586 NewFrameRate::NewFrameRate(NewWindow *nwindow, char *text, int x, int y)
587 : BC_TextBox(x, y, 90, 1, text)
589 this->nwindow = nwindow;
592 int NewFrameRate::handle_event()
594 nwindow->new_edl->session->frame_rate = Units::atoframerate(get_text());
598 FrameRatePulldown::FrameRatePulldown(MWindow *mwindow,
607 &mwindow->theme->frame_rates,
614 this->mwindow = mwindow;
615 this->output = output;
617 int FrameRatePulldown::handle_event()
619 char *text = get_selection(0, 0)->get_text();
620 output->update(text);
621 output->handle_event();
625 // NewTrackW::NewTrackW(NewWindow *nwindow, int x, int y)
626 // : BC_TextBox(x, y, 70, 1, nwindow->new_edl->session->track_w)
628 // this->nwindow = nwindow;
630 // int NewTrackW::handle_event()
632 // nwindow->new_edl->session->track_w = atol(get_text());
636 // NewTrackH::NewTrackH(NewWindow *nwindow, int x, int y)
637 // : BC_TextBox(x, y, 70, 1, nwindow->new_edl->session->track_h)
639 // this->nwindow = nwindow;
642 // int NewTrackH::handle_event()
644 // nwindow->new_edl->session->track_h = atol(get_text());
648 FrameSizePulldown::FrameSizePulldown(MWindow *mwindow,
649 BC_TextBox *output_w,
650 BC_TextBox *output_h,
658 &mwindow->theme->frame_sizes,
665 this->mwindow = mwindow;
666 this->output_w = output_w;
667 this->output_h = output_h;
669 int FrameSizePulldown::handle_event()
671 char *text = get_selection(0, 0)->get_text();
672 char string[BCTEXTLEN];
676 strcpy(string, text);
677 ptr = strrchr(string, 'x');
687 output_w->handle_event();
688 output_h->handle_event();
693 NewOutputW::NewOutputW(NewWindow *nwindow, int x, int y)
694 : BC_TextBox(x, y, 70, 1, nwindow->new_edl->session->output_w)
696 this->nwindow = nwindow;
698 int NewOutputW::handle_event()
700 nwindow->new_edl->session->output_w = MAX(1,atol(get_text()));
701 nwindow->new_thread->update_aspect();
705 NewOutputH::NewOutputH(NewWindow *nwindow, int x, int y)
706 : BC_TextBox(x, y, 70, 1, nwindow->new_edl->session->output_h)
708 this->nwindow = nwindow;
710 int NewOutputH::handle_event()
712 nwindow->new_edl->session->output_h = MAX(1, atol(get_text()));
713 nwindow->new_thread->update_aspect();
717 NewAspectW::NewAspectW(NewWindow *nwindow, char *text, int x, int y)
718 : BC_TextBox(x, y, 70, 1, text)
720 this->nwindow = nwindow;
723 int NewAspectW::handle_event()
725 nwindow->new_edl->session->aspect_w = atof(get_text());
729 NewAspectH::NewAspectH(NewWindow *nwindow, char *text, int x, int y)
730 : BC_TextBox(x, y, 70, 1, text)
732 this->nwindow = nwindow;
735 int NewAspectH::handle_event()
737 nwindow->new_edl->session->aspect_h = atof(get_text());
741 AspectPulldown::AspectPulldown(MWindow *mwindow,
742 BC_TextBox *output_w,
743 BC_TextBox *output_h,
751 &mwindow->theme->aspect_ratios,
758 this->mwindow = mwindow;
759 this->output_w = output_w;
760 this->output_h = output_h;
762 int AspectPulldown::handle_event()
764 char *text = get_selection(0, 0)->get_text();
765 char string[BCTEXTLEN];
769 strcpy(string, text);
770 ptr = strrchr(string, ':');
780 output_w->handle_event();
781 output_h->handle_event();
786 ColormodelItem::ColormodelItem(char *text, int value)
787 : BC_ListBoxItem(text)
792 ColormodelPulldown::ColormodelPulldown(MWindow *mwindow,
793 BC_TextBox *output_text,
802 (ArrayList<BC_ListBoxItem*>*)&mwindow->colormodels,
809 this->mwindow = mwindow;
810 this->output_text = output_text;
811 this->output_value = output_value;
812 output_text->update(colormodel_to_text());
815 int ColormodelPulldown::handle_event()
817 output_text->update(get_selection(0, 0)->get_text());
818 *output_value = ((ColormodelItem*)get_selection(0, 0))->value;
822 char* ColormodelPulldown::colormodel_to_text()
824 for(int i = 0; i < mwindow->colormodels.total; i++)
825 if(mwindow->colormodels.values[i]->value == *output_value)
826 return mwindow->colormodels.values[i]->get_text();
839 NewAspectAuto::NewAspectAuto(NewWindow *nwindow, int x, int y)
840 : BC_CheckBox(x, y, nwindow->new_thread->auto_aspect, _("Auto aspect ratio"))
842 this->nwindow = nwindow;
844 NewAspectAuto::~NewAspectAuto()
847 int NewAspectAuto::handle_event()
849 nwindow->new_thread->auto_aspect = get_value();
850 nwindow->new_thread->update_aspect();
857 NewCloneToggle::NewCloneToggle(MWindow *mwindow, NewWindow *nwindow, int x, int y)
860 mwindow->theme->chain_data,
861 nwindow->new_thread->auto_sizes,
867 this->mwindow = mwindow;
868 this->nwindow = nwindow;
871 int NewCloneToggle::handle_event()
873 nwindow->canvas_w_text->update((int64_t)nwindow->new_edl->session->track_w);
874 nwindow->canvas_h_text->update((int64_t)nwindow->new_edl->session->track_h);
875 nwindow->new_edl->session->output_w = nwindow->new_edl->session->track_w;
876 nwindow->new_edl->session->output_h = nwindow->new_edl->session->track_h;
877 nwindow->new_thread->update_aspect();