Change themes folder from "data/skins" to "data/themes"

This commit is contained in:
David Capello 2017-02-09 13:18:44 -03:00
parent 7e6fc5a815
commit e6fd892a40
13 changed files with 64 additions and 52 deletions

View File

Before

Width:  |  Height:  |  Size: 9.6 KiB

After

Width:  |  Height:  |  Size: 9.6 KiB

View File

Before

Width:  |  Height:  |  Size: 1.5 KiB

After

Width:  |  Height:  |  Size: 1.5 KiB

View File

Before

Width:  |  Height:  |  Size: 1.1 KiB

After

Width:  |  Height:  |  Size: 1.1 KiB

View File

Before

Width:  |  Height:  |  Size: 14 KiB

After

Width:  |  Height:  |  Size: 14 KiB

View File

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<skin name="Default"
author="Ilija Melentijevic &amp; David Capello"
url="http://ilkke.blogspot.com/">
<theme name="Default"
author="Ilija Melentijevic &amp; David Capello"
url="http://ilkke.blogspot.com/">
<dimensions>
<dim id="scrollbar_size" value="12" />
@ -911,4 +911,4 @@
</stylesheet>
</skin>
</theme>

View File

@ -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})

View File

@ -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<std::string> themeFolders() {
ResourceFinder rf;
rf.includeDataDir("skins");
rf.includeDataDir(skin::SkinTheme::kThemesFolderName);
std::vector<std::string> paths;
while (rf.next())

View File

@ -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<SkinTheme>::updateInternals();
ThemeFile<SkinTheme>::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

View File

@ -15,7 +15,7 @@
#include "ui/manager.h"
#include "ui/theme.h"
#include "skin.xml.h"
#include "theme.xml.h"
#include <map>
#include <string>
@ -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<SkinTheme> {
, public app::gen::ThemeFile<SkinTheme> {
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<std::string, SkinPartPtr> m_parts_by_id;

View File

@ -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)

View File

@ -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("<id>");
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("<dir>");
PO::Option& stringsDir = po.add("strings-dir").requiresValue("<dir>");
@ -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)) {

View File

@ -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 <iostream>
#include <vector>
void gen_skin_class(TiXmlDocument* doc, const std::string& inputFn)
void gen_theme_class(TiXmlDocument* doc, const std::string& inputFn)
{
std::vector<std::string> dimensions;
std::vector<std::string> 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<typename T>\n"
<< " class SkinFile {\n"
<< " class ThemeFile {\n"
<< " public:\n"
<< "\n";
// Dimensions sub class
std::cout
<< " class Dimensions {\n"
<< " template<typename> friend class SkinFile;\n"
<< " template<typename> 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<typename> friend class SkinFile;\n"
<< " template<typename> 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<typename> friend class SkinFile;\n"
<< " template<typename> 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<typename> friend class SkinFile;\n"
<< " template<typename> friend class ThemeFile;\n"
<< " public:\n";
for (auto style : styles) {
std::string id = convert_xmlid_to_cppid(style, false);

View File

@ -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 <string>
#include "tinyxml.h"
void gen_skin_class(TiXmlDocument* doc, const std::string& inputFn);
void gen_theme_class(TiXmlDocument* doc, const std::string& inputFn);
#endif