refactor(ribbon): extract repeated inline color literals into named constants
Consolidates 21 occurrences of identical Color literals scattered across widgets.rs and mod.rs into 9 named constants (COMBO_BG, COMBO_HOVER_BG, COMBO_OPEN_BG, COMBO_BORDER, COMBO_ACTIVE_BORDER, COMBO_ARROW, SWATCH_BORDER, TIP_BG, HIST_INACTIVE_BG). -85 net lines, zero behaviour change.
This commit is contained in:
parent
1e8a98d2cd
commit
63c13f0f63
2 changed files with 85 additions and 153 deletions
|
|
@ -717,12 +717,7 @@ impl Ribbon {
|
||||||
.style(move |_: &Theme| container::Style {
|
.style(move |_: &Theme| container::Style {
|
||||||
background: Some(Background::Color(lc)),
|
background: Some(Background::Color(lc)),
|
||||||
border: Border {
|
border: Border {
|
||||||
color: Color {
|
color: SWATCH_BORDER,
|
||||||
r: 0.0,
|
|
||||||
g: 0.0,
|
|
||||||
b: 0.0,
|
|
||||||
a: 0.5,
|
|
||||||
},
|
|
||||||
width: 1.0,
|
width: 1.0,
|
||||||
radius: 1.0.into(),
|
radius: 1.0.into(),
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -163,6 +163,63 @@ pub(super) const LABEL_OFF: Color = Color {
|
||||||
a: 1.0,
|
a: 1.0,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// ── Combo / dropdown colors ───────────────────────────────────────────────
|
||||||
|
|
||||||
|
pub(super) const COMBO_BG: Color = Color {
|
||||||
|
r: 0.18,
|
||||||
|
g: 0.18,
|
||||||
|
b: 0.18,
|
||||||
|
a: 1.0,
|
||||||
|
};
|
||||||
|
pub(super) const COMBO_HOVER_BG: Color = Color {
|
||||||
|
r: 0.26,
|
||||||
|
g: 0.26,
|
||||||
|
b: 0.26,
|
||||||
|
a: 1.0,
|
||||||
|
};
|
||||||
|
pub(super) const COMBO_OPEN_BG: Color = Color {
|
||||||
|
r: 0.14,
|
||||||
|
g: 0.14,
|
||||||
|
b: 0.14,
|
||||||
|
a: 1.0,
|
||||||
|
};
|
||||||
|
pub(super) const COMBO_BORDER: Color = Color {
|
||||||
|
r: 0.35,
|
||||||
|
g: 0.35,
|
||||||
|
b: 0.35,
|
||||||
|
a: 1.0,
|
||||||
|
};
|
||||||
|
pub(super) const COMBO_ACTIVE_BORDER: Color = Color {
|
||||||
|
r: 0.45,
|
||||||
|
g: 0.65,
|
||||||
|
b: 0.90,
|
||||||
|
a: 1.0,
|
||||||
|
};
|
||||||
|
pub(super) const COMBO_ARROW: Color = Color {
|
||||||
|
r: 0.70,
|
||||||
|
g: 0.70,
|
||||||
|
b: 0.70,
|
||||||
|
a: 1.0,
|
||||||
|
};
|
||||||
|
pub(super) const SWATCH_BORDER: Color = Color {
|
||||||
|
r: 0.0,
|
||||||
|
g: 0.0,
|
||||||
|
b: 0.0,
|
||||||
|
a: 0.5,
|
||||||
|
};
|
||||||
|
pub(super) const TIP_BG: Color = Color {
|
||||||
|
r: 0.13,
|
||||||
|
g: 0.13,
|
||||||
|
b: 0.13,
|
||||||
|
a: 0.97,
|
||||||
|
};
|
||||||
|
pub(super) const HIST_INACTIVE_BG: Color = Color {
|
||||||
|
r: 0.20,
|
||||||
|
g: 0.20,
|
||||||
|
b: 0.20,
|
||||||
|
a: 1.0,
|
||||||
|
};
|
||||||
|
|
||||||
// ── Style context (passed from Ribbon to render_large) ────────────────────
|
// ── Style context (passed from Ribbon to render_large) ────────────────────
|
||||||
|
|
||||||
pub(super) struct StyleContext {
|
pub(super) struct StyleContext {
|
||||||
|
|
@ -263,19 +320,9 @@ pub(super) fn make_tip(tip: String) -> Element<'static, Message> {
|
||||||
|
|
||||||
pub(super) fn tip_style(_theme: &Theme) -> container::Style {
|
pub(super) fn tip_style(_theme: &Theme) -> container::Style {
|
||||||
container::Style {
|
container::Style {
|
||||||
background: Some(Background::Color(Color {
|
background: Some(Background::Color(TIP_BG)),
|
||||||
r: 0.13,
|
border: Border {
|
||||||
g: 0.13,
|
color: COMBO_BORDER,
|
||||||
b: 0.13,
|
|
||||||
a: 0.97,
|
|
||||||
})),
|
|
||||||
border: Border {
|
|
||||||
color: Color {
|
|
||||||
r: 0.35,
|
|
||||||
g: 0.35,
|
|
||||||
b: 0.35,
|
|
||||||
a: 1.0,
|
|
||||||
},
|
|
||||||
width: 1.0,
|
width: 1.0,
|
||||||
radius: 3.0.into(),
|
radius: 3.0.into(),
|
||||||
},
|
},
|
||||||
|
|
@ -572,19 +619,14 @@ pub(super) fn render_large<'a>(
|
||||||
.style(move |_: &Theme| container::Style {
|
.style(move |_: &Theme| container::Style {
|
||||||
background: Some(Background::Color(lc)),
|
background: Some(Background::Color(lc)),
|
||||||
border: Border {
|
border: Border {
|
||||||
color: Color {
|
color: SWATCH_BORDER,
|
||||||
r: 0.0,
|
width: 1.0,
|
||||||
g: 0.0,
|
radius: 1.0.into(),
|
||||||
b: 0.0,
|
},
|
||||||
a: 0.5,
|
..Default::default()
|
||||||
},
|
})
|
||||||
width: 1.0,
|
.width(12)
|
||||||
radius: 1.0.into(),
|
.height(12);
|
||||||
},
|
|
||||||
..Default::default()
|
|
||||||
})
|
|
||||||
.width(12)
|
|
||||||
.height(12);
|
|
||||||
|
|
||||||
const ICONS_USED: f32 = 14.0 + 14.0 + 14.0 + 12.0 + 10.0 + 5.0 * 4.0 + 16.0 + 16.0;
|
const ICONS_USED: f32 = 14.0 + 14.0 + 14.0 + 12.0 + 10.0 + 5.0 * 4.0 + 16.0 + 16.0;
|
||||||
let name_w = (COMBO_W - ICONS_USED).max(40.0);
|
let name_w = (COMBO_W - ICONS_USED).max(40.0);
|
||||||
|
|
@ -598,15 +640,7 @@ pub(super) fn render_large<'a>(
|
||||||
container(text(active_layer).size(11).color(Color::WHITE))
|
container(text(active_layer).size(11).color(Color::WHITE))
|
||||||
.width(name_w)
|
.width(name_w)
|
||||||
.clip(true),
|
.clip(true),
|
||||||
icons::arrow_down(
|
icons::arrow_down(9.0, COMBO_ARROW),
|
||||||
9.0,
|
|
||||||
Color {
|
|
||||||
r: 0.7,
|
|
||||||
g: 0.7,
|
|
||||||
b: 0.7,
|
|
||||||
a: 1.0,
|
|
||||||
},
|
|
||||||
),
|
|
||||||
]
|
]
|
||||||
.spacing(4)
|
.spacing(4)
|
||||||
.align_y(iced::Center),
|
.align_y(iced::Center),
|
||||||
|
|
@ -614,34 +648,14 @@ pub(super) fn render_large<'a>(
|
||||||
.on_press(Message::ToggleRibbonDropdown(LAYER_COMBO_ID.to_string()))
|
.on_press(Message::ToggleRibbonDropdown(LAYER_COMBO_ID.to_string()))
|
||||||
.style(move |_: &Theme, status| button::Style {
|
.style(move |_: &Theme, status| button::Style {
|
||||||
background: Some(Background::Color(match (is_open, status) {
|
background: Some(Background::Color(match (is_open, status) {
|
||||||
(true, _) => Color {
|
(true, _) => COMBO_OPEN_BG,
|
||||||
r: 0.14,
|
(_, button::Status::Hovered) => COMBO_HOVER_BG,
|
||||||
g: 0.14,
|
_ => COMBO_BG,
|
||||||
b: 0.14,
|
|
||||||
a: 1.0,
|
|
||||||
},
|
|
||||||
(_, button::Status::Hovered) => Color {
|
|
||||||
r: 0.26,
|
|
||||||
g: 0.26,
|
|
||||||
b: 0.26,
|
|
||||||
a: 1.0,
|
|
||||||
},
|
|
||||||
_ => Color {
|
|
||||||
r: 0.18,
|
|
||||||
g: 0.18,
|
|
||||||
b: 0.18,
|
|
||||||
a: 1.0,
|
|
||||||
},
|
|
||||||
})),
|
})),
|
||||||
border: Border {
|
border: Border {
|
||||||
radius: 3.0.into(),
|
radius: 3.0.into(),
|
||||||
width: 1.0,
|
width: 1.0,
|
||||||
color: Color {
|
color: COMBO_BORDER,
|
||||||
r: 0.35,
|
|
||||||
g: 0.35,
|
|
||||||
b: 0.35,
|
|
||||||
a: 1.0,
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
..Default::default()
|
..Default::default()
|
||||||
})
|
})
|
||||||
|
|
@ -742,12 +756,7 @@ pub(super) fn render_large<'a>(
|
||||||
.style(move |_: &Theme| container::Style {
|
.style(move |_: &Theme| container::Style {
|
||||||
background: Some(Background::Color(c)),
|
background: Some(Background::Color(c)),
|
||||||
border: Border {
|
border: Border {
|
||||||
color: Color {
|
color: SWATCH_BORDER,
|
||||||
r: 0.0,
|
|
||||||
g: 0.0,
|
|
||||||
b: 0.0,
|
|
||||||
a: 0.5,
|
|
||||||
},
|
|
||||||
width: 1.0,
|
width: 1.0,
|
||||||
radius: 1.0.into(),
|
radius: 1.0.into(),
|
||||||
},
|
},
|
||||||
|
|
@ -782,43 +791,14 @@ pub(super) fn render_large<'a>(
|
||||||
.on_press(Message::ToggleRibbonDropdown(dd_id.to_string()))
|
.on_press(Message::ToggleRibbonDropdown(dd_id.to_string()))
|
||||||
.style(move |_: &Theme, status| button::Style {
|
.style(move |_: &Theme, status| button::Style {
|
||||||
background: Some(Background::Color(match (is_open, status) {
|
background: Some(Background::Color(match (is_open, status) {
|
||||||
(true, _) => Color {
|
(true, _) => COMBO_OPEN_BG,
|
||||||
r: 0.14,
|
(_, button::Status::Hovered) => COMBO_HOVER_BG,
|
||||||
g: 0.14,
|
_ => COMBO_BG,
|
||||||
b: 0.14,
|
|
||||||
a: 1.0,
|
|
||||||
},
|
|
||||||
(_, button::Status::Hovered) => Color {
|
|
||||||
r: 0.26,
|
|
||||||
g: 0.26,
|
|
||||||
b: 0.26,
|
|
||||||
a: 1.0,
|
|
||||||
},
|
|
||||||
_ => Color {
|
|
||||||
r: 0.18,
|
|
||||||
g: 0.18,
|
|
||||||
b: 0.18,
|
|
||||||
a: 1.0,
|
|
||||||
},
|
|
||||||
})),
|
})),
|
||||||
border: Border {
|
border: Border {
|
||||||
radius: 2.0.into(),
|
radius: 2.0.into(),
|
||||||
width: 1.0,
|
width: 1.0,
|
||||||
color: if is_open {
|
color: if is_open { COMBO_ACTIVE_BORDER } else { COMBO_BORDER },
|
||||||
Color {
|
|
||||||
r: 0.45,
|
|
||||||
g: 0.65,
|
|
||||||
b: 0.90,
|
|
||||||
a: 1.0,
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
Color {
|
|
||||||
r: 0.35,
|
|
||||||
g: 0.35,
|
|
||||||
b: 0.35,
|
|
||||||
a: 1.0,
|
|
||||||
}
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
..Default::default()
|
..Default::default()
|
||||||
})
|
})
|
||||||
|
|
@ -872,16 +852,7 @@ pub(super) fn render_large<'a>(
|
||||||
container(text(active.clone()).size(11).color(Color::WHITE))
|
container(text(active.clone()).size(11).color(Color::WHITE))
|
||||||
.width(Fill)
|
.width(Fill)
|
||||||
.clip(true),
|
.clip(true),
|
||||||
icons::arrow_toggle(
|
icons::arrow_toggle(is_open, 9.0, COMBO_ARROW),
|
||||||
is_open,
|
|
||||||
9.0,
|
|
||||||
Color {
|
|
||||||
r: 0.7,
|
|
||||||
g: 0.7,
|
|
||||||
b: 0.7,
|
|
||||||
a: 1.0,
|
|
||||||
},
|
|
||||||
),
|
|
||||||
]
|
]
|
||||||
.spacing(4)
|
.spacing(4)
|
||||||
.align_y(iced::Center),
|
.align_y(iced::Center),
|
||||||
|
|
@ -889,43 +860,14 @@ pub(super) fn render_large<'a>(
|
||||||
.on_press(Message::ToggleRibbonDropdown(combo_id.to_string()))
|
.on_press(Message::ToggleRibbonDropdown(combo_id.to_string()))
|
||||||
.style(move |_: &Theme, status| button::Style {
|
.style(move |_: &Theme, status| button::Style {
|
||||||
background: Some(Background::Color(match (is_open, status) {
|
background: Some(Background::Color(match (is_open, status) {
|
||||||
(true, _) => Color {
|
(true, _) => COMBO_OPEN_BG,
|
||||||
r: 0.14,
|
(_, button::Status::Hovered) => COMBO_HOVER_BG,
|
||||||
g: 0.14,
|
_ => COMBO_BG,
|
||||||
b: 0.14,
|
|
||||||
a: 1.0,
|
|
||||||
},
|
|
||||||
(_, button::Status::Hovered) => Color {
|
|
||||||
r: 0.26,
|
|
||||||
g: 0.26,
|
|
||||||
b: 0.26,
|
|
||||||
a: 1.0,
|
|
||||||
},
|
|
||||||
_ => Color {
|
|
||||||
r: 0.18,
|
|
||||||
g: 0.18,
|
|
||||||
b: 0.18,
|
|
||||||
a: 1.0,
|
|
||||||
},
|
|
||||||
})),
|
})),
|
||||||
border: Border {
|
border: Border {
|
||||||
radius: 3.0.into(),
|
radius: 3.0.into(),
|
||||||
width: 1.0,
|
width: 1.0,
|
||||||
color: if is_open {
|
color: if is_open { COMBO_ACTIVE_BORDER } else { COMBO_BORDER },
|
||||||
Color {
|
|
||||||
r: 0.45,
|
|
||||||
g: 0.65,
|
|
||||||
b: 0.90,
|
|
||||||
a: 1.0,
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
Color {
|
|
||||||
r: 0.35,
|
|
||||||
g: 0.35,
|
|
||||||
b: 0.35,
|
|
||||||
a: 1.0,
|
|
||||||
}
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
..Default::default()
|
..Default::default()
|
||||||
})
|
})
|
||||||
|
|
@ -1218,12 +1160,7 @@ pub(super) fn top_hist_btn_style(
|
||||||
) -> button::Style {
|
) -> button::Style {
|
||||||
button::Style {
|
button::Style {
|
||||||
background: Some(Background::Color(match (active, open, status) {
|
background: Some(Background::Color(match (active, open, status) {
|
||||||
(false, _, _) => Color {
|
(false, _, _) => HIST_INACTIVE_BG,
|
||||||
r: 0.20,
|
|
||||||
g: 0.20,
|
|
||||||
b: 0.20,
|
|
||||||
a: 1.0,
|
|
||||||
},
|
|
||||||
(_, true, _) => TOOL_ACTIVE,
|
(_, true, _) => TOOL_ACTIVE,
|
||||||
(_, _, button::Status::Hovered) => TOOL_HOVER,
|
(_, _, button::Status::Hovered) => TOOL_HOVER,
|
||||||
(_, _, button::Status::Pressed) => TOOL_ACTIVE,
|
(_, _, button::Status::Pressed) => TOOL_ACTIVE,
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue