mirror of
https://github.com/aseprite/aseprite.git
synced 2025-01-30 15:32:38 +00:00
Merge branch 'main' into beta
This commit is contained in:
commit
b90c56487d
2
laf
2
laf
@ -1 +1 @@
|
|||||||
Subproject commit 316bc10a674fa20cf133e9295f8c1dcbfacf20ad
|
Subproject commit 9a93eeb4557a37232e5f062dfc9effa797ea2e2b
|
@ -93,7 +93,7 @@ void FlipCommand::onExecute(Context* ctx)
|
|||||||
|
|
||||||
auto range = site.range();
|
auto range = site.range();
|
||||||
if (range.enabled()) {
|
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() &&
|
else if (site.cel() &&
|
||||||
site.layer() &&
|
site.layer() &&
|
||||||
|
@ -214,7 +214,7 @@ void RotateCommand::onExecute(Context* context)
|
|||||||
|
|
||||||
auto range = App::instance()->timeline()->range();
|
auto range = App::instance()->timeline()->range();
|
||||||
if (range.enabled())
|
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() &&
|
else if (site.cel() &&
|
||||||
site.layer() &&
|
site.layer() &&
|
||||||
site.layer()->canEditPixels()) {
|
site.layer()->canEditPixels()) {
|
||||||
|
@ -274,11 +274,9 @@ void FilterManagerImpl::applyToTarget()
|
|||||||
case CelsTarget::Selected: {
|
case CelsTarget::Selected: {
|
||||||
auto range = m_site.range();
|
auto range = m_site.range();
|
||||||
if (range.enabled()) {
|
if (range.enabled()) {
|
||||||
for (Cel* cel : get_unlocked_unique_cels(m_site.sprite(), range)) {
|
for (Cel* cel : get_unique_cels_to_edit_pixels(m_site.sprite(), range))
|
||||||
if (!cel->layer()->isReference())
|
|
||||||
cels.push_back(cel);
|
cels.push_back(cel);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
else if (m_site.cel() &&
|
else if (m_site.cel() &&
|
||||||
m_site.layer() &&
|
m_site.layer() &&
|
||||||
m_site.layer()->canEditPixels()) {
|
m_site.layer()->canEditPixels()) {
|
||||||
|
@ -589,7 +589,7 @@ bool DocView::onClear(Context* ctx)
|
|||||||
|
|
||||||
CelList cels;
|
CelList cels;
|
||||||
if (site.range().enabled()) {
|
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()) {
|
else if (site.cel()) {
|
||||||
cels.push_back(site.cel());
|
cels.push_back(site.cel());
|
||||||
|
@ -508,7 +508,11 @@ void BrushPreview::createNativeCursor()
|
|||||||
|
|
||||||
if (cursorBounds.isEmpty()) {
|
if (cursorBounds.isEmpty()) {
|
||||||
ASSERT(!m_cursor);
|
ASSERT(!m_cursor);
|
||||||
|
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);
|
m_editor->display()->nativeWindow()->setNativeMouseCursor(os::NativeCursor::Hidden);
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -547,6 +551,8 @@ void BrushPreview::forEachLittleCrossPixel(
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (m_cursor) {
|
if (m_cursor) {
|
||||||
|
// TODO should we use ui::set_mouse_cursor()?
|
||||||
|
ui::set_mouse_cursor_reset_info();
|
||||||
m_editor->display()->nativeWindow()->setNativeMouseCursor(
|
m_editor->display()->nativeWindow()->setNativeMouseCursor(
|
||||||
m_cursor.get(),
|
m_cursor.get(),
|
||||||
m_cursorCenter,
|
m_cursorCenter,
|
||||||
|
@ -1623,28 +1623,35 @@ void Editor::updateToolLoopModifiersIndicators(const bool firstFromMouseDown)
|
|||||||
int(tools::ToolLoopModifiers::kSubtractSelection) |
|
int(tools::ToolLoopModifiers::kSubtractSelection) |
|
||||||
int(tools::ToolLoopModifiers::kIntersectSelection)));
|
int(tools::ToolLoopModifiers::kIntersectSelection)));
|
||||||
|
|
||||||
tools::Controller* controller =
|
tools::Tool* tool = atm->selectedTool();
|
||||||
(atm->selectedTool() ?
|
tools::Controller* controller = (tool ? tool->getController(0): nullptr);
|
||||||
atm->selectedTool()->getController(0): nullptr);
|
tools::Ink* ink = (tool ? tool->getInk(0): nullptr);
|
||||||
|
|
||||||
// Shape tools modifiers (line, curves, rectangles, etc.)
|
// Shape tools modifiers (line, curves, rectangles, etc.)
|
||||||
if (controller && controller->isTwoPoints()) {
|
if (controller && controller->isTwoPoints()) {
|
||||||
action = m_customizationDelegate->getPressedKeyAction(KeyContext::ShapeTool);
|
action = m_customizationDelegate->getPressedKeyAction(KeyContext::ShapeTool);
|
||||||
|
|
||||||
|
// 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 (!firstFromMouseDown ||
|
||||||
|
!ink || !ink->isSelection()) {
|
||||||
if (int(action & KeyAction::MoveOrigin))
|
if (int(action & KeyAction::MoveOrigin))
|
||||||
modifiers |= int(tools::ToolLoopModifiers::kMoveOrigin);
|
modifiers |= int(tools::ToolLoopModifiers::kMoveOrigin);
|
||||||
if (int(action & KeyAction::SquareAspect))
|
if (int(action & KeyAction::SquareAspect))
|
||||||
modifiers |= int(tools::ToolLoopModifiers::kSquareAspect);
|
modifiers |= int(tools::ToolLoopModifiers::kSquareAspect);
|
||||||
if (int(action & KeyAction::DrawFromCenter))
|
if (int(action & KeyAction::DrawFromCenter))
|
||||||
modifiers |= int(tools::ToolLoopModifiers::kFromCenter);
|
modifiers |= int(tools::ToolLoopModifiers::kFromCenter);
|
||||||
|
if (int(action & KeyAction::RotateShape))
|
||||||
// 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
|
|
||||||
// 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);
|
modifiers |= int(tools::ToolLoopModifiers::kRotateShape);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Freehand modifiers
|
// Freehand modifiers
|
||||||
if (controller && controller->isFreehand()) {
|
if (controller && controller->isFreehand()) {
|
||||||
@ -2784,10 +2791,6 @@ void Editor::showMouseCursor(CursorType cursorType,
|
|||||||
|
|
||||||
void Editor::showBrushPreview(const gfx::Point& screenPos)
|
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);
|
m_brushPreview.show(screenPos);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -70,7 +70,7 @@ MovingCelCollect::MovingCelCollect(Editor* editor, Layer* layer)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Record start positions of all cels in selected range
|
// 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();
|
Layer* layer = cel->layer();
|
||||||
ASSERT(layer);
|
ASSERT(layer);
|
||||||
|
|
||||||
|
@ -1286,8 +1286,8 @@ CelList PixelsMovement::getEditableCels()
|
|||||||
CelList cels;
|
CelList cels;
|
||||||
|
|
||||||
if (editMultipleCels()) {
|
if (editMultipleCels()) {
|
||||||
cels = get_unlocked_unique_cels(
|
cels = get_unique_cels_to_edit_pixels(m_site.sprite(),
|
||||||
m_site.sprite(), m_site.range());
|
m_site.range());
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
// TODO This case is used in paste too, where the cel() can be
|
// TODO This case is used in paste too, where the cel() can be
|
||||||
|
@ -361,7 +361,7 @@ void Clipboard::cut(ContextWriter& writer)
|
|||||||
Site site = writer.context()->activeSite();
|
Site site = writer.context()->activeSite();
|
||||||
CelList cels;
|
CelList cels;
|
||||||
if (site.range().enabled()) {
|
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()) {
|
else if (site.cel()) {
|
||||||
cels.push_back(site.cel());
|
cels.push_back(site.cel());
|
||||||
|
@ -24,23 +24,31 @@ namespace app {
|
|||||||
|
|
||||||
using namespace doc;
|
using namespace doc;
|
||||||
|
|
||||||
|
enum class Target {
|
||||||
|
kAllCels,
|
||||||
|
kUniqueCels,
|
||||||
|
kUniqueCanMoveCels,
|
||||||
|
kUniqueCanEditPixelsCels,
|
||||||
|
};
|
||||||
|
|
||||||
// TODO the DocRange should be "iteratable" to replace this function
|
// TODO the DocRange should be "iteratable" to replace this function
|
||||||
// or we can wait to C++20 coroutines and co_yield
|
// or we can wait to C++20 coroutines and co_yield
|
||||||
static CelList get_cels_templ(const Sprite* sprite,
|
static CelList get_cels_templ(const Sprite* sprite,
|
||||||
DocRange range,
|
DocRange range,
|
||||||
const bool onlyUniqueCels,
|
const Target target)
|
||||||
const bool onlyUnlockedCel)
|
|
||||||
{
|
{
|
||||||
CelList cels;
|
CelList cels;
|
||||||
if (!range.convertToCels(sprite))
|
if (!range.convertToCels(sprite))
|
||||||
return cels;
|
return cels;
|
||||||
|
|
||||||
|
// Used to visit linked cels just once.
|
||||||
std::set<ObjectId> visited;
|
std::set<ObjectId> visited;
|
||||||
|
|
||||||
for (Layer* layer : range.selectedLayers()) {
|
for (Layer* layer : range.selectedLayers()) {
|
||||||
if (!layer ||
|
if (!layer ||
|
||||||
!layer->isImage() ||
|
!layer->isImage() ||
|
||||||
(onlyUnlockedCel && !layer->canEditPixels())) {
|
(target == Target::kUniqueCanMoveCels && !layer->isEditableHierarchy()) ||
|
||||||
|
(target == Target::kUniqueCanEditPixelsCels && !layer->canEditPixels())) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -50,9 +58,10 @@ static CelList get_cels_templ(const Sprite* sprite,
|
|||||||
if (!cel)
|
if (!cel)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (!onlyUniqueCels ||
|
if (target == Target::kAllCels ||
|
||||||
visited.find(cel->data()->id()) == visited.end()) {
|
visited.find(cel->data()->id()) == visited.end()) {
|
||||||
if (onlyUniqueCels)
|
// Only unique cels (avoid visited cels)
|
||||||
|
if (target != Target::kAllCels)
|
||||||
visited.insert(cel->data()->id());
|
visited.insert(cel->data()->id());
|
||||||
|
|
||||||
cels.push_back(cel);
|
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)
|
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)
|
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
|
} // namespace app
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
// Aseprite
|
// Aseprite
|
||||||
// Copyright (C) 2020 Igara Studio S.A.
|
// Copyright (C) 2020-2021 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
|
||||||
@ -24,7 +24,8 @@ namespace app {
|
|||||||
|
|
||||||
doc::CelList get_cels(const doc::Sprite* sprite, const DocRange& range);
|
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_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
|
} // namespace app
|
||||||
|
|
||||||
|
@ -336,6 +336,12 @@ void set_mouse_cursor_scale(const int newScale)
|
|||||||
update_mouse_cursor();
|
update_mouse_cursor();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void set_mouse_cursor_reset_info()
|
||||||
|
{
|
||||||
|
mouse_cursor_type = kCustomCursor;
|
||||||
|
mouse_cursor_custom = nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
void hide_mouse_cursor()
|
void hide_mouse_cursor()
|
||||||
{
|
{
|
||||||
ASSERT(mouse_scares >= 0);
|
ASSERT(mouse_scares >= 0);
|
||||||
|
@ -57,6 +57,7 @@ namespace ui {
|
|||||||
CursorType get_mouse_cursor();
|
CursorType get_mouse_cursor();
|
||||||
void set_mouse_cursor(CursorType type, const Cursor* cursor = nullptr);
|
void set_mouse_cursor(CursorType type, const Cursor* cursor = nullptr);
|
||||||
void set_mouse_cursor_scale(const int newScale);
|
void set_mouse_cursor_scale(const int newScale);
|
||||||
|
void set_mouse_cursor_reset_info();
|
||||||
|
|
||||||
void hide_mouse_cursor();
|
void hide_mouse_cursor();
|
||||||
void show_mouse_cursor();
|
void show_mouse_cursor();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user