Fix bug using brush size on selection+snap to grid

Discussion: https://community.aseprite.org/t/snap-to-grid-problem/292
This commit is contained in:
David Capello 2017-08-08 14:31:27 -03:00
parent 913a32fbab
commit e372967cde
3 changed files with 23 additions and 10 deletions

View File

@ -1879,11 +1879,22 @@ void ContextBar::setActiveBrush(const doc::BrushRef& brush)
updateForActiveTool();
}
doc::BrushRef ContextBar::activeBrush(tools::Tool* tool) const
doc::BrushRef ContextBar::activeBrush(tools::Tool* tool,
tools::Ink* ink) const
{
if ((!tool) ||
if (ink == nullptr)
ink = (tool ? tool->getInk(0): nullptr);
// Selection tools use a brush with size = 1 (always)
if (ink && ink->isSelection()) {
doc::BrushRef brush;
brush.reset(new Brush(kCircleBrushType, 1, 0));
return brush;
}
if ((tool == nullptr) ||
(tool == App::instance()->activeTool()) ||
(tool->getInk(0)->isPaint() &&
(ink && ink->isPaint() &&
m_activeBrush->type() == kImageBrushType)) {
m_activeBrush->setPattern(Preferences::instance().brush.pattern());
return m_activeBrush;

View File

@ -31,10 +31,6 @@ namespace render {
class DitheringMatrix;
}
namespace tools {
class Tool;
}
namespace ui {
class Box;
class Button;
@ -44,6 +40,11 @@ namespace ui {
namespace app {
namespace tools {
class Ink;
class Tool;
}
class BrushSlot;
class DitheringSelector;
@ -58,13 +59,14 @@ namespace app {
void updateForTool(tools::Tool* tool);
void updateForMovingPixels();
void updateForSelectingBox(const std::string& text);
void updateToolLoopModifiersIndicators(app::tools::ToolLoopModifiers modifiers);
void updateToolLoopModifiersIndicators(tools::ToolLoopModifiers modifiers);
void updateAutoSelectLayer(bool state);
bool isAutoSelectLayer() const;
void setActiveBrush(const doc::BrushRef& brush);
void setActiveBrushBySlot(tools::Tool* tool, int slot);
doc::BrushRef activeBrush(tools::Tool* tool = nullptr) const;
doc::BrushRef activeBrush(tools::Tool* tool = nullptr,
tools::Ink* ink = nullptr) const;
void discardActiveBrush();
BrushSlot createBrushSlotFromPreferences();

View File

@ -104,7 +104,7 @@ public:
const app::Color& bgColor)
: m_editor(editor)
, m_tool(tool)
, m_brush(App::instance()->contextBar()->activeBrush(m_tool))
, m_brush(App::instance()->contextBar()->activeBrush(m_tool, ink))
, m_document(document)
, m_sprite(editor->sprite())
, m_layer(layer)