From c7b170da6d180f80e539910cccb543720fa3713c Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Sun, 29 Dec 2019 10:57:01 +0100 Subject: Draft `Style` and `StyleSheet` for `Button` --- src/lib.rs | 2 +- src/native.rs | 18 +----------------- 2 files changed, 2 insertions(+), 18 deletions(-) (limited to 'src') diff --git a/src/lib.rs b/src/lib.rs index 1ef11378..579ff43d 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -174,7 +174,7 @@ //! [documentation]: https://docs.rs/iced //! [examples]: https://github.com/hecrj/iced/tree/master/examples //! [`Application`]: trait.Application.html -#![deny(missing_docs)] +//#![deny(missing_docs)] #![deny(missing_debug_implementations)] #![deny(unused_results)] #![deny(unsafe_code)] diff --git a/src/native.rs b/src/native.rs index f06f1c99..cc2068ae 100644 --- a/src/native.rs +++ b/src/native.rs @@ -22,23 +22,7 @@ pub mod widget { //! //! [`TextInput`]: text_input/struct.TextInput.html //! [`text_input::State`]: text_input/struct.State.html - pub mod button { - //! Allow your users to perform actions by pressing a button. - //! - //! A [`Button`] has some local [`State`]. - //! - //! [`Button`]: type.Button.html - //! [`State`]: struct.State.html - - /// A widget that produces a message when clicked. - /// - /// This is an alias of an `iced_native` button with a default - /// `Renderer`. - pub type Button<'a, Message> = - iced_winit::Button<'a, Message, iced_wgpu::Renderer>; - - pub use iced_winit::button::State; - } + pub use iced_wgpu::button; pub mod scrollable { //! Navigate an endless amount of content with a scrollbar. -- cgit From f74ab463d44dd0bb025b0cea466d2861576253dd Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Sun, 29 Dec 2019 12:29:47 +0100 Subject: Add `background_color` to `Settings` --- src/settings.rs | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/settings.rs b/src/settings.rs index 62a1a614..8da8948c 100644 --- a/src/settings.rs +++ b/src/settings.rs @@ -1,7 +1,8 @@ //! Configure your application. +use crate::Color; /// The settings of an application. -#[derive(Debug, Clone, Copy, PartialEq, Eq, Default)] +#[derive(Debug, Clone, Copy, PartialEq)] pub struct Settings { /// The [`Window`] settings. /// @@ -9,6 +10,20 @@ pub struct Settings { /// /// [`Window`]: struct.Window.html pub window: Window, + + /// The default background [`Color`] of the application + /// + /// [`Color`]: ../struct.Color.html + pub background_color: Color, +} + +impl Default for Settings { + fn default() -> Settings { + Settings { + window: Window::default(), + background_color: Color::WHITE, + } + } } /// The window settings of an application. @@ -44,6 +59,7 @@ impl From for iced_winit::Settings { decorations: settings.window.decorations, platform_specific: Default::default(), }, + background_color: settings.background_color, } } } -- cgit From 89a6b8a9a173e767753ec777fd83c912c1be5ea3 Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Sun, 29 Dec 2019 12:31:47 +0100 Subject: Rename `Settings::background_color` to `background` --- src/settings.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/settings.rs b/src/settings.rs index 8da8948c..4ae18a14 100644 --- a/src/settings.rs +++ b/src/settings.rs @@ -14,14 +14,14 @@ pub struct Settings { /// The default background [`Color`] of the application /// /// [`Color`]: ../struct.Color.html - pub background_color: Color, + pub background: Color, } impl Default for Settings { fn default() -> Settings { Settings { window: Window::default(), - background_color: Color::WHITE, + background: Color::WHITE, } } } @@ -59,7 +59,7 @@ impl From for iced_winit::Settings { decorations: settings.window.decorations, platform_specific: Default::default(), }, - background_color: settings.background_color, + background: settings.background, } } } -- cgit From e1062a02d17f5748e4809b76ddcc132f1c912886 Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Wed, 1 Jan 2020 14:16:10 +0100 Subject: Move styling to a brand new `iced_style` crate --- src/native.rs | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) (limited to 'src') diff --git a/src/native.rs b/src/native.rs index d5c9349a..54afee4b 100644 --- a/src/native.rs +++ b/src/native.rs @@ -22,7 +22,7 @@ pub mod widget { //! //! [`TextInput`]: text_input/struct.TextInput.html //! [`text_input::State`]: text_input/struct.State.html - pub use iced_wgpu::button; + pub use iced_wgpu::widget::*; pub mod scrollable { //! Navigate an endless amount of content with a scrollbar. @@ -73,8 +73,9 @@ pub mod widget { #[doc(no_inline)] pub use { - button::Button, image::Image, scrollable::Scrollable, slider::Slider, - svg::Svg, text_input::TextInput, + button::Button, container::Container, image::Image, + scrollable::Scrollable, slider::Slider, svg::Svg, + text_input::TextInput, }; /// A container that distributes its contents vertically. @@ -88,13 +89,6 @@ pub mod widget { /// This is an alias of an `iced_native` row with a default `Renderer`. pub type Row<'a, Message> = iced_winit::Row<'a, Message, iced_wgpu::Renderer>; - - /// An element decorating some content. - /// - /// This is an alias of an `iced_native` container with a default - /// `Renderer`. - pub type Container<'a, Message> = - iced_winit::Container<'a, Message, iced_wgpu::Renderer>; } #[doc(no_inline)] -- cgit From d96ced8e2da703117a43399110ef2b8fa21a7546 Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Wed, 1 Jan 2020 17:49:48 +0100 Subject: Allow configuration of default font --- src/application.rs | 7 ++++++- src/settings.rs | 4 ++++ 2 files changed, 10 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/application.rs b/src/application.rs index a7e826fb..7dd76774 100644 --- a/src/application.rs +++ b/src/application.rs @@ -151,7 +151,12 @@ pub trait Application: Sized { Self: 'static, { #[cfg(not(target_arch = "wasm32"))] - as iced_winit::Application>::run(_settings.into()); + as iced_winit::Application>::run( + _settings.into(), + iced_wgpu::Settings { + default_font: _settings.default_font, + }, + ); #[cfg(target_arch = "wasm32")] as iced_web::Application>::run(); diff --git a/src/settings.rs b/src/settings.rs index 4ae18a14..b01e6fc8 100644 --- a/src/settings.rs +++ b/src/settings.rs @@ -15,6 +15,9 @@ pub struct Settings { /// /// [`Color`]: ../struct.Color.html pub background: Color, + + // TODO: Add `name` for web compatibility + pub default_font: Option<&'static [u8]>, } impl Default for Settings { @@ -22,6 +25,7 @@ impl Default for Settings { Settings { window: Window::default(), background: Color::WHITE, + default_font: None, } } } -- cgit From 5af4159848341b14f6ff9ae14a9a222d8d8b0fb8 Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Wed, 1 Jan 2020 18:26:49 +0100 Subject: Draft basic styling for `TextInput` --- src/native.rs | 10 ---------- 1 file changed, 10 deletions(-) (limited to 'src') diff --git a/src/native.rs b/src/native.rs index 54afee4b..3535ab6a 100644 --- a/src/native.rs +++ b/src/native.rs @@ -38,16 +38,6 @@ pub mod widget { pub use iced_winit::scrollable::State; } - pub mod text_input { - //! Ask for information using text fields. - //! - //! A [`TextInput`] has some local [`State`]. - //! - //! [`TextInput`]: struct.TextInput.html - //! [`State`]: struct.State.html - pub use iced_winit::text_input::{State, TextInput}; - } - pub mod slider { //! Display an interactive selector of a single value from a range of //! values. -- cgit From 8d6f86b317303c06a0daf1ca3ce91c29670dd674 Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Sun, 5 Jan 2020 18:11:54 +0100 Subject: Remove `background` from `Settings` --- src/settings.rs | 8 -------- 1 file changed, 8 deletions(-) (limited to 'src') diff --git a/src/settings.rs b/src/settings.rs index b01e6fc8..b725ef9f 100644 --- a/src/settings.rs +++ b/src/settings.rs @@ -1,5 +1,4 @@ //! Configure your application. -use crate::Color; /// The settings of an application. #[derive(Debug, Clone, Copy, PartialEq)] @@ -11,11 +10,6 @@ pub struct Settings { /// [`Window`]: struct.Window.html pub window: Window, - /// The default background [`Color`] of the application - /// - /// [`Color`]: ../struct.Color.html - pub background: Color, - // TODO: Add `name` for web compatibility pub default_font: Option<&'static [u8]>, } @@ -24,7 +18,6 @@ impl Default for Settings { fn default() -> Settings { Settings { window: Window::default(), - background: Color::WHITE, default_font: None, } } @@ -63,7 +56,6 @@ impl From for iced_winit::Settings { decorations: settings.window.decorations, platform_specific: Default::default(), }, - background: settings.background, } } } -- cgit From 1a0effa961344677daf17b4192243423a154f1bf Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Sun, 5 Jan 2020 19:29:12 +0100 Subject: Add border and shadow styling to `Button` --- src/native.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/native.rs b/src/native.rs index 3535ab6a..b7becdc8 100644 --- a/src/native.rs +++ b/src/native.rs @@ -1,6 +1,6 @@ pub use iced_winit::{ Align, Background, Color, Command, Font, HorizontalAlignment, Length, - Space, Subscription, VerticalAlignment, + Space, Subscription, Vector, VerticalAlignment, }; pub mod widget { -- cgit From d0dc7cebf9c352f4d14827fe47489788f59e61a1 Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Mon, 6 Jan 2020 21:01:09 +0100 Subject: Implement styling for `Scrollable` --- src/native.rs | 14 -------------- 1 file changed, 14 deletions(-) (limited to 'src') diff --git a/src/native.rs b/src/native.rs index 67f85c20..1061a730 100644 --- a/src/native.rs +++ b/src/native.rs @@ -24,20 +24,6 @@ pub mod widget { //! [`text_input::State`]: text_input/struct.State.html pub use iced_wgpu::widget::*; - pub mod scrollable { - //! Navigate an endless amount of content with a scrollbar. - - /// A widget that can vertically display an infinite amount of content - /// with a scrollbar. - /// - /// This is an alias of an `iced_native` scrollable with a default - /// `Renderer`. - pub type Scrollable<'a, Message> = - iced_winit::Scrollable<'a, Message, iced_wgpu::Renderer>; - - pub use iced_winit::scrollable::State; - } - pub mod slider { //! Display an interactive selector of a single value from a range of //! values. -- cgit From b329003c8fdcdc3378c8fda93af54be5686fc9ae Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Tue, 7 Jan 2020 00:28:08 +0100 Subject: Implement styling for `Slider` --- src/native.rs | 11 ----------- 1 file changed, 11 deletions(-) (limited to 'src') diff --git a/src/native.rs b/src/native.rs index 1061a730..c2584fdd 100644 --- a/src/native.rs +++ b/src/native.rs @@ -24,17 +24,6 @@ pub mod widget { //! [`text_input::State`]: text_input/struct.State.html pub use iced_wgpu::widget::*; - pub mod slider { - //! Display an interactive selector of a single value from a range of - //! values. - //! - //! A [`Slider`] has some local [`State`]. - //! - //! [`Slider`]: struct.Slider.html - //! [`State`]: struct.State.html - pub use iced_winit::slider::{Slider, State}; - } - pub mod image { //! Display images in your user interface. pub use iced_winit::image::{Handle, Image}; -- cgit From 48b3b78a3840778eef1035f4585d5ba9dd3d6291 Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Tue, 7 Jan 2020 01:53:26 +0100 Subject: Implement styling for `ProgressBar` --- src/native.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/native.rs b/src/native.rs index c2584fdd..5a4db8f6 100644 --- a/src/native.rs +++ b/src/native.rs @@ -34,13 +34,13 @@ pub mod widget { pub use iced_winit::svg::{Handle, Svg}; } - pub use iced_winit::{Checkbox, ProgressBar, Radio, Text}; + pub use iced_winit::{Checkbox, Radio, Text}; #[doc(no_inline)] pub use { button::Button, container::Container, image::Image, - scrollable::Scrollable, slider::Slider, svg::Svg, - text_input::TextInput, + progress_bar::ProgressBar, scrollable::Scrollable, slider::Slider, + svg::Svg, text_input::TextInput, }; /// A container that distributes its contents vertically. -- cgit From 387fc0be26ccd1adc66c1dc80420f9b08d0c023a Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Tue, 7 Jan 2020 02:25:57 +0100 Subject: Implement styling for `Radio` --- src/native.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/native.rs b/src/native.rs index 5a4db8f6..2f2182ff 100644 --- a/src/native.rs +++ b/src/native.rs @@ -34,13 +34,13 @@ pub mod widget { pub use iced_winit::svg::{Handle, Svg}; } - pub use iced_winit::{Checkbox, Radio, Text}; + pub use iced_winit::{Checkbox, Text}; #[doc(no_inline)] pub use { button::Button, container::Container, image::Image, - progress_bar::ProgressBar, scrollable::Scrollable, slider::Slider, - svg::Svg, text_input::TextInput, + progress_bar::ProgressBar, radio::Radio, scrollable::Scrollable, + slider::Slider, svg::Svg, text_input::TextInput, }; /// A container that distributes its contents vertically. -- cgit From ed30b487d649ffa0967ab8bfd66f4820ee2150fd Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Tue, 7 Jan 2020 02:54:54 +0100 Subject: Implement styling for `Checkbox` --- src/native.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/native.rs b/src/native.rs index 2f2182ff..35441a3e 100644 --- a/src/native.rs +++ b/src/native.rs @@ -34,11 +34,11 @@ pub mod widget { pub use iced_winit::svg::{Handle, Svg}; } - pub use iced_winit::{Checkbox, Text}; + pub use iced_winit::Text; #[doc(no_inline)] pub use { - button::Button, container::Container, image::Image, + button::Button, checkbox::Checkbox, container::Container, image::Image, progress_bar::ProgressBar, radio::Radio, scrollable::Scrollable, slider::Slider, svg::Svg, text_input::TextInput, }; -- cgit From 7b278755fc7929633b5771824beac4d39b16e82e Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Thu, 9 Jan 2020 18:31:07 +0100 Subject: Write missing docs and reenable deny statements --- src/lib.rs | 2 +- src/settings.rs | 14 ++++---------- 2 files changed, 5 insertions(+), 11 deletions(-) (limited to 'src') diff --git a/src/lib.rs b/src/lib.rs index 579ff43d..1ef11378 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -174,7 +174,7 @@ //! [documentation]: https://docs.rs/iced //! [examples]: https://github.com/hecrj/iced/tree/master/examples //! [`Application`]: trait.Application.html -//#![deny(missing_docs)] +#![deny(missing_docs)] #![deny(missing_debug_implementations)] #![deny(unused_results)] #![deny(unsafe_code)] diff --git a/src/settings.rs b/src/settings.rs index b725ef9f..e20edc97 100644 --- a/src/settings.rs +++ b/src/settings.rs @@ -1,7 +1,7 @@ //! Configure your application. /// The settings of an application. -#[derive(Debug, Clone, Copy, PartialEq)] +#[derive(Debug, Clone, Copy, PartialEq, Eq, Default)] pub struct Settings { /// The [`Window`] settings. /// @@ -10,19 +10,13 @@ pub struct Settings { /// [`Window`]: struct.Window.html pub window: Window, + /// The bytes of the font that will be used by default. + /// + /// If `None` is provided, a default system font will be chosen. // TODO: Add `name` for web compatibility pub default_font: Option<&'static [u8]>, } -impl Default for Settings { - fn default() -> Settings { - Settings { - window: Window::default(), - default_font: None, - } - } -} - /// The window settings of an application. #[derive(Debug, Clone, Copy, PartialEq, Eq)] pub struct Window { -- cgit