egui_elements/lib.rs
1//! Widgets, themes, and optional components for [egui](https://github.com/emilk/egui).
2//!
3//! This crate is **not** a drop-in replacement for stock egui widgets. It
4//! ships a themed widget set, a palette of built-in looks, a live theme
5//! editor, and a few higher-level components (credentials form, QR image,
6//! Linux QR scanner).
7//!
8//! There are no crate-root re-exports. Import from the modules:
9//!
10//! ```
11//! use egui_elements::theme::{Theme, ThemeKind};
12//! use egui_elements::widgets::{Button, ComboBox, Label, Modal, SecureTextEdit, Window};
13//! use egui_elements::utils::theme_switcher;
14//! ```
15//!
16//! # Quick start
17//!
18//! ```no_run
19//! use egui::{Context, Ui};
20//! use egui_elements::theme::{Theme, ThemeKind};
21//! use egui_elements::widgets::Button;
22//!
23//! fn ui(ctx: &Context, ui: &mut Ui) {
24//! let mut theme = Theme::new(ThemeKind::TokyoNight);
25//! theme.install(ctx);
26//!
27//! if ui.add(Button::new("Save")).clicked() {
28//! // …
29//! }
30//! }
31//! ```
32//!
33//! Custom widgets pick up [`visuals`] from the installed
34//! [`Theme`](crate::theme::Theme). You can still override a single widget
35//! with `.visuals(...)`.
36//!
37//! # Modules
38//!
39//! - [`theme`] / [`themes`] — palettes, [`ThemeKind`](crate::theme::ThemeKind), install
40//! - [`widgets`] — [`Button`](crate::widgets::Button), [`Label`](crate::widgets::Label),
41//! [`ComboBox`](crate::widgets::ComboBox), [`Modal`](crate::widgets::Modal),
42//! [`SecureTextEdit`](crate::widgets::SecureTextEdit), [`MultiLabel`](crate::widgets::MultiLabel),
43//! [`Window`](crate::widgets::Window)
44//! - [`components`] — feature-gated composites (`secure-types`, `qr-image`, `qr-scanner`)
45//! - [`editor`] — live [`ThemeEditor`](crate::editor::ThemeEditor)
46//! - [`utils`] — [`theme_switcher`](crate::utils::theme_switcher), HSLA helpers
47//! - [`overlay`] — dimming overlay for stacked windows
48//! - [`visuals`] — per-widget chrome (`ButtonVisuals`, `TextEditVisuals`, …)
49//!
50//! # Features
51//!
52//! | Feature | What it enables |
53//! |---------|-----------------|
54//! | `serde` | `Serialize` / `Deserialize` on theme types; `egui/serde` |
55//! | `secure-types` | [`SecureString`](https://docs.rs/secure-types) buffers, credentials form, virtual keyboard |
56//! | `qr-image` | Encode a string as a QR [`Image`](egui::Image) |
57//! | `qr-scanner` | Linux screen-capture QR scanner (`xcap` + `rqrr-zeroize`) |
58//! | `elegance` | Push the current palette into [`egui-elegance`](https://docs.rs/egui-elegance) |
59//! | `full` | All of the above |
60//!
61//! Run the showcase with:
62//!
63//! ```text
64//! cargo run --example demo --features full
65//! ```
66//!
67//! See the crate README for system packages required by `qr-scanner`.
68//!
69//! [`ComboBox`](crate::widgets::ComboBox) and [`Window`](crate::widgets::Window) have
70//! the same names as [`egui::ComboBox`] and [`egui::Window`]. Import this crate's
71//! widgets after `use egui::*`, or alias one of them.
72
73pub mod components;
74pub mod editor;
75pub mod overlay;
76pub mod theme;
77pub mod themes;
78pub mod utils;
79pub mod visuals;
80pub mod widgets;
81
82pub use overlay::OverlayManager;
83pub use theme::{Theme, ThemeKind};
84pub use widgets::{Button, ComboBox, Label, MultiLabel, Modal};
85
86#[cfg(feature = "secure-types")]
87pub use widgets::SecureTextEdit;
88
89#[cfg(feature = "qr-scanner")]
90pub use components::QRScanner;
91
92#[cfg(feature = "secure-types")]
93pub use components::{CredentialsForm, SecureInputField, VirtualKeyboard};
94
95#[cfg(feature = "qr-image")]
96pub use components::QrImage;