gooey/interface/controller/component/
scroll.rs

1//! 2D view and layout controller for Textbox and Picture widgets
2
3use crate::interface::controller::{Alignment, Offset};
4use super::impl_kind;
5
6#[derive(Clone, Debug, Eq, PartialEq)]
7pub struct Scroll {
8  pub offset    : Offset,
9  pub alignment : Alignment
10}
11impl_kind!(Scroll);
12
13impl Scroll {
14  #[inline]
15  pub fn default_tile_absolute() -> Self {
16    Scroll {
17      offset:    Offset::default_absolute(),
18      alignment: Alignment::tile()
19    }
20  }
21  #[inline]
22  pub fn default_tile_relative() -> Self {
23    Scroll {
24      offset:    Offset::default_relative(),
25      alignment: Alignment::tile()
26    }
27  }
28  #[inline]
29  pub fn default_pixel_absolute() -> Self {
30    Scroll {
31      offset:    Offset::default_absolute(),
32      alignment: Alignment::pixel()
33    }
34  }
35  #[inline]
36  pub fn default_pixel_relative() -> Self {
37    Scroll {
38      offset:    Offset::default_relative(),
39      alignment: Alignment::pixel()
40    }
41  }
42  #[inline]
43  pub fn offset_move_right (&mut self, count : u32) {
44    self.offset = self.offset.move_right (self.alignment, count);
45  }
46  #[inline]
47  pub fn offset_move_left (&mut self, count : u32) {
48    self.offset = self.offset.move_left (self.alignment, count);
49  }
50  #[inline]
51  pub fn offset_move_up (&mut self, count : u32) {
52    self.offset = self.offset.move_up (self.alignment, count);
53  }
54  #[inline]
55  pub fn offset_move_down (&mut self, count : u32) {
56    self.offset = self.offset.move_down (self.alignment, count);
57  }
58}