David Capello 2018-10-26 14:04:08 -03:00
parent b27c685d70
commit 3a77321597
14 changed files with 82 additions and 27 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 14 KiB

After

Width:  |  Height:  |  Size: 14 KiB

View File

@ -244,6 +244,7 @@
<part id="selection_replace" x="176" y="160" w="7" h="7" /> <part id="selection_replace" x="176" y="160" w="7" h="7" />
<part id="selection_add" x="184" y="160" w="7" h="7" /> <part id="selection_add" x="184" y="160" w="7" h="7" />
<part id="selection_subtract" x="192" y="160" w="7" h="7" /> <part id="selection_subtract" x="192" y="160" w="7" h="7" />
<part id="selection_intersect" x="200" y="160" w="7" h="7" />
<part id="unpinned" x="192" y="144" w="8" h="8" /> <part id="unpinned" x="192" y="144" w="8" h="8" />
<part id="pinned" x="200" y="144" w="8" h="8" /> <part id="pinned" x="200" y="144" w="8" h="8" />
<part id="drop_down_button_left_normal" x="48" y="32" w1="3" w2="2" w3="3" h1="4" h2="6" h3="6" /> <part id="drop_down_button_left_normal" x="48" y="32" w1="3" w2="2" w3="3" h1="4" h2="6" h3="6" />

View File

@ -1,6 +1,7 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<!-- Aseprite --> <!-- Aseprite -->
<!-- Copyright (C) 2001-2018 by David Capello --> <!-- Copyright (C) 2018 Igara Studio S.A. -->
<!-- Copyright (C) 2001-2018 David Capello -->
<gui version="1.3-dev"> <gui version="1.3-dev">
<!-- Keyboard shortcuts --> <!-- Keyboard shortcuts -->
<keyboard version="1"> <keyboard version="1">
@ -449,6 +450,9 @@
<key command="SelectTile"> <key command="SelectTile">
<param name="mode" value="subtract" /> <param name="mode" value="subtract" />
</key> </key>
<key command="SelectTile">
<param name="mode" value="intersect" />
</key>
<key command="ChangePixelFormat"> <key command="ChangePixelFormat">
<param name="format" value="rgb" /> <param name="format" value="rgb" />
</key> </key>
@ -543,7 +547,8 @@
<!-- Modifiers for selection tool --> <!-- Modifiers for selection tool -->
<key action="AddSelection" shortcut="Shift" /> <key action="AddSelection" shortcut="Shift" />
<key action="SubtractSelection" shortcut="Shift+Alt" /> <key action="SubtractSelection" shortcut="Alt+Shift" />
<key action="IntersectSelection" shortcut="Ctrl+Shift" />
<!-- Modifiers for move tool --> <!-- Modifiers for move tool -->
<key action="AutoSelectLayer" shortcut="Ctrl" mac="Cmd" /> <key action="AutoSelectLayer" shortcut="Ctrl" mac="Cmd" />

View File

@ -68,6 +68,7 @@
<value id="DEFAULT" value="0" /> <value id="DEFAULT" value="0" />
<value id="ADD" value="1" /> <value id="ADD" value="1" />
<value id="SUBTRACT" value="2" /> <value id="SUBTRACT" value="2" />
<value id="INTERSECT" value="3" />
</enum> </enum>
<enum id="PivotPosition"> <enum id="PivotPosition">
<value id="NORTHWEST" value="0" /> <value id="NORTHWEST" value="0" />

View File

@ -380,6 +380,7 @@ ScrollCenter = Scroll to center of canvas
SelectTile = Select Tile SelectTile = Select Tile
SelectTile_Add = Select Tile (Add) SelectTile_Add = Select Tile (Add)
SelectTile_Subtract = Select Tile (Subtract) SelectTile_Subtract = Select Tile (Subtract)
SelectTile_Intersect = Select Tile (Intersect)
SelectionAsGrid = Selection as Grid SelectionAsGrid = Selection as Grid
SetColorSelector = Set Color Selector SetColorSelector = Set Color Selector
SetColorSelector_Spectrum = Color Spectrum SetColorSelector_Spectrum = Color Spectrum

