clay_layout/elements/containers/
scroll.rs1use crate::{bindings::*, elements::ElementConfigType, mem, TypedConfig};
2
3#[derive(Debug, Copy, Clone, Default)]
4pub struct ScrollContainer {
5 pub horizontal: bool,
6 pub vertical: bool,
7}
8
9impl ScrollContainer {
10 pub fn new() -> Self {
11 Self::default()
12 }
13
14 pub fn horizontal(&mut self) -> &mut Self {
15 self.horizontal = true;
16 self
17 }
18
19 pub fn vertical(&mut self) -> &mut Self {
20 self.vertical = true;
21 self
22 }
23
24 pub fn end(&self) -> TypedConfig {
25 let memory = unsafe { Clay__StoreScrollElementConfig((*self).into()) };
26
27 TypedConfig {
28 config_memory: memory as _,
29 id: mem::zeroed_init(),
30 config_type: ElementConfigType::ScrollContainer as _,
31 }
32 }
33}
34
35impl From<Clay_ScrollElementConfig> for ScrollContainer {
36 fn from(value: Clay_ScrollElementConfig) -> Self {
37 Self {
38 horizontal: value.horizontal,
39 vertical: value.vertical,
40 }
41 }
42}
43impl From<ScrollContainer> for Clay_ScrollElementConfig {
44 fn from(value: ScrollContainer) -> Self {
45 Self {
46 horizontal: value.horizontal,
47 vertical: value.vertical,
48 }
49 }
50}