Commit Graph

7935 Commits

Author SHA1 Message Date
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
Gaspar Capello
12d8135264 Fix secondary color with custom brush paints the FgColor instead the BgColor (fix #4013)
Before this fix to change the main color of the image brush,
it was necessary to choose a new color from the palette.
The secondary color can now also be used.

Also added some tests for image brushes.
2024-04-29 17:20:56 -03:00
David Capello
e48e71ba28 Update to tinyxml2 2024-04-22 18:28:03 -03:00
David Capello
4d18200b0c [lua] Fix bugs handling errors inside app.transaction()
This errors was reported in #4431: The Tx wasn't rolled back correctly
in case of a Lua error inside the transaction because Lua needs to be
compiled as C++ to avoid longjmps and support stack
unwinding (i.e. calling destructors).
2024-04-22 11:13:10 -03:00
David Capello
0b55dcdb3a [lua] Close stdin handle when we start running the GUI 2024-04-21 22:37:51 -03:00
David Capello
cd211ba0fd [lua] Ask permissions for io.lines/input/output functions 2024-04-21 14:31:17 -03:00
David Capello
7172de5007 [lua] Use internal variables to store ptrs to original unsecure functions
Instead of using Lua upvalues/closures.
2024-04-21 13:25:56 -03:00
David Capello
53bb6aceec [lua] Disable loadfile() without args in GUI mode
Waiting for stdin input will hang the program.
2024-04-21 13:14:09 -03:00
Gaspar Capello
99e6e7bd82 Fix nested tag with "Ping-Pong" repeat mode causes to skip the first frame of the parent tag (fix #4271) 2024-04-12 10:41:18 -03:00
David Capello
d886e20f6c [lua] Secure io.popen() access (and enable popen on Linux) 2024-04-10 12:01:29 -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
4d5bf53be8 Fix crash accessing empty list of sprites updating ContextBar fields (fix #4407)
Not sure if this will be the final solution for this crash, as a Doc
shouldn't have an empty list of sprites.
2024-04-08 10:44:44 -03:00
David Capello
e21859c4af Migrate clip module from aseprite to laf 2024-03-26 13:31:22 -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
427ee6f5b5 Use target_sources() instead of variables to list app-lib sources
target_sources() was added on cmake 3.1, long time ago, although we
started with the 2.6 versions, so now we can modernize the cmake file
a little.
2024-03-19 16:04:50 -03:00
Charles Bradley
571a3965e9 Fix copy+move cursor icon bug (fix #3887)
Add logic to show the correct curson icon when holding the
  copy key (alt) while hovering over a selected layer.
2024-03-15 11:47:04 -03:00
David Capello
e129fefb2e Hide "Play subtags" option in File > Export if there are no tags (fix #4308) 2024-03-12 15:54:05 -03:00
David Capello
30f55d196b Show "Apply pixel ratio" option in File > Export only when needed (#4308)
If the sprite doesn't have a custom pixel aspect ratio configured
there is no need to show this option.
2024-03-12 15:14:45 -03:00
David Capello
a0e469624a Use make_shader() helper function to create ColorSelector shaders 2024-03-11 17:48:11 -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
b8514ad1c6 Add helper functions make_shader(), make_skimage/skcanvas_for_docimage()
These functions can be used to create a new Skia shader from SkSL
code, and a new SkImage/SkCanvas to modify a doc::Image*
2024-03-11 10:34:05 -03:00
David Capello
50d4f9d802 Don't try to clone strings repo if Git isn't available (fix #4357)
This can happen when the source code is downloaded as a .zip and the
Git command is not available to clone the strings repo.
2024-03-06 09:59:20 -03:00
David Capello
4584d67b69 Update modules 2024-03-05 19:39:50 -03:00
David Capello
cfb663f820 Some fixes to readability-else-after-return 2024-02-29 10:26:47 -03:00
David Capello
32bdb3a695 Minor rename of header guard
In this way we avoid problems with clang-tidy and defined identifiers
that starts with __
2024-02-28 21:10:07 -03:00
David Capello
4ea0390623 Add [[nodiscard]] to Tx as we have to create an instance of Tx when we use it 2024-02-28 21:09:23 -03:00
David Capello
83d83cd8c6 Add const to lock_guards 2024-02-28 12:32:08 -03:00
David Capello
32a1b327a6 Fix typo 2024-02-28 10:16:36 -03:00
David Capello
edc248d418 Removing some unnecessary #includes 2024-02-28 10:16:11 -03:00
David Capello
7aca017a58 Fix use-after free in ase_ungroup_all()
Anyway this code is not used anymore, it was for v1.1 when v1.1 and
v1.2 branches were developed at the same time (layer groups feature
was added in v1.2, so v1.1 just moved groups children to the root).
2024-02-27 13:20:13 -03:00
David Capello
b813c1ad5f Fix regression introduced in 9e2728992d
Some info here:
https://github.com/aseprite/aseprite/pull/4299#discussion_r1503955328
2024-02-27 10:45:26 -03:00
Gaspar Capello
9e2728992d Fix slice tool doesn't work correctly in a tilemap layer when we are in Manual mode (fix #4290) 2024-02-27 10:43:44 -03:00
Martín Capello
7b9594f4e0 Avoid moving the playback cue when decrementing a ping-pong tag's repeat field that has only one frame (fix #4336) 2024-02-26 22:07:31 -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
a2b294b0fe Add final modifier to ToolLoopImpl to avoid clang-tidy warning
The warning is about using a virtual member function in the destructor
where it can be overridden by a derived class so in this case the
derived version wouldn't be called.

Just testing clang-tidy to see if we can add something in the CI.
2024-02-26 15:32:40 -03:00
David Capello
5dbaa295c5 Revert "Drop selection if we hide the layer (fix #4179)"
This reverts commit 078dac28d7.
2024-02-26 10:13:07 -03:00
Gaspar Capello
f22603caea Fix crash when trying to access a property of a Style which is nullptr (fix #4015)
Before this fix, an incomplete custom theme or an outdated official
theme could cause a crash during Aseprite startup.

This fix does not alert the artist the problem of the theme.
Simply avoid the crash.
2024-02-26 10:07:44 -03:00
Gaspar Capello
078dac28d7 Drop selection if we hide the layer (fix #4179) 2024-02-26 09:51:36 -03:00
David Capello
6ab2731fad Remove verbosity in .exe file description on Windows (fix #4333) 2024-02-23 20:00:01 -03:00
David Capello
10dda30a15 Don't write color2 chunk for files with more than 256 colors (fix #4322)
We were incorrectly saving a wrong number of entries for palettes with
more than 256 colors in color2 chunk, anyway it doesn't make sense to
use this chunks as it doesn't support more than 256 colors. So we
removed it for this case.

We've also removed the palette chunk for cases where it's not required
at all, e.g. when we have less than 256 colors and doesn't have alpha
channel, it makes sense to use the color2 chunk as it's smaller in the
output file.
2024-02-22 19:46:34 -03:00
David Capello
0d5075ff93 Add -noinapp option to disable Steam "in game" visibility (fix #4314)
Some minor changes in this commit includes the usage of
std::unique_ptr for the Pimpl-idiom in steam::SteamAPI class and
renaming the SteamAPI::initialized() to SteamAPI::isInitialized() to
avoid confusion reading the code.

Forum post:
https://steamcommunity.com/app/431730/discussions/2/7260435303111061192/
2024-02-21 12:47:27 -03:00
David Capello
5337a728be Fix platform version for Windows 10/11
Now we include the 10.0 + the build number in the version.
2024-02-20 18:08:46 -03:00
David Capello
d70801e88b Throw a bad_alloc when there is not enough memory for ImageBuffer (fix #4316)
Fix regression introduced in aeeef8e255
when we replaced the std::vector with aligned memory allocations (or
just malloc/free).
2024-02-19 11:21:53 -03:00
David Capello
0134c74926 Fix gcc error: expected primary-expression before ‘unsigned’ 2024-02-16 14:49:41 -03:00
David Capello
644b0021fb Replace ’ unicode char with ' for news description 2024-02-16 14:10:16 -03:00
David Capello
9be7c66376 Add possibility to paste as new file from clipboard on Home tab
Feature request:
https://community.aseprite.org/t/pasting-on-home-screen/21476
2024-02-16 12:40:00 -03:00
Gaspar Capello
243982ab78 Fix identify running Aseprite processes correctly to recover crashed sessions (related to #4130)
Prior to this fix, Aseprite was hiding some sessions to recover,
resulting in additional support for users.
To display available recovery sessions, Aseprite only checked if
the session belonged to any running process on the OS via the
'pid' number.
2024-02-15 12:10:09 -03:00
David Capello
14696de980 [lua] Update API version 2024-02-12 18:53:15 -03:00
David Capello
12623176bb Fix copying our en.ini file to strings.git clone 2024-02-12 16:55:31 -03:00