Replace stateful widgets with new iced_pure API
This commit is contained in:
parent
c44267b85f
commit
ff2519b1d4
142 changed files with 3631 additions and 14494 deletions
|
|
@ -1,14 +1,10 @@
|
|||
use iced_wgpu::Renderer;
|
||||
use iced_winit::widget::slider::{self, Slider};
|
||||
use iced_winit::widget::text_input::{self, TextInput};
|
||||
use iced_winit::widget::{Column, Row, Text};
|
||||
use iced_winit::widget::{slider, text_input, Column, Row, Text};
|
||||
use iced_winit::{Alignment, Color, Command, Element, Length, Program};
|
||||
|
||||
pub struct Controls {
|
||||
background_color: Color,
|
||||
text: String,
|
||||
sliders: [slider::State; 3],
|
||||
text_input: text_input::State,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
|
|
@ -22,8 +18,6 @@ impl Controls {
|
|||
Controls {
|
||||
background_color: Color::BLACK,
|
||||
text: Default::default(),
|
||||
sliders: Default::default(),
|
||||
text_input: Default::default(),
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -49,9 +43,7 @@ impl Program for Controls {
|
|||
Command::none()
|
||||
}
|
||||
|
||||
fn view(&mut self) -> Element<Message, Renderer> {
|
||||
let [r, g, b] = &mut self.sliders;
|
||||
let t = &mut self.text_input;
|
||||
fn view(&self) -> Element<Message, Renderer> {
|
||||
let background_color = self.background_color;
|
||||
let text = &self.text;
|
||||
|
||||
|
|
@ -59,7 +51,7 @@ impl Program for Controls {
|
|||
.width(Length::Units(500))
|
||||
.spacing(20)
|
||||
.push(
|
||||
Slider::new(r, 0.0..=1.0, background_color.r, move |r| {
|
||||
slider(0.0..=1.0, background_color.r, move |r| {
|
||||
Message::BackgroundColorChanged(Color {
|
||||
r,
|
||||
..background_color
|
||||
|
|
@ -68,7 +60,7 @@ impl Program for Controls {
|
|||
.step(0.01),
|
||||
)
|
||||
.push(
|
||||
Slider::new(g, 0.0..=1.0, background_color.g, move |g| {
|
||||
slider(0.0..=1.0, background_color.g, move |g| {
|
||||
Message::BackgroundColorChanged(Color {
|
||||
g,
|
||||
..background_color
|
||||
|
|
@ -77,7 +69,7 @@ impl Program for Controls {
|
|||
.step(0.01),
|
||||
)
|
||||
.push(
|
||||
Slider::new(b, 0.0..=1.0, background_color.b, move |b| {
|
||||
slider(0.0..=1.0, background_color.b, move |b| {
|
||||
Message::BackgroundColorChanged(Color {
|
||||
b,
|
||||
..background_color
|
||||
|
|
@ -108,8 +100,7 @@ impl Program for Controls {
|
|||
.size(14)
|
||||
.style(Color::WHITE),
|
||||
)
|
||||
.push(TextInput::new(
|
||||
t,
|
||||
.push(text_input(
|
||||
"Placeholder",
|
||||
text,
|
||||
Message::TextChanged,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue