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

Revert semver-breaking change, and replace with temporary HACK

This commit is contained in:
Emil Ernerfeldt
2024-02-10 18:00:31 +01:00
parent 12749f3b5a
commit 6e4dab97fb
3 changed files with 14 additions and 12 deletions

View File

@@ -1081,7 +1081,6 @@ impl Context {
layer_id,
id,
rect,
interact_rect,
sense,
enabled,
contains_pointer,

View File

@@ -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.

View File

@@ -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,
@@ -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,
@@ -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,