Skip to content

Commit

Permalink
Remove layer_id argument from Ui::new
Browse files Browse the repository at this point in the history
  • Loading branch information
emilk committed Sep 30, 2024
1 parent 9782997 commit cda4c63
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 11 deletions.
3 changes: 2 additions & 1 deletion crates/egui/src/containers/area.rs
Original file line number Diff line number Diff line change
Expand Up @@ -540,6 +540,7 @@ impl Prepared {

let mut ui_builder = UiBuilder::new()
.ui_stack_info(UiStackInfo::new(self.kind))
.layer_id(self.layer_id)
.max_rect(max_rect);

if !self.enabled {
Expand All @@ -549,7 +550,7 @@ impl Prepared {
ui_builder = ui_builder.sizing_pass().invisible();
}

let mut ui = Ui::new(ctx.clone(), self.layer_id, self.layer_id.id, ui_builder);
let mut ui = Ui::new(ctx.clone(), self.layer_id.id, ui_builder);
ui.set_clip_rect(self.constrain_rect); // Don't paint outside our bounds

if self.fade_in {
Expand Down
18 changes: 9 additions & 9 deletions crates/egui/src/containers/panel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -375,14 +375,14 @@ impl SidePanel {
ctx: &Context,
add_contents: Box<dyn FnOnce(&mut Ui) -> R + 'c>,
) -> InnerResponse<R> {
let layer_id = LayerId::background();
let side = self.side;
let available_rect = ctx.available_rect();
let mut panel_ui = Ui::new(
ctx.clone(),
layer_id,
self.id,
UiBuilder::new().max_rect(available_rect),
UiBuilder::new()
.layer_id(LayerId::background())
.max_rect(available_rect),
);
panel_ui.set_clip_rect(ctx.screen_rect());

Expand Down Expand Up @@ -868,15 +868,15 @@ impl TopBottomPanel {
ctx: &Context,
add_contents: Box<dyn FnOnce(&mut Ui) -> R + 'c>,
) -> InnerResponse<R> {
let layer_id = LayerId::background();
let available_rect = ctx.available_rect();
let side = self.side;

let mut panel_ui = Ui::new(
ctx.clone(),
layer_id,
self.id,
UiBuilder::new().max_rect(available_rect),
UiBuilder::new()
.layer_id(LayerId::background())
.max_rect(available_rect),
);
panel_ui.set_clip_rect(ctx.screen_rect());

Expand Down Expand Up @@ -1135,14 +1135,14 @@ impl CentralPanel {
add_contents: Box<dyn FnOnce(&mut Ui) -> R + 'c>,
) -> InnerResponse<R> {
let available_rect = ctx.available_rect();
let layer_id = LayerId::background();
let id = Id::new((ctx.viewport_id(), "central_panel"));

let mut panel_ui = Ui::new(
ctx.clone(),
layer_id,
id,
UiBuilder::new().max_rect(available_rect),
UiBuilder::new()
.layer_id(LayerId::background())
.max_rect(available_rect),
);
panel_ui.set_clip_rect(ctx.screen_rect());

Expand Down
5 changes: 4 additions & 1 deletion crates/egui/src/ui.rs
Original file line number Diff line number Diff line change
Expand Up @@ -120,10 +120,11 @@ impl Ui {
///
/// Normally you would not use this directly, but instead use
/// [`crate::SidePanel`], [`crate::TopBottomPanel`], [`crate::CentralPanel`], [`crate::Window`] or [`crate::Area`].
pub fn new(ctx: Context, layer_id: LayerId, id: Id, ui_builder: UiBuilder) -> Self {
pub fn new(ctx: Context, id: Id, ui_builder: UiBuilder) -> Self {
let UiBuilder {
id_salt,
ui_stack_info,
layer_id,
max_rect,
layout,
disabled,
Expand All @@ -133,6 +134,8 @@ impl Ui {
sense,
} = ui_builder;

let layer_id = layer_id.unwrap_or(LayerId::background());

debug_assert!(
id_salt.is_none(),
"Top-level Ui:s should not have an id_salt"
Expand Down

0 comments on commit cda4c63

Please sign in to comment.