Skip to content

Commit

Permalink
Make some Memory methods public (emilk#5046)
Browse files Browse the repository at this point in the history
Adding the proposed changes from @SymmetricChaos

* Closes emilk#5044
* [x] I have followed the instructions in the PR template
* [x] I ran the check script
  • Loading branch information
bircni authored and 486c committed Oct 9, 2024
1 parent bf5a802 commit a867e64
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions crates/egui/src/memory.rs
Original file line number Diff line number Diff line change
Expand Up @@ -750,16 +750,20 @@ impl Memory {
self.areas().order().iter().copied()
}

pub(crate) fn had_focus_last_frame(&self, id: Id) -> bool {
/// Check if the layer had focus last frame.
/// returns `true` if the layer had focus last frame, but not this one.
pub fn had_focus_last_frame(&self, id: Id) -> bool {
self.focus().and_then(|f| f.id_previous_frame) == Some(id)
}

/// True if the given widget had keyboard focus last frame, but not this one.
/// Check if the layer lost focus last frame
/// returns `true` if the layer lost focus last frame, but not this one.
pub(crate) fn lost_focus(&self, id: Id) -> bool {
self.had_focus_last_frame(id) && !self.has_focus(id)
}

/// True if the given widget has keyboard focus this frame, but didn't last frame.
/// Check if the layer gained focus this frame
/// returns `true` if the layer gained focus this frame, but not last one.
pub(crate) fn gained_focus(&self, id: Id) -> bool {
!self.had_focus_last_frame(id) && self.has_focus(id)
}
Expand Down

0 comments on commit a867e64

Please sign in to comment.