Add "slice" ink and tool (it is not yet implemented)

This commit is contained in:
David Capello 2014-06-27 22:58:38 -03:00
parent 9fe53de8eb
commit 0b8d88d6ee
10 changed files with 38 additions and 21 deletions

View File

@ -166,6 +166,7 @@
<key tool="hand" shortcut="H" /> <key tool="hand" shortcut="H" />
<key tool="move" shortcut="V" /> <key tool="move" shortcut="V" />
<key tool="zoom" shortcut="Z" /> <key tool="zoom" shortcut="Z" />
<!-- key tool="slice" shortcut="K" /-->
<key tool="paint_bucket" shortcut="G" /> <key tool="paint_bucket" shortcut="G" />
@ -600,6 +601,15 @@
ink="move" ink="move"
controller="freehand" controller="freehand"
/> />
<!-- tool id="slice"
text="Slice Tool"
fill="always"
ink="slice"
controller="two_points"
pointshape="pixel"
intertwine="as_rectangles"
tracepolicy="last"
/-->
</group> </group>
<group id="paint_bucket" text="Paint Bucket Tool"> <group id="paint_bucket" text="Paint Bucket Tool">

Binary file not shown.

Before

Width:  |  Height:  |  Size: 12 KiB

After

Width:  |  Height:  |  Size: 12 KiB

View File

@ -125,6 +125,7 @@
<tool id="hand" x="176" y="32" w="16" h="16" /> <tool id="hand" x="176" y="32" w="16" h="16" />
<tool id="move" x="192" y="32" w="16" h="16" /> <tool id="move" x="192" y="32" w="16" h="16" />
<tool id="zoom" x="208" y="32" w="16" h="16" /> <tool id="zoom" x="208" y="32" w="16" h="16" />
<tool id="slice" x="224" y="32" w="16" h="16" />
<tool id="paint_bucket" x="144" y="48" w="16" h="16" /> <tool id="paint_bucket" x="144" y="48" w="16" h="16" />

View File

