Leverage DefaultStyle traits instead of Default

This commit is contained in:
Héctor Ramón Jiménez 2024-03-07 20:11:32 +01:00
parent 44f002f64a
commit 833538ee7f
No known key found for this signature in database
GPG key ID: 7CC46565708259A7
30 changed files with 393 additions and 437 deletions

View file

@ -11,7 +11,7 @@ use winit::window::Window;
/// The state of a multi-windowed [`Application`].
pub struct State<A: Application>
where
multi_window::Style<A::Theme>: Default,
A::Theme: multi_window::DefaultStyle,
{
title: String,
scale_factor: f64,
@ -25,7 +25,7 @@ where
impl<A: Application> Debug for State<A>
where
multi_window::Style<A::Theme>: Default,
A::Theme: multi_window::DefaultStyle,
{
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
f.debug_struct("multi_window::State")
@ -41,7 +41,7 @@ where
impl<A: Application> State<A>
where
multi_window::Style<A::Theme>: Default,
A::Theme: multi_window::DefaultStyle,
{
/// Creates a new [`State`] for the provided [`Application`]'s `window`.
pub fn new(

View file

@ -2,7 +2,7 @@ use crate::core::mouse;
use crate::core::window::Id;
use crate::core::{Point, Size};
use crate::graphics::Compositor;
use crate::multi_window::{Application, State, Style};
use crate::multi_window::{Application, DefaultStyle, State};
use std::collections::BTreeMap;
use std::sync::Arc;
@ -12,7 +12,7 @@ use winit::monitor::MonitorHandle;
pub struct WindowManager<A: Application, C: Compositor>
where
C: Compositor<Renderer = A::Renderer>,
Style<A::Theme>: Default,
A::Theme: DefaultStyle,
{
aliases: BTreeMap<winit::window::WindowId, Id>,
entries: BTreeMap<Id, Window<A, C>>,
@ -22,7 +22,7 @@ impl<A, C> WindowManager<A, C>
where
A: Application,
C: Compositor<Renderer = A::Renderer>,
Style<A::Theme>: Default,
A::Theme: DefaultStyle,
{
pub fn new() -> Self {
Self {
@ -108,7 +108,7 @@ impl<A, C> Default for WindowManager<A, C>
where
A: Application,
C: Compositor<Renderer = A::Renderer>,
Style<A::Theme>: Default,
A::Theme: DefaultStyle,
{
fn default() -> Self {
Self::new()
@ -120,7 +120,7 @@ pub struct Window<A, C>
where
A: Application,
C: Compositor<Renderer = A::Renderer>,
Style<A::Theme>: Default,
A::Theme: DefaultStyle,
{
pub raw: Arc<winit::window::Window>,
pub state: State<A>,
@ -135,7 +135,7 @@ impl<A, C> Window<A, C>
where
A: Application,
C: Compositor<Renderer = A::Renderer>,
Style<A::Theme>: Default,
A::Theme: DefaultStyle,
{
pub fn position(&self) -> Option<Point> {
self.raw