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