Skip to content

Commit

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

* Closes #5044
* [x] I have followed the instructions in the PR template
* [x] I ran the check script
  • Loading branch information
bircni authored Sep 1, 2024
1 parent be484f5 commit 90eeb76
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 90eeb76

Please sign in to comment.