Panel footers: Photoshop's bar along the panel bottom; own mask and adjustment glyphs

The Layers footer hung under an inset hairline: 9 px above the icons, 20 below, and the line
stopped at the body margins. Photoshop's (measured on 25.4) is a bar under a line from edge to
edge of the panel, its buttons centred in the bar's height and laid out from the right.

- widgets::panel_footer draws that bar: a 1 px line across the whole panel, a 30 pt bar that
  runs on over the body's bottom margin to the panel's edge, buttons centred, from the right.
  footer_height is what a filling body leaves for it. Layers, Channels, Paths and History use it,
  all with 26 pt buttons.
- Channels and Paths lay their buttons out from the right too, in Photoshop's order.
- Layers footer glyphs: Lucide's contrast (a stroked half circle inside a circle) read as "(D)"
  at 14 px and square-dot's 1 px dot vanished. New original layer-mask (a frame around a solid
  disc) and adjustment-layer (a circle, one half solid) glyphs replace them; the Kind filter row
  uses the adjustment one too. square-dot is no longer used and is removed.
- Link Layers and the linked-layer row indicator use Lucide's horizontal link-2 chain.
- fx and New Fill or Adjustment Layer get a small triangle: they open menus.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
This commit is contained in:
UnemarsandClaude Opus 5.5 committed 2026-10-09 12:40:54 +02:00
1 parent 18426cd3a0
commit ca9a4acaa7
13 files changed
+200 -123

No files matched your search

+3 -2
View File
@@ -18,10 +18,11 @@ next to them.
| `crates/ui-egui/src/i18n/pt-br.tsv` | Brazilian Portuguese UI translations | PhotoCraft contributors | Original translations of PhotoCraft's English labels | MIT OR Apache-2.0, [`LICENSE-translations.txt`](crates/ui-egui/src/i18n/LICENSE-translations.txt) |
| `assets/fonts/Inter-Regular.ttf`, `Inter-Medium.ttf`, `Inter-SemiBold.ttf` | Inter 4.001 (UI font) | The Inter Project Authors (Rasmus Andersson) | <https://github.com/rsms/inter> | SIL OFL 1.1, [`assets/fonts/OFL-Inter.txt`](assets/fonts/OFL-Inter.txt) |
| `assets/fonts/JetBrainsMono-Regular.ttf` | JetBrains Mono 2.305 (numeric font) | The JetBrains Mono Project Authors | <https://github.com/JetBrains/JetBrainsMono> | SIL OFL 1.1, [`assets/fonts/OFL-JetBrainsMono.txt`](assets/fonts/OFL-JetBrainsMono.txt) |
| `assets/icons/*.svg` except `slice-knife.svg`, `clip-below.svg`, `clip-release.svg`, `eraser-background.svg`, `eraser-magic.svg`, `lasso-magnetic.svg` and `direct-select.svg` (109 files) | Lucide icons | Lucide Icons and Contributors | <https://github.com/lucide-icons/lucide> (`icons/<name>.svg`; `align-*` are now named `text-align-*` upstream) | ISC, [`assets/icons/LICENSE-lucide.txt`](assets/icons/LICENSE-lucide.txt) |
| `assets/icons/{check,chevron-down,chevron-right,chevron-up,chevrons-left,chevrons-right,circle,clock,compass,info,link,lock,minus,moon,move,navigation,plus,search,square,trash,triangle,type,x,zoom-in}.svg` | Lucide icons derived from Feather (subset of the row above) | Cole Bemis (Feather), Lucide Contributors | <https://github.com/feathericons/feather> via Lucide | MIT (Feather) and ISC (Lucide), [`assets/icons/LICENSE-lucide.txt`](assets/icons/LICENSE-lucide.txt) |
| `assets/icons/*.svg` except `slice-knife.svg`, `clip-below.svg`, `clip-release.svg`, `layer-mask.svg`, `adjustment-layer.svg`, `eraser-background.svg`, `eraser-magic.svg`, `lasso-magnetic.svg` and `direct-select.svg` (109 files) | Lucide icons | Lucide Icons and Contributors | <https://github.com/lucide-icons/lucide> (`icons/<name>.svg`; `align-*` are now named `text-align-*` upstream) | ISC, [`assets/icons/LICENSE-lucide.txt`](assets/icons/LICENSE-lucide.txt) |
| `assets/icons/{check,chevron-down,chevron-right,chevron-up,chevrons-left,chevrons-right,circle,clock,compass,info,link,link-2,lock,minus,moon,move,navigation,plus,search,square,trash,triangle,type,x,zoom-in}.svg` | Lucide icons derived from Feather (subset of the row above) | Cole Bemis (Feather), Lucide Contributors | <https://github.com/feathericons/feather> via Lucide | MIT (Feather) and ISC (Lucide), [`assets/icons/LICENSE-lucide.txt`](assets/icons/LICENSE-lucide.txt) |
| `assets/icons/slice-knife.svg` | Slice tool glyph | PhotoCraft contributors | Original work | MIT OR Apache-2.0 |
| `assets/icons/clip-below.svg`, `assets/icons/clip-release.svg` | Clipping-mask cursors (⌥ over the line between two layers): a hooked arrow onto the layer below; the same with a small "no" badge to release | PhotoCraft contributors | Original work | MIT OR Apache-2.0 |
| `assets/icons/layer-mask.svg`, `assets/icons/adjustment-layer.svg` | Layers panel footer glyphs: Add a mask (a frame around a solid disc) and New Fill or Adjustment Layer (a circle, one half solid), drawn on Lucide's 24 px grid and stroke | PhotoCraft contributors | Original work | MIT OR Apache-2.0 |
| `assets/icons/eraser-background.svg`, `assets/icons/eraser-magic.svg` | Background Eraser and Magic Eraser tool glyphs: Lucide `eraser` plus added marks | Lucide Icons and Contributors; marks by PhotoCraft contributors | Derived from <https://github.com/lucide-icons/lucide> `icons/eraser.svg` | ISC, [`assets/icons/LICENSE-lucide.txt`](assets/icons/LICENSE-lucide.txt) |
| `assets/icons/direct-select.svg` | Direct Selection tool glyph: Lucide `mouse-pointer-2` plus an anchor square | Lucide Icons and Contributors; square by PhotoCraft contributors | Derived from <https://github.com/lucide-icons/lucide> `icons/mouse-pointer-2.svg` | ISC, [`assets/icons/LICENSE-lucide.txt`](assets/icons/LICENSE-lucide.txt) |
| `assets/icons/lasso-magnetic.svg` | Magnetic Lasso tool glyph, adapted from "Magnetic Lasso Tool" (redrawn on the 24 px toolbar grid) | Lil' Seal (Noun Project); adapted by PhotoCraft contributors | <https://thenounproject.com/icon/magnetic-lasso-tool-177513/> | CC BY 3.0, [`assets/icons/LICENSE-noun-magnetic-lasso.txt`](assets/icons/LICENSE-noun-magnetic-lasso.txt) |
@@ -9,6 +9,6 @@
stroke-linecap="round"
stroke-linejoin="round"
>
<rect width="18" height="18" x="3" y="3" rx="2" />
<circle cx="12" cy="12" r="1" />
<circle cx="12" cy="12" r="9" />
<path d="M12 3a9 9 0 0 1 0 18z" fill="currentColor" />
</svg>

