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