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