pub struct ScrollViewer { /* private fields */ }Expand description
Scrolling container which manages the internal content’s scrolling
Design (optional Border):
┌─────────┐
│Child1 ▲│
│Child2 ┃│
│Child3 │
│Child4 │
│Child5 ▼│
│◀━ ▶ │
└─────────┘Implementations§
Source§impl ScrollViewer
impl ScrollViewer
pub const ARROW_UP: Grapheme
pub const ARROW_UP_DISABLED: Grapheme
pub const BAR_MARKER_V: Grapheme
pub const ARROW_DOWN: Grapheme
pub const ARROW_DOWN_DISABLED: Grapheme
pub const ARROW_LEFT: Grapheme
pub const ARROW_LEFT_DISABLED: Grapheme
pub const BAR_MARKER_H: Grapheme
pub const ARROW_RIGHT: Grapheme
pub const ARROW_RIGHT_DISABLED: Grapheme
Sourcepub fn set_content(
rc: &Rc<RefCell<Self>>,
content: Option<&Rc<RefCell<dyn Scrollable>>>,
)
pub fn set_content( rc: &Rc<RefCell<Self>>, content: Option<&Rc<RefCell<dyn Scrollable>>>, )
Examples found in repository?
examples/scrollviewer.rs (lines 74-77)
53 fn default() -> Self {
54 let values = [
55 "Tomatoes",
56 "Tofu",
57 "Flatbread",
58 "Olive oil",
59 "Salt",
60 "Oregano",
61 "Butter",
62 ];
63
64 let scrollviewer = WindowFactory::create::<ScrollViewer>();
65 scrollviewer
66 .borrow_mut()
67 .set_border(BorderStyle::new(BorderKind::Solid, None, None));
68 let stackpanel = WindowFactory::create::<Stackpanel>();
69 for v in values {
70 let cbx = WindowFactory::create::<TextCheckbox>();
71 cbx.borrow_mut().set_text(v);
72 stackpanel.borrow_mut().add_item(cbx);
73 }
74 ScrollViewer::set_content(
75 &scrollviewer,
76 Some(&(stackpanel as Rc<RefCell<dyn Scrollable>>)),
77 );
78
79 Self {
80 uid: WindowUID::new(),
81 scrollviewer,
82 running: true,
83 }
84 }pub fn set_scrollbar_visibility(&mut self, show: bool)
Sourcepub fn is_scrollable(&self, axis: Orientation) -> bool
pub fn is_scrollable(&self, axis: Orientation) -> bool
Can current Scrollable be scrolled horizontally / vertically
Sourcepub fn scroll(&mut self, direction: Direction, kind: ScrollKind)
pub fn scroll(&mut self, direction: Direction, kind: ScrollKind)
Scrolls page/line-wise (see ScrollKind) in the given direction
Sourcepub fn set_offset(&mut self, direction: Orientation, offset: usize)
pub fn set_offset(&mut self, direction: Orientation, offset: usize)
Sets the horizontal / vertical offset
Sourcepub fn offset(&self, axis: Orientation) -> usize
pub fn offset(&self, axis: Orientation) -> usize
Horizontal / Vertical offset of the scrolled content
Sourcepub fn viewport(&self, axis: Orientation) -> usize
pub fn viewport(&self, axis: Orientation) -> usize
Horizontal / Vertical size of the viewport for current Scrollable
Trait Implementations§
Source§impl Default for ScrollViewer
impl Default for ScrollViewer
Source§fn default() -> ScrollViewer
fn default() -> ScrollViewer
Returns the “default value” for a type. Read more
Source§impl HasWindowUID for ScrollViewer
impl HasWindowUID for ScrollViewer
Source§impl Widget for ScrollViewer
impl Widget for ScrollViewer
fn set_visibility(&mut self, visibility: bool)
fn set_width(&mut self, width: Size)
fn set_height(&mut self, height: Size)
fn set_margin(&mut self, margin: Thickness)
fn set_border(&mut self, border: BorderStyle)
fn set_alignment( &mut self, horizontal: HorizontalAlignment, vertical: VerticalAlignment, )
Source§fn set_enabled_state(&mut self, is_enabled: bool)
fn set_enabled_state(&mut self, is_enabled: bool)
Changing the IsEnabled state usually changes the highlight color
fn set_width_constraint(&mut self, width: SizeConstraint)
fn set_height_constraint(&mut self, height: SizeConstraint)
Source§impl WidgetColors for ScrollViewer
impl WidgetColors for ScrollViewer
fn set_disabled_color(&mut self, color: Option<Color>)
fn set_base_fg_color(&mut self, color: Option<Color>)
fn set_base_bg_color(&mut self, color: Option<Color>)
Source§impl Window for ScrollViewer
impl Window for ScrollViewer
Source§fn handle_event(&mut self, event: &mut WindowEvent)
fn handle_event(&mut self, event: &mut WindowEvent)
Source§fn children(&mut self, builder: SubWindowBuilder) -> SubWindows
fn children(&mut self, builder: SubWindowBuilder) -> SubWindows
Returns all children windows (and layouting Rects)
Note: When changing the children make sure to also adjust the focus
Source§impl WindowLayout for ScrollViewer
impl WindowLayout for ScrollViewer
Source§fn desired_size(&self, available_size: TPoint) -> TPoint
fn desired_size(&self, available_size: TPoint) -> TPoint
Parents call this to get the desired size of the child
This must not exceed
available_size on any axis
When the result’s product is equal to 0, this window wont be drawnSource§fn alignment(&self) -> (HorizontalAlignment, VerticalAlignment)
fn alignment(&self) -> (HorizontalAlignment, VerticalAlignment)
fn border(&self) -> BorderStyle
fn is_visible(&self) -> bool
fn margin(&self) -> Thickness
Source§fn desired_size_pre_hook(&mut self, available_size: TPoint)
fn desired_size_pre_hook(&mut self, available_size: TPoint)
This is similar to desired_size but will not return anything and can mutably change self
This is executed before WindowLayout::desired_size
Only implement if actually necessary
Auto Trait Implementations§
impl !RefUnwindSafe for ScrollViewer
impl !Send for ScrollViewer
impl !Sync for ScrollViewer
impl !UnwindSafe for ScrollViewer
impl Freeze for ScrollViewer
impl Unpin for ScrollViewer
impl UnsafeUnpin for ScrollViewer
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 T
impl<T> Downcast for T
Source§impl<T, W> HasTypeWitness<W> for Twhere
W: MakeTypeWitness<Arg = T>,
T: ?Sized,
impl<T, W> HasTypeWitness<W> for Twhere
W: MakeTypeWitness<Arg = T>,
T: ?Sized,
Source§impl<T> Identity for Twhere
T: ?Sized,
impl<T> Identity for Twhere
T: ?Sized,
Source§impl<T> WindowHelper for Twhere
T: Window,
impl<T> WindowHelper for Twhere
T: Window,
Source§fn provoke_changed_property(&self, property: WindowProperty)
fn provoke_changed_property(&self, property: WindowProperty)
Helper method for WindowEventQueue::provoke_changed_property