fltk_builder/extensions/builder/
browser.rs

1use fltk::{browser::BrowserScrollbar, prelude::BrowserExt};
2
3/// Adds builder pattern friendly versions of several setter functions
4pub trait BrowserBuilderExt {
5    /// Sets the text size.
6    /// Lines start at 1
7    fn with_text_size(self, sz: i32) -> Self;
8    /// Sets the column separator to c. This will only have an effect if you also use `with_column_widths()`.
9    /// c should be ascii
10    fn with_column_char(self, c: char) -> Self;
11    /// Sets the current column width array
12    fn with_column_widths(self, arr: &[i32]) -> Self;
13    /// Sets the type of scrollbar associated with the browser
14    fn with_has_scrollbar(self, mode: BrowserScrollbar) -> Self;
15    /// Sets the scrollbar size
16    fn with_scrollbar_size(self, new_size: i32) -> Self;
17}
18
19impl<B> BrowserBuilderExt for B
20where
21    B: BrowserExt,
22{
23    fn with_text_size(mut self, sz: i32) -> Self {
24        self.set_text_size(sz);
25        self
26    }
27
28    fn with_column_char(mut self, c: char) -> Self {
29        self.set_column_char(c);
30        self
31    }
32
33    fn with_column_widths(mut self, arr: &[i32]) -> Self {
34        self.set_column_widths(arr);
35        self
36    }
37
38    fn with_has_scrollbar(mut self, mode: BrowserScrollbar) -> Self {
39        self.set_has_scrollbar(mode);
40        self
41    }
42
43    fn with_scrollbar_size(mut self, new_size: i32) -> Self {
44        self.set_scrollbar_size(new_size);
45        self
46    }
47}