Skip to content

Commit

Permalink
Add node layout customization. Fixes #43
Browse files Browse the repository at this point in the history
Remove !Send and !Sync bounds from SnarlStyle.
Pins and background draw override in SnarlViewer
  • Loading branch information
zakarumych committed Nov 29, 2024
1 parent edeb2aa commit 7128496
Show file tree
Hide file tree
Showing 7 changed files with 1,000 additions and 532 deletions.
40 changes: 40 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# Changelog

All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased]

### Added

- NodeLayout enum
To control layout of nodes in the graph
Can be set globally in SnarlStyle and overridden per node with SnarlViewer::node_layout
Defaults to NodeLayout::Basic which is the previous layout
NodeLayout::Sandwich is a new layout that places inputs, body and outputs vertically with inputs on top and outputs on bottom
NodeLayout::FlippedSandwich is the same as Sandwich but with outputs on top and inputs on bottom

- SnarlViewer::draw_input_pin/draw_output_pin can be used to override how pins are drawn.
Default implementation matches old behavior.
This mechanism is meant to replace PinShape::Custom that was removed.

- SnarlViewer::draw_node_background can be used to override how node background is drawn.
Default implementation matches old behavior.
This mechanism is meant to replace BackgroundPattern::Custom that was removed.

### Removed

- BackgroundPattern::Custom is removed.
It contained opaque function to draw custom background pattern
and permitted !Send and !Sync captures which made SnarlStyle !Send and !Sync as well

- PinShape::Custom is removed.
It is replaced by SnarlViewer::draw_input_pin/draw_output_pin which is more flexible.

- BasicPinShape is removed. SnarlStyle::pin_shape has PinShape type now.

### Fixed

- Crash after centering graph when no nodes are present and adding a node afterwards
3 changes: 1 addition & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
workspace = { members = ["demo"] }
[package]
name = "egui-snarl"
version = "0.5.0"
version = "0.6.0"
edition = "2021"
description = "Node-graphs for egui"
license = "MIT OR Apache-2.0"
Expand All @@ -18,7 +18,6 @@ serde = ["dep:serde", "egui/serde", "slab/serde"]
egui = { version = "0.29" }
slab = { version = "0.4" }
serde = { version = "1.0", features = ["derive"], optional = true }
tiny-fn = { version = "0.1.7" }

egui-probe = { version = "0.6.0", features = ["derive"], optional = true }

Expand Down
Loading

0 comments on commit 7128496

Please sign in to comment.