mirror of
https://github.com/aseprite/aseprite.git
synced 2025-02-21 21:41:02 +00:00
Remove SnapBehavior::SnapInRightBottom which is confusing (fix issue 343)
This commit is contained in:
parent
3cbf3e122f
commit
3b8926b7d1
@ -27,11 +27,6 @@
|
||||
namespace app {
|
||||
class DocumentSettingsObserver;
|
||||
|
||||
enum SnapBehavior {
|
||||
NormalSnap = 0,
|
||||
SnapInRightBottom = 1
|
||||
};
|
||||
|
||||
class IDocumentSettings {
|
||||
public:
|
||||
virtual ~IDocumentSettings() { }
|
||||
@ -53,7 +48,7 @@ namespace app {
|
||||
virtual void setGridBounds(const gfx::Rect& rect) = 0;
|
||||
virtual void setGridColor(const app::Color& color) = 0;
|
||||
|
||||
virtual void snapToGrid(gfx::Point& point, SnapBehavior snapBehavior) const = 0;
|
||||
virtual void snapToGrid(gfx::Point& point) const = 0;
|
||||
|
||||
// Pixel grid
|
||||
|
||||
|
@ -101,7 +101,7 @@ public:
|
||||
virtual void setGridBounds(const gfx::Rect& rect) OVERRIDE;
|
||||
virtual void setGridColor(const app::Color& color) OVERRIDE;
|
||||
|
||||
virtual void snapToGrid(gfx::Point& point, SnapBehavior snapBehavior) const OVERRIDE;
|
||||
virtual void snapToGrid(gfx::Point& point) const OVERRIDE;
|
||||
|
||||
// Pixel grid
|
||||
|
||||
@ -394,21 +394,20 @@ void UIDocumentSettingsImpl::setGridColor(const app::Color& color)
|
||||
notifyObservers<const app::Color&>(&DocumentSettingsObserver::onSetGridColor, color);
|
||||
}
|
||||
|
||||
void UIDocumentSettingsImpl::snapToGrid(gfx::Point& point, SnapBehavior snapBehavior) const
|
||||
void UIDocumentSettingsImpl::snapToGrid(gfx::Point& point) const
|
||||
{
|
||||
register int w = m_gridBounds.w;
|
||||
register int h = m_gridBounds.h;
|
||||
int adjust = (snapBehavior & SnapInRightBottom ? 1: 0);
|
||||
div_t d, dx, dy;
|
||||
|
||||
dx = div(m_gridBounds.x, w);
|
||||
dy = div(m_gridBounds.y, h);
|
||||
|
||||
d = div(point.x-dx.rem, w);
|
||||
point.x = dx.rem + d.quot*w + ((d.rem > w/2)? w-adjust: 0);
|
||||
point.x = dx.rem + d.quot*w + ((d.rem > w/2)? w: 0);
|
||||
|
||||
d = div(point.y-dy.rem, h);
|
||||
point.y = dy.rem + d.quot*h + ((d.rem > h/2)? h-adjust: 0);
|
||||
point.y = dy.rem + d.quot*h + ((d.rem > h/2)? h: 0);
|
||||
}
|
||||
|
||||
bool UIDocumentSettingsImpl::getPixelGridVisible()
|
||||
|
@ -98,7 +98,7 @@ void ToolLoopManager::pressButton(const Pointer& pointer)
|
||||
Point spritePoint = m_toolLoop->screenToSprite(Point(pointer.getX(), pointer.getY()));
|
||||
m_toolLoop->setSpeed(Point(0, 0));
|
||||
m_oldPoint = spritePoint;
|
||||
snapToGrid(true, spritePoint);
|
||||
snapToGrid(spritePoint);
|
||||
|
||||
m_toolLoop->getController()->pressButton(m_points, spritePoint);
|
||||
|
||||
@ -115,7 +115,7 @@ bool ToolLoopManager::releaseButton(const Pointer& pointer)
|
||||
return false;
|
||||
|
||||
Point spritePoint = m_toolLoop->screenToSprite(Point(pointer.getX(), pointer.getY()));
|
||||
snapToGrid(true, spritePoint);
|
||||
snapToGrid(spritePoint);
|
||||
|
||||
bool res = m_toolLoop->getController()->releaseButton(m_points, spritePoint);
|
||||
|
||||
@ -138,7 +138,7 @@ void ToolLoopManager::movement(const Pointer& pointer)
|
||||
// Calculate the speed (new sprite point - old sprite point)
|
||||
m_toolLoop->setSpeed(spritePoint - m_oldPoint);
|
||||
m_oldPoint = spritePoint;
|
||||
snapToGrid(true, spritePoint);
|
||||
snapToGrid(spritePoint);
|
||||
|
||||
m_toolLoop->getController()->movement(m_toolLoop, m_points, spritePoint);
|
||||
|
||||
@ -201,19 +201,14 @@ void ToolLoopManager::doLoopStep(bool last_step)
|
||||
m_toolLoop->updateDirtyArea();
|
||||
}
|
||||
|
||||
// Applies the grid settings to the specified sprite point, if
|
||||
// "flexible" is true this function will try to snap the point
|
||||
// to one of the four corners of each grid-tile, if "flexible"
|
||||
// is false, only the origin of each grid-tile will be used
|
||||
// to snap the point
|
||||
void ToolLoopManager::snapToGrid(bool flexible, Point& point)
|
||||
// Applies the grid settings to the specified sprite point.
|
||||
void ToolLoopManager::snapToGrid(Point& point)
|
||||
{
|
||||
if (!m_toolLoop->getController()->canSnapToGrid() ||
|
||||
!m_toolLoop->getDocumentSettings()->getSnapToGrid())
|
||||
return;
|
||||
|
||||
m_toolLoop->getDocumentSettings()
|
||||
->snapToGrid(point, (flexible ? SnapInRightBottom: NormalSnap));
|
||||
m_toolLoop->getDocumentSettings()->snapToGrid(point);
|
||||
}
|
||||
|
||||
void ToolLoopManager::calculateDirtyArea(ToolLoop* loop, const Points& points, Region& dirty_area)
|
||||
|
@ -97,7 +97,7 @@ namespace app {
|
||||
typedef std::vector<gfx::Point> Points;
|
||||
|
||||
void doLoopStep(bool last_step);
|
||||
void snapToGrid(bool flexible, gfx::Point& point);
|
||||
void snapToGrid(gfx::Point& point);
|
||||
|
||||
static void calculateDirtyArea(ToolLoop* loop,
|
||||
const Points& points,
|
||||
|
@ -221,7 +221,7 @@ void PixelsMovement::moveImage(int x, int y, MoveModifier moveModifier)
|
||||
// Snap the x1,y1 point to the grid.
|
||||
gfx::Point gridOffset(x1, y1);
|
||||
UIContext::instance()->getSettings()
|
||||
->getDocumentSettings(m_document)->snapToGrid(gridOffset, NormalSnap);
|
||||
->getDocumentSettings(m_document)->snapToGrid(gridOffset);
|
||||
|
||||
// Now we calculate the difference from x1,y1 point and we can
|
||||
// use it to adjust all coordinates (x1, y1, x2, y2).
|
||||
|
Loading…
x
Reference in New Issue
Block a user