Don't discard custom brush when we use eyedropper (fix #1557)

This commit is contained in:
David Capello 2017-11-23 10:06:13 -03:00
parent ab51f02711
commit e1232516ee
7 changed files with 30 additions and 1 deletions

View File

@ -213,6 +213,7 @@
<section id="eyedropper" text="Editor">
<option id="channel" type="EyedropperChannel" default="EyedropperChannel::COLOR_ALPHA" />
<option id="sample" type="EyedropperSample" default="EyedropperSample::ALL_LAYERS" />
<option id="discard_brush" type="bool" default="false" />
</section>
<section id="shared">
<option id="share_ink" type="bool" default="false" />

View File

@ -624,6 +624,7 @@ using Shift+click, with this option checked
you will see the preview immediately when
the Shift key is pressed.
END
discard_brush = Discard custom brush when eyedropper is used
right_click = Right-click:
editor_selection = Selection
auto_opaque = Adjust opaque/transparent mode automatically

View File

@ -85,6 +85,7 @@
<check text="@.show_scrollbars" id="show_scrollbars" tooltip="@.show_scrollbars_tooltip" />
<check text="@.auto_scroll" id="auto_scroll" />
<check text="@.straight_line_preview" id="straight_line_preview" tooltip="@.straight_line_preview_tooltip" />
<check text="@.discard_brush" id="discard_brush" />
<hbox>
<label text="@.right_click" />
<combobox id="right_click_behavior" expansive="true" />

View File

@ -195,7 +195,7 @@ void EyedropperCommand::onExecute(Context* context)
return;
// Discard current image brush
{
if (Preferences::instance().eyedropper.discardBrush()) {
Command* discardBrush = CommandsModule::instance()->getCommandByName(CommandId::DiscardBrush);
context->executeCommand(discardBrush);
}

View File

@ -242,6 +242,9 @@ public:
if (m_pref.editor.straightLinePreview())
straightLinePreview()->setSelected(true);
if (m_pref.eyedropper.discardBrush())
discardBrush()->setSelected(true);
// Scope
bgScope()->addItem("Background for New Documents");
gridScope()->addItem("Grid for New Documents");
@ -386,6 +389,7 @@ public:
m_pref.editor.showScrollbars(showScrollbars()->isSelected());
m_pref.editor.autoScroll(autoScroll()->isSelected());
m_pref.editor.straightLinePreview(straightLinePreview()->isSelected());
m_pref.eyedropper.discardBrush(discardBrush()->isSelected());
m_pref.editor.zoomWithWheel(wheelZoom()->isSelected());
#if __APPLE__
m_pref.editor.zoomWithSlide(slideZoom()->isSelected());

View File

@ -118,6 +118,23 @@ private:
}
};
class ContextBar::BrushBackField : public ButtonSet {
public:
BrushBackField()
: ButtonSet(1) {
addItem("Back");
}
protected:
void onItemChange(Item* item) override {
ButtonSet::onItemChange(item);
Command* discardBrush = CommandsModule::instance()
->getCommandByName(CommandId::DiscardBrush);
UIContext::instance()->executeCommand(discardBrush);
}
};
class ContextBar::BrushTypeField : public ButtonSet {
public:
BrushTypeField(ContextBar* owner)
@ -1389,6 +1406,7 @@ ContextBar::ContextBar()
addChild(m_zoomButtons = new ZoomButtons);
addChild(m_brushBack = new BrushBackField);
addChild(m_brushType = new BrushTypeField(this));
addChild(m_brushSize = new BrushSizeField());
addChild(m_brushAngle = new BrushAngleField(m_brushType));
@ -1709,6 +1727,7 @@ void ContextBar::updateForTool(tools::Tool* tool)
// Show/Hide fields
m_zoomButtons->setVisible(needZoomButtons);
m_brushBack->setVisible(supportOpacity && hasImageBrush && !withDithering);
m_brushType->setVisible(supportOpacity && (!isFloodfill || (isFloodfill && hasImageBrush && !withDithering)));
m_brushSize->setVisible(supportOpacity && !isFloodfill && !hasImageBrush);
m_brushAngle->setVisible(supportOpacity && !isFloodfill && !hasImageBrush && hasBrushWithAngle);
@ -2019,6 +2038,7 @@ render::DitheringAlgorithmBase* ContextBar::ditheringAlgorithm()
void ContextBar::setupTooltips(TooltipManager* tooltipManager)
{
tooltipManager->addTooltipFor(m_brushBack, "Discard Brush (Esc)", BOTTOM);
tooltipManager->addTooltipFor(m_brushType, "Brush Type", BOTTOM);
tooltipManager->addTooltipFor(m_brushSize, "Brush Size (in pixels)", BOTTOM);
tooltipManager->addTooltipFor(m_brushAngle, "Brush Angle (in degrees)", BOTTOM);

View File

@ -106,6 +106,7 @@ namespace app {
void setupTooltips(ui::TooltipManager* tooltipManager);
class ZoomButtons;
class BrushBackField;
class BrushTypeField;
class BrushAngleField;
class BrushSizeField;
@ -129,6 +130,7 @@ namespace app {
class SymmetryField;
ZoomButtons* m_zoomButtons;
BrushBackField* m_brushBack;
BrushTypeField* m_brushType;
BrushAngleField* m_brushAngle;
BrushSizeField* m_brushSize;