Skip to main content

ContainerInputHandler

Trait ContainerInputHandler 

Source
pub trait ContainerInputHandler {
    // Provided methods
    fn hit_test_scrollbar(
        &self,
        scrollbar_rect: &Rect,
        mouse_pos: (f64, f64),
    ) -> bool { ... }
    fn mouse_to_scroll_offset(
        &self,
        mouse_y: f64,
        scrollbar_y: f64,
        scrollbar_height: f64,
        content_height: f64,
        viewport_height: f64,
    ) -> f64 { ... }
    fn scroll_to_delta(&self, scroll_delta: f64, _viewport_height: f64) -> f64 { ... }
    fn clamp_scroll_offset(
        &self,
        offset: f64,
        content_height: f64,
        viewport_height: f64,
    ) -> f64 { ... }
    fn calculate_thumb_size(
        &self,
        viewport_height: f64,
        content_height: f64,
        scrollbar_height: f64,
        min_thumb_height: f64,
    ) -> f64 { ... }
    fn calculate_thumb_position(
        &self,
        scroll_offset: f64,
        content_height: f64,
        viewport_height: f64,
        scrollbar_y: f64,
        scrollbar_height: f64,
        thumb_height: f64,
    ) -> f64 { ... }
}
Expand description

Input handler adapter for container scrollbar events

This trait defines the contract for converting raw input events into scroll actions. External projects implement this trait to customize scroll behavior (rare).

Provided Methods§

Source

fn hit_test_scrollbar( &self, scrollbar_rect: &Rect, mouse_pos: (f64, f64), ) -> bool

Test if mouse position is inside scrollbar rect

Source

fn mouse_to_scroll_offset( &self, mouse_y: f64, scrollbar_y: f64, scrollbar_height: f64, content_height: f64, viewport_height: f64, ) -> f64

Convert mouse Y position to scroll offset (for drag scrolling)

Source

fn scroll_to_delta(&self, scroll_delta: f64, _viewport_height: f64) -> f64

Convert scroll wheel delta to scroll offset change

Source

fn clamp_scroll_offset( &self, offset: f64, content_height: f64, viewport_height: f64, ) -> f64

Clamp scroll offset to valid range [0, max_scroll]

Source

fn calculate_thumb_size( &self, viewport_height: f64, content_height: f64, scrollbar_height: f64, min_thumb_height: f64, ) -> f64

Calculate scrollbar thumb size based on viewport/content ratio

Source

fn calculate_thumb_position( &self, scroll_offset: f64, content_height: f64, viewport_height: f64, scrollbar_y: f64, scrollbar_height: f64, thumb_height: f64, ) -> f64

Calculate scrollbar thumb Y position based on scroll offset

Implementors§