From abd3ce46a7f53e037fbe46e44076e26e8ba0fb84 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?John=20K=C3=A5re=20Alsaker?= Date: Sat, 28 Oct 2023 17:52:31 +0200 Subject: [PATCH] Add user defined style properties --- src/context.rs | 79 ++++++++-------- src/style.rs | 210 ++++++++++++++++++++++++++++++++++++++++--- src/view.rs | 29 +++--- src/views/scroll.rs | 51 +++++------ src/window_handle.rs | 2 - 5 files changed, 283 insertions(+), 88 deletions(-) diff --git a/src/context.rs b/src/context.rs index 8215a159..1c7458f0 100644 --- a/src/context.rs +++ b/src/context.rs @@ -1,6 +1,7 @@ use std::{ collections::{HashMap, HashSet}, ops::{Deref, DerefMut}, + rc::Rc, time::Duration, }; @@ -23,7 +24,7 @@ use crate::{ menu::Menu, pointer::PointerInputEvent, responsive::{GridBreakpoints, ScreenSize, ScreenSizeBp}, - style::{ComputedStyle, CursorStyle, Style, StyleSelector}, + style::{ComputedStyle, CursorStyle, Style, StyleMap, StyleProp, StyleSelector}, }; pub type EventCallback = dyn Fn(&Event) -> bool; @@ -666,16 +667,42 @@ pub struct InteractionState { pub(crate) using_keyboard_navigation: bool, } +pub(crate) struct StyleCx { + pub(crate) current: Rc, + saved: Vec>, +} + +impl StyleCx { + fn new() -> Self { + Self { + current: Default::default(), + saved: Default::default(), + } + } + + pub(crate) fn clear(&mut self) { + self.current = Default::default(); + self.saved.clear(); + } + + pub fn save(&mut self) { + self.saved.push(self.current.clone()); + } + + pub fn restore(&mut self) { + self.current = self.saved.pop().unwrap_or_default(); + } +} + /// Holds current layout state for given position in the tree. /// You'll use this in the `View::layout` implementation to call `layout_node` on children and to access any font pub struct LayoutCx<'a> { app_state: &'a mut AppState, pub(crate) viewport: Option, pub(crate) color: Option, - pub(crate) scroll_bar_color: Option, + pub(crate) style: StyleCx, pub(crate) scroll_bar_hover_color: Option, pub(crate) scroll_bar_drag_color: Option, - pub(crate) scroll_bar_bg_active_color: Option, pub(crate) scroll_bar_rounded: Option, pub(crate) scroll_bar_thickness: Option, pub(crate) scroll_bar_edge_width: Option, @@ -687,10 +714,8 @@ pub struct LayoutCx<'a> { pub(crate) window_origin: Point, pub(crate) saved_viewports: Vec>, pub(crate) saved_colors: Vec>, - pub(crate) saved_scroll_bar_colors: Vec>, pub(crate) saved_scroll_bar_hover_colors: Vec>, pub(crate) saved_scroll_bar_drag_colors: Vec>, - pub(crate) saved_scroll_bar_bg_active_colors: Vec>, pub(crate) saved_scroll_bar_roundeds: Vec>, pub(crate) saved_scroll_bar_thicknesses: Vec>, pub(crate) saved_scroll_bar_edge_widths: Vec>, @@ -714,6 +739,7 @@ impl<'a> LayoutCx<'a> { font_style: None, line_height: None, window_origin: Point::ZERO, + style: StyleCx::new(), saved_viewports: Vec::new(), saved_colors: Vec::new(), saved_font_sizes: Vec::new(), @@ -722,29 +748,32 @@ impl<'a> LayoutCx<'a> { saved_font_styles: Vec::new(), saved_line_heights: Vec::new(), saved_window_origins: Vec::new(), - scroll_bar_color: None, scroll_bar_hover_color: None, scroll_bar_drag_color: None, - scroll_bar_bg_active_color: None, scroll_bar_rounded: None, scroll_bar_thickness: None, scroll_bar_edge_width: None, - saved_scroll_bar_colors: Vec::new(), saved_scroll_bar_hover_colors: Vec::new(), saved_scroll_bar_drag_colors: Vec::new(), - saved_scroll_bar_bg_active_colors: Vec::new(), saved_scroll_bar_roundeds: Vec::new(), saved_scroll_bar_thicknesses: Vec::new(), saved_scroll_bar_edge_widths: Vec::new(), } } + pub fn get_prop(&self, _prop: P) -> Option { + self.style + .current + .map + .get(&P::prop_ref()) + .and_then(|v| v.downcast_ref().cloned()) + } + pub(crate) fn clear(&mut self) { + self.style.clear(); self.viewport = None; - self.scroll_bar_color = None; self.scroll_bar_hover_color = None; self.scroll_bar_drag_color = None; - self.scroll_bar_bg_active_color = None; self.scroll_bar_rounded = None; self.scroll_bar_thickness = None; self.scroll_bar_edge_width = None; @@ -752,10 +781,8 @@ impl<'a> LayoutCx<'a> { self.window_origin = Point::ZERO; self.saved_colors.clear(); self.saved_viewports.clear(); - self.saved_scroll_bar_colors.clear(); self.saved_scroll_bar_hover_colors.clear(); self.saved_scroll_bar_drag_colors.clear(); - self.saved_scroll_bar_bg_active_colors.clear(); self.saved_scroll_bar_roundeds.clear(); self.saved_scroll_bar_thicknesses.clear(); self.saved_scroll_bar_edge_widths.clear(); @@ -768,15 +795,13 @@ impl<'a> LayoutCx<'a> { } pub fn save(&mut self) { + self.style.save(); self.saved_viewports.push(self.viewport); self.saved_colors.push(self.color); - self.saved_scroll_bar_colors.push(self.scroll_bar_color); self.saved_scroll_bar_hover_colors .push(self.scroll_bar_hover_color); self.saved_scroll_bar_drag_colors .push(self.scroll_bar_drag_color); - self.saved_scroll_bar_bg_active_colors - .push(self.scroll_bar_bg_active_color); self.saved_scroll_bar_roundeds.push(self.scroll_bar_rounded); self.saved_scroll_bar_thicknesses .push(self.scroll_bar_thickness); @@ -791,15 +816,11 @@ impl<'a> LayoutCx<'a> { } pub fn restore(&mut self) { + self.style.restore(); self.viewport = self.saved_viewports.pop().unwrap_or_default(); self.color = self.saved_colors.pop().unwrap_or_default(); - self.scroll_bar_color = self.saved_scroll_bar_colors.pop().unwrap_or_default(); self.scroll_bar_hover_color = self.saved_scroll_bar_hover_colors.pop().unwrap_or_default(); self.scroll_bar_drag_color = self.saved_scroll_bar_drag_colors.pop().unwrap_or_default(); - self.scroll_bar_bg_active_color = self - .saved_scroll_bar_bg_active_colors - .pop() - .unwrap_or_default(); self.scroll_bar_rounded = self.saved_scroll_bar_roundeds.pop().unwrap_or_default(); self.scroll_bar_thickness = self.saved_scroll_bar_thicknesses.pop().unwrap_or_default(); self.scroll_bar_edge_width = self.saved_scroll_bar_edge_widths.pop().unwrap_or_default(); @@ -819,10 +840,6 @@ impl<'a> LayoutCx<'a> { self.app_state } - pub fn current_scroll_bar_color(&self) -> Option { - self.scroll_bar_color - } - pub fn current_scroll_bar_hover_color(&self) -> Option { self.scroll_bar_hover_color } @@ -831,10 +848,6 @@ impl<'a> LayoutCx<'a> { self.scroll_bar_drag_color } - pub fn current_scroll_bar_bg_active_color(&self) -> Option { - self.scroll_bar_bg_active_color - } - pub fn current_scroll_bar_rounded(&self) -> Option { self.scroll_bar_rounded } @@ -945,7 +958,6 @@ pub struct PaintCx<'a> { pub(crate) transform: Affine, pub(crate) clip: Option, pub(crate) color: Option, - pub(crate) scroll_bar_color: Option, pub(crate) scroll_bar_rounded: Option, pub(crate) scroll_bar_thickness: Option, pub(crate) scroll_bar_edge_width: Option, @@ -958,7 +970,6 @@ pub struct PaintCx<'a> { pub(crate) saved_transforms: Vec, pub(crate) saved_clips: Vec>, pub(crate) saved_colors: Vec>, - pub(crate) saved_scroll_bar_colors: Vec>, pub(crate) saved_scroll_bar_roundeds: Vec>, pub(crate) saved_scroll_bar_thicknesses: Vec>, pub(crate) saved_scroll_bar_edge_widths: Vec>, @@ -975,7 +986,6 @@ impl<'a> PaintCx<'a> { self.saved_transforms.push(self.transform); self.saved_clips.push(self.clip); self.saved_colors.push(self.color); - self.saved_scroll_bar_colors.push(self.scroll_bar_color); self.saved_scroll_bar_roundeds.push(self.scroll_bar_rounded); self.saved_scroll_bar_thicknesses .push(self.scroll_bar_thickness); @@ -993,7 +1003,6 @@ impl<'a> PaintCx<'a> { self.transform = self.saved_transforms.pop().unwrap_or_default(); self.clip = self.saved_clips.pop().unwrap_or_default(); self.color = self.saved_colors.pop().unwrap_or_default(); - self.scroll_bar_color = self.saved_scroll_bar_colors.pop().unwrap_or_default(); self.scroll_bar_rounded = self.saved_scroll_bar_roundeds.pop().unwrap_or_default(); self.scroll_bar_thickness = self.saved_scroll_bar_thicknesses.pop().unwrap_or_default(); self.scroll_bar_edge_width = self.saved_scroll_bar_edge_widths.pop().unwrap_or_default(); @@ -1020,10 +1029,6 @@ impl<'a> PaintCx<'a> { self.color } - pub fn current_scroll_bar_color(&self) -> Option { - self.scroll_bar_color - } - pub fn current_scroll_bar_rounded(&self) -> Option { self.scroll_bar_rounded } diff --git a/src/style.rs b/src/style.rs index 6db84ff4..6666338b 100644 --- a/src/style.rs +++ b/src/style.rs @@ -27,6 +27,12 @@ use floem_renderer::cosmic_text::{LineHeightValue, Style as FontStyle, Weight}; use peniko::Color; +use std::any::Any; +use std::collections::HashMap; +use std::hash::Hash; +use std::hash::Hasher; +use std::ptr; +use std::rc::Rc; pub use taffy::style::{ AlignContent, AlignItems, Dimension, Display, FlexDirection, JustifyContent, Position, }; @@ -36,7 +42,164 @@ use taffy::{ style::{FlexWrap, LengthPercentage, Style as TaffyStyle}, }; +use crate::context::LayoutCx; use crate::unit::{Px, PxPct, PxPctAuto, UnitExt}; +use crate::views::scroll_bar_color; + +pub trait StyleProp: Default + Copy + 'static { + type Type: Clone; + fn prop_ref() -> StylePropRef; + fn default_value() -> Self::Type; +} + +#[derive(Debug)] +pub struct StylePropInfo { + #[allow(dead_code)] + pub(crate) name: &'static str, + pub(crate) inherited: bool, +} + +impl StylePropInfo { + pub const fn new(name: &'static str, inherited: bool) -> Self { + StylePropInfo { name, inherited } + } +} + +#[derive(Copy, Clone, Debug)] +pub struct StylePropRef { + pub info: &'static StylePropInfo, +} +impl PartialEq for StylePropRef { + fn eq(&self, other: &Self) -> bool { + ptr::eq(self.info, other.info) + } +} +impl Hash for StylePropRef { + fn hash(&self, state: &mut H) { + state.write_usize(self.info as *const _ as usize) + } +} +impl Eq for StylePropRef {} + +pub trait StylePropReader { + type Type: Clone; + fn read(&mut self, cx: &LayoutCx); + fn get(&self) -> Self::Type; + fn new() -> Self; +} + +pub struct DefaultReader { + value: P::Type, +} + +impl StylePropReader for DefaultReader

{ + type Type = P::Type; + fn read(&mut self, cx: &LayoutCx) { + self.value = cx + .get_prop(P::default()) + .unwrap_or_else(|| P::default_value()); + } + fn get(&self) -> Self::Type { + self.value.clone() + } + fn new() -> Self { + Self { + value: P::default_value(), + } + } +} + +pub struct OptionReader { + value: Option, +} + +impl StylePropReader for OptionReader

{ + type Type = Option; + fn read(&mut self, cx: &LayoutCx) { + self.value = cx.get_prop(P::default()); + } + fn get(&self) -> Self::Type { + self.value.clone() + } + fn new() -> Self { + Self { value: None } + } +} + +#[macro_export] +macro_rules! prop { + ($v:vis $name:ident: $ty:ty { inherited: $inherited:expr } + = $default:expr + ) => { + #[derive(Default, Copy, Clone)] + #[allow(non_camel_case_types)] + $v struct $name; + impl $crate::style::StyleProp for $name{ + type Type = $ty; + fn prop_ref() -> $crate::style::StylePropRef { + static INFO: $crate::style::StylePropInfo = $crate::style::StylePropInfo::new( + stringify!($name), + $inherited, + ); + $crate::style::StylePropRef { info: &INFO } + } + fn default_value() -> Self::Type { + $default + } + } + + } +} + +#[macro_export] +macro_rules! prop_extracter { + ( + $vis:vis $name:ident { + $($prop_vis:vis $prop:ident $(: $reader:ty)?),* + $(,)? + } + ) => { + #[allow(non_snake_case)] + $vis struct $name { + $( + $prop: prop_extracter!([impl reader][$prop $(: $reader)?]), + )* + } + + impl $name { + fn read(&mut self, cx: &$crate::context::LayoutCx) { + $($crate::style::StylePropReader::read(&mut self.$prop, cx);)* + } + + $($prop_vis fn $prop(&self) -> ::Type + { + $crate::style::StylePropReader::get(&self.$prop) + })* + } + + impl Default for $name { + fn default() -> Self { + Self { + $( + $prop: $crate::style::StylePropReader::new(), + )* + } + } + } + }; + ([impl reader][$prop:ident: $reader:ty]) => { + $reader + }; + ([impl reader][$prop:ident]) => { + $crate::style::DefaultReader<$prop> + }; +} + +#[derive(Default, Clone, Debug)] +pub(crate) struct StyleMap { + pub(crate) map: HashMap>, +} pub enum StyleSelector { Hover, @@ -161,6 +324,7 @@ macro_rules! define_styles { /// A style with definite values for most fields. #[derive(Debug, Clone)] pub struct ComputedStyle { + pub(crate) other: StyleMap, $( pub $name: $typ, )* @@ -176,6 +340,7 @@ macro_rules! define_styles { impl Default for ComputedStyle { fn default() -> Self { Self { + other: Default::default(), $( $name: $val, )* @@ -185,18 +350,21 @@ macro_rules! define_styles { #[derive(Debug, Clone)] pub struct Style { + pub(crate) other: Option>>>, $( pub $name: StyleValue<$typ>, )* } impl Style { pub const BASE: Style = Style{ + other: None, $( $name: StyleValue::Base, )* }; pub const UNSET: Style = Style{ + other: None, $( $name: StyleValue::Unset, )* @@ -210,6 +378,12 @@ macro_rules! define_styles { /// for any missing values. pub fn compute(self, underlying: &ComputedStyle) -> ComputedStyle { ComputedStyle { + other: StyleMap { + map: self.other.unwrap_or_default() + .into_iter() + .filter_map(|(k, mut v)| v.as_mut().map(|v| (k, v.clone()))) + .collect() + }, $( $name: self.$name.unwrap_or_else(|| underlying.$name.clone()), )* @@ -224,7 +398,20 @@ macro_rules! define_styles { /// `StyleValue::Base` will leave the value as-is, whether falling back to the underlying /// `ComputedStyle` or using the value in the `Style`. pub fn apply(self, over: Style) -> Style { + let mut other = self.other.unwrap_or_default(); + for (k, v) in over.other.unwrap_or_default() { + match v { + StyleValue::Val(..) => { + other.insert(k, v); + }, + StyleValue::Base => (), + StyleValue::Unset => { + other.remove(&k); + } + } + } Style { + other: Some(other), $( $name: match (self.$name, over.$name) { (_, StyleValue::Val(x)) => StyleValue::Val(x), @@ -309,10 +496,8 @@ define_styles!( color color_sv nocb: Option = None, background background_sv nocb: Option = None, box_shadow box_shadow_sv nocb: Option = None, - scroll_bar_color scroll_bar_color_sv nocb: Option = None, scroll_bar_hover_color scroll_bar_hover_color_sv nocb: Option = None, scroll_bar_drag_color scroll_bar_drag_color_sv nocb: Option = None, - scroll_bar_bg_active_color scroll_bar_bg_active_color_sv nocb: Option = None, scroll_bar_rounded scroll_bar_rounded_sv nocb: Option = None, scroll_bar_thickness scroll_bar_thickness_sv nocb: Option = None, scroll_bar_edge_width scroll_bar_edge_width_sv nocb: Option = None, @@ -328,6 +513,17 @@ define_styles!( ); impl Style { + pub fn set(self, prop: P, value: P::Type) -> Self { + self.set_style_value(prop, StyleValue::Val(value)) + } + + pub fn set_style_value(mut self, _prop: P, value: StyleValue) -> Self { + let mut other = self.other.unwrap_or_default(); + other.insert(P::prop_ref(), value.map(|v| -> Rc { Rc::new(v) })); + self.other = Some(other); + self + } + pub fn width_full(self) -> Self { self.width_pct(100.0) } @@ -676,9 +872,8 @@ impl Style { self } - pub fn scroll_bar_color(mut self, color: impl Into>) -> Self { - self.scroll_bar_color = color.into().map(Some); - self + pub fn scroll_bar_color(self, color: impl Into>) -> Self { + self.set_style_value(scroll_bar_color, color.into()) } pub fn scroll_bar_hover_color(mut self, color: impl Into>) -> Self { @@ -691,11 +886,6 @@ impl Style { self } - pub fn scroll_bar_bg_active_color(mut self, color: impl Into>) -> Self { - self.scroll_bar_bg_active_color = color.into().map(Some); - self - } - pub fn scroll_bar_rounded(mut self, rounded: impl Into>) -> Self { self.scroll_bar_rounded = rounded.into().map(Some); self diff --git a/src/view.rs b/src/view.rs index 7540bbcb..c5fac0cd 100644 --- a/src/view.rs +++ b/src/view.rs @@ -83,7 +83,7 @@ //! //! -use std::any::Any; +use std::{any::Any, rc::Rc}; use bitflags::bitflags; use floem_renderer::Renderer; @@ -95,7 +95,7 @@ use crate::{ context::{AppState, DragState, EventCx, LayoutCx, PaintCx, UpdateCx}, event::{Event, EventListener}, id::Id, - style::{ComputedStyle, Style}, + style::{ComputedStyle, Style, StyleMap}, }; bitflags! { @@ -196,12 +196,25 @@ pub trait View { cx.app_state_mut().compute_style(self.id(), view_style); let style = cx.app_state_mut().get_computed_style(self.id()).clone(); + cx.style.current = Rc::new(StyleMap { + map: cx + .style + .current + .map + .iter() + .map(|(p, v)| (*p, v.clone())) + .chain( + style + .other + .map + .into_iter() + .filter(|(p, _)| p.info.inherited), + ) + .collect(), + }); if style.color.is_some() { cx.color = style.color; } - if style.scroll_bar_color.is_some() { - cx.scroll_bar_color = style.scroll_bar_color; - } if style.scroll_bar_hover_color.is_some() { cx.scroll_bar_hover_color = style.scroll_bar_hover_color; } @@ -211,9 +224,6 @@ pub trait View { if style.scroll_bar_hover_color.is_some() { cx.scroll_bar_hover_color = style.scroll_bar_hover_color; } - if style.scroll_bar_bg_active_color.is_some() { - cx.scroll_bar_bg_active_color = style.scroll_bar_bg_active_color; - } if style.scroll_bar_rounded.is_some() { cx.scroll_bar_rounded = style.scroll_bar_rounded; } @@ -691,9 +701,6 @@ pub trait View { if style.color.is_some() { cx.color = style.color; } - if style.scroll_bar_color.is_some() { - cx.scroll_bar_color = style.scroll_bar_color; - } if style.scroll_bar_rounded.is_some() { cx.scroll_bar_rounded = style.scroll_bar_rounded; } diff --git a/src/views/scroll.rs b/src/views/scroll.rs index fc2c1feb..a312c861 100644 --- a/src/views/scroll.rs +++ b/src/views/scroll.rs @@ -8,7 +8,8 @@ use crate::{ context::{AppState, LayoutCx, PaintCx}, event::Event, id::Id, - style::{ComputedStyle, Style, StyleValue}, + prop, prop_extracter, + style::{ComputedStyle, OptionReader, Style, StyleValue}, unit::PxPct, view::{ChangeFlags, View}, }; @@ -39,11 +40,19 @@ enum BarHeldState { Horizontal(f64, Vec2), } +prop!(pub scroll_bar_color: Color { inherited: true } = Color::rgba8(0, 0, 0, 120)); +prop!(pub bg_active_color: Color { inherited: true } = Color::rgba8(0, 0, 0, 30)); + +prop_extracter! { + Extracter { + scroll_bar_color, + bg_active_color: OptionReader, + } +} + pub struct ScrollBarStyle { - color: Color, hover_color: Option, drag_color: Option, - bg_active_color: Option, rounded: bool, hide: bool, thickness: f32, @@ -52,22 +61,14 @@ pub struct ScrollBarStyle { impl ScrollBarStyle { pub const BASE: Self = ScrollBarStyle { - // 120 is 40% of 255 so a 40% alpha factor is the default - color: Color::rgba8(0, 0, 0, 120), hover_color: None, drag_color: None, - bg_active_color: None, rounded: cfg!(target_os = "macos"), thickness: 10., edge_width: 0., hide: false, }; - pub fn color(mut self, color: Color) -> Self { - self.color = color; - self - } - pub fn hover_color(mut self, color: Color) -> Self { self.hover_color = Some(color); self @@ -110,6 +111,7 @@ pub struct Scroll { propagate_pointer_wheel: bool, vertical_scroll_as_horizontal: bool, scroll_bar_style: ScrollBarStyle, + style: Extracter, } pub fn scroll(child: V) -> Scroll { @@ -130,6 +132,7 @@ pub fn scroll(child: V) -> Scroll { propagate_pointer_wheel: false, vertical_scroll_as_horizontal: false, scroll_bar_style: ScrollBarStyle::BASE, + style: Default::default(), } } @@ -367,22 +370,22 @@ impl Scroll { if let Some(color) = self.scroll_bar_style.drag_color { color } else { - self.scroll_bar_style.color + self.style.scroll_bar_color() } } else if self.vbar_hover { if let Some(color) = self.scroll_bar_style.hover_color { color } else { - self.scroll_bar_style.color + self.style.scroll_bar_color() } } else { - self.scroll_bar_style.color + self.style.scroll_bar_color() }; if self.vbar_whole_hover || matches!(self.held, BarHeldState::Vertical(..)) { let mut bounds = bounds; bounds.y0 = self.actual_rect.y0; bounds.y1 = self.actual_rect.y1; - if let Some(color) = self.scroll_bar_style.bg_active_color { + if let Some(color) = self.style.bg_active_color() { cx.fill(&bounds, color, 0.0); } } @@ -400,22 +403,22 @@ impl Scroll { if let Some(color) = self.scroll_bar_style.drag_color { color } else { - self.scroll_bar_style.color + self.style.scroll_bar_color() } } else if self.hbar_hover { if let Some(color) = self.scroll_bar_style.hover_color { color } else { - self.scroll_bar_style.color + self.style.scroll_bar_color() } } else { - self.scroll_bar_style.color + self.style.scroll_bar_color() }; if self.hbar_whole_hover || matches!(self.held, BarHeldState::Horizontal(..)) { let mut bounds = bounds; bounds.x0 = self.actual_rect.x0; bounds.x1 = self.actual_rect.x1; - if let Some(color) = self.scroll_bar_style.bg_active_color { + if let Some(color) = self.style.bg_active_color() { cx.fill(&bounds, color, 0.0); } } @@ -663,18 +666,13 @@ impl View for Scroll { fn layout(&mut self, cx: &mut crate::context::LayoutCx) -> taffy::prelude::Node { cx.layout_node(self.id, true, |cx| { - if let Some(color) = cx.scroll_bar_color { - self.scroll_bar_style.color = color; - } if let Some(color) = cx.scroll_bar_hover_color { self.scroll_bar_style.hover_color = Some(color); } if let Some(color) = cx.scroll_bar_drag_color { self.scroll_bar_style.drag_color = Some(color); } - if let Some(color) = cx.scroll_bar_bg_active_color { - self.scroll_bar_style.bg_active_color = Some(color); - } + self.style.read(cx); if let Some(rounded) = cx.scroll_bar_rounded { self.scroll_bar_style.rounded = rounded; } @@ -868,9 +866,6 @@ impl View for Scroll { fn paint(&mut self, cx: &mut crate::context::PaintCx) { cx.save(); - if let Some(color) = cx.scroll_bar_color { - self.scroll_bar_style.color = color; - } if let Some(rounded) = cx.scroll_bar_rounded { self.scroll_bar_style.rounded = rounded; } diff --git a/src/window_handle.rs b/src/window_handle.rs index cc65a9b6..78d27683 100644 --- a/src/window_handle.rs +++ b/src/window_handle.rs @@ -475,11 +475,9 @@ impl WindowHandle { saved_font_styles: Vec::new(), saved_line_heights: Vec::new(), saved_z_indexes: Vec::new(), - scroll_bar_color: None, scroll_bar_rounded: None, scroll_bar_thickness: None, scroll_bar_edge_width: None, - saved_scroll_bar_colors: Vec::new(), saved_scroll_bar_roundeds: Vec::new(), saved_scroll_bar_thicknesses: Vec::new(), saved_scroll_bar_edge_widths: Vec::new(),