Add a stack-based Boolean Operation layer node (#1813)

* Multiple boolean operation node

* Change boolean operation ordering

* Complete layer boolean operation node

* Automatically insert new boolean operation node

* Remove divide operation

* Fix subtract operations

* Remove stack data from boolean operation properties

* Fix images and custom vectors

* Code cleanup

* Use slice instead of iter to avoid infinite type recursion

---------

Co-authored-by: Keavon Chambers <keavon@keavon.com>
This commit is contained in:
adamgerhant
2024-07-10 02:12:55 -07:00
committed by GitHub
co-authored by Keavon Chambers
parent f4e3e5ab2a
commit 9d749c49fb
14 changed files with 319 additions and 153 deletions
@@ -148,21 +148,13 @@ impl SelectTool {
}
fn boolean_widgets(&self, selected_count: usize) -> impl Iterator<Item = WidgetHolder> {
let enabled = move |operation| {
if operation == BooleanOperation::Union {
(1..=2).contains(&selected_count)
} else {
selected_count == 2
}
};
let operations = BooleanOperation::list();
let icons = BooleanOperation::icons();
operations.into_iter().zip(icons).map(move |(operation, icon)| {
IconButton::new(icon, 24)
.tooltip(operation.to_string())
.disabled(!enabled(operation))
.on_update(move |_| GraphOperationMessage::InsertBooleanOperation { operation }.into())
.disabled(selected_count == 0)
.on_update(move |_| DocumentMessage::InsertBooleanOperation { operation }.into())
.widget_holder()
})
}