Compare commits

...

5 Commits

Author SHA1 Message Date
Gaspar Capello 523d9c75de
Merge c98a2056e5 into 3fcb000eb1 2025-07-22 16:44:00 -03:00
Christian Kaiser 3fcb000eb1 Fix slice transformations not updating editors
build / build (Debug, macos-latest, lua, cli) (push) Has been cancelled Details
build / build (Debug, macos-latest, noscripts, cli) (push) Has been cancelled Details
build / build (Debug, ubuntu-latest, lua, cli) (push) Has been cancelled Details
build / build (Debug, ubuntu-latest, noscripts, cli) (push) Has been cancelled Details
build / build (Debug, windows-latest, lua, cli) (push) Has been cancelled Details
build / build (Debug, windows-latest, noscripts, cli) (push) Has been cancelled Details
build / build (RelWithDebInfo, macos-latest, lua, gui) (push) Has been cancelled Details
build / build (RelWithDebInfo, ubuntu-latest, lua, gui) (push) Has been cancelled Details
build / build (RelWithDebInfo, windows-latest, lua, gui) (push) Has been cancelled Details
2025-07-22 02:11:07 -03:00
David Capello af9dc3c817 Fix brush boundaries accumulation switching brush type only (fix #5281)
build / build (Debug, macos-latest, lua, cli) (push) Waiting to run Details
build / build (Debug, macos-latest, noscripts, cli) (push) Waiting to run Details
build / build (Debug, ubuntu-latest, lua, cli) (push) Waiting to run Details
build / build (Debug, ubuntu-latest, noscripts, cli) (push) Waiting to run Details
build / build (Debug, windows-latest, lua, cli) (push) Waiting to run Details
build / build (Debug, windows-latest, noscripts, cli) (push) Waiting to run Details
build / build (RelWithDebInfo, macos-latest, lua, gui) (push) Waiting to run Details
build / build (RelWithDebInfo, ubuntu-latest, lua, gui) (push) Waiting to run Details
build / build (RelWithDebInfo, windows-latest, lua, gui) (push) Waiting to run Details
2025-07-21 17:28:11 -03:00
David Capello 250dfdc86a Convert the brush generation counter into an atomic var 2025-07-21 17:27:23 -03:00
Gaspar Capello c98a2056e5 Add Lock Axis alternative (fix #5251)
The lock axis is selected and held as soon as SHIFT is pressed.
A diagonal translation lock has also been added.
2025-07-04 15:54:49 -03:00
10 changed files with 106 additions and 24 deletions

View File

@ -705,6 +705,7 @@ target_sources(app-lib PRIVATE
util/filetoks.cpp
util/layer_boundaries.cpp
util/layer_utils.cpp
util/moving_utils.cpp
util/msk_file.cpp
util/new_image_from_mask.cpp
util/open_file_job.cpp

View File

@ -1,5 +1,5 @@
// Aseprite
// Copyright (C) 2019-2024 Igara Studio S.A.
// Copyright (C) 2019-2025 Igara Studio S.A.
// Copyright (C) 2001-2018 David Capello
//
// This program is distributed under the terms of
@ -457,6 +457,8 @@ void BrushPreview::show(const gfx::Point& screenPos)
// Here we re-use the cached surface
if (!cached && m_uiLayer->surface()) {
m_uiLayer->surface()->clear();
gfx::Rect layerBounds = m_uiLayer->surface()->bounds();
ui::Graphics g(display, m_uiLayer->surface(), 0, 0);

View File

@ -1,5 +1,5 @@
// Aseprite
// Copyright (C) 2020-2023 Igara Studio S.A.
// Copyright (C) 2020-2025 Igara Studio S.A.
// Copyright (C) 2001-2018 David Capello
//
// This program is distributed under the terms of
@ -247,14 +247,10 @@ void MovingCelState::onCommitMouseMove(Editor* editor, const gfx::PointF& newCur
m_celOffset = newCursorPos - m_cursorStart;
if (int(editor->getCustomizationDelegate()->getPressedKeyAction(
KeyContext::TranslatingSelection) &
KeyAction::LockAxis)) {
if (ABS(m_celOffset.x) < ABS(m_celOffset.y)) {
m_celOffset.x = 0;
}
else {
m_celOffset.y = 0;
}
}
KeyAction::LockAxis))
app::lockAxis(m_lockedAxis, m_celOffset);
else
m_lockedAxis = NONE;
if (!m_moved && intCelOffset() != gfx::Point(0, 0))
m_moved = true;
break;

View File

@ -1,5 +1,5 @@
// Aseprite
// Copyright (C) 2021-2022 Igara Studio S.A.
// Copyright (C) 2021-2025 Igara Studio S.A.
// Copyright (C) 2001-2017 David Capello
//
// This program is distributed under the terms of
@ -14,6 +14,7 @@
#include "app/context_access.h"
#include "app/ui/editor/delayed_mouse_move.h"
#include "app/ui/editor/handle_type.h"
#include "app/util/moving_utils.h"
#include "doc/cel_list.h"
#include <vector>
@ -80,6 +81,7 @@ private:
gfx::PointF m_celOffset;
gfx::SizeF m_celMainSize;
gfx::SizeF m_celScale;
LockedAxis m_lockedAxis;
bool m_maskVisible;
bool m_hasReference = false;
bool m_moved = false;

View File

@ -428,8 +428,8 @@ bool MovingSliceState::onMouseMove(Editor* editor, MouseMessage* msg)
if (editor->slicesTransforms())
drawExtraCel();
// Redraw the editor.
editor->invalidate();
// Notify changes
m_site.document()->notifyGeneralUpdate();
// Use StandbyState implementation
return StandbyState::onMouseMove(editor, msg);

View File

@ -376,6 +376,7 @@ void PixelsMovement::moveImage(const gfx::PointF& pos, MoveModifier moveModifier
switch (m_handle) {
case MovePixelsHandle: {
double dx, dy;
const bool isLockAxis = ((moveModifier & LockAxisMovement) == LockAxisMovement);
if (tilesModeOn) {
if (m_catchPos.x == 0 && m_catchPos.y == 0) {
// Movement through keyboard:
@ -393,7 +394,8 @@ void PixelsMovement::moveImage(const gfx::PointF& pos, MoveModifier moveModifier
dy = point.y;
}
}
else if ((moveModifier & FineControl) == 0) {
// FineControl is discarded if 'Locked Axis' is active
else if (isLockAxis || ((moveModifier & FineControl) == 0)) {
dx = (std::floor(pos.x) - std::floor(m_catchPos.x));
dy = (std::floor(pos.y) - std::floor(m_catchPos.y));
}
@ -402,12 +404,10 @@ void PixelsMovement::moveImage(const gfx::PointF& pos, MoveModifier moveModifier
dy = (pos.y - m_catchPos.y);
}
if ((moveModifier & LockAxisMovement) == LockAxisMovement) {
if (std::abs(dx) < std::abs(dy))
dx = 0.0;
if (isLockAxis)
lockAxis(m_lockedAxis, dx, dy);
else
dy = 0.0;
}
m_lockedAxis = LockedAxis::NONE;
bounds.offset(dx, dy);

View File

@ -1,5 +1,5 @@
// Aseprite
// Copyright (C) 2019-2024 Igara Studio S.A.
// Copyright (C) 2019-2025 Igara Studio S.A.
// Copyright (C) 2001-2018 David Capello
//
// This program is distributed under the terms of
@ -15,6 +15,7 @@
#include "app/transformation.h"
#include "app/tx.h"
#include "app/ui/editor/handle_type.h"
#include "app/util/moving_utils.h"
#include "doc/algorithm/flip_type.h"
#include "doc/frame.h"
#include "doc/image_ref.h"
@ -190,6 +191,7 @@ private:
Transformation m_currentData;
std::unique_ptr<Mask> m_initialMask, m_initialMask0;
std::unique_ptr<Mask> m_currentMask;
LockedAxis m_lockedAxis;
bool m_opaque;
color_t m_maskColor;
obs::scoped_connection m_pivotVisConn;

View File

@ -0,0 +1,49 @@
// Aseprite
// Copyright (C) 2025 Igara Studio S.A.
//
// This program is distributed under the terms of
// the End-User License Agreement for Aseprite.
#include "app/util/moving_utils.h"
#include <cmath>
namespace app {
void lockAxis(LockedAxis& lockedAxis, gfx::PointF& delta)
{
double dx = delta.x;
double dy = delta.y;
lockAxis(lockedAxis, dx, dy);
delta.x = dx;
delta.y = dy;
}
void lockAxis(LockedAxis& lockedAxis, double& dx, double& dy)
{
if (lockedAxis == LockedAxis::NONE) {
if (std::abs(dx) * 3 > std::abs(dy) * 7) {
lockedAxis = LockedAxis::Y;
dy = 0.0;
}
else if (std::abs(dy) * 3 > std::abs(dx) * 7) {
lockedAxis = LockedAxis::X;
dx = 0.0;
}
else {
const bool sameSign = std::signbit(dx) == std::signbit(dy);
lockedAxis = sameSign ? LockedAxis::R_DIAG : LockedAxis::L_DIAG;
dy = sameSign ? dx : -dx;
}
}
else {
switch (lockedAxis) {
case LockedAxis::X: dx = 0.0; break;
case LockedAxis::Y: dy = 0.0; break;
case LockedAxis::R_DIAG: dy = dx; break;
case LockedAxis::L_DIAG: dy = -dx; break;
}
}
}
} // namespace app

View File

@ -0,0 +1,29 @@
// Aseprite
// Copyright (C) 2025 Igara Studio S.A.
//
// This program is distributed under the terms of
// the End-User License Agreement for Aseprite.
#ifndef APP_UTIL_MOVING_UTILS_H_INCLUDED
#define APP_UTIL_MOVING_UTILS_H_INCLUDED
#pragma once
#include "gfx/point.h"
namespace app {
enum LockedAxis {
NONE,
X,
Y,
R_DIAG,
L_DIAG,
};
void lockAxis(LockedAxis& lockedAxis, gfx::PointF& delta);
void lockAxis(LockedAxis& lockedAxis, double& dx, double& dy);
} // namespace app
#endif // APP_UTIL_MOVING_UTILS_H_INCLUDED

View File

@ -1,5 +1,5 @@
// Aseprite Document Library
// Copyright (C) 2019-2024 Igara Studio S.A.
// Copyright (C) 2019-2025 Igara Studio S.A.
// Copyright (C) 2001-2016 David Capello
//
// This file is released under the terms of the MIT license.
@ -20,11 +20,12 @@
#include "doc/primitives.h"
#include <algorithm>
#include <atomic>
#include <cmath>
namespace doc {
static int generation = 0;
static std::atomic<int> g_generation = 0;
Brush::Brush()
{
@ -300,7 +301,7 @@ void Brush::setCenter(const gfx::Point& center)
// Cleans the brush's data (image and region).
void Brush::clean()
{
m_gen = ++generation;
m_gen = ++g_generation;
m_image.reset();
m_maskBitmap.reset();
m_backupImage.reset();