Use hover widget in bezier_tool example
This commit is contained in:
parent
23ef6547ad
commit
a16a75a71d
1 changed files with 15 additions and 11 deletions
|
|
@ -1,6 +1,6 @@
|
||||||
//! This example showcases an interactive `Canvas` for drawing Bézier curves.
|
//! This example showcases an interactive `Canvas` for drawing Bézier curves.
|
||||||
use iced::alignment;
|
use iced::alignment;
|
||||||
use iced::widget::{button, container, stack};
|
use iced::widget::{button, container, horizontal_space, hover};
|
||||||
use iced::{Element, Length, Theme};
|
use iced::{Element, Length, Theme};
|
||||||
|
|
||||||
pub fn main() -> iced::Result {
|
pub fn main() -> iced::Result {
|
||||||
|
|
@ -37,17 +37,21 @@ impl Example {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn view(&self) -> Element<Message> {
|
fn view(&self) -> Element<Message> {
|
||||||
container(stack![
|
container(hover(
|
||||||
self.bezier.view(&self.curves).map(Message::AddCurve),
|
self.bezier.view(&self.curves).map(Message::AddCurve),
|
||||||
container(
|
if self.curves.is_empty() {
|
||||||
button("Clear")
|
container(horizontal_space())
|
||||||
.style(button::danger)
|
} else {
|
||||||
.on_press(Message::Clear)
|
container(
|
||||||
)
|
button("Clear")
|
||||||
.padding(10)
|
.style(button::danger)
|
||||||
.width(Length::Fill)
|
.on_press(Message::Clear),
|
||||||
.align_x(alignment::Horizontal::Right),
|
)
|
||||||
])
|
.padding(10)
|
||||||
|
.width(Length::Fill)
|
||||||
|
.align_x(alignment::Horizontal::Right)
|
||||||
|
},
|
||||||
|
))
|
||||||
.padding(20)
|
.padding(20)
|
||||||
.into()
|
.into()
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue