pub struct VerticalScrollbar {
pub parent_id: String,
/* private fields */
}Expand description
Vertical Scrollbar Component
Extracted from existing static content scrollbar implementation (F0356) Provides unified vertical scrollbar functionality with:
- Context awareness of parent box
- Automatic visibility detection
- Proportional knob sizing
- Click-to-jump and drag-to-scroll support
- Transparent behavior matching existing implementation
Fields§
§parent_id: StringParent muxbox ID for context awareness
Implementations§
Source§impl VerticalScrollbar
impl VerticalScrollbar
Sourcepub fn new(parent_id: String) -> Self
pub fn new(parent_id: String) -> Self
Create new vertical scrollbar component for a parent muxbox
Sourcepub fn should_draw(&self, content_height: usize, viewable_height: usize) -> bool
pub fn should_draw(&self, content_height: usize, viewable_height: usize) -> bool
Determine if scrollbar should be visible based on content dimensions
Sourcepub fn get_bounds(&self, parent_bounds: &Bounds) -> (usize, usize, usize)
pub fn get_bounds(&self, parent_bounds: &Bounds) -> (usize, usize, usize)
Get the bounds where this scrollbar should be drawn
Sourcepub fn calculate_knob_metrics(
&self,
content_height: usize,
viewable_height: usize,
vertical_scroll: f64,
track_height: usize,
) -> (usize, usize)
pub fn calculate_knob_metrics( &self, content_height: usize, viewable_height: usize, vertical_scroll: f64, track_height: usize, ) -> (usize, usize)
Calculate knob position and size using ScrollDimensions (eliminates ad-hoc math)
Sourcepub fn draw(
&self,
parent_bounds: &Bounds,
content_height: usize,
viewable_height: usize,
vertical_scroll: f64,
border_color: &Option<String>,
bg_color: &Option<String>,
buffer: &mut ScreenBuffer,
)
pub fn draw( &self, parent_bounds: &Bounds, content_height: usize, viewable_height: usize, vertical_scroll: f64, border_color: &Option<String>, bg_color: &Option<String>, buffer: &mut ScreenBuffer, )
Draw the complete vertical scrollbar (track + knob) This is extracted directly from the existing draw_vertical_scrollbar function
Sourcepub fn is_click_on_scrollbar(
&self,
click_x: usize,
click_y: usize,
parent_bounds: &Bounds,
) -> bool
pub fn is_click_on_scrollbar( &self, click_x: usize, click_y: usize, parent_bounds: &Bounds, ) -> bool
Check if a click position is on this scrollbar
Sourcepub fn is_click_on_knob(
&self,
click_x: usize,
click_y: usize,
parent_bounds: &Bounds,
content_height: usize,
viewable_height: usize,
vertical_scroll: f64,
) -> bool
pub fn is_click_on_knob( &self, click_x: usize, click_y: usize, parent_bounds: &Bounds, content_height: usize, viewable_height: usize, vertical_scroll: f64, ) -> bool
Check if a click position is specifically on the scrollbar knob
Sourcepub fn click_position_to_scroll_percentage(
&self,
click_y: usize,
parent_bounds: &Bounds,
) -> f64
pub fn click_position_to_scroll_percentage( &self, click_y: usize, parent_bounds: &Bounds, ) -> f64
Convert click position to scroll percentage
Trait Implementations§
Source§impl Clone for VerticalScrollbar
impl Clone for VerticalScrollbar
Source§fn clone(&self) -> VerticalScrollbar
fn clone(&self) -> VerticalScrollbar
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for VerticalScrollbar
impl RefUnwindSafe for VerticalScrollbar
impl Send for VerticalScrollbar
impl Sync for VerticalScrollbar
impl Unpin for VerticalScrollbar
impl UnsafeUnpin for VerticalScrollbar
impl UnwindSafe for VerticalScrollbar
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Convert
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Convert
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
Convert
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
Convert
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.