Skip to content

Commit

Permalink
Prepare to support nested operations
Browse files Browse the repository at this point in the history
  • Loading branch information
hannobraun committed Dec 10, 2024
1 parent 050b935 commit d7a183b
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 7 deletions.
6 changes: 2 additions & 4 deletions experiments/2024-12-09/src/render/renderer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,10 +92,8 @@ impl Renderer {
return Ok(());
};

let vertices =
Geometry::vertices(&self.device, selected_operation.as_ref());
let triangles =
Geometry::triangles(&self.device, selected_operation.as_ref());
let vertices = Geometry::vertices(&self.device, &selected_operation);
let triangles = Geometry::triangles(&self.device, &selected_operation);

let mut encoder = self
.device
Expand Down
14 changes: 11 additions & 3 deletions experiments/2024-12-09/src/ui.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,20 @@ impl OperationView {
}
}

pub fn operations(&self) -> Vec<(Box<dyn Operation>, bool)> {
pub fn operations(&self) -> Vec<(Self, bool)> {
self.operation
.children()
.into_iter()
.enumerate()
.map(|(i, op)| (op, Some(i) == self.selected))
.map(|(i, op)| {
(
OperationView {
operation: op,
selected: None,
},
Some(i) == self.selected,
)
})
.collect()
}

Expand All @@ -40,7 +48,7 @@ impl OperationView {
}
}

pub fn selected(&self) -> Option<Box<dyn Operation>> {
pub fn selected(&self) -> Option<Self> {
let selected = self.selected?;

self.operations()
Expand Down

0 comments on commit d7a183b

Please sign in to comment.