mirror of
https://github.com/aseprite/aseprite.git
synced 2025-02-04 06:40:07 +00:00
Add Move Slice tool
This commit is contained in:
parent
347ccfbb78
commit
f01e5ad5f3
10
data/gui.xml
10
data/gui.xml
@ -446,6 +446,7 @@
|
||||
<key tool="hand" shortcut="H" />
|
||||
<key tool="move" shortcut="V" />
|
||||
<key tool="slice" shortcut="C" />
|
||||
<key tool="move_slice" shortcut="C" />
|
||||
<key tool="zoom" shortcut="Z" />
|
||||
|
||||
<key tool="paint_bucket" shortcut="G" />
|
||||
@ -1133,6 +1134,15 @@
|
||||
intertwine="as_rectangles"
|
||||
tracepolicy="last"
|
||||
/>
|
||||
<tool id="move_slice"
|
||||
text="Move Slice Tool"
|
||||
fill="none"
|
||||
ink="move_slice"
|
||||
controller="two_points"
|
||||
pointshape="pixel"
|
||||
intertwine="as_rectangles"
|
||||
tracepolicy="last"
|
||||
/>
|
||||
</group>
|
||||
|
||||
<group id="paint_bucket" text="Paint Bucket Tool">
|
||||
|
Binary file not shown.
Before Width: | Height: | Size: 13 KiB After Width: | Height: | Size: 13 KiB |
File diff suppressed because it is too large
Load Diff
@ -1,5 +1,5 @@
|
||||
// Aseprite
|
||||
// Copyright (C) 2001-2015 David Capello
|
||||
// Copyright (C) 2001-2017 David Capello
|
||||
//
|
||||
// This program is distributed under the terms of
|
||||
// the End-User License Agreement for Aseprite.
|
||||
@ -64,6 +64,7 @@ namespace app {
|
||||
|
||||
// Returns true if this ink is used to mark slices
|
||||
virtual bool isSlice() const { return false; }
|
||||
virtual bool isMoveSlice() const { return false; }
|
||||
|
||||
// Returns true if inkHline() needs source cel coordinates
|
||||
// instead of sprite coordinates (i.e. relative to
|
||||
|
@ -209,6 +209,39 @@ public:
|
||||
};
|
||||
|
||||
|
||||
class MoveSliceInk : public Ink {
|
||||
AlgoHLine m_proc;
|
||||
bool m_selectSlices;
|
||||
|
||||
public:
|
||||
MoveSliceInk() {
|
||||
m_selectSlices = false;
|
||||
}
|
||||
|
||||
Ink* clone() override { return new MoveSliceInk(*this); }
|
||||
|
||||
bool isSlice() const override { return true; }
|
||||
bool isMoveSlice() const override { return true; }
|
||||
bool needsCelCoordinates() const override { return false; }
|
||||
|
||||
void prepareInk(ToolLoop* loop) override {
|
||||
m_proc = get_ink_proc<XorInkProcessing>(loop->sprite()->pixelFormat());
|
||||
}
|
||||
|
||||
void inkHline(int x1, int y, int x2, ToolLoop* loop) override {
|
||||
if (m_selectSlices) {
|
||||
// TODO
|
||||
}
|
||||
else
|
||||
(*m_proc)(x1, y, x2, loop);
|
||||
}
|
||||
|
||||
void setFinalStep(ToolLoop* loop, bool state) override {
|
||||
m_selectSlices = state;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
class EraserInk : public Ink {
|
||||
public:
|
||||
enum Type { Eraser, ReplaceFgWithBg, ReplaceBgWithFg };
|
||||
|
@ -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.
|
||||
@ -64,6 +64,7 @@ const char* WellKnownInks::Zoom = "zoom";
|
||||
const char* WellKnownInks::Scroll = "scroll";
|
||||
const char* WellKnownInks::Move = "move";
|
||||
const char* WellKnownInks::Slice = "slice";
|
||||
const char* WellKnownInks::MoveSlice = "move_slice";
|
||||
const char* WellKnownInks::Blur = "blur";
|
||||
const char* WellKnownInks::Jumble = "jumble";
|
||||
|
||||
@ -98,6 +99,7 @@ ToolBox::ToolBox()
|
||||
m_inks[WellKnownInks::Scroll] = new ScrollInk();
|
||||
m_inks[WellKnownInks::Move] = new MoveInk();
|
||||
m_inks[WellKnownInks::Slice] = new SliceInk();
|
||||
m_inks[WellKnownInks::MoveSlice] = new MoveSliceInk();
|
||||
m_inks[WellKnownInks::Blur] = new BlurInk();
|
||||
m_inks[WellKnownInks::Jumble] = new JumbleInk();
|
||||
|
||||
|
@ -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.
|
||||
@ -46,6 +46,7 @@ namespace app {
|
||||
extern const char* Scroll;
|
||||
extern const char* Move;
|
||||
extern const char* Slice;
|
||||
extern const char* MoveSlice;
|
||||
extern const char* Blur;
|
||||
extern const char* Jumble;
|
||||
};
|
||||
|
@ -1699,8 +1699,17 @@ EditorHit Editor::calcHit(const gfx::Point& mouseScreenPos)
|
||||
gfx::Rect bounds = editorToScreen(key->bounds());
|
||||
gfx::Rect center = key->center();
|
||||
|
||||
if (bounds.contains(mouseScreenPos) &&
|
||||
!bounds.shrink(5*guiscale()).contains(mouseScreenPos)) {
|
||||
// Only move slice
|
||||
if (ink->isMoveSlice()) {
|
||||
if (bounds.contains(mouseScreenPos)) {
|
||||
EditorHit hit(EditorHit::SliceBounds);
|
||||
hit.setBorder(CENTER | MIDDLE);
|
||||
hit.setSlice(slice);
|
||||
return hit;
|
||||
}
|
||||
}
|
||||
else if (bounds.contains(mouseScreenPos) &&
|
||||
!bounds.shrink(5*guiscale()).contains(mouseScreenPos)) {
|
||||
int border =
|
||||
(mouseScreenPos.x <= bounds.x ? LEFT: 0) |
|
||||
(mouseScreenPos.y <= bounds.y ? TOP: 0) |
|
||||
|
@ -69,31 +69,38 @@ bool MovingSliceState::onMouseMove(Editor* editor, MouseMessage* msg)
|
||||
(m_hit.type() == EditorHit::SliceCenter ? m_key.center():
|
||||
m_key.bounds());
|
||||
|
||||
if (m_hit.border() & LEFT) {
|
||||
// Move slice
|
||||
if (m_hit.border() == (CENTER | MIDDLE)) {
|
||||
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;
|
||||
}
|
||||
else {
|
||||
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;
|
||||
}
|
||||
}
|
||||
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;
|
||||
}
|
||||
|
||||
if (m_hit.type() == EditorHit::SliceCenter)
|
||||
|
@ -444,6 +444,9 @@ bool StandbyState::onSetCursor(Editor* editor, const gfx::Point& mouseScreenPos)
|
||||
case EditorHit::SliceBounds:
|
||||
case EditorHit::SliceCenter:
|
||||
switch (hit.border()) {
|
||||
case CENTER | MIDDLE:
|
||||
editor->showMouseCursor(kMoveCursor);
|
||||
break;
|
||||
case TOP | LEFT:
|
||||
editor->showMouseCursor(kSizeNWCursor);
|
||||
break;
|
||||
|
Loading…
x
Reference in New Issue
Block a user