Compensate for borders in iced ParamSlider
This commit is contained in:
parent
2e18ae0ebc
commit
47fe8c35f7
1 changed files with 9 additions and 2 deletions
|
@ -235,8 +235,6 @@ impl<'a, P: Param> Widget<ParamMessage, Renderer> for ParamSlider<'a, P> {
|
||||||
clipboard: &mut dyn Clipboard,
|
clipboard: &mut dyn Clipboard,
|
||||||
shell: &mut Shell<'_, ParamMessage>,
|
shell: &mut Shell<'_, ParamMessage>,
|
||||||
) -> event::Status {
|
) -> event::Status {
|
||||||
let bounds = layout.bounds();
|
|
||||||
|
|
||||||
// The pressence of a value in `self.state.text_input_value` indicates that the field should
|
// The pressence of a value in `self.state.text_input_value` indicates that the field should
|
||||||
// be focussed. The field handles defocussing by itself
|
// be focussed. The field handles defocussing by itself
|
||||||
// FIMXE: This is super hacky, I have no idea how you can reuse the text input widget
|
// FIMXE: This is super hacky, I have no idea how you can reuse the text input widget
|
||||||
|
@ -298,6 +296,15 @@ impl<'a, P: Param> Widget<ParamMessage, Renderer> for ParamSlider<'a, P> {
|
||||||
return event::Status::Captured;
|
return event::Status::Captured;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Compensate for the border when handling these events
|
||||||
|
let bounds = layout.bounds();
|
||||||
|
let bounds = Rectangle {
|
||||||
|
x: bounds.x + BORDER_WIDTH,
|
||||||
|
y: bounds.y + BORDER_WIDTH,
|
||||||
|
width: bounds.width - (BORDER_WIDTH * 2.0),
|
||||||
|
height: bounds.height - (BORDER_WIDTH * 2.0),
|
||||||
|
};
|
||||||
|
|
||||||
match event {
|
match event {
|
||||||
Event::Mouse(mouse::Event::ButtonPressed(mouse::Button::Left))
|
Event::Mouse(mouse::Event::ButtonPressed(mouse::Button::Left))
|
||||||
| Event::Touch(touch::Event::FingerPressed { .. }) => {
|
| Event::Touch(touch::Event::FingerPressed { .. }) => {
|
||||||
|
|
Loading…
Add table
Reference in a new issue