mirror of
https://github.com/storytold/photocraft.git
synced 2026-12-02 06:20:48 +01:00
Layers panel: group disclosure triangles expand/collapse groups (#126)
Group rows get a disclosure triangle; click toggles the group, Alt-click sets every group. Rows now list a group directly above its contents (the panel used to reverse a pre-order walk, putting headers below their children) and closed groups hide their contents (a kind filter still shows them). The state is Group::expanded (PSD section divider open/closed folder, .pcraft), toggled by the new layer.setExpanded command as a view change: no history step, a clean document stays clean. document.inspect reports it. Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
1 parent
3c54849ba6
commit
ef86fad78d
8 files changed
+376
-6
No files matched your search
@@ -988,6 +988,7 @@ fn build() -> Vec<CommandSpec> {
|
||||
v.extend(crate::wia_cmds::specs());
|
||||
v.extend(crate::variables_cmds::specs());
|
||||
v.extend(crate::plugin_cmds::specs());
|
||||
v.extend(crate::group_view_cmds::specs());
|
||||
v
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,158 @@
|
||||
//! Layers panel disclosure state: expanding and collapsing layer groups (#126).
|
||||
//!
|
||||
//! A group's open/closed state is document data ([`photocraft_doc::Group::expanded`], the PSD
|
||||
//! section divider's open/closed folder type, saved in `.pcraft` too) but, as in Photoshop,
|
||||
//! toggling it is a view change: no history step, and a clean document stays clean.
|
||||
|
||||
use std::sync::Arc;
|
||||
|
||||
use photocraft_doc::{Layer, LayerContent, LayerId};
|
||||
use serde_json::{Value, json};
|
||||
|
||||
use crate::commands::CommandSpec;
|
||||
use crate::{EngineError, Result, Session};
|
||||
|
||||
const ID: &str = "layer.setExpanded";
|
||||
|
||||
fn bad(msg: impl Into<String>) -> EngineError {
|
||||
EngineError::BadParams { cmd: ID.into(), msg: msg.into() }
|
||||
}
|
||||
|
||||
fn has_group(s: &Session) -> std::result::Result<(), String> {
|
||||
let d = s.active().ok_or("no document open")?;
|
||||
if d.doc.walk().iter().any(|(_, _, l)| l.is_group()) { Ok(()) } else { Err("the document has no layer groups".into()) }
|
||||
}
|
||||
|
||||
fn opt_bool(p: &Value, key: &str) -> Result<Option<bool>> {
|
||||
match p.get(key) {
|
||||
None | Some(Value::Null) => Ok(None),
|
||||
Some(v) => v.as_bool().map(Some).ok_or_else(|| bad(format!("`{key}` must be true or false"))),
|
||||
}
|
||||
}
|
||||
|
||||
fn set_all(layers: &mut [Layer], expanded: bool) -> usize {
|
||||
let mut n = 0;
|
||||
for l in layers {
|
||||
if let LayerContent::Group(g) = &mut l.content {
|
||||
g.expanded = expanded;
|
||||
n += 1 + set_all(&mut g.children, expanded);
|
||||
}
|
||||
}
|
||||
n
|
||||
}
|
||||
|
||||
/// `{"layer":id?,"expanded":bool?,"all":bool?}`: open or close a group (no `expanded`: toggle).
|
||||
/// With `all`, every group in the document takes the new state (Photoshop's ⌥-click on a
|
||||
/// disclosure triangle); without a layer, `all` toggles from "any group open".
|
||||
fn set_expanded(s: &mut Session, p: &Value) -> Result<Value> {
|
||||
let want = opt_bool(p, "expanded")?;
|
||||
let all = opt_bool(p, "all")?.unwrap_or(false);
|
||||
let st = s.active().ok_or(EngineError::NoDocument)?;
|
||||
let layer = match p.get("layer") {
|
||||
None | Some(Value::Null) if all => None,
|
||||
None | Some(Value::Null) => Some(st.active_layer.ok_or_else(|| bad("no layer given and no active layer"))?),
|
||||
Some(v) => Some(LayerId(v.as_u64().ok_or_else(|| bad("`layer` must be a layer id"))?)),
|
||||
};
|
||||
let current = match layer {
|
||||
Some(id) => match &st.doc.layer(id).ok_or(EngineError::NoLayer(id))?.content {
|
||||
LayerContent::Group(g) => g.expanded,
|
||||
_ => return Err(bad(format!("layer {} is not a group", id.0))),
|
||||
},
|
||||
None => st.doc.walk().iter().any(|(_, _, l)| matches!(&l.content, LayerContent::Group(g) if g.expanded)),
|
||||
};
|
||||
let expanded = want.unwrap_or(!current);
|
||||
let st = s.active_mut().ok_or(EngineError::NoDocument)?;
|
||||
// Copy-on-write: history snapshots keep their own state (layers share tiles, so this is cheap).
|
||||
let doc = Arc::make_mut(&mut st.doc);
|
||||
let changed = if all {
|
||||
set_all(&mut doc.layers, expanded)
|
||||
} else {
|
||||
let id = layer.ok_or_else(|| bad("no layer"))?;
|
||||
match doc.layer_mut(id).map(|l| &mut l.content) {
|
||||
Some(LayerContent::Group(g)) => {
|
||||
g.expanded = expanded;
|
||||
1
|
||||
}
|
||||
_ => return Err(EngineError::NoLayer(id)),
|
||||
}
|
||||
};
|
||||
Ok(json!({"expanded": expanded, "groups": changed}))
|
||||
}
|
||||
|
||||
pub fn specs() -> Vec<CommandSpec> {
|
||||
vec![CommandSpec {
|
||||
id: ID,
|
||||
label: "Expand/Collapse Group",
|
||||
menu: &[],
|
||||
shortcut: None,
|
||||
params: r##"{"layer":id?,"expanded":bool?,"all":bool?} (no expanded: toggle; all: every group; not an undo step)"##,
|
||||
enabled: has_group,
|
||||
run: set_expanded,
|
||||
journal: false,
|
||||
}]
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
fn session() -> (Session, u64, u64) {
|
||||
let mut s = Session::new();
|
||||
s.execute("file.new", json!({"width": 32, "height": 32})).unwrap();
|
||||
s.execute("layer.new.layer", json!({"name": "deep"})).unwrap();
|
||||
let inner = s.execute("layer.groupLayers", json!({"name": "inner"})).unwrap()["layer"].as_u64().unwrap();
|
||||
let outer = s.execute("layer.groupLayers", json!({"layer": inner, "name": "outer"})).unwrap()["layer"].as_u64().unwrap();
|
||||
(s, inner, outer)
|
||||
}
|
||||
|
||||
fn expanded(s: &Session, id: u64) -> bool {
|
||||
matches!(&s.active().unwrap().doc.layer(LayerId(id)).unwrap().content, LayerContent::Group(g) if g.expanded)
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn toggles_one_group_without_history_or_dirtying() {
|
||||
let (mut s, inner, outer) = session();
|
||||
let st = s.active_mut().unwrap();
|
||||
st.saved_revision = st.revision;
|
||||
let undo_steps = s.active().unwrap().history.entries().len();
|
||||
assert!(expanded(&s, inner) && expanded(&s, outer));
|
||||
assert_eq!(s.execute(ID, json!({"layer": inner})).unwrap()["expanded"], false);
|
||||
assert!(!expanded(&s, inner) && expanded(&s, outer));
|
||||
assert_eq!(s.active().unwrap().history.entries().len(), undo_steps, "no history step");
|
||||
assert_eq!(s.active().unwrap().saved_revision, s.active().unwrap().revision, "still clean");
|
||||
s.execute(ID, json!({"layer": inner, "expanded": true})).unwrap();
|
||||
assert!(expanded(&s, inner));
|
||||
// The inspect JSON reports it.
|
||||
s.execute(ID, json!({"layer": outer, "expanded": false})).unwrap();
|
||||
assert_eq!(s.execute("document.inspect", json!({})).unwrap()["layers"][0]["expanded"], false);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn all_sets_every_group() {
|
||||
let (mut s, inner, outer) = session();
|
||||
s.execute(ID, json!({"layer": outer, "all": true})).unwrap();
|
||||
assert!(!expanded(&s, inner) && !expanded(&s, outer));
|
||||
assert_eq!(s.execute(ID, json!({"all": true})).unwrap()["groups"], 2);
|
||||
assert!(expanded(&s, inner) && expanded(&s, outer));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn bad_params_fail_gracefully() {
|
||||
let (mut s, _, _) = session();
|
||||
let bg = s.active().unwrap().doc.layers[0].id.0;
|
||||
for p in [
|
||||
json!({"layer": bg}),
|
||||
json!({"layer": 9999}),
|
||||
json!({"layer": "x"}),
|
||||
json!({"layer": -1}),
|
||||
json!({"expanded": "yes", "all": true}),
|
||||
json!({"all": 3}),
|
||||
] {
|
||||
assert!(s.execute(ID, p.clone()).is_err(), "{p}");
|
||||
}
|
||||
let mut empty = Session::new();
|
||||
assert!(empty.execute(ID, json!({})).is_err());
|
||||
empty.execute("file.new", json!({"width": 8, "height": 8})).unwrap();
|
||||
assert!(empty.execute(ID, json!({"all": true})).is_err(), "no groups: disabled");
|
||||
}
|
||||
}
|
||||
@@ -85,6 +85,7 @@ fn layer_sel(l: &Layer, selected: &[photocraft_doc::LayerId]) -> Value {
|
||||
match &l.content {
|
||||
LayerContent::Group(g) => {
|
||||
v["children"] = Value::Array(g.children.iter().rev().map(|c| layer_sel(c, selected)).collect());
|
||||
v["expanded"] = json!(g.expanded);
|
||||
if let Some(a) = &g.artboard {
|
||||
v["artboard"] = json!({"rect": [a.rect.x0, a.rect.y0, a.rect.width(), a.rect.height()], "background": a.background.name(), "preset": a.preset});
|
||||
}
|
||||
|
||||
@@ -31,6 +31,7 @@ pub mod filters;
|
||||
pub mod filters_ext;
|
||||
mod frame_cmds;
|
||||
pub mod gallery_cmds;
|
||||
pub mod group_view_cmds;
|
||||
pub mod image_cmds;
|
||||
pub mod inspect;
|
||||
pub mod layer_menu_cmds;
|
||||
|
||||
@@ -0,0 +1,71 @@
|
||||
//! Layers panel tree: the rows in display order (top of the stack first, each group directly
|
||||
//! above its contents) and the groups' disclosure triangles (#126).
|
||||
//!
|
||||
//! Clicking a triangle opens or closes the group; ⌥-click sets every group in the document to
|
||||
//! the new state (Photoshop). The state is the group's `expanded` flag, document data saved in
|
||||
//! `.pcraft` and as the PSD section divider's open/closed folder type, toggled through
|
||||
//! `layer.setExpanded` (a view change: no history step).
|
||||
|
||||
use egui::{Rect, Sense, Shape, Stroke, pos2, vec2};
|
||||
use photocraft_doc::{Document, Layer, LayerContent};
|
||||
use serde_json::{Value, json};
|
||||
|
||||
use crate::theme::Tokens;
|
||||
|
||||
/// Width the disclosure triangle takes in a group row.
|
||||
pub const TRIANGLE_W: f32 = 14.0;
|
||||
|
||||
/// Rows as the Layers panel lists them: topmost layer first, a group directly above its
|
||||
/// children, and the contents of closed groups left out (unless `show_all`, used while the
|
||||
/// panel is filtered by kind so matches inside closed groups still show).
|
||||
pub fn display_rows(doc: &Document, show_all: bool) -> Vec<(usize, &Layer)> {
|
||||
fn rec<'a>(layers: &'a [Layer], depth: usize, show_all: bool, out: &mut Vec<(usize, &'a Layer)>) {
|
||||
for l in layers.iter().rev() {
|
||||
out.push((depth, l));
|
||||
if let LayerContent::Group(g) = &l.content
|
||||
&& (g.expanded || show_all)
|
||||
{
|
||||
rec(&g.children, depth + 1, show_all, out);
|
||||
}
|
||||
}
|
||||
}
|
||||
let mut out = Vec::new();
|
||||
rec(&doc.layers, 0, show_all, &mut out);
|
||||
out
|
||||
}
|
||||
|
||||
/// The hit area of a group row's triangle starting at `x`.
|
||||
pub fn triangle_rect(row: Rect, x: f32) -> Rect {
|
||||
Rect::from_min_size(pos2(x - 2.0, row.top()), vec2(TRIANGLE_W + 2.0, row.height()))
|
||||
}
|
||||
|
||||
/// Paint and handle a group row's disclosure triangle at `*x` (advancing it). Returns true when
|
||||
/// it was clicked this frame, so the row doesn't also treat the click as a selection.
|
||||
pub fn disclosure(ui: &mut egui::Ui, row: Rect, x: &mut f32, l: &Layer, actions: &mut Vec<(String, Value)>) -> bool {
|
||||
let LayerContent::Group(g) = &l.content else { return false };
|
||||
let hit = triangle_rect(row, *x);
|
||||
let resp = ui.interact(hit, ui.id().with(("disclosure", l.id.0)), Sense::click());
|
||||
let t = Tokens::get(ui.ctx());
|
||||
let c = pos2(*x + TRIANGLE_W / 2.0 - 1.0, row.center().y);
|
||||
let s = 3.5;
|
||||
let pts = if g.expanded {
|
||||
vec![pos2(c.x - s, c.y - s * 0.6), pos2(c.x + s, c.y - s * 0.6), pos2(c.x, c.y + s * 0.6)]
|
||||
} else {
|
||||
vec![pos2(c.x - s * 0.6, c.y - s), pos2(c.x + s * 0.6, c.y), pos2(c.x - s * 0.6, c.y + s)]
|
||||
};
|
||||
let color = if resp.hovered() { t.text } else { t.icon };
|
||||
ui.painter().add(Shape::convex_polygon(pts, color, Stroke::NONE));
|
||||
*x += TRIANGLE_W;
|
||||
let clicked = resp.clicked();
|
||||
if clicked {
|
||||
let all = ui.input(|i| i.modifiers.alt);
|
||||
actions.push(("layer.setExpanded".into(), json!({"layer": l.id.0, "expanded": !g.expanded, "all": all})));
|
||||
}
|
||||
let (verb, name) = (if g.expanded { "Collapse" } else { "Expand" }, l.name.clone());
|
||||
let resp = resp.on_hover_text(if g.expanded { "Collapse group (⌥-click: all groups)" } else { "Expand group (⌥-click: all groups)" });
|
||||
resp.widget_info(|| egui::WidgetInfo::labeled(egui::WidgetType::Button, true, format!("{verb} group {name}")));
|
||||
clicked
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests;
|
||||
@@ -0,0 +1,135 @@
|
||||
//! #126: group disclosure triangles in the real Layers panel (whole app, real pointer input).
|
||||
|
||||
use egui::{Modifiers, PointerButton, Pos2, vec2};
|
||||
use egui_kittest::Harness;
|
||||
use egui_kittest::kittest::Queryable;
|
||||
use photocraft_doc::{Document, LayerContent, LayerId};
|
||||
use serde_json::json;
|
||||
|
||||
use super::display_rows;
|
||||
use crate::PhotocraftApp;
|
||||
|
||||
/// Background, then `outer { in-outer, inner { deep } }` with a pixel layer above it all.
|
||||
fn layered() -> photocraft_engine::Session {
|
||||
let mut s = photocraft_engine::Session::new();
|
||||
s.execute("file.new", json!({"width": 64, "height": 48})).unwrap();
|
||||
s.execute("layer.new.layer", json!({"name": "deep"})).unwrap();
|
||||
let inner = s.execute("layer.groupLayers", json!({"name": "inner"})).unwrap()["layer"].as_u64().unwrap();
|
||||
let outer = s.execute("layer.groupLayers", json!({"layer": inner, "name": "outer"})).unwrap()["layer"].as_u64().unwrap();
|
||||
s.execute("layer.select", json!({"layer": inner})).unwrap();
|
||||
// `layer.new.layer` lands above the active layer, inside `outer`.
|
||||
s.execute("layer.new.layer", json!({"name": "in-outer"})).unwrap();
|
||||
s.execute("layer.select", json!({"layer": outer})).unwrap();
|
||||
s.execute("layer.new.layer", json!({"name": "top"})).unwrap();
|
||||
s
|
||||
}
|
||||
|
||||
fn harness_with(session: photocraft_engine::Session, ppp: f32) -> Harness<'static, PhotocraftApp> {
|
||||
let mut h = Harness::builder().with_size(vec2(1440.0, 900.0)).with_pixels_per_point(ppp).with_max_steps(64).build_eframe(move |cc| {
|
||||
PhotocraftApp::setup_context(&cc.egui_ctx, Default::default());
|
||||
PhotocraftApp::new(session, crate::Services::default())
|
||||
});
|
||||
h.run_steps(8);
|
||||
h
|
||||
}
|
||||
|
||||
fn group(h: &Harness<'_, PhotocraftApp>, name: &str) -> (LayerId, bool) {
|
||||
let doc = &h.state().session.active().unwrap().doc;
|
||||
doc.walk()
|
||||
.into_iter()
|
||||
.find_map(|(_, _, l)| match &l.content {
|
||||
LayerContent::Group(g) if l.name == name => Some((l.id, g.expanded)),
|
||||
_ => None,
|
||||
})
|
||||
.unwrap_or_else(|| panic!("no group {name}"))
|
||||
}
|
||||
|
||||
fn triangle(h: &Harness<'_, PhotocraftApp>, name: &str) -> Option<Pos2> {
|
||||
let verb = if group(h, name).1 { "Collapse" } else { "Expand" };
|
||||
h.query_by_label(&format!("{verb} group {name}")).map(|n| n.rect().center())
|
||||
}
|
||||
|
||||
/// A real click (press and release on separate frames), modifiers held throughout.
|
||||
fn click(h: &mut Harness<'_, PhotocraftApp>, at: Pos2, modifiers: Modifiers) {
|
||||
h.event(egui::Event::ModifiersChanged(modifiers));
|
||||
h.hover_at(at);
|
||||
h.run_steps(1);
|
||||
h.event(egui::Event::PointerButton { pos: at, button: PointerButton::Primary, pressed: true, modifiers });
|
||||
h.run_steps(1);
|
||||
h.event(egui::Event::PointerButton { pos: at, button: PointerButton::Primary, pressed: false, modifiers });
|
||||
h.run_steps(1);
|
||||
h.event(egui::Event::ModifiersChanged(Modifiers::NONE));
|
||||
h.run_steps(3);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn rows_list_groups_above_their_contents_and_hide_closed_ones() {
|
||||
let s = layered();
|
||||
let doc: &Document = &s.active().unwrap().doc;
|
||||
let names = |doc: &Document, all| display_rows(doc, all).iter().map(|(d, l)| format!("{d}:{}", l.name)).collect::<Vec<_>>();
|
||||
assert_eq!(names(doc, false), ["0:top", "0:outer", "1:in-outer", "1:inner", "2:deep", "0:Background"]);
|
||||
let mut closed = doc.clone();
|
||||
let id = closed.walk().into_iter().find(|(_, _, l)| l.name == "inner").unwrap().2.id;
|
||||
if let Some(LayerContent::Group(g)) = closed.layer_mut(id).map(|l| &mut l.content) {
|
||||
g.expanded = false;
|
||||
}
|
||||
assert_eq!(names(&closed, false), ["0:top", "0:outer", "1:in-outer", "1:inner", "0:Background"]);
|
||||
assert_eq!(names(&closed, true).len(), 6, "a kind filter still finds layers in closed groups");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn clicking_a_triangle_toggles_its_group_at_every_ui_scale() {
|
||||
for ppp in [1.0, 1.5, 2.0] {
|
||||
let mut h = harness_with(layered(), ppp);
|
||||
let active = h.state().session.active().unwrap().active_layer;
|
||||
let undo = h.state().session.active().unwrap().history.entries().len();
|
||||
let p = triangle(&h, "inner").expect("inner's triangle shows");
|
||||
click(&mut h, p, Modifiers::NONE);
|
||||
assert!(!group(&h, "inner").1, "@{ppp}x: click collapses");
|
||||
assert!(group(&h, "outer").1, "@{ppp}x: only that group");
|
||||
// The click opened/closed the group; it didn't select it or start a drag-reorder.
|
||||
assert_eq!(h.state().session.active().unwrap().active_layer, active, "@{ppp}x: selection unchanged");
|
||||
assert_eq!(h.state().session.active().unwrap().history.entries().len(), undo, "@{ppp}x: not an undo step");
|
||||
let p = triangle(&h, "inner").expect("still shows, now pointing right");
|
||||
click(&mut h, p, Modifiers::NONE);
|
||||
assert!(group(&h, "inner").1, "@{ppp}x: click expands again");
|
||||
// Nested: closing the outer group hides the inner group's row (and so its triangle).
|
||||
let p = triangle(&h, "outer").unwrap();
|
||||
click(&mut h, p, Modifiers::NONE);
|
||||
assert!(!group(&h, "outer").1);
|
||||
assert!(triangle(&h, "inner").is_none(), "@{ppp}x: inner row hidden in a closed group");
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn alt_click_toggles_every_group() {
|
||||
let mut h = harness_with(layered(), 1.0);
|
||||
let p = triangle(&h, "outer").unwrap();
|
||||
click(&mut h, p, Modifiers::ALT);
|
||||
assert!(!group(&h, "outer").1 && !group(&h, "inner").1, "⌥-click closes all groups");
|
||||
let p = triangle(&h, "outer").unwrap();
|
||||
click(&mut h, p, Modifiers::ALT);
|
||||
assert!(group(&h, "outer").1 && group(&h, "inner").1, "⌥-click opens all groups");
|
||||
assert!(triangle(&h, "inner").is_some());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn state_survives_psd_export_and_import_and_imported_groups_toggle() {
|
||||
let mut h = harness_with(layered(), 2.0);
|
||||
let p = triangle(&h, "inner").unwrap();
|
||||
click(&mut h, p, Modifiers::NONE);
|
||||
let doc = (*h.state().session.active().unwrap().doc).clone();
|
||||
let bytes = photocraft_io::export(&doc, "groups.psd", &Default::default()).unwrap().bytes;
|
||||
let back = photocraft_io::import("groups.psd", &bytes).unwrap().document;
|
||||
let mut s = photocraft_engine::Session::new();
|
||||
s.add_document(back, None);
|
||||
let mut h = harness_with(s, 2.0);
|
||||
assert!(group(&h, "outer").1 && !group(&h, "inner").1, "open/closed state round-trips through PSD");
|
||||
// A PSD-imported group toggles like any other.
|
||||
let p = triangle(&h, "inner").expect("imported group has a triangle");
|
||||
click(&mut h, p, Modifiers::NONE);
|
||||
assert!(group(&h, "inner").1);
|
||||
let p = triangle(&h, "outer").unwrap();
|
||||
click(&mut h, p, Modifiers::NONE);
|
||||
assert!(!group(&h, "outer").1);
|
||||
}
|
||||
@@ -45,6 +45,7 @@ pub mod icons;
|
||||
pub mod layer_menu_ui;
|
||||
pub mod layer_props_ui;
|
||||
pub mod layer_style;
|
||||
pub mod layer_tree_ui;
|
||||
pub mod links;
|
||||
pub mod liquify_ui;
|
||||
pub mod menu_catalog;
|
||||
|
||||
@@ -1129,7 +1129,8 @@ fn layers(app: &mut PhotocraftApp, ui: &mut egui::Ui) {
|
||||
ui.add_space(2.0);
|
||||
}
|
||||
|
||||
let rows = doc.walk();
|
||||
// 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 fill = ui.available_height() > footer + 60.0;
|
||||
@@ -1141,7 +1142,7 @@ fn layers(app: &mut PhotocraftApp, ui: &mut egui::Ui) {
|
||||
.auto_shrink([false, !fill])
|
||||
.show(ui, |ui| {
|
||||
let filter = app.ui.layer_filter.clone();
|
||||
for (_, depth, l) in rows.iter().rev() {
|
||||
for &(depth, l) in &rows {
|
||||
// Select › Isolate Layers.
|
||||
if !photocraft_engine::select_extra_cmds::isolation_shows(&doc, &isolated, l.id) {
|
||||
continue;
|
||||
@@ -1160,11 +1161,11 @@ fn layers(app: &mut PhotocraftApp, ui: &mut egui::Ui) {
|
||||
}
|
||||
}
|
||||
let row = RowSel { selected: selection.contains(&l.id), primary: active == Some(l.id), multi: selection.len() > 1 };
|
||||
layer_row(app, &ctx, ui, &doc, l, *depth, row, &mut actions);
|
||||
layer_row(app, &ctx, ui, &doc, l, depth, row, &mut actions);
|
||||
if !l.effects.items.is_empty() {
|
||||
effect_rows(app, ui, l, *depth);
|
||||
effect_rows(app, ui, l, depth);
|
||||
}
|
||||
crate::smart_ui::filter_rows(app, ui, l, *depth, &mut actions);
|
||||
crate::smart_ui::filter_rows(app, ui, l, depth, &mut actions);
|
||||
}
|
||||
});
|
||||
// End any layer drag after every row has had a chance to accept the drop.
|
||||
@@ -1325,6 +1326,7 @@ fn layer_row(
|
||||
actions.push(("layer.setProps".into(), json!({"layer": l.id.0, "visible": !l.visible})));
|
||||
}
|
||||
x += 28.0 + depth as f32 * 14.0;
|
||||
let toggled = crate::layer_tree_ui::disclosure(ui, rect, &mut x, l, actions);
|
||||
if l.clipped {
|
||||
painter.text(pos2(x, rect.center().y), Align2::LEFT_CENTER, "↳", egui::FontId::proportional(13.0), t.text_faint);
|
||||
x += 12.0;
|
||||
@@ -1405,7 +1407,7 @@ fn layer_row(
|
||||
});
|
||||
if let Some(p) = thumb_load {
|
||||
actions.push(("select.loadSelection".into(), p));
|
||||
} else if resp.clicked() && !eye_resp.clicked() {
|
||||
} else if resp.clicked() && !eye_resp.clicked() && !toggled {
|
||||
let mode = select_mode(ui.input(|i| i.modifiers));
|
||||
actions.push(("layer.select".into(), json!({"layer": l.id.0, "mode": mode})));
|
||||
// Clicking a thumbnail picks what painting targets; adjustment/fill layers target their mask.
|
||||
|
||||
Reference in new issue
Block a user