Fix moving 9-slices rules (regression introduced in 73de6c8b1d)

This commit is contained in:
David Capello 2020-02-25 15:25:36 -03:00
parent 53cb226f09
commit 5cd23b8522

View File

@ -1,5 +1,5 @@
// Aseprite
// Copyright (C) 2019 Igara Studio S.A.
// Copyright (C) 2019-2020 Igara Studio S.A.
// Copyright (C) 2017-2018 David Capello
//
// This program is distributed under the terms of
@ -92,6 +92,36 @@ bool MovingSliceState::onMouseMove(Editor* editor, MouseMessage* msg)
rc.x += delta.x;
rc.y += delta.y;
}
// Move/resize 9-slices center
else if (m_hit.type() == EditorHit::SliceCenter) {
if (m_hit.border() & LEFT) {
rc.x += delta.x;
rc.w -= delta.x;
if (rc.w < 1) {
rc.x += rc.w-1;
rc.w = 1;
}
}
if (m_hit.border() & TOP) {
rc.y += delta.y;
rc.h -= delta.y;
if (rc.h < 1) {
rc.y += rc.h-1;
rc.h = 1;
}
}
if (m_hit.border() & RIGHT) {
rc.w += delta.x;
if (rc.w < 1)
rc.w = 1;
}
if (m_hit.border() & BOTTOM) {
rc.h += delta.y;
if (rc.h < 1)
rc.h = 1;
}
}
// Move/resize bounds
else {
if (m_hit.border() & LEFT) {
rc.x += delta.x * (totalBounds.x2() - rc.x) / totalBounds.w;