r1009: Move the dependencies to newer package names
[cinelerra_cv/mob.git] / cinelerra / setformat.C
blob4abf632fb43e6106399a949929bd3167977bfc61
1 #include "clip.h"
2 #include "cwindow.h"
3 #include "cwindowgui.h"
4 #include "datatype.h"
5 #include "bchash.h"
6 #include "edl.h"
7 #include "edlsession.h"
8 #include "formatpresets.h"
9 #include "language.h"
10 #include "levelwindow.h"
11 #include "levelwindowgui.h"
12 #include "mainerror.h"
13 #include "mainundo.h"
14 #include "mutex.h"
15 #include "mwindow.h"
16 #include "mwindowgui.h"
17 #include "new.h"
18 #include "preferences.h"
19 #include "rotateframe.h"
20 #include "setformat.h"
21 #include "theme.h"
22 #include "vframe.h"
23 #include "vwindow.h"
24 #include "vwindowgui.h"
28 SetFormat::SetFormat(MWindow *mwindow)
29  : BC_MenuItem(_("Format..."), "Shift-F", 'F')
31         set_shift(1); 
32         this->mwindow = mwindow;
33         thread = new SetFormatThread(mwindow);
36 int SetFormat::handle_event()
38         if(!thread->running())
39         {
40                 thread->start();
41         }
42         else
43         {
44 // window_lock has to be locked but window can't be locked until after
45 // it is known to exist, so we neglect window_lock for now
46                 if(thread->window)
47                 {
48                         thread->window_lock->lock("SetFormat::handle_event");
49                         thread->window->lock_window("SetFormat::handle_event");
50                         thread->window->raise_window();
51                         thread->window->unlock_window();
52                         thread->window_lock->unlock();
53                 }
54         }
55         return 1;
58 SetFormatThread::SetFormatThread(MWindow *mwindow)
59  : Thread()
61         this->mwindow = mwindow;
62         window_lock = new Mutex("SetFormatThread::window_lock");
63         window = 0;
66 void SetFormatThread::run()
68         orig_dimension[0] = dimension[0] = mwindow->edl->session->output_w;
69         orig_dimension[1] = dimension[1] = mwindow->edl->session->output_h;
70         auto_aspect = mwindow->defaults->get("AUTOASPECT", 0);
71         constrain_ratio = 0;
72         ratio[0] = ratio[1] = 1;
74         new_settings = new EDL;
75         new_settings->create_objects();
76         new_settings->copy_session(mwindow->edl);
78 // This locks mwindow, so it must be done outside window_lock
79         int x = mwindow->gui->get_abs_cursor_x(1) - mwindow->theme->setformat_w / 2;
80         int y = mwindow->gui->get_abs_cursor_y(1) - mwindow->theme->setformat_h / 2;
82         window_lock->lock("SetFormatThread::run 1");
83         window = new SetFormatWindow(mwindow, this, x, y);
84         window->create_objects();
85         window_lock->unlock();
87         int result = window->run_window();
90         window_lock->lock("SetFormatThread::run 2");
91         delete window;
92         window = 0;
93         window_lock->unlock();
96         if(!result)
97         {
98                 apply_changes();
99         }
101         mwindow->defaults->update("AUTOASPECT", auto_aspect);
102         delete new_settings;
105 void SetFormatThread::apply_changes()
107         double new_samplerate = new_settings->session->sample_rate;
108         double old_samplerate = mwindow->edl->session->sample_rate;
109         double new_framerate = new_settings->session->frame_rate;
110         double old_framerate = mwindow->edl->session->frame_rate;
111         int new_channels = new_settings->session->audio_channels;
112         CLAMP(new_channels, 1, MAXCHANNELS);
114         memcpy(&mwindow->preferences->channel_positions[MAXCHANNELS * (new_channels - 1)],
115                 new_settings->session->achannel_positions,
116                 sizeof(int) * MAXCHANNELS);
119         mwindow->edl->copy_session(new_settings, 1);
120         mwindow->edl->session->output_w = dimension[0];
121         mwindow->edl->session->output_h = dimension[1];
122         mwindow->edl->rechannel();
123         mwindow->edl->resample(old_samplerate, new_samplerate, TRACK_AUDIO);
124         mwindow->edl->resample(old_framerate, new_framerate, TRACK_VIDEO);
125         mwindow->save_backup();
126         mwindow->undo->update_undo(_("set format"), LOAD_ALL);
128 // Update GUIs
129         mwindow->restart_brender();
130         mwindow->gui->lock_window("SetFormatThread::apply_changes");
131         mwindow->gui->update(1,
132                 1,
133                 1,
134                 1,
135                 1, 
136                 1,
137                 0);
138         mwindow->gui->unlock_window();
140         mwindow->cwindow->gui->lock_window("SetFormatThread::apply_changes");
141         mwindow->cwindow->gui->resize_event(mwindow->cwindow->gui->get_w(), 
142                 mwindow->cwindow->gui->get_h());
143         mwindow->cwindow->gui->meters->set_meters(new_channels, 1);
144         mwindow->cwindow->gui->slider->set_position();
145         mwindow->cwindow->gui->flush();
146         mwindow->cwindow->gui->unlock_window();
148         mwindow->vwindow->gui->lock_window("SetFormatThread::apply_changes");
149         mwindow->vwindow->gui->resize_event(mwindow->vwindow->gui->get_w(), 
150                 mwindow->vwindow->gui->get_h());
151         mwindow->vwindow->gui->meters->set_meters(new_channels, 1);
152         mwindow->vwindow->gui->flush();
153         mwindow->vwindow->gui->unlock_window();
155         mwindow->lwindow->gui->lock_window("SetFormatThread::apply_changes");
156         mwindow->lwindow->gui->panel->set_meters(new_channels, 1);
157         mwindow->lwindow->gui->flush();
158         mwindow->lwindow->gui->unlock_window();
160 // Warn user
161         if(((mwindow->edl->session->output_w % 4) ||
162                 (mwindow->edl->session->output_h % 4)) &&
163                 mwindow->edl->session->playback_config->vconfig->driver == PLAYBACK_X11_GL)
164         {
165                 MainError::show_error(
166                         _("This project's dimensions are not multiples of 4 so\n"
167                         "it can't be rendered by OpenGL."));
168         }
171 // Flash frame
172         mwindow->sync_parameters(CHANGE_ALL);
175 void SetFormatThread::update()
177         window->sample_rate->update(new_settings->session->sample_rate);
178         window->channels->update((int64_t)new_settings->session->audio_channels);
179         window->frame_rate->update((float)new_settings->session->frame_rate);
181         auto_aspect = 0;
182         window->auto_aspect->update(0);
184         constrain_ratio = 0;
185         dimension[0] = new_settings->session->output_w;
186         window->dimension[0]->update((int64_t)dimension[0]);
187         dimension[1] = new_settings->session->output_h;
188         window->dimension[1]->update((int64_t)dimension[1]);
190         ratio[0] = (float)dimension[0] / orig_dimension[0];
191         window->ratio[0]->update(ratio[0]);
192         ratio[1] = (float)dimension[1] / orig_dimension[1];
193         window->ratio[1]->update(ratio[1]);
195         window->aspect_w->update(new_settings->session->aspect_w);
196         window->aspect_h->update(new_settings->session->aspect_h);
197         window->interlace_pulldown->update(new_settings->session->interlace_mode);
199         window->canvas->draw();
202 void SetFormatThread::update_window()
204         int i, result, modified_item, dimension_modified = 0, ratio_modified = 0;
206         for(i = 0, result = 0; i < 2 && !result; i++)
207         {
208                 if(dimension[i] < 0)
209                 {
210                         dimension[i] *= -1;
211                         result = 1;
212                         modified_item = i;
213                         dimension_modified = 1;
214                 }
215                 if(ratio[i] < 0)
216                 {
217                         ratio[i] *= -1;
218                         result = 1;
219                         modified_item = i;
220                         ratio_modified = 1;
221                 }
222         }
224         if(result)
225         {
226                 if(dimension_modified)
227                         ratio[modified_item] = (float)dimension[modified_item] / orig_dimension[modified_item];
229                 if(ratio_modified && !constrain_ratio)
230                 {
231                         dimension[modified_item] = (int)(orig_dimension[modified_item] * ratio[modified_item]);
232                         window->dimension[modified_item]->update((int64_t)dimension[modified_item]);
233                 }
235                 for(i = 0; i < 2; i++)
236                 {
237                         if(dimension_modified ||
238                                 (i != modified_item && ratio_modified))
239                         {
240                                 if(constrain_ratio) ratio[i] = ratio[modified_item];
241                                 window->ratio[i]->update(ratio[i]);
242                         }
244                         if(ratio_modified ||
245                                 (i != modified_item && dimension_modified))
246                         {
247                                 if(constrain_ratio) 
248                                 {
249                                         dimension[i] = (int)(orig_dimension[i] * ratio[modified_item]);
250                                         window->dimension[i]->update((int64_t)dimension[i]);
251                                 }
252                         }
253                 }
254         }
256         update_aspect();
259 void SetFormatThread::update_aspect()
261         if(auto_aspect)
262         {
263                 char string[BCTEXTLEN];
264                 MWindow::create_aspect_ratio(new_settings->session->aspect_w, 
265                         new_settings->session->aspect_h, 
266                         dimension[0], 
267                         dimension[1]);
268                 sprintf(string, "%.02f", new_settings->session->aspect_w);
269                 window->aspect_w->update(string);
270                 sprintf(string, "%.02f", new_settings->session->aspect_h);
271                 window->aspect_h->update(string);
272         }
283 SetFormatWindow::SetFormatWindow(MWindow *mwindow, 
284         SetFormatThread *thread,
285         int x,
286         int y)
287  : BC_Window(PROGRAM_NAME ": Set Format",
288         x,
289         y,
290         mwindow->theme->setformat_w,
291         mwindow->theme->setformat_h,
292         -1,
293         -1,
294         0,
295         0,
296         1)
298         this->mwindow = mwindow;
299         this->thread = thread;
302 void SetFormatWindow::create_objects()
304         int x = 10, y = mwindow->theme->setformat_y1;
305         BC_TextBox *textbox;
306         BC_Title *title;
308         mwindow->theme->draw_setformat_bg(this);
312         presets = new SetFormatPresets(mwindow, 
313                 this, 
314                 x, 
315                 y);
316         presets->create_objects();
317         x = presets->x;
318         y = presets->y;
320         y = mwindow->theme->setformat_y2;
322         add_subwindow(new BC_Title(mwindow->theme->setformat_x1, 
323                 y, 
324                 _("Audio"), 
325                 LARGEFONT));
326         y = mwindow->theme->setformat_y3;
327         add_subwindow(new BC_Title(mwindow->theme->setformat_x1, 
328                 y,
329                 _("Samplerate:")));
331         y += mwindow->theme->setformat_margin;
332         add_subwindow(new BC_Title(mwindow->theme->setformat_x1, 
333                 y,
334                 _("Samplerate:")));
335         add_subwindow(sample_rate = new SetSampleRateTextBox(thread, 
336                 mwindow->theme->setformat_x2, 
337                 y));
338         add_subwindow(new SampleRatePulldown(mwindow, 
339                 sample_rate, 
340                 mwindow->theme->setformat_x2 + sample_rate->get_w(), 
341                 y));
343         y += mwindow->theme->setformat_margin;
344         add_subwindow(new BC_Title(mwindow->theme->setformat_x1, 
345                 y, 
346                 _("Channels:")));
347         add_subwindow(channels = new SetChannelsTextBox(thread, 
348                 mwindow->theme->setformat_x2, 
349                 y));
350         add_subwindow(new BC_ITumbler(channels, 
351                 1, 
352                 MAXCHANNELS, 
353                 mwindow->theme->setformat_x2 + channels->get_w(), 
354                 y));
356         y += mwindow->theme->setformat_margin;
357         add_subwindow(new BC_Title(mwindow->theme->setformat_x1, 
358                 y, 
359                 _("Channel positions:")));
360         y += mwindow->theme->setformat_margin;
361         add_subwindow(canvas = new SetChannelsCanvas(mwindow, 
362                 thread, 
363                 mwindow->theme->setformat_channels_x, 
364                 mwindow->theme->setformat_channels_y, 
365                 mwindow->theme->setformat_channels_w, 
366                 mwindow->theme->setformat_channels_h));
367         canvas->draw();
377         y = mwindow->theme->setformat_y2;
378         add_subwindow(new BC_Title(mwindow->theme->setformat_x3, 
379                 y, 
380                 _("Video"), 
381                 LARGEFONT));
383         y = mwindow->theme->setformat_y3;
384         add_subwindow(new BC_Title(mwindow->theme->setformat_x3, 
385                 y, 
386                 _("Frame rate:")));
387         add_subwindow(frame_rate = new SetFrameRateTextBox(thread, 
388                 mwindow->theme->setformat_x4, 
389                 y));
390         add_subwindow(new FrameRatePulldown(mwindow, 
391                 frame_rate, 
392                 mwindow->theme->setformat_x4 + frame_rate->get_w(), 
393                 y));
395         y += mwindow->theme->setformat_margin;
396         add_subwindow(new BC_Title(mwindow->theme->setformat_x3, 
397                 y, 
398                 _("Canvas size:")));
400         y += mwindow->theme->setformat_margin;
401         add_subwindow(title = new BC_Title(mwindow->theme->setformat_x3, y, _("Width:")));
402         add_subwindow(dimension[0] = new ScaleSizeText(mwindow->theme->setformat_x4, 
403                 y, 
404                 thread, 
405                 &(thread->dimension[0])));
407         y += mwindow->theme->setformat_margin;
408         add_subwindow(new BC_Title(mwindow->theme->setformat_x3, y, _("Height:")));
409         add_subwindow(dimension[1] = new ScaleSizeText(mwindow->theme->setformat_x4, 
410                 y, 
411                 thread, 
412                 &(thread->dimension[1])));
414         x = mwindow->theme->setformat_x4 + dimension[0]->get_w();
415         FrameSizePulldown *pulldown;
416         add_subwindow(pulldown = new FrameSizePulldown(mwindow, 
417                 dimension[0], 
418                 dimension[1], 
419                 x, 
420                 y - mwindow->theme->setformat_margin));
422         add_subwindow(new FormatSwapExtents(mwindow, 
423                 thread, 
424                 this, 
425                 x + pulldown->get_w() + 5,
426                 y - mwindow->theme->setformat_margin));
427                 
428         y += mwindow->theme->setformat_margin;
429         add_subwindow(new BC_Title(mwindow->theme->setformat_x3, 
430                 y, 
431                 _("W Ratio:")));
432         add_subwindow(ratio[0] = new ScaleRatioText(mwindow->theme->setformat_x4, 
433                 y, 
434                 thread, 
435                 &(thread->ratio[0])));
437         y += mwindow->theme->setformat_margin;
438         add_subwindow(new BC_Title(mwindow->theme->setformat_x3, 
439                 y, 
440                 _("H Ratio:")));
441         add_subwindow(ratio[1] = new ScaleRatioText(mwindow->theme->setformat_x4, 
442                 y, 
443                 thread, 
444                 &(thread->ratio[1])));
446         y += mwindow->theme->setformat_margin;
447         add_subwindow(new BC_Title(mwindow->theme->setformat_x3, 
448                 y, 
449                 _("Color model:")));
450         x = mwindow->theme->setformat_x4;
451         add_subwindow(color_model = new BC_TextBox(x, 
452                 y, 
453                 100, 
454                 1, 
455                 ""));
456         x += color_model->get_w();
457         add_subwindow(new ColormodelPulldown(mwindow, 
458                 color_model, 
459                 &thread->new_settings->session->color_model,
460                 x, 
461                 y));
463         y += mwindow->theme->setformat_margin;
464         add_subwindow(new BC_Title(mwindow->theme->setformat_x3, 
465                 y, 
466                 _("Aspect ratio:")));
467         y += mwindow->theme->setformat_margin;
468         x = mwindow->theme->setformat_x3;
469         add_subwindow(aspect_w = new ScaleAspectText(x, 
470                 y, 
471                 thread, 
472                 &(thread->new_settings->session->aspect_w)));
473         x += aspect_w->get_w() + 5;
474         add_subwindow(new BC_Title(x, y, _(":")));
475         x += 10;
476         add_subwindow(aspect_h = new ScaleAspectText(x, 
477                 y, 
478                 thread, 
479                 &(thread->new_settings->session->aspect_h)));
480         x += aspect_h->get_w();
481         add_subwindow(new AspectPulldown(mwindow, 
482                 aspect_w, 
483                 aspect_h, 
484                 x, 
485                 y));
486         x += 30;
487         add_subwindow(auto_aspect = new ScaleAspectAuto(x, y, thread));
488         y += mwindow->theme->setformat_margin;
490         // --------------------
491         add_subwindow(new BC_Title(mwindow->theme->setformat_x3, 
492                 y, 
493                 _("Interlace mode:")));
494         add_subwindow(textbox = new BC_TextBox(mwindow->theme->setformat_x4,
495                 y,
496                 140, 
497                 1, 
498                 ""));
499         add_subwindow(interlace_pulldown = new InterlacemodePulldown(mwindow, 
500                 textbox,
501                 &(thread->new_settings->session->interlace_mode),
502                 (ArrayList<BC_ListBoxItem*>*)&mwindow->interlace_project_modes,
503                 mwindow->theme->setformat_x4 + textbox->get_w(), 
504                 y)); 
505         y += mwindow->theme->setformat_margin;
508         BC_OKTextButton *ok;
509         BC_CancelTextButton *cancel;
510         add_subwindow(ok = new BC_OKTextButton(this));
511         add_subwindow(cancel = new BC_CancelTextButton(this));
512         add_subwindow(new SetFormatApply((ok->get_x() + cancel->get_x()) / 2, 
513                 ok->get_y(), 
514                 thread));
515         flash();
516         show_window();
519 char* SetFormatWindow::get_preset_text()
521         return "";
538 SetFormatPresets::SetFormatPresets(MWindow *mwindow, 
539         SetFormatWindow *gui, 
540         int x, 
541         int y)
542  : FormatPresets(mwindow, 0, gui, x, y)
544         
547 SetFormatPresets::~SetFormatPresets()
551 int SetFormatPresets::handle_event()
553         format_gui->thread->update();
554         return 1;
557 EDL* SetFormatPresets::get_edl()
559         return format_gui->thread->new_settings;
576 SetSampleRateTextBox::SetSampleRateTextBox(SetFormatThread *thread, int x, int y)
577  : BC_TextBox(x, y, 100, 1, (int64_t)thread->new_settings->session->sample_rate)
579         this->thread = thread;
581 int SetSampleRateTextBox::handle_event()
583         thread->new_settings->session->sample_rate = CLIP(atol(get_text()), 1, 1000000);
584         return 1;
587 SetChannelsTextBox::SetChannelsTextBox(SetFormatThread *thread, int x, int y)
588  : BC_TextBox(x, y, 100, 1, thread->new_settings->session->audio_channels)
590         this->thread = thread;
592 int SetChannelsTextBox::handle_event()
594         int new_channels = CLIP(atoi(get_text()), 1, MAXCHANNELS);
595         
596         thread->new_settings->session->audio_channels = new_channels;
599         if(new_channels > 0)
600         {
601                 memcpy(thread->new_settings->session->achannel_positions,
602                         &thread->mwindow->preferences->channel_positions[MAXCHANNELS * (new_channels - 1)],
603                         sizeof(int) * MAXCHANNELS);
604         }
607         thread->window->canvas->draw();
608         return 1;
612 SetChannelsCanvas::SetChannelsCanvas(MWindow *mwindow, 
613         SetFormatThread *thread, 
614         int x, 
615         int y,
616         int w,
617         int h)
618  : BC_SubWindow(x, 
619         y, 
620         w,
621         h)
623         this->thread = thread;
624         this->mwindow = mwindow;
625         active_channel = -1;
626         box_r = mwindow->theme->channel_position_data->get_w() / 2;
627         temp_picon = new VFrame(0, 
628                 mwindow->theme->channel_position_data->get_w(),
629                 mwindow->theme->channel_position_data->get_h(),
630                 mwindow->theme->channel_position_data->get_color_model());
631         rotater = new RotateFrame(mwindow->preferences->processors,
632                 mwindow->theme->channel_position_data->get_w(),
633                 mwindow->theme->channel_position_data->get_h());
635 SetChannelsCanvas::~SetChannelsCanvas()
637         delete temp_picon;
638         delete rotater;
641 int SetChannelsCanvas::draw(int angle)
643         set_color(RED);
644         int real_w = get_w() - box_r * 2;
645         int real_h = get_h() - box_r * 2;
646         int real_x = box_r;
647         int real_y = box_r;
649         draw_top_background(get_top_level(), 0, 0, get_w(), get_h());
650 //      draw_vframe(mwindow->theme->channel_bg_data, 0, 0);
655         int x, y, w, h;
656         char string[32];
657         set_color(mwindow->theme->channel_position_color);
658         for(int i = 0; i < thread->new_settings->session->audio_channels; i++)
659         {
660                 get_dimensions(thread->new_settings->session->achannel_positions[i], 
661                         x, 
662                         y, 
663                         w, 
664                         h);
665                 double rotate_angle = thread->new_settings->session->achannel_positions[i];
666                 rotate_angle = -rotate_angle;
667                 while(rotate_angle < 0) rotate_angle += 360;
668                 rotater->rotate(temp_picon, 
669                         mwindow->theme->channel_position_data, 
670                         rotate_angle, 
671                         0);
673                 BC_Pixmap temp_pixmap(this, 
674                         temp_picon, 
675                         PIXMAP_ALPHA,
676                         0);
677                 draw_pixmap(&temp_pixmap, x, y);
678                 sprintf(string, "%d", i + 1);
679                 draw_text(x + 2, y + box_r * 2 - 2, string);
680         }
682         if(angle > -1)
683         {
684                 sprintf(string, _("%d degrees"), angle);
685                 draw_text(this->get_w() / 2 - 40, this->get_h() / 2, string);
686         }
688         flash();
689         return 0;
692 int SetChannelsCanvas::get_dimensions(int channel_position, 
693         int &x, 
694         int &y, 
695         int &w, 
696         int &h)
698 #define MARGIN 10
699         int real_w = this->get_w() - box_r * 2 - MARGIN;
700         int real_h = this->get_h() - box_r * 2 - MARGIN;
701         float corrected_position = channel_position;
702         if(corrected_position < 0) corrected_position += 360;
703         Units::polar_to_xy((float)corrected_position, real_w / 2, x, y);
704         x += real_w / 2 + MARGIN / 2;
705         y += real_h / 2 + MARGIN / 2;
706         w = box_r * 2;
707         h = box_r * 2;
708         return 0;
711 int SetChannelsCanvas::button_press_event()
713         if(!cursor_inside()) return 0;
714 // get active channel
715         for(int i = 0; 
716                 i < thread->new_settings->session->audio_channels; 
717                 i++)
718         {
719                 int x, y, w, h;
720                 get_dimensions(thread->new_settings->session->achannel_positions[i], 
721                         x, 
722                         y, 
723                         w, 
724                         h);
725                 if(get_cursor_x() > x && get_cursor_y() > y && 
726                         get_cursor_x() < x + w && get_cursor_y() < y + h)
727                 {
728                         active_channel = i;
729                         degree_offset = (int)Units::xy_to_polar(get_cursor_x() - this->get_w() / 2, get_cursor_y() - this->get_h() / 2);
730                         degree_offset += 90;
731                         if(degree_offset >= 360) degree_offset -= 360;
732                         degree_offset -= thread->new_settings->session->achannel_positions[i];
733                         draw(thread->new_settings->session->achannel_positions[i]);
734                         return 1;
735                 }
736         }
737         return 0;
740 int SetChannelsCanvas::button_release_event()
742         if(active_channel >= 0)
743         {
744                 active_channel = -1;
745                 draw(-1);
746                 return 1;
747         }
748         return 0;
751 int SetChannelsCanvas::cursor_motion_event()
753         if(active_channel >= 0)
754         {
755 // get degrees of new channel
756                 int new_d;
757                 new_d = (int)Units::xy_to_polar(get_cursor_x() - this->get_w() / 2, get_cursor_y() - this->get_h() / 2);
758                 new_d += 90;
759                 new_d -= degree_offset;
761                 while(new_d >= 360) new_d -= 360;
762                 while(new_d < 0) new_d += 360;
764                 if(thread->new_settings->session->achannel_positions[active_channel] != new_d)
765                 {
766                         thread->new_settings->session->achannel_positions[active_channel] = new_d;
767                         int new_channels = thread->new_settings->session->audio_channels;
768                         memcpy(&thread->mwindow->preferences->channel_positions[MAXCHANNELS * (new_channels - 1)],
769                                 thread->new_settings->session->achannel_positions,
770                                 sizeof(int) * MAXCHANNELS);
771                         draw(thread->new_settings->session->achannel_positions[active_channel]);
772                 }
773                 return 1;
774         }
775         return 0;
786 SetFrameRateTextBox::SetFrameRateTextBox(SetFormatThread *thread, int x, int y)
787  : BC_TextBox(x, y, 100, 1, (float)thread->new_settings->session->frame_rate)
789         this->thread = thread;
792 int SetFrameRateTextBox::handle_event()
794         thread->new_settings->session->frame_rate = Units::atoframerate(get_text());
795         return 1;
799 // 
800 // SetVChannels::SetVChannels(SetFormatThread *thread, int x, int y)
801 //  : BC_TextBox(x, y, 100, 1, thread->channels)
802 // {
803 //      this->thread = thread;
804 // }
805 // int SetVChannels::handle_event()
806 // {
807 //      thread->channels = atol(get_text());
808 //      return 1;
809 // }
814 ScaleSizeText::ScaleSizeText(int x, int y, SetFormatThread *thread, int *output)
815  : BC_TextBox(x, y, 100, 1, *output)
817         this->thread = thread; 
818         this->output = output; 
820 ScaleSizeText::~ScaleSizeText()
823 int ScaleSizeText::handle_event()
825         *output = atol(get_text());
826         *output /= 2;
827         *output *= 2;
828         if(*output <= 0) *output = 2;
829         if(*output > 10000) *output = 10000;
830         *output *= -1;
831         thread->update_window();
836 ScaleRatioText::ScaleRatioText(int x, 
837         int y, 
838         SetFormatThread *thread, 
839         float *output)
840  : BC_TextBox(x, y, 100, 1, *output)
842         this->thread = thread; 
843         this->output = output; 
845 ScaleRatioText::~ScaleRatioText()
848 int ScaleRatioText::handle_event()
850         *output = atof(get_text());
851         //if(*output <= 0) *output = 1;
852         if(*output > 10000) *output = 10000;
853         if(*output < -10000) *output = -10000;
854         *output *= -1;
855         thread->update_window();
856         return 1;
861 ScaleAspectAuto::ScaleAspectAuto(int x, int y, SetFormatThread *thread)
862  : BC_CheckBox(x, y, thread->auto_aspect, _("Auto"))
864         this->thread = thread; 
867 ScaleAspectAuto::~ScaleAspectAuto()
871 int ScaleAspectAuto::handle_event()
873         thread->auto_aspect = get_value();
874         thread->update_aspect();
877 ScaleAspectText::ScaleAspectText(int x, int y, SetFormatThread *thread, float *output)
878  : BC_TextBox(x, y, 70, 1, *output)
880         this->output = output;
881         this->thread = thread;
883 ScaleAspectText::~ScaleAspectText()
887 int ScaleAspectText::handle_event()
889         *output = atof(get_text());
890         return 1;
898 SetFormatApply::SetFormatApply(int x, int y, SetFormatThread *thread)
899  : BC_GenericButton(x, y, _("Apply"))
901         this->thread = thread;
904 int SetFormatApply::handle_event()
906         thread->apply_changes();
907         return 1;
922 FormatSwapExtents::FormatSwapExtents(MWindow *mwindow, 
923         SetFormatThread *thread,
924         SetFormatWindow *gui, 
925         int x, 
926         int y)
927  : BC_Button(x, y, mwindow->theme->get_image_set("swap_extents"))
929         this->mwindow = mwindow;
930         this->thread = thread;
931         this->gui = gui;
932         set_tooltip("Swap dimensions");
935 int FormatSwapExtents::handle_event()
937         int w = thread->dimension[0];
938         int h = thread->dimension[1];
939         thread->dimension[0] = -h;
940         gui->dimension[0]->update((int64_t)h);
941         gui->dimension[1]->update((int64_t)w);
942         thread->update_window();
943         thread->dimension[1] = -w;
944         thread->update_window();
945         return 1;