diff --git a/data/widgets/options.xml b/data/widgets/options.xml index e986028f0..eb5a88fe2 100644 --- a/data/widgets/options.xml +++ b/data/widgets/options.xml @@ -1,7 +1,8 @@ - + + @@ -85,4 +86,5 @@ + diff --git a/src/app/commands/cmd_options.cpp b/src/app/commands/cmd_options.cpp index d4dd83c5c..067827e6d 100644 --- a/src/app/commands/cmd_options.cpp +++ b/src/app/commands/cmd_options.cpp @@ -38,15 +38,16 @@ #include "raster/image.h" #include "ui/ui.h" +#include "generated_options.h" + namespace app { using namespace ui; -class OptionsWindow : public Window { +class OptionsWindow : public app::gen::Options { public: OptionsWindow(Context* context) - : Window(Window::WithTitleBar, "Options") - , m_settings(context->settings()) + : m_settings(context->settings()) , m_docSettings(m_settings->getDocumentSettings(NULL)) , m_checked_bg_color1(new ColorButton(RenderEngine::getCheckedBgColor1(), IMAGE_RGB)) , m_checked_bg_color2(new ColorButton(RenderEngine::getCheckedBgColor2(), IMAGE_RGB)) @@ -54,94 +55,70 @@ public: , m_gridColor(new ColorButton(m_docSettings->getGridColor(), IMAGE_RGB)) , m_cursorColor(new ColorButton(Editor::get_cursor_color(), IMAGE_RGB)) { - addChild(app::load_widget("options.xml", "main_box")); - - // Load the this widget - app::finder(this) - >> "section_listbox" >> m_section_listbox - >> "panel" >> m_panel - >> "smooth" >> m_check_smooth - >> "autotimeline" >> m_check_autotimeline - >> "show_scrollbars" >> m_show_scrollbars - >> "cursor_color_box" >> m_cursor_color_box - >> "grid_color_box" >> m_grid_color_box - >> "pixel_grid_color_box" >> m_pixel_grid_color_box - >> "checked_bg_size" >> m_checked_bg - >> "checked_bg_zoom" >> m_checked_bg_zoom - >> "checked_bg_color1_box" >> m_checked_bg_color1_box - >> "checked_bg_color2_box" >> m_checked_bg_color2_box - >> "checked_bg_reset" >> m_checked_bg_reset - >> "undo_size_limit" >> m_undo_size_limit - >> "undo_goto_modified" >> m_undo_goto_modified - >> "screen_scale" >> m_screen_scale - >> "wheel_zoom" >> m_wheel_zoom - >> "locate_file" >> m_locate_file - >> "button_ok" >> m_button_ok; - - m_section_listbox->ChangeSelectedItem.connect(Bind(&OptionsWindow::onChangeSection, this)); - m_cursor_color_box->addChild(m_cursorColor); + sectionListbox()->ChangeSelectedItem.connect(Bind(&OptionsWindow::onChangeSection, this)); + cursorColorBox()->addChild(m_cursorColor); // Grid color m_gridColor->setId("grid_color"); - m_grid_color_box->addChild(m_gridColor); + gridColorBox()->addChild(m_gridColor); // Pixel grid color m_pixelGridColor->setId("pixel_grid_color"); - m_pixel_grid_color_box->addChild(m_pixelGridColor); + pixelGridColorBox()->addChild(m_pixelGridColor); // Others if (get_config_bool("Options", "MoveSmooth", true)) - m_check_smooth->setSelected(true); + smooth()->setSelected(true); if (get_config_bool("Options", "AutoShowTimeline", true)) - m_check_autotimeline->setSelected(true); + autotimeline()->setSelected(true); if (m_settings->getShowSpriteEditorScrollbars()) - m_show_scrollbars->setSelected(true); + showScrollbars()->setSelected(true); // Checked background size - m_screen_scale->addItem("1:1"); - m_screen_scale->addItem("2:1"); - m_screen_scale->addItem("3:1"); - m_screen_scale->addItem("4:1"); - m_screen_scale->setSelectedItemIndex(get_screen_scaling()-1); + screenScale()->addItem("1:1"); + screenScale()->addItem("2:1"); + screenScale()->addItem("3:1"); + screenScale()->addItem("4:1"); + screenScale()->setSelectedItemIndex(get_screen_scaling()-1); // Zoom with Scroll Wheel - m_wheel_zoom->setSelected(m_settings->getZoomWithScrollWheel()); + wheelZoom()->setSelected(m_settings->getZoomWithScrollWheel()); // Checked background size - m_checked_bg->addItem("16x16"); - m_checked_bg->addItem("8x8"); - m_checked_bg->addItem("4x4"); - m_checked_bg->addItem("2x2"); - m_checked_bg->setSelectedItemIndex((int)RenderEngine::getCheckedBgType()); + checkedBgSize()->addItem("16x16"); + checkedBgSize()->addItem("8x8"); + checkedBgSize()->addItem("4x4"); + checkedBgSize()->addItem("2x2"); + checkedBgSize()->setSelectedItemIndex((int)RenderEngine::getCheckedBgType()); // Zoom checked background if (RenderEngine::getCheckedBgZoom()) - m_checked_bg_zoom->setSelected(true); + checkedBgZoom()->setSelected(true); // Checked background colors - m_checked_bg_color1_box->addChild(m_checked_bg_color1); - m_checked_bg_color2_box->addChild(m_checked_bg_color2); + checkedBgColor1Box()->addChild(m_checked_bg_color1); + checkedBgColor2Box()->addChild(m_checked_bg_color2); // Reset button - m_checked_bg_reset->Click.connect(Bind(&OptionsWindow::onResetCheckedBg, this)); + checkedBgReset()->Click.connect(Bind(&OptionsWindow::onResetCheckedBg, this)); // Locate config file - m_locate_file->Click.connect(Bind(&OptionsWindow::onLocateConfigFile, this)); + locateFile()->Click.connect(Bind(&OptionsWindow::onLocateConfigFile, this)); // Undo limit - m_undo_size_limit->setTextf("%d", m_settings->undoSizeLimit()); + undoSizeLimit()->setTextf("%d", m_settings->undoSizeLimit()); // Goto modified frame/layer on undo/redo if (m_settings->undoGotoModified()) - m_undo_goto_modified->setSelected(true); + undoGotoModified()->setSelected(true); - m_section_listbox->selectIndex(0); + sectionListbox()->selectIndex(0); } bool ok() { - return (getKiller() == m_button_ok); + return (getKiller() == buttonOk()); } void saveConfig() { @@ -149,25 +126,25 @@ public: m_docSettings->setGridColor(m_gridColor->getColor()); m_docSettings->setPixelGridColor(m_pixelGridColor->getColor()); - set_config_bool("Options", "MoveSmooth", m_check_smooth->isSelected()); - set_config_bool("Options", "AutoShowTimeline", m_check_autotimeline->isSelected()); + set_config_bool("Options", "MoveSmooth", smooth()->isSelected()); + set_config_bool("Options", "AutoShowTimeline", autotimeline()->isSelected()); - m_settings->setShowSpriteEditorScrollbars(m_show_scrollbars->isSelected()); - m_settings->setZoomWithScrollWheel(m_wheel_zoom->isSelected()); + m_settings->setShowSpriteEditorScrollbars(showScrollbars()->isSelected()); + m_settings->setZoomWithScrollWheel(wheelZoom()->isSelected()); - RenderEngine::setCheckedBgType((RenderEngine::CheckedBgType)m_checked_bg->getSelectedItemIndex()); - RenderEngine::setCheckedBgZoom(m_checked_bg_zoom->isSelected()); + RenderEngine::setCheckedBgType((RenderEngine::CheckedBgType)checkedBgSize()->getSelectedItemIndex()); + RenderEngine::setCheckedBgZoom(checkedBgZoom()->isSelected()); RenderEngine::setCheckedBgColor1(m_checked_bg_color1->getColor()); RenderEngine::setCheckedBgColor2(m_checked_bg_color2->getColor()); int undo_size_limit_value; - undo_size_limit_value = m_undo_size_limit->getTextInt(); + undo_size_limit_value = undoSizeLimit()->getTextInt(); undo_size_limit_value = MID(1, undo_size_limit_value, 9999); m_settings->setUndoSizeLimit(undo_size_limit_value); - m_settings->setUndoGotoModified(m_undo_goto_modified->isSelected()); + m_settings->setUndoGotoModified(undoGotoModified()->isSelected()); - int new_screen_scaling = m_screen_scale->getSelectedItemIndex()+1; + int new_screen_scaling = screenScale()->getSelectedItemIndex()+1; if (new_screen_scaling != get_screen_scaling()) { set_screen_scaling(new_screen_scaling); @@ -182,17 +159,17 @@ public: private: void onChangeSection() { - ListItem* item = m_section_listbox->getSelectedChild(); + ListItem* item = sectionListbox()->getSelectedChild(); if (!item) return; - m_panel->showChild(findChild(item->getValue().c_str())); + panel()->showChild(findChild(item->getValue().c_str())); } void onResetCheckedBg() { // Default values - m_checked_bg->setSelectedItemIndex((int)RenderEngine::CHECKED_BG_16X16); - m_checked_bg_zoom->setSelected(true); + checkedBgSize()->setSelectedItemIndex((int)RenderEngine::CHECKED_BG_16X16); + checkedBgZoom()->setSelected(true); m_checked_bg_color1->setColor(app::Color::fromRgb(128, 128, 128)); m_checked_bg_color2->setColor(app::Color::fromRgb(192, 192, 192)); } @@ -203,30 +180,11 @@ private: ISettings* m_settings; IDocumentSettings* m_docSettings; - ListBox* m_section_listbox; - Panel* m_panel; - Widget* m_check_smooth; - Widget* m_check_autotimeline; - Widget* m_show_scrollbars; - Widget* m_cursor_color_box; - Widget* m_grid_color_box; - Widget* m_pixel_grid_color_box; - ComboBox* m_checked_bg; - Widget* m_checked_bg_zoom; - Widget* m_checked_bg_color1_box; - Widget* m_checked_bg_color2_box; - Button* m_checked_bg_reset; - Widget* m_undo_size_limit; - Widget* m_undo_goto_modified; - ComboBox* m_screen_scale; - CheckBox* m_wheel_zoom; - LinkLabel* m_locate_file; ColorButton* m_checked_bg_color1; ColorButton* m_checked_bg_color2; ColorButton* m_pixelGridColor; ColorButton* m_gridColor; ColorButton* m_cursorColor; - Button* m_button_ok; }; class OptionsCommand : public Command { diff --git a/src/gen/ui_class.cpp b/src/gen/ui_class.cpp index a4d8ebf09..4d3c35590 100644 --- a/src/gen/ui_class.cpp +++ b/src/gen/ui_class.cpp @@ -74,7 +74,9 @@ static std::string convert_type(const std::string& name) if (name == "entry") return "ui::Entry"; if (name == "hbox") return "ui::HBox"; if (name == "label") return "ui::Label"; + if (name == "link") return "ui::LinkLabel"; if (name == "listbox") return "ui::ListBox"; + if (name == "panel") return "ui::Panel"; if (name == "radio") return "ui::RadioButton"; if (name == "slider") return "ui::Slider"; if (name == "vbox") return "ui::VBox";