summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLibravatar Héctor Ramón <hector0193@gmail.com>2023-07-29 20:07:18 +0200
committerLibravatar GitHub <noreply@github.com>2023-07-29 20:07:18 +0200
commit8309a6b00762efd821ba298173a7ae823de0ae0b (patch)
treeaf8c4e7964e13f282e898ba33d70fa81be1f5eae
parent226e9d1cb9af6f42261a6269579d69080c7db091 (diff)
parent34ca3db1ca371ddaeb1196a2ad20d8945017c607 (diff)
downloadiced-8309a6b00762efd821ba298173a7ae823de0ae0b.tar.gz
iced-8309a6b00762efd821ba298173a7ae823de0ae0b.tar.bz2
iced-8309a6b00762efd821ba298173a7ae823de0ae0b.zip
Merge pull request #1978 from iced-rs/fix/tooltip-position
Fix `Tooltip` overlay position inside `Scrollable`
Diffstat (limited to '')
-rw-r--r--CHANGELOG.md1
-rw-r--r--widget/src/tooltip.rs34
2 files changed, 17 insertions, 18 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index c1074065..9ab7b247 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -75,6 +75,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Quad rendering including border only inside of the bounds. [#1843](https://github.com/iced-rs/iced/pull/1843)
- Redraw requests not being forwarded for `Component` overlays. [#1949](https://github.com/iced-rs/iced/pull/1949)
- Blinking input cursor when window loses focus. [#1955](https://github.com/iced-rs/iced/pull/1955)
+- `Tooltip` overlay position inside `Scrollable`. [#1978](https://github.com/iced-rs/iced/pull/1978)
- `BorderRadius` not exposed in root crate. [#1972](https://github.com/iced-rs/iced/pull/1972)
- Outdated `ROADMAP`. [#1958](https://github.com/iced-rs/iced/pull/1958)
diff --git a/widget/src/tooltip.rs b/widget/src/tooltip.rs
index ff7f960f..faa3f3e1 100644
--- a/widget/src/tooltip.rs
+++ b/widget/src/tooltip.rs
@@ -314,7 +314,7 @@ where
&self,
renderer: &Renderer,
bounds: Size,
- _position: Point,
+ position: Point,
) -> layout::Node {
let viewport = Rectangle::with_size(bounds);
@@ -331,45 +331,43 @@ where
);
let text_bounds = text_layout.bounds();
- let x_center = self.content_bounds.x
- + (self.content_bounds.width - text_bounds.width) / 2.0;
- let y_center = self.content_bounds.y
+ let x_center =
+ position.x + (self.content_bounds.width - text_bounds.width) / 2.0;
+ let y_center = position.y
+ (self.content_bounds.height - text_bounds.height) / 2.0;
let mut tooltip_bounds = {
let offset = match self.position {
Position::Top => Vector::new(
x_center,
- self.content_bounds.y
- - text_bounds.height
- - self.gap
- - self.padding,
+ position.y - text_bounds.height - self.gap - self.padding,
),
Position::Bottom => Vector::new(
x_center,
- self.content_bounds.y
+ position.y
+ self.content_bounds.height
+ self.gap
+ self.padding,
),
Position::Left => Vector::new(
- self.content_bounds.x
- - text_bounds.width
- - self.gap
- - self.padding,
+ position.x - text_bounds.width - self.gap - self.padding,
y_center,
),
Position::Right => Vector::new(
- self.content_bounds.x
+ position.x
+ self.content_bounds.width
+ self.gap
+ self.padding,
y_center,
),
- Position::FollowCursor => Vector::new(
- self.cursor_position.x,
- self.cursor_position.y - text_bounds.height,
- ),
+ Position::FollowCursor => {
+ let translation = position - self.content_bounds.position();
+
+ Vector::new(
+ self.cursor_position.x,
+ self.cursor_position.y - text_bounds.height,
+ ) + translation
+ }
};
Rectangle {