diff --git a/data/widgets/options.xml b/data/widgets/options.xml index a5c90ce54..8de8b0305 100644 --- a/data/widgets/options.xml +++ b/data/widgets/options.xml @@ -309,13 +309,20 @@ - - - - - - - + + + + + + + diff --git a/src/app/commands/cmd_options.cpp b/src/app/commands/cmd_options.cpp index 45d0e2e6e..397021760 100644 --- a/src/app/commands/cmd_options.cpp +++ b/src/app/commands/cmd_options.cpp @@ -154,13 +154,6 @@ public: clearRecentFiles()->Click.connect(base::Bind(&OptionsWindow::onClearRecentFiles, this)); // Alerts - fileFormatDoesntSupportAlert()->setSelected(m_pref.saveFile.showFileFormatDoesntSupportAlert()); - exportAnimationInSequenceAlert()->setSelected(m_pref.saveFile.showExportAnimationInSequenceAlert()); - overwriteFilesOnExportAlert()->setSelected(m_pref.exportFile.showOverwriteFilesAlert()); - overwriteFilesOnExportSpriteSheetAlert()->setSelected(m_pref.spriteSheet.showOverwriteFilesAlert()); - gifOptionsAlert()->setSelected(m_pref.gif.showAlert()); - jpegOptionsAlert()->setSelected(m_pref.jpeg.showAlert()); - advancedModeAlert()->setSelected(m_pref.advancedMode.showAlert()); resetAlerts()->Click.connect(base::Bind(&OptionsWindow::onResetAlerts, this)); // Cursor @@ -430,14 +423,6 @@ public: warnings += "<<- " + Strings::alerts_restart_by_preferences_save_recovery_data_period(); } - m_pref.saveFile.showFileFormatDoesntSupportAlert(fileFormatDoesntSupportAlert()->isSelected()); - m_pref.saveFile.showExportAnimationInSequenceAlert(exportAnimationInSequenceAlert()->isSelected()); - m_pref.exportFile.showOverwriteFilesAlert(overwriteFilesOnExportAlert()->isSelected()); - m_pref.spriteSheet.showOverwriteFilesAlert(overwriteFilesOnExportSpriteSheetAlert()->isSelected()); - m_pref.gif.showAlert(gifOptionsAlert()->isSelected()); - m_pref.jpeg.showAlert(jpegOptionsAlert()->isSelected()); - m_pref.advancedMode.showAlert(advancedModeAlert()->isSelected()); - m_pref.editor.zoomFromCenterWithWheel(zoomFromCenterWithWheel()->isSelected()); m_pref.editor.zoomFromCenterWithKeys(zoomFromCenterWithKeys()->isSelected()); m_pref.editor.showScrollbars(showScrollbars()->isSelected()); @@ -642,13 +627,13 @@ private: } void onResetAlerts() { - fileFormatDoesntSupportAlert()->setSelected(m_pref.saveFile.showFileFormatDoesntSupportAlert.defaultValue()); - exportAnimationInSequenceAlert()->setSelected(m_pref.saveFile.showExportAnimationInSequenceAlert.defaultValue()); - overwriteFilesOnExportAlert()->setSelected(m_pref.exportFile.showOverwriteFilesAlert.defaultValue()); - overwriteFilesOnExportSpriteSheetAlert()->setSelected(m_pref.spriteSheet.showOverwriteFilesAlert.defaultValue()); - gifOptionsAlert()->setSelected(m_pref.gif.showAlert.defaultValue()); - jpegOptionsAlert()->setSelected(m_pref.jpeg.showAlert.defaultValue()); - advancedModeAlert()->setSelected(m_pref.advancedMode.showAlert.defaultValue()); + fileFormatDoesntSupportAlert()->resetWithDefaultValue(); + exportAnimationInSequenceAlert()->resetWithDefaultValue(); + overwriteFilesOnExportAlert()->resetWithDefaultValue(); + overwriteFilesOnExportSpriteSheetAlert()->resetWithDefaultValue(); + gifOptionsAlert()->resetWithDefaultValue(); + jpegOptionsAlert()->resetWithDefaultValue(); + advancedModeAlert()->resetWithDefaultValue(); } void onChangeBgScope() { diff --git a/src/app/ui/pref_widget.h b/src/app/ui/pref_widget.h index 05ed1e181..81e70b802 100644 --- a/src/app/ui/pref_widget.h +++ b/src/app/ui/pref_widget.h @@ -50,6 +50,12 @@ public: } } + void resetWithDefaultValue() { + // Reset to default value in preferences + if (m_option) + this->setSelected(m_option->defaultValue()); + } + protected: bool onProcessMessage(ui::Message* msg) override { if (msg->type() == kSavePreferencesMessage) { diff --git a/src/gen/ui_class.cpp b/src/gen/ui_class.cpp index bbd68c08e..2fc05e09a 100644 --- a/src/gen/ui_class.cpp +++ b/src/gen/ui_class.cpp @@ -1,5 +1,5 @@ // Aseprite Code Generator -// Copyright (c) 2014-2017 David Capello +// Copyright (c) 2014-2018 David Capello // // This file is released under the terms of the MIT license. // Read LICENSE.txt for more information. @@ -47,7 +47,8 @@ static void collect_widgets_with_ids(TiXmlElement* elem, XmlElements& widgets) } } -static std::string convert_type(const std::string& name) +static std::string convert_type(const std::string& name, + const bool hasPref) { static std::string parent; if (name != "item") @@ -56,7 +57,12 @@ static std::string convert_type(const std::string& name) if (name == "box") return "ui::Box"; if (name == "button") return "ui::Button"; if (name == "buttonset") return "app::ButtonSet"; - if (name == "check") return "ui::CheckBox"; + if (name == "check") { + if (hasPref) + return "BoolPrefWidget"; + else + return "ui::CheckBox"; + } if (name == "colorpicker") return "app::ColorButton"; if (name == "combobox") return "ui::ComboBox"; if (name == "dropdownbutton") return "app::DropDownButton"; @@ -102,7 +108,7 @@ void gen_ui_class(TiXmlDocument* doc, std::string className = convert_xmlid_to_cppid(widgetId, true); std::string fnUpper = base::string_to_upper(base::get_file_title(inputFn)); - std::string widgetType = convert_type(elem->Value()); + std::string widgetType = convert_type(elem->Value(), false); std::cout << "#ifndef GENERATED_" << fnUpper << "_H_INCLUDED\n" @@ -111,6 +117,7 @@ void gen_ui_class(TiXmlDocument* doc, << "\n" << "#include \"app/find_widget.h\"\n" << "#include \"app/load_widget.h\"\n" + << "#include \"app/ui/pref_widget.h\"\n" << "#include \"ui/ui.h\"\n" << "\n" << "namespace app {\n" @@ -149,8 +156,9 @@ void gen_ui_class(TiXmlDocument* doc, << "\n"; for (TiXmlElement* elem : widgets) { - std::string childType = convert_type(elem->Value()); const char* id = elem->Attribute("id"); + const char* pref = elem->Attribute("pref"); + std::string childType = convert_type(elem->Value(), (pref != nullptr)); std::string cppid = convert_xmlid_to_cppid(id, false); std::cout << " " << childType << "* " << cppid << "() const { return m_" << cppid << "; }\n"; @@ -161,8 +169,9 @@ void gen_ui_class(TiXmlDocument* doc, << " private:\n"; for (TiXmlElement* elem : widgets) { - std::string childType = convert_type(elem->Value()); const char* id = elem->Attribute("id"); + const char* pref = elem->Attribute("pref"); + std::string childType = convert_type(elem->Value(), (pref != nullptr)); std::string cppid = convert_xmlid_to_cppid(id, false); std::cout << " " << childType << "* m_" << cppid << ";\n";