mirror of
https://github.com/aseprite/aseprite.git
synced 2025-04-16 14:42:44 +00:00
Add "Theme" section in Preferences
This commit is contained in:
parent
3abea9c4b3
commit
df629db6c6
@ -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" />
|
||||
|
@ -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;
|
||||
|
Loading…
x
Reference in New Issue
Block a user