Compare commits
No commits in common. "rei/touch" and "master" have entirely different histories.
|
@ -1,5 +1,5 @@
|
|||
//! Create interactive, native cross-platform applications.
|
||||
use crate::{mouse, Error, Executor, Runtime, Vector};
|
||||
use crate::{mouse, Error, Executor, Runtime};
|
||||
|
||||
pub use iced_winit::Application;
|
||||
|
||||
|
@ -187,7 +187,6 @@ async fn run_instance<A, E, C>(
|
|||
let statuses = user_interface.update(
|
||||
&events,
|
||||
state.cursor_position(),
|
||||
Vector::new(0.0, 0.0),
|
||||
&mut renderer,
|
||||
&mut clipboard,
|
||||
&mut messages,
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
use crate::event::{self, Event};
|
||||
use crate::layout;
|
||||
use crate::overlay;
|
||||
use crate::{layout, Vector};
|
||||
use crate::{
|
||||
Clipboard, Color, Hasher, Layout, Length, Point, Rectangle, Widget,
|
||||
};
|
||||
|
@ -223,7 +223,6 @@ where
|
|||
event: Event,
|
||||
layout: Layout<'_>,
|
||||
cursor_position: Point,
|
||||
scroll_offset: Vector<f32>,
|
||||
renderer: &Renderer,
|
||||
clipboard: &mut dyn Clipboard,
|
||||
messages: &mut Vec<Message>,
|
||||
|
@ -232,7 +231,6 @@ where
|
|||
event,
|
||||
layout,
|
||||
cursor_position,
|
||||
scroll_offset,
|
||||
renderer,
|
||||
clipboard,
|
||||
messages,
|
||||
|
@ -313,7 +311,6 @@ where
|
|||
event: Event,
|
||||
layout: Layout<'_>,
|
||||
cursor_position: Point,
|
||||
scroll_offset: Vector<f32>,
|
||||
renderer: &Renderer,
|
||||
clipboard: &mut dyn Clipboard,
|
||||
messages: &mut Vec<B>,
|
||||
|
@ -324,7 +321,6 @@ where
|
|||
event,
|
||||
layout,
|
||||
cursor_position,
|
||||
scroll_offset,
|
||||
renderer,
|
||||
clipboard,
|
||||
&mut original_messages,
|
||||
|
@ -405,7 +401,6 @@ where
|
|||
event: Event,
|
||||
layout: Layout<'_>,
|
||||
cursor_position: Point,
|
||||
scroll_offset: Vector<f32>,
|
||||
renderer: &Renderer,
|
||||
clipboard: &mut dyn Clipboard,
|
||||
messages: &mut Vec<Message>,
|
||||
|
@ -414,7 +409,6 @@ where
|
|||
event,
|
||||
layout,
|
||||
cursor_position,
|
||||
scroll_offset,
|
||||
renderer,
|
||||
clipboard,
|
||||
messages,
|
||||
|
|
|
@ -7,7 +7,7 @@ pub use element::Element;
|
|||
pub use menu::Menu;
|
||||
|
||||
use crate::event::{self, Event};
|
||||
use crate::{layout, Vector};
|
||||
use crate::layout;
|
||||
use crate::{Clipboard, Hasher, Layout, Point, Size};
|
||||
|
||||
/// An interactive component that can be displayed on top of other widgets.
|
||||
|
@ -67,7 +67,6 @@ where
|
|||
_event: Event,
|
||||
_layout: Layout<'_>,
|
||||
_cursor_position: Point,
|
||||
_scroll_offset: Vector<f32>,
|
||||
_renderer: &Renderer,
|
||||
_clipboard: &mut dyn Clipboard,
|
||||
_messages: &mut Vec<Message>,
|
||||
|
|
|
@ -53,7 +53,6 @@ where
|
|||
event: Event,
|
||||
layout: Layout<'_>,
|
||||
cursor_position: Point,
|
||||
scroll_offset: Vector<f32>,
|
||||
renderer: &Renderer,
|
||||
clipboard: &mut dyn Clipboard,
|
||||
messages: &mut Vec<Message>,
|
||||
|
@ -62,7 +61,6 @@ where
|
|||
event,
|
||||
layout,
|
||||
cursor_position,
|
||||
scroll_offset,
|
||||
renderer,
|
||||
clipboard,
|
||||
messages,
|
||||
|
@ -119,7 +117,6 @@ where
|
|||
event: Event,
|
||||
layout: Layout<'_>,
|
||||
cursor_position: Point,
|
||||
scroll_offset: Vector<f32>,
|
||||
renderer: &Renderer,
|
||||
clipboard: &mut dyn Clipboard,
|
||||
messages: &mut Vec<B>,
|
||||
|
@ -130,7 +127,6 @@ where
|
|||
event,
|
||||
layout,
|
||||
cursor_position,
|
||||
scroll_offset,
|
||||
renderer,
|
||||
clipboard,
|
||||
&mut original_messages,
|
||||
|
|
|
@ -219,7 +219,6 @@ where
|
|||
event: Event,
|
||||
layout: Layout<'_>,
|
||||
cursor_position: Point,
|
||||
scroll_offset: Vector<f32>,
|
||||
renderer: &Renderer,
|
||||
clipboard: &mut dyn Clipboard,
|
||||
messages: &mut Vec<Message>,
|
||||
|
@ -228,7 +227,6 @@ where
|
|||
event.clone(),
|
||||
layout,
|
||||
cursor_position,
|
||||
scroll_offset,
|
||||
renderer,
|
||||
clipboard,
|
||||
messages,
|
||||
|
@ -322,7 +320,6 @@ where
|
|||
event: Event,
|
||||
layout: Layout<'_>,
|
||||
cursor_position: Point,
|
||||
_scroll_offset: Vector<f32>,
|
||||
renderer: &Renderer,
|
||||
_clipboard: &mut dyn Clipboard,
|
||||
_messages: &mut Vec<Message>,
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
use crate::{
|
||||
Cache, Command, Debug, Event, Point, Program, Renderer, Size,
|
||||
UserInterface, Vector,
|
||||
Cache, Command, Debug, Event, Point, Program, Renderer, Size, UserInterface,
|
||||
};
|
||||
|
||||
/// The execution state of a [`Program`]. It leverages caching, event
|
||||
|
@ -91,7 +90,6 @@ where
|
|||
&mut self,
|
||||
bounds: Size,
|
||||
cursor_position: Point,
|
||||
scroll_offset: Vector<f32>,
|
||||
renderer: &mut P::Renderer,
|
||||
clipboard: &mut P::Clipboard,
|
||||
debug: &mut Debug,
|
||||
|
@ -110,7 +108,6 @@ where
|
|||
let _ = user_interface.update(
|
||||
&self.queued_events,
|
||||
cursor_position,
|
||||
scroll_offset,
|
||||
renderer,
|
||||
clipboard,
|
||||
&mut messages,
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
use crate::event::{self, Event};
|
||||
use crate::layout;
|
||||
use crate::overlay;
|
||||
use crate::{layout, Vector};
|
||||
use crate::{Clipboard, Element, Layout, Point, Rectangle, Size};
|
||||
|
||||
use std::hash::Hasher;
|
||||
|
@ -194,7 +194,6 @@ where
|
|||
&mut self,
|
||||
events: &[Event],
|
||||
cursor_position: Point,
|
||||
scroll_offset: Vector<f32>,
|
||||
renderer: &Renderer,
|
||||
clipboard: &mut dyn Clipboard,
|
||||
messages: &mut Vec<Message>,
|
||||
|
@ -217,7 +216,6 @@ where
|
|||
event,
|
||||
Layout::new(&layer.layout),
|
||||
cursor_position,
|
||||
scroll_offset,
|
||||
renderer,
|
||||
clipboard,
|
||||
messages,
|
||||
|
@ -249,7 +247,6 @@ where
|
|||
event,
|
||||
Layout::new(&self.base.layout),
|
||||
base_cursor,
|
||||
Vector::new(0.0, 0.0),
|
||||
renderer,
|
||||
clipboard,
|
||||
messages,
|
||||
|
|
|
@ -79,8 +79,8 @@ pub use toggler::Toggler;
|
|||
pub use tooltip::Tooltip;
|
||||
|
||||
use crate::event::{self, Event};
|
||||
use crate::layout;
|
||||
use crate::overlay;
|
||||
use crate::{layout, Vector};
|
||||
use crate::{Clipboard, Hasher, Layout, Length, Point, Rectangle};
|
||||
|
||||
/// A component that displays information and allows interaction.
|
||||
|
@ -167,7 +167,6 @@ where
|
|||
_event: Event,
|
||||
_layout: Layout<'_>,
|
||||
_cursor_position: Point,
|
||||
_scroll_offset: Vector<f32>,
|
||||
_renderer: &Renderer,
|
||||
_clipboard: &mut dyn Clipboard,
|
||||
_messages: &mut Vec<Message>,
|
||||
|
|
|
@ -2,16 +2,14 @@
|
|||
//!
|
||||
//! A [`Button`] has some local [`State`].
|
||||
use crate::event::{self, Event};
|
||||
use crate::layout;
|
||||
use crate::mouse;
|
||||
use crate::overlay;
|
||||
use crate::touch;
|
||||
use crate::touch::Finger;
|
||||
use crate::{layout, Vector};
|
||||
use crate::{
|
||||
Clipboard, Element, Hasher, Layout, Length, Padding, Point, Rectangle,
|
||||
Widget,
|
||||
};
|
||||
use std::collections::HashSet;
|
||||
use std::hash::Hash;
|
||||
|
||||
/// A generic widget that produces a message when pressed.
|
||||
|
@ -65,7 +63,6 @@ pub struct Button<'a, Message, Renderer: self::Renderer> {
|
|||
min_height: u32,
|
||||
padding: Padding,
|
||||
style: Renderer::Style,
|
||||
fingers_mid_press: HashSet<Finger>,
|
||||
}
|
||||
|
||||
impl<'a, Message, Renderer> Button<'a, Message, Renderer>
|
||||
|
@ -89,8 +86,6 @@ where
|
|||
min_height: 0,
|
||||
padding: Renderer::DEFAULT_PADDING,
|
||||
style: Renderer::Style::default(),
|
||||
|
||||
fingers_mid_press: HashSet::with_capacity(2),
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -193,7 +188,6 @@ where
|
|||
event: Event,
|
||||
layout: Layout<'_>,
|
||||
cursor_position: Point,
|
||||
scroll_offset: Vector<f32>,
|
||||
renderer: &Renderer,
|
||||
clipboard: &mut dyn Clipboard,
|
||||
messages: &mut Vec<Message>,
|
||||
|
@ -202,7 +196,6 @@ where
|
|||
event.clone(),
|
||||
layout.children().next().unwrap(),
|
||||
cursor_position,
|
||||
scroll_offset,
|
||||
renderer,
|
||||
clipboard,
|
||||
messages,
|
||||
|
@ -211,7 +204,8 @@ where
|
|||
}
|
||||
|
||||
match event {
|
||||
Event::Mouse(mouse::Event::ButtonPressed(mouse::Button::Left)) => {
|
||||
Event::Mouse(mouse::Event::ButtonPressed(mouse::Button::Left))
|
||||
| Event::Touch(touch::Event::FingerPressed { .. }) => {
|
||||
if self.on_press.is_some() {
|
||||
let bounds = layout.bounds();
|
||||
|
||||
|
@ -222,7 +216,8 @@ where
|
|||
}
|
||||
}
|
||||
}
|
||||
Event::Mouse(mouse::Event::ButtonReleased(mouse::Button::Left)) => {
|
||||
Event::Mouse(mouse::Event::ButtonReleased(mouse::Button::Left))
|
||||
| Event::Touch(touch::Event::FingerLifted { .. }) => {
|
||||
if let Some(on_press) = self.on_press.clone() {
|
||||
let bounds = layout.bounds();
|
||||
|
||||
|
@ -237,46 +232,8 @@ where
|
|||
}
|
||||
}
|
||||
}
|
||||
Event::Touch(x) => {
|
||||
eprintln!(
|
||||
"B {:?} Bds {:?} P {:?}",
|
||||
x,
|
||||
layout.bounds(),
|
||||
self.fingers_mid_press
|
||||
);
|
||||
match x {
|
||||
touch::Event::FingerPressed { id, position } => {
|
||||
if layout.bounds().contains(position + scroll_offset) {
|
||||
eprintln!("ins");
|
||||
let _ = self.fingers_mid_press.insert(id);
|
||||
|
||||
return event::Status::Captured;
|
||||
}
|
||||
}
|
||||
touch::Event::FingerMoved { id, position } => {
|
||||
if !layout.bounds().contains(position + scroll_offset) {
|
||||
eprintln!("exited");
|
||||
let _ = self.fingers_mid_press.remove(&id);
|
||||
} else {
|
||||
return event::Status::Captured;
|
||||
}
|
||||
}
|
||||
touch::Event::FingerLifted { id, .. } => {
|
||||
// !!! The finger position seems to be buggy on the Lift event.
|
||||
if self.fingers_mid_press.remove(&id) {
|
||||
eprintln!("lifted");
|
||||
// this should be treated as a click
|
||||
if let Some(on_press) = self.on_press.clone() {
|
||||
messages.push(on_press);
|
||||
}
|
||||
|
||||
return event::Status::Captured;
|
||||
}
|
||||
}
|
||||
touch::Event::FingerLost { id, .. } => {
|
||||
let _ = self.fingers_mid_press.remove(&id);
|
||||
}
|
||||
}
|
||||
Event::Touch(touch::Event::FingerLost { .. }) => {
|
||||
self.state.is_pressed = false;
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
|
|
|
@ -2,11 +2,11 @@
|
|||
use std::hash::Hash;
|
||||
|
||||
use crate::event::{self, Event};
|
||||
use crate::layout;
|
||||
use crate::mouse;
|
||||
use crate::row;
|
||||
use crate::text;
|
||||
use crate::touch;
|
||||
use crate::{layout, Vector};
|
||||
use crate::{
|
||||
Align, Clipboard, Color, Element, Hasher, HorizontalAlignment, Layout,
|
||||
Length, Point, Rectangle, Row, Text, VerticalAlignment, Widget,
|
||||
|
@ -158,7 +158,6 @@ where
|
|||
event: Event,
|
||||
layout: Layout<'_>,
|
||||
cursor_position: Point,
|
||||
_scroll_offset: Vector<f32>,
|
||||
_renderer: &Renderer,
|
||||
_clipboard: &mut dyn Clipboard,
|
||||
messages: &mut Vec<Message>,
|
||||
|
|
|
@ -2,8 +2,8 @@
|
|||
use std::hash::Hash;
|
||||
|
||||
use crate::event::{self, Event};
|
||||
use crate::layout;
|
||||
use crate::overlay;
|
||||
use crate::{layout, Vector};
|
||||
use crate::{
|
||||
Align, Clipboard, Element, Hasher, Layout, Length, Padding, Point,
|
||||
Rectangle, Widget,
|
||||
|
@ -142,7 +142,6 @@ where
|
|||
event: Event,
|
||||
layout: Layout<'_>,
|
||||
cursor_position: Point,
|
||||
scroll_offset: Vector<f32>,
|
||||
renderer: &Renderer,
|
||||
clipboard: &mut dyn Clipboard,
|
||||
messages: &mut Vec<Message>,
|
||||
|
@ -155,7 +154,6 @@ where
|
|||
event.clone(),
|
||||
layout,
|
||||
cursor_position,
|
||||
scroll_offset,
|
||||
renderer,
|
||||
clipboard,
|
||||
messages,
|
||||
|
|
|
@ -2,8 +2,8 @@
|
|||
use std::hash::Hash;
|
||||
|
||||
use crate::event::{self, Event};
|
||||
use crate::layout;
|
||||
use crate::overlay;
|
||||
use crate::{layout, Vector};
|
||||
use crate::{
|
||||
Align, Clipboard, Element, Hasher, Layout, Length, Padding, Point,
|
||||
Rectangle, Widget,
|
||||
|
@ -153,7 +153,6 @@ where
|
|||
event: Event,
|
||||
layout: Layout<'_>,
|
||||
cursor_position: Point,
|
||||
scroll_offset: Vector<f32>,
|
||||
renderer: &Renderer,
|
||||
clipboard: &mut dyn Clipboard,
|
||||
messages: &mut Vec<Message>,
|
||||
|
@ -162,7 +161,6 @@ where
|
|||
event,
|
||||
layout.children().next().unwrap(),
|
||||
cursor_position,
|
||||
scroll_offset,
|
||||
renderer,
|
||||
clipboard,
|
||||
messages,
|
||||
|
|
|
@ -155,7 +155,6 @@ where
|
|||
event: Event,
|
||||
layout: Layout<'_>,
|
||||
cursor_position: Point,
|
||||
_scroll_offset: Vector<f32>,
|
||||
renderer: &Renderer,
|
||||
_clipboard: &mut dyn Clipboard,
|
||||
_messages: &mut Vec<Message>,
|
||||
|
|
|
@ -362,7 +362,6 @@ where
|
|||
event: Event,
|
||||
layout: Layout<'_>,
|
||||
cursor_position: Point,
|
||||
scroll_offset: Vector<f32>,
|
||||
renderer: &Renderer,
|
||||
clipboard: &mut dyn Clipboard,
|
||||
messages: &mut Vec<Message>,
|
||||
|
@ -462,7 +461,6 @@ where
|
|||
event.clone(),
|
||||
layout,
|
||||
cursor_position,
|
||||
scroll_offset,
|
||||
renderer,
|
||||
clipboard,
|
||||
messages,
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
use crate::container;
|
||||
use crate::event::{self, Event};
|
||||
use crate::layout;
|
||||
use crate::overlay;
|
||||
use crate::pane_grid::{self, TitleBar};
|
||||
use crate::{container, Vector};
|
||||
use crate::{Clipboard, Element, Hasher, Layout, Point, Rectangle, Size};
|
||||
|
||||
/// The content of a [`Pane`].
|
||||
|
@ -146,7 +146,6 @@ where
|
|||
event: Event,
|
||||
layout: Layout<'_>,
|
||||
cursor_position: Point,
|
||||
scroll_offset: Vector<f32>,
|
||||
renderer: &Renderer,
|
||||
clipboard: &mut dyn Clipboard,
|
||||
messages: &mut Vec<Message>,
|
||||
|
@ -160,7 +159,6 @@ where
|
|||
event.clone(),
|
||||
children.next().unwrap(),
|
||||
cursor_position,
|
||||
scroll_offset,
|
||||
renderer,
|
||||
clipboard,
|
||||
messages,
|
||||
|
@ -175,7 +173,6 @@ where
|
|||
event,
|
||||
body_layout,
|
||||
cursor_position,
|
||||
scroll_offset,
|
||||
renderer,
|
||||
clipboard,
|
||||
messages,
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
use crate::container;
|
||||
use crate::event::{self, Event};
|
||||
use crate::layout;
|
||||
use crate::overlay;
|
||||
use crate::pane_grid;
|
||||
use crate::{container, Vector};
|
||||
use crate::{
|
||||
Clipboard, Element, Hasher, Layout, Padding, Point, Rectangle, Size,
|
||||
};
|
||||
|
@ -207,7 +207,6 @@ where
|
|||
event: Event,
|
||||
layout: Layout<'_>,
|
||||
cursor_position: Point,
|
||||
scroll_offset: Vector<f32>,
|
||||
renderer: &Renderer,
|
||||
clipboard: &mut dyn Clipboard,
|
||||
messages: &mut Vec<Message>,
|
||||
|
@ -225,7 +224,6 @@ where
|
|||
event.clone(),
|
||||
controls_layout,
|
||||
cursor_position,
|
||||
scroll_offset,
|
||||
renderer,
|
||||
clipboard,
|
||||
messages,
|
||||
|
@ -238,7 +236,6 @@ where
|
|||
event,
|
||||
title_layout,
|
||||
cursor_position,
|
||||
scroll_offset,
|
||||
renderer,
|
||||
clipboard,
|
||||
messages,
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
//! Display a dropdown list of selectable values.
|
||||
use crate::event::{self, Event};
|
||||
use crate::layout;
|
||||
use crate::mouse;
|
||||
use crate::overlay;
|
||||
use crate::overlay::menu::{self, Menu};
|
||||
use crate::scrollable;
|
||||
use crate::text;
|
||||
use crate::touch;
|
||||
use crate::{layout, Vector};
|
||||
use crate::{
|
||||
Clipboard, Element, Hasher, Layout, Length, Padding, Point, Rectangle,
|
||||
Size, Widget,
|
||||
|
@ -211,7 +211,6 @@ where
|
|||
event: Event,
|
||||
layout: Layout<'_>,
|
||||
cursor_position: Point,
|
||||
_scroll_offset: Vector<f32>,
|
||||
_renderer: &Renderer,
|
||||
_clipboard: &mut dyn Clipboard,
|
||||
messages: &mut Vec<Message>,
|
||||
|
|
|
@ -2,11 +2,11 @@
|
|||
use std::hash::Hash;
|
||||
|
||||
use crate::event::{self, Event};
|
||||
use crate::mouse;
|
||||
use crate::row;
|
||||
use crate::text;
|
||||
use crate::touch;
|
||||
use crate::{layout, Color};
|
||||
use crate::{mouse, Vector};
|
||||
use crate::{
|
||||
Align, Clipboard, Element, Hasher, HorizontalAlignment, Layout, Length,
|
||||
Point, Rectangle, Row, Text, VerticalAlignment, Widget,
|
||||
|
@ -172,7 +172,6 @@ where
|
|||
event: Event,
|
||||
layout: Layout<'_>,
|
||||
cursor_position: Point,
|
||||
_scroll_offset: Vector<f32>,
|
||||
_renderer: &Renderer,
|
||||
_clipboard: &mut dyn Clipboard,
|
||||
messages: &mut Vec<Message>,
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
//! Distribute content horizontally.
|
||||
use crate::event::{self, Event};
|
||||
use crate::layout;
|
||||
use crate::overlay;
|
||||
use crate::{layout, Vector};
|
||||
use crate::{
|
||||
Align, Clipboard, Element, Hasher, Layout, Length, Padding, Point,
|
||||
Rectangle, Widget,
|
||||
|
@ -141,7 +141,6 @@ where
|
|||
event: Event,
|
||||
layout: Layout<'_>,
|
||||
cursor_position: Point,
|
||||
scroll_offset: Vector<f32>,
|
||||
renderer: &Renderer,
|
||||
clipboard: &mut dyn Clipboard,
|
||||
messages: &mut Vec<Message>,
|
||||
|
@ -154,7 +153,6 @@ where
|
|||
event.clone(),
|
||||
layout,
|
||||
cursor_position,
|
||||
scroll_offset,
|
||||
renderer,
|
||||
clipboard,
|
||||
messages,
|
||||
|
|
|
@ -192,7 +192,6 @@ where
|
|||
event: Event,
|
||||
layout: Layout<'_>,
|
||||
cursor_position: Point,
|
||||
scroll_offset: Vector<f32>,
|
||||
renderer: &Renderer,
|
||||
clipboard: &mut dyn Clipboard,
|
||||
messages: &mut Vec<Message>,
|
||||
|
@ -236,7 +235,6 @@ where
|
|||
event.clone(),
|
||||
content,
|
||||
cursor_position,
|
||||
scroll_offset + Vector::new(0.0, self.state.offset.absolute(bounds, content_bounds)),
|
||||
renderer,
|
||||
clipboard,
|
||||
messages,
|
||||
|
|
|
@ -2,9 +2,9 @@
|
|||
//!
|
||||
//! A [`Slider`] has some local [`State`].
|
||||
use crate::event::{self, Event};
|
||||
use crate::layout;
|
||||
use crate::mouse;
|
||||
use crate::touch;
|
||||
use crate::{layout, Vector};
|
||||
use crate::{
|
||||
Clipboard, Element, Hasher, Layout, Length, Point, Rectangle, Size, Widget,
|
||||
};
|
||||
|
@ -180,7 +180,6 @@ where
|
|||
event: Event,
|
||||
layout: Layout<'_>,
|
||||
cursor_position: Point,
|
||||
_scroll_offset: Vector<f32>,
|
||||
_renderer: &Renderer,
|
||||
_clipboard: &mut dyn Clipboard,
|
||||
messages: &mut Vec<Message>,
|
||||
|
|
|
@ -12,11 +12,11 @@ pub use value::Value;
|
|||
use editor::Editor;
|
||||
|
||||
use crate::event::{self, Event};
|
||||
use crate::keyboard;
|
||||
use crate::layout;
|
||||
use crate::mouse::{self, click};
|
||||
use crate::text;
|
||||
use crate::touch;
|
||||
use crate::{keyboard, Vector};
|
||||
use crate::{
|
||||
Clipboard, Element, Hasher, Layout, Length, Padding, Point, Rectangle,
|
||||
Size, Widget,
|
||||
|
@ -246,7 +246,6 @@ where
|
|||
event: Event,
|
||||
layout: Layout<'_>,
|
||||
cursor_position: Point,
|
||||
_scroll_offset: Vector<f32>,
|
||||
renderer: &Renderer,
|
||||
clipboard: &mut dyn Clipboard,
|
||||
messages: &mut Vec<Message>,
|
||||
|
|
|
@ -1,13 +1,11 @@
|
|||
//! Show toggle controls using togglers.
|
||||
use std::hash::Hash;
|
||||
|
||||
use crate::touch::Finger;
|
||||
use crate::{
|
||||
event, layout, mouse, row, text, touch, Align, Clipboard, Element, Event,
|
||||
Hasher, HorizontalAlignment, Layout, Length, Point, Rectangle, Row, Text,
|
||||
Vector, VerticalAlignment, Widget,
|
||||
event, layout, mouse, row, text, Align, Clipboard, Element, Event, Hasher,
|
||||
HorizontalAlignment, Layout, Length, Point, Rectangle, Row, Text,
|
||||
VerticalAlignment, Widget,
|
||||
};
|
||||
use std::collections::HashSet;
|
||||
|
||||
/// A toggler widget
|
||||
///
|
||||
|
@ -36,8 +34,6 @@ pub struct Toggler<Message, Renderer: self::Renderer + text::Renderer> {
|
|||
spacing: u16,
|
||||
font: Renderer::Font,
|
||||
style: Renderer::Style,
|
||||
|
||||
fingers_mid_press: HashSet<Finger>,
|
||||
}
|
||||
|
||||
impl<Message, Renderer: self::Renderer + text::Renderer>
|
||||
|
@ -70,8 +66,6 @@ impl<Message, Renderer: self::Renderer + text::Renderer>
|
|||
spacing: 0,
|
||||
font: Renderer::Font::default(),
|
||||
style: Renderer::Style::default(),
|
||||
|
||||
fingers_mid_press: HashSet::with_capacity(2),
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -164,7 +158,6 @@ where
|
|||
event: Event,
|
||||
layout: Layout<'_>,
|
||||
cursor_position: Point,
|
||||
scroll_offset: Vector<f32>,
|
||||
_renderer: &Renderer,
|
||||
_clipboard: &mut dyn Clipboard,
|
||||
messages: &mut Vec<Message>,
|
||||
|
@ -181,45 +174,6 @@ where
|
|||
event::Status::Ignored
|
||||
}
|
||||
}
|
||||
Event::Touch(x) => {
|
||||
match x {
|
||||
touch::Event::FingerPressed { id, position } => {
|
||||
if layout.bounds().contains(position + scroll_offset) {
|
||||
let _ = self.fingers_mid_press.insert(id);
|
||||
|
||||
event::Status::Captured
|
||||
} else {
|
||||
event::Status::Ignored
|
||||
}
|
||||
}
|
||||
touch::Event::FingerMoved { id, position } => {
|
||||
if !layout.bounds().contains(position + scroll_offset) {
|
||||
let _ = self.fingers_mid_press.remove(&id);
|
||||
|
||||
event::Status::Captured
|
||||
} else {
|
||||
event::Status::Ignored
|
||||
}
|
||||
}
|
||||
touch::Event::FingerLifted { id, .. } => {
|
||||
// !!! The finger position seems to be buggy on the Lift event.
|
||||
if self.fingers_mid_press.remove(&id)
|
||||
// && layout.bounds().contains(position)
|
||||
{
|
||||
// this should be treated as a click
|
||||
messages.push((self.on_toggle)(!self.is_active));
|
||||
|
||||
event::Status::Captured
|
||||
} else {
|
||||
event::Status::Ignored
|
||||
}
|
||||
}
|
||||
touch::Event::FingerLost { id, .. } => {
|
||||
let _ = self.fingers_mid_press.remove(&id);
|
||||
event::Status::Ignored
|
||||
}
|
||||
}
|
||||
}
|
||||
_ => event::Status::Ignored,
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,7 +7,7 @@ use crate::widget::container;
|
|||
use crate::widget::text::{self, Text};
|
||||
use crate::{
|
||||
event, layout, Clipboard, Element, Event, Hasher, Layout, Length, Point,
|
||||
Vector, Widget,
|
||||
Widget,
|
||||
};
|
||||
|
||||
/// An element to display a widget over another.
|
||||
|
@ -120,7 +120,6 @@ where
|
|||
event: Event,
|
||||
layout: Layout<'_>,
|
||||
cursor_position: Point,
|
||||
scroll_offset: Vector<f32>,
|
||||
renderer: &Renderer,
|
||||
clipboard: &mut dyn Clipboard,
|
||||
messages: &mut Vec<Message>,
|
||||
|
@ -129,7 +128,6 @@ where
|
|||
event,
|
||||
layout,
|
||||
cursor_position,
|
||||
scroll_offset,
|
||||
renderer,
|
||||
clipboard,
|
||||
messages,
|
||||
|
|
|
@ -3,8 +3,8 @@ mod state;
|
|||
|
||||
pub use state::State;
|
||||
|
||||
use crate::conversion;
|
||||
use crate::mouse;
|
||||
use crate::{conversion, Vector};
|
||||
use crate::{
|
||||
Clipboard, Color, Command, Debug, Error, Executor, Mode, Proxy, Runtime,
|
||||
Settings, Size, Subscription,
|
||||
|
@ -261,7 +261,6 @@ async fn run_instance<A, E, C>(
|
|||
let statuses = user_interface.update(
|
||||
&events,
|
||||
state.cursor_position(),
|
||||
Vector::new(0.0, 0.0),
|
||||
&mut renderer,
|
||||
&mut clipboard,
|
||||
&mut messages,
|
||||
|
|
Loading…
Reference in New Issue