Skip to main content

agg_gui/
lib.rs

1//! # agg-gui
2//!
3//! A Rust GUI framework built on [AGG](https://github.com/larsbrubaker/agg-rust)
4//! (Anti-Grain Geometry).
5//!
6//! ## Architecture
7//!
8//! ```text
9//! Application / Widgets
10//!   │
11//! GfxCtx (Cairo-style stateful 2D drawing API)
12//!   │
13//! AGG (rasterization) + Clipper2 (boolean geometry)
14//!   │
15//! Framebuffer (RGBA8, bottom-up Y-up row order)
16//!   │
17//! Platform (WGL native / WebGL WASM)
18//! ```
19//!
20//! ## Coordinate system
21//!
22//! The entire framework uses **first-quadrant (Y-up)** coordinates throughout.
23//! Origin is the bottom-left corner of the window. Positive Y goes upward.
24//! This is a non-negotiable architectural invariant — see the dev plan for
25//! the rationale.
26
27pub mod animation;
28pub mod app_state;
29pub mod color;
30pub mod cursor;
31pub mod device_scale;
32pub mod undo;
33#[cfg(target_arch = "wasm32")]
34pub mod wasm_clipboard;
35pub mod draw_ctx;
36pub mod event;
37pub mod framebuffer;
38pub mod geometry;
39pub mod gfx_ctx;
40pub mod gl_renderer;
41pub mod font_settings;
42pub mod pixel_bounds;
43pub mod lcd_coverage;
44pub mod lcd_gfx_ctx;
45pub mod layout_props;
46pub mod screenshot;
47pub mod text;
48pub mod touch_state;
49pub mod persistence;
50pub mod theme;
51pub mod widget;
52pub mod widgets;
53
54/// Adapter helpers bridging `winit` types (keyboard, mouse, modifiers,
55/// cursor) to this crate's input/cursor types.  Enabled with the
56/// `winit-adapter` feature so consumers that don't use winit don't pull
57/// the dep.
58#[cfg(feature = "winit-adapter")]
59pub mod winit_adapter;
60
61/// Adapter helpers for web/JS targets — DOM KeyboardEvent key-string →
62/// [`Key`] parser and CSS cursor-name for [`CursorIcon`].  Compiled only
63/// for `wasm32` targets.
64#[cfg(target_arch = "wasm32")]
65pub mod web_adapter;
66
67// Re-export the most commonly used types at the crate root.
68pub use app_state::{OsWindowHandle, OsWindowState};
69pub use screenshot::ScreenshotHandle;
70pub use color::Color;
71pub use cursor::{CursorIcon, current_cursor_icon, set_cursor_icon, reset_cursor_icon};
72pub use device_scale::{device_scale, set_device_scale};
73pub use draw_ctx::{DrawCtx, GlPaint};
74pub use theme::{ThemePreference, Visuals, current_visuals, current_visuals_epoch, set_visuals};
75pub use font_settings::current_typography_epoch;
76pub use event::{Event, EventResult, Key, Modifiers, MouseButton};
77pub use framebuffer::Framebuffer;
78pub use geometry::{Point, Rect, Size};
79pub use gfx_ctx::GfxCtx;
80pub use layout_props::{HAnchor, Insets, VAnchor, WidgetBase, resolve_fit_or_stretch};
81pub use text::{Font, TextMetrics, measure_text_metrics};
82pub use touch_state::{current_multi_touch, MultiTouchInfo, TouchDeviceId, TouchId, TouchPhase};
83pub use undo::{DoUndoActions, UndoBuffer, UndoRedoCommand};
84pub use widget::{App, InspectorNode, Widget, collect_inspector_nodes};
85pub use widgets::{Button, Checkbox, ColorPicker, CollapsingHeader, ComboBox, Container, DragValue, FlexColumn, FlexRow,
86                  Hyperlink, ImageView, InspectorPanel, InspectorSavedState,
87                  Label, LabelAlign, MarkdownView, NodeIcon, Padding, ProgressBar, RadioGroup,
88                  ScrollBarColor, ScrollBarKind, ScrollBarStyle, ScrollBarVisibility,
89                  ScrollView, Separator, SizedBox, Slider, Spacer, Splitter, Stack,
90                  TabView, TextField, ToggleSwitch, Tooltip, TreeView, Window,
91                  current_scroll_style, current_scroll_visibility,
92                  set_scroll_style, set_scroll_visibility};
93
94// Re-export AGG types so callers don't need to import agg-rust directly.
95pub use agg_rust::trans_affine::TransAffine;
96pub use agg_rust::math_stroke::{LineCap, LineJoin};
97pub use agg_rust::comp_op::CompOp;
98
99#[cfg(test)]
100mod tests;