diff --git a/core/src/renderer.rs b/core/src/renderer.rs index 7c73d2e431..f6acc01937 100644 --- a/core/src/renderer.rs +++ b/core/src/renderer.rs @@ -65,12 +65,15 @@ pub struct Quad { pub struct Style { /// The text color pub text_color: Color, + /// The scale factor + pub scale_factor: f64, } impl Default for Style { fn default() -> Self { Style { text_color: Color::BLACK, + scale_factor: 1.0, } } } diff --git a/examples/integration/src/controls.rs b/examples/integration/src/controls.rs index 14e53edeee..fe26851b09 100644 --- a/examples/integration/src/controls.rs +++ b/examples/integration/src/controls.rs @@ -1,3 +1,4 @@ +use iced_wgpu::core::window::Id; use iced_wgpu::Renderer; use iced_widget::{slider, text_input, Column, Row, Text}; use iced_winit::core::{Alignment, Color, Element, Length}; @@ -45,7 +46,7 @@ impl Program for Controls { Command::none() } - fn view(&self) -> Element> { + fn view(&self, _: Id) -> Element> { let background_color = self.background_color; let text = &self.text; diff --git a/examples/integration/src/main.rs b/examples/integration/src/main.rs index 342d4c699e..622338677b 100644 --- a/examples/integration/src/main.rs +++ b/examples/integration/src/main.rs @@ -4,6 +4,7 @@ mod scene; use controls::Controls; use scene::Scene; +use iced_wgpu::core::window::Id; use iced_wgpu::graphics::Viewport; use iced_wgpu::{wgpu, Backend, Renderer, Settings}; use iced_winit::core::mouse; @@ -151,6 +152,7 @@ pub fn main() -> Result<(), Box> { )); let mut state = program::State::new( + Id(0), controls, viewport.logical_size(), &mut renderer, @@ -194,6 +196,7 @@ pub fn main() -> Result<(), Box> { if !state.is_queue_empty() { // We update iced let _ = state.update( + Id(0), viewport.logical_size(), cursor_position .map(|p| { @@ -208,6 +211,7 @@ pub fn main() -> Result<(), Box> { &Theme::Dark, &renderer::Style { text_color: Color::WHITE, + scale_factor: viewport.scale_factor(), }, &mut clipboard, &mut debug, diff --git a/sctk/src/application.rs b/sctk/src/application.rs index c230c9137b..34d1c70f2e 100644 --- a/sctk/src/application.rs +++ b/sctk/src/application.rs @@ -855,6 +855,7 @@ where state.theme(), &Style { text_color: state.text_color(), + scale_factor: state.scale_factor(), }, state.cursor(), ); @@ -1306,6 +1307,7 @@ where state.theme(), &Style { text_color: state.text_color(), + scale_factor: state.scale_factor(), }, state.cursor(), ); diff --git a/widget/src/button.rs b/widget/src/button.rs index c2c7dac988..d39847c832 100644 --- a/widget/src/button.rs +++ b/widget/src/button.rs @@ -293,7 +293,7 @@ where tree: &Tree, renderer: &mut Renderer, theme: &Renderer::Theme, - _style: &renderer::Style, + renderer_style: &renderer::Style, layout: Layout<'_>, cursor: mouse::Cursor, _viewport: &Rectangle, @@ -317,6 +317,7 @@ where theme, &renderer::Style { text_color: styling.text_color, + scale_factor: renderer_style.scale_factor, }, content_layout, cursor, diff --git a/widget/src/container.rs b/widget/src/container.rs index b99d7c45a4..c9f27bab12 100644 --- a/widget/src/container.rs +++ b/widget/src/container.rs @@ -256,6 +256,7 @@ where text_color: style .text_color .unwrap_or(renderer_style.text_color), + scale_factor: renderer_style.scale_factor, }, layout.children().next().unwrap(), cursor, diff --git a/widget/src/pane_grid/title_bar.rs b/widget/src/pane_grid/title_bar.rs index c496432aeb..22114dac0b 100644 --- a/widget/src/pane_grid/title_bar.rs +++ b/widget/src/pane_grid/title_bar.rs @@ -134,6 +134,7 @@ where let style = theme.appearance(&self.style); let inherited_style = renderer::Style { text_color: style.text_color.unwrap_or(inherited_style.text_color), + scale_factor: inherited_style.scale_factor, }; container::draw_background(renderer, &style, bounds); diff --git a/widget/src/tooltip.rs b/widget/src/tooltip.rs index dc70588706..ea07a3c2c0 100644 --- a/widget/src/tooltip.rs +++ b/widget/src/tooltip.rs @@ -421,6 +421,7 @@ where let defaults = renderer::Style { text_color: style.text_color.unwrap_or(inherited_style.text_color), + scale_factor: inherited_style.scale_factor, }; Widget::<(), Renderer>::draw( diff --git a/winit/src/application.rs b/winit/src/application.rs index f0ff5703a4..edc1ef29a1 100644 --- a/winit/src/application.rs +++ b/winit/src/application.rs @@ -507,6 +507,7 @@ async fn run_instance( state.theme(), &renderer::Style { text_color: state.text_color(), + scale_factor: state.scale_factor(), }, state.cursor(), ); @@ -671,6 +672,7 @@ async fn run_instance( state.theme(), &renderer::Style { text_color: state.text_color(), + scale_factor: state.scale_factor(), }, state.cursor(), );