View File

@ -1,4 +1,5 @@
// Aseprite // Aseprite
// Copyright (C) 2018 Igara Studio S.A.
// Copyright (C) 2015-2018 David Capello // Copyright (C) 2015-2018 David Capello
// //
// This program is distributed under the terms of // This program is distributed under the terms of
@ -55,6 +56,8 @@ void SelectTileCommand::onLoadParams(const Params& params)
m_mode = gen::SelectionMode::ADD; m_mode = gen::SelectionMode::ADD;
else if (mode == "subtract") else if (mode == "subtract")
m_mode = gen::SelectionMode::SUBTRACT; m_mode = gen::SelectionMode::SUBTRACT;
else if (mode == "intersect")
m_mode = gen::SelectionMode::INTERSECT;
else else
m_mode = gen::SelectionMode::DEFAULT; m_mode = gen::SelectionMode::DEFAULT;
} }
@ -86,10 +89,18 @@ void SelectTileCommand::onExecute(Context* ctx)
pos = snap_to_grid(gridBounds, pos, PreferSnapTo::BoxOrigin); pos = snap_to_grid(gridBounds, pos, PreferSnapTo::BoxOrigin);
gridBounds.setOrigin(pos); gridBounds.setOrigin(pos);
if (m_mode != gen::SelectionMode::SUBTRACT) switch (m_mode) {
case gen::SelectionMode::DEFAULT:
case gen::SelectionMode::ADD:
mask->add(gridBounds); mask->add(gridBounds);
else break;
case gen::SelectionMode::SUBTRACT:
mask->subtract(gridBounds); mask->subtract(gridBounds);
break;
case gen::SelectionMode::INTERSECT:
mask->intersect(gridBounds);
break;
}
} }
// Set the new mask // Set the new mask
@ -113,8 +124,11 @@ std::string SelectTileCommand::onGetFriendlyName() const
case gen::SelectionMode::SUBTRACT: case gen::SelectionMode::SUBTRACT:
text = Strings::commands_SelectTile_Subtract(); text = Strings::commands_SelectTile_Subtract();
break; break;
case gen::SelectionMode::INTERSECT:
text = Strings::commands_SelectTile_Intersect();
break;
default: default:
text = getBaseFriendlyName();; text = getBaseFriendlyName();
break; break;
} }
return text; return text;

View File

@ -362,6 +362,7 @@ public:
class SelectionInk : public BaseInk { class SelectionInk : public BaseInk {
bool m_modify_selection; bool m_modify_selection;
Mask m_mask; Mask m_mask;
Mask m_intersectMask;
Rect m_maxBounds; Rect m_maxBounds;
public: public:
@ -390,6 +391,9 @@ public:
else if ((modifiers & int(ToolLoopModifiers::kSubtractSelection)) != 0) { else if ((modifiers & int(ToolLoopModifiers::kSubtractSelection)) != 0) {
m_mask.subtract(gfx::Rect(x1, y, x2-x1+1, 1)); m_mask.subtract(gfx::Rect(x1, y, x2-x1+1, 1));
} }
else if ((modifiers & int(ToolLoopModifiers::kIntersectSelection)) != 0) {
m_intersectMask.add(gfx::Rect(x1, y, x2-x1+1, 1));
}
m_maxBounds |= gfx::Rect(x1, y, x2-x1+1, 1); m_maxBounds |= gfx::Rect(x1, y, x2-x1+1, 1);
} }
@ -409,6 +413,11 @@ public:
m_mask.reserve(loop->sprite()->bounds()); m_mask.reserve(loop->sprite()->bounds());
} }
else { else {
int modifiers = int(loop->getModifiers());
if ((modifiers & int(ToolLoopModifiers::kIntersectSelection)) != 0) {
m_mask.intersect(m_intersectMask);
}
// We can intersect the used bounds in inkHline() calls to // We can intersect the used bounds in inkHline() calls to
// reduce the shrink computation. // reduce the shrink computation.
m_mask.intersect(m_maxBounds); m_mask.intersect(m_maxBounds);

View File

@ -1,4 +1,5 @@
// Aseprite // Aseprite
// Copyright (C) 2018 Igara Studio S.A.
// Copyright (C) 2016-2018 David Capello // Copyright (C) 2016-2018 David Capello
// //
// This program is distributed under the terms of // This program is distributed under the terms of
@ -16,10 +17,11 @@ namespace tools {
kReplaceSelection = 0x00000001, kReplaceSelection = 0x00000001,
kAddSelection = 0x00000002, kAddSelection = 0x00000002,
kSubtractSelection = 0x00000004, kSubtractSelection = 0x00000004,
kMoveOrigin = 0x00000008, kIntersectSelection = 0x00000008,
kSquareAspect = 0x00000010, kMoveOrigin = 0x00000010,
kFromCenter = 0x00000020, kSquareAspect = 0x00000020,
kRotateShape = 0x00000040, kFromCenter = 0x00000040,
kRotateShape = 0x00000080,
}; };
} // namespace tools } // namespace tools

