00001 #include "bcdisplayinfo.h"
00002 #include "clip.h"
00003 #include "language.h"
00004 #include "motion.h"
00005 #include "motionwindow.h"
00006
00007
00008
00009
00010
00011
00012 PLUGIN_THREAD_OBJECT(MotionMain, MotionThread, MotionWindow)
00013
00014
00015
00016 MotionWindow::MotionWindow(MotionMain *plugin, int x, int y)
00017 : BC_Window(plugin->gui_string,
00018 x,
00019 y,
00020 610,
00021 650,
00022 610,
00023 650,
00024 0,
00025 1)
00026 {
00027 this->plugin = plugin;
00028 }
00029
00030 MotionWindow::~MotionWindow()
00031 {
00032 }
00033
00034 int MotionWindow::create_objects()
00035 {
00036 int x1 = 10, x = 10, y = 10;
00037 int x2 = 310;
00038 BC_Title *title;
00039
00040
00041
00042 add_subwindow(global = new MotionGlobal(plugin,
00043 this,
00044 x1,
00045 y));
00046
00047 add_subwindow(rotate = new MotionRotate(plugin,
00048 this,
00049 x2,
00050 y));
00051 y += 50;
00052
00053 add_subwindow(title = new BC_Title(x1,
00054 y,
00055 _("Translation search radius:\n(W/H Percent of image)")));
00056 add_subwindow(global_range_w = new GlobalRange(plugin,
00057 x1 + title->get_w() + 10,
00058 y,
00059 &plugin->config.global_range_w));
00060 add_subwindow(global_range_h = new GlobalRange(plugin,
00061 x1 + title->get_w() + 10 + global_range_w->get_w(),
00062 y,
00063 &plugin->config.global_range_h));
00064
00065 add_subwindow(title = new BC_Title(x2,
00066 y,
00067 _("Rotation search radius:\n(Degrees)")));
00068 add_subwindow(rotation_range = new RotationRange(plugin,
00069 x2 + title->get_w() + 10,
00070 y));
00071
00072 y += 50;
00073 add_subwindow(title = new BC_Title(x1,
00074 y,
00075 _("Translation block size:\n(W/H Percent of image)")));
00076 add_subwindow(global_block_w = new BlockSize(plugin,
00077 x1 + title->get_w() + 10,
00078 y,
00079 &plugin->config.global_block_w));
00080 add_subwindow(global_block_h = new BlockSize(plugin,
00081 x1 + title->get_w() + 10 + global_block_w->get_w(),
00082 y,
00083 &plugin->config.global_block_h));
00084
00085 add_subwindow(title = new BC_Title(x2,
00086 y,
00087 _("Rotation block size:\n(W/H Percent of image)")));
00088 add_subwindow(rotation_block_w = new BlockSize(plugin,
00089 x2 + title->get_w() + 10,
00090 y,
00091 &plugin->config.rotation_block_w));
00092 add_subwindow(rotation_block_h = new BlockSize(plugin,
00093 x2 + title->get_w() + 10 + rotation_block_w->get_w(),
00094 y,
00095 &plugin->config.rotation_block_h));
00096
00097 y += 50;
00098 add_subwindow(title = new BC_Title(x1, y, _("Translation search steps:")));
00099 add_subwindow(global_search_positions = new GlobalSearchPositions(plugin,
00100 x1 + title->get_w() + 10,
00101 y,
00102 80));
00103 global_search_positions->create_objects();
00104
00105 add_subwindow(title = new BC_Title(x2, y, _("Rotation search steps:")));
00106 add_subwindow(rotation_search_positions = new RotationSearchPositions(plugin,
00107 x2 + title->get_w() + 10,
00108 y,
00109 80));
00110 rotation_search_positions->create_objects();
00111
00112 y += 50;
00113 add_subwindow(title = new BC_Title(x, y, _("Translation direction:")));
00114 add_subwindow(mode3 = new Mode3(plugin,
00115 this,
00116 x + title->get_w() + 10,
00117 y));
00118 mode3->create_objects();
00119
00120 y += 40;
00121 add_subwindow(title = new BC_Title(x, y + 10, _("Block X:")));
00122 add_subwindow(block_x = new MotionBlockX(plugin,
00123 this,
00124 x + title->get_w() + 10,
00125 y));
00126 add_subwindow(block_x_text = new MotionBlockXText(plugin,
00127 this,
00128 x + title->get_w() + 10 + block_x->get_w() + 10,
00129 y + 10));
00130
00131 y += 40;
00132 add_subwindow(title = new BC_Title(x, y + 10, _("Block Y:")));
00133 add_subwindow(block_y = new MotionBlockY(plugin,
00134 this,
00135 x + title->get_w() + 10,
00136 y));
00137 add_subwindow(block_y_text = new MotionBlockYText(plugin,
00138 this,
00139 x + title->get_w() + 10 + block_y->get_w() + 10,
00140 y + 10));
00141
00142 y += 50;
00143 add_subwindow(title = new BC_Title(x, y + 10, _("Maximum absolute offset:")));
00144 add_subwindow(magnitude = new MotionMagnitude(plugin,
00145 x + title->get_w() + 10,
00146 y));
00147
00148 y += 40;
00149 add_subwindow(title = new BC_Title(x, y + 10, _("Settling speed:")));
00150 add_subwindow(return_speed = new MotionReturnSpeed(plugin,
00151 x + title->get_w() + 10,
00152 y));
00153
00154
00155
00156 y += 40;
00157 add_subwindow(vectors = new MotionDrawVectors(plugin,
00158 this,
00159 x,
00160 y));
00161
00162
00163 y += 40;
00164 add_subwindow(track_single = new TrackSingleFrame(plugin,
00165 this,
00166 x,
00167 y));
00168 add_subwindow(title = new BC_Title(x + track_single->get_w() + 20,
00169 y,
00170 _("Frame number:")));
00171 add_subwindow(track_frame_number = new TrackFrameNumber(plugin,
00172 this,
00173 x + track_single->get_w() + title->get_w() + 20,
00174 y));
00175 add_subwindow(addtrackedframeoffset = new AddTrackedFrameOffset(plugin,
00176 this,
00177 x + track_single->get_w() + title->get_w() + 20 + track_frame_number->get_w(),
00178 y));
00179
00180
00181 y += 20;
00182 add_subwindow(track_previous = new TrackPreviousFrame(plugin,
00183 this,
00184 x,
00185 y));
00186
00187 y += 20;
00188 add_subwindow(previous_same = new PreviousFrameSameBlock(plugin,
00189 this,
00190 x,
00191 y));
00192
00193 y += 40;
00194 int y1 = y;
00195 add_subwindow(title = new BC_Title(x, y, _("Master layer:")));
00196 add_subwindow(master_layer = new MasterLayer(plugin,
00197 this,
00198 x + title->get_w() + 10,
00199 y));
00200 master_layer->create_objects();
00201 y += 30;
00202
00203
00204 add_subwindow(title = new BC_Title(x, y, _("Action:")));
00205 add_subwindow(mode1 = new Mode1(plugin,
00206 this,
00207 x + title->get_w() + 10,
00208 y));
00209 mode1->create_objects();
00210 y += 30;
00211
00212
00213
00214
00215 add_subwindow(title = new BC_Title(x, y, _("Calculation:")));
00216 add_subwindow(mode2 = new Mode2(plugin,
00217 this,
00218 x + title->get_w() + 10,
00219 y));
00220 mode2->create_objects();
00221
00222
00223
00224 show_window();
00225 flush();
00226 return 0;
00227 }
00228
00229 void MotionWindow::update_mode()
00230 {
00231 global_range_w->update(plugin->config.global_range_w,
00232 MIN_RADIUS,
00233 MAX_RADIUS);
00234 global_range_h->update(plugin->config.global_range_h,
00235 MIN_RADIUS,
00236 MAX_RADIUS);
00237 rotation_range->update(plugin->config.rotation_range,
00238 MIN_ROTATION,
00239 MAX_ROTATION);
00240 vectors->update(plugin->config.draw_vectors);
00241 global->update(plugin->config.global);
00242 rotate->update(plugin->config.rotate);
00243 addtrackedframeoffset->update(plugin->config.addtrackedframeoffset);
00244 }
00245
00246
00247 WINDOW_CLOSE_EVENT(MotionWindow)
00248
00249
00250
00251
00252
00253
00254
00255
00256
00257
00258 GlobalRange::GlobalRange(MotionMain *plugin,
00259 int x,
00260 int y,
00261 int *value)
00262 : BC_IPot(x,
00263 y,
00264 (int64_t)*value,
00265 (int64_t)MIN_RADIUS,
00266 (int64_t)MAX_RADIUS)
00267 {
00268 this->plugin = plugin;
00269 this->value = value;
00270 }
00271
00272
00273 int GlobalRange::handle_event()
00274 {
00275 *value = (int)get_value();
00276 plugin->send_configure_change();
00277 return 1;
00278 }
00279
00280
00281
00282
00283 RotationRange::RotationRange(MotionMain *plugin,
00284 int x,
00285 int y)
00286 : BC_IPot(x,
00287 y,
00288 (int64_t)plugin->config.rotation_range,
00289 (int64_t)MIN_ROTATION,
00290 (int64_t)MAX_ROTATION)
00291 {
00292 this->plugin = plugin;
00293 }
00294
00295
00296 int RotationRange::handle_event()
00297 {
00298 plugin->config.rotation_range = (int)get_value();
00299 plugin->send_configure_change();
00300 return 1;
00301 }
00302
00303
00304
00305
00306
00307
00308
00309
00310 BlockSize::BlockSize(MotionMain *plugin,
00311 int x,
00312 int y,
00313 int *value)
00314 : BC_IPot(x,
00315 y,
00316 (int64_t)*value,
00317 (int64_t)MIN_BLOCK,
00318 (int64_t)MAX_BLOCK)
00319 {
00320 this->plugin = plugin;
00321 this->value = value;
00322 }
00323
00324
00325 int BlockSize::handle_event()
00326 {
00327 *value = (int)get_value();
00328 plugin->send_configure_change();
00329 return 1;
00330 }
00331
00332
00333
00334
00335
00336
00337
00338
00339
00340
00341
00342
00343
00344 GlobalSearchPositions::GlobalSearchPositions(MotionMain *plugin,
00345 int x,
00346 int y,
00347 int w)
00348 : BC_PopupMenu(x,
00349 y,
00350 w,
00351 "",
00352 1)
00353 {
00354 this->plugin = plugin;
00355 }
00356 void GlobalSearchPositions::create_objects()
00357 {
00358 add_item(new BC_MenuItem("64"));
00359 add_item(new BC_MenuItem("128"));
00360 add_item(new BC_MenuItem("256"));
00361 add_item(new BC_MenuItem("512"));
00362 add_item(new BC_MenuItem("1024"));
00363 add_item(new BC_MenuItem("2048"));
00364 add_item(new BC_MenuItem("4096"));
00365 add_item(new BC_MenuItem("8192"));
00366 add_item(new BC_MenuItem("16384"));
00367 add_item(new BC_MenuItem("32768"));
00368 add_item(new BC_MenuItem("65536"));
00369 add_item(new BC_MenuItem("131072"));
00370 char string[BCTEXTLEN];
00371 sprintf(string, "%d", plugin->config.global_positions);
00372 set_text(string);
00373 }
00374
00375 int GlobalSearchPositions::handle_event()
00376 {
00377 plugin->config.global_positions = atoi(get_text());
00378 plugin->send_configure_change();
00379 return 1;
00380 }
00381
00382
00383
00384
00385
00386
00387
00388 RotationSearchPositions::RotationSearchPositions(MotionMain *plugin,
00389 int x,
00390 int y,
00391 int w)
00392 : BC_PopupMenu(x,
00393 y,
00394 w,
00395 "",
00396 1)
00397 {
00398 this->plugin = plugin;
00399 }
00400 void RotationSearchPositions::create_objects()
00401 {
00402 add_item(new BC_MenuItem("4"));
00403 add_item(new BC_MenuItem("8"));
00404 add_item(new BC_MenuItem("16"));
00405 add_item(new BC_MenuItem("32"));
00406 char string[BCTEXTLEN];
00407 sprintf(string, "%d", plugin->config.rotate_positions);
00408 set_text(string);
00409 }
00410
00411 int RotationSearchPositions::handle_event()
00412 {
00413 plugin->config.rotate_positions = atoi(get_text());
00414 plugin->send_configure_change();
00415 return 1;
00416 }
00417
00418
00419
00420
00421
00422
00423
00424
00425 MotionMagnitude::MotionMagnitude(MotionMain *plugin,
00426 int x,
00427 int y)
00428 : BC_IPot(x,
00429 y,
00430 (int64_t)plugin->config.magnitude,
00431 (int64_t)0,
00432 (int64_t)100)
00433 {
00434 this->plugin = plugin;
00435 }
00436
00437 int MotionMagnitude::handle_event()
00438 {
00439 plugin->config.magnitude = (int)get_value();
00440 plugin->send_configure_change();
00441 return 1;
00442 }
00443
00444
00445 MotionReturnSpeed::MotionReturnSpeed(MotionMain *plugin,
00446 int x,
00447 int y)
00448 : BC_IPot(x,
00449 y,
00450 (int64_t)plugin->config.return_speed,
00451 (int64_t)0,
00452 (int64_t)100)
00453 {
00454 this->plugin = plugin;
00455 }
00456
00457 int MotionReturnSpeed::handle_event()
00458 {
00459 plugin->config.return_speed = (int)get_value();
00460 plugin->send_configure_change();
00461 return 1;
00462 }
00463
00464
00465
00466 AddTrackedFrameOffset::AddTrackedFrameOffset(MotionMain *plugin,
00467 MotionWindow *gui,
00468 int x,
00469 int y)
00470 : BC_CheckBox(x,
00471 y,
00472 plugin->config.addtrackedframeoffset,
00473 _("Add (loaded) offset from tracked frame"))
00474 {
00475 this->plugin = plugin;
00476 this->gui = gui;
00477 }
00478
00479 int AddTrackedFrameOffset::handle_event()
00480 {
00481 plugin->config.addtrackedframeoffset = get_value();
00482 plugin->send_configure_change();
00483 return 1;
00484 }
00485
00486
00487 MotionGlobal::MotionGlobal(MotionMain *plugin,
00488 MotionWindow *gui,
00489 int x,
00490 int y)
00491 : BC_CheckBox(x,
00492 y,
00493 plugin->config.global,
00494 _("Track translation"))
00495 {
00496 this->plugin = plugin;
00497 this->gui = gui;
00498 }
00499
00500 int MotionGlobal::handle_event()
00501 {
00502 plugin->config.global = get_value();
00503 plugin->send_configure_change();
00504 return 1;
00505 }
00506
00507 MotionRotate::MotionRotate(MotionMain *plugin,
00508 MotionWindow *gui,
00509 int x,
00510 int y)
00511 : BC_CheckBox(x,
00512 y,
00513 plugin->config.rotate,
00514 _("Track rotation"))
00515 {
00516 this->plugin = plugin;
00517 this->gui = gui;
00518 }
00519
00520 int MotionRotate::handle_event()
00521 {
00522 plugin->config.rotate = get_value();
00523 plugin->send_configure_change();
00524 return 1;
00525 }
00526
00527
00528
00529
00530
00531 MotionBlockX::MotionBlockX(MotionMain *plugin,
00532 MotionWindow *gui,
00533 int x,
00534 int y)
00535 : BC_FPot(x,
00536 y,
00537 plugin->config.block_x,
00538 (float)0,
00539 (float)100)
00540 {
00541 this->plugin = plugin;
00542 this->gui = gui;
00543 }
00544
00545 int MotionBlockX::handle_event()
00546 {
00547 plugin->config.block_x = get_value();
00548 gui->block_x_text->update((float)plugin->config.block_x);
00549 plugin->send_configure_change();
00550 return 1;
00551 }
00552
00553
00554
00555
00556 MotionBlockY::MotionBlockY(MotionMain *plugin,
00557 MotionWindow *gui,
00558 int x,
00559 int y)
00560 : BC_FPot(x,
00561 y,
00562 (float)plugin->config.block_y,
00563 (float)0,
00564 (float)100)
00565 {
00566 this->plugin = plugin;
00567 this->gui = gui;
00568 }
00569
00570 int MotionBlockY::handle_event()
00571 {
00572 plugin->config.block_y = get_value();
00573 gui->block_y_text->update((float)plugin->config.block_y);
00574 plugin->send_configure_change();
00575 return 1;
00576 }
00577
00578 MotionBlockXText::MotionBlockXText(MotionMain *plugin,
00579 MotionWindow *gui,
00580 int x,
00581 int y)
00582 : BC_TextBox(x,
00583 y,
00584 75,
00585 1,
00586 (float)plugin->config.block_x)
00587 {
00588 this->plugin = plugin;
00589 this->gui = gui;
00590 set_precision(4);
00591 }
00592
00593 int MotionBlockXText::handle_event()
00594 {
00595 plugin->config.block_x = atof(get_text());
00596 gui->block_x->update(plugin->config.block_x);
00597 plugin->send_configure_change();
00598 return 1;
00599 }
00600
00601
00602
00603
00604 MotionBlockYText::MotionBlockYText(MotionMain *plugin,
00605 MotionWindow *gui,
00606 int x,
00607 int y)
00608 : BC_TextBox(x,
00609 y,
00610 75,
00611 1,
00612 (float)plugin->config.block_y)
00613 {
00614 this->plugin = plugin;
00615 this->gui = gui;
00616 set_precision(4);
00617 }
00618
00619 int MotionBlockYText::handle_event()
00620 {
00621 plugin->config.block_y = atof(get_text());
00622 gui->block_y->update(plugin->config.block_y);
00623 plugin->send_configure_change();
00624 return 1;
00625 }
00626
00627
00628
00629
00630
00631
00632
00633
00634
00635
00636
00637
00638
00639
00640
00641
00642 MotionDrawVectors::MotionDrawVectors(MotionMain *plugin,
00643 MotionWindow *gui,
00644 int x,
00645 int y)
00646 : BC_CheckBox(x,
00647 y,
00648 plugin->config.draw_vectors,
00649 _("Draw vectors"))
00650 {
00651 this->gui = gui;
00652 this->plugin = plugin;
00653 }
00654
00655 int MotionDrawVectors::handle_event()
00656 {
00657 plugin->config.draw_vectors = get_value();
00658 plugin->send_configure_change();
00659 return 1;
00660 }
00661
00662
00663
00664
00665
00666
00667
00668
00669 TrackSingleFrame::TrackSingleFrame(MotionMain *plugin,
00670 MotionWindow *gui,
00671 int x,
00672 int y)
00673 : BC_Radial(x,
00674 y,
00675 plugin->config.mode3 == MotionConfig::TRACK_SINGLE,
00676 _("Track single frame"))
00677 {
00678 this->plugin = plugin;
00679 this->gui = gui;
00680 }
00681
00682 int TrackSingleFrame::handle_event()
00683 {
00684 plugin->config.mode3 = MotionConfig::TRACK_SINGLE;
00685 gui->track_previous->update(0);
00686 gui->previous_same->update(0);
00687 gui->track_frame_number->enable();
00688 plugin->send_configure_change();
00689 return 1;
00690 }
00691
00692
00693
00694
00695
00696
00697
00698
00699 TrackFrameNumber::TrackFrameNumber(MotionMain *plugin,
00700 MotionWindow *gui,
00701 int x,
00702 int y)
00703 : BC_TextBox(x, y, 100, 1, plugin->config.track_frame)
00704 {
00705 this->plugin = plugin;
00706 this->gui = gui;
00707 if(plugin->config.mode3 != MotionConfig::TRACK_SINGLE) disable();
00708 }
00709
00710 int TrackFrameNumber::handle_event()
00711 {
00712 plugin->config.track_frame = atol(get_text());
00713 plugin->send_configure_change();
00714 return 1;
00715 }
00716
00717
00718
00719
00720
00721
00722
00723 TrackPreviousFrame::TrackPreviousFrame(MotionMain *plugin,
00724 MotionWindow *gui,
00725 int x,
00726 int y)
00727 : BC_Radial(x,
00728 y,
00729 plugin->config.mode3 == MotionConfig::TRACK_PREVIOUS,
00730 _("Track previous frame"))
00731 {
00732 this->plugin = plugin;
00733 this->gui = gui;
00734 }
00735 int TrackPreviousFrame::handle_event()
00736 {
00737 plugin->config.mode3 = MotionConfig::TRACK_PREVIOUS;
00738 gui->track_single->update(0);
00739 gui->previous_same->update(0);
00740 gui->track_frame_number->disable();
00741 plugin->send_configure_change();
00742 return 1;
00743 }
00744
00745
00746
00747
00748
00749
00750
00751
00752 PreviousFrameSameBlock::PreviousFrameSameBlock(MotionMain *plugin,
00753 MotionWindow *gui,
00754 int x,
00755 int y)
00756 : BC_Radial(x,
00757 y,
00758 plugin->config.mode3 == MotionConfig::PREVIOUS_SAME_BLOCK,
00759 _("Previous frame same block"))
00760 {
00761 this->plugin = plugin;
00762 this->gui = gui;
00763 }
00764 int PreviousFrameSameBlock::handle_event()
00765 {
00766 plugin->config.mode3 = MotionConfig::PREVIOUS_SAME_BLOCK;
00767 gui->track_single->update(0);
00768 gui->track_previous->update(0);
00769 gui->track_frame_number->disable();
00770 plugin->send_configure_change();
00771 return 1;
00772 }
00773
00774
00775
00776
00777
00778
00779
00780
00781 MasterLayer::MasterLayer(MotionMain *plugin, MotionWindow *gui, int x, int y)
00782 : BC_PopupMenu(x,
00783 y,
00784 calculate_w(gui),
00785 to_text(plugin->config.bottom_is_master))
00786 {
00787 this->plugin = plugin;
00788 this->gui = gui;
00789 }
00790
00791 int MasterLayer::handle_event()
00792 {
00793 plugin->config.bottom_is_master = from_text(get_text());
00794 plugin->send_configure_change();
00795 return 1;
00796 }
00797
00798 void MasterLayer::create_objects()
00799 {
00800 add_item(new BC_MenuItem(to_text(0)));
00801 add_item(new BC_MenuItem(to_text(1)));
00802 }
00803
00804 int MasterLayer::from_text(char *text)
00805 {
00806 if(!strcmp(text, _("Top"))) return 0;
00807 return 1;
00808 }
00809
00810 char* MasterLayer::to_text(int mode)
00811 {
00812 return mode ? _("Bottom") : _("Top");
00813 }
00814
00815 int MasterLayer::calculate_w(MotionWindow *gui)
00816 {
00817 int result = 0;
00818 result = MAX(result, gui->get_text_width(MEDIUMFONT, to_text(0)));
00819 result = MAX(result, gui->get_text_width(MEDIUMFONT, to_text(1)));
00820 return result + 50;
00821 }
00822
00823
00824
00825
00826
00827
00828
00829
00830 Mode1::Mode1(MotionMain *plugin, MotionWindow *gui, int x, int y)
00831 : BC_PopupMenu(x,
00832 y,
00833 calculate_w(gui),
00834 to_text(plugin->config.mode1))
00835 {
00836 this->plugin = plugin;
00837 this->gui = gui;
00838 }
00839
00840 int Mode1::handle_event()
00841 {
00842 plugin->config.mode1 = from_text(get_text());
00843 plugin->send_configure_change();
00844 return 1;
00845 }
00846
00847 void Mode1::create_objects()
00848 {
00849 add_item(new BC_MenuItem(to_text(MotionConfig::TRACK)));
00850 add_item(new BC_MenuItem(to_text(MotionConfig::TRACK_PIXEL)));
00851 add_item(new BC_MenuItem(to_text(MotionConfig::STABILIZE)));
00852 add_item(new BC_MenuItem(to_text(MotionConfig::STABILIZE_PIXEL)));
00853 add_item(new BC_MenuItem(to_text(MotionConfig::NOTHING)));
00854 }
00855
00856 int Mode1::from_text(char *text)
00857 {
00858 if(!strcmp(text, _("Track Subpixel"))) return MotionConfig::TRACK;
00859 if(!strcmp(text, _("Track Pixel"))) return MotionConfig::TRACK_PIXEL;
00860 if(!strcmp(text, _("Stabilize Subpixel"))) return MotionConfig::STABILIZE;
00861 if(!strcmp(text, _("Stabilize Pixel"))) return MotionConfig::STABILIZE_PIXEL;
00862 if(!strcmp(text, _("Do Nothing"))) return MotionConfig::NOTHING;
00863 }
00864
00865 char* Mode1::to_text(int mode)
00866 {
00867 switch(mode)
00868 {
00869 case MotionConfig::TRACK:
00870 return _("Track Subpixel");
00871 break;
00872 case MotionConfig::TRACK_PIXEL:
00873 return _("Track Pixel");
00874 break;
00875 case MotionConfig::STABILIZE:
00876 return _("Stabilize Subpixel");
00877 break;
00878 case MotionConfig::STABILIZE_PIXEL:
00879 return _("Stabilize Pixel");
00880 break;
00881 case MotionConfig::NOTHING:
00882 return _("Do Nothing");
00883 break;
00884 }
00885 }
00886
00887 int Mode1::calculate_w(MotionWindow *gui)
00888 {
00889 int result = 0;
00890 result = MAX(result, gui->get_text_width(MEDIUMFONT, to_text(MotionConfig::TRACK)));
00891 result = MAX(result, gui->get_text_width(MEDIUMFONT, to_text(MotionConfig::TRACK_PIXEL)));
00892 result = MAX(result, gui->get_text_width(MEDIUMFONT, to_text(MotionConfig::STABILIZE)));
00893 result = MAX(result, gui->get_text_width(MEDIUMFONT, to_text(MotionConfig::STABILIZE_PIXEL)));
00894 result = MAX(result, gui->get_text_width(MEDIUMFONT, to_text(MotionConfig::NOTHING)));
00895 return result + 50;
00896 }
00897
00898
00899
00900
00901
00902 Mode2::Mode2(MotionMain *plugin, MotionWindow *gui, int x, int y)
00903 : BC_PopupMenu(x,
00904 y,
00905 calculate_w(gui),
00906 to_text(plugin->config.mode2))
00907 {
00908 this->plugin = plugin;
00909 this->gui = gui;
00910 }
00911
00912 int Mode2::handle_event()
00913 {
00914 plugin->config.mode2 = from_text(get_text());
00915 plugin->send_configure_change();
00916 return 1;
00917 }
00918
00919 void Mode2::create_objects()
00920 {
00921 add_item(new BC_MenuItem(to_text(MotionConfig::NO_CALCULATE)));
00922 add_item(new BC_MenuItem(to_text(MotionConfig::RECALCULATE)));
00923 add_item(new BC_MenuItem(to_text(MotionConfig::SAVE)));
00924 add_item(new BC_MenuItem(to_text(MotionConfig::LOAD)));
00925 }
00926
00927 int Mode2::from_text(char *text)
00928 {
00929 if(!strcmp(text, _("Don't Calculate"))) return MotionConfig::NO_CALCULATE;
00930 if(!strcmp(text, _("Recalculate"))) return MotionConfig::RECALCULATE;
00931 if(!strcmp(text, _("Save coords to /tmp"))) return MotionConfig::SAVE;
00932 if(!strcmp(text, _("Load coords from /tmp"))) return MotionConfig::LOAD;
00933 }
00934
00935 char* Mode2::to_text(int mode)
00936 {
00937 switch(mode)
00938 {
00939 case MotionConfig::NO_CALCULATE:
00940 return _("Don't Calculate");
00941 break;
00942 case MotionConfig::RECALCULATE:
00943 return _("Recalculate");
00944 break;
00945 case MotionConfig::SAVE:
00946 return _("Save coords to /tmp");
00947 break;
00948 case MotionConfig::LOAD:
00949 return _("Load coords from /tmp");
00950 break;
00951 }
00952 }
00953
00954 int Mode2::calculate_w(MotionWindow *gui)
00955 {
00956 int result = 0;
00957 result = MAX(result, gui->get_text_width(MEDIUMFONT, to_text(MotionConfig::NO_CALCULATE)));
00958 result = MAX(result, gui->get_text_width(MEDIUMFONT, to_text(MotionConfig::RECALCULATE)));
00959 result = MAX(result, gui->get_text_width(MEDIUMFONT, to_text(MotionConfig::SAVE)));
00960 result = MAX(result, gui->get_text_width(MEDIUMFONT, to_text(MotionConfig::LOAD)));
00961 return result + 50;
00962 }
00963
00964
00965
00966
00967
00968
00969
00970
00971
00972
00973 Mode3::Mode3(MotionMain *plugin, MotionWindow *gui, int x, int y)
00974 : BC_PopupMenu(x,
00975 y,
00976 calculate_w(gui),
00977 to_text(plugin->config.horizontal_only, plugin->config.vertical_only))
00978 {
00979 this->plugin = plugin;
00980 this->gui = gui;
00981 }
00982
00983 int Mode3::handle_event()
00984 {
00985 from_text(&plugin->config.horizontal_only, &plugin->config.vertical_only, get_text());
00986 plugin->send_configure_change();
00987 return 1;
00988 }
00989
00990 void Mode3::create_objects()
00991 {
00992 add_item(new BC_MenuItem(to_text(1, 0)));
00993 add_item(new BC_MenuItem(to_text(0, 1)));
00994 add_item(new BC_MenuItem(to_text(0, 0)));
00995 }
00996
00997 void Mode3::from_text(int *horizontal_only, int *vertical_only, char *text)
00998 {
00999 *horizontal_only = 0;
01000 *vertical_only = 0;
01001 if(!strcmp(text, to_text(1, 0))) *horizontal_only = 1;
01002 if(!strcmp(text, to_text(0, 1))) *vertical_only = 1;
01003 }
01004
01005 char* Mode3::to_text(int horizontal_only, int vertical_only)
01006 {
01007 if(horizontal_only) return _("Horizontal only");
01008 if(vertical_only) return _("Vertical only");
01009 return _("Both");
01010 }
01011
01012 int Mode3::calculate_w(MotionWindow *gui)
01013 {
01014 int result = 0;
01015 result = MAX(result, gui->get_text_width(MEDIUMFONT, to_text(1, 0)));
01016 result = MAX(result, gui->get_text_width(MEDIUMFONT, to_text(0, 1)));
01017 result = MAX(result, gui->get_text_width(MEDIUMFONT, to_text(0, 0)));
01018 return result + 50;
01019 }
01020