Restore the default brush center to w/2 and h/2

This generated a lot of controversy. The new center ((w-1)/2
, (h-1)/2) was useful for scripts, but not too useful for right-handed
users that prefer the most bigger part of even-sized brushes to be in
the top-left edge (instead of bottom-right edge which was the new
behavior).

With this patch we revert the changes, and we'll see if we can add a
new option to change the default brush center which might be useful
for left-handed users.
This commit is contained in:
David Capello 2019-05-20 20:27:37 -03:00
parent 25cec1543c
commit f6313f7dc6
2 changed files with 32 additions and 18 deletions

View File

@ -21,40 +21,54 @@ namespace tools {
void HorizontalSymmetry::generateStrokes(const Stroke& mainStroke, Strokes& strokes, void HorizontalSymmetry::generateStrokes(const Stroke& mainStroke, Strokes& strokes,
ToolLoop* loop) ToolLoop* loop)
{ {
int adjust; int brushSize, brushCenter;
if (loop->getPointShape()->isFloodFill()) { if (loop->getPointShape()->isFloodFill()) {
adjust = 1; brushSize = 1;
brushCenter = 0;
} }
else { else {
// TODO This adjustment is not valid for brush centers that are // TODO we should flip the brush center+image+bitmap or just do
// not in the default Brush::center(), we'll fix this later // the symmetry of all pixels
// (we should flip the brush center+image+bitmap or just do auto brush = loop->getBrush();
// the symmetry of all pixels) brushSize = brush->bounds().w;
adjust = ((loop->getBrush()->bounds().w % 2) == 0 ? 2: 1); brushCenter = brush->center().x;
} }
strokes.push_back(mainStroke); strokes.push_back(mainStroke);
Stroke stroke2; Stroke stroke2;
for (const auto& pt : mainStroke) for (const auto& pt : mainStroke) {
stroke2.addPoint(gfx::Point(m_x - (pt.x - m_x + adjust), pt.y)); stroke2.addPoint(
gfx::Point(
m_x - ((pt.x-brushCenter) - m_x + 1) - (brushSize - brushCenter - 1),
pt.y));
}
strokes.push_back(stroke2); strokes.push_back(stroke2);
} }
void VerticalSymmetry::generateStrokes(const Stroke& mainStroke, Strokes& strokes, void VerticalSymmetry::generateStrokes(const Stroke& mainStroke, Strokes& strokes,
ToolLoop* loop) ToolLoop* loop)
{ {
int adjust; int brushSize, brushCenter;
if (loop->getPointShape()->isFloodFill()) if (loop->getPointShape()->isFloodFill()) {
adjust = 1; brushSize = 1;
else brushCenter = 0;
adjust = ((loop->getBrush()->bounds().h % 2) == 0 ? 2: 1); }
else {
auto brush = loop->getBrush();
brushSize = brush->bounds().h;
brushCenter = brush->center().y;
}
strokes.push_back(mainStroke); strokes.push_back(mainStroke);
Stroke stroke2; Stroke stroke2;
for (const auto& pt : mainStroke) for (const auto& pt : mainStroke) {
stroke2.addPoint(gfx::Point(pt.x, m_y - (pt.y - m_y + adjust))); stroke2.addPoint(
gfx::Point(
pt.x,
m_y - ((pt.y-brushCenter) - m_y + 1) - (brushSize - brushCenter - 1)));
}
strokes.push_back(stroke2); strokes.push_back(stroke2);
} }

View File

@ -372,8 +372,8 @@ void Brush::regenerate()
void Brush::resetBounds() void Brush::resetBounds()
{ {
m_center = gfx::Point(std::max(0, (m_image->width()-1)/2), m_center = gfx::Point(std::max(0, m_image->width()/2),
std::max(0, (m_image->height()-1)/2)); std::max(0, m_image->height()/2));
m_bounds = gfx::Rect(-m_center, m_bounds = gfx::Rect(-m_center,
gfx::Size(m_image->width(), gfx::Size(m_image->width(),
m_image->height())); m_image->height()));