View File

@ -1,4 +1,5 @@
// Aseprite // Aseprite
// Copyright (C) 2018 Igara Studio S.A.
// Copyright (C) 2001-2018 David Capello // Copyright (C) 2001-2018 David Capello
// //
// This program is distributed under the terms of // This program is distributed under the terms of
@ -926,12 +927,13 @@ protected:
class ContextBar::SelectionModeField : public ButtonSet { class ContextBar::SelectionModeField : public ButtonSet {
public: public:
SelectionModeField() : ButtonSet(3) { SelectionModeField() : ButtonSet(4) {
SkinTheme* theme = static_cast<SkinTheme*>(this->theme()); SkinTheme* theme = static_cast<SkinTheme*>(this->theme());
addItem(theme->parts.selectionReplace()); addItem(theme->parts.selectionReplace());
addItem(theme->parts.selectionAdd()); addItem(theme->parts.selectionAdd());
addItem(theme->parts.selectionSubtract()); addItem(theme->parts.selectionSubtract());
addItem(theme->parts.selectionIntersect());
setSelectedItem((int)Preferences::instance().selection.mode()); setSelectedItem((int)Preferences::instance().selection.mode());
} }
@ -945,6 +947,9 @@ public:
tooltipManager->addTooltipFor( tooltipManager->addTooltipFor(
at(2), key_tooltip("Subtract from selection", KeyAction::SubtractSelection), BOTTOM); at(2), key_tooltip("Subtract from selection", KeyAction::SubtractSelection), BOTTOM);
tooltipManager->addTooltipFor(
at(3), key_tooltip("Intersect selection", KeyAction::IntersectSelection), BOTTOM);
} }
void setSelectionMode(gen::SelectionMode mode) { void setSelectionMode(gen::SelectionMode mode) {
@ -1510,6 +1515,8 @@ void ContextBar::updateToolLoopModifiersIndicators(tools::ToolLoopModifiers modi
mode = gen::SelectionMode::ADD; mode = gen::SelectionMode::ADD;
else if (int(modifiers) & int(tools::ToolLoopModifiers::kSubtractSelection)) else if (int(modifiers) & int(tools::ToolLoopModifiers::kSubtractSelection))
mode = gen::SelectionMode::SUBTRACT; mode = gen::SelectionMode::SUBTRACT;
else if (int(modifiers) & int(tools::ToolLoopModifiers::kIntersectSelection))
mode = gen::SelectionMode::INTERSECT;
m_selectionMode->setSelectionMode(mode); m_selectionMode->setSelectionMode(mode);
} }

View File

@ -1,4 +1,5 @@
// Aseprite // Aseprite
// Copyright (C) 2018 Igara Studio S.A.
// Copyright (C) 2001-2018 David Capello // Copyright (C) 2001-2018 David Capello
// //
// This program is distributed under the terms of // This program is distributed under the terms of
@ -153,7 +154,8 @@ bool DrawingState::onMouseUp(Editor* editor, MouseMessage* msg)
if (!m_toolLoop->getInk()->isSelection() || if (!m_toolLoop->getInk()->isSelection() ||
m_toolLoop->getController()->isOnePoint() || m_toolLoop->getController()->isOnePoint() ||
m_mouseMoveReceived || m_mouseMoveReceived ||
editor->getToolLoopModifiers() != tools::ToolLoopModifiers::kReplaceSelection) { (editor->getToolLoopModifiers() != tools::ToolLoopModifiers::kReplaceSelection &&
editor->getToolLoopModifiers() != tools::ToolLoopModifiers::kIntersectSelection)) {
// Notify the release of the mouse button to the tool loop // Notify the release of the mouse button to the tool loop
// manager. This is the correct way to say "the user finishes the // manager. This is the correct way to say "the user finishes the
// drawing trace correctly". // drawing trace correctly".

View File

@ -1496,7 +1496,8 @@ void Editor::updateToolLoopModifiersIndicators()
modifiers |= (int(m_toolLoopModifiers) & modifiers |= (int(m_toolLoopModifiers) &
(int(tools::ToolLoopModifiers::kReplaceSelection) | (int(tools::ToolLoopModifiers::kReplaceSelection) |
int(tools::ToolLoopModifiers::kAddSelection) | int(tools::ToolLoopModifiers::kAddSelection) |
int(tools::ToolLoopModifiers::kSubtractSelection))); int(tools::ToolLoopModifiers::kSubtractSelection) |
int(tools::ToolLoopModifiers::kIntersectSelection)));
tools::Controller* controller = tools::Controller* controller =
(App::instance()->activeToolManager()->selectedTool() ? (App::instance()->activeToolManager()->selectedTool() ?
@ -1535,6 +1536,9 @@ void Editor::updateToolLoopModifiersIndicators()
App::instance()->activeToolManager()->selectedTool()->getInk(0)->isSelection())) { App::instance()->activeToolManager()->selectedTool()->getInk(0)->isSelection())) {
mode = gen::SelectionMode::SUBTRACT; mode = gen::SelectionMode::SUBTRACT;
} }
else if (int(action & KeyAction::IntersectSelection)) {
mode = gen::SelectionMode::INTERSECT;
}
else if (int(action & KeyAction::AddSelection)) { else if (int(action & KeyAction::AddSelection)) {
mode = gen::SelectionMode::ADD; mode = gen::SelectionMode::ADD;
} }
@ -1542,6 +1546,7 @@ void Editor::updateToolLoopModifiersIndicators()
case gen::SelectionMode::DEFAULT: modifiers |= int(tools::ToolLoopModifiers::kReplaceSelection); break; case gen::SelectionMode::DEFAULT: modifiers |= int(tools::ToolLoopModifiers::kReplaceSelection); break;
case gen::SelectionMode::ADD: modifiers |= int(tools::ToolLoopModifiers::kAddSelection); break; case gen::SelectionMode::ADD: modifiers |= int(tools::ToolLoopModifiers::kAddSelection); break;
case gen::SelectionMode::SUBTRACT: modifiers |= int(tools::ToolLoopModifiers::kSubtractSelection); break; case gen::SelectionMode::SUBTRACT: modifiers |= int(tools::ToolLoopModifiers::kSubtractSelection); break;
case gen::SelectionMode::INTERSECT: modifiers |= int(tools::ToolLoopModifiers::kIntersectSelection); break;
} }
// For move tool // For move tool

