mirror of
https://github.com/emilk/egui.git
synced 2026-06-27 23:13:13 -04:00
Expose area::State's Rect in Memory (#3161)
This commit is contained in:
@@ -55,6 +55,8 @@ impl State {
|
||||
/// });
|
||||
/// # });
|
||||
/// ```
|
||||
///
|
||||
/// The previous rectangle used by this area can be obtained through [`crate::Memory::area_rect()`].
|
||||
#[must_use = "You should call .show()"]
|
||||
#[derive(Clone, Copy, Debug)]
|
||||
pub struct Area {
|
||||
|
||||
@@ -21,6 +21,9 @@ use super::*;
|
||||
/// ui.label("Hello World!");
|
||||
/// });
|
||||
/// # });
|
||||
/// ```
|
||||
///
|
||||
/// The previous rectangle used by this window can be obtained through [`crate::Memory::area_rect()`].
|
||||
#[must_use = "You should call .show()"]
|
||||
pub struct Window<'open> {
|
||||
title: WidgetText,
|
||||
|
||||
@@ -487,6 +487,11 @@ impl Memory {
|
||||
pub fn reset_areas(&mut self) {
|
||||
self.areas = Default::default();
|
||||
}
|
||||
|
||||
/// Obtain the previous rectangle of an area.
|
||||
pub fn area_rect(&self, id: impl Into<Id>) -> Option<Rect> {
|
||||
self.areas.get(id.into()).map(|state| state.rect())
|
||||
}
|
||||
}
|
||||
|
||||
/// ## Popups
|
||||
|
||||
Reference in New Issue
Block a user