pub struct Scrollbar { /* private fields */ }Expand description
Scrollbar renderer using wgpu
Implementations§
Source§impl Scrollbar
impl Scrollbar
Sourcepub fn new(
device: &Device,
format: TextureFormat,
width: f32,
position: &str,
thumb_color: [f32; 4],
track_color: [f32; 4],
) -> Self
pub fn new( device: &Device, format: TextureFormat, width: f32, position: &str, thumb_color: [f32; 4], track_color: [f32; 4], ) -> Self
Create a new scrollbar renderer
§Arguments
device- WGPU deviceformat- Texture formatwidth- Scrollbar width in pixelsposition- Scrollbar position (“left” or “right”)thumb_color- RGBA color for thumb [r, g, b, a]track_color- RGBA color for track [r, g, b, a]
Sourcepub fn update(
&mut self,
queue: &Queue,
scroll_offset: usize,
visible_lines: usize,
total_lines: usize,
window_width: u32,
window_height: u32,
)
pub fn update( &mut self, queue: &Queue, scroll_offset: usize, visible_lines: usize, total_lines: usize, window_width: u32, window_height: u32, )
Update scrollbar position and visibility
§Arguments
scroll_offset- Current scroll offset (0 = at bottom)visible_lines- Number of lines visible on screentotal_lines- Total number of lines including scrollbackwindow_width- Window width in pixelswindow_height- Window height in pixels
Sourcepub fn render<'a>(&'a self, render_pass: &mut RenderPass<'a>)
pub fn render<'a>(&'a self, render_pass: &mut RenderPass<'a>)
Render the scrollbar (track + thumb)
Sourcepub fn update_appearance(
&mut self,
width: f32,
thumb_color: [f32; 4],
track_color: [f32; 4],
)
pub fn update_appearance( &mut self, width: f32, thumb_color: [f32; 4], track_color: [f32; 4], )
Update scrollbar appearance (width and colors) in real-time
Sourcepub fn update_position(&mut self, position: &str)
pub fn update_position(&mut self, position: &str)
Update scrollbar position side (left/right)
pub fn width(&self) -> f32
pub fn position_right(&self) -> bool
Sourcepub fn contains_point(&self, x: f32, y: f32) -> bool
pub fn contains_point(&self, x: f32, y: f32) -> bool
Check if a point (in pixel coordinates) is within the scrollbar bounds
§Arguments
x- X coordinate in pixels (from left edge)y- Y coordinate in pixels (from top edge)
Sourcepub fn track_contains_x(&self, x: f32) -> bool
pub fn track_contains_x(&self, x: f32) -> bool
Check if a point is within the scrollbar track (any Y position)
Sourcepub fn thumb_bounds(&self) -> Option<(f32, f32)>
pub fn thumb_bounds(&self) -> Option<(f32, f32)>
Get the current thumb bounds (top Y in pixels, height in pixels)
Sourcepub fn mouse_y_to_scroll_offset(&self, mouse_y: f32) -> Option<usize>
pub fn mouse_y_to_scroll_offset(&self, mouse_y: f32) -> Option<usize>
Sourcepub fn is_visible(&self) -> bool
pub fn is_visible(&self) -> bool
Whether the scrollbar is currently visible
Auto Trait Implementations§
impl Freeze for Scrollbar
impl !RefUnwindSafe for Scrollbar
impl Send for Scrollbar
impl Sync for Scrollbar
impl Unpin for Scrollbar
impl !UnwindSafe for Scrollbar
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
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.Source§impl<T> DowncastSync for T
impl<T> DowncastSync for T
Source§impl<S> FromSample<S> for S
impl<S> FromSample<S> for S
fn from_sample_(s: S) -> S
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more