Rename *_space to space_x and space_y

This commit is contained in:
Héctor Ramón Jiménez 2025-09-11 07:10:53 +02:00
parent c684fbd6af
commit 89b7585465
No known key found for this signature in database
GPG key ID: 7CC46565708259A7
22 changed files with 92 additions and 113 deletions

View file

@ -23,8 +23,8 @@ use crate::program::message;
use crate::runtime::task::{self, Task}; use crate::runtime::task::{self, Task};
use crate::time_machine::TimeMachine; use crate::time_machine::TimeMachine;
use crate::widget::{ use crate::widget::{
bottom_right, button, center, column, container, horizontal_space, opaque, bottom_right, button, center, column, container, opaque, row, scrollable,
row, scrollable, stack, text, themer, space_x, stack, text, themer,
}; };
use std::fmt; use std::fmt;
@ -448,7 +448,7 @@ where
.width(100) .width(100)
.on_press(Message::CancelSetup) .on_press(Message::CancelSetup)
.style(button::danger), .style(button::danger),
horizontal_space(), space_x(),
button( button(
text(match goal { text(match goal {
Goal::Installation => "Install", Goal::Installation => "Install",
@ -498,13 +498,13 @@ where
let comparison = column![ let comparison = column![
row![ row![
"Installed revision:", "Installed revision:",
horizontal_space(), space_x(),
inline_code(revision.as_deref().unwrap_or("Unknown")) inline_code(revision.as_deref().unwrap_or("Unknown"))
] ]
.align_y(Center), .align_y(Center),
row![ row![
"Compatible revision:", "Compatible revision:",
horizontal_space(), space_x(),
inline_code(comet::COMPATIBLE_REVISION), inline_code(comet::COMPATIBLE_REVISION),
] ]
.align_y(Center) .align_y(Center)

View file

@ -1,5 +1,5 @@
//! This example showcases an interactive `Canvas` for drawing Bézier curves. //! This example showcases an interactive `Canvas` for drawing Bézier curves.
use iced::widget::{button, container, horizontal_space, hover, right}; use iced::widget::{button, container, hover, right, space_x};
use iced::{Element, Theme}; use iced::{Element, Theme};
pub fn main() -> iced::Result { pub fn main() -> iced::Result {
@ -38,7 +38,7 @@ impl Example {
container(hover( container(hover(
self.bezier.view(&self.curves).map(Message::AddCurve), self.bezier.view(&self.curves).map(Message::AddCurve),
if self.curves.is_empty() { if self.curves.is_empty() {
container(horizontal_space()) container(space_x())
} else { } else {
right( right(
button("Clear") button("Clear")

View file

@ -1,6 +1,4 @@
use iced::widget::{ use iced::widget::{center, column, combo_box, scrollable, space_y, text};
center, column, combo_box, scrollable, text, vertical_space,
};
use iced::{Center, Element, Fill}; use iced::{Center, Element, Fill};
pub fn main() -> iced::Result { pub fn main() -> iced::Result {
@ -62,7 +60,7 @@ impl Example {
text(&self.text), text(&self.text),
"What is your language?", "What is your language?",
combo_box, combo_box,
vertical_space().height(150), space_y().height(150),
] ]
.width(Fill) .width(Fill)
.align_x(Center) .align_x(Center)

View file

@ -1,8 +1,8 @@
use iced::highlighter; use iced::highlighter;
use iced::keyboard; use iced::keyboard;
use iced::widget::{ use iced::widget::{
button, center_x, column, container, horizontal_space, operation, button, center_x, column, container, operation, pick_list, row, space_x,
pick_list, row, text, text_editor, toggler, tooltip, text, text_editor, toggler, tooltip,
}; };
use iced::{Center, Element, Fill, Font, Task, Theme}; use iced::{Center, Element, Fill, Font, Task, Theme};
@ -157,7 +157,7 @@ impl Editor {
"Save file", "Save file",
self.is_dirty.then_some(Message::SaveFile) self.is_dirty.then_some(Message::SaveFile)
), ),
horizontal_space(), space_x(),
toggler(self.word_wrap) toggler(self.word_wrap)
.label("Word Wrap") .label("Word Wrap")
.on_toggle(Message::WordWrapToggled), .on_toggle(Message::WordWrapToggled),
@ -184,7 +184,7 @@ impl Editor {
} else { } else {
String::from("New file") String::from("New file")
}), }),
horizontal_space(), space_x(),
text({ text({
let (line, column) = self.content.cursor_position(); let (line, column) = self.content.cursor_position();

View file

@ -9,8 +9,8 @@ use crate::civitai::{Error, Id, Image, Rgba, Size};
use iced::animation; use iced::animation;
use iced::time::{Instant, milliseconds}; use iced::time::{Instant, milliseconds};
use iced::widget::{ use iced::widget::{
button, container, float, grid, horizontal_space, image, mouse_area, button, container, float, grid, image, mouse_area, opaque, scrollable,
opaque, scrollable, sensor, stack, sensor, space_x, stack,
}; };
use iced::window; use iced::window;
use iced::{ use iced::{
@ -227,7 +227,7 @@ fn card<'a>(
}) })
.into() .into()
} else { } else {
horizontal_space().into() space_x().into()
}; };
if let Some(blurhash) = preview.blurhash(now) { if let Some(blurhash) = preview.blurhash(now) {
@ -241,7 +241,7 @@ fn card<'a>(
thumbnail thumbnail
} }
} else { } else {
horizontal_space().into() space_x().into()
}; };
let card = mouse_area(container(image).style(container::dark)) let card = mouse_area(container(image).style(container::dark))
@ -264,7 +264,7 @@ fn card<'a>(
} }
fn placeholder<'a>() -> Element<'a, Message> { fn placeholder<'a>() -> Element<'a, Message> {
container(horizontal_space()).style(container::dark).into() container(space_x()).style(container::dark).into()
} }
enum Preview { enum Preview {
@ -426,7 +426,7 @@ impl Viewer {
.scale(self.image_fade_in.interpolate(1.5, 1.0, now)) .scale(self.image_fade_in.interpolate(1.5, 1.0, now))
.into() .into()
} else { } else {
horizontal_space().into() space_x().into()
}; };
if opacity > 0.0 { if opacity > 0.0 {
@ -443,7 +443,7 @@ impl Viewer {
.on_press(Message::Close), .on_press(Message::Close),
) )
} else { } else {
horizontal_space().into() space_x().into()
} }
} }
} }

View file

@ -1,8 +1,6 @@
use iced::gradient; use iced::gradient;
use iced::theme; use iced::theme;
use iced::widget::{ use iced::widget::{checkbox, column, container, row, slider, space_x, text};
checkbox, column, container, horizontal_space, row, slider, text,
};
use iced::{Center, Color, Element, Fill, Radians, Theme, color}; use iced::{Center, Color, Element, Fill, Radians, Theme, color};
pub fn main() -> iced::Result { pub fn main() -> iced::Result {
@ -59,7 +57,7 @@ impl Gradient {
transparent, transparent,
} = *self; } = *self;
let gradient_box = container(horizontal_space()) let gradient_box = container(space_x())
.style(move |_theme| { .style(move |_theme| {
let gradient = gradient::Linear::new(angle) let gradient = gradient::Linear::new(angle)
.add_stop(0.0, start) .add_stop(0.0, start)

View file

@ -2,8 +2,8 @@ use iced::border;
use iced::keyboard; use iced::keyboard;
use iced::mouse; use iced::mouse;
use iced::widget::{ use iced::widget::{
button, canvas, center, center_y, checkbox, column, container, button, canvas, center, center_y, checkbox, column, container, pick_list,
horizontal_space, pick_list, pin, row, rule, scrollable, stack, text, pin, row, rule, scrollable, space_x, stack, text,
}; };
use iced::{ use iced::{
Center, Element, Fill, Font, Length, Point, Rectangle, Renderer, Shrink, Center, Element, Fill, Font, Length, Point, Rectangle, Renderer, Shrink,
@ -70,7 +70,7 @@ impl Layout {
fn view(&self) -> Element<'_, Message> { fn view(&self) -> Element<'_, Message> {
let header = row![ let header = row![
text(self.example.title).size(20).font(Font::MONOSPACE), text(self.example.title).size(20).font(Font::MONOSPACE),
horizontal_space(), space_x(),
checkbox("Explain", self.explain) checkbox("Explain", self.explain)
.on_toggle(Message::ExplainToggled), .on_toggle(Message::ExplainToggled),
pick_list(Theme::ALL, self.theme.as_ref(), Message::ThemeSelected) pick_list(Theme::ALL, self.theme.as_ref(), Message::ThemeSelected)
@ -99,7 +99,7 @@ impl Layout {
.on_press(Message::Previous) .on_press(Message::Previous)
.into(), .into(),
), ),
Some(horizontal_space().into()), Some(space_x().into()),
(!self.example.is_last()).then_some( (!self.example.is_last()).then_some(
button(text("Next →")) button(text("Next →"))
.padding([5, 10]) .padding([5, 10])
@ -238,20 +238,14 @@ fn row_<'a>() -> Element<'a, Message> {
} }
fn space<'a>() -> Element<'a, Message> { fn space<'a>() -> Element<'a, Message> {
row!["Left!", horizontal_space(), "Right!"].into() row!["Left!", space_x(), "Right!"].into()
} }
fn application<'a>() -> Element<'a, Message> { fn application<'a>() -> Element<'a, Message> {
let header = container( let header = container(
row![ row![square(40), space_x(), "Header!", space_x(), square(40),]
square(40), .padding(10)
horizontal_space(), .align_y(Center),
"Header!",
horizontal_space(),
square(40),
]
.padding(10)
.align_y(Center),
) )
.style(|theme| { .style(|theme| {
let palette = theme.extended_palette(); let palette = theme.extended_palette();

View file

@ -1,6 +1,5 @@
use iced::widget::{ use iced::widget::{
button, column, horizontal_space, lazy, pick_list, row, scrollable, text, button, column, lazy, pick_list, row, scrollable, space_x, text, text_input,
text_input,
}; };
use iced::{Element, Fill}; use iced::{Element, Fill};
@ -174,7 +173,7 @@ impl App {
row![ row![
text(item.name.clone()).color(item.color), text(item.name.clone()).color(item.color),
horizontal_space(), space_x(),
pick_list(Color::ALL, Some(item.color), move |color| { pick_list(Color::ALL, Some(item.color), move |color| {
Message::ItemColorChanged(item.clone(), color) Message::ItemColorChanged(item.clone(), color)
}), }),

View file

@ -5,8 +5,8 @@ use iced::clipboard;
use iced::highlighter; use iced::highlighter;
use iced::time::{self, Instant, milliseconds}; use iced::time::{self, Instant, milliseconds};
use iced::widget::{ use iced::widget::{
button, center_x, container, horizontal_space, hover, image, markdown, button, center_x, container, hover, image, markdown, operation, right, row,
operation, right, row, scrollable, sensor, text_editor, toggler, scrollable, sensor, space_x, text_editor, toggler,
}; };
use iced::window; use iced::window;
use iced::{ use iced::{
@ -264,7 +264,7 @@ impl<'a> markdown::Viewer<'a, Message> for CustomViewer<'a> {
) )
.into() .into()
} else { } else {
sensor(horizontal_space()) sensor(space_x())
.key_ref(url.as_str()) .key_ref(url.as_str())
.delay(milliseconds(500)) .delay(milliseconds(500))
.on_show(|_size| Message::ImageShown(url.clone())) .on_show(|_size| Message::ImageShown(url.clone()))

View file

@ -2,8 +2,8 @@ use iced::event::{self, Event};
use iced::keyboard; use iced::keyboard;
use iced::keyboard::key; use iced::keyboard::key;
use iced::widget::{ use iced::widget::{
button, center, column, container, horizontal_space, mouse_area, opaque, button, center, column, container, mouse_area, opaque, operation,
operation, pick_list, row, stack, text, text_input, pick_list, row, space_x, stack, text, text_input,
}; };
use iced::{Bottom, Color, Element, Fill, Subscription, Task}; use iced::{Bottom, Color, Element, Fill, Subscription, Task};
@ -95,16 +95,12 @@ impl App {
fn view(&self) -> Element<'_, Message> { fn view(&self) -> Element<'_, Message> {
let content = container( let content = container(
column![ column![
row![text("Top Left"), horizontal_space(), text("Top Right")] row![text("Top Left"), space_x(), text("Top Right")]
.height(Fill), .height(Fill),
center(button(text("Show Modal")).on_press(Message::ShowModal)), center(button(text("Show Modal")).on_press(Message::ShowModal)),
row![ row![text("Bottom Left"), space_x(), text("Bottom Right")]
text("Bottom Left"), .align_y(Bottom)
horizontal_space(), .height(Fill),
text("Bottom Right")
]
.align_y(Bottom)
.height(Fill),
] ]
.height(Fill), .height(Fill),
) )

View file

@ -1,6 +1,6 @@
use iced::widget::{ use iced::widget::{
button, center, center_x, column, container, horizontal_space, operation, button, center, center_x, column, container, operation, scrollable,
scrollable, text, text_input, space_x, text, text_input,
}; };
use iced::window; use iced::window;
use iced::{ use iced::{
@ -134,7 +134,7 @@ impl Example {
if let Some(window) = self.windows.get(&window_id) { if let Some(window) = self.windows.get(&window_id) {
center(window.view(window_id)).into() center(window.view(window_id)).into()
} else { } else {
horizontal_space().into() space_x().into()
} }
} }

View file

@ -1,4 +1,4 @@
use iced::widget::{column, pick_list, scrollable, vertical_space}; use iced::widget::{column, pick_list, scrollable, space_y};
use iced::{Center, Element, Fill}; use iced::{Center, Element, Fill};
pub fn main() -> iced::Result { pub fn main() -> iced::Result {
@ -33,10 +33,10 @@ impl Example {
.placeholder("Choose a language..."); .placeholder("Choose a language...");
let content = column![ let content = column![
vertical_space().height(600), space_y().height(600),
"Which is your favorite language?", "Which is your favorite language?",
pick_list, pick_list,
vertical_space().height(600), space_y().height(600),
] ]
.width(Fill) .width(Fill)
.align_x(Center) .align_x(Center)

View file

@ -1,6 +1,6 @@
use iced::widget::{ use iced::widget::{
button, column, container, horizontal_space, operation, progress_bar, button, column, container, operation, progress_bar, radio, row, scrollable,
radio, row, scrollable, slider, text, vertical_space, slider, space_x, space_y, text,
}; };
use iced::{Border, Center, Color, Element, Fill, Task, Theme}; use iced::{Border, Center, Color, Element, Fill, Task, Theme};
@ -190,9 +190,9 @@ impl ScrollableDemo {
column![ column![
scroll_to_end_button(), scroll_to_end_button(),
text("Beginning!"), text("Beginning!"),
vertical_space().height(1200), space_y().height(1200),
text("Middle!"), text("Middle!"),
vertical_space().height(1200), space_y().height(1200),
text("End!"), text("End!"),
scroll_to_beginning_button(), scroll_to_beginning_button(),
] ]
@ -215,9 +215,9 @@ impl ScrollableDemo {
row![ row![
scroll_to_end_button(), scroll_to_end_button(),
text("Beginning!"), text("Beginning!"),
horizontal_space().width(1200), space_x().width(1200),
text("Middle!"), text("Middle!"),
horizontal_space().width(1200), space_x().width(1200),
text("End!"), text("End!"),
scroll_to_beginning_button(), scroll_to_beginning_button(),
] ]
@ -242,25 +242,25 @@ impl ScrollableDemo {
row![ row![
column![ column![
text("Let's do some scrolling!"), text("Let's do some scrolling!"),
vertical_space().height(2400) space_y().height(2400)
], ],
scroll_to_end_button(), scroll_to_end_button(),
text("Horizontal - Beginning!"), text("Horizontal - Beginning!"),
horizontal_space().width(1200), space_x().width(1200),
//vertical content //vertical content
column![ column![
text("Horizontal - Middle!"), text("Horizontal - Middle!"),
scroll_to_end_button(), scroll_to_end_button(),
text("Vertical - Beginning!"), text("Vertical - Beginning!"),
vertical_space().height(1200), space_y().height(1200),
text("Vertical - Middle!"), text("Vertical - Middle!"),
vertical_space().height(1200), space_y().height(1200),
text("Vertical - End!"), text("Vertical - End!"),
scroll_to_beginning_button(), scroll_to_beginning_button(),
vertical_space().height(40), space_y().height(40),
] ]
.spacing(40), .spacing(40),
horizontal_space().width(1200), space_x().width(1200),
text("Horizontal - End!"), text("Horizontal - End!"),
scroll_to_beginning_button(), scroll_to_beginning_button(),
] ]

View file

@ -1,8 +1,8 @@
use iced::keyboard; use iced::keyboard;
use iced::widget::{ use iced::widget::{
button, center_x, center_y, checkbox, column, container, pick_list, button, center_x, center_y, checkbox, column, container, pick_list,
progress_bar, row, rule, scrollable, slider, text, text_input, toggler, progress_bar, row, rule, scrollable, slider, space_y, text, text_input,
vertical_space, toggler,
}; };
use iced::{Center, Element, Fill, Shrink, Subscription, Theme}; use iced::{Center, Element, Fill, Shrink, Subscription, Theme};
@ -127,7 +127,7 @@ impl Styling {
let scroll_me = scrollable(column![ let scroll_me = scrollable(column![
"Scroll me!", "Scroll me!",
vertical_space().height(800), space_y().height(800),
"You did it!" "You did it!"
]) ])
.width(Fill) .width(Fill)

View file

@ -171,9 +171,7 @@ mod toast {
use iced::mouse; use iced::mouse;
use iced::theme; use iced::theme;
use iced::time::{self, Duration, Instant}; use iced::time::{self, Duration, Instant};
use iced::widget::{ use iced::widget::{button, column, container, row, rule, space_x, text};
button, column, container, horizontal_space, row, rule, text,
};
use iced::window; use iced::window;
use iced::{ use iced::{
Alignment, Center, Element, Event, Fill, Length, Point, Rectangle, Alignment, Center, Element, Event, Fill, Length, Point, Rectangle,
@ -239,7 +237,7 @@ mod toast {
container( container(
row![ row![
text(toast.title.as_str()), text(toast.title.as_str()),
horizontal_space(), space_x(),
button("X") button("X")
.on_press((on_close)(index)) .on_press((on_close)(index))
.padding(3), .padding(3),

View file

@ -1,8 +1,7 @@
use iced::widget::{Button, Column, Container, Slider}; use iced::widget::{Button, Column, Container, Slider};
use iced::widget::{ use iced::widget::{
button, center_x, center_y, checkbox, column, horizontal_space, image, button, center_x, center_y, checkbox, column, image, radio, rich_text, row,
radio, rich_text, row, scrollable, slider, span, text, text_input, toggler, scrollable, slider, space_x, space_y, span, text, text_input, toggler,
vertical_space,
}; };
use iced::{Center, Color, Element, Fill, Font, Pixels, color}; use iced::{Center, Color, Element, Fill, Font, Pixels, color};
@ -147,7 +146,7 @@ impl Tour {
.on_press(Message::BackPressed) .on_press(Message::BackPressed)
.style(button::secondary) .style(button::secondary)
}), }),
horizontal_space(), space_x(),
self.can_continue().then(|| { self.can_continue().then(|| {
padded_button("Next").on_press(Message::NextPressed) padded_button("Next").on_press(Message::NextPressed)
}) })
@ -406,14 +405,14 @@ impl Tour {
text("Tip: You can use the scrollbar to scroll down faster!") text("Tip: You can use the scrollbar to scroll down faster!")
.size(16), .size(16),
) )
.push(vertical_space().height(4096)) .push(space_y().height(4096))
.push( .push(
text("You are halfway there!") text("You are halfway there!")
.width(Fill) .width(Fill)
.size(30) .size(30)
.align_x(Center), .align_x(Center),
) )
.push(vertical_space().height(4096)) .push(space_y().height(4096))
.push(ferris(300, image::FilterMethod::Linear)) .push(ferris(300, image::FilterMethod::Linear))
.push(text("You made it!").width(Fill).size(50).align_x(Center)) .push(text("You made it!").width(Fill).size(50).align_x(Center))
} }

View file

@ -1,8 +1,6 @@
use iced::alignment; use iced::alignment;
use iced::mouse; use iced::mouse;
use iced::widget::{ use iced::widget::{canvas, checkbox, column, row, slider, space_x, text};
canvas, checkbox, column, horizontal_space, row, slider, text,
};
use iced::{Center, Element, Fill, Point, Rectangle, Renderer, Theme, Vector}; use iced::{Center, Element, Fill, Point, Rectangle, Renderer, Theme, Vector};
pub fn main() -> iced::Result { pub fn main() -> iced::Result {
@ -51,7 +49,7 @@ impl VectorialText {
fn view(&self) -> Element<'_, Message> { fn view(&self) -> Element<'_, Message> {
let slider_with_label = |label, range, value, message: fn(f32) -> _| { let slider_with_label = |label, range, value, message: fn(f32) -> _| {
column![ column![
row![text(label), horizontal_space(), text!("{:.2}", value)], row![text(label), space_x(), text!("{:.2}", value)],
slider(range, value, message).step(0.01) slider(range, value, message).step(0.01)
] ]
.spacing(2) .spacing(2)

View file

@ -1,8 +1,7 @@
use iced::event::{self, Event}; use iced::event::{self, Event};
use iced::mouse; use iced::mouse;
use iced::widget::{ use iced::widget::{
column, container, horizontal_space, row, scrollable, selector, text, column, container, row, scrollable, selector, space_x, space_y, text,
vertical_space,
}; };
use iced::window; use iced::window;
use iced::{ use iced::{
@ -64,7 +63,7 @@ impl Example {
let data_row = |label, value, color| { let data_row = |label, value, color| {
row![ row![
text(label), text(label),
horizontal_space(), space_x(),
text(value) text(value)
.font(Font::MONOSPACE) .font(Font::MONOSPACE)
.size(14) .size(14)
@ -112,21 +111,21 @@ impl Example {
scrollable( scrollable(
column![ column![
text("Scroll me!"), text("Scroll me!"),
vertical_space().height(400), space_y().height(400),
container(text("I am the outer container!")) container(text("I am the outer container!"))
.id(OUTER_CONTAINER) .id(OUTER_CONTAINER)
.padding(40) .padding(40)
.style(container::rounded_box), .style(container::rounded_box),
vertical_space().height(400), space_y().height(400),
scrollable( scrollable(
column![ column![
text("Scroll me!"), text("Scroll me!"),
vertical_space().height(400), space_y().height(400),
container(text("I am the inner container!")) container(text("I am the inner container!"))
.id(INNER_CONTAINER) .id(INNER_CONTAINER)
.padding(40) .padding(40)
.style(container::rounded_box), .style(container::rounded_box),
vertical_space().height(400), space_y().height(400),
] ]
.padding(20) .padding(20)
) )

View file

@ -27,8 +27,8 @@ use crate::test::ice;
use crate::test::instruction; use crate::test::instruction;
use crate::test::{Emulator, Ice, Instruction}; use crate::test::{Emulator, Ice, Instruction};
use crate::widget::{ use crate::widget::{
button, center, column, combo_box, container, horizontal_space, pick_list, button, center, column, combo_box, container, pick_list, row, rule,
row, rule, scrollable, text, text_editor, text_input, themer, scrollable, space_x, text, text_editor, text_input, themer,
}; };
/// Attaches a [`Tester`] to the given [`Program`]. /// Attaches a [`Tester`] to the given [`Program`].
@ -566,7 +566,7 @@ impl<P: Program + 'static> Tester<P> {
let viewport = container( let viewport = container(
scrollable( scrollable(
container(match &self.state { container(match &self.state {
State::Empty => Element::from(horizontal_space()), State::Empty => Element::from(space_x()),
State::Idle { state } => { State::Idle { state } => {
let theme = program.theme(state, window); let theme = program.theme(state, window);
@ -797,7 +797,7 @@ impl<P: Program + 'static> Tester<P> {
}; };
let edit = if self.is_busy() { let edit = if self.is_busy() {
Element::from(horizontal_space()) Element::from(space_x())
} else if self.edit.is_none() { } else if self.edit.is_none() {
button(icon::pencil().size(14)) button(icon::pencil().size(14))
.padding(0) .padding(0)
@ -851,7 +851,7 @@ where
column![ column![
row![ row![
text(fragment).size(14).font(Font::MONOSPACE), text(fragment).size(14).font(Font::MONOSPACE),
horizontal_space(), space_x(),
control.into() control.into()
] ]
.spacing(5) .spacing(5)

View file

@ -1017,7 +1017,7 @@ where
/// # mod iced { pub mod widget { pub use iced_widget::*; } } /// # mod iced { pub mod widget { pub use iced_widget::*; } }
/// # pub type State = (); /// # pub type State = ();
/// # pub type Element<'a, Message> = iced_widget::core::Element<'a, Message, iced_widget::Theme, iced_widget::Renderer>; /// # pub type Element<'a, Message> = iced_widget::core::Element<'a, Message, iced_widget::Theme, iced_widget::Renderer>;
/// use iced::widget::{column, scrollable, vertical_space}; /// use iced::widget::{column, scrollable, space_y};
/// ///
/// enum Message { /// enum Message {
/// // ... /// // ...
@ -1026,7 +1026,7 @@ where
/// fn view(state: &State) -> Element<'_, Message> { /// fn view(state: &State) -> Element<'_, Message> {
/// scrollable(column![ /// scrollable(column![
/// "Scroll me!", /// "Scroll me!",
/// vertical_space().height(3000), /// space_y().height(3000),
/// "You did it!", /// "You did it!",
/// ]).into() /// ]).into()
/// } /// }
@ -1733,7 +1733,7 @@ where
/// horizontal space. /// horizontal space.
/// ///
/// This can be useful to separate widgets in a [`Row`]. /// This can be useful to separate widgets in a [`Row`].
pub fn horizontal_space() -> Space { pub fn space_x() -> Space {
Space::with_width(Length::Fill) Space::with_width(Length::Fill)
} }
@ -1741,7 +1741,7 @@ pub fn horizontal_space() -> Space {
/// vertical space. /// vertical space.
/// ///
/// This can be useful to separate widgets in a [`Column`]. /// This can be useful to separate widgets in a [`Column`].
pub fn vertical_space() -> Space { pub fn space_y() -> Space {
Space::with_height(Length::Fill) Space::with_height(Length::Fill)
} }

View file

@ -8,7 +8,7 @@ use crate::core::{
self, Clipboard, Element, Event, Length, Rectangle, Shell, Size, Vector, self, Clipboard, Element, Event, Length, Rectangle, Shell, Size, Vector,
Widget, Widget,
}; };
use crate::horizontal_space; use crate::space_x;
/// A widget that is aware of its dimensions. /// A widget that is aware of its dimensions.
/// ///
@ -44,7 +44,7 @@ where
view: Box::new(view), view: Box::new(view),
width: Length::Fill, width: Length::Fill,
height: Length::Fill, height: Length::Fill,
content: Element::new(horizontal_space().width(0)), content: Element::new(space_x().width(0)),
} }
} }

View file

@ -5,7 +5,7 @@
//! # mod iced { pub mod widget { pub use iced_widget::*; } } //! # mod iced { pub mod widget { pub use iced_widget::*; } }
//! # pub type State = (); //! # pub type State = ();
//! # pub type Element<'a, Message> = iced_widget::core::Element<'a, Message, iced_widget::Theme, iced_widget::Renderer>; //! # pub type Element<'a, Message> = iced_widget::core::Element<'a, Message, iced_widget::Theme, iced_widget::Renderer>;
//! use iced::widget::{column, scrollable, vertical_space}; //! use iced::widget::{column, scrollable, space_y};
//! //!
//! enum Message { //! enum Message {
//! // ... //! // ...
@ -14,7 +14,7 @@
//! fn view(state: &State) -> Element<'_, Message> { //! fn view(state: &State) -> Element<'_, Message> {
//! scrollable(column![ //! scrollable(column![
//! "Scroll me!", //! "Scroll me!",
//! vertical_space().height(3000), //! space_y().height(3000),
//! "You did it!", //! "You did it!",
//! ]).into() //! ]).into()
//! } //! }
@ -48,7 +48,7 @@ pub use operation::scrollable::{AbsoluteOffset, RelativeOffset};
/// # mod iced { pub mod widget { pub use iced_widget::*; } } /// # mod iced { pub mod widget { pub use iced_widget::*; } }
/// # pub type State = (); /// # pub type State = ();
/// # pub type Element<'a, Message> = iced_widget::core::Element<'a, Message, iced_widget::Theme, iced_widget::Renderer>; /// # pub type Element<'a, Message> = iced_widget::core::Element<'a, Message, iced_widget::Theme, iced_widget::Renderer>;
/// use iced::widget::{column, scrollable, vertical_space}; /// use iced::widget::{column, scrollable, space_y};
/// ///
/// enum Message { /// enum Message {
/// // ... /// // ...
@ -57,7 +57,7 @@ pub use operation::scrollable::{AbsoluteOffset, RelativeOffset};
/// fn view(state: &State) -> Element<'_, Message> { /// fn view(state: &State) -> Element<'_, Message> {
/// scrollable(column![ /// scrollable(column![
/// "Scroll me!", /// "Scroll me!",
/// vertical_space().height(3000), /// space_y().height(3000),
/// "You did it!", /// "You did it!",
/// ]).into() /// ]).into()
/// } /// }