diff options
author | 2022-01-31 17:01:19 +0700 | |
---|---|---|
committer | 2022-01-31 17:01:19 +0700 | |
commit | e4ef29ef20724c3d1a4beff39ddfdaf6d45f9683 (patch) | |
tree | 6e0c9c38366c9d70204c80fc66bd8e8a7652cf52 /examples/integration_wgpu/src/controls.rs | |
parent | c75ed37148b019358b0297171cf31b2577eeb9ae (diff) | |
parent | 6f604ab3995cb345aacf183a569589988aa3ad1f (diff) | |
download | iced-e4ef29ef20724c3d1a4beff39ddfdaf6d45f9683.tar.gz iced-e4ef29ef20724c3d1a4beff39ddfdaf6d45f9683.tar.bz2 iced-e4ef29ef20724c3d1a4beff39ddfdaf6d45f9683.zip |
Merge pull request #1096 from pacmancoder/feat/wgpu-webgl
Experimental WebGL wgpu backend support
Diffstat (limited to 'examples/integration_wgpu/src/controls.rs')
-rw-r--r-- | examples/integration_wgpu/src/controls.rs | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/examples/integration_wgpu/src/controls.rs b/examples/integration_wgpu/src/controls.rs index 4f110bd2..9bca40eb 100644 --- a/examples/integration_wgpu/src/controls.rs +++ b/examples/integration_wgpu/src/controls.rs @@ -1,23 +1,29 @@ 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::{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)] pub enum Message { BackgroundColorChanged(Color), + TextChanged(String), } impl Controls { pub fn new() -> Controls { Controls { background_color: Color::BLACK, + text: Default::default(), sliders: Default::default(), + text_input: Default::default(), } } @@ -35,6 +41,9 @@ impl Program for Controls { Message::BackgroundColorChanged(color) => { self.background_color = color; } + Message::TextChanged(text) => { + self.text = text; + } } Command::none() @@ -42,7 +51,9 @@ impl Program for Controls { fn view(&mut self) -> Element<Message, Renderer> { let [r, g, b] = &mut self.sliders; + let t = &mut self.text_input; let background_color = self.background_color; + let text = &self.text; let sliders = Row::new() .width(Length::Units(500)) @@ -96,7 +107,13 @@ impl Program for Controls { Text::new(format!("{:?}", background_color)) .size(14) .color(Color::WHITE), - ), + ) + .push(TextInput::new( + t, + "Placeholder", + text, + move |text| Message::TextChanged(text), + )), ), ) .into() |