1
0
mirror of https://github.com/emilk/egui.git synced 2026-06-26 14:49:06 -04:00

Deprecate Context::used_size and Context::available_rect (#7788)

This commit is contained in:
Emil Ernerfeldt
2025-12-17 21:18:36 +01:00
committed by GitHub
parent ca1e76f38b
commit f1e0b2e565
2 changed files with 13 additions and 21 deletions

View File

@@ -760,8 +760,10 @@ impl Panel {
ctx: &Context,
add_contents: Box<dyn FnOnce(&mut Ui) -> R + 'c>,
) -> InnerResponse<R> {
#![expect(deprecated)]
let side = self.side;
let available_rect = ctx.globally_available_rect();
let available_rect = ctx.available_rect();
let mut panel_ui = Ui::new(
ctx.clone(),
self.id,
@@ -1059,6 +1061,8 @@ impl CentralPanel {
ctx: &Context,
add_contents: Box<dyn FnOnce(&mut Ui) -> R + 'c>,
) -> InnerResponse<R> {
#![expect(deprecated)]
let id = Id::new((ctx.viewport_id(), "central_panel"));
let mut panel_ui = Ui::new(
@@ -1066,7 +1070,7 @@ impl CentralPanel {
id,
UiBuilder::new()
.layer_id(LayerId::background())
.max_rect(ctx.globally_available_rect().round_ui()),
.max_rect(ctx.available_rect().round_ui()),
);
panel_ui.set_clip_rect(ctx.content_rect());

View File

@@ -798,7 +798,7 @@ impl Context {
Id::new((ctx.viewport_id(), "__top_ui")),
UiBuilder::new()
.layer_id(LayerId::background())
.max_rect(ctx.globally_available_rect().round_ui()),
.max_rect(ctx.available_rect().round_ui()),
);
{
@@ -2811,17 +2811,12 @@ impl Context {
}
/// How much space is still available after panels have been added.
pub fn globally_available_rect(&self) -> Rect {
#[deprecated = "Use content_rect (or viewport_rect) instead"]
pub fn available_rect(&self) -> Rect {
self.pass_state(|s| s.available_rect()).round_ui()
}
/// How much space is still available after panels have been added.
#[deprecated = "Renamed to globally_available_rect"]
pub fn available_rect(&self) -> Rect {
self.globally_available_rect()
}
/// How much space is used by panels and windows.
/// How much space is used by windows and the top-level [`Ui`].
pub fn globally_used_rect(&self) -> Rect {
self.write(|ctx| {
let mut used = ctx.viewport().this_pass.used_by_panels;
@@ -2832,23 +2827,16 @@ impl Context {
})
}
/// How much space is used by panels and windows.
/// How much space is used by windows and the top-level [`Ui`].
#[deprecated = "Renamed to globally_used_rect"]
pub fn used_rect(&self) -> Rect {
self.globally_used_rect()
}
/// How much space is used by panels and windows.
/// How much space is used by windows and the top-level [`Ui`].
///
/// You can shrink your egui area to this size and still fit all egui components.
pub fn globally_used_size(&self) -> Vec2 {
(self.globally_used_rect().max - Pos2::ZERO).round_ui()
}
/// How much space is used by panels and windows.
///
/// You can shrink your egui area to this size and still fit all egui components.
#[deprecated = "Renamed to globally_used_size"]
#[deprecated = "Use globally_used_rect instead"]
pub fn used_size(&self) -> Vec2 {
(self.globally_used_rect().max - Pos2::ZERO).round_ui()
}