Commit Graph

9167 Commits

Author SHA1 Message Date
David Capello
10ea91cb52 Fix crash saving user brushes in unknown situations (fix #3728)
We've received crash reports where save_xml() throws an Exception()
because the user brushes file cannot be saved (open_file(..., "wb")
returns nlulptr). We're not sure why (probably privileges?) but at
least we fixed the exception.
2023-05-01 10:57:37 -03:00
David Capello
4d3575f4ce Fix crash when an extension adds a command in a non-existent menu group (fix #3835) 2023-05-01 10:50:53 -03:00
David Capello
bfe4669c0e [devmode] F1 key switches the renderer only when pressed w/o modifiers 2023-04-27 11:44:11 -03:00
Martín Capello
0958573cac Add canvas autoScaling feature (fix #3748) 2023-04-27 11:07:26 -03:00
David Capello
067309f776 Fix crash decoding huge .aseprite files
Now we don't allocate an huge temporal array of width x height x bytes
per pixel to store uncompressed data per image.

Reported by an user editing a 35000x35000 canvas. Similar to
https://community.aseprite.org/t/vector-too-long-empty-file-and-lost-work/6844

Internal report: https://igarastudio.zendesk.com/agent/tickets/4703
2023-04-26 16:30:04 -03:00
David Capello
1c75092e13 Fix crash w/double backToPreviousState() when the state after app.editor:askPoint() is canceled from the script 2023-04-25 19:55:32 -03:00
David Capello
9b76f95b15 Fix Left/Right keys to move through frames in FramesSelection context (fix #3821) 2023-04-25 10:38:49 -03:00
David Capello
a9207524ff Minor refactor in code to handle keys
Added CustomizedGuiManager::processKey() member function.
2023-04-25 10:30:39 -03:00
David Capello
f655d57069 [lua] Add app.editor.spritePos/mousePos and app.editor:cancel()
Added properties needed to know where the mouse position is on the
editor canvas + a method to cancel app.editor:askPoint() from Lua.

Related to aseprite/Attachment-System#102
2023-04-25 09:03:20 -03:00
David Capello
2baf291b4a [lua] Add "point" argument to app.editor:askPoint() for initial point
Related to aseprite/Attachment-System#102 and could be used for
aseprite/Attachment-System#103
2023-04-24 23:11:09 -03:00
David Capello
72dbcf51d1 [lua] Add onchange event to app.editor:askPoint()
Related to aseprite/Attachment-System#102
2023-04-24 22:48:30 -03:00
David Capello
ff4d60bd09 [lua] Add app.editor:askPoint() (fix aseprite/Attachment-System#102) 2023-04-20 11:14:14 -03:00
David Capello
d7af7f4312 [lua] Add new app.editor object (fix aseprite/Attachment-System#104) 2023-04-19 19:10:28 -03:00
David Capello
622b02294a [lua] Add short field names (fix #3815, fix #3816) 2023-04-19 13:48:15 -03:00
David Capello
6cbde57470 Add gridBounds parameter to NewLayer command 2023-04-19 13:25:54 -03:00
David Capello
1c6e583c87 [lua] Add require() function (fix aseprite/api#10)
This is the first attempt to finally implement the require() function
on Lua. The main problem was how to solve conflicts between plugins
that use the same library name. Here we separate each plugin like in a
namespace, so require(name) inside a plugin will save the module in
_LOADED["pluginName/libraryName"] to avoid conflicts with other
libraryName from other plugins.
2023-04-18 19:41:01 -03:00
David Capello
8ff62f7a5f [lua] Add Uuid tests
Missing file from 636cce6f0d commit
2023-04-18 07:41:32 -03:00
David Capello
f0e80f1b5a Fix failing ASSERT(i >= 0 && i < int(m_states.size())) in ListBox::selectChild()
We receive kMouseMoveMessage as the first message of a multiselect
message in a ListBox when the kMouseDownMessage message is received by
a separator first e.g. if we click a separator from the Recover Files
tab and start dragging the mouse this assert was failing.
2023-04-17 22:32:22 -03:00
David Capello
79745756ef Fix bug removing submenu-groups inside menu-groups created by plugins
Before this the ASSERT(group.items.empty()) in
AppMenus::removeMenuGroup() was failing when a plugin created
subgroups/submenus inside groups.

We have to remove plugins items in the reverse order that they were
added to uninstall them correctly.
2023-04-17 20:12:31 -03:00
David Capello
172e1a615b Respect z-index layer ordering when there are empty cels
An empty cel must be counted as a layer for the z-index ordering, so
the z-index refers to number of layers to move back/front, but number
of non-empty cels in the specific frame.

A this fix, a new issue appears: #3820
2023-04-17 19:24:20 -03:00
David Capello
2962bb3676 Fix save-as-with-slice CLI test as output files are listed in order 2023-04-14 14:05:51 -03:00
David Capello
b28550faf5 Use new ScopedValue w/o old arg + C++17 class template argument deduction (CTAD) 2023-04-14 13:43:36 -03:00
Gaspar Capello
d4d18c99be [lua] Add Image:clear(Rectangle, color) overload (fix #3799)
We can use:

  Image:clear()
  Image:clear(color)
  Image:clear(rectangle)
  Image:clear(rectangle, color)

If the color is not specified it will be the transparent color of the
image.

Co-authored-by: David Capello <david@igara.com>
2023-04-12 15:30:12 -03:00
David Capello
89ced2e557 Add test for -save-as {slice} (#3801, #3802)
Original report: https://community.aseprite.org/t/17692
2023-04-12 15:11:37 -03:00
Gaspar Capello
17b976b3aa Fix regression {slice} format on CLI doesn't work (fix #3801) 2023-04-12 15:00:40 -03:00
Martín Capello
8841f3da32 Move window relayout before inserting the window to the manager (fix #3746)
This is necessary to prevent the manager to invalidate a window whose relayout is not finished. This can happen when a script opens a new window when another is currently opening. For instance a script whose canvas.onpaint handler opens another dialog.
2023-04-12 14:10:45 -03:00
David Capello
636cce6f0d [lua] Add Uuid type (fix #3809) 2023-04-12 13:51:37 -03:00
David Capello
7104a1a449 F2 renames the layer if a range of frames is not selected (fix #2326)
In this way we can use F2 to:

1. Set the Loop section if two or more frames are selected
2. Remove the loop section if only one frame is selected
3. Rename the active layer if the layer is selected (or no frames are selected)
2023-04-11 19:04:45 -03:00
David Capello
24846eae10 Add z-index property to cels (fix aseprite/Attachment-System#88)
* Now a Cel has a z-index property to change the order of layers per frame
* A new doc::RenderPlan class can calculate the order of cels to be rendered
* z-index is saved as a int16_t in the .aseprite files
* This new field can be set/get from Lua with Cel.zIndex
2023-04-10 19:23:16 -03:00
David Capello
e38398d7aa Fix compilation when ENABLE_DEVMODE is disabled
We don't compile ShaderRenderer in production yet.
2023-04-07 21:36:04 -03:00
David Capello
538219f655 Fix warnings about unused members w/ImageIteratorT
Mainly when compiling src/doc/algorithm/rotate.cpp
2023-04-07 21:11:56 -03:00
David Capello
4f80008ea7 Merge branch 'gpu' (#3516, #3523)
An initial implementation (not yet ready for production) of the
ShaderRenderer to use SkSL shaders to convert indexed -> RGB, and draw
SkImages directly on SkCanvases (this will enable future GPU
acceleration).
2023-04-07 20:35:07 -03:00
David Capello
da9f334214 Fix FullscreenPreview for SimpleRenderer
The SimpleRenderer outputs unpremultiplied RGB values when we render
in a transparent background, we have to indicate that to Skia now that
we're compositing os::Surfaces (SkiaSurfaces) directly in this
FullscreenPreview command.
2023-04-07 20:26:16 -03:00
David Capello
be11e3b324 Recreate console window to print log messages if it was closed by the user
Regression introduced cc7da16691 when
the Console was converted to a non-modal window. If a script prints
something, the console is displayed, then the user can close the
console, and if the script tried to print something else the console
window wasn't displayed again until some other command was
executed (any command that called the Console::Console() constructor
which would create the ConsoleWindow again).

With this fix the console window is recreated/displayed again on the
screen.

This bug was well-known (but I think never reported yet) and probably
the possible source of the #3787 issue.
2023-04-05 18:26:15 -03:00
David Capello
264ee71b00 Add comment to improve Image_drawImage/convert_args_into_point() interaction in the future 2023-04-05 12:43:24 -03:00
Gaspar Capello
2b3372df0e Fix backward compatibility with Image:drawImage(image, x, y) was broken (fix #3788) 2023-04-05 12:00:42 -03:00
Martín Capello
e577852eb4 Improve message error when loading a sequence of png files whose color modes don't match (fix #3751) 2023-04-05 11:57:34 -03:00
Martín Capello
7422abf490 Ignore empty tiles when exporting tilesets and the "Ignore Empty" checkbox is checked (fix #3789) 2023-04-04 11:12:28 -03:00
David Capello
7b6187ada3 Minor changes before the merge with main
Added some extra comments + compile ShaderRenderer only when
ENABLE_DEVMODE is enabled.
2023-04-03 20:15:38 -03:00
David Capello
4fedc59f29 Fix render_tests setting the new BgOptions::colorPixelFormat field 2023-04-03 20:00:45 -03:00
David Capello
da0a8b7916 Show GPU option only in DEVMODE
We've update the label "GPU acceleration" to avoid confusion between
developers so they know that this option is not enabled in the final
release.
2023-04-03 16:09:26 -03:00
David Capello
7781ff69a1 Add support to render grayscale sprites with ShaderRenderer 2023-04-03 15:59:29 -03:00
David Capello
9e08386a28 Add support to render indexed images
For this we need a new SkSL shader that receives the palette and the
indexed image data and outputs the RGBA values for each fragment.
2023-04-03 15:59:29 -03:00
David Capello
af074fd6bf Add support to render tilemaps 2023-04-03 15:59:29 -03:00
David Capello
ef6f80221e Add preview image support in ShaderRenderer
In this way we can see the real-time feedback when we're drawing when
we use the ShaderRenderer.
2023-04-03 15:59:29 -03:00
David Capello
3dbf88c9cd Ignore hidden layers in ShaderRenderer 2023-04-03 15:59:29 -03:00
David Capello
8c7b94a934 Add support to render the background directly on screen
Renderer::renderCheckeredBackground() function was used only for the
FullscreenPreviewCommand, but now we use
ShaderRenderer::renderCheckeredBackground() to render the background
in the Editor too. So the sprite is painted in a backbuffer and then
composited with the already painted background using
Graphics::drawSurface().
2023-04-03 15:59:29 -03:00
David Capello
3c099dc4dc Add support to cel/layer opacity + some blend modes 2023-04-03 15:59:29 -03:00
David Capello
f621472b7c Draw cels creating a SkShader from SkImage directly from the doc::Image data 2023-04-03 15:59:29 -03:00
David Capello
be583f8149 Add initial (incomplete) version of ShaderRenderer
This new renderer uses a shader to paint only the checkered
background. It can be tested only in ENABLE_DEVMODE and pressing F1
key to switch between the renderers (which is a devmode special key
for testing purposes only)

We've changed the Renderer::renderSprite(Image*, ...) member function
to renderSprite(os::Surface*, ...) so we receive the os::Surface
directly to paint the SkCanvas with a SkShader. Probably more
refactors will be needed.
2023-04-03 15:59:29 -03:00