mirror of
https://github.com/aseprite/aseprite.git
synced 2025-03-28 05:37:19 +00:00
Move selection edges to the main tile position
This commit is contained in:
parent
7febd638fd
commit
b638b34139
@ -793,7 +793,7 @@ void Editor::drawSpriteUnclippedRect(ui::Graphics* g, const gfx::Rect& _rc)
|
||||
gfx::Color color = color_utils::color_for_ui(m_docPref.grid.color());
|
||||
g->drawVLine(color,
|
||||
spriteRect.x + int(m_proj.applyX<double>(x)),
|
||||
enclosingRect.y,
|
||||
enclosingRect.y + mainTilePosition().y,
|
||||
enclosingRect.h);
|
||||
}
|
||||
}
|
||||
@ -802,7 +802,7 @@ void Editor::drawSpriteUnclippedRect(ui::Graphics* g, const gfx::Rect& _rc)
|
||||
if (y > 0) {
|
||||
gfx::Color color = color_utils::color_for_ui(m_docPref.grid.color());
|
||||
g->drawHLine(color,
|
||||
enclosingRect.x,
|
||||
enclosingRect.x + mainTilePosition().x,
|
||||
spriteRect.y + int(m_proj.applyY<double>(y)),
|
||||
enclosingRect.w);
|
||||
}
|
||||
@ -871,8 +871,9 @@ void Editor::drawMask(Graphics* g)
|
||||
|
||||
ASSERT(m_document->getMaskBoundaries());
|
||||
|
||||
int x = m_padding.x;
|
||||
int y = m_padding.y;
|
||||
gfx::Point pt = mainTilePosition();
|
||||
pt.x = m_padding.x + m_proj.applyX(pt.x);
|
||||
pt.y = m_padding.y + m_proj.applyY(pt.y);
|
||||
|
||||
for (const auto& seg : *m_document->getMaskBoundaries()) {
|
||||
CheckedDrawMode checked(g, m_antsOffset,
|
||||
@ -892,9 +893,9 @@ void Editor::drawMask(Graphics* g)
|
||||
|
||||
// The color doesn't matter, we are using CheckedDrawMode
|
||||
if (seg.vertical())
|
||||
g->drawVLine(gfx::rgba(0, 0, 0), x+bounds.x, y+bounds.y, bounds.h);
|
||||
g->drawVLine(gfx::rgba(0, 0, 0), pt.x+bounds.x, pt.y+bounds.y, bounds.h);
|
||||
else
|
||||
g->drawHLine(gfx::rgba(0, 0, 0), x+bounds.x, y+bounds.y, bounds.w);
|
||||
g->drawHLine(gfx::rgba(0, 0, 0), pt.x+bounds.x, pt.y+bounds.y, bounds.w);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1908,6 +1909,8 @@ bool Editor::canDraw()
|
||||
bool Editor::isInsideSelection()
|
||||
{
|
||||
gfx::Point spritePos = screenToEditor(ui::get_mouse_position());
|
||||
spritePos -= mainTilePosition();
|
||||
|
||||
KeyAction action = m_customizationDelegate->getPressedKeyAction(KeyContext::SelectionTool);
|
||||
return
|
||||
(action == KeyAction::None) &&
|
||||
@ -2365,6 +2368,18 @@ gfx::Size Editor::canvasSize() const
|
||||
return sz;
|
||||
}
|
||||
|
||||
gfx::Point Editor::mainTilePosition() const
|
||||
{
|
||||
gfx::Point pt(0, 0);
|
||||
if (int(m_docPref.tiled.mode()) & int(filters::TiledMode::X_AXIS)) {
|
||||
pt.x += m_sprite->width();
|
||||
}
|
||||
if (int(m_docPref.tiled.mode()) & int(filters::TiledMode::Y_AXIS)) {
|
||||
pt.y += m_sprite->height();
|
||||
}
|
||||
return pt;
|
||||
}
|
||||
|
||||
bool Editor::isMovingPixels() const
|
||||
{
|
||||
return (dynamic_cast<MovingPixelsState*>(m_state.get()) != nullptr);
|
||||
|
@ -177,6 +177,8 @@ namespace app {
|
||||
// Returns the visible area of the active sprite.
|
||||
gfx::Rect getVisibleSpriteBounds();
|
||||
|
||||
gfx::Point mainTilePosition() const;
|
||||
|
||||
// Changes the scroll to see the given point as the center of the editor.
|
||||
void centerInSpritePoint(const gfx::Point& spritePos);
|
||||
|
||||
|
@ -777,9 +777,13 @@ bool StandbyState::overSelectionEdges(Editor* editor,
|
||||
editor->document()->getMaskBoundaries() &&
|
||||
// TODO improve this check, how we can know that we aren't in the MovingPixelsState
|
||||
!dynamic_cast<MovingPixelsState*>(editor->getState().get())) {
|
||||
gfx::Point mainOffset(editor->mainTilePosition());
|
||||
|
||||
// For each selection edge
|
||||
for (const auto& seg : *editor->document()->getMaskBoundaries()) {
|
||||
gfx::Rect segBounds = editor->editorToScreen(seg.bounds());
|
||||
gfx::Rect segBounds = seg.bounds();
|
||||
segBounds.offset(mainOffset);
|
||||
segBounds = editor->editorToScreen(segBounds);
|
||||
if (seg.vertical())
|
||||
segBounds.w = 1;
|
||||
else
|
||||
|
@ -1,5 +1,5 @@
|
||||
// Aseprite
|
||||
// Copyright (C) 2001-2016 David Capello
|
||||
// Copyright (C) 2001-2017 David Capello
|
||||
//
|
||||
// This program is distributed under the terms of
|
||||
// the End-User License Agreement for Aseprite.
|
||||
@ -60,10 +60,8 @@ HandleType TransformHandles::getHandleAtPoint(Editor* editor, const gfx::Point&
|
||||
Transformation::Corners corners;
|
||||
transform.transformBox(corners);
|
||||
|
||||
std::vector<gfx::Point> screenPoints(corners.size());
|
||||
for (size_t c=0; c<corners.size(); ++c)
|
||||
screenPoints[c] = editor->editorToScreen(
|
||||
gfx::Point((int)corners[c].x, (int)corners[c].y));
|
||||
std::vector<gfx::Point> screenPoints;
|
||||
getScreenPoints(editor, corners, screenPoints);
|
||||
|
||||
int handle_rs[2] = { gfx->width()*2, gfx->width()*3 };
|
||||
for (int i=0; i<2; ++i) {
|
||||
@ -94,10 +92,8 @@ void TransformHandles::drawHandles(Editor* editor, const Transformation& transfo
|
||||
Transformation::Corners corners;
|
||||
transform.transformBox(corners);
|
||||
|
||||
std::vector<gfx::Point> screenPoints(corners.size());
|
||||
for (size_t c=0; c<corners.size(); ++c)
|
||||
screenPoints[c] = editor->editorToScreen(
|
||||
gfx::Point((int)corners[c].x, (int)corners[c].y));
|
||||
std::vector<gfx::Point> screenPoints;
|
||||
getScreenPoints(editor, corners, screenPoints);
|
||||
|
||||
// TODO DO NOT COMMIT
|
||||
#if 0 // Uncomment this if you want to see the bounds in red (only for debugging purposes)
|
||||
@ -143,10 +139,8 @@ void TransformHandles::invalidateHandles(Editor* editor, const Transformation& t
|
||||
Transformation::Corners corners;
|
||||
transform.transformBox(corners);
|
||||
|
||||
std::vector<gfx::Point> screenPoints(corners.size());
|
||||
for (size_t c=0; c<corners.size(); ++c)
|
||||
screenPoints[c] = editor->editorToScreen(
|
||||
gfx::Point((int)corners[c].x, (int)corners[c].y));
|
||||
std::vector<gfx::Point> screenPoints;
|
||||
getScreenPoints(editor, corners, screenPoints);
|
||||
|
||||
// Invalidate each corner handle.
|
||||
for (size_t c=0; c<HANDLES; ++c) {
|
||||
@ -258,4 +252,18 @@ bool TransformHandles::visiblePivot(fixmath::fixed angle) const
|
||||
return (Preferences::instance().selection.pivotVisibility() || angle != 0);
|
||||
}
|
||||
|
||||
void TransformHandles::getScreenPoints(
|
||||
Editor* editor,
|
||||
const Transformation::Corners& corners,
|
||||
std::vector<gfx::Point>& screenPoints) const
|
||||
{
|
||||
gfx::Point main = editor->mainTilePosition();
|
||||
|
||||
screenPoints.resize(corners.size());
|
||||
for (size_t c=0; c<corners.size(); ++c)
|
||||
screenPoints[c] = editor->editorToScreen(
|
||||
gfx::Point((int)corners[c].x+main.x,
|
||||
(int)corners[c].y+main.y));
|
||||
}
|
||||
|
||||
} // namespace app
|
||||
|
@ -1,5 +1,5 @@
|
||||
// Aseprite
|
||||
// Copyright (C) 2001-2016 David Capello
|
||||
// Copyright (C) 2001-2017 David Capello
|
||||
//
|
||||
// This program is distributed under the terms of
|
||||
// the End-User License Agreement for Aseprite.
|
||||
@ -13,6 +13,8 @@
|
||||
#include "fixmath/fixmath.h"
|
||||
#include "gfx/point.h"
|
||||
|
||||
#include <vector>
|
||||
|
||||
namespace ui {
|
||||
class Graphics;
|
||||
}
|
||||
@ -40,6 +42,10 @@ namespace app {
|
||||
void drawHandle(ui::Graphics* g, int x, int y, fixmath::fixed angle);
|
||||
void adjustHandle(int& x, int& y, int handle_w, int handle_h, fixmath::fixed angle);
|
||||
bool visiblePivot(fixmath::fixed angle) const;
|
||||
void getScreenPoints(
|
||||
Editor* editor,
|
||||
const Transformation::Corners& corners,
|
||||
std::vector<gfx::Point>& screenPoints) const;
|
||||
};
|
||||
|
||||
} // namespace app
|
||||
|
Loading…
x
Reference in New Issue
Block a user