window starting collapsed state (#2539)
This commit is contained in:
parent
e70204d726
commit
f7ed135192
1 changed files with 10 additions and 1 deletions
|
@ -30,6 +30,7 @@ pub struct Window<'open> {
|
|||
resize: Resize,
|
||||
scroll: ScrollArea,
|
||||
collapsible: bool,
|
||||
default_open: bool,
|
||||
with_title_bar: bool,
|
||||
}
|
||||
|
||||
|
@ -51,6 +52,7 @@ impl<'open> Window<'open> {
|
|||
.default_size([340.0, 420.0]), // Default inner size of a window
|
||||
scroll: ScrollArea::neither(),
|
||||
collapsible: true,
|
||||
default_open: true,
|
||||
with_title_bar: true,
|
||||
}
|
||||
}
|
||||
|
@ -162,6 +164,12 @@ impl<'open> Window<'open> {
|
|||
self
|
||||
}
|
||||
|
||||
/// Set initial collapsed state of the window
|
||||
pub fn default_open(mut self, default_open: bool) -> Self {
|
||||
self.default_open = default_open;
|
||||
self
|
||||
}
|
||||
|
||||
/// Set initial size of the window.
|
||||
pub fn default_size(mut self, default_size: impl Into<Vec2>) -> Self {
|
||||
self.resize = self.resize.default_size(default_size);
|
||||
|
@ -275,6 +283,7 @@ impl<'open> Window<'open> {
|
|||
resize,
|
||||
scroll,
|
||||
collapsible,
|
||||
default_open,
|
||||
with_title_bar,
|
||||
} = self;
|
||||
|
||||
|
@ -291,7 +300,7 @@ impl<'open> Window<'open> {
|
|||
let area_layer_id = area.layer();
|
||||
let resize_id = area_id.with("resize");
|
||||
let mut collapsing =
|
||||
CollapsingState::load_with_default_open(ctx, area_id.with("collapsing"), true);
|
||||
CollapsingState::load_with_default_open(ctx, area_id.with("collapsing"), default_open);
|
||||
|
||||
let is_collapsed = with_title_bar && !collapsing.is_open();
|
||||
let possible = PossibleInteractions::new(&area, &resize, is_collapsed);
|
||||
|
|
Loading…
Reference in a new issue