Skip to content

Commit

Permalink
Add SimplificationOptions::off() (#38)
Browse files Browse the repository at this point in the history
This enables easily running `simplify()` on a single category:

```rust
tree.simplify(&SimplificationOptions {
    prune_empty_tabs: true,
    ..SimplificationOptions::OFF
});
```
  • Loading branch information
abey79 authored Dec 14, 2023
1 parent 05e451c commit 7e5bf75
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,28 @@ pub struct SimplificationOptions {
pub join_nested_linear_containers: bool,
}

impl SimplificationOptions {
/// [`SimplificationOptions`] with all simplifications turned off.
///
/// This makes it easy to run a single simplification type on a tree:
/// ```
/// # use egui_tiles::*;
/// # let mut tree: Tree<()> = Tree::empty("tree");
/// tree.simplify(&SimplificationOptions {
/// prune_empty_tabs: true,
/// ..SimplificationOptions::OFF
/// });
///
pub const OFF: Self = Self {
prune_empty_tabs: false,
prune_empty_containers: false,
prune_single_child_tabs: false,
prune_single_child_containers: false,
all_panes_must_have_tabs: false,
join_nested_linear_containers: false,
};
}

impl Default for SimplificationOptions {
fn default() -> Self {
Self {
Expand Down

0 comments on commit 7e5bf75

Please sign in to comment.