Commit Graph

49 Commits

Author SHA1 Message Date
Martín Capello 1227f9c49c Refactor getLayerIndexFromSprite into LayerGroup 2025-08-11 14:47:56 -03:00
Martín Capello 7a03e45475 Generate UUIDs for Layers lazily 2025-02-24 11:12:54 -03:00
Martín Capello 86ad09291f Add UUIDs to layers 2025-02-24 10:10:28 -03:00
David Capello 09538f9a1a clang-format all files 2024-12-16 14:52:19 -03:00
Martín Capello 6f9b10f9fb Fix LayerImage::getMemSize
Now it doesn't count more than once the memory used by the layer's cels
2024-10-16 15:35:19 -03:00
Martín Capello 114a18bc4f Move static funcs from Layer class to layer_utils
Also refactor the code to make these functions use the current
copyLayerContent function in app::Doc and make an actual copy of the
specified layer
2024-10-16 10:42:56 -03:00
Martín Capello e5bf9cb253 Add LayerGroup::insertLayerBefore 2024-10-15 16:24:41 -03:00
Martín Capello b110078a8b Add static methods to copy a layer 2024-10-15 16:24:41 -03:00
Guilherme Belchior ffc3684b1b Compose groups separately from all other layers
Maintain hierarchical structure of sprite groups instead of flattening.
Allows opacity and blend mode to be applied correctly to groups.
Sets the foundation for future features like mask layers.

Note:
Requires full image rendering and impacts performance in some scenarios.
Avoids complex code changes for minor performance gains.

Co-authored-by: Guilherme Marcondes <guilherme.marcondes@tecnico.ulisboa.pt>
2024-06-24 18:16:42 -03:00
requizm aa152963d4 [cli] Add -list-layer-hierarchy option
Example output:
group1/
  layer1.1
  layer1.2
  group1.1/
    layer1.1.1
group2/
  layer2.1
2024-06-06 11:30:01 -03:00
Martín Capello 5bc432f289 Delete unused tilesets after deleting tilemaps (fix #3876) 2023-06-27 15:24:13 -03:00
David Capello ae904428fa Merge branch 'main' into beta 2021-04-08 16:15:02 -03:00
David Capello f3ab779bfd Don't transform hidden layers (fix #2680) 2021-04-08 11:24:55 -03:00
David Capello 91628daa9d Merge branch 'master' into beta 2020-12-22 15:48:15 -03:00
David Capello 85e51abcaa Minor changes about old "layer set" -> "layer group" 2020-11-27 19:26:18 -03:00
David Capello b1c0d80356 Add support to clear/fill/stroke selections in tiles mode 2020-08-27 20:32:22 -03:00
David Capello 7319309630 Merge branch 'master' into tilemap-editor 2020-03-17 00:25:24 -03:00
David Capello 53cb226f09 Fix crash using Flatten Visible when the active layer is a child of a group 2020-02-25 14:12:20 -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 1c8f2cde7d Fix bug: removing frames weren't saving updated cel frame positions in the backup info 2018-07-04 13:38:54 -03:00
David Capello 4d885b5b8a Use old render engine when there are visible ref layers in zoom > 100% 2018-06-28 16:56:35 -03:00
David Capello afdb6b511f Fix all commands using uniqueCels() (sprite size, rotate/flip sprite, etc.)
We have to iterate all layers on commands that modify the whole
sprite. It doesn't matter if the layer is "browsable" (e.g. it's
expanded or collapsed).
2016-12-08 09:11:54 -03:00
David Capello bc939d5638 New eyedropper mode to pick colors from reference layers 2016-10-13 21:19:25 -03:00
David Capello f2f1c1008b Add support to move/copy non-adjacent layers/frames
Changes:
* With this patch we finally removed the LayerIndex class and member
  functions to access layers by index (like Sprite::firstLayer/layerLayer
  /layer/indexToLayer/layerToIndex() etc.). As layer groups can be
  expanded/collapsed, it doesn't make sense to use layer index to
  access layers directly from sprite.
* Now we use a layer_t (int) to access a list of browsable layers each
  time we want to iterate visible layers in the timeline.
* Replaced CelsRange() and Sprite::uniqueCels() param with
  SelectedFrames to iterate non-adjacent cels.
* Updated clipboard operations (copy/paste) in timeline to support
  layer groups.
