Add "Select Layer & Move" right click option

This commit is contained in:
David Capello 2018-10-26 10:01:25 -03:00
parent 254a866b9f
commit 88acf951cc
9 changed files with 42 additions and 4 deletions

View File

@ -13,6 +13,7 @@
<value id="SCROLL" value="3" />
<value id="RECTANGULAR_MARQUEE" value="4" />
<value id="LASSO" value="5" />
<value id="SELECT_LAYER_AND_MOVE" value="6" />
</enum>
<enum id="OnionskinType">
<value id="MERGE" value="0" />

View File

@ -347,6 +347,7 @@ public:
static_assert(int(app::gen::RightClickMode::SCROLL) == 3, "");
static_assert(int(app::gen::RightClickMode::RECTANGULAR_MARQUEE) == 4, "");
static_assert(int(app::gen::RightClickMode::LASSO) == 5, "");
static_assert(int(app::gen::RightClickMode::SELECT_LAYER_AND_MOVE) == 6, "");
rightClickBehavior()->addItem("Paint with background color");
rightClickBehavior()->addItem("Pick foreground color");
@ -354,6 +355,7 @@ public:
rightClickBehavior()->addItem("Scroll");
rightClickBehavior()->addItem("Rectangular Marquee");
rightClickBehavior()->addItem("Lasso");
rightClickBehavior()->addItem("Select Layer & Move");
rightClickBehavior()->setSelectedItemIndex((int)m_pref.editor.rightClickMode());
#ifndef __APPLE__ // Zoom sliding two fingers option only on macOS

View File

@ -1,4 +1,5 @@
// Aseprite
// Copyright (C) 2018 Igara Studio S.A.
// Copyright (C) 2016 David Capello
//
// This program is distributed under the terms of
@ -185,6 +186,10 @@ void ActiveToolManager::pressButton(const Pointer& pointer)
tool = m_toolbox->getToolById(WellKnownTools::Lasso);
ink = m_toolbox->getInkById(tools::WellKnownInks::Selection);
break;
case app::gen::RightClickMode::SELECT_LAYER_AND_MOVE:
tool = m_toolbox->getToolById(WellKnownTools::Move);
ink = m_toolbox->getInkById(tools::WellKnownInks::SelectLayerAndMove);
break;
}
}
}

View File

@ -1,4 +1,5 @@
// Aseprite
// Copyright (C) 2018 Igara Studio S.A.
// Copyright (C) 2001-2017 David Capello
//
// This program is distributed under the terms of
@ -61,6 +62,9 @@ namespace app {
// Returns true if this ink moves cels
virtual bool isCelMovement() const { return false; }
// Returns true if this ink selects layers automatically
virtual bool isAutoSelectLayer() const { return false; }
// Returns true if this ink is used to mark slices
virtual bool isSlice() const { return false; }

View File

@ -1,4 +1,5 @@
// Aseprite
// Copyright (C) 2018 Igara Studio S.A.
// Copyright (C) 2001-2018 David Capello
//
// This program is distributed under the terms of
@ -189,9 +190,23 @@ public:
class MoveInk : public Ink {
bool m_autoSelect;
public:
MoveInk(bool autoSelect) : m_autoSelect(autoSelect) { }
Ink* clone() override { return new MoveInk(*this); }
bool isCelMovement() const override { return true; }
bool isAutoSelectLayer() const override { return m_autoSelect; }
void prepareInk(ToolLoop* loop) override { }
void inkHline(int x1, int y, int x2, ToolLoop* loop) override { }
};
class SelectLayerInk : public Ink {
public:
Ink* clone() override { return new SelectLayerInk(*this); }
bool isCelMovement() const override { return true; }
void prepareInk(ToolLoop* loop) override { }
void inkHline(int x1, int y, int x2, ToolLoop* loop) override { }

View File

@ -1,4 +1,5 @@
// Aseprite
// Copyright (C) 2018 Igara Studio S.A.
// Copyright (C) 2001-2018 David Capello
//
// This program is distributed under the terms of
@ -49,6 +50,7 @@ const char* WellKnownTools::Pencil = "pencil";
const char* WellKnownTools::Eraser = "eraser";
const char* WellKnownTools::Eyedropper = "eyedropper";
const char* WellKnownTools::Hand = "hand";
const char* WellKnownTools::Move = "move";
const char* WellKnownInks::Selection = "selection";
const char* WellKnownInks::Paint = "paint";
@ -66,6 +68,7 @@ const char* WellKnownInks::PickBg = "pick_bg";
const char* WellKnownInks::Zoom = "zoom";
const char* WellKnownInks::Scroll = "scroll";
const char* WellKnownInks::Move = "move";
const char* WellKnownInks::SelectLayerAndMove = "select_layer_and_move";
const char* WellKnownInks::Slice = "slice";
const char* WellKnownInks::MoveSlice = "move_slice";
const char* WellKnownInks::Blur = "blur";
@ -123,7 +126,8 @@ ToolBox::ToolBox()
m_inks[WellKnownInks::PickBg] = new PickInk(PickInk::Bg);
m_inks[WellKnownInks::Zoom] = new ZoomInk();
m_inks[WellKnownInks::Scroll] = new ScrollInk();
m_inks[WellKnownInks::Move] = new MoveInk();
m_inks[WellKnownInks::Move] = new MoveInk(false);
m_inks[WellKnownInks::SelectLayerAndMove] = new MoveInk(true);
m_inks[WellKnownInks::Slice] = new SliceInk();
m_inks[WellKnownInks::Blur] = new BlurInk();
m_inks[WellKnownInks::Jumble] = new JumbleInk();

View File

@ -1,4 +1,5 @@
// Aseprite
// Copyright (C) 2018 Igara Studio S.A.
// Copyright (C) 2001-2018 David Capello
//
// This program is distributed under the terms of
@ -27,6 +28,7 @@ namespace app {
extern const char* Eraser;
extern const char* Eyedropper;
extern const char* Hand;
extern const char* Move;
};
namespace WellKnownInks {
@ -46,6 +48,7 @@ namespace app {
extern const char* Zoom;
extern const char* Scroll;
extern const char* Move;
extern const char* SelectLayerAndMove;
extern const char* Slice;
extern const char* MoveSlice;
extern const char* Blur;

View File

@ -1311,9 +1311,13 @@ tools::Ink* Editor::getCurrentEditorInk()
return App::instance()->activeToolManager()->activeInk();
}
bool Editor::isAutoSelectLayer() const
bool Editor::isAutoSelectLayer()
{
return App::instance()->contextBar()->isAutoSelectLayer();
tools::Ink* ink = getCurrentEditorInk();
if (ink && ink->isAutoSelectLayer())
return true;
else
return App::instance()->contextBar()->isAutoSelectLayer();
}
gfx::Point Editor::screenToEditor(const gfx::Point& pt)

View File

@ -198,7 +198,7 @@ namespace app {
tools::Ink* getCurrentEditorInk();
tools::ToolLoopModifiers getToolLoopModifiers() const { return m_toolLoopModifiers; }
bool isAutoSelectLayer() const;
bool isAutoSelectLayer();
// Returns true if we are able to draw in the current doc/sprite/layer/cel.
bool canDraw();