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 resizable;
52mod scrollable_mask;
53mod scrollbar;
54mod select;
55mod selectable_text;
56mod sheet;
57pub mod slider;
58mod state_style;
59mod styled;
60mod switch;
61mod table;
62mod tabs;
63pub mod text;
64mod text_boundary;
65mod text_selection;
66mod theme;
67pub mod theme_tokens;
68mod toast;
69mod toggle;
70mod toggle_group;
71mod tooltip;
72mod tree;
73mod undo_history;
74mod virtual_list;
75
76pub use accordion::{Accordion, AccordionHeader, AccordionItem, AccordionPanel, AccordionTrigger};
77pub use alert_dialog::{
78    AlertDialog, AlertDialogAction, AlertDialogBackdrop, AlertDialogCancel, AlertDialogClose,
79    AlertDialogDescription, AlertDialogPopup, AlertDialogTitle, AlertDialogTrigger,
80};
81pub use auto_scroll::AutoScroll;
82pub use avatar::{Avatar, AvatarFallback, AvatarImage};
83pub use button::{Button, ButtonStyles};
84pub use calendar::{
85    Calendar, CalendarEvent, CalendarItem, CalendarItemKind, CalendarItemState, CalendarState,
86    CalendarView, Date, IntervalMatcher, Matcher, RangeMatcher,
87};
88pub use checkbox::{
89    Checkbox, CheckboxIndicator, CheckboxIndicatorStyles, CheckboxState, CheckboxStyles,
90};
91pub use collapsible::Collapsible;
92pub use color_picker::{ColorPicker, ColorPickerEvent, ColorPickerState, ColorSwatch, HslaSliders};
93pub use combobox::Combobox;
94pub use component_traits::FocusableExt;
95pub use component_traits::{Disableable, Selectable};
96pub use date_picker::DatePicker;
97pub use dialog::{
98    Dialog, DialogBackdrop, DialogChangeReason, DialogClose, DialogDescription, DialogHandle,
99    DialogPopup, DialogTitle, DialogTrigger,
100};
101pub use element_ext::ElementExt;
102pub use event::{InteractiveElementExt, OngoingScrollExt};
103pub use focus_trap::FocusTrapElement;
104#[doc(hidden)]
105pub use focus_trap::active_focus_trap;
106pub use geometry::*;
107pub use global_state::{DeferredPopover, GlobalState};
108pub use history::History;
109pub use hover_card::{HoverCard, HoverCardState};
110pub use index_path::IndexPath;
111pub use input::{Editor, Input, InputBase, InputStyles, Textarea};
112pub use link::{Link, LinkStyles};
113pub use list_settings::ListSettings;
114#[cfg(all(target_os = "macos", not(test)))]
115#[doc(hidden)]
116pub use macos_accessibility::install_window_hit_test_forwarder;
117#[doc(hidden)]
118pub use measure::measurement_enabled;
119pub use measure::{Measure, measure, measure_if};
120pub use motion::{
121    Discrete, DiscreteError, Easing, EasingError, Interpolate, IterationCount, Keyframe,
122    KeyframeError, Keyframes, LinearStop, MotionPhase, MotionReveal, MotionStatus, MotionTransform,
123    MotionValue, PlaybackDirection, Presence, PresencePhase, PresenceSample, SignedDuration,
124    Spring, SpringError, Stagger, StaggerOrigin, StepPosition, Timing, TimingSample, Transition,
125    TransitionId, animate_keyframes, spring, transition, transition_with_status,
126};
127pub use nav_stack::{NavMotion, NavOperation, NavPage, NavStack, NavStackEvent, NavStackState};
128pub use number_input::{
129    Decrement, Increment, NumberInput, NumberInputEvent, NumberInputText, NumberStep, StepAction,
130    step_value,
131};
132pub use observe::{ObservedElement, TestSupportExt};
133pub use otp_input::{OtpEvent, OtpInput, OtpState};
134pub use pagination::{Pagination, PaginationItem, PaginationState};
135pub use popover::{Popover, PopoverState};
136pub use popup::{POPUP_PRIORITY, Popup};
137pub use positioner::{Align, Positioner, ResolvedPosition};
138pub use progress::{Progress, ProgressIndicator, ProgressTrack};
139pub use radio::{Radio, RadioStyles};
140pub use radio_group::RadioGroup;
141#[doc(hidden)]
142pub use resizable::{PANEL_MIN_SIZE, resize_handle};
143pub use resizable::{
144    ResizablePanel, ResizablePanelEvent, ResizablePanelGroup, ResizableState, ResizeHandleContext,
145    ResizeHandleRenderer, h_resizable, resizable_panel, v_resizable,
146};
147pub use scrollable_mask::ScrollableMask;
148pub use scrollbar::{
149    Scrollbar, ScrollbarAxis, ScrollbarEntrance, ScrollbarHandle, ScrollbarMode, ScrollbarMotion,
150    ScrollbarStyles, ScrollbarThumbStyle, ScrollbarTrackStyle,
151};
152pub use select::Select;
153pub use selectable_text::SelectableText;
154pub use sheet::Sheet;
155pub use slider::{Slider, SliderIndicator, SliderThumb, SliderTrack};
156pub use state_style::StateStyle;
157#[cfg(any(feature = "inspector", debug_assertions))]
158pub use styled::styled_ext_reflection_methods;
159pub use styled::{RoleOverride, StyledExt, box_shadow, h_flex, v_flex};
160pub use switch::{
161    Switch, SwitchStyles, SwitchThumb, SwitchThumbStyles, SwitchTrack, SwitchTrackStyles,
162};
163pub use table::{Table, TableBody, TableCaption, TableCell, TableHead, TableHeader, TableRow};
164pub use tabs::{Tab, TabStyles, Tabs};
165pub use text::{
166    MarkdownExtensions, MarkdownNode, MarkdownPlugin, SelectionFormat, TableData, Text, TextView,
167    TextViewDefaults, TextViewPlugin, TextViewState, TextViewStyle, html, markdown,
168};
169pub use text_selection::{
170    TextSelection, TextSelectionContentKey, TextSelectionCoverage, TextSelectionEndpoint,
171    TextSelectionEvent, TextSelectionHandle, TextSelectionLayer, TextSelectionProjection,
172    TextSelectionRegistration, TextSelectionRun, TextSelectionScopeId, TextSelectionSnapshot,
173    TextSelectionWindowPoints,
174};
175pub use theme::{ResizableTheme, ScrollbarTheme, Theme, ThemeAppearance};
176pub use theme_tokens::{
177    ColorTokens, RadiusTokens, SemanticThemeTokens, ShadowTokens, SpacingTokens, TextStyleToken,
178    TypographyTokens,
179};
180pub use toast::{
181    Toast, ToastAdvance, ToastManager, ToastMotion, ToastOptions, ToastStack, ToastStackState,
182    ToastTransitionStatus,
183};
184pub use toggle::{Toggle, ToggleStyles};
185pub use toggle_group::ToggleGroup;
186pub use tooltip::{Tooltip, TooltipOverlay, TooltipPositioner, TooltipRequest, TooltipTransition};
187pub use tree::{Tree, TreeEntry, TreeEntryState, TreeEvent, TreeItem, TreeState};
188#[doc(hidden)]
189pub use tree::{init as init_tree, key_context as tree_key_context};
190pub use undo_history::UndoHistory;
191#[doc(hidden)]
192pub use virtual_list::virtual_list;
193pub use virtual_list::{VirtualList, VirtualListScrollHandle, h_virtual_list, v_virtual_list};
194
195use gpui::App;
196
197/// Initializes global infrastructure owned by the base layer.
198pub fn init(cx: &mut App) {
199    let _ = Theme::global_mut(cx);
200    GlobalState::init(cx);
201    dialog::init(cx);
202    focus_trap::init(cx);
203    popover::init(cx);
204    sheet::init(cx);
205    combobox::init(cx);
206    color_picker::init(cx);
207    select::init(cx);
208    number_input::init(cx);
209    input::init(cx);
210    tree::init(cx);
211    text::init(cx);
212}
213
214#[cfg(feature = "test-support")]
215pub mod test_support;