From 02fc83c02f061ec34e0f2edf45bae646975ed960 Mon Sep 17 00:00:00 2001 From: Zhuyuan Date: Wed, 14 Apr 2021 21:59:17 +0100 Subject: [PATCH 1/7] text color and font options to radio --- native/src/widget/radio.rs | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/native/src/widget/radio.rs b/native/src/widget/radio.rs index 9482a9b14e..7315a2a278 100644 --- a/native/src/widget/radio.rs +++ b/native/src/widget/radio.rs @@ -1,6 +1,6 @@ //! Create choices using radio buttons. use crate::event::{self, Event}; -use crate::layout; +use crate::{layout, Color}; use crate::mouse; use crate::row; use crate::text; @@ -47,11 +47,13 @@ pub struct Radio { size: u16, spacing: u16, text_size: Option, + text_color: Option, + font: Renderer::Font, style: Renderer::Style, } impl - Radio +Radio where Message: Clone, { @@ -81,6 +83,8 @@ where size: ::DEFAULT_SIZE, spacing: Renderer::DEFAULT_SPACING, //15 text_size: None, + text_color: None, + font: Default::default(), style: Renderer::Style::default(), } } @@ -109,6 +113,18 @@ where self } + /// Sets the text color of the [`Radio`] button. + pub fn text_color(mut self, color: Color) -> Self { + self.text_color = Some(color); + self + } + + /// Sets the text font of the [`Radio`] button. + pub fn font(mut self, font: Renderer::Font) -> Self { + self.font = font; + self + } + /// Sets the style of the [`Radio`] button. pub fn style(mut self, style: impl Into) -> Self { self.style = style.into(); @@ -196,8 +212,8 @@ where label_layout.bounds(), &self.label, self.text_size.unwrap_or(renderer.default_size()), - Default::default(), - None, + self.font, + self.text_color.clone(), HorizontalAlignment::Left, VerticalAlignment::Center, ); From 4f46b1d44e286609658ef1e1f847704bee966a7a Mon Sep 17 00:00:00 2001 From: Zhuyuan Date: Thu, 15 Apr 2021 00:42:49 +0100 Subject: [PATCH 2/7] code formatting --- native/src/widget/radio.rs | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/native/src/widget/radio.rs b/native/src/widget/radio.rs index 7315a2a278..18d5803bdd 100644 --- a/native/src/widget/radio.rs +++ b/native/src/widget/radio.rs @@ -1,16 +1,16 @@ //! Create choices using radio buttons. +use std::hash::Hash; + +use crate::{Color, layout}; +use crate::{ + Align, Clipboard, Element, Hasher, HorizontalAlignment, Layout, Length, + Point, Rectangle, Row, Text, VerticalAlignment, Widget, +}; use crate::event::{self, Event}; -use crate::{layout, Color}; use crate::mouse; use crate::row; use crate::text; use crate::touch; -use crate::{ - Align, Clipboard, Element, Hasher, HorizontalAlignment, Layout, Length, - Point, Rectangle, Row, Text, VerticalAlignment, Widget, -}; - -use std::hash::Hash; /// A circular button representing a choice. /// @@ -53,7 +53,7 @@ pub struct Radio { } impl -Radio + Radio where Message: Clone, { From c0139510fa4dd1dccd9a1c4dab4c23c7684d1537 Mon Sep 17 00:00:00 2001 From: Zhuyuan Date: Thu, 15 Apr 2021 00:53:52 +0100 Subject: [PATCH 3/7] code formatting --- native/src/widget/radio.rs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/native/src/widget/radio.rs b/native/src/widget/radio.rs index 18d5803bdd..031581c6e1 100644 --- a/native/src/widget/radio.rs +++ b/native/src/widget/radio.rs @@ -1,16 +1,16 @@ //! Create choices using radio buttons. use std::hash::Hash; -use crate::{Color, layout}; -use crate::{ - Align, Clipboard, Element, Hasher, HorizontalAlignment, Layout, Length, - Point, Rectangle, Row, Text, VerticalAlignment, Widget, -}; use crate::event::{self, Event}; use crate::mouse; use crate::row; use crate::text; use crate::touch; +use crate::{Color, layout}; +use crate::{ + Align, Clipboard, Element, Hasher, HorizontalAlignment, Layout, Length, + Point, Rectangle, Row, Text, VerticalAlignment, Widget, +}; /// A circular button representing a choice. /// From e41ffdc0bce9fc8ab72a7f685995bd07af69d56a Mon Sep 17 00:00:00 2001 From: Zhuyuan Date: Thu, 15 Apr 2021 00:57:12 +0100 Subject: [PATCH 4/7] code formatting --- native/src/widget/radio.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/native/src/widget/radio.rs b/native/src/widget/radio.rs index 031581c6e1..f319b9dfbf 100644 --- a/native/src/widget/radio.rs +++ b/native/src/widget/radio.rs @@ -6,7 +6,7 @@ use crate::mouse; use crate::row; use crate::text; use crate::touch; -use crate::{Color, layout}; +use crate::{layout, Color}; use crate::{ Align, Clipboard, Element, Hasher, HorizontalAlignment, Layout, Length, Point, Rectangle, Row, Text, VerticalAlignment, Widget, From f883d995bbfddc58b0dbd8614ef9bf532dfae931 Mon Sep 17 00:00:00 2001 From: Zhuyuan Date: Mon, 3 May 2021 11:23:24 +0100 Subject: [PATCH 5/7] Added text_color for native checkbox --- native/src/widget/checkbox.rs | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/native/src/widget/checkbox.rs b/native/src/widget/checkbox.rs index 6ce2e973fc..876734e211 100644 --- a/native/src/widget/checkbox.rs +++ b/native/src/widget/checkbox.rs @@ -8,7 +8,7 @@ use crate::row; use crate::text; use crate::touch; use crate::{ - Align, Clipboard, Element, Hasher, HorizontalAlignment, Layout, Length, + Align, Clipboard, Color, Element, Hasher, HorizontalAlignment, Layout, Length, Point, Rectangle, Row, Text, VerticalAlignment, Widget, }; @@ -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, ); From 3b678608b65812e0535a7d26733528af523591d0 Mon Sep 17 00:00:00 2001 From: Zhuyuan Date: Tue, 4 May 2021 22:48:49 +0100 Subject: [PATCH 6/7] Removed clone as color has Copy --- native/src/widget/radio.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/native/src/widget/radio.rs b/native/src/widget/radio.rs index f319b9dfbf..dee82d1fcc 100644 --- a/native/src/widget/radio.rs +++ b/native/src/widget/radio.rs @@ -213,7 +213,7 @@ where &self.label, self.text_size.unwrap_or(renderer.default_size()), self.font, - self.text_color.clone(), + self.text_color, HorizontalAlignment::Left, VerticalAlignment::Center, ); From 87b8610ad8bd4576ccfc3c18467e213cf15afda8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?H=C3=A9ctor=20Ram=C3=B3n?= Date: Mon, 17 May 2021 19:57:47 +0700 Subject: [PATCH 7/7] Fix code formatting with `cargo fmt` --- native/src/widget/checkbox.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/native/src/widget/checkbox.rs b/native/src/widget/checkbox.rs index 876734e211..0f21c873c9 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, Color, 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.