diff --git a/data/skins/default/font.png b/data/themes/default/font.png similarity index 100% rename from data/skins/default/font.png rename to data/themes/default/font.png diff --git a/data/skins/default/minifont.png b/data/themes/default/minifont.png similarity index 100% rename from data/skins/default/minifont.png rename to data/themes/default/minifont.png diff --git a/data/skins/default/palette.png b/data/themes/default/palette.png similarity index 100% rename from data/skins/default/palette.png rename to data/themes/default/palette.png diff --git a/data/skins/default/sheet.png b/data/themes/default/sheet.png similarity index 100% rename from data/skins/default/sheet.png rename to data/themes/default/sheet.png diff --git a/data/skins/default/skin.xml b/data/themes/default/theme.xml similarity index 97% rename from data/skins/default/skin.xml rename to data/themes/default/theme.xml index faad2365a..b9e8e5662 100644 --- a/data/skins/default/skin.xml +++ b/data/themes/default/theme.xml @@ -1,7 +1,7 @@ - + @@ -911,4 +911,4 @@ - + diff --git a/src/app/CMakeLists.txt b/src/app/CMakeLists.txt index 117fcd3bb..ae7b408e7 100644 --- a/src/app/CMakeLists.txt +++ b/src/app/CMakeLists.txt @@ -41,15 +41,15 @@ add_custom_command( DEPENDS gen) list(APPEND generated_files ${output_fn}) -# Generate skin.xml.h from data/skins/default/skin.xml -set(skin_xml ${CMAKE_SOURCE_DIR}/data/skins/default/skin.xml) -set(output_fn ${CMAKE_CURRENT_BINARY_DIR}/skin.xml.h) +# Generate theme.xml.h from data/themes/default/theme.xml +set(theme_xml ${CMAKE_SOURCE_DIR}/data/themes/default/theme.xml) +set(output_fn ${CMAKE_CURRENT_BINARY_DIR}/theme.xml.h) add_custom_command( OUTPUT ${output_fn} - COMMAND ${CMAKE_BINARY_DIR}/bin/gen --input ${skin_xml} --skin > ${output_fn}.tmp + COMMAND ${CMAKE_BINARY_DIR}/bin/gen --input ${theme_xml} --theme > ${output_fn}.tmp COMMAND ${CMAKE_COMMAND} -E copy_if_different ${output_fn}.tmp ${output_fn} WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} - MAIN_DEPENDENCY ${skin_xml} + MAIN_DEPENDENCY ${theme_xml} DEPENDS gen) list(APPEND generated_files ${output_fn}) diff --git a/src/app/commands/cmd_options.cpp b/src/app/commands/cmd_options.cpp index 42cd290e4..d08ec79a8 100644 --- a/src/app/commands/cmd_options.cpp +++ b/src/app/commands/cmd_options.cpp @@ -1,5 +1,5 @@ // Aseprite -// Copyright (C) 2001-2016 David Capello +// Copyright (C) 2001-2017 David Capello // // This program is distributed under the terms of // the End-User License Agreement for Aseprite. @@ -17,6 +17,7 @@ #include "app/resource_finder.h" #include "app/send_crash.h" #include "app/ui/color_button.h" +#include "app/ui/skin/skin_theme.h" #include "base/bind.h" #include "base/convert_to.h" #include "base/fs.h" @@ -589,7 +590,7 @@ private: static std::string userThemeFolder() { ResourceFinder rf; - rf.includeDataDir("skins"); + rf.includeDataDir(skin::SkinTheme::kThemesFolderName); // Create user folder to store skins try { @@ -605,7 +606,7 @@ private: static std::vector themeFolders() { ResourceFinder rf; - rf.includeDataDir("skins"); + rf.includeDataDir(skin::SkinTheme::kThemesFolderName); std::vector paths; while (rf.next()) diff --git a/src/app/ui/skin/skin_theme.cpp b/src/app/ui/skin/skin_theme.cpp index 84b8f424f..878563139 100644 --- a/src/app/ui/skin/skin_theme.cpp +++ b/src/app/ui/skin/skin_theme.cpp @@ -49,6 +49,7 @@ namespace skin { using namespace gfx; using namespace ui; +const char* SkinTheme::kThemesFolderName = "themes"; const char* SkinTheme::kThemeCloseButtonId = "theme_close_button"; // Controls the "X" button in a window to close it. @@ -227,8 +228,7 @@ void SkinTheme::loadAll(const std::string& skinId) void SkinTheme::loadSheet(const std::string& skinId) { // Load the skin sheet - std::string sheet_filename("skins/" + skinId + "/sheet.png"); - + std::string sheet_filename(themeFileName(skinId, "sheet.png")); ResourceFinder rf; rf.includeDataDir(sheet_filename.c_str()); if (!rf.findFirst()) @@ -253,14 +253,14 @@ void SkinTheme::loadFonts(const std::string& skinId) Preferences& pref = Preferences::instance(); - m_defaultFont = loadFont(pref.theme.font(), "skins/" + skinId + "/font.png"); - m_miniFont = loadFont(pref.theme.miniFont(), "skins/" + skinId + "/minifont.png"); + m_defaultFont = loadFont(pref.theme.font(), themeFileName(skinId, "font.png")); + m_miniFont = loadFont(pref.theme.miniFont(), themeFileName(skinId, "minifont.png")); } void SkinTheme::loadXml(const std::string& skinId) { // Load the skin XML - std::string xml_filename = "skins/" + skinId + "/skin.xml"; + std::string xml_filename(themeFileName(skinId, "theme.xml")); ResourceFinder rf; rf.includeDataDir(xml_filename.c_str()); if (!rf.findFirst()) @@ -272,7 +272,7 @@ void SkinTheme::loadXml(const std::string& skinId) // Load dimension { TiXmlElement* xmlDim = handle - .FirstChild("skin") + .FirstChild("theme") .FirstChild("dimensions") .FirstChild("dim").ToElement(); while (xmlDim) { @@ -289,7 +289,7 @@ void SkinTheme::loadXml(const std::string& skinId) // Load colors { TiXmlElement* xmlColor = handle - .FirstChild("skin") + .FirstChild("theme") .FirstChild("colors") .FirstChild("color").ToElement(); while (xmlColor) { @@ -310,7 +310,7 @@ void SkinTheme::loadXml(const std::string& skinId) // Load cursors { TiXmlElement* xmlCursor = handle - .FirstChild("skin") + .FirstChild("theme") .FirstChild("cursors") .FirstChild("cursor").ToElement(); while (xmlCursor) { @@ -351,7 +351,7 @@ void SkinTheme::loadXml(const std::string& skinId) // Load tool icons { TiXmlElement* xmlIcon = handle - .FirstChild("skin") + .FirstChild("theme") .FirstChild("tools") .FirstChild("tool").ToElement(); while (xmlIcon) { @@ -375,7 +375,7 @@ void SkinTheme::loadXml(const std::string& skinId) // Load parts { TiXmlElement* xmlPart = handle - .FirstChild("skin") + .FirstChild("theme") .FirstChild("parts") .FirstChild("part").ToElement(); while (xmlPart) { @@ -421,7 +421,7 @@ void SkinTheme::loadXml(const std::string& skinId) // Load styles { TiXmlElement* xmlStyle = handle - .FirstChild("skin") + .FirstChild("theme") .FirstChild("stylesheet") .FirstChild("style").ToElement(); while (xmlStyle) { @@ -504,7 +504,7 @@ void SkinTheme::loadXml(const std::string& skinId) } } - SkinFile::updateInternals(); + ThemeFile::updateInternals(); } she::Surface* SkinTheme::sliceSheet(she::Surface* sur, const gfx::Rect& bounds) @@ -2096,5 +2096,13 @@ she::Font* SkinTheme::loadFont(const std::string& userFont, const std::string& t return nullptr; } +std::string SkinTheme::themeFileName(const std::string& skinId, + const std::string& fileName) const +{ + std::string path = base::join_path(SkinTheme::kThemesFolderName, skinId); + path = base::join_path(path, fileName); + return path; +} + } // namespace skin } // namespace app diff --git a/src/app/ui/skin/skin_theme.h b/src/app/ui/skin/skin_theme.h index a3c57dd80..bc7b6e35e 100644 --- a/src/app/ui/skin/skin_theme.h +++ b/src/app/ui/skin/skin_theme.h @@ -15,7 +15,7 @@ #include "ui/manager.h" #include "ui/theme.h" -#include "skin.xml.h" +#include "theme.xml.h" #include #include @@ -36,8 +36,9 @@ namespace app { // This is the GUI theme used by Aseprite (which use images from // data/skins directory). class SkinTheme : public ui::Theme - , public app::gen::SkinFile { + , public app::gen::ThemeFile { public: + static const char* kThemesFolderName; static const char* kThemeCloseButtonId; static SkinTheme* instance(); @@ -138,6 +139,8 @@ namespace app { void paintIcon(ui::Widget* widget, ui::Graphics* g, ui::IButtonIcon* iconInterface, int x, int y); she::Font* loadFont(const std::string& userFont, const std::string& themeFont); + std::string themeFileName(const std::string& skinId, + const std::string& fileName) const; she::Surface* m_sheet; std::map m_parts_by_id; diff --git a/src/gen/CMakeLists.txt b/src/gen/CMakeLists.txt index f836c5cd5..cfe864488 100644 --- a/src/gen/CMakeLists.txt +++ b/src/gen/CMakeLists.txt @@ -1,12 +1,12 @@ # Aseprite Code Generator -# Copyright (C) 2014-2016 David Capello +# Copyright (C) 2014-2017 David Capello add_executable(gen check_strings.cpp gen.cpp pref_types.cpp - skin_class.cpp strings_class.cpp + theme_class.cpp ui_class.cpp) if(MSVC) diff --git a/src/gen/gen.cpp b/src/gen/gen.cpp index 31282ac72..a34977160 100644 --- a/src/gen/gen.cpp +++ b/src/gen/gen.cpp @@ -1,5 +1,5 @@ // Aseprite Code Generator -// Copyright (c) 2014-2016 David Capello +// Copyright (c) 2014-2017 David Capello // // This file is released under the terms of the MIT license. // Read LICENSE.txt for more information. @@ -11,8 +11,8 @@ #include "gen/check_strings.h" #include "gen/check_strings.h" #include "gen/pref_types.h" -#include "gen/skin_class.h" #include "gen/strings_class.h" +#include "gen/theme_class.h" #include "gen/ui_class.h" #include "tinyxml.h" @@ -27,7 +27,7 @@ static void run(int argc, const char* argv[]) PO::Option& widgetId = po.add("widgetid").requiresValue(""); PO::Option& prefH = po.add("pref-h"); PO::Option& prefCpp = po.add("pref-cpp"); - PO::Option& skin = po.add("skin"); + PO::Option& theme = po.add("theme"); PO::Option& strings = po.add("strings"); PO::Option& widgetsDir = po.add("widgets-dir").requiresValue(""); PO::Option& stringsDir = po.add("strings-dir").requiresValue(""); @@ -63,9 +63,9 @@ static void run(int argc, const char* argv[]) // Generate preference c++ file else if (po.enabled(prefCpp)) gen_pref_impl(doc, inputFilename); - // Generate skin class - else if (po.enabled(skin)) - gen_skin_class(doc, inputFilename); + // Generate theme class + else if (po.enabled(theme)) + gen_theme_class(doc, inputFilename); } // Generate strings.ini.h file else if (po.enabled(strings)) { diff --git a/src/gen/skin_class.cpp b/src/gen/theme_class.cpp similarity index 89% rename from src/gen/skin_class.cpp rename to src/gen/theme_class.cpp index 66ce523e5..a31af3332 100644 --- a/src/gen/skin_class.cpp +++ b/src/gen/theme_class.cpp @@ -1,10 +1,10 @@ // Aseprite Code Generator -// Copyright (c) 2015 David Capello +// Copyright (c) 2015-2017 David Capello // // This file is released under the terms of the MIT license. // Read LICENSE.txt for more information. -#include "gen/skin_class.h" +#include "gen/theme_class.h" #include "base/string.h" #include "gen/common.h" @@ -12,7 +12,7 @@ #include #include -void gen_skin_class(TiXmlDocument* doc, const std::string& inputFn) +void gen_theme_class(TiXmlDocument* doc, const std::string& inputFn) { std::vector dimensions; std::vector colors; @@ -21,7 +21,7 @@ void gen_skin_class(TiXmlDocument* doc, const std::string& inputFn) TiXmlHandle handle(doc); TiXmlElement* elem = handle - .FirstChild("skin") + .FirstChild("theme") .FirstChild("dimensions") .FirstChild("dim").ToElement(); while (elem) { @@ -31,7 +31,7 @@ void gen_skin_class(TiXmlDocument* doc, const std::string& inputFn) } elem = handle - .FirstChild("skin") + .FirstChild("theme") .FirstChild("colors") .FirstChild("color").ToElement(); while (elem) { @@ -41,7 +41,7 @@ void gen_skin_class(TiXmlDocument* doc, const std::string& inputFn) } elem = handle - .FirstChild("skin") + .FirstChild("theme") .FirstChild("parts") .FirstChild("part").ToElement(); while (elem) { @@ -52,7 +52,7 @@ void gen_skin_class(TiXmlDocument* doc, const std::string& inputFn) } elem = handle - .FirstChild("skin") + .FirstChild("theme") .FirstChild("stylesheet") .FirstChild("style").ToElement(); while (elem) { @@ -65,22 +65,22 @@ void gen_skin_class(TiXmlDocument* doc, const std::string& inputFn) std::cout << "// Don't modify, generated file from " << inputFn << "\n" << "\n" - << "#ifndef GENERATED_SKIN_H_INCLUDED\n" - << "#define GENERATED_SKIN_H_INCLUDED\n" + << "#ifndef GENERATED_THEME_H_INCLUDED\n" + << "#define GENERATED_THEME_H_INCLUDED\n" << "#pragma once\n" << "\n" << "namespace app {\n" << "namespace gen {\n" << "\n" << " template\n" - << " class SkinFile {\n" + << " class ThemeFile {\n" << " public:\n" << "\n"; // Dimensions sub class std::cout << " class Dimensions {\n" - << " template friend class SkinFile;\n" + << " template friend class ThemeFile;\n" << " public:\n"; for (auto dimension : dimensions) { std::string id = convert_xmlid_to_cppid(dimension, false); @@ -100,7 +100,7 @@ void gen_skin_class(TiXmlDocument* doc, const std::string& inputFn) // Colors sub class std::cout << " class Colors {\n" - << " template friend class SkinFile;\n" + << " template friend class ThemeFile;\n" << " public:\n"; for (auto color : colors) { std::string id = convert_xmlid_to_cppid(color, false); @@ -120,7 +120,7 @@ void gen_skin_class(TiXmlDocument* doc, const std::string& inputFn) // Parts sub class std::cout << " class Parts {\n" - << " template friend class SkinFile;\n" + << " template friend class ThemeFile;\n" << " public:\n"; for (auto part : parts) { std::string id = convert_xmlid_to_cppid(part, false); @@ -141,7 +141,7 @@ void gen_skin_class(TiXmlDocument* doc, const std::string& inputFn) std::cout << "\n" << " class Styles {\n" - << " template friend class SkinFile;\n" + << " template friend class ThemeFile;\n" << " public:\n"; for (auto style : styles) { std::string id = convert_xmlid_to_cppid(style, false); diff --git a/src/gen/skin_class.h b/src/gen/theme_class.h similarity index 51% rename from src/gen/skin_class.h rename to src/gen/theme_class.h index d7418277f..e3a5f9cd8 100644 --- a/src/gen/skin_class.h +++ b/src/gen/theme_class.h @@ -1,16 +1,16 @@ // Aseprite Code Generator -// Copyright (c) 2015 David Capello +// Copyright (c) 2015-2017 David Capello // // This file is released under the terms of the MIT license. // Read LICENSE.txt for more information. -#ifndef GEN_SKIN_CLASS_H_INCLUDED -#define GEN_SKIN_CLASS_H_INCLUDED +#ifndef GEN_THEME_CLASS_H_INCLUDED +#define GEN_THEME_CLASS_H_INCLUDED #pragma once #include #include "tinyxml.h" -void gen_skin_class(TiXmlDocument* doc, const std::string& inputFn); +void gen_theme_class(TiXmlDocument* doc, const std::string& inputFn); #endif