diff --git a/tui-scrollbar/src/lib.rs b/tui-scrollbar/src/lib.rs index 0da87f36..2c51e507 100644 --- a/tui-scrollbar/src/lib.rs +++ b/tui-scrollbar/src/lib.rs @@ -225,6 +225,7 @@ //! - [`ScrollMetrics`]: pure math for thumb sizing and hit testing. //! - [`GlyphSet`]: glyph selection for track and thumb rendering. //! - [`ScrollBarArrows`]: arrow endcap configuration. +//! - [`ScrollBarStyle`]: style configuration for the scrollbar. //! //! ## Enums and events //! @@ -312,5 +313,7 @@ pub use crate::input::{ ScrollEvent, ScrollWheel, }; pub use crate::lengths::ScrollLengths; -pub use crate::metrics::{CellFill, HitTest, SUBCELL, ScrollMetrics}; -pub use crate::scrollbar::{ScrollBar, ScrollBarArrows, ScrollBarOrientation, TrackClickBehavior}; +pub use crate::metrics::{CellFill, HitTest, ScrollMetrics, SUBCELL}; +pub use crate::scrollbar::{ + ScrollBar, ScrollBarArrows, ScrollBarOrientation, ScrollBarStyle, TrackClickBehavior, +}; diff --git a/tui-scrollbar/src/scrollbar/mod.rs b/tui-scrollbar/src/scrollbar/mod.rs index d9473e06..c18017a6 100644 --- a/tui-scrollbar/src/scrollbar/mod.rs +++ b/tui-scrollbar/src/scrollbar/mod.rs @@ -126,6 +126,108 @@ struct ArrowLayout { end: Option<(u16, u16)>, } +/// Style of the scrollbar (track, thumb, and optional arrow endcaps). +/// +/// # Reading and updating +/// +/// The `track_style`, `thumb_style`, and `arrow_style` fields are public, so you can read or +/// assign them directly (including in struct update expressions). +/// +/// Methods [`Self::track_style`], [`Self::thumb_style`], and [`Self::arrow_style`] that take a +/// [`Style`] and return `Self` are **builders** for chained construction. +/// +/// Use [`Self::get_track_style`], [`Self::get_thumb_style`], and [`Self::get_arrow_style`] to read +/// by method call, and [`Self::set_track_style`], [`Self::set_thumb_style`], [`Self::set_arrow_style`], +/// and [`Self::clear_arrow_style`] to update a `ScrollBarStyle` in place without consuming it. +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +pub struct ScrollBarStyle { + /// Style applied to track glyphs. + pub track_style: Style, + /// Style applied to thumb glyphs. + pub thumb_style: Style, + /// Style applied to arrow glyphs. + pub arrow_style: Option