summaryrefslogtreecommitdiffstats
path: root/examples/component/src
diff options
context:
space:
mode:
authorLibravatar Héctor Ramón <hector0193@gmail.com>2023-03-09 19:05:38 +0100
committerLibravatar GitHub <noreply@github.com>2023-03-09 19:05:38 +0100
commitcaf2836b1b15bff6e8a2ea72441d67f297eb8707 (patch)
tree0ffa0d1d604780999892b88de85ee93e3ed7d539 /examples/component/src
parent11b2c3bbe31a43e73a61b9bd9f022233f302ae27 (diff)
parent424ac8177309440bbd8efe0dd9f7622cb10807ce (diff)
downloadiced-caf2836b1b15bff6e8a2ea72441d67f297eb8707.tar.gz
iced-caf2836b1b15bff6e8a2ea72441d67f297eb8707.tar.bz2
iced-caf2836b1b15bff6e8a2ea72441d67f297eb8707.zip
Merge pull request #1748 from iced-rs/feature/software-renderer
Software renderer, runtime renderer fallback, and core consolidation
Diffstat (limited to 'examples/component/src')
-rw-r--r--examples/component/src/main.rs27
1 files changed, 8 insertions, 19 deletions
diff --git a/examples/component/src/main.rs b/examples/component/src/main.rs
index c407bb06..09e5e4a2 100644
--- a/examples/component/src/main.rs
+++ b/examples/component/src/main.rs
@@ -47,9 +47,8 @@ impl Sandbox for Component {
mod numeric_input {
use iced::alignment::{self, Alignment};
- use iced::widget::{self, button, row, text, text_input};
- use iced::{Element, Length};
- use iced_lazy::{self, Component};
+ use iced::widget::{button, component, row, text, text_input, Component};
+ use iced::{Element, Length, Renderer};
pub struct NumericInput<Message> {
value: Option<u32>,
@@ -82,13 +81,7 @@ mod numeric_input {
}
}
- impl<Message, Renderer> Component<Message, Renderer> for NumericInput<Message>
- where
- Renderer: iced_native::text::Renderer + 'static,
- Renderer::Theme: widget::button::StyleSheet
- + widget::text_input::StyleSheet
- + widget::text::StyleSheet,
- {
+ impl<Message> Component<Message, Renderer> for NumericInput<Message> {
type State = ();
type Event = Event;
@@ -127,7 +120,8 @@ mod numeric_input {
.horizontal_alignment(alignment::Horizontal::Center)
.vertical_alignment(alignment::Vertical::Center),
)
- .width(50)
+ .width(40)
+ .height(40)
.on_press(on_press)
};
@@ -145,23 +139,18 @@ mod numeric_input {
.padding(10),
button("+", Event::IncrementPressed),
]
- .align_items(Alignment::Fill)
+ .align_items(Alignment::Center)
.spacing(10)
.into()
}
}
- impl<'a, Message, Renderer> From<NumericInput<Message>>
- for Element<'a, Message, Renderer>
+ impl<'a, Message> From<NumericInput<Message>> for Element<'a, Message, Renderer>
where
Message: 'a,
- Renderer: 'static + iced_native::text::Renderer,
- Renderer::Theme: widget::button::StyleSheet
- + widget::text_input::StyleSheet
- + widget::text::StyleSheet,
{
fn from(numeric_input: NumericInput<Message>) -> Self {
- iced_lazy::component(numeric_input)
+ component(numeric_input)
}
}
}