summaryrefslogtreecommitdiffstats
path: root/winit/src/multi_window.rs
diff options
context:
space:
mode:
authorLibravatar Héctor Ramón Jiménez <hector@hecrj.dev>2024-03-06 21:27:03 +0100
committerLibravatar Héctor Ramón Jiménez <hector@hecrj.dev>2024-03-06 21:27:03 +0100
commit7c4bf70023a8092faad9630c2c87fbf41bd6ab76 (patch)
treea02aa7fa62276e4e9b870f4f88ba448c0a264e2b /winit/src/multi_window.rs
parent34e7c6593a9e0f56cee5db18b7258717cf6bc11b (diff)
downloadiced-7c4bf70023a8092faad9630c2c87fbf41bd6ab76.tar.gz
iced-7c4bf70023a8092faad9630c2c87fbf41bd6ab76.tar.bz2
iced-7c4bf70023a8092faad9630c2c87fbf41bd6ab76.zip
Simplify theming for `Application`
Diffstat (limited to 'winit/src/multi_window.rs')
-rw-r--r--winit/src/multi_window.rs21
1 files changed, 11 insertions, 10 deletions
diff --git a/winit/src/multi_window.rs b/winit/src/multi_window.rs
index 03066d6c..19951ed3 100644
--- a/winit/src/multi_window.rs
+++ b/winit/src/multi_window.rs
@@ -20,9 +20,10 @@ use crate::runtime::command::{self, Command};
use crate::runtime::multi_window::Program;
use crate::runtime::user_interface::{self, UserInterface};
use crate::runtime::Debug;
-use crate::style::application::StyleSheet;
use crate::{Clipboard, Error, Proxy, Settings};
+pub use crate::application::{default, Appearance, Style};
+
use std::collections::HashMap;
use std::mem::ManuallyDrop;
use std::sync::Arc;
@@ -41,7 +42,7 @@ use std::time::Instant;
/// can be toggled by pressing `F12`.
pub trait Application: Program
where
- Self::Theme: StyleSheet,
+ Style<Self::Theme>: Default,
{
/// The data needed to initialize your [`Application`].
type Flags;
@@ -66,8 +67,8 @@ where
fn theme(&self, window: window::Id) -> Self::Theme;
/// Returns the `Style` variation of the `Theme`.
- fn style(&self) -> <Self::Theme as StyleSheet>::Style {
- Default::default()
+ fn style(&self, theme: &Self::Theme) -> Appearance {
+ Style::default().resolve(theme)
}
/// Returns the event `Subscription` for the current state of the
@@ -108,7 +109,7 @@ where
A: Application + 'static,
E: Executor + 'static,
C: Compositor<Renderer = A::Renderer> + 'static,
- A::Theme: StyleSheet,
+ Style<A::Theme>: Default,
{
use winit::event_loop::EventLoopBuilder;
@@ -349,7 +350,7 @@ async fn run_instance<A, E, C>(
A: Application + 'static,
E: Executor + 'static,
C: Compositor<Renderer = A::Renderer> + 'static,
- A::Theme: StyleSheet,
+ Style<A::Theme>: Default,
{
use winit::event;
use winit::event_loop::ControlFlow;
@@ -819,7 +820,7 @@ fn build_user_interface<'a, A: Application>(
id: window::Id,
) -> UserInterface<'a, A::Message, A::Theme, A::Renderer>
where
- A::Theme: StyleSheet,
+ Style<A::Theme>: Default,
{
debug.view_started();
let view = application.view(id);
@@ -847,7 +848,7 @@ fn update<A: Application, C, E: Executor>(
ui_caches: &mut HashMap<window::Id, user_interface::Cache>,
) where
C: Compositor<Renderer = A::Renderer> + 'static,
- A::Theme: StyleSheet,
+ Style<A::Theme>: Default,
{
for message in messages.drain(..) {
debug.log_message(&message);
@@ -890,7 +891,7 @@ fn run_command<A, C, E>(
A: Application,
E: Executor,
C: Compositor<Renderer = A::Renderer> + 'static,
- A::Theme: StyleSheet,
+ Style<A::Theme>: Default,
{
use crate::runtime::clipboard;
use crate::runtime::system;
@@ -1216,8 +1217,8 @@ pub fn build_user_interfaces<'a, A: Application, C: Compositor>(
mut cached_user_interfaces: HashMap<window::Id, user_interface::Cache>,
) -> HashMap<window::Id, UserInterface<'a, A::Message, A::Theme, A::Renderer>>
where
- A::Theme: StyleSheet,
C: Compositor<Renderer = A::Renderer>,
+ Style<A::Theme>: Default,
{
cached_user_interfaces
.drain()