Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
116 commits
Select commit Hold shift + click to select a range
a8d1d2e
Modified clock example to make the clock more readable. Added number…
kgday Oct 19, 2024
4b81ebc
feat: pop-os megasquash
wash2 May 2, 2023
f2a6203
Make iced_wgpu build on redox
jackpot51 Oct 9, 2024
c607218
add reserved Id
wash2 Oct 16, 2024
a72e247
cleanup
wash2 Oct 16, 2024
c1bde75
fix: derive serde traits
wash2 Oct 16, 2024
a719324
cargo fmt
wash2 Oct 17, 2024
c116af5
clippy
wash2 Oct 18, 2024
17b5d3c
fix: scrollable direction
wash2 Oct 18, 2024
4e67eb9
Fix doc links
jackpot51 Oct 18, 2024
1f01607
fix: docs
wash2 Oct 21, 2024
eb1b5d4
refactor: disable wayland in winit shell by default
wash2 Oct 21, 2024
1cc06ae
fix: log warning instead of panicing for current_monitor
wash2 Oct 21, 2024
68b3ede
fix: filter out events with no window id, if the window id is needed
wash2 Oct 21, 2024
f0f7bbe
fix(sctk): reduce event spam for redraw requests
wash2 Oct 22, 2024
e6e6536
Implement fill_raw
jackpot51 Oct 22, 2024
8e2f300
fix: slider rendering
wash2 Oct 22, 2024
17cbea2
refactor: apply requested size for surface after creation
wash2 Oct 23, 2024
22ff17b
fix: reverse sctk scroll direction
wash2 Oct 24, 2024
73a2679
improv: expose set_blur
edfloreshz Oct 30, 2024
7de6bdb
fix: use enable and disable methods
edfloreshz Oct 30, 2024
d0825db
fix: documentation
edfloreshz Oct 30, 2024
d7d18aa
fix: scrollbar width
git-f0x Nov 4, 2024
5f3f9f5
fix: avoid overwriting id when diffing children
wash2 Nov 5, 2024
66dc1fc
fix: offset DnD events in scrollable
wash2 Nov 5, 2024
8af9f39
fix: tree diff improvements
wash2 Nov 7, 2024
396fe4f
fix
wash2 Nov 7, 2024
21f857e
fix: a11y nodes
wash2 Nov 11, 2024
f6c90ea
fix: feature gate a11y_nodes for mouse_area
wash2 Nov 12, 2024
dd1f6d6
fix: close subscriptions when exiting
wash2 Nov 13, 2024
e1e9fe7
refactor: allow apps to request to be treated as a daemon
wash2 Nov 13, 2024
f615c31
Send `KeyboardEventVariant::Enter` on keyboard enter
ids1024 Nov 18, 2024
7205200
fix: request logical size when autosizing
wash2 Nov 19, 2024
3444551
fix: rebuild a11y tree when rebuilding widget tree
wash2 Nov 20, 2024
9954864
Revert "fix: rebuild a11y tree when rebuilding widget tree"
wash2 Nov 22, 2024
316f89b
fix: send a11y tree after actions
wash2 Nov 22, 2024
64f9867
fix: correct event types for windows
netraptor Oct 27, 2024
4becadb
fix: clear drag_initiated state on dbl click
netraptor Dec 1, 2024
883eb0a
hard-code which targets have drag_resize support
netraptor Oct 30, 2024
f646bac
use a variable instead of a fn for hard-coded check
netraptor Dec 1, 2024
75ff8c8
refactor: use cctk
wash2 Nov 23, 2024
974b12c
feat: overlap notify
wash2 Nov 26, 2024
e454cbf
refactor: add namespace
wash2 Nov 27, 2024
83396f3
fix: convert sctk configure events to Opened and Resized
wash2 Nov 27, 2024
98d538f
fix: use dummy window for clipboard
wash2 Dec 3, 2024
b32415d
fix(winit): cleanup layer surface dnd surface
wash2 Dec 3, 2024
584ffb6
subsurface_widget: Take owned `SubsurfaceBuffer`
ids1024 Nov 6, 2024
1077ba9
subsurface_widget: Clear subsurface list after calls to `::draw()`
ids1024 Nov 6, 2024
9f2280c
subsurface_widget: Remove `subsurface_ids`
ids1024 Nov 21, 2024
7b3b0fd
Remove `surface` argument of `Compositor::screenshot`
ids1024 Nov 22, 2024
8404d3a
Update `screenshot` call to not pass surface
ids1024 Nov 22, 2024
a20b5b5
subsurface: Add `width`/`height` methods to `SubsuraceBuffer`
ids1024 Dec 2, 2024
c2414c1
subsurface: Remove width/height arguments to `Subsurface::new`
ids1024 Dec 2, 2024
72589e7
subsurface: Add option to apply buffer transform
ids1024 Dec 2, 2024
5d75966
fix: use total_cmp where possible
wash2 Dec 11, 2024
fb70472
Remove unused `destroyed_surface_ids`
ids1024 Jan 2, 2025
aeaf005
winit/wayland: Subsurfaces for drag surfaces
ids1024 Dec 17, 2024
4602555
Don't unnecessarily chain `.map()`
ids1024 Jan 3, 2025
9b52fb7
Don't use `Box<Arc<_>>` and `Arc::into_inner` unnecessarily
ids1024 Jan 3, 2025
b2fa62e
runtime: Remove `start_dnd`
ids1024 Jan 3, 2025
8960f88
Define a `IconSurface<E>` for drag and drop instead of tuple, box dyn
ids1024 Jan 3, 2025
5866623
Add an `offset` to `IconSurface`, so icon can be offset from custor
ids1024 Jan 3, 2025
a4fdb59
winit/wayland: Apply scale when creating drag surface
ids1024 Jan 7, 2025
62fda6f
winit: Fix building without `wayland` feature
ids1024 Jan 13, 2025
1c9a768
chore: update image to 0.25
mmstick Jan 14, 2025
953e84d
mouse_area: Fix `on_drag` behavior without `on_release`
ids1024 Jan 28, 2025
596a506
Update `cctk` to latest commit
ids1024 Feb 4, 2025
2d129a8
winit/wayland: Update for toplevel-info cctk changes
ids1024 Feb 10, 2025
170b899
Add focus id to text editor
sgued Nov 11, 2024
060ddf4
perf: use cached alpha mode instead of calling surface.get_capabiliti…
Adam-Cosner Feb 20, 2025
68c6b03
feat: subsurfaces
wash2 Mar 14, 2025
5b6fa8d
fix: create fractional scale for sctk subsurfaces
wash2 Mar 18, 2025
ca0c2c6
Fix rich text widget capturing all mouse presses
jackpot51 Mar 19, 2025
ec3c23d
Format
jackpot51 Mar 19, 2025
28b23af
refactor: include virtual offset in Layout
wash2 Mar 20, 2025
411a879
subsurface_widget: Fix use of `place_above`
ids1024 Mar 26, 2025
6d6b3b4
subsurface_widget: Sort parent `WlSurface`, not `ObjectId`
ids1024 Mar 27, 2025
84e7729
subsurface_widget: Use neagtive `z` to place below parent surface
ids1024 Mar 27, 2025
8e00310
Adapt to new cosmic-text
jackpot51 Mar 31, 2025
669c084
feat(scrollable): add padding to ends of scrollbar
git-f0x Apr 3, 2025
282d045
wayland: Set cusor position on `Enter` events
ids1024 Apr 7, 2025
4070d79
fix: reset control flow if the loop is about to wait with nothing to do.
wash2 Apr 10, 2025
16a2e8f
wgpu: Fix explicit nvidia device selection
Drakulix Apr 14, 2025
e996b9a
fix: send pointer motion event for pointer enter event
wash2 Apr 29, 2025
742957c
Infinite `List` widget from upstream feature/list-widget-reloaded branch
hecrj May 4, 2024
3c0d844
support CapsLock modifiers on wayland
jackpot51 May 15, 2025
364db8b
Format
jackpot51 May 15, 2025
a7c886d
fix: parsing of nested markdown lists without empty line
Jinderamarak Oct 16, 2024
35bd818
Fix code block merging with previous spans in `markdown` widget
hecrj Jan 30, 2025
f6090a8
Make `spacing` configurable in `markdown::Settings`
hecrj Jan 30, 2025
72962f2
Let `markdown::view` be `Shrink` when no code blocks exist
hecrj Jan 30, 2025
e27849e
Draft incremental `markdown` parsing
hecrj Jan 31, 2025
0848624
Implement `markdown` incremental code highlighting
hecrj Jan 31, 2025
644050b
Replace `println` with `log` calls in `markdown` module
hecrj Jan 31, 2025
eb0d7bd
Add `new` constructor for `markdown::Content`
hecrj Jan 31, 2025
911bce2
Discard `markdown::Highlighter` if language changes
hecrj Jan 31, 2025
169218f
Split code blocks into multiple `rich_text` lines
hecrj Feb 1, 2025
4b65e87
Write documentation for `markdown::Content`
hecrj Feb 1, 2025
52293b1
Fix broken references when parsing `markdown` streams
hecrj Feb 2, 2025
13191c2
Avoid sharing `State` when re-parsing `markdown` sections
hecrj Feb 2, 2025
37f23e2
Introduce `view_with` customizers in `markdown` module
hecrj Feb 4, 2025
ca6abc7
Remove Cargo.lock
Ultrasquid9 May 2, 2025
63fcda9
Remove png
Ultrasquid9 May 2, 2025
e6e1071
fix(winit): Cleanup `surface_subsurfaces` on parent window removal
ids1024 Jun 4, 2025
fe41dcf
fix: nested popup destruction
wash2 Jun 10, 2025
d8c3d5b
improv(sctk): setup error handling
wash2 Jun 12, 2025
5c8fac7
chore(sctk): reduce severity of log messages
wash2 Jun 12, 2025
e4b7033
fix: conditional feature compile error for highlighter
wiiznokes Jun 24, 2025
f9783a7
examples: Update `sctk_subsurface_gst` to compile again
ids1024 May 8, 2025
ce3e56f
examples: Update gstreamer
ids1024 May 8, 2025
3bd1116
examples: Add `sctk_subsurface_img`
ids1024 May 9, 2025
1dd19d5
subsurface_widget: Handle `viewport` and set source rectangle
ids1024 May 9, 2025
ccbbc09
examples/sctk_subsurface_img: Toggle image/subsurface with key
ids1024 May 9, 2025
992f3b2
Revert "subsurface_widget: Handle `viewport` and set source rectangle"
ids1024 Jul 21, 2025
08caffa
winit/sctk: Update cursor position on touch event
ids1024 Jul 30, 2025
6c9055d
fix(wayland popup): apply input region
wash2 Jul 31, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 0 additions & 12 deletions .github/workflows/audit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,3 @@ jobs:
run: cargo update
- name: Audit vulnerabilities
run: cargo audit

# artifacts:
# runs-on: ubuntu-latest
# steps:
# - uses: hecrj/setup-rust-action@v2
# - name: Install cargo-outdated
# run: cargo install cargo-outdated
# - uses: actions/checkout@master
# - name: Delete `web-sys` dependency from `integration` example
# run: sed -i '$d' examples/integration/Cargo.toml
# - name: Find outdated dependencies
# run: cargo outdated --workspace --exit-code 1 --ignore raw-window-handle
7 changes: 5 additions & 2 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,14 @@ jobs:
- uses: hecrj/setup-rust-action@v2
with:
components: clippy

- uses: actions/checkout@master
- name: Install dependencies
run: |
export DEBIAN_FRONTED=noninteractive
sudo apt-get -qq update
sudo apt-get install -y libxkbcommon-dev libgtk-3-dev
sudo apt-get install -y libxkbcommon-dev libgtk-3-dev libwayland-dev
- name: Check lints
run: cargo lint
run: |
cargo clippy --no-default-features --features "winit" --all-targets
cargo clippy --no-default-features --features "wayland wgpu svg canvas qr_code lazy debug tokio palette web-colors a11y"
36 changes: 33 additions & 3 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,38 @@ jobs:
run: |
export DEBIAN_FRONTED=noninteractive
sudo apt-get -qq update
sudo apt-get install -y libxkbcommon-dev libgtk-3-dev
sudo apt-get install -y libxkbcommon-dev libwayland-dev
- name: Run tests
run: |
cargo test --verbose --workspace
cargo test --verbose --workspace --all-features
cargo test --verbose --features "winit wgpu svg canvas qr_code lazy debug tokio palette web-colors a11y"
cargo test -p iced_accessibility
cargo test -p iced_core
cargo test -p iced_futures
cargo test -p iced_graphics
cargo test -p iced_renderer
cargo test -p iced_runtime
cargo test -p iced_tiny_skia
cargo test -p iced_widget
cargo test -p iced_wgpu
- name: test wayland
if: matrix.os == 'ubuntu-latest'
run: |
cargo test --verbose --features "wayland wgpu svg canvas qr_code lazy debug tokio palette web-colors a11y"
cargo test -p iced_sctk

