From e19a07d40049f40f36d879a498fab4ce63778b27 Mon Sep 17 00:00:00 2001 From: Sebastian Imlay Date: Mon, 11 Nov 2019 20:29:58 -0800 Subject: Added initial touch events to support iOS --- native/src/widget/checkbox.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'native/src/widget/checkbox.rs') diff --git a/native/src/widget/checkbox.rs b/native/src/widget/checkbox.rs index b36d10a4..26665d8b 100644 --- a/native/src/widget/checkbox.rs +++ b/native/src/widget/checkbox.rs @@ -2,7 +2,7 @@ use std::hash::Hash; use crate::{ - input::{mouse, ButtonState}, + input::{mouse, touch::Touch, ButtonState}, layout, row, text, Align, Clipboard, Element, Event, Font, Hasher, HorizontalAlignment, Layout, Length, Point, Rectangle, Row, Text, VerticalAlignment, Widget, @@ -155,7 +155,8 @@ where Event::Mouse(mouse::Event::Input { button: mouse::Button::Left, state: ButtonState::Pressed, - }) => { + }) + | Event::Touch(Touch::Started { .. }) => { let mouse_over = layout.bounds().contains(cursor_position); if mouse_over { -- cgit From d3572e1b819ff4d40de4f39f48eab71b9d0d4d5e Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Thu, 19 Mar 2020 12:17:16 +0100 Subject: Turn `Touch` into a struct and add finger id --- native/src/widget/checkbox.rs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'native/src/widget/checkbox.rs') diff --git a/native/src/widget/checkbox.rs b/native/src/widget/checkbox.rs index 26665d8b..7b2345de 100644 --- a/native/src/widget/checkbox.rs +++ b/native/src/widget/checkbox.rs @@ -2,7 +2,7 @@ use std::hash::Hash; use crate::{ - input::{mouse, touch::Touch, ButtonState}, + input::{mouse, touch, ButtonState, Touch}, layout, row, text, Align, Clipboard, Element, Event, Font, Hasher, HorizontalAlignment, Layout, Length, Point, Rectangle, Row, Text, VerticalAlignment, Widget, @@ -156,7 +156,10 @@ where button: mouse::Button::Left, state: ButtonState::Pressed, }) - | Event::Touch(Touch::Started { .. }) => { + | Event::Touch(Touch { + phase: touch::Phase::Started, + .. + }) => { let mouse_over = layout.bounds().contains(cursor_position); if mouse_over { -- cgit From 3bdf931925067acbaabf040f6c437a54640ed1a0 Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Tue, 15 Dec 2020 06:38:46 +0100 Subject: Turn `Touch` into a `touch::Event` enum --- native/src/widget/checkbox.rs | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) (limited to 'native/src/widget/checkbox.rs') diff --git a/native/src/widget/checkbox.rs b/native/src/widget/checkbox.rs index 92175b25..77a82fad 100644 --- a/native/src/widget/checkbox.rs +++ b/native/src/widget/checkbox.rs @@ -6,7 +6,7 @@ use crate::layout; use crate::mouse; use crate::row; use crate::text; -use crate::touch::{self, Touch}; +use crate::touch; use crate::{ Align, Clipboard, Element, Hasher, HorizontalAlignment, Layout, Length, Point, Rectangle, Row, Text, VerticalAlignment, Widget, @@ -156,10 +156,7 @@ where ) -> event::Status { match event { Event::Mouse(mouse::Event::ButtonPressed(mouse::Button::Left)) - | Event::Touch(Touch { - phase: touch::Phase::Started, - .. - }) => { + | Event::Touch(touch::Event::FingerPressed { .. }) => { let mouse_over = layout.bounds().contains(cursor_position); if mouse_over { -- cgit From 21971e0037c2ddcb96fd48ea96332445de4137bb Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Wed, 10 Mar 2021 01:59:02 +0100 Subject: Make `Clipboard` argument in `Widget` trait mutable --- native/src/widget/checkbox.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'native/src/widget/checkbox.rs') diff --git a/native/src/widget/checkbox.rs b/native/src/widget/checkbox.rs index 77a82fad..6ce2e973 100644 --- a/native/src/widget/checkbox.rs +++ b/native/src/widget/checkbox.rs @@ -150,9 +150,9 @@ where event: Event, layout: Layout<'_>, cursor_position: Point, - messages: &mut Vec, _renderer: &Renderer, - _clipboard: Option<&dyn Clipboard>, + _clipboard: &mut dyn Clipboard, + messages: &mut Vec, ) -> event::Status { match event { Event::Mouse(mouse::Event::ButtonPressed(mouse::Button::Left)) -- cgit From 40d21d23659bdb9fc6a6166208adb351e188846b Mon Sep 17 00:00:00 2001 From: zdevwu Date: Mon, 17 May 2021 14:22:55 +0100 Subject: Added text color and font options for native radio and checkbox (#831) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * text color and font options to radio * code formatting * code formatting * code formatting * Added text_color for native checkbox * Removed clone as color has Copy * Fix code formatting with `cargo fmt` Co-authored-by: Héctor Ramón --- native/src/widget/checkbox.rs | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) (limited to 'native/src/widget/checkbox.rs') diff --git a/native/src/widget/checkbox.rs b/native/src/widget/checkbox.rs index 6ce2e973..0f21c873 100644 --- a/native/src/widget/checkbox.rs +++ b/native/src/widget/checkbox.rs @@ -8,8 +8,8 @@ use crate::row; use crate::text; use crate::touch; use crate::{ - Align, Clipboard, Element, Hasher, HorizontalAlignment, Layout, Length, - Point, Rectangle, Row, Text, VerticalAlignment, Widget, + Align, Clipboard, Color, Element, Hasher, HorizontalAlignment, Layout, + Length, Point, Rectangle, Row, Text, VerticalAlignment, Widget, }; /// A box that can be checked. @@ -39,6 +39,7 @@ pub struct Checkbox { spacing: u16, text_size: Option, font: Renderer::Font, + text_color: Option, style: Renderer::Style, } @@ -66,6 +67,7 @@ impl spacing: Renderer::DEFAULT_SPACING, text_size: None, font: Renderer::Font::default(), + text_color: None, style: Renderer::Style::default(), } } @@ -102,6 +104,12 @@ impl self } + /// Sets the text color of the [`Checkbox`] button. + pub fn text_color(mut self, color: Color) -> Self { + self.text_color = Some(color); + self + } + /// Sets the style of the [`Checkbox`]. pub fn style(mut self, style: impl Into) -> Self { self.style = style.into(); @@ -193,7 +201,7 @@ where &self.label, self.text_size.unwrap_or(renderer.default_size()), self.font, - None, + self.text_color, HorizontalAlignment::Left, VerticalAlignment::Center, ); -- cgit