Skip to main content

gpui_component/
lib.rs

1use gpui::App;
2use std::ops::Deref;
3use std::sync::LazyLock;
4
5mod component_traits;
6mod element_ext;
7pub mod global_state;
8mod icon;
9mod index_path;
10#[cfg(any(feature = "inspector", debug_assertions))]
11mod inspector;
12mod root;
13mod sizing;
14mod styled;
15mod time;
16mod title_bar;
17mod touch_selection;
18mod virtual_list;
19mod window_border;
20mod window_ext;
21
22pub(crate) mod actions {
23    pub use gpui_base::actions::*;
24}
25
26pub mod accordion;
27pub mod alert;
28pub mod attachment;
29pub mod avatar;
30pub mod badge;
31pub mod breadcrumb;
32pub mod bubble;
33pub mod button;
34pub mod carousel;
35pub mod chart;
36pub mod checkbox;
37pub mod clipboard;
38pub mod collapsible;
39pub mod color_picker;
40pub mod combobox;
41pub mod command;
42pub mod description_list;
43pub mod dialog;
44pub mod dock;
45pub mod empty;
46pub mod form;
47pub mod group_box;
48pub mod highlighter;
49pub mod history;
50pub mod hover_card;
51pub mod input;
52pub mod kbd;
53pub mod label;
54pub mod link;
55pub mod list;
56pub mod marker;
57pub mod menu;
58pub mod message;
59pub mod message_scroller;
60pub mod native_menu;
61pub mod notification;
62pub mod pagination;
63pub mod plot;
64pub mod popover;
65pub mod progress;
66pub mod questionnaire;
67pub mod radio;
68pub mod rating;
69pub mod resizable;
70pub mod scroll;
71pub mod searchable_list;
72pub mod select;
73pub mod separator;
74pub mod setting;
75pub mod sheet;
76pub mod shimmer;
77pub mod sidebar;
78pub mod skeleton;
79pub mod slider;
80pub mod speech;
81pub mod spinner;
82pub mod status_bar;
83pub mod stepper;
84pub mod switch;
85pub mod tab;
86pub mod table;
87pub mod tag;
88pub mod text;
89pub mod theme;
90pub mod toolbar;
91pub mod tooltip;
92pub mod tree;
93
94pub use crate::Disableable;
95pub use element_ext::*;
96pub use global_state::GlobalState;
97pub use gpui_base::Root;
98pub use gpui_base::animation;
99#[doc(hidden)]
100pub(crate) use gpui_base::resize_handle;
101pub use gpui_base::{
102    AxisExt, Edges, FocusTrapElement, InteractiveElementExt, LengthExt, Measure, OngoingScrollExt,
103    Placement, Side, measure, measure_if,
104};
105pub use gpui_component_macros::icon_named;
106pub use icon::*;
107pub use index_path::IndexPath;
108pub use input::{Rope, RopeExt, RopeLines};
109#[cfg(any(feature = "inspector", debug_assertions))]
110pub use inspector::*;
111pub use resizable::{
112    ResizablePanel, ResizablePanelEvent, ResizablePanelGroup, ResizableState, h_resizable,
113    resizable_panel, resize_handle_appearance, v_resizable,
114};
115pub use styled::*;
116pub use theme::*;
117pub use time::{calendar, date_picker, time_field};
118pub use title_bar::*;
119pub use virtual_list::{VirtualList, VirtualListScrollHandle, h_virtual_list, v_virtual_list};
120pub use window_border::{WindowBorder, window_border, window_paddings};
121pub use window_ext::WindowExt;
122
123rust_i18n::i18n!("locales", fallback = "en");
124
125/// Initialize the components.
126///
127/// You must initialize the components at your application's entry point.
128pub fn init(cx: &mut App) {
129    theme::init(cx);
130    global_state::init(cx);
131    #[cfg(any(feature = "inspector", debug_assertions))]
132    inspector::init(cx);
133    root::init(cx);
134    gpui_base::init(cx);
135    input::init(cx);
136    date_picker::init(cx);
137    dock::init(cx);
138    sheet::init(cx);
139    list::init(cx);
140    command::init(cx);
141    carousel::init(cx);
142    notification::init(cx);
143    popover::init(cx);
144    questionnaire::init(cx);
145    menu::init(cx);
146    table::init(cx);
147    tooltip::init(cx);
148}
149
150#[inline]
151pub fn locale() -> impl Deref<Target = str> {
152    rust_i18n::locale()
153}
154
155#[inline]
156pub fn set_locale(locale: &str) {
157    rust_i18n::set_locale(locale)
158}
159
160/// Whether measurement logging is enabled, read once per process.
161///
162/// Measurement is a startup debug flag, and the table queries it for every
163/// rendered cell, so cache it instead of reading the environment each call.
164#[inline]
165pub(crate) fn measure_enable() -> bool {
166    static MEASURE_ENABLED: LazyLock<bool> = LazyLock::new(gpui_base::measurement_enabled);
167    *MEASURE_ENABLED
168}