Commit Graph

101 Commits

Author SHA1 Message Date
David Capello 40031f83d8 [lua] Fix typo in Sprite:newCel() error 2025-08-13 13:06:05 -03:00
Christian Kaiser 80fa065bd5 [lua] Add sprite.undoHistory
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-25 13:58:52 -03:00
Martín Capello ba5adcaa7d Change uuidsForLayers by useLayerUuids 2025-04-22 12:42:12 -03:00
Martín Capello 9e35fd817a [lua] Add uuid field to layers (fix #5033) 2025-04-22 12:42:12 -03:00
David Capello a4e0636c9f [lua] don't allow to set invalid pixel ratios (fix #3285) 2025-02-19 17:19:27 -03:00
Gaspar Capello 26f6a210b6 Fix crash with custom pixel ratios (e.g. Size(4, 3)) (fix #4632)
Prior this fix some custom pixel ratios + old render engine +
zoom level <= 50% resulted in crashes.
2025-02-19 15:47:16 -03:00
David Capello b2e4f78b69 clang-format all files 2024-12-16 10:10:34 -03:00
دانتي باولا b40614ca36
Use FlattenLayers for MergeDownLayerCommand (#4643)
Rework of the cmd::FlattenLayers implementation to accommodates the
'Merge Down' command as a special case.
2024-09-20 17:25:09 -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 557b22a719 [lua] Sprite:newTileset() uses sprite grid size by default (fix #4116) 2023-10-30 13:45:11 -03:00
David Capello bb60da8c60 [lua] Make Sprite:newTileset(Rectangle) work (fix #4117) 2023-10-30 13:40:12 -03:00
David Capello 43079b226d [lua] Limit the possibility to create a tileset with origin != 0,0 (fix #4118) 2023-10-30 12:35:08 -03:00
David Capello 64ce25fae2 Add property to disable the standard tilemap UI
Added a Sprite.tileManagementPlugin property for plugins that want to
replace the standard tilemap/tileset interface. This includes a new
external file field in .aseprite files to specify that the sprite
tiles are controlled by a specific plugin.

Once this property is set, the standard tilemap/tileset modes
selectors will disappear and the only way to make then available will
be setting this property to nil/empty string again.

Fix https://github.com/aseprite/Attachment-System/issues/21
2023-02-15 18:55:21 -03:00
David Capello 0775b0d8ba Take care of an empty tileset in doc::Tilesets collection
We cannot delete a tileset yet from Aseprite UI, but now an extension
can do it through Sprite:deleteTileset(). Deleting the non-last
tileset will create an Tilesets array with an empty (nullptr) slot on
it (so tileset indexes are not changed, and for the future, if some
external file is referencing that tileset index, the reference will be
kept).

Related to https://github.com/aseprite/Attachment-System/issues/19
2023-01-17 17:49:21 -03:00
Gaspar Capello e0aaa76e9c Add warning to Sprite:newTile() and Sprite:deleteTile()
Now, if the tileset does not belong to the sprite object, the lua engine throws an error. Also added a warning when tile_index = 0 on Sprite:deleteTile()
2023-01-16 10:42:31 -03:00
David Capello 9678cc4ac3 [lua] Alternative Sprite:deleteTile(tileset, tileIndex) syntax 2023-01-12 09:32:44 -03:00
Gaspar Capello 822357869a Add new/delete tiles from a tileset using Lua (fix #3663) 2023-01-11 10:23:52 -03:00
Martín Capello c299be50a5 Add a way to create and delete tilesets using Lua 2023-01-11 10:02:20 -03:00
David Capello 8aa49479b8 [lua] Add Sprite.id and Layer.id properties 2023-01-05 16:01:42 -03:00
David Capello e2024c6edd [lua] Add "properties" property to all objects with user data 2023-01-03 09:00:58 -03:00
David Capello 76a398b162 [lua] Add access to user data properties in Sprite object (aseprite/api#88)
This is a basic implementation where we can only access basic
properties (not maps or vectors yet).
2023-01-02 12:54:37 -03:00
David Capello 38c0400927 Fix Doc::isModified() when we are in a similar UndoState to the saved one
If the current UndoState doesn't modify the "saved state" (e.g. there
is a sequence of undoes/redoes that doesn't modify the saved version
of the sprite compared to the current one), we can indicate that we
are in the saved state anyway (!Doc::isModified).
2022-11-02 09:58:18 -03:00
David Capello f8f925c634 Merge branch 'main' into beta 2022-07-13 19:49:03 -03:00
David Capello 7aa90db770 [lua] Add undo information in Sprite:newSlice() (fix #3393) 2022-06-29 19:46:37 -03:00
David Capello 684d06ede8 Merge branch 'main' into beta 2022-05-23 18:04:55 -03:00
David Capello fd430603a0 [lua] Allow to compare different docobj types without failing (fix #3218)
Just return false if we compare a layer with a sprite, etc.
2022-05-23 17:15:15 -03:00
David Capello 1f4e3bcd11 Merge branch 'main' into beta 2022-02-08 12:56:26 -03:00
Gaspar Capello 653931c4fc [lua] Add a warning message deleting objects that are not part of the sprite (fix #3135)
Before this fix, the Sprite:deleteLayer/Slice/etc() Lua functions
didn't warn the user if its argument (a layer/slice/etc) didn't belong
to the corresponding sprite.
2022-02-03 11:02:55 -03:00
David Capello db44eeb269 Merge branch 'main' into beta 2021-10-12 10:45:33 -03:00
David Capello b9241e6d91 Refactor ask_access() with ResourceType argument 2021-10-07 19:34:40 -03:00
David Capello cd342f5630 [lua] Add events handling with Sprite.events & App.events
Added a new Events object with :on() and :off() methods to start or
stop listening to a specific event respectively. This also allows to
add several callbacks for the same event.

Replaced the temporal Site.onChange & Sprite.onChange implementations.

Related to several issues (enable more possibilities for): #138, #1403, #1949, #2965, #2980
2021-10-07 18:56:39 -03:00
lampysprites 2628afdfce Remove unneeded Sprite.__gc 2021-10-04 23:15:55 +07:00
lampysprites bf53fa26cd Make onChange callbacks more predictable 2021-10-04 12:17:25 +07:00
lampysprites 28595a410d Clean up sprite observers on lua GC 2021-10-02 22:10:25 +07:00
lampysprites 22e3e6244a Simplify user API for Sprite observers 2021-10-02 16:22:31 +07:00
lampysprites 85f3164e21 Expose DocObserver to the scripts 2021-09-29 22:39:01 +07:00
David Capello c42c5e1453 Backport new laf API to main branch of aseprite
Some features from the beta branch of aseprite & laf were backported
to the main branch of aseprite.

Related commits:
- New memory handling (db4504e816)
- New get event with timeout (e6ec13cc31)
- Convert os::NativeCursor to an enum (06a5b4f3ae)
- Adapt code to the new os::Display -> os::Window refactor (5d31314cdb)
- Save/load main window layout correctly and limit to current workarea (d6acb9e20f)
- Redraw window immediately on "live resizing" (d0b39ebade)
2021-07-05 17:51:29 -03:00
David Capello a012dac020 Merge branch 'main' into beta 2021-04-12 17:11:28 -03:00
David Capello 3769d91125 [lua] Add Sprite.pixelRatio property
Feature request: https://community.aseprite.org/t/8627
2021-04-09 16:22:50 -03:00
Gaspar Capello 54ae195159 [lua] Add support to sprite user data 2020-12-16 12:40:21 -03:00
David Capello d8f6c666de Merge branch 'beta' into tilemap-editor 2020-07-30 16:49:17 -03:00
David Capello 20d763ca4b Merge branch 'master' into beta 2020-07-30 16:48:43 -03:00
David Capello 7a534b0a4e [lua] Add Sprite{ fromFile="...", oneFrame=true } to load just one frame 2020-07-28 17:41:01 -03:00
David Capello 4dfed179fb [lua] Fix crash undoing Sprite:newCel() in background layers 2020-07-22 14:19:11 -03:00
David Capello 515dace441 Merge branch 'beta' into tilemap-editor 2020-07-13 17:32:42 -03:00
David Capello db4504e816 Refactor laf-os memory handling 2020-07-07 19:06:48 -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 30b2585037 Save grid bounds inside .aseprite files and doc::Sprite (fix #688) 2019-10-10 15:08:59 -03:00
David Capello 1c8b8051a8 Rename FrameTag -> Tag 2019-10-01 14:55:08 -03:00
David Capello cbd3ee2cd7 [lua] Fix Sprite:resize() to resize non-active sprite 2019-09-11 19:19:58 -03:00