* Updated Timeline control to support selecting multiple layer/frame
  ranges with Ctrl+ or Alt+click (fix #1157)
* Added more test units for DocumentRange operations (mainly for
  non-adjacent ranges).
2016-08-25 12:31:00 -03:00
David Capello e5ef4be54a Add allLayersCount() to LayerGroup and Sprite
This will give us the total number of layers + children.
2016-08-11 14:53:51 -03:00
David Capello 7b55037abb Replace LayersRange with Sprite::all*Layers() members 2016-06-21 12:02:31 -03:00
David Capello 0f77bf0712 Move selected layers into the new group
If the Timeline has an active selected range of layers and the user
creates a new layer group, the selected layers will be be grouped as
children of the new layer 'group'.
2016-06-21 00:02:13 -03:00
David Capello 139b8f6d74 Fix goto next/previous layer for multiple group levels 2016-06-20 21:15:35 -03:00
David Capello ebb6825b87 Don't enter in collapsed groups with GotoNext/PrevLayer 2016-06-15 15:49:39 -03:00
David Capello ac20d1edfc Fix some commands/editor states to check parent group editable/visible state too 2016-06-15 15:27:38 -03:00
David Capello 5e89ab3148 Fix GotoNext/PreviousLayer for groups 2016-06-14 15:00:11 -03:00
David Capello 58f8ed6476 Prefer LayerGroup::layers() instead of iterators 2016-06-08 16:46:15 -03:00
David Capello 2f91122c26 Rename layer folder/set -> layer group 2016-06-07 19:38:56 -03:00
David Capello 08bef859e3 Add user data field on layers and cels 2015-12-10 18:34:25 -03:00
David Capello a9c3f82c11 Use a binary search to find cels in LayerImage 2015-09-15 08:18:52 -03:00
David Capello 510a686020 Change CelList and LayerList from std::list to std::vector
This change gives us an huge performance improvement to paint the
Timeline widget.
2015-09-14 17:37:21 -03:00
David Capello 8f891a4e25 Add asserts to detect bugs adding cels w/pixel format != sprite's pixel format 2015-07-27 12:40:02 -03:00
David Capello 6a829727b7 Fix initialization order of LayerImage members 2015-06-23 11:25:00 -03:00
David Capello fb4b2e76c8 Add layer opacity property (fix #225) 2015-06-14 20:23:49 -03:00
David Capello 21ca87862c Add layer blending modes (fix #318)
- Added doc::BlendMode enum and doc::BlendFunc type
- Renamed LayerImage::getBlendMode() -> blendMode()
- BLEND_MODE_COPY is BlendMode::SRC now
- BLEND_MODE_NORMAL is BlendMode::NORMAL now
- Added app::cmd::SetLayerBlendMode
2015-06-13 21:29:16 -03:00
David Capello 7da6f3e857 Minor changes to some #include header files 2015-03-05 12:40:47 -03:00
David Capello 3ebb708000 Add CelData to share image/position/opacity between linked cels
Changes:
- Merged app::cmd::ObjectIO into doc::SubObjectsIO
- Changed app::cmd::SetCelImage with app::cmd::SetCelData
- Added Cel::createCopy/Link() to avoid confunsion with Cel copy ctor
- Renamed Sprite::getImage() -> getImageRef()
- Added Sprite::getDataCelRef()
- Added doc::CelsRange helper to iterate cels
- Added Sprite::cels()/uniqueCels() member functions (removed
  Sprite::getCels())
- Added DocumentRange::convertToCels()
2015-02-09 11:40:43 -03:00
David Capello e55865843e Replace undo impl: replace undoers with cmds
Undoers were little objects to swap/revert an action. They didn't
execute the action itself, they just revert its previous state. Now
undoers were replaced with cmds: A cmd is an object that
executes/undoes/redoes just one action.

Changes:
* Remove old undo library and app/objects_container_impl.cpp
  (now we use the doc::ObjectId directly to store undo info)
* Remove all Undoers from app/undoers/
* Replace DocumentApi impl with little Cmds in app/cmd/, these
  cmds handle execute/undo/redo of each action at the logic layer
* Remove doc::Dirty object
* Remove doc::Settings: all undo configuration is in the app side
* Move undo options from app:ISettings to app::Preferences
* Rename UndoTransaction to Transaction
* Create a CmdSequence to store a sequence of Cmds (as now the new
  undo library doesn't support open/close groups)
* Add doc::get<T>(ObjectId) function to get any kind of object
  from the doc library by its ID
* Add Cel::document() and Sprite::document() members
* Add Sprite::cels(frame_t) to get all cels in the given frame
* Add Layer::displaceFrames() member function
* Move the "allow non-linear history" flag from undo2::UndoHistory
  to app::DocumentUndo
2015-01-18 22:05:33 -03:00
David Capello f1f24cbcdd Replace doc::Stock with doc::ImageRef shared pointer
Changes:
* Add doc::ImageRef to count references to the same image between Cels
  (at this moment we cannot generate linked cels anyway)
* Remove doc:Stock class and doc::Sprite::m_stock member variable
* Remove app::undoers::Add/RemoveImage
* Add doc::SubObjectsIO and app::undoers::ObjectIO to
  replace doc::LayerSubObjectsSerializer
2015-01-04 10:58:14 -03:00
David Capello 603dde343f Replace doc::LayerImage::getCel() with doc::Layer::cel() 2014-12-28 21:04:08 -03:00
David Capello 06d18f1e8a Replace doc::FrameNumber with doc::frame_t 2014-12-28 20:39:11 -03:00
David Capello da1358c5dc Unify all render code in one library
Changes:
* Create render library (move util/render.cpp to render/render.cpp)
* Move app::Zoom class to render::Zoom
* Remove doc::Image::merge() member function
* Add gfx::Clip helper class (to clip dst/src rectangles before a blit)
* Move doc::composite_image() to render::composite_image()
* Remove doc::Sprite::render()
* Replace Sprite::getPixel() with render::get_sprite_pixel()
* Remove doc::layer_render() function
* Convert DitheringMethod to a enum class
* Add AppRender to configure a render::Render with the app configuration
* Move checked background preferences as document-specific configuration
* Add doc::Sprite::layer() and palette() member functions
* Add doc::Layer::cel() member function
* Add doc::Palette::entry() member function()
* Add doc::frame_t type
* Move create_palette_from_rgb/convert_pixel_format to render library
* ExportSpriteSheet doesn't need a temporary image now that we can specify
  the source rectangle in the render routine
2014-12-28 11:06:11 -03:00
David Capello cc889f2b2f Minor refactor to doc::Layer flags 2014-11-16 23:03:30 -03:00
David Capello 63995c6f0a Merge "raster" namespace into "doc" library 2014-10-20 22:21:31 -03:00