uzor_core/widgets/icon_button.rs
1//! Icon button widget
2//!
3//! Minimal icon button implementation for toolbar actions (close, add, etc.)
4
5use crate::types::WidgetState;
6
7/// Configuration for icon button rendering
8#[derive(Clone, Debug)]
9pub struct IconButtonConfig {
10 /// Icon identifier (e.g., "close", "plus", "settings")
11 pub icon: String,
12 /// Button size (width and height)
13 pub size: f64,
14}
15
16impl IconButtonConfig {
17 /// Create a new icon button configuration
18 pub fn new(icon: impl Into<String>) -> Self {
19 Self {
20 icon: icon.into(),
21 size: 24.0, // Default size for toolbar buttons
22 }
23 }
24
25 /// Set custom button size
26 pub fn with_size(mut self, size: f64) -> Self {
27 self.size = size;
28 self
29 }
30}
31
32/// Response from icon button interaction
33#[derive(Clone, Copy, Debug)]
34pub struct IconButtonResponse {
35 /// Whether the button was clicked this frame
36 pub clicked: bool,
37 /// Whether the button is hovered
38 pub hovered: bool,
39 /// Current interaction state (Normal, Hovered, Pressed)
40 pub state: WidgetState,
41}