summaryrefslogtreecommitdiffstats
path: root/native/src/renderer/null.rs
diff options
context:
space:
mode:
authorLibravatar Héctor Ramón Jiménez <hector0193@gmail.com>2020-01-11 00:44:56 +0100
committerLibravatar Héctor Ramón Jiménez <hector0193@gmail.com>2020-01-11 00:44:56 +0100
commitde71776e02495df5dc962fb8b8853f666ab8be4f (patch)
tree1f87cc68dc554783c6102f3587377f9956bcddba /native/src/renderer/null.rs
parente879982cfdf0c6a1c6781a9bc46e0a77839de88f (diff)
parent84f1a936db93c16255a07f079c47e351635586f4 (diff)
downloadiced-de71776e02495df5dc962fb8b8853f666ab8be4f.tar.gz
iced-de71776e02495df5dc962fb8b8853f666ab8be4f.tar.bz2
iced-de71776e02495df5dc962fb8b8853f666ab8be4f.zip
Merge branch 'master' into paint-example
Diffstat (limited to 'native/src/renderer/null.rs')
-rw-r--r--native/src/renderer/null.rs77
1 files changed, 71 insertions, 6 deletions
diff --git a/native/src/renderer/null.rs b/native/src/renderer/null.rs
index 43076d61..df261cdc 100644
--- a/native/src/renderer/null.rs
+++ b/native/src/renderer/null.rs
@@ -1,20 +1,33 @@
use crate::{
- button, checkbox, column, radio, row, scrollable, text, text_input,
- Background, Color, Element, Font, HorizontalAlignment, Layout, Point,
+ 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.
+///
+/// It can be useful if you are writing tests!
#[derive(Debug, Clone, Copy)]
pub struct Null;
+impl Null {
+ /// Creates a new [`Null`] renderer.
+ ///
+ /// [`Null`]: struct.Null.html
+ pub fn new() -> Null {
+ Null
+ }
+}
+
impl Renderer for Null {
type Output = ();
+ type Defaults = ();
}
impl column::Renderer for Null {
fn draw<Message>(
&mut self,
+ _defaults: &Self::Defaults,
_content: &[Element<'_, Message, Self>],
_layout: Layout<'_>,
_cursor_position: Point,
@@ -25,6 +38,7 @@ impl column::Renderer for Null {
impl row::Renderer for Null {
fn draw<Message>(
&mut self,
+ _defaults: &Self::Defaults,
_content: &[Element<'_, Message, Self>],
_layout: Layout<'_>,
_cursor_position: Point,
@@ -49,6 +63,7 @@ impl text::Renderer for Null {
fn draw(
&mut self,
+ _defaults: &Self::Defaults,
_bounds: Rectangle,
_content: &str,
_size: u16,
@@ -61,6 +76,8 @@ impl text::Renderer for Null {
}
impl scrollable::Renderer for Null {
+ type Style = ();
+
fn scrollbar(
&self,
_bounds: Rectangle,
@@ -79,12 +96,15 @@ impl scrollable::Renderer for Null {
_is_mouse_over_scrollbar: bool,
_scrollbar: Option<scrollable::Scrollbar>,
_offset: u32,
+ _style: &Self::Style,
_content: Self::Output,
) {
}
}
impl text_input::Renderer for Null {
+ type Style = ();
+
fn default_size(&self) -> u16 {
20
}
@@ -112,24 +132,31 @@ impl text_input::Renderer for Null {
_placeholder: &str,
_value: &text_input::Value,
_state: &text_input::State,
+ _style: &Self::Style,
) -> Self::Output {
}
}
impl button::Renderer for Null {
- fn draw(
+ type Style = ();
+
+ fn draw<Message>(
&mut self,
+ _defaults: &Self::Defaults,
_bounds: Rectangle,
_cursor_position: Point,
+ _is_disabled: bool,
_is_pressed: bool,
- _background: Option<Background>,
- _border_radius: u16,
- _content: Self::Output,
+ _style: &Self::Style,
+ _content: &Element<'_, Message, Self>,
+ _content_layout: Layout<'_>,
) -> Self::Output {
}
}
impl radio::Renderer for Null {
+ type Style = ();
+
fn default_size(&self) -> u32 {
20
}
@@ -140,11 +167,14 @@ impl radio::Renderer for Null {
_is_selected: bool,
_is_mouse_over: bool,
_label: Self::Output,
+ _style: &Self::Style,
) {
}
}
impl checkbox::Renderer for Null {
+ type Style = ();
+
fn default_size(&self) -> u32 {
20
}
@@ -155,6 +185,41 @@ impl checkbox::Renderer for Null {
_is_checked: bool,
_is_mouse_over: bool,
_label: Self::Output,
+ _style: &Self::Style,
+ ) {
+ }
+}
+
+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<f32>,
+ _value: f32,
+ _is_dragging: bool,
+ _style_sheet: &Self::Style,
+ ) {
+ }
+}
+
+impl progress_bar::Renderer for Null {
+ type Style = ();
+
+ const DEFAULT_HEIGHT: u16 = 30;
+
+ fn draw(
+ &self,
+ _bounds: Rectangle,
+ _range: std::ops::RangeInclusive<f32>,
+ _value: f32,
+ _style: &Self::Style,
) {
}
}