Fix bug with the layout of wide DragValue
:s
This commit is contained in:
parent
c07f439b28
commit
0351662763
3 changed files with 13 additions and 2 deletions
|
@ -17,6 +17,7 @@ NOTE: [`eframe`](eframe/CHANGELOG.md), [`egui_web`](egui_web/CHANGELOG.md) and [
|
||||||
|
|
||||||
### Fixed 🐛
|
### Fixed 🐛
|
||||||
* Fix [defocus-bug on touch screens](https://github.com/emilk/egui/issues/288).
|
* Fix [defocus-bug on touch screens](https://github.com/emilk/egui/issues/288).
|
||||||
|
* Fix bug with the layout of wide `DragValue`:s.
|
||||||
|
|
||||||
## 0.11.0 - 2021-04-05 - Optimization, screen reader & new layout logic
|
## 0.11.0 - 2021-04-05 - Optimization, screen reader & new layout logic
|
||||||
|
|
||||||
|
|
|
@ -22,6 +22,7 @@ pub struct Button {
|
||||||
small: bool,
|
small: bool,
|
||||||
frame: bool,
|
frame: bool,
|
||||||
wrap: Option<bool>,
|
wrap: Option<bool>,
|
||||||
|
min_size: Vec2,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Button {
|
impl Button {
|
||||||
|
@ -35,6 +36,7 @@ impl Button {
|
||||||
small: false,
|
small: false,
|
||||||
frame: true,
|
frame: true,
|
||||||
wrap: None,
|
wrap: None,
|
||||||
|
min_size: Vec2::ZERO,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -99,6 +101,11 @@ impl Button {
|
||||||
self.wrap = Some(wrap);
|
self.wrap = Some(wrap);
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub(crate) fn min_size(mut self, min_size: Vec2) -> Self {
|
||||||
|
self.min_size = min_size;
|
||||||
|
self
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Button {
|
impl Button {
|
||||||
|
@ -112,6 +119,7 @@ impl Button {
|
||||||
small,
|
small,
|
||||||
frame,
|
frame,
|
||||||
wrap,
|
wrap,
|
||||||
|
min_size,
|
||||||
} = self;
|
} = self;
|
||||||
|
|
||||||
let mut button_padding = ui.spacing().button_padding;
|
let mut button_padding = ui.spacing().button_padding;
|
||||||
|
@ -132,6 +140,7 @@ impl Button {
|
||||||
if !small {
|
if !small {
|
||||||
desired_size.y = desired_size.y.at_least(ui.spacing().interact_size.y);
|
desired_size.y = desired_size.y.at_least(ui.spacing().interact_size.y);
|
||||||
}
|
}
|
||||||
|
desired_size = desired_size.at_least(min_size);
|
||||||
|
|
||||||
let (rect, response) = ui.allocate_at_least(desired_size, sense);
|
let (rect, response) = ui.allocate_at_least(desired_size, sense);
|
||||||
response.widget_info(|| WidgetInfo::labeled(WidgetType::Button, &galley.text));
|
response.widget_info(|| WidgetInfo::labeled(WidgetType::Button, &galley.text));
|
||||||
|
|
|
@ -266,9 +266,10 @@ 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)
|
||||||
.wrap(false);
|
.wrap(false)
|
||||||
|
.min_size(ui.spacing().interact_size); // TODO: find some more generic solution to this
|
||||||
|
|
||||||
let response = ui.add_sized(ui.spacing().interact_size, button);
|
let response = ui.add(button);
|
||||||
let response = response
|
let response = response
|
||||||
.on_hover_cursor(CursorIcon::ResizeHorizontal)
|
.on_hover_cursor(CursorIcon::ResizeHorizontal)
|
||||||
.on_hover_text(format!(
|
.on_hover_text(format!(
|
||||||
|
|
Loading…
Reference in a new issue