Skip to content

Commit

Permalink
Revert semver-breaking change, and replace with temporary HACK
Browse files Browse the repository at this point in the history
  • Loading branch information
emilk committed Feb 10, 2024
1 parent 12749f3 commit 6e4dab9
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 12 deletions.
1 change: 0 additions & 1 deletion crates/egui/src/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1081,7 +1081,6 @@ impl Context {
layer_id,
id,
rect,
interact_rect,
sense,
enabled,
contains_pointer,
Expand Down
4 changes: 4 additions & 0 deletions crates/egui/src/layers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,10 @@ impl PaintList {
pub fn all_entries(&self) -> impl ExactSizeIterator<Item = &ClippedShape> {
self.0.iter()
}

pub fn last(&self) -> Option<&ClippedShape> {
self.0.last()
}
}

/// This is where painted [`Shape`]s end up during a frame.
Expand Down
21 changes: 10 additions & 11 deletions crates/egui/src/response.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,6 @@ pub struct Response {
/// The area of the screen we are talking about.
pub rect: Rect,

/// The rectangle sensing interaction.
///
/// This is sometimes smaller than [`Self::rect`] because of clipping
/// (e.g. when inside a scroll area).
///
/// The interact rect may also be slightly larger than the widget rect,
/// because egui adds half if the item spacing to make the interact rect easier to hit.
pub interact_rect: Rect,

/// The senses (click and/or drag) that the widget was interested in (if any).
pub sense: Sense,

Expand Down Expand Up @@ -610,11 +601,20 @@ impl Response {
/// ```
#[must_use]
pub fn interact(&self, sense: Sense) -> Self {
// Temporary hack for 0.26.1 to avoid breaking change.
let clip_rect = self.ctx.graphics(|g| {
g.get(self.layer_id)
.and_then(|list| list.last())
.map(|c| c.clip_rect)
});
let clip_rect = clip_rect.unwrap_or(Rect::EVERYTHING);
let interact_rect = self.rect.intersect(clip_rect);

self.ctx.interact_with_hovered(
self.layer_id,
self.id,
self.rect,
self.interact_rect,
interact_rect,
sense,
self.enabled,
self.contains_pointer,
Expand Down Expand Up @@ -809,7 +809,6 @@ impl Response {
layer_id: self.layer_id,
id: self.id,
rect: self.rect.union(other.rect),
interact_rect: self.interact_rect.union(other.interact_rect),
sense: self.sense.union(other.sense),
enabled: self.enabled || other.enabled,
contains_pointer: self.contains_pointer || other.contains_pointer,
Expand Down

0 comments on commit 6e4dab9

Please sign in to comment.