00001 #include "clip.h"
00002 #include "cwindow.h"
00003 #include "cwindowgui.h"
00004 #include "datatype.h"
00005 #include "bchash.h"
00006 #include "edl.h"
00007 #include "edlsession.h"
00008 #include "formatpresets.h"
00009 #include "language.h"
00010 #include "levelwindow.h"
00011 #include "levelwindowgui.h"
00012 #include "mainerror.h"
00013 #include "mainundo.h"
00014 #include "mutex.h"
00015 #include "mwindow.h"
00016 #include "mwindowgui.h"
00017 #include "new.h"
00018 #include "preferences.h"
00019 #include "rotateframe.h"
00020 #include "setformat.h"
00021 #include "theme.h"
00022 #include "vframe.h"
00023 #include "vwindow.h"
00024 #include "vwindowgui.h"
00025
00026
00027
00028 SetFormat::SetFormat(MWindow *mwindow)
00029 : BC_MenuItem(_("Format..."), "Shift-F", 'F')
00030 {
00031 set_shift(1);
00032 this->mwindow = mwindow;
00033 thread = new SetFormatThread(mwindow);
00034 }
00035
00036 int SetFormat::handle_event()
00037 {
00038 if(!thread->running())
00039 {
00040 thread->start();
00041 }
00042 else
00043 {
00044
00045
00046 if(thread->window)
00047 {
00048 thread->window_lock->lock("SetFormat::handle_event");
00049 thread->window->lock_window("SetFormat::handle_event");
00050 thread->window->raise_window();
00051 thread->window->unlock_window();
00052 thread->window_lock->unlock();
00053 }
00054 }
00055 return 1;
00056 }
00057
00058 SetFormatThread::SetFormatThread(MWindow *mwindow)
00059 : Thread()
00060 {
00061 this->mwindow = mwindow;
00062 window_lock = new Mutex("SetFormatThread::window_lock");
00063 window = 0;
00064 }
00065
00066 void SetFormatThread::run()
00067 {
00068 orig_dimension[0] = dimension[0] = mwindow->edl->session->output_w;
00069 orig_dimension[1] = dimension[1] = mwindow->edl->session->output_h;
00070 auto_aspect = mwindow->defaults->get("AUTOASPECT", 0);
00071 constrain_ratio = 0;
00072 ratio[0] = ratio[1] = 1;
00073
00074 new_settings = new EDL;
00075 new_settings->create_objects();
00076 new_settings->copy_session(mwindow->edl);
00077
00078
00079 int x = mwindow->gui->get_abs_cursor_x(1) - mwindow->theme->setformat_w / 2;
00080 int y = mwindow->gui->get_abs_cursor_y(1) - mwindow->theme->setformat_h / 2;
00081
00082 window_lock->lock("SetFormatThread::run 1");
00083 window = new SetFormatWindow(mwindow, this, x, y);
00084 window->create_objects();
00085 window_lock->unlock();
00086
00087 int result = window->run_window();
00088
00089
00090 window_lock->lock("SetFormatThread::run 2");
00091 delete window;
00092 window = 0;
00093 window_lock->unlock();
00094
00095
00096 if(!result)
00097 {
00098 apply_changes();
00099 }
00100
00101 mwindow->defaults->update("AUTOASPECT", auto_aspect);
00102 delete new_settings;
00103 }
00104
00105 void SetFormatThread::apply_changes()
00106 {
00107 double new_samplerate = new_settings->session->sample_rate;
00108 double old_samplerate = mwindow->edl->session->sample_rate;
00109 double new_framerate = new_settings->session->frame_rate;
00110 double old_framerate = mwindow->edl->session->frame_rate;
00111 int new_channels = new_settings->session->audio_channels;
00112 CLAMP(new_channels, 1, MAXCHANNELS);
00113
00114 memcpy(&mwindow->preferences->channel_positions[MAXCHANNELS * (new_channels - 1)],
00115 new_settings->session->achannel_positions,
00116 sizeof(int) * MAXCHANNELS);
00117
00118
00119 mwindow->edl->copy_session(new_settings, 1);
00120 mwindow->edl->session->output_w = dimension[0];
00121 mwindow->edl->session->output_h = dimension[1];
00122 mwindow->edl->rechannel();
00123 mwindow->edl->resample(old_samplerate, new_samplerate, TRACK_AUDIO);
00124 mwindow->edl->resample(old_framerate, new_framerate, TRACK_VIDEO);
00125 mwindow->save_backup();
00126 mwindow->undo->update_undo(_("set format"), LOAD_ALL);
00127
00128
00129 mwindow->restart_brender();
00130 mwindow->gui->lock_window("SetFormatThread::apply_changes");
00131 mwindow->gui->update(1,
00132 1,
00133 1,
00134 1,
00135 1,
00136 1,
00137 0);
00138 mwindow->gui->unlock_window();
00139
00140 mwindow->cwindow->gui->lock_window("SetFormatThread::apply_changes");
00141 mwindow->cwindow->gui->resize_event(mwindow->cwindow->gui->get_w(),
00142 mwindow->cwindow->gui->get_h());
00143 mwindow->cwindow->gui->meters->set_meters(new_channels, 1);
00144 mwindow->cwindow->gui->slider->set_position();
00145 mwindow->cwindow->gui->flush();
00146 mwindow->cwindow->gui->unlock_window();
00147
00148 mwindow->vwindow->gui->lock_window("SetFormatThread::apply_changes");
00149 mwindow->vwindow->gui->resize_event(mwindow->vwindow->gui->get_w(),
00150 mwindow->vwindow->gui->get_h());
00151 mwindow->vwindow->gui->meters->set_meters(new_channels, 1);
00152 mwindow->vwindow->gui->flush();
00153 mwindow->vwindow->gui->unlock_window();
00154
00155 mwindow->lwindow->gui->lock_window("SetFormatThread::apply_changes");
00156 mwindow->lwindow->gui->panel->set_meters(new_channels, 1);
00157 mwindow->lwindow->gui->flush();
00158 mwindow->lwindow->gui->unlock_window();
00159
00160
00161 if(((mwindow->edl->session->output_w % 4) ||
00162 (mwindow->edl->session->output_h % 4)) &&
00163 mwindow->edl->session->playback_config->vconfig->driver == PLAYBACK_X11_GL)
00164 {
00165 MainError::show_error(
00166 _("This project's dimensions are not multiples of 4 so\n"
00167 "it can't be rendered by OpenGL."));
00168 }
00169
00170
00171
00172 mwindow->sync_parameters(CHANGE_ALL);
00173 }
00174
00175 void SetFormatThread::update()
00176 {
00177 window->sample_rate->update(new_settings->session->sample_rate);
00178 window->channels->update((int64_t)new_settings->session->audio_channels);
00179 window->frame_rate->update((float)new_settings->session->frame_rate);
00180
00181 auto_aspect = 0;
00182 window->auto_aspect->update(0);
00183
00184 constrain_ratio = 0;
00185 dimension[0] = new_settings->session->output_w;
00186 window->dimension[0]->update((int64_t)dimension[0]);
00187 dimension[1] = new_settings->session->output_h;
00188 window->dimension[1]->update((int64_t)dimension[1]);
00189
00190 ratio[0] = (float)dimension[0] / orig_dimension[0];
00191 window->ratio[0]->update(ratio[0]);
00192 ratio[1] = (float)dimension[1] / orig_dimension[1];
00193 window->ratio[1]->update(ratio[1]);
00194
00195 window->aspect_w->update(new_settings->session->aspect_w);
00196 window->aspect_h->update(new_settings->session->aspect_h);
00197 window->interlace_pulldown->update(new_settings->session->interlace_mode);
00198
00199 window->canvas->draw();
00200 }
00201
00202 void SetFormatThread::update_window()
00203 {
00204 int i, result, modified_item, dimension_modified = 0, ratio_modified = 0;
00205
00206 for(i = 0, result = 0; i < 2 && !result; i++)
00207 {
00208 if(dimension[i] < 0)
00209 {
00210 dimension[i] *= -1;
00211 result = 1;
00212 modified_item = i;
00213 dimension_modified = 1;
00214 }
00215 if(ratio[i] < 0)
00216 {
00217 ratio[i] *= -1;
00218 result = 1;
00219 modified_item = i;
00220 ratio_modified = 1;
00221 }
00222 }
00223
00224 if(result)
00225 {
00226 if(dimension_modified)
00227 ratio[modified_item] = (float)dimension[modified_item] / orig_dimension[modified_item];
00228
00229 if(ratio_modified && !constrain_ratio)
00230 {
00231 dimension[modified_item] = (int)(orig_dimension[modified_item] * ratio[modified_item]);
00232 window->dimension[modified_item]->update((int64_t)dimension[modified_item]);
00233 }
00234
00235 for(i = 0; i < 2; i++)
00236 {
00237 if(dimension_modified ||
00238 (i != modified_item && ratio_modified))
00239 {
00240 if(constrain_ratio) ratio[i] = ratio[modified_item];
00241 window->ratio[i]->update(ratio[i]);
00242 }
00243
00244 if(ratio_modified ||
00245 (i != modified_item && dimension_modified))
00246 {
00247 if(constrain_ratio)
00248 {
00249 dimension[i] = (int)(orig_dimension[i] * ratio[modified_item]);
00250 window->dimension[i]->update((int64_t)dimension[i]);
00251 }
00252 }
00253 }
00254 }
00255
00256 update_aspect();
00257 }
00258
00259 void SetFormatThread::update_aspect()
00260 {
00261 if(auto_aspect)
00262 {
00263 char string[BCTEXTLEN];
00264 MWindow::create_aspect_ratio(new_settings->session->aspect_w,
00265 new_settings->session->aspect_h,
00266 dimension[0],
00267 dimension[1]);
00268 sprintf(string, "%.02f", new_settings->session->aspect_w);
00269 window->aspect_w->update(string);
00270 sprintf(string, "%.02f", new_settings->session->aspect_h);
00271 window->aspect_h->update(string);
00272 }
00273 }
00274
00275
00276
00277
00278
00279
00280
00281
00282
00283 SetFormatWindow::SetFormatWindow(MWindow *mwindow,
00284 SetFormatThread *thread,
00285 int x,
00286 int y)
00287 : BC_Window(PROGRAM_NAME ": Set Format",
00288 x,
00289 y,
00290 mwindow->theme->setformat_w,
00291 mwindow->theme->setformat_h,
00292 -1,
00293 -1,
00294 0,
00295 0,
00296 1)
00297 {
00298 this->mwindow = mwindow;
00299 this->thread = thread;
00300 }
00301
00302 void SetFormatWindow::create_objects()
00303 {
00304 int x = 10, y = mwindow->theme->setformat_y1;
00305 BC_TextBox *textbox;
00306 BC_Title *title;
00307
00308 mwindow->theme->draw_setformat_bg(this);
00309
00310
00311
00312 presets = new SetFormatPresets(mwindow,
00313 this,
00314 x,
00315 y);
00316 presets->create_objects();
00317 x = presets->x;
00318 y = presets->y;
00319
00320 y = mwindow->theme->setformat_y2;
00321
00322 add_subwindow(new BC_Title(mwindow->theme->setformat_x1,
00323 y,
00324 _("Audio"),
00325 LARGEFONT));
00326 y = mwindow->theme->setformat_y3;
00327
00328 add_subwindow(new BC_Title(mwindow->theme->setformat_x1,
00329 y,
00330 _("Samplerate:")));
00331 add_subwindow(sample_rate = new SetSampleRateTextBox(thread,
00332 mwindow->theme->setformat_x2,
00333 y));
00334 add_subwindow(new SampleRatePulldown(mwindow,
00335 sample_rate,
00336 mwindow->theme->setformat_x2 + sample_rate->get_w(),
00337 y));
00338
00339 y += mwindow->theme->setformat_margin;
00340 add_subwindow(new BC_Title(mwindow->theme->setformat_x1,
00341 y,
00342 _("Channels:")));
00343 add_subwindow(channels = new SetChannelsTextBox(thread,
00344 mwindow->theme->setformat_x2,
00345 y));
00346 add_subwindow(new BC_ITumbler(channels,
00347 1,
00348 MAXCHANNELS,
00349 mwindow->theme->setformat_x2 + channels->get_w(),
00350 y));
00351
00352 y += mwindow->theme->setformat_margin;
00353 add_subwindow(new BC_Title(mwindow->theme->setformat_x1,
00354 y,
00355 _("Channel positions:")));
00356 y += mwindow->theme->setformat_margin;
00357 add_subwindow(canvas = new SetChannelsCanvas(mwindow,
00358 thread,
00359 mwindow->theme->setformat_channels_x,
00360 mwindow->theme->setformat_channels_y,
00361 mwindow->theme->setformat_channels_w,
00362 mwindow->theme->setformat_channels_h));
00363 canvas->draw();
00364
00365
00366
00367
00368
00369
00370
00371
00372
00373 y = mwindow->theme->setformat_y2;
00374 add_subwindow(new BC_Title(mwindow->theme->setformat_x3,
00375 y,
00376 _("Video"),
00377 LARGEFONT));
00378
00379 y = mwindow->theme->setformat_y3;
00380 add_subwindow(new BC_Title(mwindow->theme->setformat_x3,
00381 y,
00382 _("Frame rate:")));
00383 add_subwindow(frame_rate = new SetFrameRateTextBox(thread,
00384 mwindow->theme->setformat_x4,
00385 y));
00386 add_subwindow(new FrameRatePulldown(mwindow,
00387 frame_rate,
00388 mwindow->theme->setformat_x4 + frame_rate->get_w(),
00389 y));
00390
00391 y += mwindow->theme->setformat_margin;
00392 add_subwindow(new BC_Title(mwindow->theme->setformat_x3,
00393 y,
00394 _("Canvas size:")));
00395
00396 y += mwindow->theme->setformat_margin;
00397 add_subwindow(title = new BC_Title(mwindow->theme->setformat_x3, y, _("Width:")));
00398 add_subwindow(dimension[0] = new ScaleSizeText(mwindow->theme->setformat_x4,
00399 y,
00400 thread,
00401 &(thread->dimension[0])));
00402
00403 y += mwindow->theme->setformat_margin;
00404 add_subwindow(new BC_Title(mwindow->theme->setformat_x3, y, _("Height:")));
00405 add_subwindow(dimension[1] = new ScaleSizeText(mwindow->theme->setformat_x4,
00406 y,
00407 thread,
00408 &(thread->dimension[1])));
00409
00410 x = mwindow->theme->setformat_x4 + dimension[0]->get_w();
00411 FrameSizePulldown *pulldown;
00412 add_subwindow(pulldown = new FrameSizePulldown(mwindow,
00413 dimension[0],
00414 dimension[1],
00415 x,
00416 y - mwindow->theme->setformat_margin));
00417
00418 add_subwindow(new FormatSwapExtents(mwindow,
00419 thread,
00420 this,
00421 x + pulldown->get_w() + 5,
00422 y - mwindow->theme->setformat_margin));
00423
00424 y += mwindow->theme->setformat_margin;
00425 add_subwindow(new BC_Title(mwindow->theme->setformat_x3,
00426 y,
00427 _("W Ratio:")));
00428 add_subwindow(ratio[0] = new ScaleRatioText(mwindow->theme->setformat_x4,
00429 y,
00430 thread,
00431 &(thread->ratio[0])));
00432
00433 y += mwindow->theme->setformat_margin;
00434 add_subwindow(new BC_Title(mwindow->theme->setformat_x3,
00435 y,
00436 _("H Ratio:")));
00437 add_subwindow(ratio[1] = new ScaleRatioText(mwindow->theme->setformat_x4,
00438 y,
00439 thread,
00440 &(thread->ratio[1])));
00441
00442 y += mwindow->theme->setformat_margin;
00443 add_subwindow(new BC_Title(mwindow->theme->setformat_x3,
00444 y,
00445 _("Color model:")));
00446 x = mwindow->theme->setformat_x4;
00447 add_subwindow(color_model = new BC_TextBox(x,
00448 y,
00449 100,
00450 1,
00451 ""));
00452 x += color_model->get_w();
00453 add_subwindow(new ColormodelPulldown(mwindow,
00454 color_model,
00455 &thread->new_settings->session->color_model,
00456 x,
00457 y));
00458
00459 y += mwindow->theme->setformat_margin;
00460 add_subwindow(new BC_Title(mwindow->theme->setformat_x3,
00461 y,
00462 _("Aspect ratio:")));
00463 y += mwindow->theme->setformat_margin;
00464 x = mwindow->theme->setformat_x3;
00465 add_subwindow(aspect_w = new ScaleAspectText(x,
00466 y,
00467 thread,
00468 &(thread->new_settings->session->aspect_w)));
00469 x += aspect_w->get_w() + 5;
00470 add_subwindow(new BC_Title(x, y, _(":")));
00471 x += 10;
00472 add_subwindow(aspect_h = new ScaleAspectText(x,
00473 y,
00474 thread,
00475 &(thread->new_settings->session->aspect_h)));
00476 x += aspect_h->get_w();
00477 add_subwindow(new AspectPulldown(mwindow,
00478 aspect_w,
00479 aspect_h,
00480 x,
00481 y));
00482 x += 30;
00483 add_subwindow(auto_aspect = new ScaleAspectAuto(x, y, thread));
00484 y += mwindow->theme->setformat_margin;
00485
00486
00487 add_subwindow(new BC_Title(mwindow->theme->setformat_x3,
00488 y,
00489 _("Interlace mode:")));
00490 add_subwindow(textbox = new BC_TextBox(mwindow->theme->setformat_x4,
00491 y,
00492 140,
00493 1,
00494 ""));
00495 add_subwindow(interlace_pulldown = new InterlacemodePulldown(mwindow,
00496 textbox,
00497 &(thread->new_settings->session->interlace_mode),
00498 (ArrayList<BC_ListBoxItem*>*)&mwindow->interlace_project_modes,
00499 mwindow->theme->setformat_x4 + textbox->get_w(),
00500 y));
00501 y += mwindow->theme->setformat_margin;
00502
00503
00504 BC_OKTextButton *ok;
00505 BC_CancelTextButton *cancel;
00506 add_subwindow(ok = new BC_OKTextButton(this));
00507 add_subwindow(cancel = new BC_CancelTextButton(this));
00508 add_subwindow(new SetFormatApply((ok->get_x() + cancel->get_x()) / 2,
00509 ok->get_y(),
00510 thread));
00511 flash();
00512 show_window();
00513 }
00514
00515 char* SetFormatWindow::get_preset_text()
00516 {
00517 return "";
00518 }
00519
00520
00521
00522
00523
00524
00525
00526
00527
00528
00529
00530
00531
00532
00533
00534 SetFormatPresets::SetFormatPresets(MWindow *mwindow,
00535 SetFormatWindow *gui,
00536 int x,
00537 int y)
00538 : FormatPresets(mwindow, 0, gui, x, y)
00539 {
00540
00541 }
00542
00543 SetFormatPresets::~SetFormatPresets()
00544 {
00545 }
00546
00547 int SetFormatPresets::handle_event()
00548 {
00549 format_gui->thread->update();
00550 return 1;
00551 }
00552
00553 EDL* SetFormatPresets::get_edl()
00554 {
00555 return format_gui->thread->new_settings;
00556 }
00557
00558
00559
00560
00561
00562
00563
00564
00565
00566
00567
00568
00569
00570
00571
00572 SetSampleRateTextBox::SetSampleRateTextBox(SetFormatThread *thread, int x, int y)
00573 : BC_TextBox(x, y, 100, 1, (int64_t)thread->new_settings->session->sample_rate)
00574 {
00575 this->thread = thread;
00576 }
00577 int SetSampleRateTextBox::handle_event()
00578 {
00579 thread->new_settings->session->sample_rate = CLIP(atol(get_text()), 1, 1000000);
00580 return 1;
00581 }
00582
00583 SetChannelsTextBox::SetChannelsTextBox(SetFormatThread *thread, int x, int y)
00584 : BC_TextBox(x, y, 100, 1, thread->new_settings->session->audio_channels)
00585 {
00586 this->thread = thread;
00587 }
00588 int SetChannelsTextBox::handle_event()
00589 {
00590 int new_channels = CLIP(atoi(get_text()), 1, MAXCHANNELS);
00591
00592 thread->new_settings->session->audio_channels = new_channels;
00593
00594
00595 if(new_channels > 0)
00596 {
00597 memcpy(thread->new_settings->session->achannel_positions,
00598 &thread->mwindow->preferences->channel_positions[MAXCHANNELS * (new_channels - 1)],
00599 sizeof(int) * MAXCHANNELS);
00600 }
00601
00602
00603 thread->window->canvas->draw();
00604 return 1;
00605 }
00606
00607
00608 SetChannelsCanvas::SetChannelsCanvas(MWindow *mwindow,
00609 SetFormatThread *thread,
00610 int x,
00611 int y,
00612 int w,
00613 int h)
00614 : BC_SubWindow(x,
00615 y,
00616 w,
00617 h)
00618 {
00619 this->thread = thread;
00620 this->mwindow = mwindow;
00621 active_channel = -1;
00622 box_r = mwindow->theme->channel_position_data->get_w() / 2;
00623 temp_picon = new VFrame(0,
00624 mwindow->theme->channel_position_data->get_w(),
00625 mwindow->theme->channel_position_data->get_h(),
00626 mwindow->theme->channel_position_data->get_color_model());
00627 rotater = new RotateFrame(mwindow->preferences->processors,
00628 mwindow->theme->channel_position_data->get_w(),
00629 mwindow->theme->channel_position_data->get_h());
00630 }
00631 SetChannelsCanvas::~SetChannelsCanvas()
00632 {
00633 delete temp_picon;
00634 delete rotater;
00635 }
00636
00637 int SetChannelsCanvas::draw(int angle)
00638 {
00639 set_color(RED);
00640 int real_w = get_w() - box_r * 2;
00641 int real_h = get_h() - box_r * 2;
00642 int real_x = box_r;
00643 int real_y = box_r;
00644
00645 draw_top_background(get_top_level(), 0, 0, get_w(), get_h());
00646
00647
00648
00649
00650
00651 int x, y, w, h;
00652 char string[32];
00653 set_color(mwindow->theme->channel_position_color);
00654 for(int i = 0; i < thread->new_settings->session->audio_channels; i++)
00655 {
00656 get_dimensions(thread->new_settings->session->achannel_positions[i],
00657 x,
00658 y,
00659 w,
00660 h);
00661 double rotate_angle = thread->new_settings->session->achannel_positions[i];
00662 rotate_angle = -rotate_angle;
00663 while(rotate_angle < 0) rotate_angle += 360;
00664 rotater->rotate(temp_picon,
00665 mwindow->theme->channel_position_data,
00666 rotate_angle,
00667 0);
00668
00669 BC_Pixmap temp_pixmap(this,
00670 temp_picon,
00671 PIXMAP_ALPHA,
00672 0);
00673 draw_pixmap(&temp_pixmap, x, y);
00674 sprintf(string, "%d", i + 1);
00675 draw_text(x + 2, y + box_r * 2 - 2, string);
00676 }
00677
00678 if(angle > -1)
00679 {
00680 sprintf(string, _("%d degrees"), angle);
00681 draw_text(this->get_w() / 2 - 40, this->get_h() / 2, string);
00682 }
00683
00684 flash();
00685 return 0;
00686 }
00687
00688 int SetChannelsCanvas::get_dimensions(int channel_position,
00689 int &x,
00690 int &y,
00691 int &w,
00692 int &h)
00693 {
00694 #define MARGIN 10
00695 int real_w = this->get_w() - box_r * 2 - MARGIN;
00696 int real_h = this->get_h() - box_r * 2 - MARGIN;
00697 float corrected_position = channel_position;
00698 if(corrected_position < 0) corrected_position += 360;
00699 Units::polar_to_xy((float)corrected_position, real_w / 2, x, y);
00700 x += real_w / 2 + MARGIN / 2;
00701 y += real_h / 2 + MARGIN / 2;
00702 w = box_r * 2;
00703 h = box_r * 2;
00704 return 0;
00705 }
00706
00707 int SetChannelsCanvas::button_press_event()
00708 {
00709 if(!cursor_inside()) return 0;
00710
00711 for(int i = 0;
00712 i < thread->new_settings->session->audio_channels;
00713 i++)
00714 {
00715 int x, y, w, h;
00716 get_dimensions(thread->new_settings->session->achannel_positions[i],
00717 x,
00718 y,
00719 w,
00720 h);
00721 if(get_cursor_x() > x && get_cursor_y() > y &&
00722 get_cursor_x() < x + w && get_cursor_y() < y + h)
00723 {
00724 active_channel = i;
00725 degree_offset = (int)Units::xy_to_polar(get_cursor_x() - this->get_w() / 2, get_cursor_y() - this->get_h() / 2);
00726 degree_offset += 90;
00727 if(degree_offset >= 360) degree_offset -= 360;
00728 degree_offset -= thread->new_settings->session->achannel_positions[i];
00729 draw(thread->new_settings->session->achannel_positions[i]);
00730 return 1;
00731 }
00732 }
00733 return 0;
00734 }
00735
00736 int SetChannelsCanvas::button_release_event()
00737 {
00738 if(active_channel >= 0)
00739 {
00740 active_channel = -1;
00741 draw(-1);
00742 return 1;
00743 }
00744 return 0;
00745 }
00746
00747 int SetChannelsCanvas::cursor_motion_event()
00748 {
00749 if(active_channel >= 0)
00750 {
00751
00752 int new_d;
00753 new_d = (int)Units::xy_to_polar(get_cursor_x() - this->get_w() / 2, get_cursor_y() - this->get_h() / 2);
00754 new_d += 90;
00755 new_d -= degree_offset;
00756
00757 while(new_d >= 360) new_d -= 360;
00758 while(new_d < 0) new_d += 360;
00759
00760 if(thread->new_settings->session->achannel_positions[active_channel] != new_d)
00761 {
00762 thread->new_settings->session->achannel_positions[active_channel] = new_d;
00763 int new_channels = thread->new_settings->session->audio_channels;
00764 memcpy(&thread->mwindow->preferences->channel_positions[MAXCHANNELS * (new_channels - 1)],
00765 thread->new_settings->session->achannel_positions,
00766 sizeof(int) * MAXCHANNELS);
00767 draw(thread->new_settings->session->achannel_positions[active_channel]);
00768 }
00769 return 1;
00770 }
00771 return 0;
00772 }
00773
00774
00775
00776
00777
00778
00779
00780
00781
00782 SetFrameRateTextBox::SetFrameRateTextBox(SetFormatThread *thread, int x, int y)
00783 : BC_TextBox(x, y, 100, 1, (float)thread->new_settings->session->frame_rate)
00784 {
00785 this->thread = thread;
00786 }
00787
00788 int SetFrameRateTextBox::handle_event()
00789 {
00790 thread->new_settings->session->frame_rate = Units::atoframerate(get_text());
00791 return 1;
00792 }
00793
00794
00795
00796
00797
00798
00799
00800
00801
00802
00803
00804
00805
00806
00807
00808
00809
00810 ScaleSizeText::ScaleSizeText(int x, int y, SetFormatThread *thread, int *output)
00811 : BC_TextBox(x, y, 100, 1, *output)
00812 {
00813 this->thread = thread;
00814 this->output = output;
00815 }
00816 ScaleSizeText::~ScaleSizeText()
00817 {
00818 }
00819 int ScaleSizeText::handle_event()
00820 {
00821 *output = atol(get_text());
00822 *output /= 2;
00823 *output *= 2;
00824 if(*output <= 0) *output = 2;
00825 if(*output > 10000) *output = 10000;
00826 *output *= -1;
00827 thread->update_window();
00828 }
00829
00830
00831
00832 ScaleRatioText::ScaleRatioText(int x,
00833 int y,
00834 SetFormatThread *thread,
00835 float *output)
00836 : BC_TextBox(x, y, 100, 1, *output)
00837 {
00838 this->thread = thread;
00839 this->output = output;
00840 }
00841 ScaleRatioText::~ScaleRatioText()
00842 {
00843 }
00844 int ScaleRatioText::handle_event()
00845 {
00846 *output = atof(get_text());
00847
00848 if(*output > 10000) *output = 10000;
00849 if(*output < -10000) *output = -10000;
00850 *output *= -1;
00851 thread->update_window();
00852 return 1;
00853 }
00854
00855
00856
00857 ScaleAspectAuto::ScaleAspectAuto(int x, int y, SetFormatThread *thread)
00858 : BC_CheckBox(x, y, thread->auto_aspect, _("Auto"))
00859 {
00860 this->thread = thread;
00861 }
00862
00863 ScaleAspectAuto::~ScaleAspectAuto()
00864 {
00865 }
00866
00867 int ScaleAspectAuto::handle_event()
00868 {
00869 thread->auto_aspect = get_value();
00870 thread->update_aspect();
00871 }
00872
00873 ScaleAspectText::ScaleAspectText(int x, int y, SetFormatThread *thread, float *output)
00874 : BC_TextBox(x, y, 70, 1, *output)
00875 {
00876 this->output = output;
00877 this->thread = thread;
00878 }
00879 ScaleAspectText::~ScaleAspectText()
00880 {
00881 }
00882
00883 int ScaleAspectText::handle_event()
00884 {
00885 *output = atof(get_text());
00886 return 1;
00887 }
00888
00889
00890
00891
00892
00893
00894 SetFormatApply::SetFormatApply(int x, int y, SetFormatThread *thread)
00895 : BC_GenericButton(x, y, _("Apply"))
00896 {
00897 this->thread = thread;
00898 }
00899
00900 int SetFormatApply::handle_event()
00901 {
00902 thread->apply_changes();
00903 return 1;
00904 }
00905
00906
00907
00908
00909
00910
00911
00912
00913
00914
00915
00916
00917
00918 FormatSwapExtents::FormatSwapExtents(MWindow *mwindow,
00919 SetFormatThread *thread,
00920 SetFormatWindow *gui,
00921 int x,
00922 int y)
00923 : BC_Button(x, y, mwindow->theme->get_image_set("swap_extents"))
00924 {
00925 this->mwindow = mwindow;
00926 this->thread = thread;
00927 this->gui = gui;
00928 set_tooltip("Swap dimensions");
00929 }
00930
00931 int FormatSwapExtents::handle_event()
00932 {
00933 int w = thread->dimension[0];
00934 int h = thread->dimension[1];
00935 thread->dimension[0] = -h;
00936 gui->dimension[0]->update((int64_t)h);
00937 gui->dimension[1]->update((int64_t)w);
00938 thread->update_window();
00939 thread->dimension[1] = -w;
00940 thread->update_window();
00941 return 1;
00942 }
00943
00944
00945
00946