Skip to content

Commit

Permalink
Deprecate ui.set_sizing_pass (emilk#5074)
Browse files Browse the repository at this point in the history
Use `UiBuilder::new().sizing_pass().invisible()` instead.

Also changes `UiBuilder::sizing_pass` to no longer turn the ui
invisible. You'll have to opt-in to that instead when it makes sense,
e.g. for the first frame of a tooltip, but not when auto-sizing a column
in a `Table`.
  • Loading branch information
emilk authored Sep 5, 2024
1 parent f741529 commit 7cb61f8
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 12 deletions.
2 changes: 1 addition & 1 deletion crates/egui/src/containers/area.rs
Original file line number Diff line number Diff line change
Expand Up @@ -543,7 +543,7 @@ impl Prepared {
ui_builder = ui_builder.disabled();
}
if self.sizing_pass {
ui_builder = ui_builder.sizing_pass();
ui_builder = ui_builder.sizing_pass().invisible();
}

let mut ui = Ui::new(ctx.clone(), self.layer_id, self.layer_id.id, ui_builder);
Expand Down
2 changes: 1 addition & 1 deletion crates/egui/src/grid.rs
Original file line number Diff line number Diff line change
Expand Up @@ -435,7 +435,7 @@ impl Grid {
let mut ui_builder = UiBuilder::new().max_rect(max_rect);
if prev_state.is_none() {
// Hide the ui this frame, and make things as narrow as possible.
ui_builder = ui_builder.sizing_pass();
ui_builder = ui_builder.sizing_pass().invisible();
}

ui.allocate_new_ui(ui_builder, |ui| {
Expand Down
12 changes: 4 additions & 8 deletions crates/egui/src/ui.rs
Original file line number Diff line number Diff line change
Expand Up @@ -119,8 +119,7 @@ impl Ui {
let max_rect = max_rect.unwrap_or_else(|| ctx.screen_rect());
let clip_rect = max_rect;
let layout = layout.unwrap_or_default();
let invisible = invisible || sizing_pass;
let disabled = disabled || invisible || sizing_pass;
let disabled = disabled || invisible;
let style = style.unwrap_or_else(|| ctx.style());

let placer = Placer::new(max_rect, layout);
Expand All @@ -139,7 +138,7 @@ impl Ui {
style,
placer,
enabled: true,
sizing_pass: false,
sizing_pass,
menu_state: None,
stack: Arc::new(ui_stack),
};
Expand All @@ -161,9 +160,6 @@ impl Ui {
if invisible {
ui.set_invisible();
}
if sizing_pass {
ui.set_sizing_pass();
}

ui
}
Expand Down Expand Up @@ -227,8 +223,7 @@ impl Ui {
let id_salt = id_salt.unwrap_or_else(|| Id::from("child"));
let max_rect = max_rect.unwrap_or_else(|| self.available_rect_before_wrap());
let mut layout = layout.unwrap_or(*self.layout());
let invisible = invisible || sizing_pass;
let enabled = self.enabled && !disabled && !invisible && !sizing_pass;
let enabled = self.enabled && !disabled && !invisible;
if invisible {
painter.set_invisible();
}
Expand Down Expand Up @@ -293,6 +288,7 @@ impl Ui {
/// This will also turn the Ui invisible.
/// Should be called right after [`Self::new`], if at all.
#[inline]
#[deprecated = "Use UiBuilder.sizing_pass().invisible()"]
pub fn set_sizing_pass(&mut self) {
self.sizing_pass = true;
self.set_invisible();
Expand Down
2 changes: 0 additions & 2 deletions crates/egui/src/ui_builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,6 @@ impl UiBuilder {
#[inline]
pub fn sizing_pass(mut self) -> Self {
self.sizing_pass = true;
self.invisible = true;
self.disabled = true;
self
}

Expand Down

0 comments on commit 7cb61f8

Please sign in to comment.