From c7b170da6d180f80e539910cccb543720fa3713c Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Sun, 29 Dec 2019 10:57:01 +0100 Subject: Draft `Style` and `StyleSheet` for `Button` --- native/src/renderer/null.rs | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'native/src/renderer/null.rs') diff --git a/native/src/renderer/null.rs b/native/src/renderer/null.rs index 43076d61..1be669c2 100644 --- a/native/src/renderer/null.rs +++ b/native/src/renderer/null.rs @@ -1,7 +1,7 @@ use crate::{ - button, checkbox, column, radio, row, scrollable, text, text_input, - Background, Color, Element, Font, HorizontalAlignment, Layout, Point, - Rectangle, Renderer, Size, VerticalAlignment, + button, checkbox, column, radio, row, scrollable, text, text_input, Color, + Element, Font, HorizontalAlignment, Layout, Point, Rectangle, Renderer, + Size, VerticalAlignment, }; /// A renderer that does nothing. @@ -117,13 +117,14 @@ impl text_input::Renderer for Null { } impl button::Renderer for Null { + type Style = (); + fn draw( &mut self, _bounds: Rectangle, _cursor_position: Point, _is_pressed: bool, - _background: Option, - _border_radius: u16, + _style: &Self::Style, _content: Self::Output, ) -> Self::Output { } -- cgit From 8caa66be2708b1c83e20d905d69902c2567c4692 Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Mon, 30 Dec 2019 12:14:26 +0100 Subject: Add `Renderer::Defaults` and style inheritance --- native/src/renderer/null.rs | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) (limited to 'native/src/renderer/null.rs') diff --git a/native/src/renderer/null.rs b/native/src/renderer/null.rs index 1be669c2..56d7e472 100644 --- a/native/src/renderer/null.rs +++ b/native/src/renderer/null.rs @@ -5,16 +5,26 @@ use crate::{ }; /// A renderer that does nothing. +/// +/// It can be useful if you are writing tests! #[derive(Debug, Clone, Copy)] pub struct Null; +impl Null { + pub fn new() -> Null { + Null + } +} + impl Renderer for Null { type Output = (); + type Defaults = (); } impl column::Renderer for Null { fn draw( &mut self, + _defaults: &Self::Defaults, _content: &[Element<'_, Message, Self>], _layout: Layout<'_>, _cursor_position: Point, @@ -25,6 +35,7 @@ impl column::Renderer for Null { impl row::Renderer for Null { fn draw( &mut self, + _defaults: &Self::Defaults, _content: &[Element<'_, Message, Self>], _layout: Layout<'_>, _cursor_position: Point, @@ -49,6 +60,7 @@ impl text::Renderer for Null { fn draw( &mut self, + _defaults: &Self::Defaults, _bounds: Rectangle, _content: &str, _size: u16, @@ -119,13 +131,16 @@ impl text_input::Renderer for Null { impl button::Renderer for Null { type Style = (); - fn draw( + fn draw( &mut self, + _defaults: &Self::Defaults, _bounds: Rectangle, _cursor_position: Point, + _is_disabled: bool, _is_pressed: bool, _style: &Self::Style, - _content: Self::Output, + _content: &Element<'_, Message, Self>, + _content_layout: Layout<'_>, ) -> Self::Output { } } -- cgit From 5af4159848341b14f6ff9ae14a9a222d8d8b0fb8 Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Wed, 1 Jan 2020 18:26:49 +0100 Subject: Draft basic styling for `TextInput` --- native/src/renderer/null.rs | 3 +++ 1 file changed, 3 insertions(+) (limited to 'native/src/renderer/null.rs') diff --git a/native/src/renderer/null.rs b/native/src/renderer/null.rs index 56d7e472..96aa132c 100644 --- a/native/src/renderer/null.rs +++ b/native/src/renderer/null.rs @@ -97,6 +97,8 @@ impl scrollable::Renderer for Null { } impl text_input::Renderer for Null { + type Style = (); + fn default_size(&self) -> u16 { 20 } @@ -124,6 +126,7 @@ impl text_input::Renderer for Null { _placeholder: &str, _value: &text_input::Value, _state: &text_input::State, + _style: &Self::Style, ) -> Self::Output { } } -- cgit From d0dc7cebf9c352f4d14827fe47489788f59e61a1 Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Mon, 6 Jan 2020 21:01:09 +0100 Subject: Implement styling for `Scrollable` --- native/src/renderer/null.rs | 3 +++ 1 file changed, 3 insertions(+) (limited to 'native/src/renderer/null.rs') diff --git a/native/src/renderer/null.rs b/native/src/renderer/null.rs index 96aa132c..0184ac00 100644 --- a/native/src/renderer/null.rs +++ b/native/src/renderer/null.rs @@ -73,6 +73,8 @@ impl text::Renderer for Null { } impl scrollable::Renderer for Null { + type Style = (); + fn scrollbar( &self, _bounds: Rectangle, @@ -91,6 +93,7 @@ impl scrollable::Renderer for Null { _is_mouse_over_scrollbar: bool, _scrollbar: Option, _offset: u32, + _style: &Self::Style, _content: Self::Output, ) { } -- cgit From b329003c8fdcdc3378c8fda93af54be5686fc9ae Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Tue, 7 Jan 2020 00:28:08 +0100 Subject: Implement styling for `Slider` --- native/src/renderer/null.rs | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) (limited to 'native/src/renderer/null.rs') diff --git a/native/src/renderer/null.rs b/native/src/renderer/null.rs index 0184ac00..72f06a87 100644 --- a/native/src/renderer/null.rs +++ b/native/src/renderer/null.rs @@ -1,7 +1,7 @@ use crate::{ - button, checkbox, column, radio, row, scrollable, text, text_input, Color, - Element, Font, HorizontalAlignment, Layout, Point, Rectangle, Renderer, - Size, VerticalAlignment, + button, checkbox, column, radio, row, scrollable, slider, text, text_input, + Color, Element, Font, HorizontalAlignment, Layout, Point, Rectangle, + Renderer, Size, VerticalAlignment, }; /// A renderer that does nothing. @@ -180,3 +180,22 @@ impl checkbox::Renderer for Null { ) { } } + +impl slider::Renderer for Null { + type Style = (); + + fn height(&self) -> u32 { + 30 + } + + fn draw( + &mut self, + _bounds: Rectangle, + _cursor_position: Point, + _range: std::ops::RangeInclusive, + _value: f32, + _is_dragging: bool, + _style_sheet: &Self::Style, + ) -> Self::Output { + } +} -- cgit From 48b3b78a3840778eef1035f4585d5ba9dd3d6291 Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Tue, 7 Jan 2020 01:53:26 +0100 Subject: Implement styling for `ProgressBar` --- native/src/renderer/null.rs | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) (limited to 'native/src/renderer/null.rs') diff --git a/native/src/renderer/null.rs b/native/src/renderer/null.rs index 72f06a87..b721e29e 100644 --- a/native/src/renderer/null.rs +++ b/native/src/renderer/null.rs @@ -1,7 +1,7 @@ use crate::{ - button, checkbox, column, radio, row, scrollable, slider, text, text_input, - Color, Element, Font, HorizontalAlignment, Layout, Point, Rectangle, - Renderer, Size, VerticalAlignment, + button, checkbox, column, progress_bar, radio, row, scrollable, slider, + text, text_input, Color, Element, Font, HorizontalAlignment, Layout, Point, + Rectangle, Renderer, Size, VerticalAlignment, }; /// A renderer that does nothing. @@ -196,6 +196,21 @@ impl slider::Renderer for Null { _value: f32, _is_dragging: bool, _style_sheet: &Self::Style, - ) -> Self::Output { + ) { + } +} + +impl progress_bar::Renderer for Null { + type Style = (); + + const DEFAULT_HEIGHT: u16 = 30; + + fn draw( + &self, + _bounds: Rectangle, + _range: std::ops::RangeInclusive, + _value: f32, + _style: &Self::Style, + ) { } } -- cgit From 387fc0be26ccd1adc66c1dc80420f9b08d0c023a Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Tue, 7 Jan 2020 02:25:57 +0100 Subject: Implement styling for `Radio` --- native/src/renderer/null.rs | 3 +++ 1 file changed, 3 insertions(+) (limited to 'native/src/renderer/null.rs') diff --git a/native/src/renderer/null.rs b/native/src/renderer/null.rs index b721e29e..4fb4f2d5 100644 --- a/native/src/renderer/null.rs +++ b/native/src/renderer/null.rs @@ -152,6 +152,8 @@ impl button::Renderer for Null { } impl radio::Renderer for Null { + type Style = (); + fn default_size(&self) -> u32 { 20 } @@ -162,6 +164,7 @@ impl radio::Renderer for Null { _is_selected: bool, _is_mouse_over: bool, _label: Self::Output, + _style: &Self::Style, ) { } } -- cgit From ed30b487d649ffa0967ab8bfd66f4820ee2150fd Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Tue, 7 Jan 2020 02:54:54 +0100 Subject: Implement styling for `Checkbox` --- native/src/renderer/null.rs | 3 +++ 1 file changed, 3 insertions(+) (limited to 'native/src/renderer/null.rs') diff --git a/native/src/renderer/null.rs b/native/src/renderer/null.rs index 4fb4f2d5..bd5bba23 100644 --- a/native/src/renderer/null.rs +++ b/native/src/renderer/null.rs @@ -170,6 +170,8 @@ impl radio::Renderer for Null { } impl checkbox::Renderer for Null { + type Style = (); + fn default_size(&self) -> u32 { 20 } @@ -180,6 +182,7 @@ impl checkbox::Renderer for Null { _is_checked: bool, _is_mouse_over: bool, _label: Self::Output, + _style: &Self::Style, ) { } } -- cgit From 7b278755fc7929633b5771824beac4d39b16e82e Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Thu, 9 Jan 2020 18:31:07 +0100 Subject: Write missing docs and reenable deny statements --- native/src/renderer/null.rs | 3 +++ 1 file changed, 3 insertions(+) (limited to 'native/src/renderer/null.rs') diff --git a/native/src/renderer/null.rs b/native/src/renderer/null.rs index bd5bba23..df261cdc 100644 --- a/native/src/renderer/null.rs +++ b/native/src/renderer/null.rs @@ -11,6 +11,9 @@ use crate::{ pub struct Null; impl Null { + /// Creates a new [`Null`] renderer. + /// + /// [`Null`]: struct.Null.html pub fn new() -> Null { Null } -- cgit