Compare commits

...

5 Commits

Author SHA1 Message Date
asqude 5c2113566c
Merge 0f32b43475 into 2ba051b59b 2025-07-23 19:17:56 -03:00
David Capello 2ba051b59b Fix crash deselecting moved pixels when using certain extensions (fix #5280)
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
Although the issue refers to deselecting MovingPixelsState, the same
crash could happen when canceling/finishing WritingTextState or
MovingSelectionState. This fixes the crash for all these states.
2025-07-23 19:01:37 -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
asqude 0f32b43475
Make handle-bars the same legth by using the smallest sprite dimesion 2025-07-01 19:12:16 +02:00
Biggy ausm Bürro a811dd320a Add point symmetry mode and update related UI elements 2025-06-30 19:37:43 +02:00
14 changed files with 92 additions and 23 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 17 KiB

After

Width:  |  Height:  |  Size: 17 KiB

View File

@ -256,12 +256,12 @@
<part id="pal_presets" x="160" y="200" w="5" h="5" />
<part id="pal_options" x="168" y="200" w="5" h="5" />
<part id="pal_resize" x="176" y="200" w="5" h="5" />
<part id="debug_continue" x="208" y="240" w="7" h="7" />
<part id="debug_pause" x="208" y="247" w="7" h="7" />
<part id="debug_step_into" x="222" y="240" w="7" h="7" />
<part id="debug_step_over" x="215" y="240" w="7" h="7" />
<part id="debug_step_out" x="229" y="240" w="7" h="7" />
<part id="debug_breakpoint" x="236" y="240" w="7" h="7" />
<part id="debug_continue" x="224" y="240" w="7" h="7" />
<part id="debug_pause" x="224" y="247" w="7" h="7" />
<part id="debug_step_into" x="238" y="240" w="7" h="7" />
<part id="debug_step_over" x="231" y="240" w="7" h="7" />
<part id="debug_step_out" x="245" y="240" w="7" h="7" />
<part id="debug_breakpoint" x="252" y="240" 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_subtract" x="192" y="160" w="7" h="7" />
@ -456,6 +456,7 @@
<part id="spin_down" x="128" y="259" w="5" h="3" />
<part id="right_diagonal_symmetry" x="176" y="240" w="13" h="13" />
<part id="left_diagonal_symmetry" x="192" y="240" w="13" h="13" />
<part id="point_symmetry" x="208" y="240" w="13" h="13" />
</parts>
<styles>
<style id="box" />

Binary file not shown.

Before

Width:  |  Height:  |  Size: 16 KiB

After

Width:  |  Height:  |  Size: 16 KiB

View File

@ -252,12 +252,12 @@
<part id="pal_presets" x="160" y="200" w="5" h="5" />
<part id="pal_options" x="168" y="200" w="5" h="5" />
<part id="pal_resize" x="176" y="200" w="5" h="5" />
<part id="debug_continue" x="208" y="240" w="7" h="7" />
<part id="debug_pause" x="208" y="247" w="7" h="7" />
<part id="debug_step_into" x="222" y="240" w="7" h="7" />
<part id="debug_step_over" x="215" y="240" w="7" h="7" />
<part id="debug_step_out" x="229" y="240" w="7" h="7" />
<part id="debug_breakpoint" x="236" y="240" w="7" h="7" />
<part id="debug_continue" x="224" y="240" w="7" h="7" />
<part id="debug_pause" x="224" y="247" w="7" h="7" />
<part id="debug_step_into" x="238" y="240" w="7" h="7" />
<part id="debug_step_over" x="231" y="240" w="7" h="7" />
<part id="debug_step_out" x="245" y="240" w="7" h="7" />
<part id="debug_breakpoint" x="252" y="240" 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_subtract" x="192" y="160" w="7" h="7" />
@ -452,6 +452,7 @@
<part id="spin_down" x="128" y="259" w="5" h="3" />
<part id="right_diagonal_symmetry" x="176" y="240" w="13" h="13" />
<part id="left_diagonal_symmetry" x="192" y="240" w="13" h="13" />
<part id="point_symmetry" x="208" y="240" w="13" h="13" />
</parts>
<styles>
<style id="box" />

View File

@ -554,6 +554,9 @@
<key command="SymmetryMode">
<param name="orientation" value="left_diagonal" />
</key>
<key command="SymmetryMode">
<param name="orientation" value="point" />
</key>
<key command="AutocropSprite" />
<key command="AutocropSprite">
<param name="byGrid" value="true" />

View File

@ -97,6 +97,7 @@
<value id="RIGHT_DIAG" value="4" />
<value id="LEFT_DIAG" value="8" />
<value id="BOTH_DIAG" value="12" />
<value id="POINT" value="16" />
<value id="ALL" value="15" />
</enum>
<enum id="PaintingCursorType">

View File

@ -1944,6 +1944,7 @@ toggle_horizontal = Toggle Horizontal Symmetry
toggle_vertical = Toggle Vertical Symmetry
toggle_right_diagonal = Toggle 45° Symmetry
toggle_left_diagonal = Toggle -45° Symmetry
toggle_point = Toggle Point Symmetry
show_options = Symmetry Options
reset_position = Reset Symmetry to Center
reset_position_to_view_center = Reset Symmetry to View Center

View File

@ -48,6 +48,7 @@ std::string SymmetryModeCommand::onGetFriendlyName() const
case app::gen::SymmetryMode::VERTICAL: return Strings::symmetry_toggle_vertical();
case app::gen::SymmetryMode::RIGHT_DIAG: return Strings::symmetry_toggle_right_diagonal();
case app::gen::SymmetryMode::LEFT_DIAG: return Strings::symmetry_toggle_left_diagonal();
case app::gen::SymmetryMode::POINT: return Strings::symmetry_toggle_point();
default: return Strings::symmetry_toggle();
}
}
@ -63,6 +64,8 @@ void SymmetryModeCommand::onLoadParams(const Params& params)
m_mode = app::gen::SymmetryMode::RIGHT_DIAG;
else if (mode == "left_diagonal")
m_mode = app::gen::SymmetryMode::LEFT_DIAG;
else if (mode == "point")
m_mode = app::gen::SymmetryMode::POINT;
else
m_mode = app::gen::SymmetryMode::NONE;
}

View File

@ -73,6 +73,15 @@ void Symmetry::generateStrokes(const Stroke& stroke, Strokes& strokes, ToolLoop*
break;
}
case gen::SymmetryMode::POINT: {
Stroke strokeTemp;
calculateSymmetricalStroke(stroke, strokeTemp, loop, doc::SymmetryIndex::FLIPPED_Y);
calculateSymmetricalStroke(strokeTemp, stroke2, loop, doc::SymmetryIndex::FLIPPED_XY);
strokes.push_back(stroke2);
break;
}
case gen::SymmetryMode::ALL: {
calculateSymmetricalStroke(stroke, stroke2, loop, doc::SymmetryIndex::FLIPPED_X);
strokes.push_back(stroke2);
@ -175,8 +184,13 @@ gen::SymmetryMode Symmetry::resolveMode(gen::SymmetryMode mode)
{
return (((int(mode) & int(gen::SymmetryMode::HORIZONTAL)) ||
(int(mode) & int(gen::SymmetryMode::VERTICAL))) &&
((int(mode) & int(gen::SymmetryMode::RIGHT_DIAG)) ||
(int(mode) & int(gen::SymmetryMode::LEFT_DIAG)))) ?
((int(mode) & int(gen::SymmetryMode::RIGHT_DIAG)) ||
(int(mode) & int(gen::SymmetryMode::LEFT_DIAG)))) ||
((int(mode) & int(gen::SymmetryMode::POINT)) &&
((int(mode) & int(gen::SymmetryMode::RIGHT_DIAG)) ||
(int(mode) & int(gen::SymmetryMode::LEFT_DIAG)) ||
(int(mode) & int(gen::SymmetryMode::HORIZONTAL)) ||
(int(mode) & int(gen::SymmetryMode::VERTICAL)))) ?
gen::SymmetryMode::ALL :
mode;
}

View File

@ -1502,7 +1502,7 @@ protected:
class ContextBar::SymmetryField : public ButtonSet {
public:
SymmetryField() : ButtonSet(5)
SymmetryField() : ButtonSet(6)
{
setMultiMode(MultiMode::Set);
auto theme = SkinTheme::get(this);
@ -1510,6 +1510,7 @@ public:
addItem(theme->parts.verticalSymmetry(), theme->styles.symmetryField());
addItem(theme->parts.rightDiagonalSymmetry(), theme->styles.symmetryField());
addItem(theme->parts.leftDiagonalSymmetry(), theme->styles.symmetryField());
addItem(theme->parts.pointSymmetry(), theme->styles.symmetryField());
addItem("...", theme->styles.symmetryOptions());
}
@ -1519,7 +1520,8 @@ public:
tooltipManager->addTooltipFor(at(1), Strings::symmetry_toggle_vertical(), BOTTOM);
tooltipManager->addTooltipFor(at(2), Strings::symmetry_toggle_right_diagonal(), BOTTOM);
tooltipManager->addTooltipFor(at(3), Strings::symmetry_toggle_left_diagonal(), BOTTOM);
tooltipManager->addTooltipFor(at(4), Strings::symmetry_show_options(), BOTTOM);
tooltipManager->addTooltipFor(at(4), Strings::symmetry_toggle_point(), BOTTOM);
tooltipManager->addTooltipFor(at(5), Strings::symmetry_show_options(), BOTTOM);
}
void updateWithCurrentDocument()
@ -1534,6 +1536,7 @@ public:
at(1)->setSelected(int(docPref.symmetry.mode()) & int(app::gen::SymmetryMode::VERTICAL));
at(2)->setSelected(int(docPref.symmetry.mode()) & int(app::gen::SymmetryMode::RIGHT_DIAG));
at(3)->setSelected(int(docPref.symmetry.mode()) & int(app::gen::SymmetryMode::LEFT_DIAG));
at(4)->setSelected(int(docPref.symmetry.mode()) & int(app::gen::SymmetryMode::POINT));
}
private:
@ -1556,14 +1559,16 @@ private:
mode |= int(app::gen::SymmetryMode::RIGHT_DIAG);
if (at(3)->isSelected())
mode |= int(app::gen::SymmetryMode::LEFT_DIAG);
if (at(4)->isSelected())
mode |= int(app::gen::SymmetryMode::POINT);
if (app::gen::SymmetryMode(mode) != docPref.symmetry.mode()) {
docPref.symmetry.mode(app::gen::SymmetryMode(mode));
// Redraw symmetry rules
doc->notifyGeneralUpdate();
}
else if (at(4)->isSelected()) {
auto* item = at(4);
else if (at(5)->isSelected()) {
auto* item = at(5);
gfx::Rect bounds = item->bounds();
item->setSelected(false);

View File

@ -58,6 +58,7 @@
#include "app/util/tile_flags_utils.h"
#include "base/chrono.h"
#include "base/convert_to.h"
#include "base/scoped_value.h"
#include "doc/doc.h"
#include "doc/mask_boundaries.h"
#include "doc/slice.h"
@ -266,6 +267,23 @@ void Editor::setStateInternal(const EditorStatePtr& newState)
{
m_brushPreview.hide();
// Some onLeaveState impls (like the ones from MovingPixelsState,
// WritingTextState, MovingSelectionState) might generate a
// Tx/Transaction::commit(), which will add a new undo state,
// triggering a sprite change scripting event
// (SpriteEvents::onAddUndoState). This event could be handled by an
// extension and that extension might want to save the current
// sprite (e.g. calling Sprite_saveCopyAs, the kind of extension
// that takes snapshots after each sprite change). That will be a
// new Context::executeCommand() for the save command, generating a
// BeforeCommandExecution signal, getting back to onLeaveState
// again. In that case, we just ignore the reentry as the first
// onLeaveState should handle everything (to avoid an stack
// overflow/infinite recursion).
if (m_leavingState)
return;
base::ScopedValue leaving(m_leavingState, true);
// Fire before change state event, set the state, and fire after
// change state event.
EditorState::LeaveAction leaveAction = m_state->onLeaveState(this, newState.get());
@ -916,6 +934,19 @@ void Editor::drawOneSpriteUnclippedRect(ui::Graphics* g,
topLeft,
bottomRight);
}
if (mode & int(app::gen::SymmetryMode::POINT)) {
int smallestDimension = std::min(enclosingRect.w, enclosingRect.h);
g->drawHLine(
symmetryButtons & int(app::gen::SymmetryMode::POINT) ? color : semiTransparentColor,
enclosingRect.x + x - smallestDimension * 0.10f,
enclosingRect.y + y,
smallestDimension * 0.10f * 2.0f);
g->drawVLine(
(symmetryButtons & int(app::gen::SymmetryMode::POINT)) ? color : semiTransparentColor,
enclosingRect.x + x,
enclosingRect.y + y - smallestDimension * 0.10f,
smallestDimension * 0.10f * 2.0f);
}
}
}
}

View File

@ -1,5 +1,5 @@
// Aseprite
// Copyright (C) 2018-2024 Igara Studio S.A.
// Copyright (C) 2018-2025 Igara Studio S.A.
// Copyright (C) 2001-2018 David Capello
//
// This program is distributed under the terms of
@ -458,6 +458,13 @@ private:
DocView* m_docView;
// Special flag to avoid re-entering a new state when we are leaving
// the current one. This avoids an infinite onLeaveState() recursion
// in some special cases when an extension (third-party code)
// creates a new sprite change in the same sprite change scripting
// event.
bool m_leavingState = false;
// Last known mouse position received by this editor when the
// mouse button was pressed. Used for auto-scrolling. To get the
// current mouse position on the editor you can use

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

@ -1030,7 +1030,8 @@ bool StandbyState::Decorator::getSymmetryHandles(Editor* editor, Handles& handle
if ((int(mode) & int(app::gen::SymmetryMode::HORIZONTAL)) ||
(int(mode) & int(app::gen::SymmetryMode::RIGHT_DIAG)) ||
(int(mode) & int(app::gen::SymmetryMode::LEFT_DIAG))) {
(int(mode) & int(app::gen::SymmetryMode::LEFT_DIAG)) ||
(int(mode) & int(app::gen::SymmetryMode::POINT))) {
double pos = symmetry.xAxis();
gfx::PointF pt1, pt2;
@ -1051,7 +1052,8 @@ bool StandbyState::Decorator::getSymmetryHandles(Editor* editor, Handles& handle
if ((int(mode) & int(app::gen::SymmetryMode::VERTICAL)) ||
(int(mode) & int(app::gen::SymmetryMode::RIGHT_DIAG)) ||
(int(mode) & int(app::gen::SymmetryMode::LEFT_DIAG))) {
(int(mode) & int(app::gen::SymmetryMode::LEFT_DIAG)) ||
(int(mode) & int(app::gen::SymmetryMode::POINT))) {
double pos = symmetry.yAxis();
gfx::PointF pt1, pt2;