winio/widgets/
scroll_view.rs1use inherit_methods_macro::inherit_methods;
2use winio_elm::{Component, ComponentSender};
3use winio_handle::BorrowedContainer;
4use winio_primitive::{Enable, Failable, Layoutable, Point, Size, Visible};
5
6use crate::{
7 sys,
8 sys::{Error, Result},
9};
10
11#[derive(Debug)]
14pub struct ScrollView {
15 widget: sys::ScrollView,
16}
17
18impl Failable for ScrollView {
19 type Error = Error;
20}
21
22#[inherit_methods(from = "self.widget")]
23impl ScrollView {
24 pub fn hscroll(&self) -> Result<bool>;
26
27 pub fn set_hscroll(&mut self, v: bool) -> Result<()>;
29
30 pub fn vscroll(&self) -> Result<bool>;
32
33 pub fn set_vscroll(&mut self, v: bool) -> Result<()>;
35}
36
37#[inherit_methods(from = "self.widget")]
38impl Visible for ScrollView {
39 fn is_visible(&self) -> Result<bool>;
40
41 fn set_visible(&mut self, v: bool) -> Result<()>;
42}
43
44#[inherit_methods(from = "self.widget")]
45impl Enable for ScrollView {
46 fn is_enabled(&self) -> Result<bool>;
47
48 fn set_enabled(&mut self, v: bool) -> Result<()>;
49}
50
51#[inherit_methods(from = "self.widget")]
52impl Layoutable for ScrollView {
53 fn loc(&self) -> Result<Point>;
54
55 fn set_loc(&mut self, p: Point) -> Result<()>;
56
57 fn size(&self) -> Result<Size>;
58
59 fn set_size(&mut self, v: Size) -> Result<()>;
60}
61
62#[derive(Debug)]
64#[non_exhaustive]
65pub enum ScrollViewEvent {}
66
67#[derive(Debug)]
69#[non_exhaustive]
70pub enum ScrollViewMessage {}
71
72impl Component for ScrollView {
73 type Error = Error;
74 type Event = ScrollViewEvent;
75 type Init<'a> = BorrowedContainer<'a>;
76 type Message = ScrollViewMessage;
77
78 async fn init(init: Self::Init<'_>, _sender: &ComponentSender<Self>) -> Result<Self> {
79 let widget = sys::ScrollView::new(init)?;
80 Ok(Self { widget })
81 }
82
83 async fn start(&mut self, _sender: &ComponentSender<Self>) -> ! {
84 self.widget.start().await
85 }
86}
87
88winio_handle::impl_as_widget!(ScrollView, widget);
89winio_handle::impl_as_container!(ScrollView, widget);