From 3514bd1535bc8421c746d981ca488883486de97f Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Fri, 8 Jul 2022 20:13:14 +0200 Subject: Add `theme::Application` styling support to `Sandbox` --- src/sandbox.rs | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) (limited to 'src/sandbox.rs') diff --git a/src/sandbox.rs b/src/sandbox.rs index f03562fb..3ca3fe8f 100644 --- a/src/sandbox.rs +++ b/src/sandbox.rs @@ -1,6 +1,5 @@ -use crate::{ - Application, Command, Element, Error, Settings, Subscription, Theme, -}; +use crate::theme::{self, Theme}; +use crate::{Application, Command, Element, Error, Settings, Subscription}; /// A sandboxed [`Application`]. /// @@ -121,6 +120,13 @@ pub trait Sandbox { Theme::default() } + /// Returns the current style variant of [`theme::Application`]. + /// + /// By default, it returns [`theme::Application::default`]. + fn style(&self) -> theme::Application { + theme::Application::default() + } + /// Returns the scale factor of the [`Sandbox`]. /// /// It can be used to dynamically control the size of the UI at runtime @@ -186,6 +192,10 @@ where T::theme(self) } + fn style(&self) -> theme::Application { + T::style(self) + } + fn subscription(&self) -> Subscription { Subscription::none() } -- cgit