Commit Graph

86 Commits

Author SHA1 Message Date
Christian Kaiser af349ce7ee [lua] Fix new layers not going to the top when selected (fix #5364) 2025-09-04 12:02:10 -03:00
Martín Capello 3bc84cca53 Fix timeline scrolling when creating layer
Fix #4930
2025-04-22 21:54:22 -03:00
David Capello 09538f9a1a clang-format all files 2024-12-16 14:52:19 -03:00
David Capello b2c6240a7e Initial refactor to create the view module (#3904)
* Moved app::DocRange to view::Range
* Moved range_utils to view/cels.cpp
* Moved layer_utils to view/layers.cpp
* Created more functions in app::Site to access selected cels
  (they use the functions from view/cels.h)
2024-11-11 19:27:43 -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
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 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 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
Martín Capello 872267dc9b Avoid crash if the "New Layer" menu item is configured to ask the layer name 2023-06-27 15:24:13 -03:00
David Capello 6cbde57470 Add gridBounds parameter to NewLayer command 2023-04-19 13:25:54 -03:00
David Capello 83857ea600 Merge branch 'main' into beta 2022-08-17 22:58:12 -03:00
David Capello a66c170ded Add render::BgOptions to simplify some code 2022-08-17 22:40:25 -03:00
Gaspar Capello 12e59b887f Add remember new tilemap layer base index (fix #2735) 2022-08-04 14:30:11 -03:00
David Capello 46626bb5ce Merge branch 'main' into beta 2022-04-13 23:01:12 -03:00
David Capello 43513e0f1b Don't show tooltip when a new frame/layer is created from a script transaction
This might improve the performance of some scripts if it creates
several frames/layers at the same time.
2022-04-11 09:53:01 -03:00
David Capello 7e732b3223 Don't use cmd::TrimCel() on tiles when manual mode is enabled
Applied the fix from e1402381a8 to all
places where cmd::TrimCel() is used.
2021-02-22 16:39:40 -03:00
David Capello 26b75bdb57 Add option to specify/modify the tileset name 2020-11-10 17:48:09 -03:00
David Capello a3286fc20a Minor refactor "first visible index" -> "base index" 2020-10-30 20:58:45 -03:00
David Capello c2e5e69882 Simplify tilesets impl using tile index 0 = an empty tile
In this way we always have an empty tile available in the drawing
process. We've also added the Tileset::firstVisibleIndex field to
change the visible index of the tile 1 so we can offset the visible
number by the user (just as a visual aid / simulate old tilesets with
index=0=non-empty tile).
2020-10-30 16:33:34 -03:00
David Capello edebb57f66 Refactor clipboard code
* Moved all clipboard:: functions inside app::Clipboard class
* Convert app:📋:ClipboardFormat enum to
  app::ClipboardFormat enum class
* Added app::Context::clipboard()
2020-09-25 11:14:52 -03:00
David Capello 3623720dd4 Merge branch 'master' into beta 2020-08-18 11:05:37 -03:00
David Capello b355f34a70 Export all groups (even collapsed ones) by default in JSON metadata (fix #2484) 2020-08-17 17:14:12 -03:00
David Capello c86b4a28a6 Fix typo 2020-07-14 17:27:03 -03:00
David Capello a80af2b304 Merge branch 'master' into tilemap-editor 2020-05-18 20:24:22 -03:00
David Capello 46f4002368 Fix crashes saving sprites with '%' char in their filename
To fix this we changed the way StatusBar text is handled (we are using
fmt::format() in StatusBar instead of printf-like ... args now).
2020-05-08 17:39:55 -03:00
David Capello e56cc15326 Add possibility to use New Layer via Cut/Copy with ranges
Requested here: https://community.aseprite.org/t/5222
2020-04-17 16:13:22 -03:00
David Capello b628e21e76 Replace MIN/MAX() macros with std::min/max() functions 2020-04-08 12:20:53 -03:00
David Capello 12e1b4d934 Add dialog to create new tilemaps selecting the tileset specs 2020-02-17 09:06:01 -03:00
David Capello 26139c4ae2 Add tilemap layers (#977)
This is the first commit with a simple tilemap editor. Still buggy but
functional in several ways. Several changes were made:

* NewLayer command can receive a tilemap=true to create a new tilemap
  layer
* New ToggleTilesMode command added to switch between the palette and
  the tileset in the ColorBar (the ColorBar was expanded to show
  colors or tilesets with a generic AbstractPaletteViewAdapter)
* All commands to create new layers were moved to Layer >
  New... submenu
* There are a new tileset chunk to save tilesets in .aseprite files,
  and a new kind of cels to save tilemaps
* Added doc::LayerTilemap, doc::Tileset, etc. and several other types
  to handle tilesets/tilemaps in the doc layer.
* Added doc::Grid class with grid specifications that indicates how a
  tilemap <-> tileset must be drawn
* Added and expanded cel operations to work with tilemaps and
  conversions between regular LayerImage cels <-> LayerTilemap cels
  (e.g. copy cels in the timeline between layer types)
2020-02-17 09:06:00 -03:00
David Capello 1ae29dfc3c Check if the context can show the new layer name dialog 2019-07-10 12:45:53 -03:00
David Capello 757fadeaf0 Add New Layer via Cut/Copy commands (fix #1567) 2019-07-02 15:28:05 -03:00
David Capello a0ebecca50 Make NewLayerCommand compilable when ENABLE_UI is not defined 2019-06-28 18:53:23 -03:00
David Capello ff6538a68e Add Edit > Paste Special > Paste As New (Reference) Layer (fix #672, fix #1748) 2019-06-27 15:34:56 -03:00
David Capello 056eb28670 Fix crash destroying temporal docs (e.g. adding new reference layer) 2019-06-25 15:53:31 -03:00
David Capello 109e6fa205 Add render::Dithering() class to store all dithering parameters 2019-04-03 19:32:24 -03:00
David Capello fcf272bb69 Add amount parameter to Error Diffusion algorithm 2019-04-03 18:45:18 -03:00
David Capello 3c35887abf Specialize Params::get_as<bool>() to read "true" as a true bool
Just like new params impl Param<bool>::fromString()
2019-03-22 11:47:45 -03:00
Gaspar Capello f53544842c Fix non-normal blend modes when the backdrop is transparent (fix #1096) 2019-03-09 12:40:31 -03:00
David Capello 271865e13d Remove unused Command::clone() member function 2019-01-07 17:03:38 -03:00
David Capello 26d510fffd Support more commands without UI
- BackgroundFromLayer
- CelOpacity
- LayerFromBackground
- RemoveLayer
2018-09-06 14:18:59 -03:00
David Capello 853415332b NewLayer can be called in batch mode 2018-09-04 17:30:34 -03:00
Gaspar Capello 93d0b94929 Enhancement new layer below (issue #1822) 2018-08-30 13:31:48 -03:00
David Capello 70629d6f89 Use Tx instead of Transaction in commands 2018-08-20 16:00:59 -03:00
David Capello b83eddf2ea Fix uninitialized var 2018-08-16 12:30:23 -03:00
David Capello 9c79ea2b77 Rename app::Document -> Doc 2018-07-07 11:54:44 -03:00
David Capello ee5842cde3 Rename DocumentApi -> DocApi 2018-07-07 03:07:16 -03:00
David Capello e0a60b6748 Generate the list of command IDs from en.ini file 2017-12-01 15:10:21 -03:00