Skip to content

Commit 8c2df48

Browse files
authored
Add back old Tooltip::new (#7156)
I was a bit too hasty in #7151 and changed a public API in a breaking way, for no good reason
1 parent 011e0d2 commit 8c2df48

File tree

2 files changed

+21
-3
lines changed

2 files changed

+21
-3
lines changed

crates/egui/src/containers/old_popup.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ pub fn show_tooltip_at_pointer<R>(
6161
widget_id: Id,
6262
add_contents: impl FnOnce(&mut Ui) -> R,
6363
) -> Option<R> {
64-
Tooltip::new(ctx.clone(), parent_layer, widget_id, PopupAnchor::Pointer)
64+
Tooltip::always_open(ctx.clone(), parent_layer, widget_id, PopupAnchor::Pointer)
6565
.gap(12.0)
6666
.show(add_contents)
6767
.map(|response| response.inner)
@@ -78,7 +78,7 @@ pub fn show_tooltip_for<R>(
7878
widget_rect: &Rect,
7979
add_contents: impl FnOnce(&mut Ui) -> R,
8080
) -> Option<R> {
81-
Tooltip::new(ctx.clone(), parent_layer, widget_id, *widget_rect)
81+
Tooltip::always_open(ctx.clone(), parent_layer, widget_id, *widget_rect)
8282
.show(add_contents)
8383
.map(|response| response.inner)
8484
}
@@ -94,7 +94,7 @@ pub fn show_tooltip_at<R>(
9494
suggested_position: Pos2,
9595
add_contents: impl FnOnce(&mut Ui) -> R,
9696
) -> Option<R> {
97-
Tooltip::new(ctx.clone(), parent_layer, widget_id, suggested_position)
97+
Tooltip::always_open(ctx.clone(), parent_layer, widget_id, suggested_position)
9898
.show(add_contents)
9999
.map(|response| response.inner)
100100
}

crates/egui/src/containers/tooltip.rs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,25 @@ pub struct Tooltip<'a> {
1717

1818
impl Tooltip<'_> {
1919
/// Show a tooltip that is always open.
20+
#[deprecated = "Use `Tooltip::always_open` instead."]
2021
pub fn new(
22+
parent_widget: Id,
23+
ctx: Context,
24+
anchor: impl Into<PopupAnchor>,
25+
parent_layer: LayerId,
26+
) -> Self {
27+
Self {
28+
popup: Popup::new(parent_widget, ctx, anchor.into(), parent_layer)
29+
.kind(PopupKind::Tooltip)
30+
.gap(4.0)
31+
.sense(Sense::hover()),
32+
parent_layer,
33+
parent_widget,
34+
}
35+
}
36+
37+
/// Show a tooltip that is always open.
38+
pub fn always_open(
2139
ctx: Context,
2240
parent_layer: LayerId,
2341
parent_widget: Id,

0 commit comments

Comments
 (0)