Use f32 for scale_factor

This commit is contained in:
Héctor Ramón Jiménez 2025-09-02 23:29:22 +02:00
parent ad0e4c53cf
commit 74b792b608
No known key found for this signature in database
GPG key ID: 7CC46565708259A7
14 changed files with 56 additions and 51 deletions

View file

@ -94,7 +94,7 @@ pub trait Program: Sized {
theme::Base::base(theme)
}
fn scale_factor(&self, _state: &Self::State, _window: window::Id) -> f64 {
fn scale_factor(&self, _state: &Self::State, _window: window::Id) -> f32 {
1.0
}
}
@ -171,7 +171,7 @@ pub fn with_title<P: Program>(
self.program.style(state, theme)
}
fn scale_factor(&self, state: &Self::State, window: window::Id) -> f64 {
fn scale_factor(&self, state: &Self::State, window: window::Id) -> f32 {
self.program.scale_factor(state, window)
}
}
@ -250,7 +250,7 @@ pub fn with_subscription<P: Program>(
self.program.style(state, theme)
}
fn scale_factor(&self, state: &Self::State, window: window::Id) -> f64 {
fn scale_factor(&self, state: &Self::State, window: window::Id) -> f32 {
self.program.scale_factor(state, window)
}
}
@ -332,7 +332,7 @@ pub fn with_theme<P: Program>(
self.program.style(state, theme)
}
fn scale_factor(&self, state: &Self::State, window: window::Id) -> f64 {
fn scale_factor(&self, state: &Self::State, window: window::Id) -> f32 {
self.program.scale_factor(state, window)
}
}
@ -411,7 +411,7 @@ pub fn with_style<P: Program>(
self.program.theme(state, window)
}
fn scale_factor(&self, state: &Self::State, window: window::Id) -> f64 {
fn scale_factor(&self, state: &Self::State, window: window::Id) -> f32 {
self.program.scale_factor(state, window)
}
}
@ -422,7 +422,7 @@ pub fn with_style<P: Program>(
/// Decorates a [`Program`] with the given scale factor function.
pub fn with_scale_factor<P: Program>(
program: P,
f: impl Fn(&P::State, window::Id) -> f64,
f: impl Fn(&P::State, window::Id) -> f32,
) -> impl Program<State = P::State, Message = P::Message, Theme = P::Theme> {
struct WithScaleFactor<P, F> {
program: P,
@ -431,7 +431,7 @@ pub fn with_scale_factor<P: Program>(
impl<P: Program, F> Program for WithScaleFactor<P, F>
where
F: Fn(&P::State, window::Id) -> f64,
F: Fn(&P::State, window::Id) -> f32,
{
type State = P::State;
type Message = P::Message;
@ -490,7 +490,7 @@ pub fn with_scale_factor<P: Program>(
self.program.style(state, theme)
}
fn scale_factor(&self, state: &Self::State, window: window::Id) -> f64 {
fn scale_factor(&self, state: &Self::State, window: window::Id) -> f32 {
(self.scale_factor)(state, window)
}
}
@ -573,7 +573,7 @@ pub fn with_executor<P: Program, E: Executor>(
self.program.style(state, theme)
}
fn scale_factor(&self, state: &Self::State, window: window::Id) -> f64 {
fn scale_factor(&self, state: &Self::State, window: window::Id) -> f32 {
self.program.scale_factor(state, window)
}
}
@ -638,7 +638,7 @@ impl<P: Program> Instance<P> {
}
/// Returns the current scale factor of the [`Instance`].
pub fn scale_factor(&self, window: window::Id) -> f64 {
pub fn scale_factor(&self, window: window::Id) -> f32 {
self.program.scale_factor(&self.state, window)
}
}