diff --git a/data/pref.xml b/data/pref.xml
index 33c9c7f86..d3b204575 100644
--- a/data/pref.xml
+++ b/data/pref.xml
@@ -116,6 +116,7 @@
+
diff --git a/data/widgets/options.xml b/data/widgets/options.xml
index b15c131c1..873affa45 100644
--- a/data/widgets/options.xml
+++ b/data/widgets/options.xml
@@ -10,7 +10,8 @@
-
+
+
@@ -67,6 +68,7 @@
+
@@ -129,43 +131,81 @@
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
+
+
+
-
+
+
+
+
+
+
-
+
-
-
-
-
-
-
-
-
-
-
-
-
-
+
diff --git a/src/app/commands/cmd_options.cpp b/src/app/commands/cmd_options.cpp
index b57dfcbfd..98e278e00 100644
--- a/src/app/commands/cmd_options.cpp
+++ b/src/app/commands/cmd_options.cpp
@@ -30,6 +30,8 @@
namespace app {
+static const char* kSectionBgId = "section_bg";
+static const char* kSectionGridId = "section_grid";
static const char* kSectionThemeId = "section_theme";
using namespace ui;
@@ -161,10 +163,18 @@ public:
if (m_pref.editor.showScrollbars())
showScrollbars()->setSelected(true);
+ if (m_pref.editor.autoScroll())
+ autoScroll()->setSelected(true);
+
// Scope
- gridScope()->addItem("New Documents");
+ bgScope()->addItem("Background for New Documents");
+ gridScope()->addItem("Grid for New Documents");
if (context->activeDocument()) {
- gridScope()->addItem("Active Document");
+ bgScope()->addItem("Background for the Active Document");
+ bgScope()->setSelectedItemIndex(1);
+ bgScope()->Change.connect(base::Bind(&OptionsWindow::onChangeBgScope, this));
+
+ gridScope()->addItem("Grid for the Active Document");
gridScope()->setSelectedItemIndex(1);
gridScope()->Change.connect(base::Bind(&OptionsWindow::onChangeGridScope, this));
}
@@ -223,8 +233,9 @@ public:
checkedBgColor1Box()->addChild(m_checked_bg_color1);
checkedBgColor2Box()->addChild(m_checked_bg_color2);
- // Reset button
- reset()->Click.connect(base::Bind(&OptionsWindow::onReset, this));
+ // Reset buttons
+ resetBg()->Click.connect(base::Bind(&OptionsWindow::onResetBg, this));
+ resetGrid()->Click.connect(base::Bind(&OptionsWindow::onResetGrid, this));
// Links
locateFile()->Click.connect(base::Bind(&OptionsWindow::onLocateConfigFile, this));
@@ -247,6 +258,7 @@ public:
// Apply button
buttonApply()->Click.connect(base::Bind(&OptionsWindow::saveConfig, this));
+ onChangeBgScope();
onChangeGridScope();
sectionListbox()->selectIndex(m_curSection);
}
@@ -279,6 +291,7 @@ public:
m_pref.editor.zoomFromCenterWithWheel(zoomFromCenterWithWheel()->isSelected());
m_pref.editor.zoomFromCenterWithKeys(zoomFromCenterWithKeys()->isSelected());
m_pref.editor.showScrollbars(showScrollbars()->isSelected());
+ m_pref.editor.autoScroll(autoScroll()->isSelected());
m_pref.editor.zoomWithWheel(wheelZoom()->isSelected());
#if __APPLE__
m_pref.editor.zoomWithSlide(slideZoom()->isSelected());
@@ -292,12 +305,17 @@ public:
m_pref.selection.autoOpaque(autoOpaque()->isSelected());
m_pref.selection.keepSelectionAfterClear(keepSelectionAfterClear()->isSelected());
+ m_curPref->show.grid(gridVisible()->isSelected());
+ m_curPref->grid.bounds(gridBounds());
m_curPref->grid.color(m_gridColor->getColor());
m_curPref->grid.opacity(gridOpacity()->getValue());
m_curPref->grid.autoOpacity(gridAutoOpacity()->isSelected());
+
+ m_curPref->show.pixelGrid(pixelGridVisible()->isSelected());
m_curPref->pixelGrid.color(m_pixelGridColor->getColor());
m_curPref->pixelGrid.opacity(pixelGridOpacity()->getValue());
m_curPref->pixelGrid.autoOpacity(pixelGridAutoOpacity()->isSelected());
+
m_curPref->bg.type(app::gen::BgType(checkedBgSize()->getSelectedItemIndex()));
m_curPref->bg.zoom(checkedBgZoom()->isSelected());
m_curPref->bg.color1(m_checked_bg_color1->getColor());
@@ -374,11 +392,29 @@ private:
panel()->showChild(findChild(item->getValue().c_str()));
m_curSection = sectionListbox()->getSelectedIndex();
+ if (item->getValue() == kSectionBgId)
+ onChangeBgScope();
+ else if (item->getValue() == kSectionGridId)
+ onChangeGridScope();
// Load themes
- if (item->getValue() == kSectionThemeId)
+ else if (item->getValue() == kSectionThemeId)
loadThemes();
}
+ 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());
+ m_checked_bg_color1->setColor(m_curPref->bg.color1());
+ m_checked_bg_color2->setColor(m_curPref->bg.color2());
+ }
+
void onChangeGridScope() {
int item = gridScope()->getSelectedItemIndex();
@@ -387,33 +423,27 @@ private:
case 1: m_curPref = &m_docPref; break;
}
+ 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);
+
m_gridColor->setColor(m_curPref->grid.color());
gridOpacity()->setValue(m_curPref->grid.opacity());
gridAutoOpacity()->setSelected(m_curPref->grid.autoOpacity());
+ pixelGridVisible()->setSelected(m_curPref->show.pixelGrid());
m_pixelGridColor->setColor(m_curPref->pixelGrid.color());
pixelGridOpacity()->setValue(m_curPref->pixelGrid.opacity());
pixelGridAutoOpacity()->setSelected(m_curPref->pixelGrid.autoOpacity());
-
- checkedBgSize()->setSelectedItemIndex(int(m_curPref->bg.type()));
- checkedBgZoom()->setSelected(m_curPref->bg.zoom());
- m_checked_bg_color1->setColor(m_curPref->bg.color1());
- m_checked_bg_color2->setColor(m_curPref->bg.color2());
}
- void onReset() {
+ void onResetBg() {
+ DocumentPreferences& pref = m_globPref;
+
// Reset global preferences (use default values specified in pref.xml)
if (m_curPref == &m_globPref) {
- DocumentPreferences& pref = m_globPref;
-
- m_gridColor->setColor(pref.grid.color.defaultValue());
- gridOpacity()->setValue(pref.grid.opacity.defaultValue());
- gridAutoOpacity()->setSelected(pref.grid.autoOpacity.defaultValue());
-
- m_pixelGridColor->setColor(pref.pixelGrid.color.defaultValue());
- pixelGridOpacity()->setValue(pref.pixelGrid.opacity.defaultValue());
- pixelGridAutoOpacity()->setSelected(pref.pixelGrid.autoOpacity.defaultValue());
-
checkedBgSize()->setSelectedItemIndex(int(pref.bg.type.defaultValue()));
checkedBgZoom()->setSelected(pref.bg.zoom.defaultValue());
m_checked_bg_color1->setColor(pref.bg.color1.defaultValue());
@@ -421,20 +451,49 @@ private:
}
// Reset document preferences with global settings
else {
- DocumentPreferences& pref = m_globPref;
+ checkedBgSize()->setSelectedItemIndex(int(pref.bg.type()));
+ checkedBgZoom()->setSelected(pref.bg.zoom());
+ m_checked_bg_color1->setColor(pref.bg.color1());
+ m_checked_bg_color2->setColor(pref.bg.color2());
+ }
+ }
+
+ void onResetGrid() {
+ DocumentPreferences& pref = m_globPref;
+
+ // Reset global preferences (use default values specified in pref.xml)
+ if (m_curPref == &m_globPref) {
+ 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);
+
+ m_gridColor->setColor(pref.grid.color.defaultValue());
+ gridOpacity()->setValue(pref.grid.opacity.defaultValue());
+ gridAutoOpacity()->setSelected(pref.grid.autoOpacity.defaultValue());
+
+ pixelGridVisible()->setSelected(pref.show.pixelGrid.defaultValue());
+ m_pixelGridColor->setColor(pref.pixelGrid.color.defaultValue());
+ pixelGridOpacity()->setValue(pref.pixelGrid.opacity.defaultValue());
+ pixelGridAutoOpacity()->setSelected(pref.pixelGrid.autoOpacity.defaultValue());
+ }
+ // Reset document preferences with global settings
+ else {
+ 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);
m_gridColor->setColor(pref.grid.color());
gridOpacity()->setValue(pref.grid.opacity());
gridAutoOpacity()->setSelected(pref.grid.autoOpacity());
+ pixelGridVisible()->setSelected(pref.show.pixelGrid());
m_pixelGridColor->setColor(pref.pixelGrid.color());
pixelGridOpacity()->setValue(pref.pixelGrid.opacity());
pixelGridAutoOpacity()->setSelected(pref.pixelGrid.autoOpacity());
-
- checkedBgSize()->setSelectedItemIndex(int(pref.bg.type()));
- checkedBgZoom()->setSelected(pref.bg.zoom());
- m_checked_bg_color1->setColor(pref.bg.color1());
- m_checked_bg_color2->setColor(pref.bg.color2());
}
}
@@ -517,6 +576,11 @@ private:
layout();
}
+ gfx::Rect gridBounds() const {
+ return gfx::Rect(gridX()->textInt(), gridY()->textInt(),
+ gridW()->textInt(), gridH()->textInt());
+ }
+
static std::string userThemeFolder() {
ResourceFinder rf;
rf.includeDataDir("skins");
diff --git a/src/app/ui/color_popup.cpp b/src/app/ui/color_popup.cpp
index 6eb2b9bde..493decd9b 100644
--- a/src/app/ui/color_popup.cpp
+++ b/src/app/ui/color_popup.cpp
@@ -91,8 +91,10 @@ ColorPopup::ColorPopup(bool canPin)
break;
}
}
- m_topBox.addChild(new BoxFiller);
- m_topBox.addChild(closeButton);
+ if (closeButton) {
+ m_topBox.addChild(new BoxFiller);
+ m_topBox.addChild(closeButton);
+ }
}
m_vbox.addChild(&m_topBox);
@@ -268,8 +270,13 @@ void ColorPopup::selectColorType(app::Color::Type type)
case app::Color::MaskType: m_colorType.setSelectedItem(MASK_MODE); break;
}
- // Remove focus from some RGB/HSB text entry
- manager()->freeFocus();
+ // Remove focus from hidden RGB/HSB text entries
+ auto widget = manager()->getFocus();
+ if (widget && !widget->isVisible()) {
+ auto window = widget->window();
+ if (window && window == this)
+ widget->releaseFocus();
+ }
m_vbox.layout();
m_vbox.invalidate();
diff --git a/src/app/ui/editor/editor.cpp b/src/app/ui/editor/editor.cpp
index be26517f6..cf842ecc0 100644
--- a/src/app/ui/editor/editor.cpp
+++ b/src/app/ui/editor/editor.cpp
@@ -984,11 +984,14 @@ void Editor::flashCurrentLayer()
gfx::Point Editor::autoScroll(MouseMessage* msg, AutoScroll dir)
{
- // // Hide the brush preview
- // HideBrushPreview hide(editor->brushPreview());
+ gfx::Point mousePos = msg->position();
+ if (!Preferences::instance().editor.autoScroll())
+ return mousePos;
+
+ // Hide the brush preview
+ //HideBrushPreview hide(editor->brushPreview());
View* view = View::getView(this);
gfx::Rect vp = view->viewportBounds();
- gfx::Point mousePos = msg->position();
if (!vp.contains(mousePos)) {
gfx::Point delta = (mousePos - m_oldPos);
diff --git a/src/app/ui/status_bar.cpp b/src/app/ui/status_bar.cpp
index d64ac70c8..eb81b26f7 100644
--- a/src/app/ui/status_bar.cpp
+++ b/src/app/ui/status_bar.cpp
@@ -682,7 +682,8 @@ void StatusBar::showTool(int msecs, tools::Tool* tool)
void StatusBar::showSnapToGridWarning(bool state)
{
if (state) {
- ASSERT(m_doc);
+ // m_doc can be null if "snap to grid" command is pressed without
+ // an opened document. (E.g. to change the default setting)
if (!m_doc)
return;