From 0d8cefbf2d084053b92ded4785da8083486374ea Mon Sep 17 00:00:00 2001 From: Cory Forsstrom Date: Thu, 23 Apr 2020 15:34:55 -0700 Subject: Add `ImagePane` widget --- src/widget.rs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/widget.rs b/src/widget.rs index e33a6b2c..a1bc8f5b 100644 --- a/src/widget.rs +++ b/src/widget.rs @@ -33,6 +33,12 @@ mod platform { pub use iced_winit::image::{Handle, Image}; } + #[cfg_attr(docsrs, doc(cfg(feature = "image")))] + pub mod image_pane { + //! Zoom and pan on an image. + pub use iced_wgpu::image_pane::{ImagePane, State}; + } + #[cfg_attr(docsrs, doc(cfg(feature = "svg")))] pub mod svg { //! Display vector graphics in your user interface. @@ -44,8 +50,8 @@ mod platform { #[doc(no_inline)] pub use { button::Button, checkbox::Checkbox, container::Container, image::Image, - pane_grid::PaneGrid, progress_bar::ProgressBar, radio::Radio, - scrollable::Scrollable, slider::Slider, svg::Svg, + image_pane::ImagePane, pane_grid::PaneGrid, progress_bar::ProgressBar, + radio::Radio, scrollable::Scrollable, slider::Slider, svg::Svg, text_input::TextInput, }; -- cgit From 431171f975642fe96286f11fb75cd5b06827cc7f Mon Sep 17 00:00:00 2001 From: Cory Forsstrom Date: Fri, 15 May 2020 09:46:22 -0700 Subject: Rename and add to iced image module --- src/widget.rs | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) (limited to 'src') diff --git a/src/widget.rs b/src/widget.rs index a1bc8f5b..92303277 100644 --- a/src/widget.rs +++ b/src/widget.rs @@ -31,12 +31,7 @@ mod platform { pub mod image { //! Display images in your user interface. pub use iced_winit::image::{Handle, Image}; - } - - #[cfg_attr(docsrs, doc(cfg(feature = "image")))] - pub mod image_pane { - //! Zoom and pan on an image. - pub use iced_wgpu::image_pane::{ImagePane, State}; + pub use iced_winit::image_viewer::{ImageViewer, State}; } #[cfg_attr(docsrs, doc(cfg(feature = "svg")))] @@ -49,9 +44,16 @@ mod platform { #[doc(no_inline)] pub use { - button::Button, checkbox::Checkbox, container::Container, image::Image, - image_pane::ImagePane, pane_grid::PaneGrid, progress_bar::ProgressBar, - radio::Radio, scrollable::Scrollable, slider::Slider, svg::Svg, + button::Button, + checkbox::Checkbox, + container::Container, + image::{Image, ImageViewer}, + pane_grid::PaneGrid, + progress_bar::ProgressBar, + radio::Radio, + scrollable::Scrollable, + slider::Slider, + svg::Svg, text_input::TextInput, }; -- cgit From 5d045c2e9a639f8bbf43e68fde9091be702b3ab8 Mon Sep 17 00:00:00 2001 From: Cory Forsstrom Date: Tue, 26 May 2020 17:15:55 -0700 Subject: rename to image::Viewer --- src/widget.rs | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) (limited to 'src') diff --git a/src/widget.rs b/src/widget.rs index 92303277..0b0b25db 100644 --- a/src/widget.rs +++ b/src/widget.rs @@ -30,8 +30,7 @@ mod platform { #[cfg_attr(docsrs, doc(cfg(feature = "image")))] pub mod image { //! Display images in your user interface. - pub use iced_winit::image::{Handle, Image}; - pub use iced_winit::image_viewer::{ImageViewer, State}; + pub use iced_winit::image::{Handle, Image, State, Viewer}; } #[cfg_attr(docsrs, doc(cfg(feature = "svg")))] @@ -44,16 +43,9 @@ mod platform { #[doc(no_inline)] pub use { - button::Button, - checkbox::Checkbox, - container::Container, - image::{Image, ImageViewer}, - pane_grid::PaneGrid, - progress_bar::ProgressBar, - radio::Radio, - scrollable::Scrollable, - slider::Slider, - svg::Svg, + button::Button, checkbox::Checkbox, container::Container, image::Image, + pane_grid::PaneGrid, progress_bar::ProgressBar, radio::Radio, + scrollable::Scrollable, slider::Slider, svg::Svg, text_input::TextInput, }; -- cgit From c7bb43411381a1bffe70ea8e684cd9e4a27739e0 Mon Sep 17 00:00:00 2001 From: Cory Forsstrom Date: Wed, 27 May 2020 14:20:07 -0700 Subject: remove re-export on viewer::State --- src/widget.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/widget.rs b/src/widget.rs index 0b0b25db..932a8cf6 100644 --- a/src/widget.rs +++ b/src/widget.rs @@ -30,7 +30,9 @@ mod platform { #[cfg_attr(docsrs, doc(cfg(feature = "image")))] pub mod image { //! Display images in your user interface. - pub use iced_winit::image::{Handle, Image, State, Viewer}; + pub use iced_winit::image::{Handle, Image, Viewer}; + + pub use iced_winit::image::viewer; } #[cfg_attr(docsrs, doc(cfg(feature = "svg")))] -- cgit From b2415eee61063d5c2b220d7b7a513d1952ce2be1 Mon Sep 17 00:00:00 2001 From: Jayce Fayne Date: Wed, 13 Jan 2021 01:48:35 +0100 Subject: Add `smol` async runtime --- src/executor.rs | 30 ++++++++++++++++++++++++------ src/lib.rs | 8 +++++++- 2 files changed, 31 insertions(+), 7 deletions(-) (limited to 'src') diff --git a/src/executor.rs b/src/executor.rs index 0333bc1d..2c6d9ec0 100644 --- a/src/executor.rs +++ b/src/executor.rs @@ -7,22 +7,40 @@ pub use platform::Default; mod platform { use iced_futures::{executor, futures}; - #[cfg(feature = "tokio_old")] + #[cfg(all( + not(any(feature = "tokio", feature = "smol", feature = "async-std")), + feature = "tokio_old" + ))] type Executor = executor::TokioOld; - #[cfg(all(not(feature = "tokio_old"), feature = "tokio"))] + #[cfg(all( + not(any( + feature = "tokio_old", + feature = "smol", + feature = "async-std" + )), + feature = "tokio" + ))] type Executor = executor::Tokio; + #[cfg(feature = "async-std")] + type Executor = executor::AsyncStd; + #[cfg(all( - not(any(feature = "tokio_old", feature = "tokio")), - feature = "async-std" + not(any( + feature = "tokio_old", + feature = "tokio", + feature = "async-std" + )), + feature = "smol" ))] - type Executor = executor::AsyncStd; + type Executor = executor::Smol; #[cfg(not(any( feature = "tokio_old", feature = "tokio", - feature = "async-std" + feature = "async-std", + feature = "smol", )))] type Executor = executor::ThreadPool; diff --git a/src/lib.rs b/src/lib.rs index 3578ea82..dedcac7a 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -191,7 +191,12 @@ pub mod widget; pub mod window; #[cfg(all( - any(feature = "tokio", feature = "tokio_old", feature = "async-std"), + any( + feature = "tokio", + feature = "tokio_old", + feature = "async-std", + feature = "smol" + ), not(target_arch = "wasm32") ))] #[cfg_attr( @@ -200,6 +205,7 @@ pub mod window; feature = "tokio", feature = "tokio_old", feature = "async-std" + feature = "smol" ))) )] pub mod time; -- cgit From a42a0844c2ffc51e117304a5d08e4a0fb52adac7 Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Fri, 15 Jan 2021 18:31:30 +0100 Subject: Keep old behavior for `Executor` feature flags --- src/executor.rs | 21 +++++++-------------- 1 file changed, 7 insertions(+), 14 deletions(-) (limited to 'src') diff --git a/src/executor.rs b/src/executor.rs index 2c6d9ec0..9f3656b1 100644 --- a/src/executor.rs +++ b/src/executor.rs @@ -7,32 +7,25 @@ pub use platform::Default; mod platform { use iced_futures::{executor, futures}; - #[cfg(all( - not(any(feature = "tokio", feature = "smol", feature = "async-std")), - feature = "tokio_old" - ))] + #[cfg(feature = "tokio_old")] type Executor = executor::TokioOld; - #[cfg(all( - not(any( - feature = "tokio_old", - feature = "smol", - feature = "async-std" - )), - feature = "tokio" - ))] + #[cfg(all(feature = "tokio", not(feature = "tokio_old")))] type Executor = executor::Tokio; - #[cfg(feature = "async-std")] + #[cfg(all( + feature = "async-std", + not(any(feature = "tokio_old", feature = "tokio")), + ))] type Executor = executor::AsyncStd; #[cfg(all( + feature = "smol", not(any( feature = "tokio_old", feature = "tokio", feature = "async-std" )), - feature = "smol" ))] type Executor = executor::Smol; -- cgit From 8d882d787e6b7fd7c2435f42f82933e2ed904edf Mon Sep 17 00:00:00 2001 From: GunpowderGuy Date: Thu, 21 Jan 2021 19:36:05 -0500 Subject: update example description at sandbox's documentation (#710) * Update sandbox.rs * Update sandbox.rs * format Co-authored-by: Diego Rosario --- src/sandbox.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/sandbox.rs b/src/sandbox.rs index dbaa02f1..b53fa1f2 100644 --- a/src/sandbox.rs +++ b/src/sandbox.rs @@ -17,8 +17,8 @@ use crate::{ /// # Examples /// [The repository has a bunch of examples] that use the [`Sandbox`] trait: /// -/// - [`bezier_tool`], a Paint-like tool for drawing Bézier curves using -/// [`lyon`]. +/// - [`bezier_tool`], a Paint-like tool for drawing Bézier curves using the +/// [`Canvas widget`]. /// - [`counter`], the classic counter example explained in [the overview]. /// - [`custom_widget`], a demonstration of how to build a custom widget that /// draws a circle. @@ -45,7 +45,7 @@ use crate::{ /// [`styling`]: https://github.com/hecrj/iced/tree/0.2/examples/styling /// [`svg`]: https://github.com/hecrj/iced/tree/0.2/examples/svg /// [`tour`]: https://github.com/hecrj/iced/tree/0.2/examples/tour -/// [`lyon`]: https://github.com/nical/lyon +/// [`Canvas widget`]: crate::widget::Canvas /// [the overview]: index.html#overview /// [`iced_wgpu`]: https://github.com/hecrj/iced/tree/0.2/wgpu /// [`Svg` widget]: crate::widget::Svg -- cgit From 14d900d8359a2b011e1f90fd54f7ad76b103b459 Mon Sep 17 00:00:00 2001 From: Taiki Endo Date: Fri, 29 Jan 2021 14:03:27 +0900 Subject: Make iced::Error Send + Sync --- src/error.rs | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/error.rs b/src/error.rs index 31b87d17..c8fa6636 100644 --- a/src/error.rs +++ b/src/error.rs @@ -9,7 +9,7 @@ pub enum Error { /// The application window could not be created. #[error("the application window could not be created")] - WindowCreationFailed(Box), + WindowCreationFailed(Box), /// A suitable graphics adapter or device could not be found. #[error("a suitable graphics adapter or device could not be found")] @@ -32,3 +32,14 @@ impl From for Error { } } } + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn assert_send_sync() { + fn _assert() {} + _assert::(); + } +} -- cgit From a19f89d3a6af2804f2ac4e30f6d639b56a9bebfd Mon Sep 17 00:00:00 2001 From: Yusuf Bera Ertan Date: Tue, 28 Jul 2020 18:07:46 +0300 Subject: feat(native): add Tooltip widget --- src/widget.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/widget.rs b/src/widget.rs index edd35d2d..eac50d57 100644 --- a/src/widget.rs +++ b/src/widget.rs @@ -17,7 +17,8 @@ mod platform { pub use crate::renderer::widget::{ button, checkbox, container, pane_grid, pick_list, progress_bar, radio, - rule, scrollable, slider, text_input, Column, Row, Space, Text, + rule, scrollable, slider, text_input, tooltip, Column, Row, Space, + Text, }; #[cfg(any(feature = "canvas", feature = "glow_canvas"))] @@ -52,7 +53,7 @@ mod platform { button::Button, checkbox::Checkbox, container::Container, image::Image, pane_grid::PaneGrid, pick_list::PickList, progress_bar::ProgressBar, radio::Radio, rule::Rule, scrollable::Scrollable, slider::Slider, - svg::Svg, text_input::TextInput, + svg::Svg, text_input::TextInput, tooltip::Tooltip, }; #[cfg(any(feature = "canvas", feature = "glow_canvas"))] -- cgit From ae517b9fa033ba75df5fc6ce766698fab22504fa Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Thu, 11 Mar 2021 03:38:20 +0100 Subject: Add `clipboard` argument to `Application::update` --- src/application.rs | 25 ++++++++++++++++++------- src/lib.rs | 5 +++-- src/sandbox.rs | 9 +++++++-- 3 files changed, 28 insertions(+), 11 deletions(-) (limited to 'src') diff --git a/src/application.rs b/src/application.rs index 3b690a7c..162fde84 100644 --- a/src/application.rs +++ b/src/application.rs @@ -1,5 +1,7 @@ use crate::window; -use crate::{Color, Command, Element, Executor, Settings, Subscription}; +use crate::{ + Clipboard, Color, Command, Element, Executor, Settings, Subscription, +}; /// An interactive cross-platform application. /// @@ -57,7 +59,7 @@ use crate::{Color, Command, Element, Executor, Settings, Subscription}; /// says "Hello, world!": /// /// ```no_run -/// use iced::{executor, Application, Command, Element, Settings, Text}; +/// use iced::{executor, Application, Clipboard, Command, Element, Settings, Text}; /// /// pub fn main() -> iced::Result { /// Hello::run(Settings::default()) @@ -78,7 +80,7 @@ use crate::{Color, Command, Element, Executor, Settings, Subscription}; /// String::from("A cool application") /// } /// -/// fn update(&mut self, _message: Self::Message) -> Command { +/// fn update(&mut self, _message: Self::Message, _clipboard: &mut Clipboard) -> Command { /// Command::none() /// } /// @@ -127,7 +129,11 @@ pub trait Application: Sized { /// this method. /// /// Any [`Command`] returned will be executed immediately in the background. - fn update(&mut self, message: Self::Message) -> Command; + fn update( + &mut self, + message: Self::Message, + clipboard: &mut Clipboard, + ) -> Command; /// Returns the event [`Subscription`] for the current state of the /// application. @@ -228,9 +234,14 @@ where { type Renderer = crate::renderer::Renderer; type Message = A::Message; - - fn update(&mut self, message: Self::Message) -> Command { - self.0.update(message) + type Clipboard = iced_winit::Clipboard; + + fn update( + &mut self, + message: Self::Message, + clipboard: &mut iced_winit::Clipboard, + ) -> Command { + self.0.update(message, clipboard) } fn view(&mut self) -> Element<'_, Self::Message> { diff --git a/src/lib.rs b/src/lib.rs index dedcac7a..812a50c1 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -245,6 +245,7 @@ pub use sandbox::Sandbox; pub use settings::Settings; pub use runtime::{ - futures, Align, Background, Color, Command, Font, HorizontalAlignment, - Length, Point, Rectangle, Size, Subscription, Vector, VerticalAlignment, + futures, Align, Background, Clipboard, Color, Command, Font, + HorizontalAlignment, Length, Point, Rectangle, Size, Subscription, Vector, + VerticalAlignment, }; diff --git a/src/sandbox.rs b/src/sandbox.rs index b53fa1f2..9dd17b7e 100644 --- a/src/sandbox.rs +++ b/src/sandbox.rs @@ -1,5 +1,6 @@ use crate::{ - Application, Color, Command, Element, Error, Settings, Subscription, + Application, Clipboard, Color, Command, Element, Error, Settings, + Subscription, }; /// A sandboxed [`Application`]. @@ -161,7 +162,11 @@ where T::title(self) } - fn update(&mut self, message: T::Message) -> Command { + fn update( + &mut self, + message: T::Message, + _clipboard: &mut Clipboard, + ) -> Command { T::update(self, message); Command::none() -- cgit From 7da3fb1b2225732c87aebb13a067fbdb30b0cf2d Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Thu, 11 Mar 2021 03:49:45 +0100 Subject: Implement stub `Clipboard` in `iced_web` We need to figure out browser permissions and use of unstable `web-sys` APIs --- src/application.rs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/application.rs b/src/application.rs index 162fde84..4c6d5b7f 100644 --- a/src/application.rs +++ b/src/application.rs @@ -305,8 +305,12 @@ where self.0.title() } - fn update(&mut self, message: Self::Message) -> Command { - self.0.update(message) + fn update( + &mut self, + message: Self::Message, + clipboard: &mut Clipboard, + ) -> Command { + self.0.update(message, clipboard) } fn subscription(&self) -> Subscription { -- cgit From 883c7e71ae699a29c23b8f95b7335d015e5a985d Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Thu, 25 Mar 2021 11:27:31 +0100 Subject: Introduce `internal_backend` to `iced_wgpu::Settings` --- src/application.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/application.rs b/src/application.rs index 4c6d5b7f..83ce900a 100644 --- a/src/application.rs +++ b/src/application.rs @@ -206,7 +206,7 @@ pub trait Application: Sized { } else { None }, - ..crate::renderer::Settings::default() + ..crate::renderer::Settings::from_env() }; Ok(crate::runtime::application::run::< -- cgit From 67db13ff7c727254182a8c4474bd962b205e2e99 Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Tue, 30 Mar 2021 21:44:19 +0200 Subject: Add support for graceful exits in `Application` - `Settings` now contains an `exit_on_close_request` field - `Application` has a new `should_exit` method --- src/application.rs | 11 +++++++++++ src/settings.rs | 15 +++++++++++---- 2 files changed, 22 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/application.rs b/src/application.rs index 83ce900a..7b7de6d4 100644 --- a/src/application.rs +++ b/src/application.rs @@ -184,6 +184,13 @@ pub trait Application: Sized { 1.0 } + /// Returns whether the [`Application`] should be terminated. + /// + /// By default, it returns `false`. + fn should_exit(&self) -> bool { + false + } + /// Runs the [`Application`]. /// /// On native platforms, this method will take control of the current thread @@ -284,6 +291,10 @@ where fn scale_factor(&self) -> f64 { self.0.scale_factor() } + + fn should_exit(&self) -> bool { + self.0.should_exit() + } } #[cfg(target_arch = "wasm32")] diff --git a/src/settings.rs b/src/settings.rs index c82a1354..2b32258d 100644 --- a/src/settings.rs +++ b/src/settings.rs @@ -25,6 +25,10 @@ pub struct Settings { /// The default value is 20. pub default_text_size: u16, + /// Whether the [`Application`] should exit when the user requests the + /// window to close (e.g. the user presses the close button). + pub exit_on_close_request: bool, + /// If set to true, the renderer will try to perform antialiasing for some /// primitives. /// @@ -46,10 +50,11 @@ impl Settings { Self { flags, - antialiasing: default_settings.antialiasing, + window: default_settings.window, default_font: default_settings.default_font, default_text_size: default_settings.default_text_size, - window: default_settings.window, + exit_on_close_request: default_settings.exit_on_close_request, + antialiasing: default_settings.antialiasing, } } } @@ -61,10 +66,11 @@ where fn default() -> Self { Self { flags: Default::default(), - antialiasing: Default::default(), + window: Default::default(), default_font: Default::default(), default_text_size: 20, - window: Default::default(), + exit_on_close_request: true, + antialiasing: false, } } } @@ -75,6 +81,7 @@ impl From> for iced_winit::Settings { iced_winit::Settings { window: settings.window.into(), flags: settings.flags, + exit_on_close_request: settings.exit_on_close_request, } } } -- cgit From cdab8f90fb525c509e0a15bb1d0b3d7213e176f3 Mon Sep 17 00:00:00 2001 From: Cory Forsstrom Date: Thu, 8 Apr 2021 12:58:08 -0700 Subject: add window visibility --- src/application.rs | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'src') diff --git a/src/application.rs b/src/application.rs index 7b7de6d4..317f9801 100644 --- a/src/application.rs +++ b/src/application.rs @@ -191,6 +191,13 @@ pub trait Application: Sized { false } + /// Returns whether the [`Application`] should be visible or not + /// + /// By default, it returns `true`. + fn visible(&self) -> bool { + true + } + /// Runs the [`Application`]. /// /// On native platforms, this method will take control of the current thread @@ -295,6 +302,10 @@ where fn should_exit(&self) -> bool { self.0.should_exit() } + + fn visible(&self) -> bool { + self.0.visible() + } } #[cfg(target_arch = "wasm32")] -- cgit From 84c0c9bc7ab858793183560739c8fd6087e22f6e Mon Sep 17 00:00:00 2001 From: Cory Forsstrom Date: Fri, 9 Apr 2021 09:00:29 -0700 Subject: use Mode::Hidden instead --- src/application.rs | 12 +----------- src/window/mode.rs | 3 +++ 2 files changed, 4 insertions(+), 11 deletions(-) (limited to 'src') diff --git a/src/application.rs b/src/application.rs index 317f9801..ee532e0b 100644 --- a/src/application.rs +++ b/src/application.rs @@ -191,13 +191,6 @@ pub trait Application: Sized { false } - /// Returns whether the [`Application`] should be visible or not - /// - /// By default, it returns `true`. - fn visible(&self) -> bool { - true - } - /// Runs the [`Application`]. /// /// On native platforms, this method will take control of the current thread @@ -284,6 +277,7 @@ where match self.0.mode() { window::Mode::Windowed => iced_winit::Mode::Windowed, window::Mode::Fullscreen => iced_winit::Mode::Fullscreen, + window::Mode::Hidden => iced_winit::Mode::Hidden, } } @@ -302,10 +296,6 @@ where fn should_exit(&self) -> bool { self.0.should_exit() } - - fn visible(&self) -> bool { - self.0.visible() - } } #[cfg(target_arch = "wasm32")] diff --git a/src/window/mode.rs b/src/window/mode.rs index 37464711..fdce8e23 100644 --- a/src/window/mode.rs +++ b/src/window/mode.rs @@ -6,4 +6,7 @@ pub enum Mode { /// The application takes the whole screen of its current monitor. Fullscreen, + + /// The application is hidden + Hidden, } -- cgit From 983aa1b3665c6b546700767d21d73de72372ddad Mon Sep 17 00:00:00 2001 From: Dispersia Date: Mon, 12 Apr 2021 23:23:47 -0700 Subject: Run cargo fmt --- src/window/icon.rs | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) (limited to 'src') diff --git a/src/window/icon.rs b/src/window/icon.rs index 0d27b00e..287538b1 100644 --- a/src/window/icon.rs +++ b/src/window/icon.rs @@ -97,23 +97,25 @@ impl fmt::Display for Error { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { match self { Error::InvalidData { byte_count } => { - write!(f, - "The provided RGBA data (with length {:?}) isn't divisble by \ + write!( + f, + "The provided RGBA data (with length {:?}) isn't divisble by \ 4. Therefore, it cannot be safely interpreted as 32bpp RGBA \ pixels.", - byte_count, - ) + byte_count, + ) } Error::DimensionsMismatch { width, height, pixel_count, } => { - write!(f, - "The number of RGBA pixels ({:?}) does not match the provided \ + write!( + f, + "The number of RGBA pixels ({:?}) does not match the provided \ dimensions ({:?}x{:?}).", - pixel_count, width, height, - ) + pixel_count, width, height, + ) } Error::OsError(e) => write!( f, -- cgit From 5f1b880521efb125f2f85137cc2e5ff1e66a5f42 Mon Sep 17 00:00:00 2001 From: Riccardo D'Ambrosio Date: Thu, 13 May 2021 11:04:09 -0400 Subject: Change examples to point to 0.3 examples, not 0.2 --- src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/lib.rs b/src/lib.rs index 812a50c1..6a029afd 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -30,7 +30,7 @@ //! [windowing shell]: https://github.com/hecrj/iced/tree/master/winit //! [`dodrio`]: https://github.com/fitzgen/dodrio //! [web runtime]: https://github.com/hecrj/iced/tree/master/web -//! [examples]: https://github.com/hecrj/iced/tree/0.2/examples +//! [examples]: https://github.com/hecrj/iced/tree/0.3/examples //! [repository]: https://github.com/hecrj/iced //! //! # Overview -- cgit From 52a185fbab728b85cf414d4997567f52ebc66205 Mon Sep 17 00:00:00 2001 From: Kaiden42 Date: Sat, 19 Sep 2020 18:44:27 +0200 Subject: Implement `Toggler` widget for iced_native --- src/widget.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/widget.rs b/src/widget.rs index eac50d57..db052106 100644 --- a/src/widget.rs +++ b/src/widget.rs @@ -17,8 +17,8 @@ mod platform { pub use crate::renderer::widget::{ button, checkbox, container, pane_grid, pick_list, progress_bar, radio, - rule, scrollable, slider, text_input, tooltip, Column, Row, Space, - Text, + rule, scrollable, slider, text_input, toggler, tooltip, Column, Row, + Space, Text, }; #[cfg(any(feature = "canvas", feature = "glow_canvas"))] @@ -53,7 +53,7 @@ mod platform { button::Button, checkbox::Checkbox, container::Container, image::Image, pane_grid::PaneGrid, pick_list::PickList, progress_bar::ProgressBar, radio::Radio, rule::Rule, scrollable::Scrollable, slider::Slider, - svg::Svg, text_input::TextInput, tooltip::Tooltip, + svg::Svg, text_input::TextInput, toggler::Toggler, tooltip::Tooltip, }; #[cfg(any(feature = "canvas", feature = "glow_canvas"))] -- cgit From 83d19689c80266874e0a26085f17a94fd3507e1e Mon Sep 17 00:00:00 2001 From: Yusuf Bera Ertan Date: Mon, 14 Jun 2021 21:01:37 +0300 Subject: docs: update all 0.2 github links to 0.3 --- src/application.rs | 18 +++++++++--------- src/sandbox.rs | 22 +++++++++++----------- 2 files changed, 20 insertions(+), 20 deletions(-) (limited to 'src') diff --git a/src/application.rs b/src/application.rs index ee532e0b..bda8558c 100644 --- a/src/application.rs +++ b/src/application.rs @@ -39,15 +39,15 @@ use crate::{ /// to listen to time. /// - [`todos`], a todos tracker inspired by [TodoMVC]. /// -/// [The repository has a bunch of examples]: https://github.com/hecrj/iced/tree/0.2/examples -/// [`clock`]: https://github.com/hecrj/iced/tree/0.2/examples/clock -/// [`download_progress`]: https://github.com/hecrj/iced/tree/0.2/examples/download_progress -/// [`events`]: https://github.com/hecrj/iced/tree/0.2/examples/events -/// [`game_of_life`]: https://github.com/hecrj/iced/tree/0.2/examples/game_of_life -/// [`pokedex`]: https://github.com/hecrj/iced/tree/0.2/examples/pokedex -/// [`solar_system`]: https://github.com/hecrj/iced/tree/0.2/examples/solar_system -/// [`stopwatch`]: https://github.com/hecrj/iced/tree/0.2/examples/stopwatch -/// [`todos`]: https://github.com/hecrj/iced/tree/0.2/examples/todos +/// [The repository has a bunch of examples]: https://github.com/hecrj/iced/tree/0.3/examples +/// [`clock`]: https://github.com/hecrj/iced/tree/0.3/examples/clock +/// [`download_progress`]: https://github.com/hecrj/iced/tree/0.3/examples/download_progress +/// [`events`]: https://github.com/hecrj/iced/tree/0.3/examples/events +/// [`game_of_life`]: https://github.com/hecrj/iced/tree/0.3/examples/game_of_life +/// [`pokedex`]: https://github.com/hecrj/iced/tree/0.3/examples/pokedex +/// [`solar_system`]: https://github.com/hecrj/iced/tree/0.3/examples/solar_system +/// [`stopwatch`]: https://github.com/hecrj/iced/tree/0.3/examples/stopwatch +/// [`todos`]: https://github.com/hecrj/iced/tree/0.3/examples/todos /// [`Sandbox`]: crate::Sandbox /// [`Canvas`]: crate::widget::Canvas /// [PokéAPI]: https://pokeapi.co/ diff --git a/src/sandbox.rs b/src/sandbox.rs index 9dd17b7e..10b05a92 100644 --- a/src/sandbox.rs +++ b/src/sandbox.rs @@ -36,19 +36,19 @@ use crate::{ /// - [`tour`], a simple UI tour that can run both on native platforms and the /// web! /// -/// [The repository has a bunch of examples]: https://github.com/hecrj/iced/tree/0.2/examples -/// [`bezier_tool`]: https://github.com/hecrj/iced/tree/0.2/examples/bezier_tool -/// [`counter`]: https://github.com/hecrj/iced/tree/0.2/examples/counter -/// [`custom_widget`]: https://github.com/hecrj/iced/tree/0.2/examples/custom_widget -/// [`geometry`]: https://github.com/hecrj/iced/tree/0.2/examples/geometry -/// [`pane_grid`]: https://github.com/hecrj/iced/tree/0.2/examples/pane_grid -/// [`progress_bar`]: https://github.com/hecrj/iced/tree/0.2/examples/progress_bar -/// [`styling`]: https://github.com/hecrj/iced/tree/0.2/examples/styling -/// [`svg`]: https://github.com/hecrj/iced/tree/0.2/examples/svg -/// [`tour`]: https://github.com/hecrj/iced/tree/0.2/examples/tour +/// [The repository has a bunch of examples]: https://github.com/hecrj/iced/tree/0.3/examples +/// [`bezier_tool`]: https://github.com/hecrj/iced/tree/0.3/examples/bezier_tool +/// [`counter`]: https://github.com/hecrj/iced/tree/0.3/examples/counter +/// [`custom_widget`]: https://github.com/hecrj/iced/tree/0.3/examples/custom_widget +/// [`geometry`]: https://github.com/hecrj/iced/tree/0.3/examples/geometry +/// [`pane_grid`]: https://github.com/hecrj/iced/tree/0.3/examples/pane_grid +/// [`progress_bar`]: https://github.com/hecrj/iced/tree/0.3/examples/progress_bar +/// [`styling`]: https://github.com/hecrj/iced/tree/0.3/examples/styling +/// [`svg`]: https://github.com/hecrj/iced/tree/0.3/examples/svg +/// [`tour`]: https://github.com/hecrj/iced/tree/0.3/examples/tour /// [`Canvas widget`]: crate::widget::Canvas /// [the overview]: index.html#overview -/// [`iced_wgpu`]: https://github.com/hecrj/iced/tree/0.2/wgpu +/// [`iced_wgpu`]: https://github.com/hecrj/iced/tree/0.3/wgpu /// [`Svg` widget]: crate::widget::Svg /// [Ghostscript Tiger]: https://commons.wikimedia.org/wiki/File:Ghostscript_Tiger.svg /// -- cgit From 5c45d36d1a8cfd92cd1a454a7f4deedcd4d13fe7 Mon Sep 17 00:00:00 2001 From: TimUntersberger Date: Fri, 25 Jun 2021 17:16:44 +0200 Subject: wip --- src/window/settings.rs | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'src') diff --git a/src/window/settings.rs b/src/window/settings.rs index 6b5d2985..981f0858 100644 --- a/src/window/settings.rs +++ b/src/window/settings.rs @@ -6,6 +6,11 @@ pub struct Settings { /// The initial size of the window. pub size: (u32, u32), + /// The initial position of the window. + /// + /// Note: this gets ignored on the web + pub position: (u32, u32), + /// The minimum size of the window. pub min_size: Option<(u32, u32)>, @@ -32,6 +37,7 @@ impl Default for Settings { fn default() -> Settings { Settings { size: (1024, 768), + position: (100, 100), min_size: None, max_size: None, resizable: true, @@ -48,6 +54,7 @@ impl From for iced_winit::settings::Window { fn from(settings: Settings) -> Self { Self { size: settings.size, + position: settings.position, min_size: settings.min_size, max_size: settings.max_size, resizable: settings.resizable, -- cgit From de79a01b88e1610d374ed06077ac78f3e10b9c3d Mon Sep 17 00:00:00 2001 From: TimUntersberger Date: Fri, 25 Jun 2021 18:03:18 +0200 Subject: done --- src/window/settings.rs | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/window/settings.rs b/src/window/settings.rs index 981f0858..0fecc3bb 100644 --- a/src/window/settings.rs +++ b/src/window/settings.rs @@ -8,8 +8,23 @@ pub struct Settings { /// The initial position of the window. /// + /// When the decorations of the window are enabled, Windows 10 will add some inivisble padding + /// to the window. This padding gets included in the position. So if you have decorations + /// enabled and want the window to be at 0,0 you would have to set the position to + /// -DPI_BORDER_X,-DPI_BORDER_Y. + /// + /// DPI_BORDER_X/DPI_BORDER_Y are the usual size of the padding, which changes based on the DPI of the display. + /// + /// On a 1920x1080 monitor you would have to set the position to -8,-2. + /// + /// For info on how you could implement positioning that supports all DPI monitors look at the + /// following WINAPI calls: + /// + /// * GetDpiForMonitor (with MDT_RAW_DPI) + /// * GetSystemMetricsForDpi (with SM_CXFRAME and SM_CYFRAME) + /// /// Note: this gets ignored on the web - pub position: (u32, u32), + pub position: (i32, i32), /// The minimum size of the window. pub min_size: Option<(u32, u32)>, -- cgit From 9fc5ad23edca93553137100d167de7b69e88f785 Mon Sep 17 00:00:00 2001 From: Richard Date: Mon, 5 Jul 2021 16:23:44 -0300 Subject: Initial menu implementation --- src/application.rs | 11 ++++++++++- src/lib.rs | 4 ++-- 2 files changed, 12 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/application.rs b/src/application.rs index bda8558c..b3dae1b3 100644 --- a/src/application.rs +++ b/src/application.rs @@ -1,6 +1,6 @@ use crate::window; use crate::{ - Clipboard, Color, Command, Element, Executor, Settings, Subscription, + Clipboard, Color, Command, Element, Executor, Menu, Settings, Subscription, }; /// An interactive cross-platform application. @@ -191,6 +191,11 @@ pub trait Application: Sized { false } + /// TODO + fn menu(&self) -> Menu { + Menu::new() + } + /// Runs the [`Application`]. /// /// On native platforms, this method will take control of the current thread @@ -296,6 +301,10 @@ where fn should_exit(&self) -> bool { self.0.should_exit() } + + fn menu(&self) -> Menu { + self.0.menu() + } } #[cfg(target_arch = "wasm32")] diff --git a/src/lib.rs b/src/lib.rs index 6a029afd..50952777 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -246,6 +246,6 @@ pub use settings::Settings; pub use runtime::{ futures, Align, Background, Clipboard, Color, Command, Font, - HorizontalAlignment, Length, Point, Rectangle, Size, Subscription, Vector, - VerticalAlignment, + HorizontalAlignment, Length, Menu, Point, Rectangle, Size, Subscription, + Vector, VerticalAlignment, }; -- cgit From 1428e9180ae9f4edbf22514bb74c5c7e9df9c712 Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Mon, 12 Jul 2021 21:38:54 +0200 Subject: Make `Menu` API a bit more functional --- src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/lib.rs b/src/lib.rs index 50952777..8cd6aa70 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -245,7 +245,7 @@ pub use sandbox::Sandbox; pub use settings::Settings; pub use runtime::{ - futures, Align, Background, Clipboard, Color, Command, Font, + futures, menu, Align, Background, Clipboard, Color, Command, Font, HorizontalAlignment, Length, Menu, Point, Rectangle, Size, Subscription, Vector, VerticalAlignment, }; -- cgit From 5df2a92f28be1d53d32d5b42a6645459b7d78efe Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Tue, 13 Jul 2021 21:15:07 +0200 Subject: Force `Application::Message` to implement `Clone` A `Message` should represent an application event (e.g. user interactions, command results, subscription results...). Therefore, it should always consist of pure, cloneable data. --- src/application.rs | 2 +- src/sandbox.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/application.rs b/src/application.rs index b3dae1b3..42c28f99 100644 --- a/src/application.rs +++ b/src/application.rs @@ -99,7 +99,7 @@ pub trait Application: Sized { type Executor: Executor; /// The type of __messages__ your [`Application`] will produce. - type Message: std::fmt::Debug + Send; + type Message: std::fmt::Debug + Clone + Send; /// The data needed to initialize your [`Application`]. type Flags; diff --git a/src/sandbox.rs b/src/sandbox.rs index 10b05a92..cb3cf624 100644 --- a/src/sandbox.rs +++ b/src/sandbox.rs @@ -88,7 +88,7 @@ use crate::{ /// ``` pub trait Sandbox { /// The type of __messages__ your [`Sandbox`] will produce. - type Message: std::fmt::Debug + Send; + type Message: std::fmt::Debug + Clone + Send; /// Initializes the [`Sandbox`]. /// -- cgit From c8ac77e4e99414746adedf38cf69ac8dcd1601a4 Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Mon, 19 Jul 2021 21:05:16 +0700 Subject: Write documentation for `menu` method in `Application` --- src/application.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/application.rs b/src/application.rs index 42c28f99..ae85c841 100644 --- a/src/application.rs +++ b/src/application.rs @@ -191,7 +191,9 @@ pub trait Application: Sized { false } - /// TODO + /// Returns the current system [`Menu`] of the [`Application`]. + /// + /// By default, it returns an empty [`Menu`]. fn menu(&self) -> Menu { Menu::new() } -- cgit From 6793a7e00dc96425ae720309182ec8b03c076111 Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Wed, 21 Jul 2021 18:15:32 +0700 Subject: Remove DPI from docs in `window::Settings::position` --- src/window/settings.rs | 21 +++++---------------- 1 file changed, 5 insertions(+), 16 deletions(-) (limited to 'src') diff --git a/src/window/settings.rs b/src/window/settings.rs index 0fecc3bb..59654edc 100644 --- a/src/window/settings.rs +++ b/src/window/settings.rs @@ -8,22 +8,11 @@ pub struct Settings { /// The initial position of the window. /// - /// When the decorations of the window are enabled, Windows 10 will add some inivisble padding - /// to the window. This padding gets included in the position. So if you have decorations - /// enabled and want the window to be at 0,0 you would have to set the position to - /// -DPI_BORDER_X,-DPI_BORDER_Y. - /// - /// DPI_BORDER_X/DPI_BORDER_Y are the usual size of the padding, which changes based on the DPI of the display. - /// - /// On a 1920x1080 monitor you would have to set the position to -8,-2. - /// - /// For info on how you could implement positioning that supports all DPI monitors look at the - /// following WINAPI calls: - /// - /// * GetDpiForMonitor (with MDT_RAW_DPI) - /// * GetSystemMetricsForDpi (with SM_CXFRAME and SM_CYFRAME) - /// - /// Note: this gets ignored on the web + /// When the decorations of the window are enabled, Windows 10 will add some + /// invisible padding to the window. This padding gets included in the + /// position. So if you have decorations enabled and want the window to be + /// at (0, 0) you would have to set the position to + /// `(PADDING_X, PADDING_Y)`. pub position: (i32, i32), /// The minimum size of the window. -- cgit From 72b3bf95de3f11812b1541fe2ffea76a515aee79 Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Wed, 21 Jul 2021 18:59:24 +0700 Subject: Improve `window::Position` API --- src/window.rs | 2 ++ src/window/position.rs | 33 +++++++++++++++++++++++++++++++++ src/window/settings.rs | 14 ++++---------- 3 files changed, 39 insertions(+), 10 deletions(-) create mode 100644 src/window/position.rs (limited to 'src') diff --git a/src/window.rs b/src/window.rs index a2883b62..7d441062 100644 --- a/src/window.rs +++ b/src/window.rs @@ -1,9 +1,11 @@ //! Configure the window of your application in native platforms. mod mode; +mod position; mod settings; pub mod icon; pub use icon::Icon; pub use mode::Mode; +pub use position::Position; pub use settings::Settings; diff --git a/src/window/position.rs b/src/window/position.rs new file mode 100644 index 00000000..8535ef6a --- /dev/null +++ b/src/window/position.rs @@ -0,0 +1,33 @@ +/// The position of a window in a given screen. +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +pub enum Position { + /// The platform-specific default position for a new window. + Default, + /// The window is completely centered on the screen. + Centered, + /// The window is positioned with specific coordinates: `(X, Y)`. + /// + /// When the decorations of the window are enabled, Windows 10 will add some + /// invisible padding to the window. This padding gets included in the + /// position. So if you have decorations enabled and want the window to be + /// at (0, 0) you would have to set the position to + /// `(PADDING_X, PADDING_Y)`. + Specific(i32, i32), +} + +impl Default for Position { + fn default() -> Self { + Self::Default + } +} + +#[cfg(not(target_arch = "wasm32"))] +impl From for iced_winit::Position { + fn from(position: Position) -> Self { + match position { + Position::Default => Self::Default, + Position::Centered => Self::Centered, + Position::Specific(x, y) => Self::Specific(x, y), + } + } +} diff --git a/src/window/settings.rs b/src/window/settings.rs index 59654edc..ec6c3071 100644 --- a/src/window/settings.rs +++ b/src/window/settings.rs @@ -1,4 +1,4 @@ -use crate::window::Icon; +use crate::window::{Icon, Position}; /// The window settings of an application. #[derive(Debug, Clone)] @@ -7,13 +7,7 @@ pub struct Settings { pub size: (u32, u32), /// The initial position of the window. - /// - /// When the decorations of the window are enabled, Windows 10 will add some - /// invisible padding to the window. This padding gets included in the - /// position. So if you have decorations enabled and want the window to be - /// at (0, 0) you would have to set the position to - /// `(PADDING_X, PADDING_Y)`. - pub position: (i32, i32), + pub position: Position, /// The minimum size of the window. pub min_size: Option<(u32, u32)>, @@ -41,7 +35,7 @@ impl Default for Settings { fn default() -> Settings { Settings { size: (1024, 768), - position: (100, 100), + position: Position::default(), min_size: None, max_size: None, resizable: true, @@ -58,7 +52,7 @@ impl From for iced_winit::settings::Window { fn from(settings: Settings) -> Self { Self { size: settings.size, - position: settings.position, + position: iced_winit::Position::from(settings.position), min_size: settings.min_size, max_size: settings.max_size, resizable: settings.resizable, -- cgit From 357a8a95c9820651110fe4d80d8d33a2678827c0 Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Thu, 22 Jul 2021 18:27:33 +0700 Subject: Introduce `text_multithreading` to `Settings` --- src/application.rs | 1 + src/settings.rs | 20 +++++++++++++++----- 2 files changed, 16 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/application.rs b/src/application.rs index ee532e0b..14bed2cb 100644 --- a/src/application.rs +++ b/src/application.rs @@ -208,6 +208,7 @@ pub trait Application: Sized { let renderer_settings = crate::renderer::Settings { default_font: settings.default_font, default_text_size: settings.default_text_size, + text_multithreading: settings.text_multithreading, antialiasing: if settings.antialiasing { Some(crate::renderer::settings::Antialiasing::MSAAx4) } else { diff --git a/src/settings.rs b/src/settings.rs index 2b32258d..480bf813 100644 --- a/src/settings.rs +++ b/src/settings.rs @@ -25,9 +25,11 @@ pub struct Settings { /// The default value is 20. pub default_text_size: u16, - /// Whether the [`Application`] should exit when the user requests the - /// window to close (e.g. the user presses the close button). - pub exit_on_close_request: bool, + /// If enabled, spread text workload in multiple threads when multiple cores + /// are available. + /// + /// By default, it is disabled. + pub text_multithreading: bool, /// If set to true, the renderer will try to perform antialiasing for some /// primitives. @@ -39,6 +41,12 @@ pub struct Settings { /// /// [`Canvas`]: crate::widget::Canvas pub antialiasing: bool, + + /// Whether the [`Application`] should exit when the user requests the + /// window to close (e.g. the user presses the close button). + /// + /// By default, it is enabled. + pub exit_on_close_request: bool, } impl Settings { @@ -53,8 +61,9 @@ impl Settings { window: default_settings.window, default_font: default_settings.default_font, default_text_size: default_settings.default_text_size, - exit_on_close_request: default_settings.exit_on_close_request, + text_multithreading: default_settings.text_multithreading, antialiasing: default_settings.antialiasing, + exit_on_close_request: default_settings.exit_on_close_request, } } } @@ -69,8 +78,9 @@ where window: Default::default(), default_font: Default::default(), default_text_size: 20, - exit_on_close_request: true, + text_multithreading: false, antialiasing: false, + exit_on_close_request: true, } } } -- cgit