mirror of
https://github.com/aseprite/aseprite.git
synced 2025-03-20 04:20:49 +00:00
Fix SelectBoxState when tiled mode is enabled
This commit is contained in:
parent
72610099ae
commit
338ed9dd49
@ -84,7 +84,9 @@ void SelectBoxState::onBeforePopState(Editor* editor)
|
||||
bool SelectBoxState::onMouseDown(Editor* editor, MouseMessage* msg)
|
||||
{
|
||||
if (msg->left() || msg->right()) {
|
||||
m_startingPos = editor->screenToEditor(msg->position());
|
||||
m_startingPos =
|
||||
editor->screenToEditor(msg->position())
|
||||
- editor->mainTilePosition();
|
||||
|
||||
if (hasFlag(Flags::Rulers)) {
|
||||
m_rulersDragAlign = hitTestRulers(editor, msg->position(), true);
|
||||
@ -130,7 +132,10 @@ bool SelectBoxState::onMouseMove(Editor* editor, MouseMessage* msg)
|
||||
updateContextBar();
|
||||
|
||||
if (hasFlag(Flags::Rulers) && !m_movingRulers.empty()) {
|
||||
gfx::Point newPos = editor->screenToEditor(msg->position());
|
||||
gfx::Point newPos =
|
||||
editor->screenToEditor(msg->position())
|
||||
- editor->mainTilePosition();
|
||||
|
||||
gfx::Point delta = newPos - m_startingPos;
|
||||
|
||||
for (int i : m_movingRulers) {
|
||||
@ -147,7 +152,9 @@ bool SelectBoxState::onMouseMove(Editor* editor, MouseMessage* msg)
|
||||
|
||||
if (hasFlag(Flags::QuickBox) && m_selectingBox) {
|
||||
gfx::Point p1 = m_startingPos;
|
||||
gfx::Point p2 = editor->screenToEditor(msg->position());
|
||||
gfx::Point p2 =
|
||||
editor->screenToEditor(msg->position())
|
||||
- editor->mainTilePosition();
|
||||
|
||||
if (p2.x < p1.x) std::swap(p1.x, p2.x);
|
||||
if (p2.y < p1.y) std::swap(p1.y, p2.y);
|
||||
@ -257,7 +264,10 @@ void SelectBoxState::postRenderDecorator(EditorPostRender* render)
|
||||
// Paint a grid generated by the box
|
||||
gfx::Color rulerColor = skin::SkinTheme::instance()->colors.selectBoxRuler();
|
||||
gfx::Color gridColor = skin::SkinTheme::instance()->colors.selectBoxGrid();
|
||||
gfx::Point mainOffset = editor->mainTilePosition();
|
||||
gfx::Rect boxBounds = getBoxBounds();
|
||||
boxBounds.offset(mainOffset);
|
||||
sp.offset(mainOffset);
|
||||
|
||||
if (hasFlag(Flags::Grid)) {
|
||||
if (boxBounds.w > 0) {
|
||||
@ -288,13 +298,17 @@ void SelectBoxState::postRenderDecorator(EditorPostRender* render)
|
||||
for (Rulers::iterator it = m_rulers.begin(), end = m_rulers.end(); it != end; ++it) {
|
||||
switch (it->orientation()) {
|
||||
|
||||
case Ruler::Horizontal:
|
||||
render->drawLine(vp.x, it->position(), vp.x+vp.w-1, it->position(), rulerColor);
|
||||
case Ruler::Horizontal: {
|
||||
const int y = it->position()+mainOffset.y;
|
||||
render->drawLine(vp.x, y, vp.x+vp.w-1, y, rulerColor);
|
||||
break;
|
||||
}
|
||||
|
||||
case Ruler::Vertical:
|
||||
render->drawLine(it->position(), vp.y, it->position(), vp.y+vp.h-1, rulerColor);
|
||||
case Ruler::Vertical: {
|
||||
const int x = it->position()+mainOffset.x;
|
||||
render->drawLine(x, vp.y, x, vp.y+vp.h-1, rulerColor);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -339,7 +353,9 @@ int SelectBoxState::hitTestRulers(Editor* editor,
|
||||
|
||||
// Check moving all rulers at the same time
|
||||
if (align == 0 && !hasFlag(Flags::QuickBox)) {
|
||||
if (editor->editorToScreen(getBoxBounds()).contains(mousePos)) {
|
||||
if (editor->editorToScreen(
|
||||
getBoxBounds().offset(editor->mainTilePosition()))
|
||||
.contains(mousePos)) {
|
||||
align = LEFT | TOP | RIGHT | BOTTOM;
|
||||
if (updateMovingRulers) {
|
||||
// Add all rulers
|
||||
@ -355,12 +371,19 @@ int SelectBoxState::hitTestRulers(Editor* editor,
|
||||
bool SelectBoxState::hitTestRuler(Editor* editor, const Ruler& ruler,
|
||||
const gfx::Point& mousePos)
|
||||
{
|
||||
gfx::Point pt = editor->editorToScreen(
|
||||
gfx::Point(ruler.position(), ruler.position()));
|
||||
gfx::Point pt = editor->mainTilePosition();
|
||||
pt = editor->editorToScreen(
|
||||
pt + gfx::Point(ruler.position(), ruler.position()));
|
||||
|
||||
switch (ruler.orientation()) {
|
||||
case Ruler::Horizontal: return (mousePos.y >= pt.y-2*guiscale() && mousePos.y <= pt.y+2*guiscale());
|
||||
case Ruler::Vertical: return (mousePos.x >= pt.x-2*guiscale() && mousePos.x <= pt.x+2*guiscale());
|
||||
|
||||
case Ruler::Horizontal:
|
||||
return (mousePos.y >= pt.y-2*guiscale() &&
|
||||
mousePos.y <= pt.y+2*guiscale());
|
||||
|
||||
case Ruler::Vertical:
|
||||
return (mousePos.x >= pt.x-2*guiscale() &&
|
||||
mousePos.x <= pt.x+2*guiscale());
|
||||
}
|
||||
|
||||
return false;
|
||||
|
Loading…
x
Reference in New Issue
Block a user