diff --git a/data/pref.xml b/data/pref.xml
index 373d98f98..a8e935cce 100644
--- a/data/pref.xml
+++ b/data/pref.xml
@@ -111,6 +111,7 @@
diff --git a/data/widgets/options.xml b/data/widgets/options.xml
index 99b876c44..722f8fd0c 100644
--- a/data/widgets/options.xml
+++ b/data/widgets/options.xml
@@ -58,9 +58,12 @@
+
+
+
-
+
diff --git a/src/app/commands/cmd_options.cpp b/src/app/commands/cmd_options.cpp
index fc7db52c3..5bb8fad4e 100644
--- a/src/app/commands/cmd_options.cpp
+++ b/src/app/commands/cmd_options.cpp
@@ -84,6 +84,9 @@ public:
if (m_preferences.editor.zoomFromCenterWithKeys())
zoomFromCenterWithKeys()->setSelected(true);
+ if (m_preferences.selection.autoOpaque())
+ autoOpaque()->setSelected(true);
+
if (m_preferences.experimental.useNativeCursor())
nativeCursor()->setSelected(true);
@@ -181,6 +184,7 @@ public:
m_preferences.editor.zoomWithWheel(wheelZoom()->isSelected());
m_preferences.editor.rightClickMode(static_cast(rightClickBehavior()->getSelectedItemIndex()));
m_preferences.editor.cursorColor(m_cursorColor->getColor());
+ m_preferences.selection.autoOpaque(autoOpaque()->isSelected());
m_curPref->grid.color(m_gridColor->getColor());
m_curPref->grid.opacity(gridOpacity()->getValue());
diff --git a/src/app/ui/context_bar.cpp b/src/app/ui/context_bar.cpp
index da777b314..61eb0deb0 100644
--- a/src/app/ui/context_bar.cpp
+++ b/src/app/ui/context_bar.cpp
@@ -490,10 +490,14 @@ public:
gfx::Size sz = m_icon.getItem(0)->getPreferredSize();
sz.w += 2*guiscale();
m_icon.getItem(0)->setMinSize(sz);
- setOpaque(Preferences::instance().selection.opaque());
m_icon.ItemChange.connect(Bind(&TransparentColorField::onPopup, this));
m_maskColor.Change.connect(Bind(&TransparentColorField::onChangeColor, this));
+
+ Preferences::instance().selection.opaque.AfterChange.connect(
+ Bind(&TransparentColorField::onOpaqueChange, this));
+
+ setOpaque(Preferences::instance().selection.opaque());
}
private:
@@ -525,12 +529,18 @@ private:
}
void setOpaque(bool opaque) {
+ Preferences::instance().selection.opaque(opaque);
+ }
+
+ // When the preference is changed from outside the context bar
+ void onOpaqueChange() {
+ bool opaque = Preferences::instance().selection.opaque();
+
int part = (opaque ? PART_SELECTION_OPAQUE: PART_SELECTION_MASKED);
m_icon.getItem(0)->setIcon(
static_cast(getTheme())->get_part(part));
m_maskColor.setVisible(!opaque);
- Preferences::instance().selection.opaque(opaque);
if (!opaque) {
Preferences::instance().selection.transparentColor(
m_maskColor.getColor());
diff --git a/src/app/ui/editor/moving_pixels_state.cpp b/src/app/ui/editor/moving_pixels_state.cpp
index 6ee67f45e..4225d12da 100644
--- a/src/app/ui/editor/moving_pixels_state.cpp
+++ b/src/app/ui/editor/moving_pixels_state.cpp
@@ -70,7 +70,11 @@ MovingPixelsState::MovingPixelsState(Editor* editor, MouseMessage* msg, PixelsMo
editor->captureMouse();
}
- // Setup mask color
+ // Setup transparent mode/mask color
+ if (Preferences::instance().selection.autoOpaque()) {
+ Preferences::instance().selection.opaque(
+ editor->layer()->isBackground());
+ }
onTransparentColorChange();
// Hook BeforeCommandExecution signal so we know if the user wants