1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
// SPDX-License-Identifier: MPL-2.0
// SPDX-FileCopyrightText: 2026 FernTech
//! Tier-3 style protocol for `IconButton`. See `docs/styling-system.md`.
use std::rc::Rc;
use serde::{Deserialize, Serialize};
use crate::build_context::BuildContext;
use crate::signal::Signal;
use crate::widget_id::WidgetId;
/// Five sizes calibrated to the IntelliJ Int UI scale. Apps usually
/// pick one per call; the active style maps each to a (square_size,
/// icon_size) pair from its recipe.
#[derive(Copy, Clone, Debug, Eq, PartialEq, Hash, Default, Serialize, Deserialize)]
pub enum IconButtonSize {
Compact,
#[default]
Default,
Toolbar,
Large,
Hero,
}
#[derive(Clone, Debug)]
pub struct IconButtonStyleConfig {
/// Pre-built icon subtree (color-bound by the host widget so the
/// style stays neutral on icon coloring policy — embedded vs
/// standalone vs caller override).
pub icon: WidgetId,
pub is_pressed: Signal<bool>,
pub is_hovered: Signal<bool>,
pub is_focused: Signal<bool>,
pub is_disabled: Signal<bool>,
/// Bistate-toggle source. When present, the style paints the
/// `Selected` surface tint while `is_on == true`; absent → plain
/// flat treatment for every state.
pub is_on: Option<Signal<bool>>,
pub size: IconButtonSize,
}
pub trait IconButtonStyle: 'static {
fn make_body(&self, cfg: &IconButtonStyleConfig, ctx: &mut BuildContext) -> WidgetId;
}
pub type SharedIconButtonStyle = Rc<dyn IconButtonStyle>;