fltk_builder/extensions/builder/
group.rs

1use fltk::prelude::{GroupExt, WidgetExt};
2
3/// Defines all necessary functions for group widgets to add widgets and other groups as children, as well as builder friendly versions of several setter functions
4pub trait GroupBuilderExt {
5    // Functions for adding groups and widgets
6    /// Adds a group widget as a child
7    fn group(self, group: impl GroupExt) -> Self;
8    /// Adds a widget as a child
9    fn widget(self, widget: impl WidgetExt) -> Self;
10
11    // Builder Pattern friendly functions
12    /// Make the group itself resizable
13    fn as_resizeable(self, val: bool) -> Self;
14    /// Clips children outside the group boundaries
15    fn with_clip_children(self, flag: bool) -> Self;
16}
17
18impl<G> GroupBuilderExt for G
19where
20    G: GroupExt,
21{
22    fn group(self, group: impl GroupExt) -> Self {
23        group.end();
24        self
25    }
26
27    fn widget(mut self, widget: impl WidgetExt) -> Self {
28        self.add(&widget);
29        self
30    }
31
32    fn as_resizeable(mut self, val: bool) -> Self {
33        self.make_resizable(val);
34        self
35    }
36
37    fn with_clip_children(mut self, flag: bool) -> Self {
38        self.set_clip_children(flag);
39        self
40    }
41}