fltk_builder/extensions/builder/
menu.rs

1use fltk::{
2    enums::{Color, Font, FrameType},
3    prelude::MenuExt,
4};
5/// Adds builder pattern friendly versions of several setter functions
6pub trait MenuBuilderExt {
7    /// Sets the text font
8    fn with_text_font(self, c: Font) -> Self;
9    /// Sets the text size
10    fn with_text_size(self, c: i32) -> Self;
11    /// Sets the text color
12    fn with_text_color(self, c: Color) -> Self;
13    /// Set the `down_box` of the widget
14    fn with_down_frame(self, f: FrameType) -> Self;
15}
16
17impl<M> MenuBuilderExt for M
18where
19    M: MenuExt,
20{
21    fn with_text_font(mut self, c: Font) -> Self {
22        self.set_text_font(c);
23        self
24    }
25
26    fn with_text_size(mut self, c: i32) -> Self {
27        self.set_text_size(c);
28        self
29    }
30
31    fn with_text_color(mut self, c: Color) -> Self {
32        self.set_text_color(c);
33        self
34    }
35
36    fn with_down_frame(mut self, f: FrameType) -> Self {
37        self.set_down_frame(f);
38        self
39    }
40}