Make each DragValue at least the size of interact_size

This commit is contained in:
Emil Ernerfeldt 2021-03-31 22:18:45 +02:00
parent b8a0f5be15
commit 0d7c84c327
2 changed files with 2 additions and 2 deletions

View file

@ -74,7 +74,7 @@ pub struct Spacing {
/// Indent collapsing regions etc by this much. /// Indent collapsing regions etc by this much.
pub indent: f32, pub indent: f32,
/// Minimum size of e.g. a button (including padding). /// Minimum size of a `DragValue`, color picker button, and other small widgets.
/// `interact_size.y` is the default height of button, slider, etc. /// `interact_size.y` is the default height of button, slider, etc.
/// Anything clickable should be (at least) this size. /// Anything clickable should be (at least) this size.
pub interact_size: Vec2, // TODO: rename min_interact_size ? pub interact_size: Vec2, // TODO: rename min_interact_size ?

View file

@ -261,7 +261,7 @@ impl<'a> Widget for DragValue<'a> {
let button = Button::new(format!("{}{}{}", prefix, value_text, suffix)) let button = Button::new(format!("{}{}{}", prefix, value_text, suffix))
.sense(Sense::click_and_drag()) .sense(Sense::click_and_drag())
.text_style(TextStyle::Monospace); .text_style(TextStyle::Monospace);
let response = ui.add(button); let response = ui.add_sized(ui.spacing().interact_size, button);
let response = response.on_hover_text(format!( let response = response.on_hover_text(format!(
"{}{}{}\nDrag to edit or click to enter a value.", "{}{}{}\nDrag to edit or click to enter a value.",
prefix, prefix,