[aseprite] 54/250: Add "Theme" section in Preferences
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 df629db6c60554ca7237baeda7beb1a1b4d62d77
Author: David Capello <davidcapello at gmail.com>
Date: Fri Sep 18 12:23:02 2015 -0300
Add "Theme" section in Preferences
---
data/widgets/options.xml | 13 +++++++++++
src/app/commands/cmd_options.cpp | 47 ++++++++++++++++++++++++++++++++++++++++
2 files changed, 60 insertions(+)
diff --git a/data/widgets/options.xml b/data/widgets/options.xml
index 2a7f396..5f5fa10 100644
--- a/data/widgets/options.xml
+++ b/data/widgets/options.xml
@@ -11,6 +11,7 @@
<listitem text="Timeline" value="section_timeline" />
<listitem text="Grid && Background" value="section_grid" />
<listitem text="Undo" value="section_undo" />
+ <listitem text="Theme" value="section_theme" />
<listitem text="Experimental" value="section_experimental" />
</listbox>
</view>
@@ -134,6 +135,18 @@
</vbox>
</vbox>
+ <!-- Theme -->
+ <vbox id="section_theme">
+ <separator text="Available Themes" horizontal="true" />
+ <view expansive="true" maxsize="true">
+ <listbox id="theme_list" />
+ </view>
+ <hbox>
+ <button id="select_theme" text="&Select" width="60" />
+ <boxfiller />
+ </hbox>
+ </vbox>
+
<!-- Experimental -->
<vbox id="section_experimental">
<separator text="User Interface" horizontal="true" />
diff --git a/src/app/commands/cmd_options.cpp b/src/app/commands/cmd_options.cpp
index 7701eee..22b6dea 100644
--- a/src/app/commands/cmd_options.cpp
+++ b/src/app/commands/cmd_options.cpp
@@ -22,6 +22,7 @@
#include "app/ui/color_button.h"
#include "base/bind.h"
#include "base/convert_to.h"
+#include "base/fs.h"
#include "base/path.h"
#include "doc/image.h"
#include "render/render.h"
@@ -33,6 +34,8 @@
namespace app {
+static const char* kSectionThemeId = "section_theme";
+
using namespace ui;
class OptionsWindow : public app::gen::Options {
@@ -151,6 +154,9 @@ public:
undoGotoModified()->setSelected(m_preferences.undo.gotoModified());
undoAllowNonlinearHistory()->setSelected(m_preferences.undo.allowNonlinearHistory());
+ // Theme buttons
+ selectTheme()->Click.connect(Bind<void>(&OptionsWindow::onSelectTheme, this));
+
onChangeGridScope();
sectionListbox()->selectIndex(m_curSection);
}
@@ -249,6 +255,10 @@ private:
panel()->showChild(findChild(item->getValue().c_str()));
m_curSection = sectionListbox()->getSelectedIndex();
+
+ // Load themes
+ if (item->getValue() == kSectionThemeId)
+ loadThemes();
}
void onChangeGridScope() {
@@ -318,6 +328,43 @@ private:
app::launcher::open_folder(app::main_config_filename());
}
+ void loadThemes() {
+ // Themes already loaded
+ if (themeList()->getItemsCount() > 0)
+ return;
+
+ ResourceFinder rf;
+ rf.includeDataDir("skins");
+ std::string path = rf.defaultFilename();
+ for (auto& fn : base::list_files(path)) {
+ if (!base::is_directory(base::join_path(path, fn)))
+ continue;
+
+ ListItem* item = new ListItem(fn);
+ item->setValue(fn);
+ themeList()->addChild(item);
+
+ // Selected theme
+ if (fn == m_preferences.theme.selected())
+ themeList()->selectChild(item);
+ }
+
+ themeList()->sortItems();
+ themeList()->layout();
+ }
+
+ void onSelectTheme() {
+ ListItem* item = dynamic_cast<ListItem*>(themeList()->getSelectedChild());
+ if (item &&
+ item->getValue() != m_preferences.theme.selected()) {
+ m_preferences.theme.selected(item->getValue());
+
+ ui::Alert::show(PACKAGE
+ "<<You must restart the program to see the selected theme"
+ "||&OK");
+ }
+ }
+
Preferences& m_preferences;
DocumentPreferences& m_globPref;
DocumentPreferences& m_docPref;
--
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