Merge branch 'main' into beta

This commit is contained in:
David Capello 2021-04-16 14:13:05 -03:00
commit b90c56487d
14 changed files with 71 additions and 42 deletions

2
laf

@ -1 +1 @@
Subproject commit 316bc10a674fa20cf133e9295f8c1dcbfacf20ad
Subproject commit 9a93eeb4557a37232e5f062dfc9effa797ea2e2b

View File

@ -93,7 +93,7 @@ void FlipCommand::onExecute(Context* ctx)
auto range = site.range();
if (range.enabled()) {
cels = get_unlocked_unique_cels(site.sprite(), range);
cels = get_unique_cels_to_edit_pixels(site.sprite(), range);
}
else if (site.cel() &&
site.layer() &&

View File

@ -214,7 +214,7 @@ void RotateCommand::onExecute(Context* context)
auto range = App::instance()->timeline()->range();
if (range.enabled())
cels = get_unlocked_unique_cels(site.sprite(), range);
cels = get_unique_cels_to_edit_pixels(site.sprite(), range);
else if (site.cel() &&
site.layer() &&
site.layer()->canEditPixels()) {

View File

@ -274,10 +274,8 @@ void FilterManagerImpl::applyToTarget()
case CelsTarget::Selected: {
auto range = m_site.range();
if (range.enabled()) {
for (Cel* cel : get_unlocked_unique_cels(m_site.sprite(), range)) {
if (!cel->layer()->isReference())
cels.push_back(cel);
}
for (Cel* cel : get_unique_cels_to_edit_pixels(m_site.sprite(), range))
cels.push_back(cel);
}
else if (m_site.cel() &&
m_site.layer() &&

View File

@ -589,7 +589,7 @@ bool DocView::onClear(Context* ctx)
CelList cels;
if (site.range().enabled()) {
cels = get_unlocked_unique_cels(site.sprite(), site.range());
cels = get_unique_cels_to_edit_pixels(site.sprite(), site.range());
}
else if (site.cel()) {
cels.push_back(site.cel());

View File

@ -508,7 +508,11 @@ void BrushPreview::createNativeCursor()
if (cursorBounds.isEmpty()) {
ASSERT(!m_cursor);
m_editor->display()->nativeWindow()->setNativeMouseCursor(os::NativeCursor::Hidden);
if (!(m_type & NATIVE_CROSSHAIR)) {
// TODO should we use ui::set_mouse_cursor()?
ui::set_mouse_cursor_reset_info();
m_editor->display()->nativeWindow()->setNativeMouseCursor(os::NativeCursor::Hidden);
}
return;
}
@ -547,6 +551,8 @@ void BrushPreview::forEachLittleCrossPixel(
}
if (m_cursor) {
// TODO should we use ui::set_mouse_cursor()?
ui::set_mouse_cursor_reset_info();
m_editor->display()->nativeWindow()->setNativeMouseCursor(
m_cursor.get(),
m_cursorCenter,

View File

@ -1623,27 +1623,34 @@ void Editor::updateToolLoopModifiersIndicators(const bool firstFromMouseDown)
int(tools::ToolLoopModifiers::kSubtractSelection) |
int(tools::ToolLoopModifiers::kIntersectSelection)));
tools::Controller* controller =
(atm->selectedTool() ?
atm->selectedTool()->getController(0): nullptr);
tools::Tool* tool = atm->selectedTool();
tools::Controller* controller = (tool ? tool->getController(0): nullptr);
tools::Ink* ink = (tool ? tool->getInk(0): nullptr);
// Shape tools modifiers (line, curves, rectangles, etc.)
if (controller && controller->isTwoPoints()) {
action = m_customizationDelegate->getPressedKeyAction(KeyContext::ShapeTool);
if (int(action & KeyAction::MoveOrigin))
modifiers |= int(tools::ToolLoopModifiers::kMoveOrigin);
if (int(action & KeyAction::SquareAspect))
modifiers |= int(tools::ToolLoopModifiers::kSquareAspect);
if (int(action & KeyAction::DrawFromCenter))
modifiers |= int(tools::ToolLoopModifiers::kFromCenter);
// We prefer to activate the rotation only when the user press
// the Alt key again in the ToolLoop (and not before starting
// the loop). So Alt+Shift+selection tool will subtract the
// For two-points-selection-like tools (Rectangular/Elliptical
// Marquee) we prefer to activate the
// square-aspect/rotation/etc. only when the user presses the
// modifier key again in the ToolLoop (and not before starting
// the loop). So Alt+selection will add a selection, but
// willn't start the square-aspect until we press Alt key
// again, or Alt+Shift+selection tool will subtract the
// selection but will not start the rotation until we release
// and press the Alt key again.
if ((int(action & KeyAction::RotateShape)) && !firstFromMouseDown)
modifiers |= int(tools::ToolLoopModifiers::kRotateShape);
if (!firstFromMouseDown ||
!ink || !ink->isSelection()) {
if (int(action & KeyAction::MoveOrigin))
modifiers |= int(tools::ToolLoopModifiers::kMoveOrigin);
if (int(action & KeyAction::SquareAspect))
modifiers |= int(tools::ToolLoopModifiers::kSquareAspect);
if (int(action & KeyAction::DrawFromCenter))
modifiers |= int(tools::ToolLoopModifiers::kFromCenter);
if (int(action & KeyAction::RotateShape))
modifiers |= int(tools::ToolLoopModifiers::kRotateShape);
}
}
// Freehand modifiers
@ -2784,10 +2791,6 @@ void Editor::showMouseCursor(CursorType cursorType,
void Editor::showBrushPreview(const gfx::Point& screenPos)
{
if (Preferences::instance().cursor.paintingCursorType() !=
app::gen::PaintingCursorType::SIMPLE_CROSSHAIR)
ui::set_mouse_cursor(kNoCursor);
m_brushPreview.show(screenPos);
}

View File

@ -70,7 +70,7 @@ MovingCelCollect::MovingCelCollect(Editor* editor, Layer* layer)
}
// Record start positions of all cels in selected range
for (Cel* cel : get_unlocked_unique_cels(editor->sprite(), range2)) {
for (Cel* cel : get_unique_cels_to_move_cel(editor->sprite(), range2)) {
Layer* layer = cel->layer();
ASSERT(layer);

View File

@ -1286,8 +1286,8 @@ CelList PixelsMovement::getEditableCels()
CelList cels;
if (editMultipleCels()) {
cels = get_unlocked_unique_cels(
m_site.sprite(), m_site.range());
cels = get_unique_cels_to_edit_pixels(m_site.sprite(),
m_site.range());
}
else {
// TODO This case is used in paste too, where the cel() can be

View File

@ -361,7 +361,7 @@ void Clipboard::cut(ContextWriter& writer)
Site site = writer.context()->activeSite();
CelList cels;
if (site.range().enabled()) {
cels = get_unlocked_unique_cels(site.sprite(), site.range());
cels = get_unique_cels_to_edit_pixels(site.sprite(), site.range());
}
else if (site.cel()) {
cels.push_back(site.cel());

View File

@ -24,23 +24,31 @@ namespace app {
using namespace doc;
enum class Target {
kAllCels,
kUniqueCels,
kUniqueCanMoveCels,
kUniqueCanEditPixelsCels,
};
// TODO the DocRange should be "iteratable" to replace this function
// or we can wait to C++20 coroutines and co_yield
static CelList get_cels_templ(const Sprite* sprite,
DocRange range,
const bool onlyUniqueCels,
const bool onlyUnlockedCel)
const Target target)
{
CelList cels;
if (!range.convertToCels(sprite))
return cels;
// Used to visit linked cels just once.
std::set<ObjectId> visited;
for (Layer* layer : range.selectedLayers()) {
if (!layer ||
!layer->isImage() ||
(onlyUnlockedCel && !layer->canEditPixels())) {
(target == Target::kUniqueCanMoveCels && !layer->isEditableHierarchy()) ||
(target == Target::kUniqueCanEditPixelsCels && !layer->canEditPixels())) {
continue;
}
@ -50,9 +58,10 @@ static CelList get_cels_templ(const Sprite* sprite,
if (!cel)
continue;
if (!onlyUniqueCels ||
if (target == Target::kAllCels ||
visited.find(cel->data()->id()) == visited.end()) {
if (onlyUniqueCels)
// Only unique cels (avoid visited cels)
if (target != Target::kAllCels)
visited.insert(cel->data()->id());
cels.push_back(cel);
@ -64,17 +73,22 @@ static CelList get_cels_templ(const Sprite* sprite,
CelList get_cels(const doc::Sprite* sprite, const DocRange& range)
{
return get_cels_templ(sprite, range, false, false);
return get_cels_templ(sprite, range, Target::kAllCels);
}
CelList get_unique_cels(const Sprite* sprite, const DocRange& range)
{
return get_cels_templ(sprite, range, true, false);
return get_cels_templ(sprite, range, Target::kUniqueCels);
}
CelList get_unlocked_unique_cels(const Sprite* sprite, const DocRange& range)
CelList get_unique_cels_to_move_cel(const Sprite* sprite, const DocRange& range)
{
return get_cels_templ(sprite, range, true, true);
return get_cels_templ(sprite, range, Target::kUniqueCanMoveCels);
}
CelList get_unique_cels_to_edit_pixels(const Sprite* sprite, const DocRange& range)
{
return get_cels_templ(sprite, range, Target::kUniqueCanEditPixelsCels);
}
} // namespace app

View File

@ -1,5 +1,5 @@
// Aseprite
// Copyright (C) 2020 Igara Studio S.A.
// Copyright (C) 2020-2021 Igara Studio S.A.
// Copyright (C) 2001-2018 David Capello
//
// This program is distributed under the terms of
@ -24,7 +24,8 @@ namespace app {
doc::CelList get_cels(const doc::Sprite* sprite, const DocRange& range);
doc::CelList get_unique_cels(const doc::Sprite* sprite, const DocRange& range);
doc::CelList get_unlocked_unique_cels(const doc::Sprite* sprite, const DocRange& range);
doc::CelList get_unique_cels_to_edit_pixels(const doc::Sprite* sprite, const DocRange& range);
doc::CelList get_unique_cels_to_move_cel(const doc::Sprite* sprite, const DocRange& range);
} // namespace app

View File

@ -336,6 +336,12 @@ void set_mouse_cursor_scale(const int newScale)
update_mouse_cursor();
}
void set_mouse_cursor_reset_info()
{
mouse_cursor_type = kCustomCursor;
mouse_cursor_custom = nullptr;
}
void hide_mouse_cursor()
{
ASSERT(mouse_scares >= 0);

View File

@ -57,6 +57,7 @@ namespace ui {
CursorType get_mouse_cursor();
void set_mouse_cursor(CursorType type, const Cursor* cursor = nullptr);
void set_mouse_cursor_scale(const int newScale);
void set_mouse_cursor_reset_info();
void hide_mouse_cursor();
void show_mouse_cursor();