egui_mobius_widgets/lib.rs
1//! # egui_mobius_widgets
2//!
3//! A collection of reusable widgets for the egui_mobius framework, designed to enhance your UI with
4//! stateful and styled components.
5//!
6//! ## Features
7//!
8//! - **StyledButton**: A customizable button with enhanced styling options, perfect for creating
9//! visually consistent and appealing UIs.
10//! - **StatefulButton**: A button that maintains its state between frames with customizable colors
11//! and behavior, ideal for toggle switches and start/stop controls.
12//!
13//! ## Basic Example
14//!
15//! ```rust,no_run
16//! use egui_mobius_widgets::{StyledButton, StatefulButton};
17//!
18//! fn ui_example(ui: &mut egui::Ui) {
19//! // Create a styled button with custom appearance
20//! let styled_btn = StyledButton::new("Click me")
21//! .margin(egui::Vec2::new(8.0, 4.0))
22//! .rounding(4.0)
23//! .hover_color(egui::Color32::LIGHT_BLUE);
24//!
25//! // Create a stateful button (e.g., for a start/stop control)
26//! let mut stateful_btn = StatefulButton::new()
27//! .margin(egui::Vec2::new(8.0, 4.0))
28//! .rounding(4.0)
29//! .run_color(egui::Color32::GREEN)
30//! .stop_color(egui::Color32::RED);
31//!
32//! // Handle button interactions
33//! if styled_btn.show(ui).clicked() {
34//! println!("Styled button clicked!");
35//! }
36//!
37//! if stateful_btn.show(ui).clicked() {
38//! stateful_btn.set_started(!stateful_btn.is_started());
39//! println!("Process is now {}",
40//! if stateful_btn.is_started() { "running" } else { "stopped" });
41//! }
42//! }
43//! ```
44//!
45//! ### Custom Styling
46//!
47//! ```rust,no_run
48//! use egui_mobius_widgets::StyledButton;
49//! use eframe::egui;
50//!
51//! fn create_themed_button(theme: &str) -> StyledButton {
52//! match theme {
53//! "dark" => StyledButton::new("Dark Theme")
54//! .normal_color(egui::Color32::from_rgb(48, 48, 48))
55//! .hover_color(egui::Color32::from_rgb(64, 64, 64))
56//! .text_color(egui::Color32::WHITE)
57//! .rounding(8.0),
58//! "light" => StyledButton::new("Light Theme")
59//! .normal_color(egui::Color32::from_rgb(240, 240, 240))
60//! .hover_color(egui::Color32::from_rgb(220, 220, 220))
61//! .text_color(egui::Color32::BLACK)
62//! .rounding(8.0),
63//! _ => StyledButton::default(),
64//! }
65//! }
66//! ```
67
68pub mod styled_button;
69pub use styled_button::StyledButton;
70
71pub mod stateful_button;
72pub use stateful_button::StatefulButton;