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