Skip to main content

gpui_base/
lib.rs

1//! Behavior and infrastructure foundations for GPUI applications.
2//!
3//! Primitives deliberately avoid presentation styles. Layout, positioning,
4//! colors, sizing, and motion belong to applications or the
5//! `gpui-component` façade.
6
7mod accordion;
8pub mod actions;
9mod alert_dialog;
10pub mod animation;
11#[doc(hidden)]
12pub mod async_util;
13mod auto_scroll;
14mod avatar;
15mod button;
16mod calendar;
17mod checkbox;
18mod collapsible;
19mod color_picker;
20mod combobox;
21pub mod component_traits;
22mod date_picker;
23mod dialog;
24pub mod dock;
25mod element_ext;
26mod event;
27mod focus_trap;
28mod geometry;
29mod global_state;
30mod history;
31mod hover_card;
32mod index_path;
33pub mod input;
34mod link;
35mod list_settings;
36#[cfg(all(target_os = "macos", not(test)))]
37mod macos_accessibility;
38mod measure;
39pub mod motion;
40mod nav_stack;
41mod number_input;
42mod observe;
43mod otp_input;
44mod pagination;
45mod popover;
46mod popup;
47mod positioner;
48mod progress;
49mod radio;
50mod radio_group;
51mod reduce_motion;
52mod resizable;
53mod scroll_bounce;
54mod scrollable_mask;
55mod scrollbar;
56mod select;
57mod selectable_text;
58mod sheet;
59pub mod slider;
60mod state_style;
61mod styled;
62mod switch;
63mod table;
64mod tabs;
65pub mod text;
66mod text_boundary;
67mod text_selection;
68mod theme;
69pub mod theme_tokens;
70mod toast;
71mod toggle;
72mod toggle_group;
73mod tooltip;
74mod touch_selection;
75mod tree;
76mod undo_history;
77mod virtual_list;
78
79pub use accordion::{Accordion, AccordionHeader, AccordionItem, AccordionPanel, AccordionTrigger};
80pub use alert_dialog::{
81    AlertDialog, AlertDialogAction, AlertDialogBackdrop, AlertDialogCancel, AlertDialogClose,
82    AlertDialogDescription, AlertDialogPopup, AlertDialogTitle, AlertDialogTrigger,
83};
84pub use auto_scroll::AutoScroll;
85pub use avatar::{Avatar, AvatarFallback, AvatarImage};
86pub use button::{Button, ButtonStyles};
87pub use calendar::{
88    Calendar, CalendarEvent, CalendarItem, CalendarItemKind, CalendarItemState, CalendarState,
89    CalendarView, Date, IntervalMatcher, Matcher, RangeMatcher,
90};
91pub use checkbox::{
92    Checkbox, CheckboxIndicator, CheckboxIndicatorStyles, CheckboxState, CheckboxStyles,
93};
94pub use collapsible::Collapsible;
95pub use color_picker::{ColorPicker, ColorPickerEvent, ColorPickerState, ColorSwatch, HslaSliders};
96pub use combobox::Combobox;
97pub use component_traits::FocusableExt;
98pub use component_traits::{Disableable, Selectable};
99pub use date_picker::DatePicker;
100pub use dialog::{
101    Dialog, DialogBackdrop, DialogChangeReason, DialogClose, DialogDescription, DialogHandle,
102    DialogPopup, DialogTitle, DialogTrigger,
103};
104pub use element_ext::ElementExt;
105pub use event::{InteractiveElementExt, OngoingScrollExt};
106pub use focus_trap::FocusTrapElement;
107#[doc(hidden)]
108pub use focus_trap::active_focus_trap;
109pub use geometry::*;
110pub use global_state::{DeferredPopover, GlobalState};
111pub use history::History;
112pub use hover_card::{HoverCard, HoverCardState};
113pub use index_path::IndexPath;
114pub use input::{Editor, Input, InputBase, InputStyles, Textarea};
115pub use link::{Link, LinkStyles};
116pub use list_settings::ListSettings;
117#[cfg(all(target_os = "macos", not(test)))]
118#[doc(hidden)]
119pub use macos_accessibility::install_window_hit_test_forwarder;
120#[doc(hidden)]
121pub use measure::measurement_enabled;
122pub use measure::{Measure, measure, measure_if};
123pub use motion::{
124    Discrete, DiscreteError, Easing, EasingError, Interpolate, IterationCount, Keyframe,
125    KeyframeError, Keyframes, LinearStop, MotionPhase, MotionReveal, MotionStatus, MotionTransform,
126    MotionValue, PlaybackDirection, Presence, PresencePhase, PresenceSample, Sequence,
127    SequenceSample, SequenceStep, SignedDuration, Spring, SpringError, Stagger, StaggerOrigin,
128    StepPosition, Timing, TimingSample, Transition, TransitionId, animate_keyframes, spring,
129    transition, transition_with_status,
130};
131pub use nav_stack::{NavMotion, NavOperation, NavPage, NavStack, NavStackEvent, NavStackState};
132pub use number_input::{
133    Decrement, Increment, NumberInput, NumberInputEvent, NumberInputText, NumberStep, StepAction,
134    step_value,
135};
136pub use observe::{ObservedElement, TestSupportExt};
137pub use otp_input::{OtpEvent, OtpInput, OtpState};
138pub use pagination::{Pagination, PaginationItem, PaginationState};
139pub use popover::{Popover, PopoverState};
140pub use popup::{POPUP_PRIORITY, Popup};
141pub use positioner::{Align, Positioner, ResolvedPosition};
142pub use progress::{Progress, ProgressIndicator, ProgressTrack};
143pub use radio::{Radio, RadioStyles};
144pub use radio_group::RadioGroup;
145pub use reduce_motion::apply_system_reduce_motion;
146#[doc(hidden)]
147pub use resizable::{PANEL_MIN_SIZE, resize_handle};
148pub use resizable::{
149    ResizablePanel, ResizablePanelEvent, ResizablePanelGroup, ResizableState, ResizeHandleContext,
150    ResizeHandleRenderer, h_resizable, resizable_panel, v_resizable,
151};
152pub use scroll_bounce::{ScrollBounce, ScrollBounceMotion};
153pub use scrollable_mask::ScrollableMask;
154pub use scrollbar::{
155    Scrollbar, ScrollbarAxis, ScrollbarEntrance, ScrollbarHandle, ScrollbarMode, ScrollbarMotion,
156    ScrollbarStyles, ScrollbarThumbStyle, ScrollbarTrackStyle,
157};
158pub use select::Select;
159pub use selectable_text::SelectableText;
160pub use sheet::Sheet;
161pub use slider::{Slider, SliderIndicator, SliderThumb, SliderTrack};
162pub use state_style::StateStyle;
163#[cfg(any(feature = "inspector", debug_assertions))]
164pub use styled::styled_ext_reflection_methods;
165pub use styled::{RoleOverride, StyledExt, box_shadow, h_flex, v_flex};
166pub use switch::{
167    Switch, SwitchStyles, SwitchThumb, SwitchThumbStyles, SwitchTrack, SwitchTrackStyles,
168};
169pub use table::{Table, TableBody, TableCaption, TableCell, TableHead, TableHeader, TableRow};
170pub use tabs::{Tab, TabStyles, Tabs};
171pub use text::{
172    InlineElement, InlineRenderContext, MarkdownExtensions, MarkdownNode, MarkdownParseContext,
173    MarkdownPlugin, SelectionFormat, TableData, Text, TextView, TextViewDefaults, TextViewMotion,
174    TextViewPlugin, TextViewState, TextViewStyle, html, markdown, markdown_ast,
175};
176pub use text_selection::{
177    TextSelection, TextSelectionContentKey, TextSelectionCoverage, TextSelectionEndpoint,
178    TextSelectionEvent, TextSelectionHandle, TextSelectionLayer, TextSelectionProjection,
179    TextSelectionRegistration, TextSelectionRun, TextSelectionScopeId, TextSelectionSnapshot,
180    TextSelectionWindowPoints, TouchHandleLayout,
181};
182pub use theme::{ResizableTheme, ScrollbarTheme, Theme, ThemeAppearance};
183pub use theme_tokens::{
184    ColorTokens, RadiusTokens, SemanticThemeTokens, ShadowTokens, SpacingTokens, TextStyleToken,
185    TypographyTokens,
186};
187pub use toast::{
188    Toast, ToastAdvance, ToastManager, ToastMotion, ToastOptions, ToastStack, ToastStackState,
189    ToastTransitionStatus,
190};
191pub use toggle::{Toggle, ToggleStyles};
192pub use toggle_group::ToggleGroup;
193pub use tooltip::{Tooltip, TooltipOverlay, TooltipPositioner, TooltipRequest, TooltipTransition};
194pub use touch_selection::{SelectionEdge, TouchHandle, TouchSelectionSnapshot};
195pub use tree::{Tree, TreeEntry, TreeEntryState, TreeEvent, TreeItem, TreeState};
196#[doc(hidden)]
197pub use tree::{init as init_tree, key_context as tree_key_context};
198pub use undo_history::UndoHistory;
199#[doc(hidden)]
200pub use virtual_list::virtual_list;
201pub use virtual_list::{VirtualList, VirtualListScrollHandle, h_virtual_list, v_virtual_list};
202
203use gpui::App;
204
205/// Returns whether the application is compiled for iOS or Android.
206///
207/// This is a compile-time platform check, not a screen-size or input-device check.
208#[inline]
209pub const fn is_mobile() -> bool {
210    cfg!(any(target_os = "ios", target_os = "android"))
211}
212
213/// Initializes global infrastructure owned by the base layer.
214pub fn init(cx: &mut App) {
215    let _ = Theme::global_mut(cx);
216    GlobalState::init(cx);
217    reduce_motion::init(cx);
218    dialog::init(cx);
219    focus_trap::init(cx);
220    popover::init(cx);
221    sheet::init(cx);
222    combobox::init(cx);
223    color_picker::init(cx);
224    select::init(cx);
225    number_input::init(cx);
226    input::init(cx);
227    tree::init(cx);
228    text::init(cx);
229}
230
231#[cfg(feature = "test-support")]
232pub mod test_support;