[aseprite] 53/250: Use Preferences class to store the active theme

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 3abea9c4b3a9be23c200653440187fd6ee1c30bf
Author: David Capello <davidcapello at gmail.com>
Date:   Fri Sep 18 11:56:45 2015 -0300

    Use Preferences class to store the active theme
---
 data/pref.xml                  |  5 +++++
 src/app/ui/skin/skin_theme.cpp | 23 +++++++++++------------
 src/app/ui/skin/skin_theme.h   |  2 +-
 3 files changed, 17 insertions(+), 13 deletions(-)

diff --git a/data/pref.xml b/data/pref.xml
index ea80585..899cadc 100644
--- a/data/pref.xml
+++ b/data/pref.xml
@@ -90,6 +90,11 @@
       <option id="auto_select_layer" type="bool" default="false" migrate="Options.AutoSelectLayer" />
       <option id="cursor_color" type="app::Color" default="app::Color::fromMask()" migrate="Tools.CursorColor" />
     </section>
+    <section id="theme" text="Theme">
+      <option id="selected" type="std::string" default=""default"" migrate="Skin.Selected" />
+      <option id="font" type="std::string" migrate="Options.UserFont" />
+      <option id="mini_font" type="std::string" migrate="Options.UserMiniFont" />
+    </section>
     <section id="experimental" text="Experimental">
       <option id="ui_scale" type="int" default="1" />
       <option id="use_native_cursor" type="bool" default="false" migrate="Options.NativeCursor" />
diff --git a/src/app/ui/skin/skin_theme.cpp b/src/app/ui/skin/skin_theme.cpp
index 36e32eb..68413f6 100644
--- a/src/app/ui/skin/skin_theme.cpp
+++ b/src/app/ui/skin/skin_theme.cpp
@@ -9,8 +9,8 @@
 #include "config.h"
 #endif
 
-#include "app/ini_file.h"
 #include "app/modules/gui.h"
+#include "app/pref/preferences.h"
 #include "app/resource_finder.h"
 #include "app/ui/app_menuitem.h"
 #include "app/ui/keyboard_shortcuts.h"
@@ -144,7 +144,7 @@ SkinTheme* SkinTheme::instance()
 SkinTheme::SkinTheme()
   : m_cursors(ui::kCursorTypes, NULL)
 {
-  m_selected_skin = get_config_string("Skin", "Selected", "default");
+  m_selected_skin = Preferences::instance().theme.selected();
   m_defaultFont = nullptr;
   m_miniFont = nullptr;
 
@@ -208,8 +208,10 @@ void SkinTheme::loadFonts()
   if (m_defaultFont) m_defaultFont->dispose();
   if (m_miniFont) m_miniFont->dispose();
 
-  m_defaultFont = loadFont("UserFont", "skins/" + m_selected_skin + "/font.png");
-  m_miniFont = loadFont("UserMiniFont", "skins/" + m_selected_skin + "/minifont.png");
+  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");
 }
 
 void SkinTheme::onRegenerate()
@@ -1973,16 +1975,13 @@ void SkinTheme::paintIcon(Widget* widget, Graphics* g, IButtonIcon* iconInterfac
     g->drawRgbaSurface(icon_bmp, x, y);
 }
 
-she::Font* SkinTheme::loadFont(const char* userFont, const std::string& path)
+she::Font* SkinTheme::loadFont(const std::string& userFont, const std::string& themeFont)
 {
-  ResourceFinder rf;
-
   // Directories to find the font
-  const char* user_font = get_config_string("Options", userFont, "");
-  if (user_font && *user_font)
-    rf.addPath(user_font);
-
-  rf.includeDataDir(path.c_str());
+  ResourceFinder rf;
+  if (!userFont.empty())
+    rf.addPath(userFont.c_str());
+  rf.includeDataDir(themeFont.c_str());
 
   // Try to load the font
   while (rf.next()) {
diff --git a/src/app/ui/skin/skin_theme.h b/src/app/ui/skin/skin_theme.h
index db74aa4..35daf7d 100644
--- a/src/app/ui/skin/skin_theme.h
+++ b/src/app/ui/skin/skin_theme.h
@@ -131,7 +131,7 @@ namespace app {
 
       void paintIcon(ui::Widget* widget, ui::Graphics* g, ui::IButtonIcon* iconInterface, int x, int y);
 
-      she::Font* loadFont(const char* userFont, const std::string& path);
+      she::Font* loadFont(const std::string& userFont, const std::string& themeFont);
 
       std::string m_selected_skin;
       she::Surface* m_sheet;

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