diff --git a/data/pref.xml b/data/pref.xml
index 8068e00fd..860221115 100644
--- a/data/pref.xml
+++ b/data/pref.xml
@@ -120,6 +120,10 @@
+
diff --git a/src/app/ui/context_bar.cpp b/src/app/ui/context_bar.cpp
index 3e0f4d02a..a417cd7e1 100644
--- a/src/app/ui/context_bar.cpp
+++ b/src/app/ui/context_bar.cpp
@@ -352,10 +352,13 @@ protected:
MenuItem
replace("Replace Pixel"),
alphacompo("Alpha Compositing"),
- lockalpha("Lock Alpha");
+ lockalpha("Lock Alpha"),
+ alltools("Same in all Tools");
menu.addChild(&replace);
menu.addChild(&alphacompo);
menu.addChild(&lockalpha);
+ menu.addChild(new MenuSeparator);
+ menu.addChild(&alltools);
Tool* tool = App::instance()->activeTool();
switch (Preferences::instance().tool(tool).ink()) {
@@ -363,10 +366,12 @@ protected:
case tools::InkType::ALPHA_COMPOSITING: alphacompo.setSelected(true); break;
case tools::InkType::LOCK_ALPHA: lockalpha.setSelected(true); break;
}
+ alltools.setSelected(Preferences::instance().shared.shareInk());
replace.Click.connect(Bind(&InkTypeField::selectInk, this, InkType::REPLACE_PIXEL));
alphacompo.Click.connect(Bind(&InkTypeField::selectInk, this, InkType::ALPHA_COMPOSITING));
lockalpha.Click.connect(Bind(&InkTypeField::selectInk, this, InkType::LOCK_ALPHA));
+ alltools.Click.connect(Bind(&InkTypeField::onSameInAllTools, this));
menu.showPopup(gfx::Point(bounds.x, bounds.y+bounds.h));
@@ -374,12 +379,39 @@ protected:
}
void selectInk(InkType inkType) {
- Tool* tool = App::instance()->activeTool();
- Preferences::instance().tool(tool).ink(inkType);
+ Preferences& pref = Preferences::instance();
+
+ if (pref.shared.shareInk()) {
+ for (Tool* tool : *App::instance()->getToolBox())
+ pref.tool(tool).ink(inkType);
+ }
+ else {
+ Tool* tool = App::instance()->activeTool();
+ pref.tool(tool).ink(inkType);
+ }
m_owner->updateForCurrentTool();
}
+ void onSameInAllTools() {
+ Preferences& pref = Preferences::instance();
+ bool newState = !pref.shared.shareInk();
+ pref.shared.shareInk(newState);
+
+ if (newState) {
+ Tool* activeTool = App::instance()->activeTool();
+ InkType inkType = pref.tool(activeTool).ink();
+ int opacity = pref.tool(activeTool).opacity();
+
+ for (Tool* tool : *App::instance()->getToolBox()) {
+ if (tool != activeTool) {
+ pref.tool(tool).ink(inkType);
+ pref.tool(tool).opacity(opacity);
+ }
+ }
+ }
+ }
+
ContextBar* m_owner;
};
@@ -398,8 +430,15 @@ protected:
base::ScopedValue lockFlag(g_updatingFromCode, true, g_updatingFromCode);
int newValue = getValue();
- Tool* tool = App::instance()->activeTool();
- Preferences::instance().tool(tool).opacity(newValue);
+ Preferences& pref = Preferences::instance();
+ if (pref.shared.shareInk()) {
+ for (Tool* tool : *App::instance()->getToolBox())
+ pref.tool(tool).opacity(newValue);
+ }
+ else {
+ Tool* tool = App::instance()->activeTool();
+ pref.tool(tool).opacity(newValue);
+ }
}
};