View File

@ -1,4 +1,5 @@
// Aseprite // Aseprite
// Copyright (C) 2018 Igara Studio S.A.
// Copyright (C) 2001-2018 David Capello // Copyright (C) 2001-2018 David Capello
// //
// This program is distributed under the terms of // This program is distributed under the terms of
@ -386,6 +387,8 @@ bool StandbyState::onDoubleClick(Editor* editor, MouseMessage* msg)
params.set("mode", "add"); params.set("mode", "add");
else if (int(editor->getToolLoopModifiers()) & int(tools::ToolLoopModifiers::kSubtractSelection)) else if (int(editor->getToolLoopModifiers()) & int(tools::ToolLoopModifiers::kSubtractSelection))
params.set("mode", "subtract"); params.set("mode", "subtract");
else if (int(editor->getToolLoopModifiers()) & int(tools::ToolLoopModifiers::kIntersectSelection))
params.set("mode", "intersect");
UIContext::instance()->executeCommand(selectTileCmd, params); UIContext::instance()->executeCommand(selectTileCmd, params);
return true; return true;

View File

@ -1,4 +1,5 @@
// Aseprite // Aseprite
// Copyright (C) 2018 Igara Studio S.A.
// Copyright (C) 2001-2018 David Capello // Copyright (C) 2001-2018 David Capello
// //
// This program is distributed under the terms of // This program is distributed under the terms of
@ -51,16 +52,17 @@ namespace app {
LockAxis = 0x00000010, LockAxis = 0x00000010,
AddSelection = 0x00000020, AddSelection = 0x00000020,
SubtractSelection = 0x00000040, SubtractSelection = 0x00000040,
AutoSelectLayer = 0x00000080, IntersectSelection = 0x00000080,
LeftMouseButton = 0x00000100, AutoSelectLayer = 0x00000100,
RightMouseButton = 0x00000200, LeftMouseButton = 0x00000200,
StraightLineFromLastPoint = 0x00000400, RightMouseButton = 0x00000400,
MoveOrigin = 0x00000800, StraightLineFromLastPoint = 0x00000800,
SquareAspect = 0x00001000, MoveOrigin = 0x00001000,
DrawFromCenter = 0x00002000, SquareAspect = 0x00002000,
ScaleFromCenter = 0x00004000, DrawFromCenter = 0x00004000,
AngleSnapFromLastPoint = 0x00008000, ScaleFromCenter = 0x00008000,
RotateShape = 0x00010000, AngleSnapFromLastPoint = 0x00010000,
RotateShape = 0x00020000,
}; };
enum class WheelAction { enum class WheelAction {

View File

@ -1,4 +1,5 @@
// Aseprite // Aseprite
// Copyright (C) 2018 Igara Studio S.A.
// Copyright (C) 2001-2018 David Capello // Copyright (C) 2001-2018 David Capello
// //
// This program is distributed under the terms of // This program is distributed under the terms of
@ -47,6 +48,7 @@ namespace {
{ "LockAxis" , "Lock Axis" , app::KeyAction::LockAxis }, { "LockAxis" , "Lock Axis" , app::KeyAction::LockAxis },
{ "AddSelection" , "Add Selection" , app::KeyAction::AddSelection }, { "AddSelection" , "Add Selection" , app::KeyAction::AddSelection },
{ "SubtractSelection" , "Subtract Selection" , app::KeyAction::SubtractSelection }, { "SubtractSelection" , "Subtract Selection" , app::KeyAction::SubtractSelection },
{ "IntersectSelection" , "Intersect Selection" , app::KeyAction::IntersectSelection },
{ "AutoSelectLayer" , "Auto Select Layer" , app::KeyAction::AutoSelectLayer }, { "AutoSelectLayer" , "Auto Select Layer" , app::KeyAction::AutoSelectLayer },
{ "StraightLineFromLastPoint", "Straight Line from Last Point", app::KeyAction::StraightLineFromLastPoint }, { "StraightLineFromLastPoint", "Straight Line from Last Point", app::KeyAction::StraightLineFromLastPoint },
{ "AngleSnapFromLastPoint", "Angle Snap from Last Point", app::KeyAction::AngleSnapFromLastPoint }, { "AngleSnapFromLastPoint", "Angle Snap from Last Point", app::KeyAction::AngleSnapFromLastPoint },
@ -209,6 +211,7 @@ Key::Key(KeyAction action)
break; break;
case KeyAction::AddSelection: case KeyAction::AddSelection:
case KeyAction::SubtractSelection: case KeyAction::SubtractSelection:
case KeyAction::IntersectSelection:
m_keycontext = KeyContext::SelectionTool; m_keycontext = KeyContext::SelectionTool;
break; break;
case KeyAction::AutoSelectLayer: case KeyAction::AutoSelectLayer: