Add a new simple/default ink

This ink behaves as alpha compositing but doesn't use the opacity slider
(opacity is used from current color's alpha channel). Also, in case that
we pick the mask color, it behaves as the eraser tool.
This commit is contained in:
David Capello 2015-08-13 13:26:52 -03:00
parent f4d82ad2c0
commit 32bf3314e6
6 changed files with 38 additions and 10 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 13 KiB

After

Width:  |  Height:  |  Size: 13 KiB

View File

@ -375,9 +375,10 @@
<part id="canvas_s" x="112" y="128" w="16" h="16" /> <part id="canvas_s" x="112" y="128" w="16" h="16" />
<part id="canvas_se" x="128" y="128" w="16" h="16" /> <part id="canvas_se" x="128" y="128" w="16" h="16" />
<part id="canvas_empty" x="96" y="96" w="1" h="1" /> <part id="canvas_empty" x="96" y="96" w="1" h="1" />
<part id="ink_default" x="144" y="144" w="16" h="16" /> <part id="ink_simple" x="144" y="144" w="16" h="16" />
<part id="ink_copy_color" x="160" y="144" w="16" h="16" /> <part id="ink_alpha_compositing" x="160" y="144" w="16" h="16" />
<part id="ink_lock_alpha" x="176" y="144" w="16" h="16" /> <part id="ink_copy_color" x="144" y="160" w="16" h="16" />
<part id="ink_lock_alpha" x="160" y="160" w="16" h="16" />
<part id="selection_opaque" x="208" y="176" w="16" h="10" /> <part id="selection_opaque" x="208" y="176" w="16" h="10" />
<part id="selection_masked" x="224" y="176" w="16" h="10" /> <part id="selection_masked" x="224" y="176" w="16" h="10" />
<part id="pivot_hidden" x="208" y="192" w="7" h="7" /> <part id="pivot_hidden" x="208" y="192" w="7" h="7" />

View File

@ -14,11 +14,17 @@ namespace tools {
enum class InkType { enum class InkType {
DEFAULT = 0, DEFAULT = 0,
ALPHA_COMPOSITING = 0, SIMPLE = 0,
COPY_COLOR = 1, ALPHA_COMPOSITING = 1,
LOCK_ALPHA = 2, COPY_COLOR = 2,
LOCK_ALPHA = 3,
}; };
inline bool inkHasOpacity(InkType inkType) {
return (inkType == InkType::ALPHA_COMPOSITING ||
inkType == InkType::LOCK_ALPHA);
}
} // namespace tools } // namespace tools
} // namespace app } // namespace app

View File

@ -325,15 +325,16 @@ public:
InkTypeField(ContextBar* owner) : ButtonSet(1) InkTypeField(ContextBar* owner) : ButtonSet(1)
, m_owner(owner) { , m_owner(owner) {
SkinTheme* theme = SkinTheme::instance(); SkinTheme* theme = SkinTheme::instance();
addItem(theme->parts.inkDefault()); addItem(theme->parts.inkSimple());
} }
void setInkType(InkType inkType) { void setInkType(InkType inkType) {
SkinTheme* theme = SkinTheme::instance(); SkinTheme* theme = SkinTheme::instance();
SkinPartPtr part = theme->parts.inkDefault(); SkinPartPtr part = theme->parts.inkSimple();
switch (inkType) { switch (inkType) {
case InkType::ALPHA_COMPOSITING: part = theme->parts.inkDefault(); break; case InkType::SIMPLE: part = theme->parts.inkSimple(); break;
case InkType::ALPHA_COMPOSITING: part = theme->parts.inkAlphaCompositing(); break;
case InkType::COPY_COLOR: part = theme->parts.inkCopyColor(); break; case InkType::COPY_COLOR: part = theme->parts.inkCopyColor(); break;
case InkType::LOCK_ALPHA: part = theme->parts.inkLockAlpha(); break; case InkType::LOCK_ALPHA: part = theme->parts.inkLockAlpha(); break;
} }
@ -349,10 +350,12 @@ protected:
Menu menu; Menu menu;
MenuItem MenuItem
simple("Simple Ink"),
alphacompo("Alpha Compositing"), alphacompo("Alpha Compositing"),
copycolor("Copy Color+Alpha"), copycolor("Copy Color+Alpha"),
lockalpha("Lock Alpha"), lockalpha("Lock Alpha"),
alltools("Same in all Tools"); alltools("Same in all Tools");
menu.addChild(&simple);
menu.addChild(&alphacompo); menu.addChild(&alphacompo);
menu.addChild(&copycolor); menu.addChild(&copycolor);
menu.addChild(&lockalpha); menu.addChild(&lockalpha);
@ -361,12 +364,14 @@ protected:
Tool* tool = App::instance()->activeTool(); Tool* tool = App::instance()->activeTool();
switch (Preferences::instance().tool(tool).ink()) { switch (Preferences::instance().tool(tool).ink()) {
case tools::InkType::SIMPLE: simple.setSelected(true); break;
case tools::InkType::ALPHA_COMPOSITING: alphacompo.setSelected(true); break; case tools::InkType::ALPHA_COMPOSITING: alphacompo.setSelected(true); break;
case tools::InkType::COPY_COLOR: copycolor.setSelected(true); break; case tools::InkType::COPY_COLOR: copycolor.setSelected(true); break;
case tools::InkType::LOCK_ALPHA: lockalpha.setSelected(true); break; case tools::InkType::LOCK_ALPHA: lockalpha.setSelected(true); break;
} }
alltools.setSelected(Preferences::instance().shared.shareInk()); alltools.setSelected(Preferences::instance().shared.shareInk());
simple.Click.connect(Bind<void>(&InkTypeField::selectInk, this, InkType::SIMPLE));
alphacompo.Click.connect(Bind<void>(&InkTypeField::selectInk, this, InkType::ALPHA_COMPOSITING)); alphacompo.Click.connect(Bind<void>(&InkTypeField::selectInk, this, InkType::ALPHA_COMPOSITING));
copycolor.Click.connect(Bind<void>(&InkTypeField::selectInk, this, InkType::COPY_COLOR)); copycolor.Click.connect(Bind<void>(&InkTypeField::selectInk, this, InkType::COPY_COLOR));
lockalpha.Click.connect(Bind<void>(&InkTypeField::selectInk, this, InkType::LOCK_ALPHA)); lockalpha.Click.connect(Bind<void>(&InkTypeField::selectInk, this, InkType::LOCK_ALPHA));
@ -1184,7 +1189,7 @@ void ContextBar::updateForTool(tools::Tool* tool)
m_inkOpacity->setTextf("%d", toolPref->opacity()); m_inkOpacity->setTextf("%d", toolPref->opacity());
hasInkWithOpacity = hasInkWithOpacity =
((isPaint && toolPref->ink() != tools::InkType::COPY_COLOR) || ((isPaint && tools::inkHasOpacity(toolPref->ink())) ||
(isEffect)); (isEffect));
m_freehandAlgo->setFreehandAlgorithm(toolPref->freehandAlgorithm()); m_freehandAlgo->setFreehandAlgorithm(toolPref->freehandAlgorithm());

View File

@ -928,6 +928,18 @@ tools::Ink* Editor::getCurrentEditorInk()
const char* id = NULL; const char* id = NULL;
switch (inkType) { switch (inkType) {
case tools::InkType::SIMPLE: {
id = tools::WellKnownInks::Paint;
ColorBar* colorbar = ColorBar::instance();
app::Color color = (m_secondaryButton ? colorbar->getBgColor():
colorbar->getFgColor());
if (color.getAlpha() == 0)
id = tools::WellKnownInks::PaintCopy;
break;
}
case tools::InkType::ALPHA_COMPOSITING: case tools::InkType::ALPHA_COMPOSITING:
id = tools::WellKnownInks::Paint; id = tools::WellKnownInks::Paint;
break; break;

View File

@ -134,6 +134,10 @@ public:
break; break;
} }
} }
// Ignore opacity for these inks
if (!tools::inkHasOpacity(m_toolPref.ink()))
m_opacity = 255;
} }
// IToolLoop interface // IToolLoop interface