Skip to main content

ui/
app.rs

1//! App-owned configuration.
2
3use gpui::App;
4
5/// Configuration carried by the application. Import as `use ui::AppExt as _;`.
6pub trait AppExt {
7    /// Reads the caption button style. Defaults to `Rectangular`.
8    fn caption_style(&self) -> crate::titlebar::CaptionStyle;
9
10    /// Sets the caption button style and refreshes windows.
11    fn set_caption_style(&mut self, style: crate::titlebar::CaptionStyle);
12
13    /// Reads caret blink.
14    fn caret_blink(&self) -> bool;
15
16    /// Enables blinking or holds carets solid, then refreshes windows.
17    fn set_caret_blink(&mut self, blink: bool);
18
19    /// Reads caret shape.
20    fn caret_shape(&self) -> crate::input::CaretShape;
21
22    /// Sets text caret shape and refreshes windows. Defaults to `Bar`.
23    fn set_caret_shape(&mut self, shape: crate::input::CaretShape);
24
25    /// Reads block caret height.
26    fn caret_height(&self) -> crate::input::CaretHeight;
27
28    /// Sets block caret height and refreshes windows. Defaults to `Line`.
29    fn set_caret_height(&mut self, height: crate::input::CaretHeight);
30
31    /// Reads what a block caret paints as in an inactive window.
32    fn inactive_caret(&self) -> crate::input::InactiveCaret;
33
34    /// Sets it and refreshes windows. Defaults to `Hollow`.
35    fn set_inactive_caret(&mut self, inactive: crate::input::InactiveCaret);
36
37    /// Reads scrollbar visibility.
38    fn scrollbar_visibility(&self) -> crate::scroll::Visibility;
39
40    /// Sets default scrollbar visibility and refreshes windows.
41    fn set_scrollbar_visibility(&mut self, value: crate::scroll::Visibility);
42
43    /// Reads the preset color set pickers offer.
44    fn color_swatches(&self) -> std::rc::Rc<[crate::color::Swatch]>;
45
46    /// Replaces the preset color set and refreshes windows. Defaults to
47    /// [`crate::color::default_swatches`].
48    fn set_color_swatches(&mut self, set: impl Into<std::rc::Rc<[crate::color::Swatch]>>);
49
50    /// Reads the menu indent step.
51    fn menu_indent(&self) -> crate::menu::MenuIndent;
52
53    /// Sets how far each [`crate::menu::Item::indented`] level moves a row in,
54    /// and refreshes windows. Defaults to 12px.
55    fn set_menu_indent(&mut self, indent: crate::menu::MenuIndent);
56
57    /// The compact menu height, in rows. Defaults to 12.
58    fn menu_height(&self) -> crate::menu::MenuHeight;
59
60    fn set_menu_height(&mut self, height: crate::menu::MenuHeight);
61
62    /// Reads the menu panel widths.
63    fn menu_width(&self) -> crate::menu::MenuWidth;
64
65    /// Sets how wide menu panels sit, and refreshes windows. Defaults to
66    /// 180px at least, and exactly 280px for a panel with a described row.
67    fn set_menu_width(&mut self, width: crate::menu::MenuWidth);
68}
69
70impl AppExt for App {
71    fn caption_style(&self) -> crate::titlebar::CaptionStyle {
72        crate::titlebar::caption_style(self)
73    }
74
75    fn set_caption_style(&mut self, style: crate::titlebar::CaptionStyle) {
76        self.set_global(style);
77        self.refresh_windows();
78    }
79
80    fn caret_blink(&self) -> bool {
81        crate::input::caret_blink(self)
82    }
83
84    fn set_caret_blink(&mut self, blink: bool) {
85        crate::input::set_caret_blink(blink, self)
86    }
87
88    fn caret_shape(&self) -> crate::input::CaretShape {
89        crate::input::caret::caret_shape(self)
90    }
91
92    fn set_caret_shape(&mut self, shape: crate::input::CaretShape) {
93        crate::input::caret::set_caret_shape(shape, self)
94    }
95
96    fn caret_height(&self) -> crate::input::CaretHeight {
97        crate::input::caret::caret_height(self)
98    }
99
100    fn set_caret_height(&mut self, height: crate::input::CaretHeight) {
101        crate::input::caret::set_caret_height(height, self)
102    }
103
104    fn inactive_caret(&self) -> crate::input::InactiveCaret {
105        crate::input::caret::inactive_caret(self)
106    }
107
108    fn set_inactive_caret(&mut self, inactive: crate::input::InactiveCaret) {
109        crate::input::caret::set_inactive_caret(inactive, self)
110    }
111
112    fn scrollbar_visibility(&self) -> crate::scroll::Visibility {
113        crate::scroll::overlay::visibility(self)
114    }
115
116    fn set_scrollbar_visibility(&mut self, value: crate::scroll::Visibility) {
117        crate::scroll::overlay::set_visibility(value, self)
118    }
119
120    fn color_swatches(&self) -> std::rc::Rc<[crate::color::Swatch]> {
121        crate::color::swatches(self)
122    }
123
124    fn set_color_swatches(&mut self, set: impl Into<std::rc::Rc<[crate::color::Swatch]>>) {
125        crate::color::set_swatches(set, self)
126    }
127
128    fn menu_indent(&self) -> crate::menu::MenuIndent {
129        crate::menu::indent(self)
130    }
131
132    fn set_menu_indent(&mut self, indent: crate::menu::MenuIndent) {
133        crate::menu::set_indent(indent, self)
134    }
135
136    fn menu_height(&self) -> crate::menu::MenuHeight {
137        crate::menu::height(self)
138    }
139
140    fn set_menu_height(&mut self, height: crate::menu::MenuHeight) {
141        crate::menu::set_height(height, self)
142    }
143
144    fn menu_width(&self) -> crate::menu::MenuWidth {
145        crate::menu::width(self)
146    }
147
148    fn set_menu_width(&mut self, width: crate::menu::MenuWidth) {
149        crate::menu::set_width(width, self)
150    }
151}