Before

Width:  |  Height:  |  Size: 296 B

After

Width:  |  Height:  |  Size: 300 B

+14
View File
@@ -0,0 +1,14 @@
<svg
xmlns="http://www.w3.org/2000/svg"
width="24"
height="24"
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
stroke-width="2"
stroke-linecap="round"
stroke-linejoin="round"
>
<rect width="20" height="16" x="2" y="4" rx="2" />
<circle cx="12" cy="12" r="4" fill="currentColor" />
</svg>

After

Width:  |  Height:  |  Size: 316 B

+15
View File
@@ -0,0 +1,15 @@
<svg
xmlns="http://www.w3.org/2000/svg"
width="24"
height="24"
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
stroke-width="2"
stroke-linecap="round"
stroke-linejoin="round"
>
<path d="M9 17H7A5 5 0 0 1 7 7h2" />
<path d="M15 7h2a5 5 0 1 1 0 10h-2" />
<line x1="8" x2="16" y1="12" y2="12" />
</svg>

After

Width:  |  Height:  |  Size: 330 B

+11 -16
View File
@@ -82,7 +82,7 @@ pub fn show(app: &mut PhotocraftApp, ui: &mut egui::Ui) {
let shown_colors = if colors > 1 { colors } else { 0 };
let mut actions: Vec<(String, Value)> = Vec::new();
// The buttons sit in a footer at the panel's bottom, like Photoshop's.
let footer = 34.0;
let footer = widgets::footer_height(ui) + ui.spacing().item_spacing.y;
let fill = ui.available_height() > footer + 60.0;
let rows_h = if fill { ui.available_height() - footer } else { f32::INFINITY };
let mut mask_click = None;
@@ -270,30 +270,25 @@ pub fn show(app: &mut PhotocraftApp, ui: &mut egui::Ui) {
});
}
});
ui.add_space(4.0);
widgets::hairline(ui);
ui.add_space(2.0);
ui.horizontal(|ui| {
ui.spacing_mut().item_spacing.x = 2.0;
// Photoshop's order from the left: Load as selection, Save selection, New, Delete.
widgets::panel_footer(ui, |ui| {
let target_ref = match view.target {
ChannelTarget::Alpha(i) => json!(i),
ChannelTarget::Color(k) => json!({ "color": k }),
ChannelTarget::Composite => json!("composite"),
};
if icons::button(ui, "circle-dashed", 26.0, false, tl!("Load channel as selection")).clicked() {
actions.push(("select.loadSelection".into(), json!({ "channel": target_ref })));
if icons::button(ui, "trash", 26.0, false, tl!("Delete current channel")).clicked() {
actions.push(("channel.delete".into(), json!({})));
}
if icons::button(ui, "plus", 26.0, false, tl!("Create new channel")).clicked() {
actions.push(("channel.new".into(), json!({})));
}
if icons::button(ui, "square-dashed", 26.0, false, tl!("Save selection as channel")).clicked() {
actions.push(("select.saveSelection".into(), json!({})));
}
ui.with_layout(egui::Layout::right_to_left(egui::Align::Center), |ui| {
if icons::button(ui, "trash", 26.0, false, tl!("Delete current channel")).clicked() {
actions.push(("channel.delete".into(), json!({})));
}
if icons::button(ui, "plus", 26.0, false, tl!("Create new channel")).clicked() {
actions.push(("channel.new".into(), json!({})));
}
});
if icons::button(ui, "circle-dashed", 26.0, false, tl!("Load channel as selection")).clicked() {
actions.push(("select.loadSelection".into(), json!({ "channel": target_ref })));
}
});
ctx.data_mut(|d| d.insert_temp(thumbs_id(), drawn));
if let Some(on) = mask_click {
+3 -1
View File
@@ -1,6 +1,7 @@
//! Lucide icons (ISC licence), embedded and tinted at runtime.
pub static ICONS: &[(&str, &[u8])] = &[
("adjustment-layer", include_bytes!("../../../assets/icons/adjustment-layer.svg")),
("align-center", include_bytes!("../../../assets/icons/align-center.svg")),
("align-justify", include_bytes!("../../../assets/icons/align-justify.svg")),
("align-left", include_bytes!("../../../assets/icons/align-left.svg")),
@@ -55,8 +56,10 @@ pub static ICONS: &[(&str, &[u8])] = &[
("lasso", include_bytes!("../../../assets/icons/lasso.svg")),
("lasso-magnetic", include_bytes!("../../../assets/icons/lasso-magnetic.svg")),
("lasso-select", include_bytes!("../../../assets/icons/lasso-select.svg")),
("layer-mask", include_bytes!("../../../assets/icons/layer-mask.svg")),
("layers", include_bytes!("../../../assets/icons/layers.svg")),
("link", include_bytes!("../../../assets/icons/link.svg")),
("link-2", include_bytes!("../../../assets/icons/link-2.svg")),
("lock", include_bytes!("../../../assets/icons/lock.svg")),
("lock-open", include_bytes!("../../../assets/icons/lock-open.svg")),
("lollipop", include_bytes!("../../../assets/icons/lollipop.svg")),
@@ -98,7 +101,6 @@ pub static ICONS: &[(&str, &[u8])] = &[
("square", include_bytes!("../../../assets/icons/square.svg")),
("square-dashed", include_bytes!("../../../assets/icons/square-dashed.svg")),
("square-dashed-mouse-pointer", include_bytes!("../../../assets/icons/square-dashed-mouse-pointer.svg")),
("square-dot", include_bytes!("../../../assets/icons/square-dot.svg")),
("square-plus", include_bytes!("../../../assets/icons/square-plus.svg")),
("squares-subtract", include_bytes!("../../../assets/icons/squares-subtract.svg")),
("stamp", include_bytes!("../../../assets/icons/stamp.svg")),
+1 -1
View File
@@ -55,7 +55,7 @@ fn row(h: &Harness<'static, PhotocraftApp>, name: &str) -> Option<Rect> {
/// Fully inside the rows viewport (below the strip and the blend/lock rows, above the footer).
fn in_view(h: &Harness<'static, PhotocraftApp>, r: Rect) -> bool {
let layers = last_rects(&h.ctx).into_iter().find(|(g, _)| *g == Group::Layers).unwrap().1;
r.top() >= layers.top() + 26.0 && r.bottom() <= layers.bottom() - 36.0
r.top() >= layers.top() + 26.0 && r.bottom() <= layers.bottom() - (crate::widgets::FOOTER_BAR + 1.0)
}
fn expanded(app: &PhotocraftApp, group: LayerId) -> bool {
+1 -1
View File
@@ -140,7 +140,7 @@ pub fn indicators(
for &(kind, r) in &rects {
match kind {
Indicator::Lock => icons::paint(ui, Rect::from_center_size(r.center(), vec2(ICON_W, ICON_W)), "lock", 12.0, t.text_faint),
Indicator::Link => icons::paint(ui, Rect::from_center_size(r.center(), vec2(ICON_W, ICON_W)), "link", 12.0, t.text_faint),
Indicator::Link => icons::paint(ui, Rect::from_center_size(r.center(), vec2(ICON_W, ICON_W)), "link-2", 12.0, t.text_faint),
Indicator::Fx => {
if let Some(g) = fx_galley.clone() {
painter.galley(pos2(r.left(), cy - g.size().y / 2.0), g, t.text_dim);
+20
View File
@@ -311,3 +311,23 @@ fn alt_dragging_a_row_drops_a_copy_and_a_plain_drag_moves() {
assert_eq!(names(&h), ["Background", "L0", "L2", "L0 copy", "L1"]);
assert_eq!(h.state().session.active().unwrap().history.undo_label(), Some("Reorder Layers"));
}
/// Photoshop's Layers footer is a bar along the panel's bottom edge: its buttons sit in the middle
/// of the bar's height, from the right. They used to hang under the line with twice the gap below.
#[test]
fn the_footer_is_a_bar_along_the_panel_bottom_with_its_buttons_centred() {
for theme in ["promedium", "studio"] {
let mut s = photocraft_engine::Session::new();
s.execute("file.new", json!({"width": 64, "height": 48})).unwrap();
s.execute("layer.new.layer", json!({})).unwrap();
let h = harness(s, 1.0, theme, 290.0);
let group = crate::dock::last_rects(&h.ctx).into_iter().find(|(g, _)| *g == crate::dock::Group::Layers).unwrap().1;
let delete = h.get_by_label("Delete layer").rect();
let bar_middle = group.bottom() - crate::widgets::FOOTER_BAR / 2.0;
assert!((delete.center().y - bar_middle).abs() <= 1.5, "{theme}: button at {delete:?}, bar middle {bar_middle}, group {group:?}");
assert!(group.right() - delete.right() <= 10.0, "{theme}: laid out from the right: {delete:?} in {group:?}");
let new_layer = h.get_by_label("Create a new layer").rect();
assert_eq!(new_layer.center().y, delete.center().y, "{theme}: one row");
assert!(new_layer.right() <= delete.left(), "{theme}: New Layer left of Delete");
}
}
+2 -2
View File
@@ -176,9 +176,9 @@ fn paths_list_the_layer_path_above_a_bottom_footer() {
let p = h.get_by_label("Badge Shape Path").rect().center();
click_with(&mut h, p, Modifiers::NONE);
assert_eq!(h.state().ui.selected_path.as_deref(), Some("layer"));
// Footer: fill, stroke, load as selection, … (24 pt buttons, 2 pt apart).
// Footer: fill, stroke, load as selection, … (26 pt buttons, 2 pt apart).
let footer = crate::vector_ui::paths_footer(&h.ctx).unwrap();
let p = pos2(footer.left() + 2.0 * 26.0 + 12.0, footer.center().y);
let p = pos2(footer.left() + 2.0 * 28.0 + 13.0, footer.center().y);
click_with(&mut h, p, Modifiers::NONE);
let sel = h.state().session.active().unwrap().doc.selection.clone().expect("selection from the shape path");
let b = sel.content_bounds();
+81 -79
View File
@@ -1482,7 +1482,7 @@ fn layers(app: &mut PhotocraftApp, ui: &mut egui::Ui) {
ui.add_space(4.0);
for (kind, icon, tip) in [
("pixel", "image", tl!("Filter for pixel layers")),
("adjustment", "contrast", tl!("Filter for adjustment layers")),
("adjustment", "adjustment-layer", tl!("Filter for adjustment layers")),
("type", "type", tl!("Filter for type layers")),
("shape", "square", tl!("Filter for shape layers")),
("smart", "app-window", tl!("Filter for smart objects")),
@@ -1577,7 +1577,7 @@ fn layers(app: &mut PhotocraftApp, ui: &mut egui::Ui) {
// Top of the stack first, groups above their contents, closed groups' contents hidden (#126).
let rows = crate::layer_tree_ui::display_rows(&doc, !app.ui.layer_filter.is_empty());
let ctx = ui.ctx().clone();
let footer = 38.0;
let footer = widgets::footer_height(ui) + ui.spacing().item_spacing.y;
let fill = ui.available_height() > footer + 60.0;
let rows_h = if fill { ui.available_height() - footer } else { f32::INFINITY };
egui::ScrollArea::vertical()
@@ -1648,79 +1648,75 @@ fn layers(app: &mut PhotocraftApp, ui: &mut egui::Ui) {
if ctx.input(|i| i.pointer.any_released()) {
ctx.data_mut(|d| d.remove::<u64>(egui::Id::new("layer-drag")));
}
ui.add_space(4.0);
widgets::hairline(ui);
ui.add_space(2.0);
ui.horizontal(|ui| {
ui.spacing_mut().item_spacing.x = 2.0;
ui.with_layout(egui::Layout::right_to_left(egui::Align::Center), |ui| {
let trash = icons::button(ui, "trash", 26.0, false, tl!("Delete layer"));
if trash.clicked() {
actions.push(("layer.delete".into(), json!({})));
}
actions.extend(footer_drop(ui, &trash, footer_drag, "layer.delete"));
let new_layer = icons::button(ui, "square-plus", 26.0, false, &crate::shortcuts::tip_label(app, "Create a new layer", "layer.new.layer"));
if new_layer.clicked() {
actions.push(("layer.new.layer".into(), json!({})));
}
actions.extend(footer_drop(ui, &new_layer, footer_drag, "layer.duplicate"));
let group = icons::button(ui, "folder", 26.0, false, tl!("Create a new group"));
if group.clicked() {
actions.push(("layer.new.group".into(), json!({})));
}
actions.extend(footer_drop(ui, &group, footer_drag, "layer.groupLayers"));
let adj = icons::button(ui, "contrast", 26.0, false, tl!("Create new fill or adjustment layer"));
egui::Popup::menu(&adj).show(|ui| {
ui.set_min_width(190.0);
for c in photocraft_engine::command_specs().iter().filter(|c| c.id.starts_with("layer.newAdjustmentLayer.")) {
if ui.button(tl!(c.label).trim_end_matches('…')).clicked() {
actions.push((c.id.into(), json!({})));
ui.close();
}
}
ui.separator();
if ui.button(tl!("Solid Color…")).clicked() {
actions.push(("layer.newFillLayer.solidColor".into(), json!({})));
widgets::panel_footer(ui, |ui| {
let trash = icons::button(ui, "trash", 26.0, false, tl!("Delete layer"));
if trash.clicked() {
actions.push(("layer.delete".into(), json!({})));
}
actions.extend(footer_drop(ui, &trash, footer_drag, "layer.delete"));
let new_layer = icons::button(ui, "square-plus", 26.0, false, &crate::shortcuts::tip_label(app, "Create a new layer", "layer.new.layer"));
if new_layer.clicked() {
actions.push(("layer.new.layer".into(), json!({})));
}
actions.extend(footer_drop(ui, &new_layer, footer_drag, "layer.duplicate"));
let group = icons::button(ui, "folder", 26.0, false, tl!("Create a new group"));
if group.clicked() {
actions.push(("layer.new.group".into(), json!({})));
}
actions.extend(footer_drop(ui, &group, footer_drag, "layer.groupLayers"));
let adj = icons::button(ui, "adjustment-layer", 26.0, false, tl!("Create new fill or adjustment layer"));
menu_mark(ui, &adj);
egui::Popup::menu(&adj).show(|ui| {
ui.set_min_width(190.0);
for c in photocraft_engine::command_specs().iter().filter(|c| c.id.starts_with("layer.newAdjustmentLayer.")) {
if ui.button(tl!(c.label).trim_end_matches('…')).clicked() {
actions.push((c.id.into(), json!({})));
ui.close();
}
if ui.button(tl!("Gradient…")).clicked() {
actions.push(("layer.newFillLayer.gradient".into(), json!({})));
ui.close();
}
});
if icons::button(
ui,
"square-dot",
26.0,
false,
&crate::i18n::fmt(tl!("Add a mask (from the selection; {key} inverts)"), &[("key", &crate::shortcuts::pretty("Alt"))]),
)
.clicked()
{
let alt = ui.input(|i| i.modifiers.alt);
actions.push((crate::layer_menu_ui::add_mask_command(doc.selection.is_some(), alt).into(), json!({})));
}
let fx = fx_button(ui, 26.0, tl!("Add a layer style"));
egui::Popup::menu(&fx).show(|ui| {
ui.set_min_width(180.0);
if ui.button(tl!("Blending Options…")).clicked() {
crate::layer_style::open(app, None);
ui.close();
}
ui.separator();
for &(kind, label) in crate::layer_style::KINDS {
if ui.button(format!("{}…", tl!(label))).clicked() {
crate::layer_style::open(app, Some(kind));
ui.close();
}
}
});
// Photoshop's footer starts with Link Layers (enabled with two or more layers selected).
let can_link = app.session.is_enabled("layer.linkLayers");
if ui.add_enabled_ui(can_link, |ui| icons::button(ui, "link", 26.0, false, tl!("Link layers"))).inner.clicked() {
actions.push(("layer.linkLayers".into(), json!({})));
ui.separator();
if ui.button(tl!("Solid Color…")).clicked() {
actions.push(("layer.newFillLayer.solidColor".into(), json!({})));
ui.close();
}
if ui.button(tl!("Gradient…")).clicked() {
actions.push(("layer.newFillLayer.gradient".into(), json!({})));
ui.close();
}
});
if icons::button(
ui,
"layer-mask",
26.0,
false,
&crate::i18n::fmt(tl!("Add a mask (from the selection; {key} inverts)"), &[("key", &crate::shortcuts::pretty("Alt"))]),
)
.clicked()
{
let alt = ui.input(|i| i.modifiers.alt);
actions.push((crate::layer_menu_ui::add_mask_command(doc.selection.is_some(), alt).into(), json!({})));
}
let fx = fx_button(ui, 26.0, tl!("Add a layer style"));
menu_mark(ui, &fx);
egui::Popup::menu(&fx).show(|ui| {
ui.set_min_width(180.0);
if ui.button(tl!("Blending Options…")).clicked() {
crate::layer_style::open(app, None);
ui.close();
}
ui.separator();
for &(kind, label) in crate::layer_style::KINDS {
if ui.button(format!("{}…", tl!(label))).clicked() {
crate::layer_style::open(app, Some(kind));
ui.close();
}
}
});
// Photoshop's footer starts with Link Layers (enabled with two or more layers selected).
let can_link = app.session.is_enabled("layer.linkLayers");
if ui.add_enabled_ui(can_link, |ui| icons::button(ui, "link-2", 26.0, false, tl!("Link layers"))).inner.clicked() {
actions.push(("layer.linkLayers".into(), json!({})));
}
});
for (id, p) in actions {
if id == "ui.maskTarget" {
@@ -1774,6 +1770,16 @@ fn footer_label(command: &str) -> &'static str {
}
}
/// The small triangle at the corner of a footer button that opens a menu (Photoshop's fx and
/// New Fill or Adjustment Layer buttons).
fn menu_mark(ui: &egui::Ui, button: &egui::Response) {
let t = Tokens::get(ui.ctx());
let c = button.rect.center() + vec2(7.0, 8.5);
let color = if button.hovered() { t.text } else { t.icon };
let tip = vec![pos2(c.x - 3.0, c.y - 1.5), pos2(c.x + 3.0, c.y - 1.5), pos2(c.x, c.y + 1.5)];
ui.painter().add(egui::Shape::convex_polygon(tip, color, Stroke::NONE));
}
/// Photoshop's italic "fx" footer button (no icon-font equivalent).
fn fx_button(ui: &mut egui::Ui, size: f32, tip: &str) -> egui::Response {
let t = Tokens::get(ui.ctx());
@@ -2139,7 +2145,7 @@ fn history(app: &mut PhotocraftApp, ui: &mut egui::Ui) {
let mut target: Option<isize> = None;
let all = entries.iter().map(|e| (e.clone(), false)).chain(redo.iter().map(|e| (e.clone(), true)));
// The dock gives History a fixed height: the rows scroll above the footer.
let footer = if t.pro { 34.0 } else { 0.0 };
let footer = if t.pro { widgets::footer_height(ui) + ui.spacing().item_spacing.y } else { 0.0 };
let max_h = (ui.available_height() - footer).max(40.0);
egui::ScrollArea::vertical().id_salt("history-rows").max_height(max_h).auto_shrink([false, false]).show(ui, |ui| {
for (i, (e, is_redo)) in all.enumerate() {
@@ -2172,14 +2178,10 @@ fn history(app: &mut PhotocraftApp, ui: &mut egui::Ui) {
}
});
if t.pro {
widgets::hairline(ui);
ui.horizontal(|ui| {
ui.spacing_mut().item_spacing.x = 2.0;
ui.with_layout(egui::Layout::right_to_left(egui::Align::Center), |ui| {
let _ = icons::button(ui, "trash", 24.0, false, tl!("Delete current state"));
let _ = icons::button(ui, "scan", 24.0, false, tl!("Create new snapshot"));
let _ = icons::button(ui, "file-plus", 24.0, false, tl!("Create new document from current state"));
});
widgets::panel_footer(ui, |ui| {
let _ = icons::button(ui, "trash", 26.0, false, tl!("Delete current state"));
let _ = icons::button(ui, "scan", 26.0, false, tl!("Create new snapshot"));
let _ = icons::button(ui, "file-plus", 26.0, false, tl!("Create new document from current state"));
});
}
// An open Free Transform owns Undo (transform_tool::intercept): stepping the document's history under
+11 -10
View File
@@ -804,7 +804,7 @@ fn ctx_data_footer(ctx: &egui::Context, r: Rect) {
ctx.data_mut(|d| d.insert_temp(footer_id(), r));
}
/// Where the Paths panel's button footer was drawn last frame.
/// Where the Paths panel's footer buttons were drawn last frame (the rect around them all).
pub fn paths_footer(ctx: &egui::Context) -> Option<Rect> {
ctx.data(|d| d.get_temp(footer_id()))
}
@@ -861,7 +861,7 @@ pub fn paths_panel(app: &mut PhotocraftApp, ui: &mut egui::Ui) {
let has_layer_path = rows.iter().any(|r| r.kind == PathRow::Layer);
let mut action: Option<(&str, Value)> = None;
// The buttons sit in a footer at the panel's bottom, like Photoshop's.
let footer = 34.0;
let footer = crate::widgets::footer_height(ui) + ui.spacing().item_spacing.y;
let fill = ui.available_height() > footer + 60.0;
let rows_h = if fill { ui.available_height() - footer } else { f32::INFINITY };
egui::ScrollArea::vertical().id_salt("path-rows").max_height(rows_h).min_scrolled_height(if fill { rows_h } else { 0.0 }).auto_shrink([false, !fill]).show(
@@ -929,12 +929,8 @@ pub fn paths_panel(app: &mut PhotocraftApp, ui: &mut egui::Ui) {
}
},
);
ui.add_space(4.0);
crate::widgets::hairline(ui);
ui.add_space(2.0);
let sel = app.ui.selected_path.clone().filter(|s| s != "layer" || has_layer_path).unwrap_or_else(|| "work".into());
let footer_rect = ui.horizontal(|ui| {
ui.spacing_mut().item_spacing.x = 2.0;
let buttons = crate::widgets::panel_footer(ui, |ui| {
let fg = hex(app.session.tools.foreground);
let mut n = doc.paths.len() + 1;
while doc.paths.iter().any(|p| p.name == format!("Path {n}")) {
@@ -955,14 +951,19 @@ pub fn paths_panel(app: &mut PhotocraftApp, ui: &mut egui::Ui) {
let items = items.map(|(icon, tip, cmd, p)| {
if cmd == "path.delete" && delete_layer_path { (icon, "Delete vector mask", "layer.vectorMask.delete", json!({})) } else { (icon, tip, cmd, p) }
});
for (icon, tip, cmd, p) in items {
// Laid out from the right, so the last button goes first.
let mut buttons = Rect::NOTHING;
for (icon, tip, cmd, p) in items.into_iter().rev() {
let icon = if crate::icons::exists(icon) { icon } else { "square" };
if crate::icons::button(ui, icon, 24.0, false, tip).clicked() {
let b = crate::icons::button(ui, icon, 26.0, false, tip);
if b.clicked() {
action = Some((cmd, p));
}
buttons = buttons.union(b.rect);
}
buttons
});
ctx_data_footer(ui.ctx(), footer_rect.response.rect);
ctx_data_footer(ui.ctx(), buttons);
if let Some((cmd, p)) = action
&& let Err(e) = app.run(cmd, p)
{
+36 -9
View File
@@ -59,11 +59,12 @@ pub fn card_ex(ui: &mut Ui, id: &str, tabs: &[&str], selected: &mut usize, colla
if t.pro {
return pro_panel(ui, id, tabs, selected, collapsed, body);
}
let m = body_margin(false);
let frame = egui::Frame::NONE
.fill(t.card)
.stroke(Stroke::new(1.0, t.card_border))
.corner_radius(CornerRadius::same(t.radius as u8))
.inner_margin(egui::Margin { left: 8, right: 8, top: 6, bottom: if collapsed { 6 } else { 10 } });
.inner_margin(egui::Margin { bottom: if collapsed { 6 } else { m.bottom }, ..m });
let out = frame
.show(ui, |ui| {
ui.set_width(ui.available_width());
@@ -88,6 +89,36 @@ pub fn card_ex(ui: &mut Ui, id: &str, tabs: &[&str], selected: &mut usize, colla
out
}
/// Inner margin of a dock panel's body: a Pro panel's, or a Studio card's below its tab strip.
fn body_margin(pro: bool) -> egui::Margin {
if pro { egui::Margin::same(8) } else { egui::Margin { left: 8, right: 8, top: 6, bottom: 10 } }
}
/// Height of a panel footer's bar ([`panel_footer`]), under its 1 px line.
pub const FOOTER_BAR: f32 = 30.0;
/// The height a [`panel_footer`] takes from the panel body: its line, and its bar down to the
/// body's bottom margin (the bar runs on over the margin).
pub fn footer_height(ui: &Ui) -> f32 {
1.0 + FOOTER_BAR - body_margin(Tokens::get(ui.ctx()).pro).bottom as f32
}
/// A panel footer as in Photoshop's Layers and History panels: a bar of buttons under a line that
/// runs from edge to edge of the panel, the buttons centred in the bar's height and laid out from
/// the right. Drawn last in a body that fills its group (leave it [`footer_height`]), the bar ends
/// at the panel's bottom edge.
pub fn panel_footer<R>(ui: &mut Ui, add: impl FnOnce(&mut Ui) -> R) -> R {
let t = Tokens::get(ui.ctx());
let m = body_margin(t.pro);
let (r, _) = ui.allocate_exact_size(vec2(ui.available_width(), footer_height(ui)), Sense::hover());
let y = r.top() + 0.5;
ui.painter().line_segment([pos2(r.left() - m.left as f32, y), pos2(r.right() + m.right as f32, y)], Stroke::new(1.0, t.separator));
let bar = Rect::from_min_size(pos2(r.left(), r.top() + 1.0), vec2(r.width(), FOOTER_BAR));
let mut bar_ui = ui.new_child(egui::UiBuilder::new().max_rect(bar).layout(egui::Layout::right_to_left(egui::Align::Center)));
bar_ui.spacing_mut().item_spacing.x = 2.0;
add(&mut bar_ui)
}
/// Photoshop-grammar panel group: dark tab strip with flat tabs, flat body, hamburger menu.
fn pro_panel(ui: &mut Ui, id: &str, tabs: &[&str], selected: &mut usize, collapsed: bool, body: impl FnOnce(&mut Ui, usize)) -> CardResponse {
let t = Tokens::get(ui.ctx());
@@ -109,14 +140,10 @@ fn pro_panel(ui: &mut Ui, id: &str, tabs: &[&str], selected: &mut usize, collaps
}
// Body.
if !collapsed {
egui::Frame::NONE
.fill(t.card)
.corner_radius(CornerRadius { nw: 0, ne: 0, sw: 3, se: 3 })
.inner_margin(egui::Margin { left: 8, right: 8, top: 8, bottom: 8 })
.show(ui, |ui| {
ui.set_width(width - 16.0);
body(ui, *selected);
});
egui::Frame::NONE.fill(t.card).corner_radius(CornerRadius { nw: 0, ne: 0, sw: 3, se: 3 }).inner_margin(body_margin(true)).show(ui, |ui| {
ui.set_width(width - 16.0);
body(ui, *selected);
});
}
ui.add_space(2.0);
CardResponse { strip: strip_resp, menu: mresp, tab_double_clicked: tabs_out.double_clicked, tabs: tabs_out.tabs, chevron: tabs_out.chevron }