r870: Merge 2.1:
[cinelerra_cv.git] / cinelerra / setformat.C
blob5d79f1dffcaf6aaa3545ebb37cdee275c8c9abd5
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);
198         window->canvas->draw();
201 void SetFormatThread::update_window()
203         int i, result, modified_item, dimension_modified = 0, ratio_modified = 0;
205         for(i = 0, result = 0; i < 2 && !result; i++)
206         {
207                 if(dimension[i] < 0)
208                 {
209                         dimension[i] *= -1;
210                         result = 1;
211                         modified_item = i;
212                         dimension_modified = 1;
213                 }
214                 if(ratio[i] < 0)
215                 {
216                         ratio[i] *= -1;
217                         result = 1;
218                         modified_item = i;
219                         ratio_modified = 1;
220                 }
221         }
223         if(result)
224         {
225                 if(dimension_modified)
226                         ratio[modified_item] = (float)dimension[modified_item] / orig_dimension[modified_item];
228                 if(ratio_modified && !constrain_ratio)
229                 {
230                         dimension[modified_item] = (int)(orig_dimension[modified_item] * ratio[modified_item]);
231                         window->dimension[modified_item]->update((int64_t)dimension[modified_item]);
232                 }
234                 for(i = 0; i < 2; i++)
235                 {
236                         if(dimension_modified ||
237                                 (i != modified_item && ratio_modified))
238                         {
239                                 if(constrain_ratio) ratio[i] = ratio[modified_item];
240                                 window->ratio[i]->update(ratio[i]);
241                         }
243                         if(ratio_modified ||
244                                 (i != modified_item && dimension_modified))
245                         {
246                                 if(constrain_ratio) 
247                                 {
248                                         dimension[i] = (int)(orig_dimension[i] * ratio[modified_item]);
249                                         window->dimension[i]->update((int64_t)dimension[i]);
250                                 }
251                         }
252                 }
253         }
255         update_aspect();
258 void SetFormatThread::update_aspect()
260         if(auto_aspect)
261         {
262                 char string[BCTEXTLEN];
263                 MWindow::create_aspect_ratio(new_settings->session->aspect_w, 
264                         new_settings->session->aspect_h, 
265                         dimension[0], 
266                         dimension[1]);
267                 sprintf(string, "%.02f", new_settings->session->aspect_w);
268                 window->aspect_w->update(string);
269                 sprintf(string, "%.02f", new_settings->session->aspect_h);
270                 window->aspect_h->update(string);
271         }
282 SetFormatWindow::SetFormatWindow(MWindow *mwindow, 
283         SetFormatThread *thread,
284         int x,
285         int y)
286  : BC_Window(PROGRAM_NAME ": Set Format",
287         x,
288         y,
289         mwindow->theme->setformat_w,
290         mwindow->theme->setformat_h,
291         -1,
292         -1,
293         0,
294         0,
295         1)
297         this->mwindow = mwindow;
298         this->thread = thread;
301 void SetFormatWindow::create_objects()
303         int x = 10, y = mwindow->theme->setformat_y1;
304         BC_TextBox *textbox;
305         BC_Title *title;
307         mwindow->theme->draw_setformat_bg(this);
311         presets = new SetFormatPresets(mwindow, 
312                 this, 
313                 x, 
314                 y);
315         presets->create_objects();
316         x = presets->x;
317         y = presets->y;
319         y = mwindow->theme->setformat_y2;
321         add_subwindow(new BC_Title(mwindow->theme->setformat_x1, 
322                 y, 
323                 _("Audio"), 
324                 LARGEFONT));
325         y = mwindow->theme->setformat_y3;
326         add_subwindow(new BC_Title(mwindow->theme->setformat_x1, 
327                 y,
328                 _("Samplerate:")));
330         y += mwindow->theme->setformat_margin;
331         add_subwindow(new BC_Title(mwindow->theme->setformat_x1, 
332                 y,
333                 _("Samplerate:")));
334         add_subwindow(sample_rate = new SetSampleRateTextBox(thread, 
335                 mwindow->theme->setformat_x2, 
336                 y));
337         add_subwindow(new SampleRatePulldown(mwindow, 
338                 sample_rate, 
339                 mwindow->theme->setformat_x2 + sample_rate->get_w(), 
340                 y));
342         y += mwindow->theme->setformat_margin;
343         add_subwindow(new BC_Title(mwindow->theme->setformat_x1, 
344                 y, 
345                 _("Channels:")));
346         add_subwindow(channels = new SetChannelsTextBox(thread, 
347                 mwindow->theme->setformat_x2, 
348                 y));
349         add_subwindow(new BC_ITumbler(channels, 
350                 1, 
351                 MAXCHANNELS, 
352                 mwindow->theme->setformat_x2 + channels->get_w(), 
353                 y));
355         y += mwindow->theme->setformat_margin;
356         add_subwindow(new BC_Title(mwindow->theme->setformat_x1, 
357                 y, 
358                 _("Channel positions:")));
359         y += mwindow->theme->setformat_margin;
360         add_subwindow(canvas = new SetChannelsCanvas(mwindow, 
361                 thread, 
362                 mwindow->theme->setformat_channels_x, 
363                 mwindow->theme->setformat_channels_y, 
364                 mwindow->theme->setformat_channels_w, 
365                 mwindow->theme->setformat_channels_h));
366         canvas->draw();
376         y = mwindow->theme->setformat_y2;
377         add_subwindow(new BC_Title(mwindow->theme->setformat_x3, 
378                 y, 
379                 _("Video"), 
380                 LARGEFONT));
382         y = mwindow->theme->setformat_y3;
383         add_subwindow(new BC_Title(mwindow->theme->setformat_x3, 
384                 y, 
385                 _("Frame rate:")));
386         add_subwindow(frame_rate = new SetFrameRateTextBox(thread, 
387                 mwindow->theme->setformat_x4, 
388                 y));
389         add_subwindow(new FrameRatePulldown(mwindow, 
390                 frame_rate, 
391                 mwindow->theme->setformat_x4 + frame_rate->get_w(), 
392                 y));
394         y += mwindow->theme->setformat_margin;
395         add_subwindow(new BC_Title(mwindow->theme->setformat_x3, 
396                 y, 
397                 _("Canvas size:")));
399         y += mwindow->theme->setformat_margin;
400         add_subwindow(title = new BC_Title(mwindow->theme->setformat_x3, y, _("Width:")));
401         add_subwindow(dimension[0] = new ScaleSizeText(mwindow->theme->setformat_x4, 
402                 y, 
403                 thread, 
404                 &(thread->dimension[0])));
406         y += mwindow->theme->setformat_margin;
407         add_subwindow(new BC_Title(mwindow->theme->setformat_x3, y, _("Height:")));
408         add_subwindow(dimension[1] = new ScaleSizeText(mwindow->theme->setformat_x4, 
409                 y, 
410                 thread, 
411                 &(thread->dimension[1])));
413         x = mwindow->theme->setformat_x4 + dimension[0]->get_w();
414         FrameSizePulldown *pulldown;
415         add_subwindow(pulldown = new FrameSizePulldown(mwindow, 
416                 dimension[0], 
417                 dimension[1], 
418                 x, 
419                 y - mwindow->theme->setformat_margin));
421         add_subwindow(new FormatSwapExtents(mwindow, 
422                 thread, 
423                 this, 
424                 x + pulldown->get_w() + 5,
425                 y - mwindow->theme->setformat_margin));
426                 
427         y += mwindow->theme->setformat_margin;
428         add_subwindow(new BC_Title(mwindow->theme->setformat_x3, 
429                 y, 
430                 _("W Ratio:")));
431         add_subwindow(ratio[0] = new ScaleRatioText(mwindow->theme->setformat_x4, 
432                 y, 
433                 thread, 
434                 &(thread->ratio[0])));
436         y += mwindow->theme->setformat_margin;
437         add_subwindow(new BC_Title(mwindow->theme->setformat_x3, 
438                 y, 
439                 _("H Ratio:")));
440         add_subwindow(ratio[1] = new ScaleRatioText(mwindow->theme->setformat_x4, 
441                 y, 
442                 thread, 
443                 &(thread->ratio[1])));
445         y += mwindow->theme->setformat_margin;
446         add_subwindow(new BC_Title(mwindow->theme->setformat_x3, 
447                 y, 
448                 _("Color model:")));
449         x = mwindow->theme->setformat_x4;
450         add_subwindow(color_model = new BC_TextBox(x, 
451                 y, 
452                 100, 
453                 1, 
454                 ""));
455         x += color_model->get_w();
456         add_subwindow(new ColormodelPulldown(mwindow, 
457                 color_model, 
458                 &thread->new_settings->session->color_model,
459                 x, 
460                 y));
462         y += mwindow->theme->setformat_margin;
463         add_subwindow(new BC_Title(mwindow->theme->setformat_x3, 
464                 y, 
465                 _("Aspect ratio:")));
466         y += mwindow->theme->setformat_margin;
467         x = mwindow->theme->setformat_x3;
468         add_subwindow(aspect_w = new ScaleAspectText(x, 
469                 y, 
470                 thread, 
471                 &(thread->new_settings->session->aspect_w)));
472         x += aspect_w->get_w() + 5;
473         add_subwindow(new BC_Title(x, y, _(":")));
474         x += 10;
475         add_subwindow(aspect_h = new ScaleAspectText(x, 
476                 y, 
477                 thread, 
478                 &(thread->new_settings->session->aspect_h)));
479         x += aspect_h->get_w();
480         add_subwindow(new AspectPulldown(mwindow, 
481                 aspect_w, 
482                 aspect_h, 
483                 x, 
484                 y));
485         x += 30;
486         add_subwindow(auto_aspect = new ScaleAspectAuto(x, y, thread));
487         y += mwindow->theme->setformat_margin;
489         // --------------------
490         add_subwindow(new BC_Title(mwindow->theme->setformat_x3, 
491                 y, 
492                 _("Interlace mode:")));
493         add_subwindow(textbox = new BC_TextBox(mwindow->theme->setformat_x4,
494                 y,
495                 140, 
496                 1, 
497                 ""));
498         add_subwindow(new InterlacemodePulldown(mwindow, 
499                 textbox,
500                 &(thread->new_settings->session->interlace_mode),
501                 (ArrayList<BC_ListBoxItem*>*)&mwindow->interlace_project_modes,
502                 mwindow->theme->setformat_x4 + textbox->get_w(), 
503                 y)); 
504         y += mwindow->theme->setformat_margin;
507         BC_OKTextButton *ok;
508         BC_CancelTextButton *cancel;
509         add_subwindow(ok = new BC_OKTextButton(this));
510         add_subwindow(cancel = new BC_CancelTextButton(this));
511         add_subwindow(new SetFormatApply((ok->get_x() + cancel->get_x()) / 2, 
512                 ok->get_y(), 
513                 thread));
514         flash();
515         show_window();
518 char* SetFormatWindow::get_preset_text()
520         return "";
537 SetFormatPresets::SetFormatPresets(MWindow *mwindow, 
538         SetFormatWindow *gui, 
539         int x, 
540         int y)
541  : FormatPresets(mwindow, 0, gui, x, y)
543         
546 SetFormatPresets::~SetFormatPresets()
550 int SetFormatPresets::handle_event()
552         format_gui->thread->update();
553         return 1;
556 EDL* SetFormatPresets::get_edl()
558         return format_gui->thread->new_settings;
575 SetSampleRateTextBox::SetSampleRateTextBox(SetFormatThread *thread, int x, int y)
576  : BC_TextBox(x, y, 100, 1, (int64_t)thread->new_settings->session->sample_rate)
578         this->thread = thread;
580 int SetSampleRateTextBox::handle_event()
582         thread->new_settings->session->sample_rate = CLIP(atol(get_text()), 1, 1000000);
583         return 1;
586 SetChannelsTextBox::SetChannelsTextBox(SetFormatThread *thread, int x, int y)
587  : BC_TextBox(x, y, 100, 1, thread->new_settings->session->audio_channels)
589         this->thread = thread;
591 int SetChannelsTextBox::handle_event()
593         int new_channels = CLIP(atoi(get_text()), 1, MAXCHANNELS);
594         
595         thread->new_settings->session->audio_channels = new_channels;
598         if(new_channels > 0)
599         {
600                 memcpy(thread->new_settings->session->achannel_positions,
601                         &thread->mwindow->preferences->channel_positions[MAXCHANNELS * (new_channels - 1)],
602                         sizeof(int) * MAXCHANNELS);
603         }
606         thread->window->canvas->draw();
607         return 1;
611 SetChannelsCanvas::SetChannelsCanvas(MWindow *mwindow, 
612         SetFormatThread *thread, 
613         int x, 
614         int y,
615         int w,
616         int h)
617  : BC_SubWindow(x, 
618         y, 
619         w,
620         h)
622         this->thread = thread;
623         this->mwindow = mwindow;
624         active_channel = -1;
625         box_r = mwindow->theme->channel_position_data->get_w() / 2;
626         temp_picon = new VFrame(0, 
627                 mwindow->theme->channel_position_data->get_w(),
628                 mwindow->theme->channel_position_data->get_h(),
629                 mwindow->theme->channel_position_data->get_color_model());
630         rotater = new RotateFrame(mwindow->preferences->processors,
631                 mwindow->theme->channel_position_data->get_w(),
632                 mwindow->theme->channel_position_data->get_h());
634 SetChannelsCanvas::~SetChannelsCanvas()
636         delete temp_picon;
637         delete rotater;
640 int SetChannelsCanvas::draw(int angle)
642         set_color(RED);
643         int real_w = get_w() - box_r * 2;
644         int real_h = get_h() - box_r * 2;
645         int real_x = box_r;
646         int real_y = box_r;
648         draw_top_background(get_top_level(), 0, 0, get_w(), get_h());
649 //      draw_vframe(mwindow->theme->channel_bg_data, 0, 0);
654         int x, y, w, h;
655         char string[32];
656         set_color(mwindow->theme->channel_position_color);
657         for(int i = 0; i < thread->new_settings->session->audio_channels; i++)
658         {
659                 get_dimensions(thread->new_settings->session->achannel_positions[i], 
660                         x, 
661                         y, 
662                         w, 
663                         h);
664                 double rotate_angle = thread->new_settings->session->achannel_positions[i];
665                 rotate_angle = -rotate_angle;
666                 while(rotate_angle < 0) rotate_angle += 360;
667                 rotater->rotate(temp_picon, 
668                         mwindow->theme->channel_position_data, 
669                         rotate_angle, 
670                         0);
672                 BC_Pixmap temp_pixmap(this, 
673                         temp_picon, 
674                         PIXMAP_ALPHA,
675                         0);
676                 draw_pixmap(&temp_pixmap, x, y);
677                 sprintf(string, "%d", i + 1);
678                 draw_text(x + 2, y + box_r * 2 - 2, string);
679         }
681         if(angle > -1)
682         {
683                 sprintf(string, _("%d degrees"), angle);
684                 draw_text(this->get_w() / 2 - 40, this->get_h() / 2, string);
685         }
687         flash();
688         return 0;
691 int SetChannelsCanvas::get_dimensions(int channel_position, 
692         int &x, 
693         int &y, 
694         int &w, 
695         int &h)
697 #define MARGIN 10
698         int real_w = this->get_w() - box_r * 2 - MARGIN;
699         int real_h = this->get_h() - box_r * 2 - MARGIN;
700         float corrected_position = channel_position;
701         if(corrected_position < 0) corrected_position += 360;
702         Units::polar_to_xy((float)corrected_position, real_w / 2, x, y);
703         x += real_w / 2 + MARGIN / 2;
704         y += real_h / 2 + MARGIN / 2;
705         w = box_r * 2;
706         h = box_r * 2;
707         return 0;
710 int SetChannelsCanvas::button_press_event()
712         if(!cursor_inside()) return 0;
713 // get active channel
714         for(int i = 0; 
715                 i < thread->new_settings->session->audio_channels; 
716                 i++)
717         {
718                 int x, y, w, h;
719                 get_dimensions(thread->new_settings->session->achannel_positions[i], 
720                         x, 
721                         y, 
722                         w, 
723                         h);
724                 if(get_cursor_x() > x && get_cursor_y() > y && 
725                         get_cursor_x() < x + w && get_cursor_y() < y + h)
726                 {
727                         active_channel = i;
728                         degree_offset = (int)Units::xy_to_polar(get_cursor_x() - this->get_w() / 2, get_cursor_y() - this->get_h() / 2);
729                         degree_offset += 90;
730                         if(degree_offset >= 360) degree_offset -= 360;
731                         degree_offset -= thread->new_settings->session->achannel_positions[i];
732                         draw(thread->new_settings->session->achannel_positions[i]);
733                         return 1;
734                 }
735         }
736         return 0;
739 int SetChannelsCanvas::button_release_event()
741         if(active_channel >= 0)
742         {
743                 active_channel = -1;
744                 draw(-1);
745                 return 1;
746         }
747         return 0;
750 int SetChannelsCanvas::cursor_motion_event()
752         if(active_channel >= 0)
753         {
754 // get degrees of new channel
755                 int new_d;
756                 new_d = (int)Units::xy_to_polar(get_cursor_x() - this->get_w() / 2, get_cursor_y() - this->get_h() / 2);
757                 new_d += 90;
758                 new_d -= degree_offset;
760                 while(new_d >= 360) new_d -= 360;
761                 while(new_d < 0) new_d += 360;
763                 if(thread->new_settings->session->achannel_positions[active_channel] != new_d)
764                 {
765                         thread->new_settings->session->achannel_positions[active_channel] = new_d;
766                         int new_channels = thread->new_settings->session->audio_channels;
767                         memcpy(&thread->mwindow->preferences->channel_positions[MAXCHANNELS * (new_channels - 1)],
768                                 thread->new_settings->session->achannel_positions,
769                                 sizeof(int) * MAXCHANNELS);
770                         draw(thread->new_settings->session->achannel_positions[active_channel]);
771                 }
772                 return 1;
773         }
774         return 0;
785 SetFrameRateTextBox::SetFrameRateTextBox(SetFormatThread *thread, int x, int y)
786  : BC_TextBox(x, y, 100, 1, (float)thread->new_settings->session->frame_rate)
788         this->thread = thread;
791 int SetFrameRateTextBox::handle_event()
793         thread->new_settings->session->frame_rate = Units::atoframerate(get_text());
794         return 1;
798 // 
799 // SetVChannels::SetVChannels(SetFormatThread *thread, int x, int y)
800 //  : BC_TextBox(x, y, 100, 1, thread->channels)
801 // {
802 //      this->thread = thread;
803 // }
804 // int SetVChannels::handle_event()
805 // {
806 //      thread->channels = atol(get_text());
807 //      return 1;
808 // }
813 ScaleSizeText::ScaleSizeText(int x, int y, SetFormatThread *thread, int *output)
814  : BC_TextBox(x, y, 100, 1, *output)
816         this->thread = thread; 
817         this->output = output; 
819 ScaleSizeText::~ScaleSizeText()
822 int ScaleSizeText::handle_event()
824         *output = atol(get_text());
825         *output /= 2;
826         *output *= 2;
827         if(*output <= 0) *output = 2;
828         if(*output > 10000) *output = 10000;
829         *output *= -1;
830         thread->update_window();
835 ScaleRatioText::ScaleRatioText(int x, 
836         int y, 
837         SetFormatThread *thread, 
838         float *output)
839  : BC_TextBox(x, y, 100, 1, *output)
841         this->thread = thread; 
842         this->output = output; 
844 ScaleRatioText::~ScaleRatioText()
847 int ScaleRatioText::handle_event()
849         *output = atof(get_text());
850         //if(*output <= 0) *output = 1;
851         if(*output > 10000) *output = 10000;
852         if(*output < -10000) *output = -10000;
853         *output *= -1;
854         thread->update_window();
855         return 1;
860 ScaleAspectAuto::ScaleAspectAuto(int x, int y, SetFormatThread *thread)
861  : BC_CheckBox(x, y, thread->auto_aspect, _("Auto"))
863         this->thread = thread; 
866 ScaleAspectAuto::~ScaleAspectAuto()
870 int ScaleAspectAuto::handle_event()
872         thread->auto_aspect = get_value();
873         thread->update_aspect();
876 ScaleAspectText::ScaleAspectText(int x, int y, SetFormatThread *thread, float *output)
877  : BC_TextBox(x, y, 70, 1, *output)
879         this->output = output;
880         this->thread = thread;
882 ScaleAspectText::~ScaleAspectText()
886 int ScaleAspectText::handle_event()
888         *output = atof(get_text());
889         return 1;
897 SetFormatApply::SetFormatApply(int x, int y, SetFormatThread *thread)
898  : BC_GenericButton(x, y, _("Apply"))
900         this->thread = thread;
903 int SetFormatApply::handle_event()
905         thread->apply_changes();
906         return 1;
921 FormatSwapExtents::FormatSwapExtents(MWindow *mwindow, 
922         SetFormatThread *thread,
923         SetFormatWindow *gui, 
924         int x, 
925         int y)
926  : BC_Button(x, y, mwindow->theme->get_image_set("swap_extents"))
928         this->mwindow = mwindow;
929         this->thread = thread;
930         this->gui = gui;
931         set_tooltip("Swap dimensions");
934 int FormatSwapExtents::handle_event()
936         int w = thread->dimension[0];
937         int h = thread->dimension[1];
938         thread->dimension[0] = -h;
939         gui->dimension[0]->update((int64_t)h);
940         gui->dimension[1]->update((int64_t)w);
941         thread->update_window();
942         thread->dimension[1] = -w;
943         thread->update_window();
944         return 1;