[style] Wrap tooltip text earlier

This commit is contained in:
Emil Ernerfeldt 2020-10-24 10:10:08 +02:00
parent c96a929713
commit 3416f3b91f
2 changed files with 12 additions and 1 deletions

View file

@ -31,5 +31,10 @@ fn show_popup(
.order(Order::Tooltip) .order(Order::Tooltip)
.fixed_pos(window_pos) .fixed_pos(window_pos)
.interactable(false) .interactable(false)
.show(ctx, |ui| Frame::popup(&ctx.style()).show(ui, add_contents)) .show(ctx, |ui| {
Frame::popup(&ctx.style()).show(ui, |ui| {
ui.set_max_width(ui.style().spacing.tooltip_width);
add_contents(ui);
})
})
} }

View file

@ -67,6 +67,9 @@ pub struct Spacing {
/// Checkboxes, radio button and collapsing headers have an icon at the start. /// Checkboxes, radio button and collapsing headers have an icon at the start.
/// This is the spacing between the icon and the text /// This is the spacing between the icon and the text
pub icon_spacing: f32, pub icon_spacing: f32,
/// Width of a tooltip (`on_hover_ui`, `on_hover_text` etc).
pub tooltip_width: f32,
} }
impl Spacing { impl Spacing {
@ -231,6 +234,7 @@ impl Default for Spacing {
slider_width: 140.0, slider_width: 140.0,
icon_width: 16.0, icon_width: 16.0,
icon_spacing: 1.0, icon_spacing: 1.0,
tooltip_width: 400.0,
} }
} }
} }
@ -348,6 +352,7 @@ impl Spacing {
slider_width, slider_width,
icon_width, icon_width,
icon_spacing, icon_spacing,
tooltip_width,
} = self; } = self;
ui_slider_vec2(ui, item_spacing, 0.0..=10.0, "item_spacing"); ui_slider_vec2(ui, item_spacing, 0.0..=10.0, "item_spacing");
@ -359,6 +364,7 @@ impl Spacing {
ui.add(Slider::f32(slider_width, 0.0..=1000.0).text("slider_width")); ui.add(Slider::f32(slider_width, 0.0..=1000.0).text("slider_width"));
ui.add(Slider::f32(icon_width, 0.0..=60.0).text("icon_width")); ui.add(Slider::f32(icon_width, 0.0..=60.0).text("icon_width"));
ui.add(Slider::f32(icon_spacing, 0.0..=10.0).text("icon_spacing")); ui.add(Slider::f32(icon_spacing, 0.0..=10.0).text("icon_spacing"));
ui.add(Slider::f32(tooltip_width, 0.0..=10.0).text("tooltip_width"));
} }
} }