2015-02-12 23:16:25 +08:00
|
|
|
// Aseprite
|
2017-02-10 00:18:44 +08:00
|
|
|
// Copyright (C) 2001-2017 David Capello
|
2015-02-12 23:16:25 +08:00
|
|
|
//
|
2016-08-27 04:02:58 +08:00
|
|
|
// This program is distributed under the terms of
|
|
|
|
// the End-User License Agreement for Aseprite.
|
2012-01-06 06:45:03 +08:00
|
|
|
|
2013-08-06 08:20:19 +08:00
|
|
|
#ifdef HAVE_CONFIG_H
|
2012-01-06 06:45:03 +08:00
|
|
|
#include "config.h"
|
2013-08-06 08:20:19 +08:00
|
|
|
#endif
|
2012-01-06 06:45:03 +08:00
|
|
|
|
2013-08-06 08:20:19 +08:00
|
|
|
#include "app/app.h"
|
|
|
|
#include "app/commands/command.h"
|
|
|
|
#include "app/context.h"
|
2017-06-11 02:02:39 +08:00
|
|
|
#include "app/extensions.h"
|
2013-08-06 08:20:19 +08:00
|
|
|
#include "app/ini_file.h"
|
2014-06-14 10:00:49 +08:00
|
|
|
#include "app/launcher.h"
|
2014-12-15 07:19:31 +08:00
|
|
|
#include "app/pref/preferences.h"
|
2014-08-20 11:11:19 +08:00
|
|
|
#include "app/resource_finder.h"
|
2014-08-24 11:19:14 +08:00
|
|
|
#include "app/send_crash.h"
|
2013-08-06 08:20:19 +08:00
|
|
|
#include "app/ui/color_button.h"
|
2017-02-10 00:18:44 +08:00
|
|
|
#include "app/ui/skin/skin_theme.h"
|
2012-06-16 10:37:59 +08:00
|
|
|
#include "base/bind.h"
|
2015-04-09 18:46:55 +08:00
|
|
|
#include "base/convert_to.h"
|
2015-09-18 23:23:02 +08:00
|
|
|
#include "base/fs.h"
|
2014-10-21 09:21:31 +08:00
|
|
|
#include "doc/image.h"
|
2014-12-28 22:06:11 +08:00
|
|
|
#include "render/render.h"
|
2015-07-30 05:12:35 +08:00
|
|
|
#include "she/display.h"
|
2014-08-11 06:51:14 +08:00
|
|
|
#include "she/system.h"
|
2013-08-06 08:20:19 +08:00
|
|
|
#include "ui/ui.h"
|
2012-01-06 06:45:03 +08:00
|
|
|
|
2015-09-23 03:33:49 +08:00
|
|
|
#include "options.xml.h"
|
2014-08-10 12:12:31 +08:00
|
|
|
|
2013-08-06 08:20:19 +08:00
|
|
|
namespace app {
|
2012-06-18 09:02:54 +08:00
|
|
|
|
2016-12-05 22:58:26 +08:00
|
|
|
static const char* kSectionBgId = "section_bg";
|
|
|
|
static const char* kSectionGridId = "section_grid";
|
2015-09-18 23:23:02 +08:00
|
|
|
static const char* kSectionThemeId = "section_theme";
|
2017-06-11 02:02:39 +08:00
|
|
|
static const char* kSectionExtensionsId = "section_extensions";
|
2015-09-18 23:23:02 +08:00
|
|
|
|
2013-08-06 08:20:19 +08:00
|
|
|
using namespace ui;
|
2012-01-06 06:45:03 +08:00
|
|
|
|
2014-08-10 12:12:31 +08:00
|
|
|
class OptionsWindow : public app::gen::Options {
|
2016-07-21 05:30:03 +08:00
|
|
|
|
|
|
|
class ThemeItem : public ListItem {
|
|
|
|
public:
|
|
|
|
ThemeItem(const std::string& path,
|
|
|
|
const std::string& name)
|
|
|
|
: ListItem(name.empty() ? "-- " + path + " --": name),
|
|
|
|
m_path(path),
|
|
|
|
m_name(name) {
|
|
|
|
}
|
|
|
|
|
|
|
|
const std::string& themePath() const { return m_path; }
|
|
|
|
const std::string& themeName() const { return m_name; }
|
|
|
|
|
|
|
|
void openFolder() const {
|
|
|
|
app::launcher::open_folder(
|
|
|
|
m_name.empty() ? m_path: base::join_path(m_path, m_name));
|
|
|
|
}
|
|
|
|
|
|
|
|
bool canSelect() const {
|
|
|
|
return !m_name.empty();
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
std::string m_path;
|
|
|
|
std::string m_name;
|
|
|
|
};
|
2017-06-11 02:02:39 +08:00
|
|
|
|
|
|
|
class ExtensionItem : public ListItem {
|
|
|
|
public:
|
|
|
|
ExtensionItem(Extension* extension)
|
|
|
|
: ListItem(extension->displayName())
|
|
|
|
, m_extension(extension) {
|
|
|
|
}
|
|
|
|
|
|
|
|
bool isEnabled() const { return m_extension->isEnabled(); }
|
|
|
|
bool isInstalled() const { return m_extension->isInstalled(); }
|
|
|
|
bool canBeDisabled() const { return m_extension->canBeDisabled(); }
|
|
|
|
bool canBeUninstalled() const { return m_extension->canBeUninstalled(); }
|
|
|
|
|
|
|
|
void enable(bool state) {
|
|
|
|
m_extension->enable(state);
|
|
|
|
}
|
|
|
|
|
|
|
|
void uninstall() {
|
|
|
|
ASSERT(canBeUninstalled());
|
|
|
|
m_extension->uninstall();
|
|
|
|
}
|
|
|
|
|
|
|
|
void openFolder() const {
|
|
|
|
app::launcher::open_folder(m_extension->path());
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
Extension* m_extension;
|
|
|
|
};
|
|
|
|
|
2012-01-06 06:45:03 +08:00
|
|
|
public:
|
2015-02-15 09:43:21 +08:00
|
|
|
OptionsWindow(Context* context, int& curSection)
|
2016-03-25 01:29:15 +08:00
|
|
|
: m_pref(Preferences::instance())
|
|
|
|
, m_globPref(m_pref.document(nullptr))
|
|
|
|
, m_docPref(m_pref.document(context->activeDocument()))
|
2015-02-15 10:31:11 +08:00
|
|
|
, m_curPref(&m_docPref)
|
2015-02-15 09:43:21 +08:00
|
|
|
, m_curSection(curSection)
|
2014-06-23 08:56:04 +08:00
|
|
|
{
|
2015-12-05 02:17:42 +08:00
|
|
|
sectionListbox()->Change.connect(base::Bind<void>(&OptionsWindow::onChangeSection, this));
|
2016-03-25 01:29:15 +08:00
|
|
|
|
|
|
|
// Cursor
|
2016-08-31 22:22:08 +08:00
|
|
|
paintingCursorType()->setSelectedItemIndex(int(m_pref.cursor.paintingCursorType()));
|
2017-03-25 12:15:40 +08:00
|
|
|
cursorColor()->setColor(m_pref.cursor.cursorColor());
|
2016-03-25 01:29:15 +08:00
|
|
|
|
2017-03-25 12:15:40 +08:00
|
|
|
if (cursorColor()->getColor().getType() == app::Color::MaskType) {
|
2016-03-25 01:29:15 +08:00
|
|
|
cursorColorType()->setSelectedItemIndex(0);
|
2017-03-25 12:15:40 +08:00
|
|
|
cursorColor()->setVisible(false);
|
2016-03-25 01:29:15 +08:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
cursorColorType()->setSelectedItemIndex(1);
|
2017-03-25 12:15:40 +08:00
|
|
|
cursorColor()->setVisible(true);
|
2016-03-25 01:29:15 +08:00
|
|
|
}
|
|
|
|
cursorColorType()->Change.connect(base::Bind<void>(&OptionsWindow::onCursorColorType, this));
|
|
|
|
|
|
|
|
// Brush preview
|
|
|
|
brushPreview()->setSelectedItemIndex(
|
2016-08-31 03:52:03 +08:00
|
|
|
(int)m_pref.cursor.brushPreview());
|
2014-06-23 08:56:04 +08:00
|
|
|
|
2017-03-25 12:01:59 +08:00
|
|
|
// Guide colors
|
|
|
|
layerEdgesColor()->setColor(m_pref.guides.layerEdgesColor());
|
|
|
|
autoGuidesColor()->setColor(m_pref.guides.autoGuidesColor());
|
|
|
|
|
|
|
|
// Slices default color
|
|
|
|
defaultSliceColor()->setColor(m_pref.slices.defaultColor());
|
|
|
|
|
2014-06-23 08:56:04 +08:00
|
|
|
// Others
|
2016-03-25 01:29:15 +08:00
|
|
|
if (m_pref.general.autoshowTimeline())
|
2014-08-10 12:12:31 +08:00
|
|
|
autotimeline()->setSelected(true);
|
2014-06-23 08:56:04 +08:00
|
|
|
|
2016-03-25 01:29:15 +08:00
|
|
|
if (m_pref.general.rewindOnStop())
|
2015-06-19 23:09:34 +08:00
|
|
|
rewindOnStop()->setSelected(true);
|
|
|
|
|
2016-11-23 05:05:56 +08:00
|
|
|
firstFrame()->setTextf("%d", m_globPref.timeline.firstFrame());
|
|
|
|
|
2016-03-25 01:29:15 +08:00
|
|
|
if (m_pref.general.expandMenubarOnMouseover())
|
2014-10-25 22:24:29 +08:00
|
|
|
expandMenubarOnMouseover()->setSelected(true);
|
|
|
|
|
2016-03-25 01:29:15 +08:00
|
|
|
if (m_pref.general.dataRecovery())
|
2015-04-09 07:28:30 +08:00
|
|
|
enableDataRecovery()->setSelected(true);
|
|
|
|
|
2016-07-25 22:04:16 +08:00
|
|
|
if (m_pref.general.showFullPath())
|
|
|
|
showFullPath()->setSelected(true);
|
|
|
|
|
2015-04-09 18:46:55 +08:00
|
|
|
dataRecoveryPeriod()->setSelectedItemIndex(
|
|
|
|
dataRecoveryPeriod()->findItemIndexByValue(
|
2016-03-25 01:29:15 +08:00
|
|
|
base::convert_to<std::string>(m_pref.general.dataRecoveryPeriod())));
|
2015-04-09 18:46:55 +08:00
|
|
|
|
2016-03-25 01:29:15 +08:00
|
|
|
if (m_pref.editor.zoomFromCenterWithWheel())
|
2015-05-08 02:52:26 +08:00
|
|
|
zoomFromCenterWithWheel()->setSelected(true);
|
2014-11-08 06:11:23 +08:00
|
|
|
|
2016-03-25 01:29:15 +08:00
|
|
|
if (m_pref.editor.zoomFromCenterWithKeys())
|
2015-05-08 02:56:38 +08:00
|
|
|
zoomFromCenterWithKeys()->setSelected(true);
|
|
|
|
|
2016-03-25 01:29:15 +08:00
|
|
|
if (m_pref.selection.autoOpaque())
|
2015-07-27 22:43:48 +08:00
|
|
|
autoOpaque()->setSelected(true);
|
|
|
|
|
2016-03-25 01:29:15 +08:00
|
|
|
if (m_pref.selection.keepSelectionAfterClear())
|
2015-12-23 04:49:21 +08:00
|
|
|
keepSelectionAfterClear()->setSelected(true);
|
|
|
|
|
2017-04-07 06:12:36 +08:00
|
|
|
if (m_pref.selection.moveEdges())
|
|
|
|
moveEdges()->setSelected(true);
|
|
|
|
|
2017-04-22 02:31:22 +08:00
|
|
|
// If the platform supports native cursors...
|
|
|
|
if ((int(she::instance()->capabilities()) &
|
|
|
|
int(she::Capabilities::CustomNativeMouseCursor)) != 0) {
|
|
|
|
if (m_pref.cursor.useNativeCursor())
|
|
|
|
nativeCursor()->setSelected(true);
|
|
|
|
nativeCursor()->Click.connect(base::Bind<void>(&OptionsWindow::onNativeCursorChange, this));
|
|
|
|
|
|
|
|
cursorScale()->setSelectedItemIndex(
|
|
|
|
cursorScale()->findItemIndexByValue(
|
|
|
|
base::convert_to<std::string>(m_pref.cursor.cursorScale())));
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
nativeCursor()->setEnabled(false);
|
|
|
|
}
|
|
|
|
|
2016-08-31 04:27:19 +08:00
|
|
|
onNativeCursorChange();
|
2014-08-11 06:51:14 +08:00
|
|
|
|
2016-03-25 01:29:15 +08:00
|
|
|
if (m_pref.experimental.useNativeFileDialog())
|
2015-03-03 03:07:35 +08:00
|
|
|
nativeFileDialog()->setSelected(true);
|
|
|
|
|
2016-03-25 01:29:15 +08:00
|
|
|
if (m_pref.experimental.flashLayer())
|
2014-10-26 03:04:39 +08:00
|
|
|
flashLayer()->setSelected(true);
|
|
|
|
|
2016-12-02 02:20:35 +08:00
|
|
|
nonactiveLayersOpacity()->setValue(m_pref.experimental.nonactiveLayersOpacity());
|
|
|
|
|
2016-03-25 01:29:15 +08:00
|
|
|
if (m_pref.editor.showScrollbars())
|
2014-08-10 12:12:31 +08:00
|
|
|
showScrollbars()->setSelected(true);
|
2014-06-23 08:56:04 +08:00
|
|
|
|
2016-12-03 07:37:54 +08:00
|
|
|
if (m_pref.editor.autoScroll())
|
|
|
|
autoScroll()->setSelected(true);
|
|
|
|
|
2015-02-15 10:31:11 +08:00
|
|
|
// Scope
|
2016-12-05 22:58:26 +08:00
|
|
|
bgScope()->addItem("Background for New Documents");
|
|
|
|
gridScope()->addItem("Grid for New Documents");
|
2015-02-15 10:31:11 +08:00
|
|
|
if (context->activeDocument()) {
|
2016-12-05 22:58:26 +08:00
|
|
|
bgScope()->addItem("Background for the Active Document");
|
2016-12-05 22:06:32 +08:00
|
|
|
bgScope()->setSelectedItemIndex(1);
|
|
|
|
bgScope()->Change.connect(base::Bind<void>(&OptionsWindow::onChangeBgScope, this));
|
|
|
|
|
2016-12-05 22:58:26 +08:00
|
|
|
gridScope()->addItem("Grid for the Active Document");
|
2015-02-15 10:31:11 +08:00
|
|
|
gridScope()->setSelectedItemIndex(1);
|
2015-12-05 02:17:42 +08:00
|
|
|
gridScope()->Change.connect(base::Bind<void>(&OptionsWindow::onChangeGridScope, this));
|
2015-02-15 10:31:11 +08:00
|
|
|
}
|
|
|
|
|
2015-04-17 22:11:36 +08:00
|
|
|
// Screen/UI Scale
|
|
|
|
screenScale()->setSelectedItemIndex(
|
|
|
|
screenScale()->findItemIndexByValue(
|
2016-03-25 01:29:15 +08:00
|
|
|
base::convert_to<std::string>(m_pref.general.screenScale())));
|
2015-04-17 22:11:36 +08:00
|
|
|
|
|
|
|
uiScale()->setSelectedItemIndex(
|
|
|
|
uiScale()->findItemIndexByValue(
|
2016-09-09 20:46:10 +08:00
|
|
|
base::convert_to<std::string>(m_pref.general.uiScale())));
|
2014-06-23 08:56:04 +08:00
|
|
|
|
2015-10-06 08:18:42 +08:00
|
|
|
if ((int(she::instance()->capabilities()) &
|
|
|
|
int(she::Capabilities::GpuAccelerationSwitch)) == int(she::Capabilities::GpuAccelerationSwitch)) {
|
2016-03-25 01:29:15 +08:00
|
|
|
gpuAcceleration()->setSelected(m_pref.general.gpuAcceleration());
|
2015-10-06 08:18:42 +08:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
gpuAcceleration()->setVisible(false);
|
|
|
|
}
|
|
|
|
|
2016-12-19 01:44:39 +08:00
|
|
|
showHome()->setSelected(m_pref.general.showHome());
|
|
|
|
|
2014-08-19 19:17:57 +08:00
|
|
|
// Right-click
|
2016-12-01 08:07:30 +08:00
|
|
|
|
|
|
|
static_assert(int(app::gen::RightClickMode::PAINT_BGCOLOR) == 0, "");
|
|
|
|
static_assert(int(app::gen::RightClickMode::PICK_FGCOLOR) == 1, "");
|
|
|
|
static_assert(int(app::gen::RightClickMode::ERASE) == 2, "");
|
|
|
|
static_assert(int(app::gen::RightClickMode::SCROLL) == 3, "");
|
|
|
|
static_assert(int(app::gen::RightClickMode::RECTANGULAR_MARQUEE) == 4, "");
|
|
|
|
static_assert(int(app::gen::RightClickMode::LASSO) == 5, "");
|
|
|
|
|
2014-08-19 19:17:57 +08:00
|
|
|
rightClickBehavior()->addItem("Paint with background color");
|
|
|
|
rightClickBehavior()->addItem("Pick foreground color");
|
|
|
|
rightClickBehavior()->addItem("Erase");
|
2015-08-20 05:00:51 +08:00
|
|
|
rightClickBehavior()->addItem("Scroll");
|
2016-12-01 08:07:30 +08:00
|
|
|
rightClickBehavior()->addItem("Rectangular Marquee");
|
|
|
|
rightClickBehavior()->addItem("Lasso");
|
2016-03-25 01:29:15 +08:00
|
|
|
rightClickBehavior()->setSelectedItemIndex((int)m_pref.editor.rightClickMode());
|
2014-08-19 19:17:57 +08:00
|
|
|
|
2014-06-23 09:35:51 +08:00
|
|
|
// Zoom with Scroll Wheel
|
2016-03-25 01:29:15 +08:00
|
|
|
wheelZoom()->setSelected(m_pref.editor.zoomWithWheel());
|
2014-06-23 09:35:51 +08:00
|
|
|
|
2016-05-28 00:15:13 +08:00
|
|
|
// Zoom sliding two fingers
|
|
|
|
#if __APPLE__
|
|
|
|
slideZoom()->setSelected(m_pref.editor.zoomWithSlide());
|
|
|
|
#else
|
|
|
|
slideZoom()->setVisible(false);
|
|
|
|
#endif
|
|
|
|
|
2014-06-23 08:56:04 +08:00
|
|
|
// Checked background size
|
2014-08-10 12:12:31 +08:00
|
|
|
checkedBgSize()->addItem("16x16");
|
|
|
|
checkedBgSize()->addItem("8x8");
|
|
|
|
checkedBgSize()->addItem("4x4");
|
|
|
|
checkedBgSize()->addItem("2x2");
|
2014-06-23 08:56:04 +08:00
|
|
|
|
2016-12-05 22:06:32 +08:00
|
|
|
// Reset buttons
|
|
|
|
resetBg()->Click.connect(base::Bind<void>(&OptionsWindow::onResetBg, this));
|
|
|
|
resetGrid()->Click.connect(base::Bind<void>(&OptionsWindow::onResetGrid, this));
|
2014-06-23 08:56:04 +08:00
|
|
|
|
2014-08-20 11:11:19 +08:00
|
|
|
// Links
|
2015-12-05 02:17:42 +08:00
|
|
|
locateFile()->Click.connect(base::Bind<void>(&OptionsWindow::onLocateConfigFile, this));
|
2015-02-12 23:46:56 +08:00
|
|
|
#if _WIN32
|
2015-12-05 02:17:42 +08:00
|
|
|
locateCrashFolder()->Click.connect(base::Bind<void>(&OptionsWindow::onLocateCrashFolder, this));
|
2014-08-20 11:11:19 +08:00
|
|
|
#else
|
|
|
|
locateCrashFolder()->setVisible(false);
|
|
|
|
#endif
|
2014-06-23 08:56:04 +08:00
|
|
|
|
2015-01-19 09:05:33 +08:00
|
|
|
// Undo preferences
|
2016-03-25 01:29:15 +08:00
|
|
|
undoSizeLimit()->setTextf("%d", m_pref.undo.sizeLimit());
|
|
|
|
undoGotoModified()->setSelected(m_pref.undo.gotoModified());
|
|
|
|
undoAllowNonlinearHistory()->setSelected(m_pref.undo.allowNonlinearHistory());
|
2014-06-23 08:56:04 +08:00
|
|
|
|
2015-09-18 23:23:02 +08:00
|
|
|
// Theme buttons
|
2016-07-21 05:30:03 +08:00
|
|
|
themeList()->Change.connect(base::Bind<void>(&OptionsWindow::onThemeChange, this));
|
2015-12-05 02:17:42 +08:00
|
|
|
selectTheme()->Click.connect(base::Bind<void>(&OptionsWindow::onSelectTheme, this));
|
|
|
|
openThemeFolder()->Click.connect(base::Bind<void>(&OptionsWindow::onOpenThemeFolder, this));
|
2015-09-18 23:23:02 +08:00
|
|
|
|
2017-06-11 02:02:39 +08:00
|
|
|
// Extensions buttons
|
|
|
|
extensionsList()->Change.connect(base::Bind<void>(&OptionsWindow::onExtensionChange, this));
|
|
|
|
newExtension()->Click.connect(base::Bind<void>(&OptionsWindow::onNewExtension, this));
|
|
|
|
disableExtension()->Click.connect(base::Bind<void>(&OptionsWindow::onDisableExtension, this));
|
|
|
|
uninstallExtension()->Click.connect(base::Bind<void>(&OptionsWindow::onUninstallExtension, this));
|
|
|
|
openExtensionFolder()->Click.connect(base::Bind<void>(&OptionsWindow::onOpenExtensionFolder, this));
|
|
|
|
|
2015-12-20 23:58:25 +08:00
|
|
|
// Apply button
|
|
|
|
buttonApply()->Click.connect(base::Bind<void>(&OptionsWindow::saveConfig, this));
|
|
|
|
|
2016-12-05 22:06:32 +08:00
|
|
|
onChangeBgScope();
|
2015-02-15 10:31:11 +08:00
|
|
|
onChangeGridScope();
|
2015-02-15 09:43:21 +08:00
|
|
|
sectionListbox()->selectIndex(m_curSection);
|
2014-06-23 08:56:04 +08:00
|
|
|
}
|
2012-01-06 06:45:03 +08:00
|
|
|
|
2014-06-23 08:56:04 +08:00
|
|
|
bool ok() {
|
2015-12-05 01:54:15 +08:00
|
|
|
return (closer() == buttonOk());
|
2014-06-23 08:56:04 +08:00
|
|
|
}
|
2012-01-06 06:45:03 +08:00
|
|
|
|
2014-06-23 08:56:04 +08:00
|
|
|
void saveConfig() {
|
2016-03-25 01:29:15 +08:00
|
|
|
m_pref.general.autoshowTimeline(autotimeline()->isSelected());
|
|
|
|
m_pref.general.rewindOnStop(rewindOnStop()->isSelected());
|
2016-11-23 05:05:56 +08:00
|
|
|
m_globPref.timeline.firstFrame(firstFrame()->textInt());
|
2016-07-25 22:04:16 +08:00
|
|
|
m_pref.general.showFullPath(showFullPath()->isSelected());
|
2012-01-06 06:45:03 +08:00
|
|
|
|
2014-10-25 22:24:29 +08:00
|
|
|
bool expandOnMouseover = expandMenubarOnMouseover()->isSelected();
|
2016-03-25 01:29:15 +08:00
|
|
|
m_pref.general.expandMenubarOnMouseover(expandOnMouseover);
|
2014-10-25 22:24:29 +08:00
|
|
|
ui::MenuBar::setExpandOnMouseover(expandOnMouseover);
|
|
|
|
|
2015-04-09 07:28:30 +08:00
|
|
|
std::string warnings;
|
|
|
|
|
2016-11-13 05:02:47 +08:00
|
|
|
double newPeriod = base::convert_to<double>(dataRecoveryPeriod()->getValue());
|
2016-03-25 01:29:15 +08:00
|
|
|
if (enableDataRecovery()->isSelected() != m_pref.general.dataRecovery() ||
|
|
|
|
newPeriod != m_pref.general.dataRecoveryPeriod()) {
|
|
|
|
m_pref.general.dataRecovery(enableDataRecovery()->isSelected());
|
|
|
|
m_pref.general.dataRecoveryPeriod(newPeriod);
|
2015-04-09 18:46:55 +08:00
|
|
|
|
|
|
|
warnings += "<<- Automatically save recovery data every";
|
2015-04-09 07:28:30 +08:00
|
|
|
}
|
|
|
|
|
2016-03-25 01:29:15 +08:00
|
|
|
m_pref.editor.zoomFromCenterWithWheel(zoomFromCenterWithWheel()->isSelected());
|
|
|
|
m_pref.editor.zoomFromCenterWithKeys(zoomFromCenterWithKeys()->isSelected());
|
|
|
|
m_pref.editor.showScrollbars(showScrollbars()->isSelected());
|
2016-12-03 07:37:54 +08:00
|
|
|
m_pref.editor.autoScroll(autoScroll()->isSelected());
|
2016-03-25 01:29:15 +08:00
|
|
|
m_pref.editor.zoomWithWheel(wheelZoom()->isSelected());
|
2016-05-28 00:15:13 +08:00
|
|
|
#if __APPLE__
|
|
|
|
m_pref.editor.zoomWithSlide(slideZoom()->isSelected());
|
|
|
|
#endif
|
2016-03-25 01:29:15 +08:00
|
|
|
m_pref.editor.rightClickMode(static_cast<app::gen::RightClickMode>(rightClickBehavior()->getSelectedItemIndex()));
|
2016-08-31 22:22:08 +08:00
|
|
|
m_pref.cursor.paintingCursorType(static_cast<app::gen::PaintingCursorType>(paintingCursorType()->getSelectedItemIndex()));
|
2017-03-25 12:15:40 +08:00
|
|
|
m_pref.cursor.cursorColor(cursorColor()->getColor());
|
2016-08-31 03:52:03 +08:00
|
|
|
m_pref.cursor.brushPreview(static_cast<app::gen::BrushPreview>(brushPreview()->getSelectedItemIndex()));
|
|
|
|
m_pref.cursor.useNativeCursor(nativeCursor()->isSelected());
|
2016-08-31 04:27:19 +08:00
|
|
|
m_pref.cursor.cursorScale(base::convert_to<int>(cursorScale()->getValue()));
|
2016-03-25 01:29:15 +08:00
|
|
|
m_pref.selection.autoOpaque(autoOpaque()->isSelected());
|
|
|
|
m_pref.selection.keepSelectionAfterClear(keepSelectionAfterClear()->isSelected());
|
2017-04-07 06:12:36 +08:00
|
|
|
m_pref.selection.moveEdges(moveEdges()->isSelected());
|
2017-03-25 12:01:59 +08:00
|
|
|
m_pref.guides.layerEdgesColor(layerEdgesColor()->getColor());
|
|
|
|
m_pref.guides.autoGuidesColor(autoGuidesColor()->getColor());
|
|
|
|
m_pref.slices.defaultColor(defaultSliceColor()->getColor());
|
2014-01-27 00:28:11 +08:00
|
|
|
|
2016-12-05 22:58:26 +08:00
|
|
|
m_curPref->show.grid(gridVisible()->isSelected());
|
|
|
|
m_curPref->grid.bounds(gridBounds());
|
2017-03-25 12:15:40 +08:00
|
|
|
m_curPref->grid.color(gridColor()->getColor());
|
2015-02-15 20:48:38 +08:00
|
|
|
m_curPref->grid.opacity(gridOpacity()->getValue());
|
|
|
|
m_curPref->grid.autoOpacity(gridAutoOpacity()->isSelected());
|
2016-12-05 22:58:26 +08:00
|
|
|
|
|
|
|
m_curPref->show.pixelGrid(pixelGridVisible()->isSelected());
|
2017-03-25 12:15:40 +08:00
|
|
|
m_curPref->pixelGrid.color(pixelGridColor()->getColor());
|
2015-02-15 20:48:38 +08:00
|
|
|
m_curPref->pixelGrid.opacity(pixelGridOpacity()->getValue());
|
|
|
|
m_curPref->pixelGrid.autoOpacity(pixelGridAutoOpacity()->isSelected());
|
2016-12-05 22:58:26 +08:00
|
|
|
|
2015-02-15 10:31:11 +08:00
|
|
|
m_curPref->bg.type(app::gen::BgType(checkedBgSize()->getSelectedItemIndex()));
|
|
|
|
m_curPref->bg.zoom(checkedBgZoom()->isSelected());
|
2017-03-25 12:15:40 +08:00
|
|
|
m_curPref->bg.color1(checkedBgColor1()->getColor());
|
|
|
|
m_curPref->bg.color2(checkedBgColor2()->getColor());
|
2012-01-06 06:45:03 +08:00
|
|
|
|
2014-06-23 08:56:04 +08:00
|
|
|
int undo_size_limit_value;
|
Refactor several "getNoun()" getters to "noun()"
This is a work-in-progress to create a consistent API and finally
separate the whole Aseprite base/gfx/ui libs into a reusable C++ library.
Classes:
app::IFileItem, app::AppMenuItem, app::skin::SkinPart,
gfx::Rect, gfx::Border, she::FileDialog,
ui::IButtonIcon, ui::Graphics, ui::Overlay, ui::Widget,
ui::ScrollableViewDelegate, and UI events
2015-12-05 01:39:04 +08:00
|
|
|
undo_size_limit_value = undoSizeLimit()->textInt();
|
2012-01-06 06:45:03 +08:00
|
|
|
undo_size_limit_value = MID(1, undo_size_limit_value, 9999);
|
2014-07-31 11:19:58 +08:00
|
|
|
|
2016-03-25 01:29:15 +08:00
|
|
|
m_pref.undo.sizeLimit(undo_size_limit_value);
|
|
|
|
m_pref.undo.gotoModified(undoGotoModified()->isSelected());
|
|
|
|
m_pref.undo.allowNonlinearHistory(undoAllowNonlinearHistory()->isSelected());
|
2012-01-06 06:45:03 +08:00
|
|
|
|
2014-10-26 03:04:39 +08:00
|
|
|
// Experimental features
|
2016-03-25 01:29:15 +08:00
|
|
|
m_pref.experimental.useNativeFileDialog(nativeFileDialog()->isSelected());
|
|
|
|
m_pref.experimental.flashLayer(flashLayer()->isSelected());
|
2016-12-02 02:20:35 +08:00
|
|
|
m_pref.experimental.nonactiveLayersOpacity(nonactiveLayersOpacity()->getValue());
|
2016-08-31 04:27:19 +08:00
|
|
|
|
2016-08-31 03:52:03 +08:00
|
|
|
ui::set_use_native_cursors(m_pref.cursor.useNativeCursor());
|
2016-08-31 04:27:19 +08:00
|
|
|
ui::set_mouse_cursor_scale(m_pref.cursor.cursorScale());
|
2014-08-11 06:51:14 +08:00
|
|
|
|
2015-04-17 22:11:36 +08:00
|
|
|
bool reset_screen = false;
|
|
|
|
int newScreenScale = base::convert_to<int>(screenScale()->getValue());
|
2016-03-25 01:29:15 +08:00
|
|
|
if (newScreenScale != m_pref.general.screenScale()) {
|
|
|
|
m_pref.general.screenScale(newScreenScale);
|
2015-04-17 22:11:36 +08:00
|
|
|
reset_screen = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
int newUIScale = base::convert_to<int>(uiScale()->getValue());
|
2016-09-09 20:46:10 +08:00
|
|
|
if (newUIScale != m_pref.general.uiScale()) {
|
|
|
|
m_pref.general.uiScale(newUIScale);
|
2015-04-17 22:11:36 +08:00
|
|
|
warnings += "<<- UI Elements Scale";
|
2014-02-08 11:19:20 +08:00
|
|
|
}
|
|
|
|
|
2015-10-06 08:18:42 +08:00
|
|
|
bool newGpuAccel = gpuAcceleration()->isSelected();
|
2016-03-25 01:29:15 +08:00
|
|
|
if (newGpuAccel != m_pref.general.gpuAcceleration()) {
|
|
|
|
m_pref.general.gpuAcceleration(newGpuAccel);
|
2015-10-06 08:18:42 +08:00
|
|
|
reset_screen = true;
|
|
|
|
}
|
2016-12-19 01:44:39 +08:00
|
|
|
|
|
|
|
bool newShowHome = showHome()->isSelected();
|
|
|
|
if (newShowHome != m_pref.general.showHome())
|
|
|
|
m_pref.general.showHome(newShowHome);
|
2015-10-06 08:18:42 +08:00
|
|
|
|
2016-03-25 01:29:15 +08:00
|
|
|
m_pref.save();
|
2015-04-09 07:28:30 +08:00
|
|
|
|
|
|
|
if (!warnings.empty()) {
|
|
|
|
ui::Alert::show(PACKAGE
|
|
|
|
"<<You must restart the program to see your changes to:%s"
|
|
|
|
"||&OK", warnings.c_str());
|
|
|
|
}
|
2015-04-17 22:11:36 +08:00
|
|
|
|
2015-07-30 05:12:35 +08:00
|
|
|
if (reset_screen) {
|
|
|
|
ui::Manager* manager = ui::Manager::getDefault();
|
|
|
|
she::Display* display = manager->getDisplay();
|
2015-10-06 08:18:42 +08:00
|
|
|
she::instance()->setGpuAcceleration(newGpuAccel);
|
2015-10-07 04:13:50 +08:00
|
|
|
display->setScale(newScreenScale);
|
2015-07-30 05:12:35 +08:00
|
|
|
manager->setDisplay(display);
|
|
|
|
}
|
2012-01-06 06:45:03 +08:00
|
|
|
}
|
|
|
|
|
2014-06-23 08:56:04 +08:00
|
|
|
private:
|
2016-08-31 04:27:19 +08:00
|
|
|
void onNativeCursorChange() {
|
2017-04-22 02:31:22 +08:00
|
|
|
bool state =
|
|
|
|
// If the platform supports native cursors...
|
|
|
|
(((int(she::instance()->capabilities()) &
|
|
|
|
int(she::Capabilities::CustomNativeMouseCursor)) != 0) &&
|
|
|
|
// If the native cursor option is not selec
|
|
|
|
!nativeCursor()->isSelected());
|
|
|
|
|
2016-08-31 04:27:19 +08:00
|
|
|
cursorScaleLabel()->setEnabled(state);
|
|
|
|
cursorScale()->setEnabled(state);
|
|
|
|
}
|
|
|
|
|
2014-06-23 08:56:04 +08:00
|
|
|
void onChangeSection() {
|
2015-03-02 22:18:33 +08:00
|
|
|
ListItem* item = static_cast<ListItem*>(sectionListbox()->getSelectedChild());
|
2014-06-23 08:56:04 +08:00
|
|
|
if (!item)
|
|
|
|
return;
|
|
|
|
|
2014-08-10 12:12:31 +08:00
|
|
|
panel()->showChild(findChild(item->getValue().c_str()));
|
2015-02-15 09:43:21 +08:00
|
|
|
m_curSection = sectionListbox()->getSelectedIndex();
|
2015-09-18 23:23:02 +08:00
|
|
|
|
2016-12-05 22:58:26 +08:00
|
|
|
if (item->getValue() == kSectionBgId)
|
|
|
|
onChangeBgScope();
|
|
|
|
else if (item->getValue() == kSectionGridId)
|
|
|
|
onChangeGridScope();
|
2015-09-18 23:23:02 +08:00
|
|
|
// Load themes
|
2016-12-05 22:58:26 +08:00
|
|
|
else if (item->getValue() == kSectionThemeId)
|
2015-09-18 23:23:02 +08:00
|
|
|
loadThemes();
|
2017-06-11 02:02:39 +08:00
|
|
|
// Load extension
|
|
|
|
else if (item->getValue() == kSectionExtensionsId)
|
|
|
|
loadExtensions();
|
2014-06-23 08:56:04 +08:00
|
|
|
}
|
|
|
|
|
2016-12-05 22:06:32 +08:00
|
|
|
void onChangeBgScope() {
|
|
|
|
int item = bgScope()->getSelectedItemIndex();
|
|
|
|
|
|
|
|
switch (item) {
|
|
|
|
case 0: m_curPref = &m_globPref; break;
|
|
|
|
case 1: m_curPref = &m_docPref; break;
|
|
|
|
}
|
|
|
|
|
|
|
|
checkedBgSize()->setSelectedItemIndex(int(m_curPref->bg.type()));
|
|
|
|
checkedBgZoom()->setSelected(m_curPref->bg.zoom());
|
2017-03-25 12:15:40 +08:00
|
|
|
checkedBgColor1()->setColor(m_curPref->bg.color1());
|
|
|
|
checkedBgColor2()->setColor(m_curPref->bg.color2());
|
2016-12-05 22:06:32 +08:00
|
|
|
}
|
|
|
|
|
2015-02-15 10:31:11 +08:00
|
|
|
void onChangeGridScope() {
|
|
|
|
int item = gridScope()->getSelectedItemIndex();
|
|
|
|
|
|
|
|
switch (item) {
|
2015-02-15 20:48:38 +08:00
|
|
|
case 0: m_curPref = &m_globPref; break;
|
|
|
|
case 1: m_curPref = &m_docPref; break;
|
2015-02-15 10:31:11 +08:00
|
|
|
}
|
|
|
|
|
2016-12-05 22:58:26 +08:00
|
|
|
gridVisible()->setSelected(m_curPref->show.grid());
|
|
|
|
gridX()->setTextf("%d", m_curPref->grid.bounds().x);
|
|
|
|
gridY()->setTextf("%d", m_curPref->grid.bounds().y);
|
|
|
|
gridW()->setTextf("%d", m_curPref->grid.bounds().w);
|
|
|
|
gridH()->setTextf("%d", m_curPref->grid.bounds().h);
|
|
|
|
|
2017-03-25 12:15:40 +08:00
|
|
|
gridColor()->setColor(m_curPref->grid.color());
|
2015-02-15 20:48:38 +08:00
|
|
|
gridOpacity()->setValue(m_curPref->grid.opacity());
|
|
|
|
gridAutoOpacity()->setSelected(m_curPref->grid.autoOpacity());
|
2015-02-15 10:31:11 +08:00
|
|
|
|
2016-12-05 22:58:26 +08:00
|
|
|
pixelGridVisible()->setSelected(m_curPref->show.pixelGrid());
|
2017-03-25 12:15:40 +08:00
|
|
|
pixelGridColor()->setColor(m_curPref->pixelGrid.color());
|
2015-02-15 20:48:38 +08:00
|
|
|
pixelGridOpacity()->setValue(m_curPref->pixelGrid.opacity());
|
|
|
|
pixelGridAutoOpacity()->setSelected(m_curPref->pixelGrid.autoOpacity());
|
2016-12-05 22:06:32 +08:00
|
|
|
}
|
2015-02-15 10:31:11 +08:00
|
|
|
|
2016-12-05 22:06:32 +08:00
|
|
|
void onResetBg() {
|
2016-12-05 22:58:26 +08:00
|
|
|
DocumentPreferences& pref = m_globPref;
|
|
|
|
|
2016-12-05 22:06:32 +08:00
|
|
|
// Reset global preferences (use default values specified in pref.xml)
|
|
|
|
if (m_curPref == &m_globPref) {
|
|
|
|
checkedBgSize()->setSelectedItemIndex(int(pref.bg.type.defaultValue()));
|
|
|
|
checkedBgZoom()->setSelected(pref.bg.zoom.defaultValue());
|
2017-03-25 12:15:40 +08:00
|
|
|
checkedBgColor1()->setColor(pref.bg.color1.defaultValue());
|
|
|
|
checkedBgColor2()->setColor(pref.bg.color2.defaultValue());
|
2016-12-05 22:06:32 +08:00
|
|
|
}
|
|
|
|
// Reset document preferences with global settings
|
|
|
|
else {
|
|
|
|
checkedBgSize()->setSelectedItemIndex(int(pref.bg.type()));
|
|
|
|
checkedBgZoom()->setSelected(pref.bg.zoom());
|
2017-03-25 12:15:40 +08:00
|
|
|
checkedBgColor1()->setColor(pref.bg.color1());
|
|
|
|
checkedBgColor2()->setColor(pref.bg.color2());
|
2016-12-05 22:06:32 +08:00
|
|
|
}
|
2015-02-15 10:31:11 +08:00
|
|
|
}
|
|
|
|
|
2016-12-05 22:06:32 +08:00
|
|
|
void onResetGrid() {
|
2016-12-05 22:58:26 +08:00
|
|
|
DocumentPreferences& pref = m_globPref;
|
|
|
|
|
2015-05-19 03:53:25 +08:00
|
|
|
// Reset global preferences (use default values specified in pref.xml)
|
2015-02-15 20:59:11 +08:00
|
|
|
if (m_curPref == &m_globPref) {
|
2016-12-05 22:58:26 +08:00
|
|
|
gridVisible()->setSelected(pref.show.grid.defaultValue());
|
|
|
|
gridX()->setTextf("%d", pref.grid.bounds.defaultValue().x);
|
|
|
|
gridY()->setTextf("%d", pref.grid.bounds.defaultValue().y);
|
|
|
|
gridW()->setTextf("%d", pref.grid.bounds.defaultValue().w);
|
|
|
|
gridH()->setTextf("%d", pref.grid.bounds.defaultValue().h);
|
2015-02-15 20:59:11 +08:00
|
|
|
|
2017-03-25 12:15:40 +08:00
|
|
|
gridColor()->setColor(pref.grid.color.defaultValue());
|
2015-02-15 20:59:11 +08:00
|
|
|
gridOpacity()->setValue(pref.grid.opacity.defaultValue());
|
|
|
|
gridAutoOpacity()->setSelected(pref.grid.autoOpacity.defaultValue());
|
|
|
|
|
2016-12-05 22:58:26 +08:00
|
|
|
pixelGridVisible()->setSelected(pref.show.pixelGrid.defaultValue());
|
2017-03-25 12:15:40 +08:00
|
|
|
pixelGridColor()->setColor(pref.pixelGrid.color.defaultValue());
|
2015-02-15 20:59:11 +08:00
|
|
|
pixelGridOpacity()->setValue(pref.pixelGrid.opacity.defaultValue());
|
|
|
|
pixelGridAutoOpacity()->setSelected(pref.pixelGrid.autoOpacity.defaultValue());
|
|
|
|
}
|
2015-05-19 03:53:25 +08:00
|
|
|
// Reset document preferences with global settings
|
2015-02-15 20:59:11 +08:00
|
|
|
else {
|
2016-12-05 22:58:26 +08:00
|
|
|
gridVisible()->setSelected(pref.show.grid());
|
|
|
|
gridX()->setTextf("%d", pref.grid.bounds().x);
|
|
|
|
gridY()->setTextf("%d", pref.grid.bounds().y);
|
|
|
|
gridW()->setTextf("%d", pref.grid.bounds().w);
|
|
|
|
gridH()->setTextf("%d", pref.grid.bounds().h);
|
2015-02-15 20:59:11 +08:00
|
|
|
|
2017-03-25 12:15:40 +08:00
|
|
|
gridColor()->setColor(pref.grid.color());
|
2015-02-15 20:59:11 +08:00
|
|
|
gridOpacity()->setValue(pref.grid.opacity());
|
|
|
|
gridAutoOpacity()->setSelected(pref.grid.autoOpacity());
|
|
|
|
|
2016-12-05 22:58:26 +08:00
|
|
|
pixelGridVisible()->setSelected(pref.show.pixelGrid());
|
2017-03-25 12:15:40 +08:00
|
|
|
pixelGridColor()->setColor(pref.pixelGrid.color());
|
2015-02-15 20:59:11 +08:00
|
|
|
pixelGridOpacity()->setValue(pref.pixelGrid.opacity());
|
|
|
|
pixelGridAutoOpacity()->setSelected(pref.pixelGrid.autoOpacity());
|
|
|
|
}
|
2014-06-23 08:56:04 +08:00
|
|
|
}
|
|
|
|
|
2014-08-20 11:11:19 +08:00
|
|
|
void onLocateCrashFolder() {
|
2014-08-24 11:19:14 +08:00
|
|
|
app::launcher::open_folder(base::get_file_path(app::memory_dump_filename()));
|
2014-08-20 11:11:19 +08:00
|
|
|
}
|
|
|
|
|
2014-06-23 08:56:04 +08:00
|
|
|
void onLocateConfigFile() {
|
2014-10-17 08:27:25 +08:00
|
|
|
app::launcher::open_folder(app::main_config_filename());
|
2014-06-23 08:56:04 +08:00
|
|
|
}
|
|
|
|
|
2015-09-18 23:23:02 +08:00
|
|
|
void loadThemes() {
|
|
|
|
// Themes already loaded
|
|
|
|
if (themeList()->getItemsCount() > 0)
|
|
|
|
return;
|
|
|
|
|
2016-07-21 05:30:03 +08:00
|
|
|
auto userFolder = userThemeFolder();
|
|
|
|
auto folders = themeFolders();
|
|
|
|
std::sort(folders.begin(), folders.end());
|
|
|
|
|
|
|
|
for (const auto& path : folders) {
|
|
|
|
auto files = base::list_files(path);
|
|
|
|
|
|
|
|
// Only one empty theme folder: the user folder
|
|
|
|
if (files.empty() && path != userFolder)
|
2015-09-18 23:23:02 +08:00
|
|
|
continue;
|
|
|
|
|
2016-07-21 05:30:03 +08:00
|
|
|
themeList()->addChild(new ThemeItem(path, std::string()));
|
|
|
|
std::sort(files.begin(), files.end());
|
|
|
|
for (auto& fn : files) {
|
|
|
|
if (!base::is_directory(base::join_path(path, fn)))
|
|
|
|
continue;
|
|
|
|
|
|
|
|
ThemeItem* item = new ThemeItem(path, fn);
|
|
|
|
themeList()->addChild(item);
|
2015-09-18 23:23:02 +08:00
|
|
|
|
2016-07-21 05:30:03 +08:00
|
|
|
// Selected theme
|
|
|
|
if (fn == m_pref.theme.selected())
|
|
|
|
themeList()->selectChild(item);
|
|
|
|
}
|
2015-09-18 23:23:02 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
themeList()->layout();
|
|
|
|
}
|
|
|
|
|
2017-06-11 02:02:39 +08:00
|
|
|
void loadExtensions() {
|
|
|
|
// Extensions already loaded
|
|
|
|
if (extensionsList()->getItemsCount() > 0)
|
|
|
|
return;
|
|
|
|
|
|
|
|
for (auto extension : App::instance()->extensions()) {
|
|
|
|
ExtensionItem* item = new ExtensionItem(extension);
|
|
|
|
extensionsList()->addChild(item);
|
|
|
|
}
|
|
|
|
|
|
|
|
onExtensionChange();
|
|
|
|
extensionsList()->layout();
|
|
|
|
}
|
|
|
|
|
2016-07-21 05:30:03 +08:00
|
|
|
void onThemeChange() {
|
|
|
|
ThemeItem* item = dynamic_cast<ThemeItem*>(themeList()->getSelectedChild());
|
|
|
|
selectTheme()->setEnabled(item && item->canSelect());
|
|
|
|
}
|
|
|
|
|
2015-09-18 23:23:02 +08:00
|
|
|
void onSelectTheme() {
|
2016-07-21 05:30:03 +08:00
|
|
|
ThemeItem* item = dynamic_cast<ThemeItem*>(themeList()->getSelectedChild());
|
2015-09-18 23:23:02 +08:00
|
|
|
if (item &&
|
2016-07-21 05:30:03 +08:00
|
|
|
item->themeName() != m_pref.theme.selected()) {
|
|
|
|
m_pref.theme.selected(item->themeName());
|
2015-09-18 23:23:02 +08:00
|
|
|
|
|
|
|
ui::Alert::show(PACKAGE
|
|
|
|
"<<You must restart the program to see the selected theme"
|
|
|
|
"||&OK");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-09-18 23:39:46 +08:00
|
|
|
void onOpenThemeFolder() {
|
2016-07-21 05:30:03 +08:00
|
|
|
ThemeItem* item = dynamic_cast<ThemeItem*>(themeList()->getSelectedChild());
|
|
|
|
if (item)
|
|
|
|
item->openFolder();
|
2015-09-18 23:39:46 +08:00
|
|
|
}
|
|
|
|
|
2017-06-11 02:02:39 +08:00
|
|
|
void onExtensionChange() {
|
|
|
|
ExtensionItem* item = dynamic_cast<ExtensionItem*>(extensionsList()->getSelectedChild());
|
|
|
|
if (item && item->isInstalled()) {
|
|
|
|
disableExtension()->setText(item->isEnabled() ? "Disable": "Enable");
|
|
|
|
disableExtension()->setEnabled(item->isEnabled() ? item->canBeDisabled(): true);
|
|
|
|
uninstallExtension()->setEnabled(item->canBeUninstalled());
|
|
|
|
openExtensionFolder()->setEnabled(true);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
disableExtension()->setEnabled(false);
|
|
|
|
uninstallExtension()->setEnabled(false);
|
|
|
|
openExtensionFolder()->setEnabled(false);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void onNewExtension() {
|
|
|
|
// TODO open dialog to select a .zip file with the extension and uncompress it in the user folder
|
|
|
|
}
|
|
|
|
|
|
|
|
void onDisableExtension() {
|
|
|
|
ExtensionItem* item = dynamic_cast<ExtensionItem*>(extensionsList()->getSelectedChild());
|
|
|
|
if (item) {
|
|
|
|
item->enable(!item->isEnabled());
|
|
|
|
onExtensionChange();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void onUninstallExtension() {
|
|
|
|
ExtensionItem* item = dynamic_cast<ExtensionItem*>(extensionsList()->getSelectedChild());
|
|
|
|
if (item) {
|
|
|
|
item->uninstall();
|
|
|
|
onExtensionChange();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void onOpenExtensionFolder() {
|
|
|
|
ExtensionItem* item = dynamic_cast<ExtensionItem*>(extensionsList()->getSelectedChild());
|
|
|
|
if (item)
|
|
|
|
item->openFolder();
|
|
|
|
}
|
|
|
|
|
2016-03-25 01:29:15 +08:00
|
|
|
void onCursorColorType() {
|
|
|
|
switch (cursorColorType()->getSelectedItemIndex()) {
|
|
|
|
case 0:
|
2017-03-25 12:15:40 +08:00
|
|
|
cursorColor()->setColor(app::Color::fromMask());
|
|
|
|
cursorColor()->setVisible(false);
|
2016-03-25 01:29:15 +08:00
|
|
|
break;
|
|
|
|
case 1:
|
2017-03-25 12:15:40 +08:00
|
|
|
cursorColor()->setColor(app::Color::fromRgb(0, 0, 0, 255));
|
|
|
|
cursorColor()->setVisible(true);
|
2016-03-25 01:29:15 +08:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
layout();
|
|
|
|
}
|
|
|
|
|
2016-12-05 22:58:26 +08:00
|
|
|
gfx::Rect gridBounds() const {
|
|
|
|
return gfx::Rect(gridX()->textInt(), gridY()->textInt(),
|
|
|
|
gridW()->textInt(), gridH()->textInt());
|
|
|
|
}
|
|
|
|
|
2016-07-21 05:30:03 +08:00
|
|
|
static std::string userThemeFolder() {
|
2015-09-18 23:39:46 +08:00
|
|
|
ResourceFinder rf;
|
2017-02-10 00:18:44 +08:00
|
|
|
rf.includeDataDir(skin::SkinTheme::kThemesFolderName);
|
2016-07-21 05:30:03 +08:00
|
|
|
|
|
|
|
// Create user folder to store skins
|
|
|
|
try {
|
|
|
|
if (!base::is_directory(rf.defaultFilename()))
|
|
|
|
base::make_all_directories(rf.defaultFilename());
|
|
|
|
}
|
|
|
|
catch (...) {
|
|
|
|
// Ignore errors
|
|
|
|
}
|
|
|
|
|
|
|
|
return base::normalize_path(rf.defaultFilename());
|
|
|
|
}
|
|
|
|
|
|
|
|
static std::vector<std::string> themeFolders() {
|
|
|
|
ResourceFinder rf;
|
2017-02-10 00:18:44 +08:00
|
|
|
rf.includeDataDir(skin::SkinTheme::kThemesFolderName);
|
2016-07-21 05:30:03 +08:00
|
|
|
|
|
|
|
std::vector<std::string> paths;
|
|
|
|
while (rf.next())
|
|
|
|
paths.push_back(base::normalize_path(rf.filename()));
|
|
|
|
return paths;
|
2015-09-18 23:39:46 +08:00
|
|
|
}
|
|
|
|
|
2016-03-25 01:29:15 +08:00
|
|
|
Preferences& m_pref;
|
2015-02-15 10:31:11 +08:00
|
|
|
DocumentPreferences& m_globPref;
|
2014-12-28 22:06:11 +08:00
|
|
|
DocumentPreferences& m_docPref;
|
2015-02-15 10:31:11 +08:00
|
|
|
DocumentPreferences* m_curPref;
|
2015-02-15 09:43:21 +08:00
|
|
|
int& m_curSection;
|
2014-06-23 08:56:04 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
class OptionsCommand : public Command {
|
|
|
|
public:
|
|
|
|
OptionsCommand();
|
2014-08-15 10:07:47 +08:00
|
|
|
Command* clone() const override { return new OptionsCommand(*this); }
|
2014-06-23 08:56:04 +08:00
|
|
|
|
|
|
|
protected:
|
2015-10-01 03:34:43 +08:00
|
|
|
void onExecute(Context* context) override;
|
2014-06-23 08:56:04 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
OptionsCommand::OptionsCommand()
|
|
|
|
: Command("Options",
|
|
|
|
"Options",
|
|
|
|
CmdUIOnlyFlag)
|
2012-01-06 06:45:03 +08:00
|
|
|
{
|
2015-05-19 03:53:25 +08:00
|
|
|
Preferences& preferences = Preferences::instance();
|
2014-12-15 07:19:31 +08:00
|
|
|
|
2014-10-25 22:24:29 +08:00
|
|
|
ui::MenuBar::setExpandOnMouseover(
|
2014-12-15 07:19:31 +08:00
|
|
|
preferences.general.expandMenubarOnMouseover());
|
2012-01-06 06:45:03 +08:00
|
|
|
}
|
|
|
|
|
2014-06-23 08:56:04 +08:00
|
|
|
void OptionsCommand::onExecute(Context* context)
|
2014-06-14 10:00:49 +08:00
|
|
|
{
|
2015-02-15 09:43:21 +08:00
|
|
|
static int curSection = 0;
|
|
|
|
|
|
|
|
OptionsWindow window(context, curSection);
|
2014-06-23 08:56:04 +08:00
|
|
|
window.openWindowInForeground();
|
2015-02-12 23:16:25 +08:00
|
|
|
if (window.ok())
|
2014-06-23 08:56:04 +08:00
|
|
|
window.saveConfig();
|
2014-06-14 10:00:49 +08:00
|
|
|
}
|
|
|
|
|
2012-01-06 06:45:03 +08:00
|
|
|
Command* CommandFactory::createOptionsCommand()
|
|
|
|
{
|
|
|
|
return new OptionsCommand;
|
|
|
|
}
|
2013-08-06 08:20:19 +08:00
|
|
|
|
|
|
|
} // namespace app
|