@ -58,6 +58,9 @@ namespace app {
// Returns true if this ink moves cels // Returns true if this ink moves cels
virtual bool isCelMovement() const { return false; } virtual bool isCelMovement() const { return false; }
// Returns true if this ink is used to mark slices
virtual bool isSlice() const { return false; }
// It is called when the tool-loop start (generally when the user // It is called when the tool-loop start (generally when the user
// presses a mouse button over a sprite editor) // presses a mouse button over a sprite editor)
virtual void prepareInk(ToolLoop* loop) { } virtual void prepareInk(ToolLoop* loop) { }

View File

@ -135,34 +135,27 @@ public:
class ZoomInk : public Ink { class ZoomInk : public Ink {
public: public:
bool isZoom() const { return true; } bool isZoom() const { return true; }
void prepareInk(ToolLoop* loop) { }
void prepareInk(ToolLoop* loop) void inkHline(int x1, int y, int x2, ToolLoop* loop) { }
{
// Do nothing
}
void inkHline(int x1, int y, int x2, ToolLoop* loop)
{
// Do nothing
}
}; };
class MoveInk : public Ink { class MoveInk : public Ink {
public: public:
bool isCelMovement() const { return true; } bool isCelMovement() const { return true; }
void prepareInk(ToolLoop* loop) { }
void inkHline(int x1, int y, int x2, ToolLoop* loop) { }
};
void prepareInk(ToolLoop* loop)
{
// Do nothing
}
void inkHline(int x1, int y, int x2, ToolLoop* loop) class SliceInk : public Ink {
{ public:
// Do nothing bool isSlice() const { return true; }
void prepareInk(ToolLoop* loop) { }
void inkHline(int x1, int y, int x2, ToolLoop* loop) {
// TODO show the selection-preview with a XOR color or something like that
draw_hline(loop->getDstImage(), x1, y, x2, loop->getPrimaryColor());
} }
}; };

View File

@ -68,6 +68,7 @@ const char* WellKnownInks::PickBg = "pick_bg";
const char* WellKnownInks::Zoom = "zoom"; const char* WellKnownInks::Zoom = "zoom";
const char* WellKnownInks::Scroll = "scroll"; const char* WellKnownInks::Scroll = "scroll";
const char* WellKnownInks::Move = "move"; const char* WellKnownInks::Move = "move";
const char* WellKnownInks::Slice = "slice";
const char* WellKnownInks::Blur = "blur"; const char* WellKnownInks::Blur = "blur";
const char* WellKnownInks::Jumble = "jumble"; const char* WellKnownInks::Jumble = "jumble";
@ -95,9 +96,10 @@ ToolBox::ToolBox()
m_inks[WellKnownInks::ReplaceBgWithFg] = new EraserInk(EraserInk::ReplaceBgWithFg); m_inks[WellKnownInks::ReplaceBgWithFg] = new EraserInk(EraserInk::ReplaceBgWithFg);
m_inks[WellKnownInks::PickFg] = new PickInk(PickInk::Fg); m_inks[WellKnownInks::PickFg] = new PickInk(PickInk::Fg);
m_inks[WellKnownInks::PickBg] = new PickInk(PickInk::Bg); m_inks[WellKnownInks::PickBg] = new PickInk(PickInk::Bg);
m_inks[WellKnownInks::Zoom] = new ZoomInk(); m_inks[WellKnownInks::Zoom] = new ZoomInk();
m_inks[WellKnownInks::Scroll] = new ScrollInk(); m_inks[WellKnownInks::Scroll] = new ScrollInk();
m_inks[WellKnownInks::Move] = new MoveInk(); m_inks[WellKnownInks::Move] = new MoveInk();
m_inks[WellKnownInks::Slice] = new SliceInk();
m_inks[WellKnownInks::Blur] = new BlurInk(); m_inks[WellKnownInks::Blur] = new BlurInk();
m_inks[WellKnownInks::Jumble] = new JumbleInk(); m_inks[WellKnownInks::Jumble] = new JumbleInk();

View File

@ -52,6 +52,7 @@ namespace app {
extern const char* Zoom; extern const char* Zoom;
extern const char* Scroll; extern const char* Scroll;
extern const char* Move; extern const char* Move;
extern const char* Slice;
extern const char* Blur; extern const char* Blur;
extern const char* Jumble; extern const char* Jumble;
}; };

View File

@ -269,7 +269,8 @@ void Editor::editor_draw_cursor(int x, int y, bool refresh)
color_t brush_color = get_brush_color(m_sprite, m_layer); color_t brush_color = get_brush_color(m_sprite, m_layer);
color_t mask_color = m_sprite->getTransparentColor(); color_t mask_color = m_sprite->getTransparentColor();
if (current_tool->getInk(0)->isSelection()) { if (current_tool->getInk(0)->isSelection() ||
current_tool->getInk(0)->isSlice()) {
cursor_type = CURSOR_CROSS_ONE; cursor_type = CURSOR_CROSS_ONE;
} }
else if ( else if (

View File

@ -443,6 +443,11 @@ bool StandbyState::onSetCursor(Editor* editor)
jmouse_set_cursor(kMoveCursor); jmouse_set_cursor(kMoveCursor);
return true; return true;
} }
else if (current_ink->isSlice()) {
jmouse_set_cursor(kNoCursor);
editor->showDrawingCursor();
return true;
}
} }
// Draw // Draw

View File

@ -117,6 +117,7 @@ public:
((getInk()->isSelection() || ((getInk()->isSelection() ||
getInk()->isEyedropper() || getInk()->isEyedropper() ||
getInk()->isScrollMovement() || getInk()->isScrollMovement() ||
getInk()->isSlice() ||
getInk()->isZoom()) ? undo::DoesntModifyDocument: getInk()->isZoom()) ? undo::DoesntModifyDocument:
undo::ModifyDocument)) undo::ModifyDocument))
, m_expandCelCanvas(m_context, m_docSettings->getTiledMode(), m_undoTransaction) , m_expandCelCanvas(m_context, m_docSettings->getTiledMode(), m_undoTransaction)