A modern, GPU-accelerated immediate-mode UI library for Rust, built on top of wgpu and winit. Gloomy provides a declarative, RON-based approach to building beautiful user interfaces with a focus on performance and flexibility.
- π¨ Theming System - Comprehensive theme support with semantic colors, global styles, and live theme switching
- π¦ Declarative UI - Define UIs using RON files or programmatically with a clean Rust API
- β‘ GPU-Accelerated - Hardware-accelerated rendering using
wgpuwith SDF-based primitives - πΌοΈ Rich Widgets - Buttons, labels, inputs, checkboxes, sliders, dropdowns, and more
- π Flexible Layouts - Flexbox-style layout engine with Row, Column, and Grid support
- π― Interactive - Full mouse and keyboard input handling with focus management
- π Scrolling - Scrollable containers with automatic overflow handling
- π Advanced Styling - Borders, shadows, gradients, corner radii (individual or uniform)
- π€ Text Rendering - TTF font support with multi-font capability
- πΌοΈ SVG Support - Vector graphics rendering
- π Dividers - Visual separators for horizontal and vertical layouts
- π¨ Custom Widgets - Easy to extend with custom widget types
Add Gloomy to your Cargo.toml:
[dependencies]
gloomy-app = "0.1.0"
gloomy-core = "0.1.0"use gloomy_app::GloomyApp;
use gloomy_core::{Widget, layout::*, ui::*, Vec2, style::*};
fn main() -> anyhow::Result<()> {
let mut ui = Widget::Container {
style: BoxStyle {
background: Some((0.12, 0.12, 0.12, 1.0)),
..Default::default()
},
padding: 20.0,
layout: Layout {
direction: Direction::Column,
spacing: 10.0,
..Default::default()
},
children: vec![
Widget::label("Hello, Gloomy!"),
Widget::Button {
text: "Click Me".to_string(),
action: "button_click".to_string(),
style: ButtonStyle {
idle: BoxStyle {
background: Some((0.3, 0.6, 1.0, 1.0)),
..Default::default()
},
..Default::default()
},
..Default::default()
},
],
..Default::default()
};
GloomyApp::new()
.on_draw(move |win, ctx| {
let size = win.renderer.size();
compute_layout(&mut ui, 0.0, 0.0, size.x, size.y);
render_ui(&ui, &mut win.renderer, ctx.device, ctx.queue, None);
})
.run()
}Gloomy comes with numerous examples demonstrating different features:
# Theme switching demo
cargo run --example theme_switcher
# Divider widget showcase
cargo run --example divider_demo
# Basic widgets
cargo run --example simple_starter
# Border styles
cargo run --example borders_showcase
# Complete widget showcase
cargo run --example widgets_ui
# Grid layouts
cargo run --example grid_ui
# Scrollable content
cargo run --example scroll_uiSee the examples/README.md for a complete list and descriptions.
Gloomy includes a powerful theming system with semantic colors and global style defaults.
use gloomy_core::{Theme, StyleContext};
// Use preset themes
let ctx = StyleContext::default(); // Dark theme + Modern style
// Or load from RON files
let theme = Theme::load("themes/dark.ron")?;
let ctx = StyleContext::new(theme, GlobalStyle::default());
// Switch themes at runtime
ctx.set_theme(Theme::light());- Dark - Modern dark theme (default)
- Light - Clean light theme
- High Contrast - Accessibility-focused high contrast theme
- Modern - Smooth corners, subtle shadows
- Classic - Sharp edges, no shadows
- Minimal - Subtle, clean design
Gloomy uses a flexbox-inspired layout system:
Layout {
direction: Direction::Column, // or Row, Grid
spacing: 16.0,
align_items: Align::Center,
justify_content: Justify::SpaceBetween,
..Default::default()
}Layout {
direction: Direction::Grid { columns: 3 },
template_columns: vec![1.0, 2.0, 1.0], // Proportional sizing
spacing: 10.0,
..Default::default()
}- Container - Layout container with optional scrolling
- Label - Text display
- Button - Clickable button with hover/active states
- TextInput - Single-line text input
- Checkbox - Toggle checkbox
- Slider - Value slider
- ToggleSwitch - On/off switch
- RadioButton - Radio button groups
- Dropdown - Selection dropdown
- ProgressBar - Progress indicator
- Image - Raster image display
- Icon - Icon rendering
- SVGImage - Vector graphics
- Divider - Visual separator
- DataGrid - Feature-rich table with sorting, resizing, Documentation
All widgets support extensive styling options via their style field:
Widget::Button {
style: ButtonStyle {
idle: BoxStyle {
background: Some((0.3, 0.6, 1.0, 1.0)),
border: Some(Border {
width: 2.0,
color: (1.0, 1.0, 1.0, 0.3),
..Default::default()
}),
corner_radii: [8.0; 4],
shadow: Some(Shadow {
offset: (0.0, 4.0),
blur: 8.0,
color: (0.0, 0.0, 0.0, 0.2),
}),
gradient: Some(Gradient {
start: (0.3, 0.6, 1.0, 1.0),
end: (0.2, 0.4, 0.8, 1.0),
}),
..Default::default()
},
hover: BoxStyle {
background: Some((0.4, 0.7, 1.0, 1.0)),
corner_radii: [8.0; 4],
..Default::default()
},
..Default::default()
},
..Default::default()
}gloomy/
βββ crates/
β βββ gloomy-core/ # Core UI rendering and widgets
β βββ gloomy-app/ # Application framework and event loop
β βββ gloomy-designer/ # Visual UI designer (in development)
βββ examples/ # Example applications
βββ themes/ # Theme configuration files
βββ styles/ # Style configuration files
βββ docs/ # Documentation
Gloomy is built on a modular architecture:
-
gloomy-core - Core rendering, widgets, layout engine
primitives- SDF-based shape renderingtext- TTF text rendering viawgpu-textwidget- Widget definitions and typesui- Rendering and interaction logiclayout_engine- Flexbox-style layout computationtheme- Theming system
-
gloomy-app - Application framework
- Window management via
winit - Event loop and input handling
- Callback-based API
- Window management via
# Build all crates
cargo build
# Build examples
cargo build --examples
# Run tests
cargo test
# Build documentation
cargo doc --openGloomy follows the Google Rust Style Guide:
- 79 character line limit
- Documentation comments above code
- Doxygen-compliant docstrings using
///
Tests are located in the tests/ directory:
cargo test- Widget Overview - List of all available widgets
- Theming System - Using themes and semantic colors
- Rich Text - Text formatting guide
- Testing - Testing strategies and
gloomy-driver - Architecture - Internal design
- Roadmap - Future plans
- Examples README - Guide to examples
Contributions are welcome! Please feel free to submit issues and pull requests.
- Follow the existing code style
- Add tests for new features
- Update documentation
- Run
cargo fmtandcargo clippybefore committing
- MIT License (LICENSE-MIT)
at your option.
Built with:
- wgpu - Modern GPU API
- winit - Cross-platform windowing
- wgpu-text - Text rendering
- glam - Math library
- serde - Serialization
- ron - RON format
Status: Active Development π§
Gloomy is under active development. The API may change between releases.
