From 65eb218d3d7ba52b2869a586a1480eeb3c8f84e4 Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Thu, 21 Nov 2019 13:47:20 +0100 Subject: Move widgets from `core` to `native` and `web` Also made fields private and improved `Renderer` traits. --- src/lib.rs | 4 ++-- src/native.rs | 51 +++++++++++++++++++++++++++++++++++++++++++++++++++ src/winit.rs | 13 ------------- 3 files changed, 53 insertions(+), 15 deletions(-) create mode 100644 src/native.rs delete mode 100644 src/winit.rs (limited to 'src') diff --git a/src/lib.rs b/src/lib.rs index 945af421..e64767c2 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,5 +1,5 @@ #[cfg_attr(target_arch = "wasm32", path = "web.rs")] -#[cfg_attr(not(target_arch = "wasm32"), path = "winit.rs")] +#[cfg_attr(not(target_arch = "wasm32"), path = "native.rs")] mod platform; pub use platform::*; @@ -34,7 +34,7 @@ impl iced_winit::Application for Instance where A: Application, { - type Renderer = Renderer; + type Renderer = iced_wgpu::Renderer; type Message = A::Message; fn new() -> (Self, Command) { diff --git a/src/native.rs b/src/native.rs new file mode 100644 index 00000000..fcb50d43 --- /dev/null +++ b/src/native.rs @@ -0,0 +1,51 @@ +pub use iced_winit::{ + Align, Background, Color, Command, Font, HorizontalAlignment, Length, + VerticalAlignment, +}; + +pub mod widget { + pub mod button { + pub type Button<'a, Message> = + iced_winit::Button<'a, Message, iced_wgpu::Renderer>; + + pub use iced_winit::button::State; + } + + pub mod scrollable { + pub type Scrollable<'a, Message> = + iced_winit::Scrollable<'a, Message, iced_wgpu::Renderer>; + + pub use iced_winit::scrollable::State; + } + + pub mod text_input { + pub use iced_winit::text_input::{State, TextInput}; + } + + pub mod slider { + pub use iced_winit::slider::{Slider, State}; + } + + pub use iced_winit::{Checkbox, Image, Radio, Text}; + + #[doc(no_inline)] + pub use { + button::Button, scrollable::Scrollable, slider::Slider, + text_input::TextInput, + }; + + pub type Column<'a, Message> = + iced_winit::Column<'a, Message, iced_wgpu::Renderer>; + + pub type Row<'a, Message> = + iced_winit::Row<'a, Message, iced_wgpu::Renderer>; + + pub type Container<'a, Message> = + iced_winit::Container<'a, Message, iced_wgpu::Renderer>; +} + +#[doc(no_inline)] +pub use widget::*; + +pub type Element<'a, Message> = + iced_winit::Element<'a, Message, iced_wgpu::Renderer>; diff --git a/src/winit.rs b/src/winit.rs deleted file mode 100644 index c869a269..00000000 --- a/src/winit.rs +++ /dev/null @@ -1,13 +0,0 @@ -pub use iced_wgpu::{Primitive, Renderer}; - -pub use iced_winit::{ - button, scrollable, slider, text, text_input, winit, Align, Background, - Checkbox, Color, Command, Font, Image, Length, Radio, Scrollable, Slider, - Text, TextInput, -}; - -pub type Element<'a, Message> = iced_winit::Element<'a, Message, Renderer>; -pub type Container<'a, Message> = iced_winit::Container<'a, Message, Renderer>; -pub type Row<'a, Message> = iced_winit::Row<'a, Message, Renderer>; -pub type Column<'a, Message> = iced_winit::Column<'a, Message, Renderer>; -pub type Button<'a, Message> = iced_winit::Button<'a, Message, Renderer>; -- cgit