Commit Graph

1413 Commits

Author SHA1 Message Date
Gaspar Capello
aca9bf6bb7 Fix duplicate "Tiled Mode" items in the keyboard shortcuts list (#4387) 2024-09-16 10:08:35 -03:00
David Capello
adb537614f Always prefer unique_ptr over shared_ptr 2024-09-05 18:33:07 -03:00
Gaspar Capello
e70bbbd369 Add 'x' and 'y' as input parameters to app.command.Paste() 2024-09-05 17:22:12 -03:00
Gaspar Capello
de1fc581f2 Fix app.command.Cut/Paste does not work in --batch mode (fix #4354)
This fix adds support for cut/copy/paste selected areas during
script execution when there isn't UI.
2024-09-05 17:22:12 -03:00
Gaspar Capello
c8f018f2f1
Fix exporting a Sprite Sheet with Group name has different functionality between CLI and Scripting (fix #4456) (#4475)
Before this fix, the lua command:
app.command.ExportSpriteSheet
could not process a layer within a group when the layer name
was expressed using the layer hierarchy path, for example:
layer = "Group1/Layer1"
2024-09-03 20:20:36 -03:00
Gaspar Capello
e1bd7990a3 Add color fit criteria for Color Mode conversion (fix #2787, #4416)
Added other color comparison criterias (fit criteria) during
color mode conversion RGBA to Indexed or Grayscale to Indexed.
The 'fit criteria' will help us to recolor an RGB image with
a limited color palette taking into account different color
perception criteria (color spaces: RGB, linearized RGB,
CIE XYZ, CIE LAB).
2024-09-03 13:17:09 -03:00
Gaspar Capello
3cc1c63274 Add different best fit criteria to compare colors for RgbMaps (fix #2787, #4416) 2024-09-03 13:17:06 -03:00
Gaspar Capello
95513af267 Fix multiple tileset layers selection move is broken (fix #3144)
Before this fix, a multi-layer mask movement/scaling (with mixed layer
types: normal layer and tilemap layers with different grids) caused
loss of drawing areas.

The heart of this solution is to correctly align the 'selection mask'
and 'transform data' according to the layer's grid, and also, forcing
'site' TilemapMode/TilesetMode before each
reproduceAllTransformationsWithInnerCmds() iteration.
During the life of a PixelMovement object there is a tilemap mode lock.

Additionally arrow keys now work to move a selected area in
TilemapMode::Tiles.
2024-09-03 11:44:25 -03:00
David Capello
bf0a47545c Remove #if/endif ENABLE_UI conditional directives (fix #4619)
This was originated for #1279 (CLI-only Aseprite) which can be
achieved with LAF_BACKEND=none anyway.

In this way we simplify the development process, and checking for the
availability of the GUI can be done in run-time through App::isGui()
or Context::isUIAvailable().
2024-09-02 23:16:26 -03:00
Gaspar Capello
8323a55500 Fix Cancel command do not work on scripting
Before this fix, the 'Cancel' command did not work in the following
specific situation:
As soon as Aseprite was started and without hitting the 'Esc' key,
the 'app.command.Cancel()' command did not perform any operation.

It was discovered that the Cancel command is started only once per
session and retains the 'm_type' throughout the session. Only
a specific:
app.command.Cancel {type = "all"} or
app.command.Cancel {type = "noop"}
could change the command type.
2024-08-29 10:50:03 -03:00
Martín Capello
712d84e44e
Avoid div by zero by preventing entering/returning a grid bounds w/zero width/height (fix #4146, #4597) 2024-08-19 18:07:40 -03:00
Gaspar Capello
8f3af748b9
Don't allow to install third-party themes that override the default one (fix #4226) (#4335)
This 1) hides user themes whose name is the same as the default,
and are present in the user folders (i.e.  'extensions' and
'data/themes' folders), and 2) doesn't allow to install themes with
the same content/ID of the default aseprite-theme (fix #4226)
2024-07-29 16:02:05 -03:00
David Capello
32a099dcb6 Fix crashes with ill-formed fmt format strings (fix #2274)
There is a third-party translation (and can happen with our own
translations) that a fmt format string is ill-formed in the .ini file
of the translation (this could happen even if the en.ini file was
manually modified/broken by hand).

This patch includes a refactor of the Strings class so we can:

1) Static check at compile-time about the number of required arguments
   to format a string (no need to call fmt::format() directly with
   arbitrary number of args)
2) If a string is not valid for the fmt library, the runtime exception
   is caught and the default (English) string is returned.
2024-06-20 20:49:10 -03:00
David Capello
7d63ceb199 Remove System::tabletAPI() function 2024-06-18 14:02:37 -03:00
David Capello
f29ec83c6c [win] Fix sync between mouse cursor <-> stylus cursor (fix #4539)
Added a new option (enabled by default) to set the mouse cursor when a
pen/pointer message is received. This fixes a couple of issues:

1) When we zoom in/out with keys or scrolling the trackpad, the last
   known position will be used (the pen position if we are using the
   pen).

2) If we are recording the stream/live streaming with a software like
   OBS Studio, the cursor position will correctly be in the pen
   position if we're painting with the pen.
2024-06-18 13:44:19 -03:00
David Capello
2c7fc767bf Update GPU flag correctly on all display when it's changed 2024-06-14 20:07:05 -03:00
Martín Capello
88ef46de42 Add new CLI param to save animations taking into account subtabs and repeats (fix #4297) 2024-05-28 15:00:22 -03:00
Gaspar Capello
1896483458 Fix crashing segfault when calling: app.command.CloseFile() or app.command.GotoPreviousTab() , in --batch mode (fix #4352) 2024-05-28 13:35:55 -03:00
David Capello
3ea0437e1d Add "recent" param to SaveFile/ExportSpriteSheet to avoid adding the file to the list of recent files 2024-05-10 15:20:32 -03:00
David Capello
0cc1161d64 Disable progress bar in commands that can receive ui=false (fix #4165) 2024-05-09 14:34:48 -03:00
David Capello
92edd5f700 Add Brush::clone() functions to fix/simplify some Brush-related code
This refactor includes:

- In Lua now we can clone a custom brush with Brush(Image) and the new
  brush doesn't share the image with the original one (added a new test
  for this).

- Avoid creating extra images when it's not needed using
  Brush::cloneWithExistingImages() (we can inject existing images in
  the brush itself).

- Delete Brush-copy contructor & assign operator to use
  Brush::clone() functions instead (which are more explicit).

- Some code from 12d8135264 (#4023)
  reverted to avoid recreating brushes on left-click or in the brush
  preview, i.e. moving the mouse (#4013 refers only to right-click, so
  only on right-click we have to adjust the custom brush).
2024-05-03 11:35:36 -03:00
David Capello
6a12c7014d Select "English" if the current language is not found in Preferences
If the user preferences file (aseprite.ini) contained a non-existent
language, the first option of the languages combo box was selected,
which might lead to a confusing situation where just opening the
preferences dialog will change from English to other
language (non-English, the first language in the combobox).
2024-04-08 13:23:38 -03:00
David Capello
ec4e82bdc0 Fix crashes with SpriteJob(s) that weren't locking the doc correctly (fix #4315)
This was mainly found in SpriteSizeJob crash reports. In these reports
deleted image buffers were still used to paint the Editor canvas
because the doc was write-locked in the main thread (same thread where
the canvas is painted). This produced a re-entrant lock in the
Editor::onPaint() as we can still read-lock from the same thread where
we write-locked the doc.

With this change we write-lock the doc from the SpriteJob background
thread (not the main thread) only if it's necessary (i.e. when the doc
is not already locked in the main thread, e.g. when running a script).
This makes that the main thread (Editor::onPaint) cannot read the doc
until we finish the whole SpriteJob transaction/Tx.
2024-03-25 18:53:12 -03:00
David Capello
7905acf38a Handle some extra CannotWriteDocException cases when ContextWriter is used (#4367)
One fix that this patch includes for #4367 (crash by unhandled
CannotWriteDocException exception) is when we drag-and-drop a tag
border to resize its limits. This is a fix for that case but we don't
know if this include all cases of #4367 crashes (so we cannot close
the issue).

Anyway we have added some try { } catch in cases where it's better to
avoid propagating the exception, e.g. in
MovingSelectionState::onLeaveState() to avoid throwing exceptions in
Editor::backToPreviousState() which might be problematic in several
cases. (Maybe related to #2829?)
2024-03-11 17:15:13 -03:00
David Capello
7f659d2f86 Handle exceptions that DocDestroyer can throw (probably #4367) 2024-03-11 11:06:57 -03:00
David Capello
cfb663f820 Some fixes to readability-else-after-return 2024-02-29 10:26:47 -03:00
David Capello
83d83cd8c6 Add const to lock_guards 2024-02-28 12:32:08 -03:00
David Capello
e949a5401d Drop selection when we hide a layer that is being transformed (fix #4179, fix #3254)
This fixes several problems in MovingPixelsState where hidden layers
were transformed anyway when we switched the visibility of a layer in
this state.

Other fix was tried before in #3254 but we needed the onBefore/After
layer visibility change notifications to make this work properly
(i.e. drop pixels when the visiblity of a layer is changed).

The only drawback at this moment is that changing the visibility of
the non-active layer when we are transforming multiple cels/timeline
range can be confused because we don't have #2144/#2865 implemented
yet.

This bug was originally reported here: https://community.aseprite.org/t/20621
2024-02-26 17:36:57 -03:00
David Capello
749ea49185 Add link in About dialog to show the list of translators 2024-02-12 11:59:26 -03:00
David Capello
434c262489 Merge branch 'intuitive-opacity-values' (#1544, #4262) 2024-02-08 15:22:58 -03:00
Martín Capello
eb45c4adf5 Add support to "play subtags & repetitions" when exporting an animation (fix #4173) 2024-02-02 17:52:58 -03:00
Martín Capello
0ae3a23066 Fix "ping-pong reverse" ordering of frames when exporting 2024-02-02 17:52:58 -03:00
Martín Capello
4d8fc12351 Adjust export dialog UI to support "Play Subtags & Repetitions" checkbox (fix #4173) 2024-02-02 17:52:42 -03:00
Martín Capello
d331195c4c Add "Alpha & Opacity" section to Preferences > Color (fix #1544) 2024-01-12 14:38:04 -03:00
David Capello
f178941f2c Fix crash copying, pasting, and transforming selection (fix #4249)
Regression introduced with 8722c8ec16
and d3562b140c.

Our re-entrant RWLock implementation is tricky because it doesn't
support to unlock in different order than it was locked.

E.g. If we create a DocWriter (e.g. paste command), and try to create
a DocReader (e.g. PixelsMovement) inside the DocWriter scope, the
reader will return a LockResult::Reentrant, but if we unlock the
write, then the reader cannot be used to upgradeToWrite() because the
lock will have just 0 locks (the re-entrant one didn't modify the
count of the RWLock). This is because it was thought that the
DocReader was going to be unlocked before the writer lock (in the
exact inverse order).

Basically these re-entrant RWLocks will not work fine if we mix up the
order of locks/unlocks in the same thread.
2023-12-29 17:22:10 -03:00
David Capello
8722c8ec16 Lock document in Tx() ctor (part of #2430)
This already fixes a lot of possible problems that can happen when a
script is running and modifying some part of a sprite that is being
backed up in a background thread.

We still need some work to being able to lock a sprite two or more
times in the same thread to write it. E.g. an app.transaction() should
lock the sprite for write access, but the script transaction function
could call a command, and that command could use a ContextWriter to
lock the sprite again. At the moment this is not possible because we
need a re-entrant RWLock implementation.
2023-12-27 11:05:15 -03:00
David Capello
e87fdbb3af [i18n] Add some hardcoded strings to en.ini (fix #4237) 2023-12-22 15:03:07 -03:00
David Capello
84187ad1ec Simplify strings for PaletteEditor command removing leading blanks
This issue was brought up here:
https://github.com/aseprite/aseprite/pull/4207#issuecomment-1845334373
2023-12-07 12:11:00 -03:00
David Capello
abba4684a7 Fix error messages about locked sprite when deleting multiple cels (fix #4204)
This is a combination when we modify a layer property and then
modify/delete several cels/frames/layers.
2023-12-06 12:47:52 -03:00
David Capello
0cc8769e29 Add tileset options when we convert a layer to a tilemap (fix #4158) 2023-11-22 14:37:27 -03:00
TakWolf
77ea4d40b8 Fix strings spelling typo: Difussion -> Diffusion. Notice, this is not compatible for translations. 2023-11-20 20:10:59 -03:00
David Capello
f92f14f261 Fix possible crash adding reference layer (fix #3949) 2023-11-13 10:51:19 -03:00
David Capello
62bdd8af9f Add "Advanced Options" checkbox in Tileset selector
To hide "Base Index" & "Allowed Flips" options by default.
2023-11-10 17:19:41 -03:00
David Capello
302d998218 Add support to match flipped tiles automatically in Auto/Stack modes
By default Aseprite will not try to match flipped versions of the
tiles (as it requires more CPU), but when we create a tileset we can
specify which flips can be matched automatically (new
Tileset::matchFlags() property).

These flags are just for the Auto mode, if we manually insert a
flipped tile, that is always supported, even when the matchFlags() are
not specified.
2023-11-09 16:44:46 -03:00
David Capello
78cda70ab6 Add support to flip/rotate tiles to ChangeBrush command (like #1222) 2023-11-09 16:44:46 -03:00
Dariy Guzairov
9772534ca5 Fix error message when attempting to delete layer in a group (fix #4083)
If the sprite contained only one layer group, and we tried to delete
one child, we got an error message about "You cannot delete all
layers". This fixes this (the error message is only when we delete the
last top level layer).
2023-11-06 16:23:59 -03:00
David Capello
ae3b2dd144 Revert timeline behavior to the v1.2 default (#4024)
This change was introduced in dd7e27a098
as a possible fix for #4024, but the change is too disruptive to be
introduced at this stage, we need some extra UI elements to make the
drag & drop accessible in both modes: the default v1.2 behavior, and
a possible new selection mode, e.g. #1498
2023-10-25 08:36:54 -03:00
Dariy Guzairov
ea35725c85 Fix disable delete layer button when only one layer exists (fix #3649) 2023-10-23 19:16:35 -03:00
David Capello
3f101d48d4 Add more accessible option to re-enable the Aseprite file dialog (fix #4051)
As now the native file selector is the default one, we moved the
option to re-enable the previous file selector to Edit > Preferences >
General > Show Aseprite file dialog option.

Related to #3615 and added as a simple alternative to #2745 which
require native widgets on each native file dialog.
2023-10-04 16:57:11 -03:00
David Capello
63fb39e0e8 Fix sprintf() warnings using snprintf() or fmt::format() 2023-09-27 19:57:41 -03:00