Add Move Slice tool

This commit is contained in:
David Capello 2017-03-16 12:08:56 -03:00
parent 347ccfbb78
commit f01e5ad5f3
10 changed files with 911 additions and 918 deletions

View File

@ -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

View File

@ -1,13 +1,13 @@
<?xml version="1.0" encoding="utf-8" ?>
<theme name="Default"
author="Ilija Melentijevic &amp; David Capello"
url="http://ilkke.blogspot.com/">
<theme name="Default">
<authors>
<author name="David Capello" url="http://davidcapello.com/" />
<author name="Ilija Melentijevic" url="http://ilkke.blogspot.com/" />
</authors>
<fonts>
<font id="default" font="Aseprite" />
<font id="mini" font="Aseprite Mini" />
</fonts>
<dimensions>
<dim id="scrollbar_size" value="12" />
<dim id="mini_scrollbar_size" value="6" />
@ -25,7 +25,6 @@
<dim id="color_slider_height" value="14" />
<dim id="timeline_base_size" value="12" />
</dimensions>
<colors>
<color id="text" value="#000000" />
<color id="disabled" value="#968275" />
@ -103,7 +102,6 @@
<color id="select_box_ruler" value="#0000ff" />
<color id="select_box_grid" value="#64c864" />
</colors>
<parts>
<part id="cursor_normal" x="80" y="0" w="16" h="16" focusx="0" focusy="0" />
<part id="cursor_normal_add" x="80" y="16" w="16" h="16" focusx="0" focusy="0" />
@ -390,28 +388,23 @@
<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" />
</parts>
<styles>
<style id="box" />
<style id="grid" />
<style id="window_without_title" border="3">
<background color="window_face" />
<border part="menu" />
</style>
<style id="window_with_title" border="6" border-top="17">
<background color="window_face" />
<border part="window" />
</style>
<style id="window_title_label" margin-top="5" margin-left="5">
<background color="window_titlebar_face" />
<text color="window_titlebar_text" align="left middle" />
</style>
<style id="window_close_button" margin-top="3" margin-right="3">
<background part="window_button_normal" align="center middle" />
<background part="window_button_hot" state="mouse" align="center middle" />
@ -420,69 +413,50 @@
<icon part="window_close_icon" color="button_hot_text" state="mouse" />
<icon part="window_close_icon" color="button_selected_text" state="selected" />
</style>
<style id="popup_window">
<background color="window_face" />
<border part="menu" />
</style>
<style id="transparent_popup_window">
<!-- nothing (transparent) -->
</style>
<style id="menu">
<background color="window_face" />
</style>
<style id="menubox" extends="menu">
</style>
<style id="menubar" extends="menubox">
</style>
<style id="menubox" extends="menu" />
<style id="menubar" extends="menubox" />
<style id="desktop">
<background color="window_face" />
</style>
<style id="tooltip_window">
<background part="tooltip" />
</style>
<style id="tooltip_window_arrow">
<background part="tooltip_arrow" />
</style>
<style id="tooltip_face">
<background color="tooltip_face" />
</style>
<style id="tooltip_text">
<background color="tooltip_face" />
<text color="tooltip_text" align="left" />
</style>
<style id="label" padding="1">
<text color="text" align="left" />
<text color="disabled" align="left" state="disabled" />
</style>
<style id="link">
<text color="link_text" align="left" />
<text color="link_hover" align="left" state="mouse" />
</style>
<style id="browser_link" extends="link" padding-top="1">
</style>
<style id="browser_link" extends="link" padding-top="1" />
<style id="workspace_label">
<text color="workspace_text" align="left" />
</style>
<style id="workspace_link">
<text color="workspace_link" align="left" />
<text color="workspace_link_hover" align="left" state="mouse" />
</style>
<style id="workspace_update_link" padding-right="16">
<background part="button_normal" />
<background part="button_hot" state="mouse" />
@ -492,29 +466,24 @@
<text color="button_hot_text" state="mouse" />
<text color="button_selected_text" state="selected" />
</style>
<style id="view" border="3" border-top="4">
<background color="window_face" />
<border part="sunken_normal" />
<border part="sunken_focused" state="focus" />
</style>
<style id="editor_view">
<background color="editor_view_face" />
<border part="editor_normal" />
<border part="editor_selected" state="selected" />
</style>
<style id="workspace_view" border-top="4" extends="view">
<border part="editor_normal" />
<border part="editor_selected" state="focus" />
</style>
<style id="colorbar_view">
<border part="editor_normal" />
<border part="editor_selected" state="focus" />
</style>
<style id="button">
<background part="button_normal" />
<background part="button_hot" state="mouse" />
@ -524,7 +493,6 @@
<text color="button_hot_text" state="mouse" />
<text color="button_selected_text" state="selected" />
</style>
<style id="mini_button">
<background part="toolbutton_last" />
<background part="toolbutton_hot" state="mouse" />
@ -534,20 +502,17 @@
<text color="button_hot_text" state="mouse" />
<text color="button_selected_text" state="selected" />
</style>
<style id="combobox_button" extends="mini_button">
<icon part="combobox_arrow_down" />
<icon part="combobox_arrow_down_selected" state="selected" />
<icon part="combobox_arrow_down_disabled" state="disabled" />
</style>
<style id="drop_down_button" extends="button">
<background part="drop_down_button_left_normal" />
<background part="drop_down_button_left_selected" state="selected" />
<background part="drop_down_button_left_hot" state="mouse" />
<background part="drop_down_button_left_focused" state="focus" />
</style>
<style id="drop_down_expand_button" extends="button">
<background part="drop_down_button_right_normal" />
<background part="drop_down_button_right_selected" state="selected" />
@ -557,79 +522,51 @@
<icon part="combobox_arrow_down_selected" state="selected" />
<icon part="combobox_arrow_down_disabled" state="disabled" />
</style>
<style id="go_back_button" extends="mini_button">
<icon part="combobox_arrow_left" />
<icon part="combobox_arrow_left_selected" state="selected" />
<icon part="combobox_arrow_left_disabled" state="disabled" />
</style>
<style id="go_forward_button" extends="mini_button">
<icon part="combobox_arrow_right" />
<icon part="combobox_arrow_right_selected" state="selected" />
<icon part="combobox_arrow_right_disabled" state="disabled" />
</style>
<style id="go_up_button" extends="mini_button">
<icon part="combobox_arrow_up" />
<icon part="combobox_arrow_up_selected" state="selected" />
<icon part="combobox_arrow_up_disabled" state="disabled" />
</style>
<style id="new_folder_button" extends="mini_button">
<icon part="newfolder" />
<icon part="newfolder_selected" state="selected" />
</style>
<style id="color_wheel_options" border="1">
<background color="editor_face" />
<background color="check_hot_face" state="mouse" />
<background color="check_hot_face" state="selected" />
<icon part="pal_options" />
</style>
<style id="recover_sprites_button" extends="button"
border="0" padding="8">
</style>
<style id="new_frame_button" extends="mini_button">
</style>
<style id="color_button" extends="mini_button" border="5" font="mini">
</style>
<style id="recover_sprites_button" extends="button" border="0" padding="8" />
<style id="new_frame_button" extends="mini_button" />
<style id="color_button" extends="mini_button" border="5" font="mini" />
<style id="splitter">
<background color="face" />
</style>
<style id="workspace_splitter">
<background color="workspace" />
</style>
<style id="horizontal_separator"
border-left="2"
border-top="4"
border-right="2"
border-bottom="0">
<style id="horizontal_separator" border-left="2" border-top="4" border-right="2" border-bottom="0">
<background part="separator_horz" color="window_face" align="middle" />
<text color="separator_label" x="4" align="left middle" />
</style>
<style id="menu_separator" extends="horizontal_separator">
</style>
<style id="menu_separator" extends="horizontal_separator" />
<style id="separator_in_view" extends="horizontal_separator">
<background part="separator_horz" color="background" align="middle" />
</style>
<style id="vertical_separator"
border-left="4"
border-top="2"
border-right="1"
border-bottom="2">
<style id="vertical_separator" border-left="4" border-top="2" border-right="1" border-bottom="2">
<background part="separator_vert" align="center" />
</style>
<style id="recent_item" />
<style id="recent_file" border="2">
<background color="background" />
@ -641,7 +578,6 @@
<style id="recent_file_detail" border="2" border-left="0" extends="recent_file">
<text color="disabled" align="left" x="2" />
</style>
<style id="news_item" border="2">
<background color="background" />
<background color="menuitem_hot_face" state="mouse" />
@ -653,7 +589,6 @@
<text color="disabled" align="left top wordwrap" x="2" />
<text color="listitem_selected_text" align="left top wordwrap" x="2" state="selected" />
</style>
<style id="scrollbar">
<background part="scrollbar_bg" />
</style>
@ -676,7 +611,6 @@
<background part="transparent_scrollbar_thumb" />
<background part="transparent_scrollbar_thumb_hot" state="mouse" />
</style>
<style id="main_tabs">
<background color="window_face" />
</style>
@ -718,19 +652,16 @@
<icon part="tab_home_icon_normal" align="left middle" x="4" y="1" />
<icon part="tab_home_icon_active" align="left middle" x="4" y="1" state="focus" />
</style>
<style id="flag">
<background part="flag_normal" color="flag_normal" />
<background part="flag_highlight" color="flag_active" state="focus" />
<background part="flag_highlight" color="flag_clicked" state="selected" />
</style>
<style id="warning_box" padding-left="2" padding-right="2">
<background color="workspace" />
<background color="hot_face" state="mouse" />
<icon part="warning_box" align="center middle" />
</style>
<style id="timeline">
<background color="timeline_normal" part="timeline_normal" />
</style>
@ -876,16 +807,12 @@
<style id="timeline_loop_range">
<background part="timeline_loop_range" />
</style>
<style id="shade_selection">
<background part="colorbar_selection_hot" />
</style>
<style id="colorbar_selection">
<background part="colorbar_selection" />
<background part="colorbar_selection_hot" state="mouse" />
</style>
</styles>
</theme>

View File

@ -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

View File

@ -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 };

View File

@ -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();

View File

@ -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;
};

View File

@ -1699,7 +1699,16 @@ EditorHit Editor::calcHit(const gfx::Point& mouseScreenPos)
gfx::Rect bounds = editorToScreen(key->bounds());
gfx::Rect center = key->center();
if (bounds.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) |

View File

@ -69,6 +69,12 @@ bool MovingSliceState::onMouseMove(Editor* editor, MouseMessage* msg)
(m_hit.type() == EditorHit::SliceCenter ? m_key.center():
m_key.bounds());
// Move slice
if (m_hit.border() == (CENTER | MIDDLE)) {
rc.x += delta.x;
rc.y += delta.y;
}
else {
if (m_hit.border() & LEFT) {
rc.x += delta.x;
rc.w -= delta.x;
@ -95,6 +101,7 @@ bool MovingSliceState::onMouseMove(Editor* editor, MouseMessage* msg)
if (rc.h < 1)
rc.h = 1;
}
}
if (m_hit.type() == EditorHit::SliceCenter)
m_key.setCenter(rc);

View File

@ -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;