[aseprite] 58/250: Fix loading of non-default themes with missing parts
Tobias Hansen
thansen at moszumanska.debian.org
Sun Dec 20 15:27:11 UTC 2015
This is an automated email from the git hooks/post-receive script.
thansen pushed a commit to branch master
in repository aseprite.
commit 09e18ddf2bcc23869d35b2489b0f1405658d59e5
Author: David Capello <davidcapello at gmail.com>
Date: Fri Sep 18 13:05:52 2015 -0300
Fix loading of non-default themes with missing parts
---
src/app/ui/skin/skin_theme.cpp | 42 ++++++++++++++++++++++++++++++------------
src/app/ui/skin/skin_theme.h | 7 ++++---
2 files changed, 34 insertions(+), 15 deletions(-)
diff --git a/src/app/ui/skin/skin_theme.cpp b/src/app/ui/skin/skin_theme.cpp
index 68413f6..a26f23a 100644
--- a/src/app/ui/skin/skin_theme.cpp
+++ b/src/app/ui/skin/skin_theme.cpp
@@ -144,7 +144,6 @@ SkinTheme* SkinTheme::instance()
SkinTheme::SkinTheme()
: m_cursors(ui::kCursorTypes, NULL)
{
- m_selected_skin = Preferences::instance().theme.selected();
m_defaultFont = nullptr;
m_miniFont = nullptr;
@@ -176,9 +175,29 @@ SkinTheme::~SkinTheme()
m_miniFont->dispose();
}
-void SkinTheme::loadSheet()
+void SkinTheme::onRegenerate()
{
- TRACE("SkinTheme::loadSheet()\n");
+ Preferences& pref = Preferences::instance();
+
+ // First we load the skin from default theme, which is more proper
+ // to have every single needed skin part/color/dimension.
+ loadAll(pref.theme.selected.defaultValue());
+
+ // Then we load the selected theme to redefine default theme parts.
+ if (pref.theme.selected.defaultValue() != pref.theme.selected())
+ loadAll(pref.theme.selected());
+}
+
+void SkinTheme::loadAll(const std::string& skinId)
+{
+ loadSheet(skinId);
+ loadFonts(skinId);
+ loadXml(skinId);
+}
+
+void SkinTheme::loadSheet(const std::string& skinId)
+{
+ TRACE("SkinTheme::loadSheet(%s)\n", skinId.c_str());
if (m_sheet) {
m_sheet->dispose();
@@ -186,7 +205,7 @@ void SkinTheme::loadSheet()
}
// Load the skin sheet
- std::string sheet_filename("skins/" + m_selected_skin + "/sheet.png");
+ std::string sheet_filename("skins/" + skinId + "/sheet.png");
ResourceFinder rf;
rf.includeDataDir(sheet_filename.c_str());
@@ -201,26 +220,25 @@ void SkinTheme::loadSheet()
}
}
-void SkinTheme::loadFonts()
+void SkinTheme::loadFonts(const std::string& skinId)
{
- TRACE("SkinTheme::loadFonts()\n");
+ TRACE("SkinTheme::loadFonts(%s)\n", skinId.c_str());
if (m_defaultFont) m_defaultFont->dispose();
if (m_miniFont) m_miniFont->dispose();
Preferences& pref = Preferences::instance();
- m_defaultFont = loadFont(pref.theme.font(), "skins/" + m_selected_skin + "/font.png");
- m_miniFont = loadFont(pref.theme.miniFont(), "skins/" + m_selected_skin + "/minifont.png");
+ m_defaultFont = loadFont(pref.theme.font(), "skins/" + skinId + "/font.png");
+ m_miniFont = loadFont(pref.theme.miniFont(), "skins/" + skinId + "/minifont.png");
}
-void SkinTheme::onRegenerate()
+void SkinTheme::loadXml(const std::string& skinId)
{
- loadSheet();
- loadFonts();
+ TRACE("SkinTheme::loadXml(%s)\n", skinId.c_str());
// Load the skin XML
- std::string xml_filename = "skins/" + m_selected_skin + "/skin.xml";
+ std::string xml_filename = "skins/" + skinId + "/skin.xml";
ResourceFinder rf;
rf.includeDataDir(xml_filename.c_str());
if (!rf.findFirst())
diff --git a/src/app/ui/skin/skin_theme.h b/src/app/ui/skin/skin_theme.h
index 35daf7d..60e7301 100644
--- a/src/app/ui/skin/skin_theme.h
+++ b/src/app/ui/skin/skin_theme.h
@@ -119,8 +119,10 @@ namespace app {
void onRegenerate() override;
private:
- void loadSheet();
- void loadFonts();
+ void loadAll(const std::string& skinId);
+ void loadSheet(const std::string& skinId);
+ void loadFonts(const std::string& skinId);
+ void loadXml(const std::string& skinId);
she::Surface* sliceSheet(she::Surface* sur, const gfx::Rect& bounds);
gfx::Color getWidgetBgColor(ui::Widget* widget);
@@ -133,7 +135,6 @@ namespace app {
she::Font* loadFont(const std::string& userFont, const std::string& themeFont);
- std::string m_selected_skin;
she::Surface* m_sheet;
std::map<std::string, SkinPartPtr> m_parts_by_id;
std::map<std::string, she::Surface*> m_toolicon;
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-games/aseprite.git
More information about the Pkg-games-commits
mailing list