Unify slice/move_slice tools

This commit is contained in:
David Capello 2017-04-12 15:40:27 -03:00
parent fece0cf025
commit 097efa4cc2
7 changed files with 14 additions and 58 deletions

View File

@ -446,7 +446,6 @@
<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" />
@ -1135,15 +1134,6 @@
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: 14 KiB

After

Width:  |  Height:  |  Size: 13 KiB

View File

@ -388,7 +388,6 @@
<part id="tool_jumble" x="176" y="112" w="16" h="16" />
<part id="tool_configuration" x="144" y="128" w="16" h="16" />
<part id="tool_minieditor" x="160" y="128" w="16" h="16" />
<part id="tool_move_slice" x="224" y="48" w="16" h="16" />
<part id="simple_color_border" x="16" y="32" w1="3" w2="6" w3="3" h1="3" h2="6" h3="3" />
<part id="simple_color_selected" x="32" y="32" w1="3" w2="6" w3="3" h1="3" h2="6" h3="3" />
</parts>

View File

@ -64,7 +64,6 @@ 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

View File

@ -209,39 +209,6 @@ 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 };

View File

@ -99,7 +99,6 @@ 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();

View File

@ -1853,17 +1853,9 @@ EditorHit Editor::calcHit(const gfx::Point& mouseScreenPos)
gfx::Rect bounds = editorToScreen(key->bounds());
gfx::Rect center = key->center();
// 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)) {
// Move bounds
if (bounds.contains(mouseScreenPos) &&
!bounds.shrink(5*guiscale()).contains(mouseScreenPos)) {
int border =
(mouseScreenPos.x <= bounds.x ? LEFT: 0) |
(mouseScreenPos.y <= bounds.y ? TOP: 0) |
@ -1875,7 +1867,9 @@ EditorHit Editor::calcHit(const gfx::Point& mouseScreenPos)
hit.setSlice(slice);
return hit;
}
else if (!center.isEmpty()) {
// Move center
if (!center.isEmpty()) {
center = editorToScreen(
center.offset(key->bounds().origin()));
@ -1896,6 +1890,14 @@ EditorHit Editor::calcHit(const gfx::Point& mouseScreenPos)
return hit;
}
}
// Move all the slice
if (bounds.contains(mouseScreenPos)) {
EditorHit hit(EditorHit::SliceBounds);
hit.setBorder(CENTER | MIDDLE);
hit.setSlice(slice);
return hit;
}
}
}
}