diff options
author | 2024-04-27 06:06:28 +0200 | |
---|---|---|
committer | 2024-04-27 06:06:28 +0200 | |
commit | a16a75a71d0bc76c17c2d76d827fa8c37eb56f09 (patch) | |
tree | 59b9567d237f0453e74f9279ed0706849ed899e1 /examples/bezier_tool | |
parent | 23ef6547ad0f0cc2944664ace4be7cdacc0a23cf (diff) | |
download | iced-a16a75a71d0bc76c17c2d76d827fa8c37eb56f09.tar.gz iced-a16a75a71d0bc76c17c2d76d827fa8c37eb56f09.tar.bz2 iced-a16a75a71d0bc76c17c2d76d827fa8c37eb56f09.zip |
Use `hover` widget in `bezier_tool` example
Diffstat (limited to 'examples/bezier_tool')
-rw-r--r-- | examples/bezier_tool/src/main.rs | 26 |
1 files changed, 15 insertions, 11 deletions
diff --git a/examples/bezier_tool/src/main.rs b/examples/bezier_tool/src/main.rs index ba51a00e..29df3eeb 100644 --- a/examples/bezier_tool/src/main.rs +++ b/examples/bezier_tool/src/main.rs @@ -1,6 +1,6 @@ //! This example showcases an interactive `Canvas` for drawing Bézier curves. use iced::alignment; -use iced::widget::{button, container, stack}; +use iced::widget::{button, container, horizontal_space, hover}; use iced::{Element, Length, Theme}; pub fn main() -> iced::Result { @@ -37,17 +37,21 @@ impl Example { } fn view(&self) -> Element<Message> { - container(stack![ + container(hover( self.bezier.view(&self.curves).map(Message::AddCurve), - container( - button("Clear") - .style(button::danger) - .on_press(Message::Clear) - ) - .padding(10) - .width(Length::Fill) - .align_x(alignment::Horizontal::Right), - ]) + if self.curves.is_empty() { + container(horizontal_space()) + } else { + container( + button("Clear") + .style(button::danger) + .on_press(Message::Clear), + ) + .padding(10) + .width(Length::Fill) + .align_x(alignment::Horizontal::Right) + }, + )) .padding(20) .into() } |