egui_macview/lib.rs
1#![doc = include_str!("../README.md")]
2//!
3//! Grounded in Apple AppKit, macOS Human Interface Guidelines (HIG), and W3C DTCG Design Tokens.
4//!
5//! # Architecture & Highlights
6//!
7//! - **Authentic Control Primitives**: Complete macOS AppKit controls including [`MacToggle`], [`MacSlider`],
8//! [`MacSegmentedControl`], [`MacPopUpButton`], [`MacSearchField`], [`MacStepper`], [`MacColorWell`],
9//! [`MacOutlineView`], [`MacButtonCell`], [`MacInputCell`], and [`MacThumbnailCell`].
10//! - **Deterministic Layout Engines**: Subpixel-snapped linear [`MacStackView`] (`NSStackView`), draggable hairline [`MacSplitView`] (`NSSplitView`),
11//! zero-gutter floating overlay [`MacScrollView`] (`NSScrollView`), absolute [`MacFixedView`], and autolayout [`MacRow`].
12//! - **CoreAnimation Physics**: Analytical spring physics runtime [`CASpring`] matching Apple's `CASpringAnimation`
13//! and SwiftUI `.spring(response:dampingRatio:)` with analytical displacement and velocity calculations.
14//! - **W3C DTCG Token Catalog & Theming**: Dynamic theming via [`MacTheme`] and [`MacAppearance`] supporting Aqua and DarkAqua
15//! appearances, configurable window control decorations via [`WindowControlsStyle`], and dynamic system accent colors.
16//! - **Subpixel Snapping**: Physical pixel boundary rounding via [`subpixel_snap`], [`subpixel_snap_pos`], and [`subpixel_snap_rect`].
17//!
18//! # Quick Start Example
19//!
20//! ```rust
21//! use egui_macview::{
22//! CASpring, MacAppearance, MacSlider, MacStackView, MacTheme, MacToggle,
23//! };
24//!
25//! # let ctx = egui::Context::default();
26//! # let mut output = ctx.run_ui(egui::RawInput::default(), |ui| {
27//! // 1. Initialize macOS dynamic theme (Aqua or DarkAqua)
28//! let theme = MacTheme::new(MacAppearance::DarkAqua);
29//!
30//! // 2. Assemble controls inside an NSStackView linear layout
31//! let mut enabled = true;
32//! let mut volume = 75.0f32;
33//!
34//! MacStackView::vertical()
35//! .theme(&theme)
36//! .show_separators(true)
37//! .show(ui, |stack| {
38//! stack.add(|ui| {
39//! ui.add(MacToggle::new(&mut enabled).theme(&theme));
40//! });
41//! stack.add(|ui| {
42//! MacSlider::new(&mut volume, 0.0..=100.0)
43//! .theme(&theme)
44//! .ticks(5, true)
45//! .show(ui);
46//! });
47//! });
48//!
49//! // 3. Analytical spring physics evaluation
50//! let spring = CASpring::new(0.35, 0.85);
51//! let displacement = spring.evaluate(0.15); // t = 150ms
52//! # assert!(displacement > 0.0);
53//! # });
54//! # output.textures_delta.clear();
55//! ```
56
57#![deny(missing_docs)]
58
59/// Crate release version string extracted from `Cargo.toml`.
60pub const VERSION: &str = env!("CARGO_PKG_VERSION");
61
62pub mod controls;
63pub mod feedback;
64pub mod layout;
65pub mod motion;
66pub mod navigation;
67pub mod state;
68pub mod surfaces;
69pub mod symbols;
70pub mod theme;
71pub mod tokens;
72
73pub use symbols::{
74 setup_symbols_font, MacSymbol, CUPERTINO_ICONS_FONT_BYTES, CUPERTINO_ICONS_FONT_NAME,
75};
76
77pub use theme::{
78 contrast_ratio, relative_luminance, MacAppearance, MacBackgroundStyle, MacTheme,
79 WindowControlsStyle,
80};
81
82pub use controls::{
83 calculate_pan_weights, MacButtonCell, MacCircularSlider, MacColorWell, MacControlSize,
84 MacInputCell, MacLevelIndicator, MacLevelIndicatorStyle, MacLevelOrientation, MacOutlineRow,
85 MacOutlineRowResponse, MacOutlineTree, MacOutlineView, MacPathComponent, MacPathControl,
86 MacPathControlResponse, MacPopUpButton, MacProgressControlSize, MacProgressIndicator,
87 MacProgressStyle, MacRatingIndicator, MacSearchField, MacSegmentedControl, MacSlider,
88 MacSortDirection, MacStepper, MacTableColumn, MacTableView, MacTableViewOutput,
89 MacTableViewResponse, MacThumbnailCell, MacTimelineZone, MacToggle, MacTokenField,
90 MacTrimScrubber, MacTrimScrubberResponse, UNIT_STAR,
91};
92pub use feedback::{clamp_menu_rect, MacContextMenu, MacToast, MacToastManager, ToastLevel};
93pub use layout::{
94 is_window_active, subpixel_snap, subpixel_snap_pos, subpixel_snap_rect, MacFixedView, MacForm,
95 MacFormUi, MacFrame, MacRow, MacScrollView, MacScrollViewOutput, MacSplitOrientation,
96 MacSplitView, MacStackAlignment, MacStackOrientation, MacStackUi, MacStackView,
97 MacStackViewOutput,
98};
99pub use motion::CASpring;
100pub use navigation::{
101 CommandPaletteItem, MacCanvasFooter, MacCanvasFooterAction, MacCommandPalette,
102 MacKeyboardShortcut, MacMenuBar, MacMenuItemKind, MacToolbar, MacToolbarResponse, NSMenu,
103 NSMenuItem, CANVAS_FOOTER_HEIGHT, COMMAND_PALETTE_HEIGHT, COMMAND_PALETTE_WIDTH,
104};
105pub use state::{NSUndoManager, DEFAULT_UNDO_CAPACITY};
106pub use surfaces::{MacCard, MacFloatingInfoBox, MacPanel, MacPopover, MacPopoverArrowEdge};
107pub use tokens::{
108 sf_pro_tracking, ColorWellMetrics, LayoutMetrics, LevelIndicatorMetrics, MacColorTokens,
109 MacControlMetrics, MacDesignTokens, MacMotionTokens, MacTypographyTokens, OutlineViewMetrics,
110 PathControlMetrics, PopUpButtonMetrics, ProgressIndicatorMetrics, ProgressSizeMetrics,
111 ScrollViewMetrics, SearchFieldMetrics, SliderMetrics, SplitViewMetrics, StackViewMetrics,
112 StepperMetrics, TableViewMetrics, ThumbnailCellMetrics, ToggleMetrics, TokenFieldMetrics,
113 TrimScrubberMetrics,
114};