r807: Minor fix...
[cinelerra_cv/mob.git] / cinelerra / setformat.C
blob468f2d244b79af0c0d4c17d3c02f03df174f3d1b
1 #include "clip.h"
2 #include "cwindow.h"
3 #include "cwindowgui.h"
4 #include "datatype.h"
5 #include "defaults.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 "mainundo.h"
13 #include "mutex.h"
14 #include "mwindow.h"
15 #include "mwindowgui.h"
16 #include "new.h"
17 #include "preferences.h"
18 #include "rotateframe.h"
19 #include "setformat.h"
20 #include "theme.h"
21 #include "vframe.h"
22 #include "vwindow.h"
23 #include "vwindowgui.h"
27 SetFormat::SetFormat(MWindow *mwindow)
28  : BC_MenuItem(_("Format..."), "Shift-F", 'F')
30         set_shift(1); 
31         this->mwindow = mwindow;
32         thread = new SetFormatThread(mwindow);
35 int SetFormat::handle_event()
37         if(!thread->running())
38         {
39                 thread->start();
40         }
41         else
42         {
43 // window_lock has to be locked but window can't be locked until after
44 // it is known to exist, so we neglect window_lock for now
45                 if(thread->window)
46                 {
47                         thread->window_lock->lock("SetFormat::handle_event");
48                         thread->window->lock_window("SetFormat::handle_event");
49                         thread->window->raise_window();
50                         thread->window->unlock_window();
51                         thread->window_lock->unlock();
52                 }
53         }
54         return 1;
57 SetFormatThread::SetFormatThread(MWindow *mwindow)
58  : Thread()
60         this->mwindow = mwindow;
61         window_lock = new Mutex("SetFormatThread::window_lock");
62         window = 0;
65 void SetFormatThread::run()
67         orig_dimension[0] = dimension[0] = mwindow->edl->session->output_w;
68         orig_dimension[1] = dimension[1] = mwindow->edl->session->output_h;
69         auto_aspect = mwindow->defaults->get("AUTOASPECT", 0);
70         constrain_ratio = 0;
71         ratio[0] = ratio[1] = 1;
73         new_settings = new EDL;
74         new_settings->create_objects();
75         new_settings->copy_session(mwindow->edl);
77 // This locks mwindow, so it must be done outside window_lock
78         int x = mwindow->gui->get_abs_cursor_x(1) - mwindow->theme->setformat_w / 2;
79         int y = mwindow->gui->get_abs_cursor_y(1) - mwindow->theme->setformat_h / 2;
81         window_lock->lock("SetFormatThread::run 1");
82         window = new SetFormatWindow(mwindow, this, x, y);
83         window->create_objects();
84         window_lock->unlock();
86         int result = window->run_window();
89         window_lock->lock("SetFormatThread::run 2");
90         delete window;
91         window = 0;
92         window_lock->unlock();
95         if(!result)
96         {
97                 apply_changes();
98         }
100         mwindow->defaults->update("AUTOASPECT", auto_aspect);
101         delete new_settings;
104 void SetFormatThread::apply_changes()
106         double new_samplerate = new_settings->session->sample_rate;
107         double old_samplerate = mwindow->edl->session->sample_rate;
108         double new_framerate = new_settings->session->frame_rate;
109         double old_framerate = mwindow->edl->session->frame_rate;
110         int new_channels = new_settings->session->audio_channels;
113         mwindow->edl->copy_session(new_settings);
114         mwindow->edl->session->output_w = dimension[0];
115         mwindow->edl->session->output_h = dimension[1];
116         mwindow->edl->rechannel();
117         mwindow->edl->resample(old_samplerate, new_samplerate, TRACK_AUDIO);
118         mwindow->edl->resample(old_framerate, new_framerate, TRACK_VIDEO);
119         mwindow->save_backup();
120         mwindow->undo->update_undo(_("set format"), LOAD_ALL);
122 // Update GUIs
123         mwindow->restart_brender();
124         mwindow->gui->lock_window("SetFormatThread::apply_changes");
125         mwindow->gui->update(1,
126                 1,
127                 1,
128                 1,
129                 1, 
130                 1,
131                 0);
132         mwindow->gui->unlock_window();
134         mwindow->cwindow->gui->lock_window("SetFormatThread::apply_changes");
135         mwindow->cwindow->gui->resize_event(mwindow->cwindow->gui->get_w(), 
136                 mwindow->cwindow->gui->get_h());
137         mwindow->cwindow->gui->meters->set_meters(new_channels, 1);
138         mwindow->cwindow->gui->slider->set_position();
139         mwindow->cwindow->gui->flush();
140         mwindow->cwindow->gui->unlock_window();
142         mwindow->vwindow->gui->lock_window("SetFormatThread::apply_changes");
143         mwindow->vwindow->gui->resize_event(mwindow->vwindow->gui->get_w(), 
144                 mwindow->vwindow->gui->get_h());
145         mwindow->vwindow->gui->meters->set_meters(new_channels, 1);
146         mwindow->vwindow->gui->flush();
147         mwindow->vwindow->gui->unlock_window();
149         mwindow->lwindow->gui->lock_window("SetFormatThread::apply_changes");
150         mwindow->lwindow->gui->panel->set_meters(new_channels, 1);
151         mwindow->lwindow->gui->flush();
152         mwindow->lwindow->gui->unlock_window();
154 // Flash frame
155         mwindow->sync_parameters(CHANGE_ALL);
158 void SetFormatThread::update()
160         window->sample_rate->update(new_settings->session->sample_rate);
161         window->channels->update((int64_t)new_settings->session->audio_channels);
162         window->frame_rate->update((float)new_settings->session->frame_rate);
164         auto_aspect = 0;
165         window->auto_aspect->update(0);
167         constrain_ratio = 0;
168         dimension[0] = new_settings->session->output_w;
169         window->dimension[0]->update((int64_t)dimension[0]);
170         dimension[1] = new_settings->session->output_h;
171         window->dimension[1]->update((int64_t)dimension[1]);
173         ratio[0] = (float)dimension[0] / orig_dimension[0];
174         window->ratio[0]->update(ratio[0]);
175         ratio[1] = (float)dimension[1] / orig_dimension[1];
176         window->ratio[1]->update(ratio[1]);
178         window->aspect_w->update(new_settings->session->aspect_w);
179         window->aspect_h->update(new_settings->session->aspect_h);
181         window->canvas->draw();
184 void SetFormatThread::update_window()
186         int i, result, modified_item, dimension_modified = 0, ratio_modified = 0;
188         for(i = 0, result = 0; i < 2 && !result; i++)
189         {
190                 if(dimension[i] < 0)
191                 {
192                         dimension[i] *= -1;
193                         result = 1;
194                         modified_item = i;
195                         dimension_modified = 1;
196                 }
197                 if(ratio[i] < 0)
198                 {
199                         ratio[i] *= -1;
200                         result = 1;
201                         modified_item = i;
202                         ratio_modified = 1;
203                 }
204         }
206         if(result)
207         {
208                 if(dimension_modified)
209                         ratio[modified_item] = (float)dimension[modified_item] / orig_dimension[modified_item];
211                 if(ratio_modified && !constrain_ratio)
212                 {
213                         dimension[modified_item] = (int)(orig_dimension[modified_item] * ratio[modified_item]);
214                         window->dimension[modified_item]->update((int64_t)dimension[modified_item]);
215                 }
217                 for(i = 0; i < 2; i++)
218                 {
219                         if(dimension_modified ||
220                                 (i != modified_item && ratio_modified))
221                         {
222                                 if(constrain_ratio) ratio[i] = ratio[modified_item];
223                                 window->ratio[i]->update(ratio[i]);
224                         }
226                         if(ratio_modified ||
227                                 (i != modified_item && dimension_modified))
228                         {
229                                 if(constrain_ratio) 
230                                 {
231                                         dimension[i] = (int)(orig_dimension[i] * ratio[modified_item]);
232                                         window->dimension[i]->update((int64_t)dimension[i]);
233                                 }
234                         }
235                 }
236         }
238         update_aspect();
241 void SetFormatThread::update_aspect()
243         if(auto_aspect)
244         {
245                 char string[BCTEXTLEN];
246                 MWindow::create_aspect_ratio(new_settings->session->aspect_w, 
247                         new_settings->session->aspect_h, 
248                         dimension[0], 
249                         dimension[1]);
250                 sprintf(string, "%.02f", new_settings->session->aspect_w);
251                 window->aspect_w->update(string);
252                 sprintf(string, "%.02f", new_settings->session->aspect_h);
253                 window->aspect_h->update(string);
254         }
265 SetFormatWindow::SetFormatWindow(MWindow *mwindow, 
266         SetFormatThread *thread,
267         int x,
268         int y)
269  : BC_Window(PROGRAM_NAME ": Set Format",
270         x,
271         y,
272         mwindow->theme->setformat_w,
273         mwindow->theme->setformat_h,
274         -1,
275         -1,
276         0,
277         0,
278         1)
280         this->mwindow = mwindow;
281         this->thread = thread;
284 void SetFormatWindow::create_objects()
286         int x = 10, y = mwindow->theme->setformat_y1;
287         BC_TextBox *textbox;
288         BC_Title   *titlew;
290         mwindow->theme->draw_setformat_bg(this);
294         presets = new SetFormatPresets(mwindow, 
295                 this, 
296                 x, 
297                 y);
298         presets->create_objects();
299         x = presets->x;
300         y = presets->y;
302         y = mwindow->theme->setformat_y2;
304         add_subwindow(new BC_Title(mwindow->theme->setformat_x1, 
305                 y, 
306                 _("Audio"), 
307                 LARGEFONT));
308         y = mwindow->theme->setformat_y3;
309         add_subwindow(new BC_Title(mwindow->theme->setformat_x1, 
310                 y,
311                 _("Samplerate:")));
313         y += mwindow->theme->setformat_margin;
314         add_subwindow(new BC_Title(mwindow->theme->setformat_x1, 
315                 y,
316                 _("Samplerate:")));
317         add_subwindow(sample_rate = new SetSampleRateTextBox(thread, 
318                 mwindow->theme->setformat_x2, 
319                 y));
320         add_subwindow(new SampleRatePulldown(mwindow, 
321                 sample_rate, 
322                 mwindow->theme->setformat_x2 + sample_rate->get_w(), 
323                 y));
325         y += mwindow->theme->setformat_margin;
326         add_subwindow(new BC_Title(mwindow->theme->setformat_x1, 
327                 y, 
328                 _("Channels:")));
329         add_subwindow(channels = new SetChannelsTextBox(thread, 
330                 mwindow->theme->setformat_x2, 
331                 y));
332         add_subwindow(new BC_ITumbler(channels, 
333                 1, 
334                 MAXCHANNELS, 
335                 mwindow->theme->setformat_x2 + channels->get_w(), 
336                 y));
338         y += mwindow->theme->setformat_margin;
339         add_subwindow(new BC_Title(mwindow->theme->setformat_x1, 
340                 y, 
341                 _("Channel positions:")));
342         y += mwindow->theme->setformat_margin;
343         add_subwindow(canvas = new SetChannelsCanvas(mwindow, 
344                 thread, 
345                 mwindow->theme->setformat_channels_x, 
346                 mwindow->theme->setformat_channels_y, 
347                 mwindow->theme->setformat_channels_w, 
348                 mwindow->theme->setformat_channels_h));
349         canvas->draw();
359         y = mwindow->theme->setformat_y2;
360         add_subwindow(new BC_Title(mwindow->theme->setformat_x3, 
361                 y, 
362                 _("Video"), 
363                 LARGEFONT));
365         y = mwindow->theme->setformat_y3;
366         add_subwindow(new BC_Title(mwindow->theme->setformat_x3, 
367                 y, 
368                 _("Frame rate:")));
369         add_subwindow(frame_rate = new SetFrameRateTextBox(thread, 
370                 mwindow->theme->setformat_x4, 
371                 y));
372         add_subwindow(new FrameRatePulldown(mwindow, 
373                 frame_rate, 
374                 mwindow->theme->setformat_x4 + frame_rate->get_w(), 
375                 y));
377         y += mwindow->theme->setformat_margin;
378         add_subwindow(new BC_Title(mwindow->theme->setformat_x3, 
379                 y, 
380                 _("Canvas size:")));
382         y += mwindow->theme->setformat_margin;
383         add_subwindow(new BC_Title(mwindow->theme->setformat_x3, y, _("Width:")));
384         add_subwindow(dimension[0] = new ScaleSizeText(mwindow->theme->setformat_x4, 
385                 y, 
386                 thread, 
387                 &(thread->dimension[0])));
389         y += mwindow->theme->setformat_margin;
390         add_subwindow(new BC_Title(mwindow->theme->setformat_x3, y, _("Height:")));
391         add_subwindow(dimension[1] = new ScaleSizeText(mwindow->theme->setformat_x4, 
392                 y, 
393                 thread, 
394                 &(thread->dimension[1])));
395         add_subwindow(new FrameSizePulldown(mwindow, 
396                 dimension[0], 
397                 dimension[1], 
398                 mwindow->theme->setformat_x4 + dimension[0]->get_w(), 
399                 y - mwindow->theme->setformat_margin));
401         y += mwindow->theme->setformat_margin;
402         add_subwindow(new BC_Title(mwindow->theme->setformat_x3, 
403                 y, 
404                 _("W Ratio:")));
405         add_subwindow(ratio[0] = new ScaleRatioText(mwindow->theme->setformat_x4, 
406                 y, 
407                 thread, 
408                 &(thread->ratio[0])));
410         y += mwindow->theme->setformat_margin;
411         add_subwindow(new BC_Title(mwindow->theme->setformat_x3, 
412                 y, 
413                 _("H Ratio:")));
414         add_subwindow(ratio[1] = new ScaleRatioText(mwindow->theme->setformat_x4, 
415                 y, 
416                 thread, 
417                 &(thread->ratio[1])));
419         y += mwindow->theme->setformat_margin;
420         add_subwindow(new BC_Title(mwindow->theme->setformat_x3, 
421                 y, 
422                 _("Color model:")));
423         x = mwindow->theme->setformat_x4;
424         add_subwindow(color_model = new BC_TextBox(x, 
425                 y, 
426                 100, 
427                 1, 
428                 ""));
429         x += color_model->get_w();
430         add_subwindow(new ColormodelPulldown(mwindow, 
431                 color_model, 
432                 &thread->new_settings->session->color_model,
433                 x, 
434                 y));
436         y += mwindow->theme->setformat_margin;
437         add_subwindow(new BC_Title(mwindow->theme->setformat_x3, 
438                 y, 
439                 _("Aspect ratio:")));
440         y += mwindow->theme->setformat_margin;
441         x = mwindow->theme->setformat_x3;
442         add_subwindow(aspect_w = new ScaleAspectText(x, 
443                 y, 
444                 thread, 
445                 &(thread->new_settings->session->aspect_w)));
446         x += aspect_w->get_w() + 5;
447         add_subwindow(new BC_Title(x, y, _(":")));
448         x += 10;
449         add_subwindow(aspect_h = new ScaleAspectText(x, 
450                 y, 
451                 thread, 
452                 &(thread->new_settings->session->aspect_h)));
453         x += aspect_h->get_w();
454         add_subwindow(new AspectPulldown(mwindow, 
455                 aspect_w, 
456                 aspect_h, 
457                 x, 
458                 y));
459         x += 30;
460         add_subwindow(auto_aspect = new ScaleAspectAuto(x, y, thread));
461         y += mwindow->theme->setformat_margin;
463         // --------------------
464         add_subwindow(new BC_Title(mwindow->theme->setformat_x3, 
465                 y, 
466                 _("Interlace mode:")));
467         add_subwindow(textbox = new BC_TextBox(mwindow->theme->setformat_x4,
468                 y,
469                 140, 
470                 1, 
471                 ""));
472         add_subwindow(new InterlacemodePulldown(mwindow, 
473                 textbox,
474                 &(thread->new_settings->session->interlace_mode),
475                 (ArrayList<BC_ListBoxItem*>*)&mwindow->interlace_project_modes,
476                 mwindow->theme->setformat_x4 + textbox->get_w(), 
477                 y)); 
478         y += mwindow->theme->setformat_margin;
481         BC_OKTextButton *ok;
482         BC_CancelTextButton *cancel;
483         add_subwindow(ok = new BC_OKTextButton(this));
484         add_subwindow(cancel = new BC_CancelTextButton(this));
485         add_subwindow(new SetFormatApply((ok->get_x() + cancel->get_x()) / 2, 
486                 ok->get_y(), 
487                 thread));
488         flash();
489         show_window();
492 char* SetFormatWindow::get_preset_text()
494         return "";
511 SetFormatPresets::SetFormatPresets(MWindow *mwindow, 
512         SetFormatWindow *gui, 
513         int x, 
514         int y)
515  : FormatPresets(mwindow, 0, gui, x, y)
517         
520 SetFormatPresets::~SetFormatPresets()
524 int SetFormatPresets::handle_event()
526         format_gui->thread->update();
527         return 1;
530 EDL* SetFormatPresets::get_edl()
532         return format_gui->thread->new_settings;
549 SetSampleRateTextBox::SetSampleRateTextBox(SetFormatThread *thread, int x, int y)
550  : BC_TextBox(x, y, 100, 1, (int64_t)thread->new_settings->session->sample_rate)
552         this->thread = thread;
554 int SetSampleRateTextBox::handle_event()
556         thread->new_settings->session->sample_rate = CLIP(atol(get_text()), 1, 1000000);
557         return 1;
560 SetChannelsTextBox::SetChannelsTextBox(SetFormatThread *thread, int x, int y)
561  : BC_TextBox(x, y, 100, 1, thread->new_settings->session->audio_channels)
563         this->thread = thread;
565 int SetChannelsTextBox::handle_event()
567         thread->new_settings->session->audio_channels = CLIP(atol(get_text()), 1, MAXCHANNELS - 1);
568         thread->window->canvas->draw();
569         return 1;
573 SetChannelsCanvas::SetChannelsCanvas(MWindow *mwindow, 
574         SetFormatThread *thread, 
575         int x, 
576         int y,
577         int w,
578         int h)
579  : BC_SubWindow(x, 
580         y, 
581         w,
582         h)
584         this->thread = thread;
585         this->mwindow = mwindow;
586         active_channel = -1;
587         box_r = mwindow->theme->channel_position_data->get_w() / 2;
588         temp_picon = new VFrame(0, 
589                 mwindow->theme->channel_position_data->get_w(),
590                 mwindow->theme->channel_position_data->get_h(),
591                 mwindow->theme->channel_position_data->get_color_model());
592         rotater = new RotateFrame(mwindow->preferences->processors,
593                 mwindow->theme->channel_position_data->get_w(),
594                 mwindow->theme->channel_position_data->get_h());
596 SetChannelsCanvas::~SetChannelsCanvas()
598         delete temp_picon;
599         delete rotater;
602 int SetChannelsCanvas::draw(int angle)
604         set_color(RED);
605         int real_w = get_w() - box_r * 2;
606         int real_h = get_h() - box_r * 2;
607         int real_x = box_r;
608         int real_y = box_r;
610         draw_top_background(get_top_level(), 0, 0, get_w(), get_h());
611 //      draw_vframe(mwindow->theme->channel_bg_data, 0, 0);
616         int x, y, w, h;
617         char string[32];
618         set_color(mwindow->theme->channel_position_color);
619         for(int i = 0; i < thread->new_settings->session->audio_channels; i++)
620         {
621                 get_dimensions(thread->new_settings->session->achannel_positions[i], 
622                         x, 
623                         y, 
624                         w, 
625                         h);
626                 double rotate_angle = thread->new_settings->session->achannel_positions[i];
627                 rotate_angle = -rotate_angle;
628                 while(rotate_angle < 0) rotate_angle += 360;
629                 rotater->rotate(temp_picon, 
630                         mwindow->theme->channel_position_data, 
631                         rotate_angle, 
632                         0);
634                 BC_Pixmap temp_pixmap(this, 
635                         temp_picon, 
636                         PIXMAP_ALPHA,
637                         0);
638                 draw_pixmap(&temp_pixmap, x, y);
639                 sprintf(string, "%d", i + 1);
640                 draw_text(x + 2, y + box_r * 2 - 2, string);
641         }
643         if(angle > -1)
644         {
645                 sprintf(string, _("%d degrees"), angle);
646                 draw_text(this->get_w() / 2 - 40, this->get_h() / 2, string);
647         }
649         flash();
650         return 0;
653 int SetChannelsCanvas::get_dimensions(int channel_position, 
654         int &x, 
655         int &y, 
656         int &w, 
657         int &h)
659 #define MARGIN 10
660         int real_w = this->get_w() - box_r * 2 - MARGIN;
661         int real_h = this->get_h() - box_r * 2 - MARGIN;
662         float corrected_position = channel_position;
663         if(corrected_position < 0) corrected_position += 360;
664         Units::polar_to_xy((float)corrected_position, real_w / 2, x, y);
665         x += real_w / 2 + MARGIN / 2;
666         y += real_h / 2 + MARGIN / 2;
667         w = box_r * 2;
668         h = box_r * 2;
669         return 0;
672 int SetChannelsCanvas::button_press_event()
674         if(!cursor_inside()) return 0;
675 // get active channel
676         for(int i = 0; 
677                 i < thread->new_settings->session->audio_channels; 
678                 i++)
679         {
680                 int x, y, w, h;
681                 get_dimensions(thread->new_settings->session->achannel_positions[i], 
682                         x, 
683                         y, 
684                         w, 
685                         h);
686                 if(get_cursor_x() > x && get_cursor_y() > y && 
687                         get_cursor_x() < x + w && get_cursor_y() < y + h)
688                 {
689                         active_channel = i;
690                         degree_offset = (int)Units::xy_to_polar(get_cursor_x() - this->get_w() / 2, get_cursor_y() - this->get_h() / 2);
691                         degree_offset += 90;
692                         if(degree_offset >= 360) degree_offset -= 360;
693                         degree_offset -= thread->new_settings->session->achannel_positions[i];
694                         draw(thread->new_settings->session->achannel_positions[i]);
695                         return 1;
696                 }
697         }
698         return 0;
701 int SetChannelsCanvas::button_release_event()
703         if(active_channel >= 0)
704         {
705                 active_channel = -1;
706                 draw(-1);
707                 return 1;
708         }
709         return 0;
712 int SetChannelsCanvas::cursor_motion_event()
714         if(active_channel >= 0)
715         {
716 // get degrees of new channel
717                 int new_d;
718                 new_d = (int)Units::xy_to_polar(get_cursor_x() - this->get_w() / 2, get_cursor_y() - this->get_h() / 2);
719                 new_d += 90;
720                 new_d -= degree_offset;
722                 while(new_d >= 360) new_d -= 360;
723                 while(new_d < 0) new_d += 360;
725                 if(thread->new_settings->session->achannel_positions[active_channel] != new_d)
726                 {
727                         thread->new_settings->session->achannel_positions[active_channel] = new_d;
728                         draw(thread->new_settings->session->achannel_positions[active_channel]);
729                 }
730                 return 1;
731         }
732         return 0;
743 SetFrameRateTextBox::SetFrameRateTextBox(SetFormatThread *thread, int x, int y)
744  : BC_TextBox(x, y, 100, 1, (float)thread->new_settings->session->frame_rate)
746         this->thread = thread;
749 int SetFrameRateTextBox::handle_event()
751         thread->new_settings->session->frame_rate = Units::atoframerate(get_text());
752         return 1;
756 // 
757 // SetVChannels::SetVChannels(SetFormatThread *thread, int x, int y)
758 //  : BC_TextBox(x, y, 100, 1, thread->channels)
759 // {
760 //      this->thread = thread;
761 // }
762 // int SetVChannels::handle_event()
763 // {
764 //      thread->channels = atol(get_text());
765 //      return 1;
766 // }
771 ScaleSizeText::ScaleSizeText(int x, int y, SetFormatThread *thread, int *output)
772  : BC_TextBox(x, y, 100, 1, *output)
774         this->thread = thread; 
775         this->output = output; 
777 ScaleSizeText::~ScaleSizeText()
780 int ScaleSizeText::handle_event()
782         *output = atol(get_text());
783         *output /= 2;
784         *output *= 2;
785         if(*output <= 0) *output = 2;
786         if(*output > 10000) *output = 10000;
787         *output *= -1;
788         thread->update_window();
793 ScaleRatioText::ScaleRatioText(int x, 
794         int y, 
795         SetFormatThread *thread, 
796         float *output)
797  : BC_TextBox(x, y, 100, 1, *output)
799         this->thread = thread; 
800         this->output = output; 
802 ScaleRatioText::~ScaleRatioText()
805 int ScaleRatioText::handle_event()
807         *output = atof(get_text());
808         //if(*output <= 0) *output = 1;
809         if(*output > 10000) *output = 10000;
810         if(*output < -10000) *output = -10000;
811         *output *= -1;
812         thread->update_window();
813         return 1;
818 ScaleAspectAuto::ScaleAspectAuto(int x, int y, SetFormatThread *thread)
819  : BC_CheckBox(x, y, thread->auto_aspect, _("Auto"))
821         this->thread = thread; 
824 ScaleAspectAuto::~ScaleAspectAuto()
828 int ScaleAspectAuto::handle_event()
830         thread->auto_aspect = get_value();
831         thread->update_aspect();
834 ScaleAspectText::ScaleAspectText(int x, int y, SetFormatThread *thread, float *output)
835  : BC_TextBox(x, y, 70, 1, *output)
837         this->output = output;
838         this->thread = thread;
840 ScaleAspectText::~ScaleAspectText()
844 int ScaleAspectText::handle_event()
846         *output = atof(get_text());
847         return 1;
853 SetFormatApply::SetFormatApply(int x, int y, SetFormatThread *thread)
854  : BC_GenericButton(x, y, _("Apply"))
856         this->thread = thread;
859 int SetFormatApply::handle_event()
861         thread->apply_changes();
862         return 1;