From b63e4d66d2bb07df921eb76074ce8ed36ef94293 Mon Sep 17 00:00:00 2001 From: Jonathan Johnson Date: Wed, 22 Nov 2023 18:53:41 -0800 Subject: [PATCH] Bug fixes --- src/context.rs | 5 +++-- src/styles.rs | 12 ++++++++++++ src/widgets/label.rs | 1 + src/widgets/scroll.rs | 2 +- 4 files changed, 17 insertions(+), 3 deletions(-) diff --git a/src/context.rs b/src/context.rs index 04a0189..c898c88 100644 --- a/src/context.rs +++ b/src/context.rs @@ -17,8 +17,8 @@ use kludgine::{Color, Kludgine}; use crate::context::sealed::WindowHandle; use crate::graphics::Graphics; use crate::styles::components::{ - CornerRadius, FontFamily, FontStyle, FontWeight, HighlightColor, LayoutOrder, TextSize, - WidgetBackground, + CornerRadius, FontFamily, FontStyle, FontWeight, HighlightColor, LayoutOrder, LineHeight, + TextSize, WidgetBackground, }; use crate::styles::{ComponentDefinition, Styles, Theme, ThemePair}; use crate::utils::IgnorePoison; @@ -618,6 +618,7 @@ impl<'context, 'window, 'clip, 'gfx, 'pass> GraphicsContext<'context, 'window, ' self.gfx .set_available_font_family(&self.widget.get(&FontFamily)); self.gfx.set_font_size(self.widget.get(&TextSize)); + self.gfx.set_line_height(self.widget.get(&LineHeight)); self.gfx.set_font_style(self.widget.get(&FontStyle)); self.gfx.set_font_weight(self.widget.get(&FontWeight)); } diff --git a/src/styles.rs b/src/styles.rs index f3383d9..186b3ac 100644 --- a/src/styles.rs +++ b/src/styles.rs @@ -1099,6 +1099,18 @@ impl IntoValue> for Lp { } } +impl IntoValue for Px { + fn into_value(self) -> Value { + Dimension::from(self).into_value() + } +} + +impl IntoValue for Lp { + fn into_value(self) -> Value { + Dimension::from(self).into_value() + } +} + /// A set of light and dark [`Theme`]s. #[derive(Clone, Debug)] pub struct ThemePair { diff --git a/src/widgets/label.rs b/src/widgets/label.rs index 7d040f4..8c37b9b 100644 --- a/src/widgets/label.rs +++ b/src/widgets/label.rs @@ -43,6 +43,7 @@ impl Label { || ((*prepared_width < width || prepared.size.width <= width) && prepared.line_height == prepared.size.height)) => {} _ => { + context.apply_current_font_settings(); let measured = self.text.map(|text| { context .gfx diff --git a/src/widgets/scroll.rs b/src/widgets/scroll.rs index 08f1ed3..d19f986 100644 --- a/src/widgets/scroll.rs +++ b/src/widgets/scroll.rs @@ -261,7 +261,7 @@ impl Widget for Scroll { MouseScrollDelta::LineDelta(x, y) => Point::new(x, y) * self.line_height.into_float(), MouseScrollDelta::PixelDelta(px) => Point::new(px.x.cast(), px.y.cast()), }; - + context.invalidate_when_changed(&self.scroll); let mut scroll = self.scroll.lock(); let old_scroll = *scroll; let new_scroll = Self::constrained_scroll(*scroll + amount.cast(), self.max_scroll.get());