Rename space_{x,y} to space::{horizontal,vertical}
This commit is contained in:
parent
299eb54d6f
commit
611f89fc59
25 changed files with 143 additions and 142 deletions
|
|
@ -1017,7 +1017,7 @@ where
|
|||
/// # mod iced { pub mod widget { pub use iced_widget::*; } }
|
||||
/// # pub type State = ();
|
||||
/// # pub type Element<'a, Message> = iced_widget::core::Element<'a, Message, iced_widget::Theme, iced_widget::Renderer>;
|
||||
/// use iced::widget::{column, scrollable, space_y};
|
||||
/// use iced::widget::{column, scrollable, space};
|
||||
///
|
||||
/// enum Message {
|
||||
/// // ...
|
||||
|
|
@ -1026,7 +1026,7 @@ where
|
|||
/// fn view(state: &State) -> Element<'_, Message> {
|
||||
/// scrollable(column![
|
||||
/// "Scroll me!",
|
||||
/// space_y().height(3000),
|
||||
/// space().height(3000),
|
||||
/// "You did it!",
|
||||
/// ]).into()
|
||||
/// }
|
||||
|
|
@ -1729,20 +1729,12 @@ where
|
|||
ComboBox::new(state, placeholder, selection, on_selected)
|
||||
}
|
||||
|
||||
/// Creates a new [`Space`] widget that fills the available
|
||||
/// horizontal space.
|
||||
/// Creates some empty [`Space`] with no size.
|
||||
///
|
||||
/// This can be useful to separate widgets in a [`Row`].
|
||||
pub fn space_x() -> Space {
|
||||
Space::with_width(Length::Fill)
|
||||
}
|
||||
|
||||
/// Creates a new [`Space`] widget that fills the available
|
||||
/// vertical space.
|
||||
///
|
||||
/// This can be useful to separate widgets in a [`Column`].
|
||||
pub fn space_y() -> Space {
|
||||
Space::with_height(Length::Fill)
|
||||
/// This is considered the "identity" widget. It will take
|
||||
/// no space and do nothing.
|
||||
pub fn space() -> Space {
|
||||
Space::new()
|
||||
}
|
||||
|
||||
/// Creates a horizontal [`Rule`] with the given height.
|
||||
|
|
|
|||
|
|
@ -14,7 +14,6 @@ mod column;
|
|||
mod mouse_area;
|
||||
mod pin;
|
||||
mod responsive;
|
||||
mod space;
|
||||
mod stack;
|
||||
mod themer;
|
||||
|
||||
|
|
@ -35,6 +34,7 @@ pub mod rule;
|
|||
pub mod scrollable;
|
||||
pub mod sensor;
|
||||
pub mod slider;
|
||||
pub mod space;
|
||||
pub mod table;
|
||||
pub mod text;
|
||||
pub mod text_editor;
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ use crate::core::{
|
|||
self, Clipboard, Element, Event, Length, Rectangle, Shell, Size, Vector,
|
||||
Widget,
|
||||
};
|
||||
use crate::space_x;
|
||||
use crate::space;
|
||||
|
||||
/// A widget that is aware of its dimensions.
|
||||
///
|
||||
|
|
@ -43,7 +43,7 @@ where
|
|||
view: Box::new(view),
|
||||
width: Length::Fill,
|
||||
height: Length::Fill,
|
||||
content: Element::new(space_x().width(0)),
|
||||
content: Element::new(space()),
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@
|
|||
//! # mod iced { pub mod widget { pub use iced_widget::*; } }
|
||||
//! # pub type State = ();
|
||||
//! # pub type Element<'a, Message> = iced_widget::core::Element<'a, Message, iced_widget::Theme, iced_widget::Renderer>;
|
||||
//! use iced::widget::{column, scrollable, space_y};
|
||||
//! use iced::widget::{column, scrollable, space};
|
||||
//!
|
||||
//! enum Message {
|
||||
//! // ...
|
||||
|
|
@ -14,7 +14,7 @@
|
|||
//! fn view(state: &State) -> Element<'_, Message> {
|
||||
//! scrollable(column![
|
||||
//! "Scroll me!",
|
||||
//! space_y().height(3000),
|
||||
//! space().height(3000),
|
||||
//! "You did it!",
|
||||
//! ]).into()
|
||||
//! }
|
||||
|
|
@ -48,7 +48,7 @@ pub use operation::scrollable::{AbsoluteOffset, RelativeOffset};
|
|||
/// # mod iced { pub mod widget { pub use iced_widget::*; } }
|
||||
/// # pub type State = ();
|
||||
/// # pub type Element<'a, Message> = iced_widget::core::Element<'a, Message, iced_widget::Theme, iced_widget::Renderer>;
|
||||
/// use iced::widget::{column, scrollable, space_y};
|
||||
/// use iced::widget::{column, scrollable, space};
|
||||
///
|
||||
/// enum Message {
|
||||
/// // ...
|
||||
|
|
@ -57,7 +57,7 @@ pub use operation::scrollable::{AbsoluteOffset, RelativeOffset};
|
|||
/// fn view(state: &State) -> Element<'_, Message> {
|
||||
/// scrollable(column![
|
||||
/// "Scroll me!",
|
||||
/// space_y().height(3000),
|
||||
/// space().height(3000),
|
||||
/// "You did it!",
|
||||
/// ]).into()
|
||||
/// }
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
//! Distribute content vertically.
|
||||
//! Add some explicit spacing between elements.
|
||||
use crate::core;
|
||||
use crate::core::layout;
|
||||
use crate::core::mouse;
|
||||
|
|
@ -6,6 +6,22 @@ use crate::core::renderer;
|
|||
use crate::core::widget::Tree;
|
||||
use crate::core::{Element, Layout, Length, Rectangle, Size, Widget};
|
||||
|
||||
/// Creates a new [`Space`] widget that fills the available
|
||||
/// horizontal space.
|
||||
///
|
||||
/// This can be useful to separate widgets in a [`Row`](crate::Row).
|
||||
pub fn horizontal() -> Space {
|
||||
Space::new().width(Length::Fill)
|
||||
}
|
||||
|
||||
/// Creates a new [`Space`] widget that fills the available
|
||||
/// vertical space.
|
||||
///
|
||||
/// This can be useful to separate widgets in a [`Column`](crate::Column).
|
||||
pub fn vertical() -> Space {
|
||||
Space::new().height(Length::Fill)
|
||||
}
|
||||
|
||||
/// An amount of empty space.
|
||||
///
|
||||
/// It can be useful if you want to fill some space with nothing.
|
||||
|
|
@ -16,27 +32,11 @@ pub struct Space {
|
|||
}
|
||||
|
||||
impl Space {
|
||||
/// Creates an amount of empty [`Space`] with the given width and height.
|
||||
pub fn new(width: impl Into<Length>, height: impl Into<Length>) -> Self {
|
||||
Space {
|
||||
width: width.into(),
|
||||
height: height.into(),
|
||||
}
|
||||
}
|
||||
|
||||
/// Creates an amount of horizontal [`Space`].
|
||||
pub fn with_width(width: impl Into<Length>) -> Self {
|
||||
Space {
|
||||
width: width.into(),
|
||||
height: Length::Shrink,
|
||||
}
|
||||
}
|
||||
|
||||
/// Creates an amount of vertical [`Space`].
|
||||
pub fn with_height(height: impl Into<Length>) -> Self {
|
||||
/// Creates some empty [`Space`] with no size.
|
||||
pub fn new() -> Self {
|
||||
Space {
|
||||
width: Length::Shrink,
|
||||
height: height.into(),
|
||||
height: Length::Shrink,
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -53,6 +53,12 @@ impl Space {
|
|||
}
|
||||
}
|
||||
|
||||
impl Default for Space {
|
||||
fn default() -> Self {
|
||||
Space::new()
|
||||
}
|
||||
}
|
||||
|
||||
impl<Message, Theme, Renderer> Widget<Message, Theme, Renderer> for Space
|
||||
where
|
||||
Renderer: core::Renderer,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue