pub struct HorizontalScrollbar {
pub parent_id: String,
/* private fields */
}Expand description
Horizontal Scrollbar Component
Extracted from existing static content scrollbar implementation (F0357) Provides unified horizontal 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 HorizontalScrollbar
impl HorizontalScrollbar
Sourcepub fn new(parent_id: String) -> Self
pub fn new(parent_id: String) -> Self
Create new horizontal scrollbar component for a parent muxbox
Sourcepub fn should_draw(&self, content_width: usize, viewable_width: usize) -> bool
pub fn should_draw(&self, content_width: usize, viewable_width: 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_width: usize,
viewable_width: usize,
horizontal_scroll: f64,
track_width: usize,
) -> (usize, usize)
pub fn calculate_knob_metrics( &self, content_width: usize, viewable_width: usize, horizontal_scroll: f64, track_width: usize, ) -> (usize, usize)
Calculate knob position and size using ScrollDimensions (eliminates ad-hoc math)
Sourcepub fn draw(
&self,
parent_bounds: &Bounds,
content_width: usize,
viewable_width: usize,
horizontal_scroll: f64,
border_color: &Option<String>,
bg_color: &Option<String>,
buffer: &mut ScreenBuffer,
)
pub fn draw( &self, parent_bounds: &Bounds, content_width: usize, viewable_width: usize, horizontal_scroll: f64, border_color: &Option<String>, bg_color: &Option<String>, buffer: &mut ScreenBuffer, )
Draw the complete horizontal scrollbar (track + knob) This is extracted directly from the existing inline horizontal scrollbar drawing
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_width: usize,
viewable_width: usize,
horizontal_scroll: f64,
) -> bool
pub fn is_click_on_knob( &self, click_x: usize, click_y: usize, parent_bounds: &Bounds, content_width: usize, viewable_width: usize, horizontal_scroll: f64, ) -> bool
Check if a click position is specifically on the scrollbar knob
Sourcepub fn click_position_to_scroll_percentage(
&self,
click_x: usize,
parent_bounds: &Bounds,
) -> f64
pub fn click_position_to_scroll_percentage( &self, click_x: usize, parent_bounds: &Bounds, ) -> f64
Convert click position to scroll percentage
Trait Implementations§
Source§impl Clone for HorizontalScrollbar
impl Clone for HorizontalScrollbar
Source§fn clone(&self) -> HorizontalScrollbar
fn clone(&self) -> HorizontalScrollbar
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 HorizontalScrollbar
impl RefUnwindSafe for HorizontalScrollbar
impl Send for HorizontalScrollbar
impl Sync for HorizontalScrollbar
impl Unpin for HorizontalScrollbar
impl UnsafeUnpin for HorizontalScrollbar
impl UnwindSafe for HorizontalScrollbar
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.