web:
runs-on: ubuntu-latest
steps:
- uses: hecrj/setup-rust-action@v1
with:
rust-version: stable
targets: wasm32-unknown-unknown
- uses: actions/checkout@master
- name: Run checks
run: cargo check --package iced --target wasm32-unknown-unknown --no-default-features --features "winit"
- name: Check compilation of `tour` example
run: cargo build --package tour --target wasm32-unknown-unknown
- name: Check compilation of `todos` example
run: cargo build --package todos --target wasm32-unknown-unknown
- name: Check compilation of `integration` example
run: cargo build --package integration --target wasm32-unknown-unknown
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,8 @@ Many thanks to...
- @wiiznokes
- @woelfman
- @Zaubentrucker
- @ryanabx
- @edfloreshz

## [0.12.1] - 2024-02-22
### Added
Expand Down Expand Up @@ -413,6 +415,10 @@ Many thanks to...
- @william-shere
- @wyatt-herkamp

Many thanks to...
- @jackpot51
- @wash2

## [0.10.0] - 2023-07-28
### Added
- Text shaping, font fallback, and `iced_wgpu` overhaul. [#1697](https://github.com/iced-rs/iced/pull/1697)
Expand Down
93 changes: 70 additions & 23 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ all-features = true
maintenance = { status = "actively-developed" }

[features]
default = ["wgpu", "tiny-skia", "fira-sans", "auto-detect-theme"]
default = ["tiny-skia"]
# Enable the `wgpu` GPU-accelerated renderer backend
wgpu = ["iced_renderer/wgpu", "iced_widget/wgpu"]
# Enable the `tiny-skia` software renderer backend
Expand All @@ -42,11 +42,11 @@ markdown = ["iced_widget/markdown"]
# Enables lazy widgets
lazy = ["iced_widget/lazy"]
# Enables a debug view in native platforms (press F12)
debug = ["iced_winit/debug"]
debug = ["iced_winit?/debug"]
# Enables `tokio` as the `executor::Default` on native platforms
tokio = ["iced_futures/tokio"]
tokio = ["iced_futures/tokio", "iced_accessibility?/tokio"]
# Enables `async-std` as the `executor::Default` on native platforms
async-std = ["iced_futures/async-std"]
async-std = ["iced_futures/async-std", "iced_accessibility?/async-io"]
# Enables `smol` as the `executor::Default` on native platforms
smol = ["iced_futures/smol"]
# Enables querying system information
Expand All @@ -58,28 +58,45 @@ webgl = ["iced_renderer/webgl"]
# Enables the syntax `highlighter` module
highlighter = ["iced_highlighter", "iced_widget/highlighter"]
# Enables experimental multi-window support.
multi-window = ["iced_winit/multi-window"]
multi-window = ["iced_winit?/multi-window"]
# Enables the advanced module
advanced = ["iced_core/advanced", "iced_widget/advanced"]
# Enables embedding Fira Sans as the default font on Wasm builds
fira-sans = ["iced_renderer/fira-sans"]


# Enables auto-detecting light/dark mode for the built-in theme
auto-detect-theme = ["iced_core/auto-detect-theme"]
# Enables strict assertions for debugging purposes at the expense of performance
strict-assertions = ["iced_renderer/strict-assertions"]
# Enables the `accesskit` accessibility library
a11y = [
"iced_accessibility",
"iced_core/a11y",
"iced_widget/a11y",
"iced_winit?/a11y",
]
# Enables the winit shell. Conflicts with `wayland` and `glutin`.
winit = ["iced_winit", "iced_accessibility?/accesskit_winit"]


# Enables the sctk shell.
wayland = ["iced_widget/wayland", "iced_core/wayland", "iced_winit/wayland"]
[dependencies]
iced_core.workspace = true
iced_futures.workspace = true
iced_renderer.workspace = true
iced_widget.workspace = true
iced_winit.features = ["program"]
iced_winit.workspace = true

iced_winit.optional = true
iced_highlighter.workspace = true
iced_highlighter.optional = true

iced_accessibility.workspace = true
iced_accessibility.optional = true
thiserror.workspace = true
window_clipboard.workspace = true
mime.workspace = true
dnd.workspace = true

image.workspace = true
image.optional = true
Expand Down Expand Up @@ -116,7 +133,9 @@ members = [
"widget",
"winit",
"examples/*",
"accessibility",
]
exclude = ["examples/integration"]

[workspace.package]
version = "0.14.0-dev"
Expand All @@ -141,19 +160,30 @@ iced_tiny_skia = { version = "0.14.0-dev", path = "tiny_skia" }
iced_wgpu = { version = "0.14.0-dev", path = "wgpu" }
iced_widget = { version = "0.14.0-dev", path = "widget" }
iced_winit = { version = "0.14.0-dev", path = "winit" }
iced_accessibility = { version = "0.1", path = "accessibility" }

async-std = "1.0"
bitflags = "2.0"
# bitflags = "2.0"
bitflags = "2.5"
bytemuck = { version = "1.0", features = ["derive"] }
bytes = "1.6"
cosmic-text = "0.12"

cosmic-text = { git = "https://github.com/pop-os/cosmic-text.git" }
# cosmic-text = "0.12"


dark-light = "1.0"
futures = "0.3"
glam = "0.25"
glyphon = { git = "https://github.com/hecrj/glyphon.git", rev = "09712a70df7431e9a3b1ac1bbd4fb634096cb3b4" }
glyphon = { git = "https://github.com/pop-os/glyphon.git", branch="iced-0.13" }
# glyphon = { path = "../glyphon" }
resvg = "0.42"


web-sys = "0.3.69"
guillotiere = "0.6"
half = "2.2"
image = { version = "0.24", default-features = false }
image = { version = "0.25", default-features = false }
kamadak-exif = "0.5"
kurbo = "0.10"
log = "0.4"
Expand All @@ -163,15 +193,15 @@ num-traits = "0.2"
once_cell = "1.0"
ouroboros = "0.18"
palette = "0.7"
pulldown-cmark = "0.11"
pulldown-cmark = "0.12"
qrcode = { version = "0.13", default-features = false }
raw-window-handle = "0.6"
resvg = "0.42"
rustc-hash = "2.0"
cctk = { git = "https://github.com/pop-os/cosmic-protocols", package = "cosmic-client-toolkit", rev = "178eb0b" }
smol = "1.0"
smol_str = "0.2"
softbuffer = "0.4"
syntect = "5.1"
softbuffer = { git = "https://github.com/pop-os/softbuffer", tag = "cosmic-4.0" }
syntect = "5.2"
sysinfo = "0.30"
thiserror = "1.0"
tiny-skia = "0.11"
Expand All @@ -181,18 +211,31 @@ unicode-segmentation = "1.0"
url = "2.5"
wasm-bindgen-futures = "0.4"
wasm-timer = "0.2"
web-sys = "0.3.69"
web-time = "1.1"
wgpu = "23.0"
wayland-protocols = { version = "0.32.1", features = ["staging"] }
wayland-client = { version = "0.31.5" }
# web-time = "1.1"

winapi = "0.3"
window_clipboard = "0.4.1"
winit = { git = "https://github.com/iced-rs/winit.git", rev = "254d6b3420ce4e674f516f7a2bd440665e05484d" }
# window_clipboard = "0.4.1"

window_clipboard = { git = "https://github.com/pop-os/window_clipboard.git", tag = "pop-0.13-2" }
dnd = { git = "https://github.com/pop-os/window_clipboard.git", tag = "pop-0.13-2" }
mime = { git = "https://github.com/pop-os/window_clipboard.git", tag = "pop-0.13-2" }
winit = { git = "https://github.com/pop-os/winit.git", tag = "iced-xdg-surface-0.13" }
# winit = { path = "../../winit" }
# winit = { git = "https://github.com/iced-rs/winit.git", rev = "254d6b3420ce4e674f516f7a2bd440665e05484d" }
# winit = { git = "https://github.com/rust-windowing/winit.git", rev = "241b7a80bba96c91fa3901729cd5dec66abb9be4" }
# winit = { path = "../../../winit" }


[workspace.lints.rust]
rust_2018_idioms = { level = "forbid", priority = -1 }
missing_debug_implementations = "deny"
missing_docs = "deny"
unsafe_code = "deny"
# rust_2018_idioms = { level = "forbid", priority = -1 }
# missing_debug_implementations = "deny"
# missing_docs = "deny"
# unsafe_code = "deny"
# TODO(POP): We have some unsafe code that needs to be fixed
unused_results = "deny"

[workspace.lints.clippy]
Expand All @@ -212,3 +255,7 @@ useless_conversion = "deny"

[workspace.lints.rustdoc]
broken_intra_doc_links = "forbid"

# [patch."https://github.com/rust-windowing/winit.git"]
# winit = { git = "https://github.com/rust-windowing/winit.git", rev = "241b7a80bba96c91fa3901729cd5dec66abb9be4" }
# winit = { path = "../../../winit" }
24 changes: 24 additions & 0 deletions accessibility/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
[package]
name = "iced_accessibility"
version = "0.1.0"
edition = "2021"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
# TODO Ashley re-export more platform adapters
[features]
async-io = ["accesskit_winit?/async-io"]
tokio = ["accesskit_winit?/tokio"]

[dependencies]
accesskit = { git = "https://github.com/wash2/accesskit", tag = "iced-xdg-surface-0.13" }
accesskit_windows = { git = "https://github.com/wash2/accesskit", tag = "iced-xdg-surface-0.13", optional = true }
accesskit_macos = { git = "https://github.com/wash2/accesskit", tag = "iced-xdg-surface-0.13", optional = true }
accesskit_winit = { git = "https://github.com/wash2/accesskit", tag = "iced-xdg-surface-0.13", optional = true, default-features = false, features = [
"rwh_06",
] }
# accesskit = { path = "../../../../accesskit/common" }
# accesskit_windows = { path = "../../../../accesskit/platforms/windows", optional = true }
# accesskit_macos = { path = "../../../../accesskit/platforms/macos", optional = true }
# accesskit_winit = { path = "../../../../accesskit/platforms/winit", optional = true, default-features = false, features = [
# "rwh_06",
# ] }
80 changes: 80 additions & 0 deletions accessibility/src/a11y_tree.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
use crate::{A11yId, A11yNode, IdEq};

#[derive(Debug, Clone, Default)]
/// Accessible tree of nodes
pub struct A11yTree {
/// The root of the current widget, children of the parent widget or the Window if there is no parent widget
root: Vec<A11yNode>,
/// The children of a widget and its children
children: Vec<A11yNode>,
}

impl A11yTree {
/// Create a new A11yTree
/// XXX if you use this method, you will need to manually add the children of the root nodes
pub fn new(root: Vec<A11yNode>, children: Vec<A11yNode>) -> Self {
Self { root, children }
}

pub fn leaf<T: Into<A11yId>>(node: accesskit::NodeBuilder, id: T) -> Self {
Self {
root: vec![A11yNode::new(node, id)],
children: vec![],
}
}

/// Helper for creating an A11y tree with a single root node and some children
pub fn node_with_child_tree(mut root: A11yNode, child_tree: Self) -> Self {
root.add_children(
child_tree.root.iter().map(|n| n.id()).cloned().collect(),
);
Self {
root: vec![root],
children: child_tree
.children
.into_iter()
.chain(child_tree.root)
.collect(),
}
}

/// Joins multiple trees into a single tree
pub fn join<T: Iterator<Item = Self>>(trees: T) -> Self {
trees.fold(Self::default(), |mut acc, A11yTree { root, children }| {
acc.root.extend(root);
acc.children.extend(children);
acc
})
}

pub fn root(&self) -> &Vec<A11yNode> {
&self.root
}

pub fn children(&self) -> &Vec<A11yNode> {
&self.children
}

pub fn root_mut(&mut self) -> &mut Vec<A11yNode> {
&mut self.root
}

pub fn children_mut(&mut self) -> &mut Vec<A11yNode> {
&mut self.children
}

pub fn contains(&self, id: &A11yId) -> bool {
self.root.iter().any(|n| IdEq::eq(n.id(), id))
|| self.children.iter().any(|n| IdEq::eq(n.id(), id))
}
}

impl From<A11yTree> for Vec<(accesskit::NodeId, accesskit::Node)> {
fn from(tree: A11yTree) -> Vec<(accesskit::NodeId, accesskit::Node)> {
tree.root
.into_iter()
.map(|node| node.into())
.chain(tree.children.into_iter().map(|node| node.into()))
.collect()
}
}
Loading