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 clipboard;
30pub mod color;
31pub mod cursor;
32pub mod device_scale;
33pub mod draw_ctx;
34pub mod event;
35pub mod font_settings;
36pub mod framebuffer;
37pub mod geometry;
38pub mod gfx_ctx;
39pub mod gl_renderer;
40pub mod layout_props;
41pub mod lcd_coverage;
42pub mod lcd_gfx_ctx;
43pub mod persistence;
44pub mod pixel_bounds;
45pub mod platform;
46pub mod screenshot;
47pub mod svg;
48pub mod text;
49pub mod theme;
50pub mod timestep;
51pub mod touch_state;
52pub mod undo;
53#[cfg(target_arch = "wasm32")]
54pub mod wasm_clipboard;
55pub mod widget;
56pub mod widgets;
57
58/// Adapter helpers bridging `winit` types (keyboard, mouse, modifiers,
59/// cursor) to this crate's input/cursor types.  Enabled with the
60/// `winit-adapter` feature so consumers that don't use winit don't pull
61/// the dep.
62#[cfg(feature = "winit-adapter")]
63pub mod winit_adapter;
64
65/// Adapter helpers for web/JS targets — DOM KeyboardEvent key-string →
66/// [`Key`] parser and CSS cursor-name for [`CursorIcon`].  Compiled only
67/// for `wasm32` targets.
68#[cfg(target_arch = "wasm32")]
69pub mod web_adapter;
70
71// Re-export the most commonly used types at the crate root.
72pub use app_state::{OsWindowHandle, OsWindowState};
73pub use color::Color;
74pub use cursor::{current_cursor_icon, reset_cursor_icon, set_cursor_icon, CursorIcon};
75pub use device_scale::{device_scale, set_device_scale};
76pub use draw_ctx::{DrawCtx, FillRule, GlPaint};
77pub use event::{Event, EventResult, Key, Modifiers, MouseButton};
78pub use font_settings::current_typography_epoch;
79pub use framebuffer::Framebuffer;
80pub use geometry::{Point, Rect, Size};
81pub use gfx_ctx::GfxCtx;
82pub use layout_props::{resolve_fit_or_stretch, HAnchor, Insets, VAnchor, WidgetBase};
83pub use platform::{current_platform, platform_from_name, set_platform, Platform};
84pub use screenshot::ScreenshotHandle;
85pub use svg::{
86    compare_svg_rgba, parse_svg, render_svg, render_svg_at_size, render_svg_at_size_with_options,
87    render_svg_at_size_with_resources, render_svg_to_framebuffer,
88    render_svg_to_framebuffer_at_size, render_svg_to_framebuffer_at_size_with_options,
89    render_svg_to_framebuffer_at_size_with_resources, render_svg_to_framebuffer_with_options,
90    render_svg_to_lcd_buffer, render_svg_to_lcd_buffer_at_size,
91    render_svg_to_lcd_buffer_at_size_with_options, render_svg_to_lcd_buffer_at_size_with_resources,
92    render_svg_to_lcd_buffer_with_options, render_svg_tree, render_svg_tree_at_size,
93    render_svg_tree_to_framebuffer, render_svg_tree_to_framebuffer_at_size,
94    render_svg_tree_to_lcd_buffer, render_svg_tree_to_lcd_buffer_at_size, render_svg_with_options,
95    set_default_svg_parse_options, svg_fontdb_from_font_data, SvgCompareResult,
96    SvgCompareThresholds, SvgParseOptions, SvgRenderError, DEFAULT_ALPHA_TOLERANCE,
97    DEFAULT_MISMATCH_RATIO, DEFAULT_OPAQUE_RGB_TOLERANCE, DEFAULT_TRANSLUCENT_RGB_TOLERANCE,
98    DEFAULT_VISUAL_RGB_TOLERANCE,
99};
100pub use text::{measure_text_metrics, Font, TextMetrics};
101pub use theme::{
102    current_visuals, current_visuals_epoch, set_visuals, AccentColor, ThemePreference, Visuals,
103};
104pub use timestep::{FixedTimestep, StepBatch, FIXED_DT, MAX_STEPS_PER_DRAW, SIMULATION_HZ};
105pub use touch_state::{current_multi_touch, MultiTouchInfo, TouchDeviceId, TouchId, TouchPhase};
106pub use undo::{DoUndoActions, UndoBuffer, UndoRedoCommand};
107pub use widget::{
108    apply_widget_base_edit, collect_inspector_nodes, current_mouse_world, current_viewport,
109    find_widget_by_id, find_widget_by_id_mut, find_widget_by_type, App, BackbufferKind,
110    BackbufferSpec, BackbufferState, InspectorNode, InspectorOverlay, Widget, WidgetBaseEdit,
111    WidgetBaseField,
112};
113#[cfg(feature = "reflect")]
114pub use widget::{
115    apply_inspector_edit, reflect_fields, InspectorEdit,
116};
117pub use widgets::{
118    current_scroll_style, current_scroll_visibility, set_scroll_style, set_scroll_visibility,
119    Button, Checkbox, CollapsingHeader, ColorPicker, ComboBox, Conditional, Container, DragValue,
120    FlexColumn, FlexRow, Hyperlink, ImageView, InspectorPanel, InspectorSavedState, Label, LabelAlign,
121    MarkdownView, MenuBar, MenuEntry, MenuItem, MenuResponse, MenuSelection, MenuShortcut,
122    NodeIcon, Padding, PopupMenu, ProgressBar, RadioGroup, Resize, ScrollBarColor, ScrollBarKind,
123    ScrollBarStyle, ScrollBarVisibility, ScrollView, Separator, ShortcutKey, SizedBox, Slider,
124    CellInfo, HeaderInfo, Spacer, Splitter, Stack, TabView, Table, TableBuilder, TableColumn,
125    TableRows, TextArea, TextField, ToggleSwitch, Tooltip, TopMenu, TreeView, Window,
126};
127
128// Re-export AGG types so callers don't need to import agg-rust directly.
129pub use agg_rust::comp_op::CompOp;
130pub use agg_rust::math_stroke::{LineCap, LineJoin};
131pub use agg_rust::trans_affine::TransAffine;
132
133#[cfg(test)]
134mod tests;