diff options
author | 2019-12-30 21:32:21 +0100 | |
---|---|---|
committer | 2019-12-30 21:33:27 +0100 | |
commit | 3a327e08e96d9588d145c32afe4f04f37a8f0f0f (patch) | |
tree | b1da004410c0dc4ba82bd0c3262ea3359fad38b2 | |
parent | 8426bf953cb50f3b7fcb1e0ec8c2fdf22d2b01af (diff) | |
download | iced-3a327e08e96d9588d145c32afe4f04f37a8f0f0f.tar.gz iced-3a327e08e96d9588d145c32afe4f04f37a8f0f0f.tar.bz2 iced-3a327e08e96d9588d145c32afe4f04f37a8f0f0f.zip |
Rename `Empty` widget to `Space`
-rw-r--r-- | examples/tour.rs | 6 | ||||
-rw-r--r-- | native/src/widget.rs | 6 | ||||
-rw-r--r-- | native/src/widget/space.rs (renamed from native/src/widget/empty.rs) | 59 | ||||
-rw-r--r-- | src/native.rs | 4 | ||||
-rw-r--r-- | web/src/widget.rs | 4 | ||||
-rw-r--r-- | web/src/widget/space.rs (renamed from web/src/widget/empty.rs) | 49 | ||||
-rw-r--r-- | wgpu/src/renderer/widget.rs | 2 | ||||
-rw-r--r-- | wgpu/src/renderer/widget/space.rs (renamed from wgpu/src/renderer/widget/empty.rs) | 4 |
8 files changed, 67 insertions, 67 deletions
diff --git a/examples/tour.rs b/examples/tour.rs index fcace9c3..91b75296 100644 --- a/examples/tour.rs +++ b/examples/tour.rs @@ -1,7 +1,7 @@ use iced::{ button, scrollable, slider, text_input, Button, Checkbox, Color, Column, - Container, Element, Empty, HorizontalAlignment, Image, Length, Radio, Row, - Sandbox, Scrollable, Settings, Slider, Text, TextInput, + Container, Element, HorizontalAlignment, Image, Length, Radio, Row, + Sandbox, Scrollable, Settings, Slider, Space, Text, TextInput, }; pub fn main() { @@ -67,7 +67,7 @@ impl Sandbox for Tour { ); } - controls = controls.push(Empty::new().width(Length::Fill)); + controls = controls.push(Space::with_width(Length::Fill)); if steps.can_continue() { controls = controls.push( diff --git a/native/src/widget.rs b/native/src/widget.rs index b73f229e..dcc99645 100644 --- a/native/src/widget.rs +++ b/native/src/widget.rs @@ -24,12 +24,12 @@ pub mod button; pub mod checkbox; pub mod column; pub mod container; -pub mod empty; pub mod image; pub mod radio; pub mod row; pub mod scrollable; pub mod slider; +pub mod space; pub mod svg; pub mod text; pub mod text_input; @@ -43,8 +43,6 @@ pub use column::Column; #[doc(no_inline)] pub use container::Container; #[doc(no_inline)] -pub use empty::Empty; -#[doc(no_inline)] pub use image::Image; #[doc(no_inline)] pub use radio::Radio; @@ -55,6 +53,8 @@ pub use scrollable::Scrollable; #[doc(no_inline)] pub use slider::Slider; #[doc(no_inline)] +pub use space::Space; +#[doc(no_inline)] pub use svg::Svg; #[doc(no_inline)] pub use text::Text; diff --git a/native/src/widget/empty.rs b/native/src/widget/space.rs index f670048f..2029c52f 100644 --- a/native/src/widget/empty.rs +++ b/native/src/widget/space.rs @@ -8,43 +8,42 @@ use crate::{ /// An amount of empty space. /// /// It can be useful if you want to fill some space with nothing. -/// -/// [`Empty`]: struct.Empty.html #[derive(Debug)] -pub struct Empty { +pub struct Space { width: Length, height: Length, } -impl Empty { - /// Creates an amount of [`Empty`] space. +impl Space { + /// Creates an amount of empty [`Space`] with the given width and height. /// - /// [`Empty`]: struct.Empty.html - pub fn new() -> Self { - Empty { - width: Length::Shrink, - height: Length::Shrink, - } + /// [`Space`]: struct.Space.html + pub fn new(width: Length, height: Length) -> Self { + Space { width, height } } - /// Sets the width of the [`Empty`] space. + /// Creates an amount of horizontal [`Space`]. /// - /// [`Empty`]: struct..html - pub fn width(mut self, width: Length) -> Self { - self.width = width; - self + /// [`Space`]: struct.Space.html + pub fn with_width(width: Length) -> Self { + Space { + width, + height: Length::Shrink, + } } - /// Sets the height of the [`Empty`] space. + /// Creates an amount of vertical [`Space`]. /// - /// [`Empty`]: struct.Column.html - pub fn height(mut self, height: Length) -> Self { - self.height = height; - self + /// [`Space`]: struct.Space.html + pub fn with_height(height: Length) -> Self { + Space { + width: Length::Shrink, + height, + } } } -impl<'a, Message, Renderer> Widget<Message, Renderer> for Empty +impl<'a, Message, Renderer> Widget<Message, Renderer> for Space where Renderer: self::Renderer, { @@ -76,28 +75,30 @@ where } fn hash_layout(&self, state: &mut Hasher) { - std::any::TypeId::of::<Empty>().hash(state); + std::any::TypeId::of::<Space>().hash(state); self.width.hash(state); self.height.hash(state); } } -/// The renderer of an amount of [`Empty`] space. +/// The renderer of an amount of [`Space`]. /// -/// [`Empty`]: struct.Empty.html +/// [`Space`]: struct.Space.html pub trait Renderer: crate::Renderer { - /// Draws an amount of [`Empty`] space. + /// Draws an amount of empty [`Space`]. /// /// You should most likely return an empty primitive here. + /// + /// [`Space`]: struct.Space.html fn draw(&mut self, bounds: Rectangle) -> Self::Output; } -impl<'a, Message, Renderer> From<Empty> for Element<'a, Message, Renderer> +impl<'a, Message, Renderer> From<Space> for Element<'a, Message, Renderer> where Renderer: self::Renderer, Message: 'static, { - fn from(empty: Empty) -> Element<'a, Message, Renderer> { - Element::new(empty) + fn from(space: Space) -> Element<'a, Message, Renderer> { + Element::new(space) } } diff --git a/src/native.rs b/src/native.rs index 8a04b7c3..cf48a391 100644 --- a/src/native.rs +++ b/src/native.rs @@ -1,6 +1,6 @@ pub use iced_winit::{ - Align, Background, Color, Command, Empty, Font, HorizontalAlignment, - Length, Subscription, VerticalAlignment, + Align, Background, Color, Command, Font, HorizontalAlignment, Length, + Space, Subscription, VerticalAlignment, }; pub mod widget { diff --git a/web/src/widget.rs b/web/src/widget.rs index 5cf0238a..0ac536bd 100644 --- a/web/src/widget.rs +++ b/web/src/widget.rs @@ -25,10 +25,10 @@ pub mod text_input; mod checkbox; mod column; mod container; -mod empty; mod image; mod radio; mod row; +mod space; mod text; #[doc(no_inline)] @@ -45,10 +45,10 @@ pub use text_input::TextInput; pub use checkbox::Checkbox; pub use column::Column; pub use container::Container; -pub use empty::Empty; pub use image::Image; pub use radio::Radio; pub use row::Row; +pub use space::Space; /// A component that displays information and allows interaction. /// diff --git a/web/src/widget/empty.rs b/web/src/widget/space.rs index dda17efe..baf4c80b 100644 --- a/web/src/widget/empty.rs +++ b/web/src/widget/space.rs @@ -4,43 +4,42 @@ use dodrio::bumpalo; /// An amount of empty space. /// /// It can be useful if you want to fill some space with nothing. -/// -/// [`Empty`]: struct.Empty.html #[derive(Debug)] -pub struct Empty { +pub struct Space { width: Length, height: Length, } -impl Empty { - /// Creates an amount of [`Empty`] space. +impl Space { + /// Creates an amount of empty [`Space`] with the given width and height. /// - /// [`Empty`]: struct.Empty.html - pub fn new() -> Self { - Empty { - width: Length::Shrink, - height: Length::Shrink, - } + /// [`Space`]: struct.Space.html + pub fn new(width: Length, height: Length) -> Self { + Space { width, height } } - /// Sets the width of the [`Empty`] space. + /// Creates an amount of horizontal [`Space`]. /// - /// [`Empty`]: struct..html - pub fn width(mut self, width: Length) -> Self { - self.width = width; - self + /// [`Space`]: struct.Space.html + pub fn with_width(width: Length) -> Self { + Space { + width, + height: Length::Shrink, + } } - /// Sets the height of the [`Empty`] space. + /// Creates an amount of vertical [`Space`]. /// - /// [`Empty`]: struct.Column.html - pub fn height(mut self, height: Length) -> Self { - self.height = height; - self + /// [`Space`]: struct.Space.html + pub fn with_height(height: Length) -> Self { + Space { + width: Length::Shrink, + height, + } } } -impl<'a, Message> Widget<Message> for Empty { +impl<'a, Message> Widget<Message> for Space { fn node<'b>( &self, bump: &'b bumpalo::Bump, @@ -63,8 +62,8 @@ impl<'a, Message> Widget<Message> for Empty { } } -impl<'a, Message> From<Empty> for Element<'a, Message> { - fn from(empty: Empty) -> Element<'a, Message> { - Element::new(empty) +impl<'a, Message> From<Space> for Element<'a, Message> { + fn from(space: Space) -> Element<'a, Message> { + Element::new(space) } } diff --git a/wgpu/src/renderer/widget.rs b/wgpu/src/renderer/widget.rs index f2d443fb..f82631d5 100644 --- a/wgpu/src/renderer/widget.rs +++ b/wgpu/src/renderer/widget.rs @@ -1,12 +1,12 @@ mod button; mod checkbox; mod column; -mod empty; mod image; mod radio; mod row; mod scrollable; mod slider; +mod space; mod text; mod text_input; diff --git a/wgpu/src/renderer/widget/empty.rs b/wgpu/src/renderer/widget/space.rs index 26ee74b4..28e05437 100644 --- a/wgpu/src/renderer/widget/empty.rs +++ b/wgpu/src/renderer/widget/space.rs @@ -1,7 +1,7 @@ use crate::{Primitive, Renderer}; -use iced_native::{empty, MouseCursor, Rectangle}; +use iced_native::{space, MouseCursor, Rectangle}; -impl empty::Renderer for Renderer { +impl space::Renderer for Renderer { fn draw(&mut self, _bounds: Rectangle) -> Self::Output { (Primitive::None, MouseCursor::OutOfBounds) } |