UI: favorite themes and appearance shortcuts

Port of storytold/photocraft#2445. Each theme in the appearance picker gets a
star at the right edge of its row. Starred themes are saved with the
preferences and listed in a right-click menu on the header's appearance button,
next to Appearance Settings, so switching between favorites takes one click.
This commit is contained in:
Luniiya
2026-10-11 15:46:18 +02:00
parent 9a7d3e7699
commit e1bcaab0a0
8 changed files with 176 additions and 7 deletions
+13
View File
@@ -22,6 +22,7 @@ pub enum Icon {
Ellipse,
Polygon,
Star,
StarFilled,
Pen,
PenAdd,
PenDelete,
@@ -271,6 +272,18 @@ pub fn paint(painter: &Painter, rect: Rect, icon: Icon, color: Color32) {
let pts = pen.star(8.0, 8.6, 6.4, 2.7, 5);
pen.closed(&pts);
}
StarFilled => {
// Five triangles fill the concave star without a convex-polygon approximation.
let pts = pen.star(8.0, 8.6, 6.4, 2.7, 5);
for pair in pts.windows(2) {
if let [a, b] = pair {
pen.fill(&[(8.0, 8.6), *a, *b]);
}
}
if let (Some(first), Some(last)) = (pts.first(), pts.last()) {
pen.fill(&[(8.0, 8.6), *last, *first]);
}
}
Pen => {
pen.closed(&[(8.0, 1.8), (12.0, 9.0), (8.0, 14.0), (4.0, 9.0)]);
pen.dot(8.0, 8.6, 1.1);