Touch support for PaneGrid and PickList (#650)
* touch events properly parsed and converted to logical size, button working * scrolling with a nice touch * fixed application state level touch cursor. panel_grid is touchable now. * format glicthes fixes * format glitches * tight format * fixed pane grid * fixing with upstream * Remove unused `touch` module from `iced_core` * Remove unused `crate::text` import in `iced_native` * Remove redundant match branch in `iced_winit` * Keep removed line break in `UserInterface::update` * Compute `text_size` only when bounds contains cursor in `overlay::menu` Co-authored-by: Héctor Ramón Jiménez <hector0193@gmail.com>
This commit is contained in:
parent
2f10a1f2a2
commit
9e453843b2
4 changed files with 93 additions and 71 deletions
|
|
@ -6,6 +6,7 @@ use crate::mouse;
|
|||
use crate::overlay;
|
||||
use crate::scrollable;
|
||||
use crate::text;
|
||||
use crate::touch;
|
||||
use crate::{
|
||||
Clipboard, Container, Element, Hasher, Layout, Length, Point, Rectangle,
|
||||
Scrollable, Size, Vector, Widget,
|
||||
|
|
@ -337,10 +338,11 @@ where
|
|||
}
|
||||
Event::Mouse(mouse::Event::CursorMoved { .. }) => {
|
||||
let bounds = layout.bounds();
|
||||
let text_size =
|
||||
self.text_size.unwrap_or(renderer.default_size());
|
||||
|
||||
if bounds.contains(cursor_position) {
|
||||
let text_size =
|
||||
self.text_size.unwrap_or(renderer.default_size());
|
||||
|
||||
*self.hovered_option = Some(
|
||||
((cursor_position.y - bounds.y)
|
||||
/ f32::from(text_size + self.padding * 2))
|
||||
|
|
@ -348,6 +350,26 @@ where
|
|||
);
|
||||
}
|
||||
}
|
||||
Event::Touch(touch::Event::FingerPressed { .. }) => {
|
||||
let bounds = layout.bounds();
|
||||
|
||||
if bounds.contains(cursor_position) {
|
||||
let text_size =
|
||||
self.text_size.unwrap_or(renderer.default_size());
|
||||
|
||||
*self.hovered_option = Some(
|
||||
((cursor_position.y - bounds.y)
|
||||
/ f32::from(text_size + self.padding * 2))
|
||||
as usize,
|
||||
);
|
||||
|
||||
if let Some(index) = *self.hovered_option {
|
||||
if let Some(option) = self.options.get(index) {
|
||||
*self.last_selection = Some(option.clone());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue