Merge pull request #1978 from iced-rs/fix/tooltip-position
Fix `Tooltip` overlay position inside `Scrollable`
This commit is contained in:
commit
8309a6b007
2 changed files with 17 additions and 18 deletions
|
|
@ -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)
|
- 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)
|
- 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)
|
- 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)
|
- `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)
|
- Outdated `ROADMAP`. [#1958](https://github.com/iced-rs/iced/pull/1958)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -314,7 +314,7 @@ where
|
||||||
&self,
|
&self,
|
||||||
renderer: &Renderer,
|
renderer: &Renderer,
|
||||||
bounds: Size,
|
bounds: Size,
|
||||||
_position: Point,
|
position: Point,
|
||||||
) -> layout::Node {
|
) -> layout::Node {
|
||||||
let viewport = Rectangle::with_size(bounds);
|
let viewport = Rectangle::with_size(bounds);
|
||||||
|
|
||||||
|
|
@ -331,45 +331,43 @@ where
|
||||||
);
|
);
|
||||||
|
|
||||||
let text_bounds = text_layout.bounds();
|
let text_bounds = text_layout.bounds();
|
||||||
let x_center = self.content_bounds.x
|
let x_center =
|
||||||
+ (self.content_bounds.width - text_bounds.width) / 2.0;
|
position.x + (self.content_bounds.width - text_bounds.width) / 2.0;
|
||||||
let y_center = self.content_bounds.y
|
let y_center = position.y
|
||||||
+ (self.content_bounds.height - text_bounds.height) / 2.0;
|
+ (self.content_bounds.height - text_bounds.height) / 2.0;
|
||||||
|
|
||||||
let mut tooltip_bounds = {
|
let mut tooltip_bounds = {
|
||||||
let offset = match self.position {
|
let offset = match self.position {
|
||||||
Position::Top => Vector::new(
|
Position::Top => Vector::new(
|
||||||
x_center,
|
x_center,
|
||||||
self.content_bounds.y
|
position.y - text_bounds.height - self.gap - self.padding,
|
||||||
- text_bounds.height
|
|
||||||
- self.gap
|
|
||||||
- self.padding,
|
|
||||||
),
|
),
|
||||||
Position::Bottom => Vector::new(
|
Position::Bottom => Vector::new(
|
||||||
x_center,
|
x_center,
|
||||||
self.content_bounds.y
|
position.y
|
||||||
+ self.content_bounds.height
|
+ self.content_bounds.height
|
||||||
+ self.gap
|
+ self.gap
|
||||||
+ self.padding,
|
+ self.padding,
|
||||||
),
|
),
|
||||||
Position::Left => Vector::new(
|
Position::Left => Vector::new(
|
||||||
self.content_bounds.x
|
position.x - text_bounds.width - self.gap - self.padding,
|
||||||
- text_bounds.width
|
|
||||||
- self.gap
|
|
||||||
- self.padding,
|
|
||||||
y_center,
|
y_center,
|
||||||
),
|
),
|
||||||
Position::Right => Vector::new(
|
Position::Right => Vector::new(
|
||||||
self.content_bounds.x
|
position.x
|
||||||
+ self.content_bounds.width
|
+ self.content_bounds.width
|
||||||
+ self.gap
|
+ self.gap
|
||||||
+ self.padding,
|
+ self.padding,
|
||||||
y_center,
|
y_center,
|
||||||
),
|
),
|
||||||
Position::FollowCursor => Vector::new(
|
Position::FollowCursor => {
|
||||||
self.cursor_position.x,
|
let translation = position - self.content_bounds.position();
|
||||||
self.cursor_position.y - text_bounds.height,
|
|
||||||
),
|
Vector::new(
|
||||||
|
self.cursor_position.x,
|
||||||
|
self.cursor_position.y - text_bounds.height,
|
||||||
|
) + translation
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
Rectangle {
|
Rectangle {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue