From 664251f3f5c7b76f69a97683af1468094bba887f Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Sat, 14 May 2022 01:47:55 +0200 Subject: Draft first-class `Theme` support RFC: https://github.com/iced-rs/rfcs/pull/6 --- examples/solar_system/src/main.rs | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'examples/solar_system/src/main.rs') diff --git a/examples/solar_system/src/main.rs b/examples/solar_system/src/main.rs index 12184dd1..308c8c39 100644 --- a/examples/solar_system/src/main.rs +++ b/examples/solar_system/src/main.rs @@ -6,10 +6,13 @@ //! Inspired by the example found in the MDN docs[1]. //! //! [1]: https://developer.mozilla.org/en-US/docs/Web/API/Canvas_API/Tutorial/Basic_animations#An_animated_solar_system +use iced::canvas::{self, Cursor, Path, Stroke}; +use iced::executor; +use iced::time; +use iced::window; use iced::{ - canvas::{self, Cursor, Path, Stroke}, - executor, time, window, Application, Canvas, Color, Command, Element, - Length, Point, Rectangle, Settings, Size, Subscription, Vector, + Application, Canvas, Color, Command, Element, Length, Point, Rectangle, + Settings, Size, Subscription, Theme, Vector, }; use std::time::Instant; @@ -31,8 +34,9 @@ enum Message { } impl Application for SolarSystem { - type Executor = executor::Default; type Message = Message; + type Theme = Theme; + type Executor = executor::Default; type Flags = (); fn new(_flags: ()) -> (Self, Command) { -- cgit From fc13bb3d65c85cfad9f231c0776d3a45f4fbf480 Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Tue, 7 Jun 2022 05:24:43 +0200 Subject: Implement theme styling for `Canvas` --- examples/solar_system/src/main.rs | 1 + 1 file changed, 1 insertion(+) (limited to 'examples/solar_system/src/main.rs') diff --git a/examples/solar_system/src/main.rs b/examples/solar_system/src/main.rs index 308c8c39..5f6c309d 100644 --- a/examples/solar_system/src/main.rs +++ b/examples/solar_system/src/main.rs @@ -135,6 +135,7 @@ impl State { impl canvas::Program for State { fn draw( &self, + _theme: &Theme, bounds: Rectangle, _cursor: Cursor, ) -> Vec { -- cgit From bb07d017e8c8e43ac74f66bf649643bebdc5f71d Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Fri, 8 Jul 2022 20:07:33 +0200 Subject: Add `Style` variant support to `application::StyleSheet` --- examples/solar_system/src/main.rs | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'examples/solar_system/src/main.rs') diff --git a/examples/solar_system/src/main.rs b/examples/solar_system/src/main.rs index 7e0e06b0..cee9a02f 100644 --- a/examples/solar_system/src/main.rs +++ b/examples/solar_system/src/main.rs @@ -6,13 +6,15 @@ //! Inspired by the example found in the MDN docs[1]. //! //! [1]: https://developer.mozilla.org/en-US/docs/Web/API/Canvas_API/Tutorial/Basic_animations#An_animated_solar_system +use iced::application; use iced::canvas::{self, Cursor, Path, Stroke}; use iced::executor; +use iced::theme::{self, Theme}; use iced::time; use iced::window; use iced::{ Application, Canvas, Color, Command, Element, Length, Point, Rectangle, - Settings, Size, Subscription, Theme, Vector, + Settings, Size, Subscription, Vector, }; use std::time::Instant; @@ -77,6 +79,13 @@ impl Application for SolarSystem { fn theme(&self) -> Theme { Theme::Dark } + + fn style(&self) -> theme::Application { + theme::Application::Custom(|_theme| application::Appearance { + background_color: Color::BLACK, + text_color: Color::WHITE, + }) + } } #[derive(Debug)] -- cgit