mirror of
https://github.com/aseprite/aseprite.git
synced 2025-02-06 21:39:57 +00:00
Now selection tools select "by tiles" when we are in tile mode
This commit is contained in:
parent
1d68d169a4
commit
9420bfff18
@ -442,24 +442,33 @@ public:
|
||||
}
|
||||
|
||||
void inkHline(int x1, int y, int x2, ToolLoop* loop) override {
|
||||
gfx::Rect rc(x1, y, x2-x1+1, 1);
|
||||
|
||||
// For tile point shape, the point shape is done in "tiles"
|
||||
// coordinatse, but we want the selection in "canvas" coordinates.
|
||||
if (loop->getPointShape()->isTile())
|
||||
rc = loop->getGrid().tileToCanvas(rc);
|
||||
|
||||
if (m_modify_selection) {
|
||||
int modifiers = int(loop->getModifiers());
|
||||
|
||||
if ((modifiers & (int(ToolLoopModifiers::kReplaceSelection) |
|
||||
int(ToolLoopModifiers::kAddSelection))) != 0) {
|
||||
m_mask.add(gfx::Rect(x1, y, x2-x1+1, 1));
|
||||
m_mask.add(rc);
|
||||
}
|
||||
else if ((modifiers & int(ToolLoopModifiers::kSubtractSelection)) != 0) {
|
||||
m_mask.subtract(gfx::Rect(x1, y, x2-x1+1, 1));
|
||||
m_mask.subtract(rc);
|
||||
}
|
||||
else if ((modifiers & int(ToolLoopModifiers::kIntersectSelection)) != 0) {
|
||||
m_intersectMask.add(gfx::Rect(x1, y, x2-x1+1, 1));
|
||||
m_intersectMask.add(rc);
|
||||
}
|
||||
|
||||
m_maxBounds |= gfx::Rect(x1, y, x2-x1+1, 1);
|
||||
m_maxBounds |= rc;
|
||||
}
|
||||
else {
|
||||
BaseInk::inkHline(x1, y, x2, loop);
|
||||
rc &= loop->getDstImage()->bounds();
|
||||
for (int v=rc.y; v<rc.y2(); ++v)
|
||||
BaseInk::inkHline(rc.x, v, rc.x2()-1, loop);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -21,6 +21,7 @@ namespace app {
|
||||
public:
|
||||
virtual ~PointShape() { }
|
||||
virtual bool isPixel() { return false; }
|
||||
virtual bool isTile() { return false; }
|
||||
virtual bool isFloodFill() { return false; }
|
||||
virtual bool isSpray() { return false; }
|
||||
virtual void preparePointShape(ToolLoop* loop) { }
|
||||
|
@ -41,6 +41,7 @@ public:
|
||||
class TilePointShape : public PointShape {
|
||||
public:
|
||||
bool isPixel() override { return true; }
|
||||
bool isTile() override { return true; }
|
||||
|
||||
void transformPoint(ToolLoop* loop, const Stroke::Pt& pt) override {
|
||||
const doc::Grid& grid = loop->getGrid();
|
||||
|
@ -84,7 +84,6 @@ static void fill_toolloop_params_from_tool_preferences(ToolLoopParams& params)
|
||||
// Common properties between drawing/preview ToolLoop impl
|
||||
|
||||
class ToolLoopBase : public tools::ToolLoop {
|
||||
|
||||
protected:
|
||||
Editor* m_editor;
|
||||
tools::Tool* m_tool;
|
||||
@ -125,7 +124,7 @@ protected:
|
||||
|
||||
public:
|
||||
ToolLoopBase(Editor* editor,
|
||||
const Site& site,
|
||||
Site& site,
|
||||
ToolLoopParams& params)
|
||||
: m_editor(editor)
|
||||
, m_tool(params.tool)
|
||||
@ -171,6 +170,17 @@ public:
|
||||
if (site.tilemapMode() == TilemapMode::Tiles) {
|
||||
m_pointShape = App::instance()->toolBox()->getPointShapeById(
|
||||
tools::WellKnownPointShapes::Tile);
|
||||
|
||||
// In selection ink, we need the Pixels tilemap mode so
|
||||
// ExpandCelCanvas uses the whole canvas for the selection
|
||||
// preview.
|
||||
//
|
||||
// TODO in the future we could improve this, using 1) a special
|
||||
// tilemap layer to preview the selection, or 2) using a
|
||||
// path to show the selection (so there is no preview layer
|
||||
// at all and nor ExpandCelCanvas)
|
||||
if (m_ink->isSelection())
|
||||
site.tilemapMode(TilemapMode::Pixels);
|
||||
}
|
||||
|
||||
#ifdef ENABLE_UI // TODO add dynamics support when UI is not enabled
|
||||
@ -443,7 +453,7 @@ class ToolLoopImpl : public ToolLoopBase {
|
||||
|
||||
public:
|
||||
ToolLoopImpl(Editor* editor,
|
||||
const Site& site,
|
||||
Site& site,
|
||||
Context* context,
|
||||
ToolLoopParams& params,
|
||||
const bool saveLastPoint)
|
||||
@ -843,8 +853,9 @@ tools::ToolLoop* create_tool_loop_for_script(
|
||||
if (!context->isUIAvailable())
|
||||
Preferences::instance().resetToolPreferences(params.tool);
|
||||
|
||||
Site site2(site);
|
||||
return new ToolLoopImpl(
|
||||
nullptr, site, context, params, false);
|
||||
nullptr, site2, context, params, false);
|
||||
}
|
||||
catch (const std::exception& ex) {
|
||||
Console::showException(ex);
|
||||
@ -865,7 +876,7 @@ class PreviewToolLoopImpl : public ToolLoopBase {
|
||||
public:
|
||||
PreviewToolLoopImpl(
|
||||
Editor* editor,
|
||||
const Site& site,
|
||||
Site& site,
|
||||
ToolLoopParams& params,
|
||||
Image* image,
|
||||
const gfx::Point& celOrigin)
|
||||
|
Loading…
x
Reference in New Issue
Block a user