mirror of
https://github.com/storytold/photocraft.git
synced 2026-12-02 06:20:48 +01:00
Justify buttons: grey when any formatted type layer is point text
Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
1 parent
c8907e2cd2
commit
b862323a8e
2 files changed
+29
-1
No files matched your search
@@ -2365,7 +2365,16 @@ fn type_sections(app: &mut PhotocraftApp, ui: &mut egui::Ui, character: bool, pa
|
||||
let cw = cell_width(full, items.len());
|
||||
// Justification needs a paragraph box: on point text Photoshop greys the four justify
|
||||
// buttons (#7713).
|
||||
let point = target(app).is_some_and(|(layer, _)| box_shape(app, LayerId(layer)).is_none());
|
||||
// The panel formats the layer being typed in, else every selected type layer.
|
||||
let point = match formatting_params(app) {
|
||||
Some(p) => p.get("layers").and_then(serde_json::Value::as_array).map_or_else(
|
||||
|| p.get("layer").and_then(serde_json::Value::as_u64).into_iter().collect::<Vec<_>>(),
|
||||
|ids| ids.iter().filter_map(serde_json::Value::as_u64).collect(),
|
||||
),
|
||||
None => Vec::new(),
|
||||
}
|
||||
.into_iter()
|
||||
.any(|layer| box_shape(app, LayerId(layer)).is_none());
|
||||
ui.horizontal(|ui| {
|
||||
ui.spacing_mut().item_spacing.x = 2.0;
|
||||
for (key, tip, a) in items {
|
||||
|
||||
@@ -2159,4 +2159,23 @@ fn justify_buttons_are_greyed_on_point_text() {
|
||||
}
|
||||
assert!(!h.get_by_label("Center text").accesskit_node().is_disabled(), "alignment itself stays available");
|
||||
}
|
||||
// A selection of a paragraph and a point type layer formats both: justify is greyed.
|
||||
let mut app = new_app();
|
||||
let point = app.run("type.create", json!({"text": "point", "size": 24, "x": 300, "y": 420})).unwrap()["layer"].as_u64().unwrap();
|
||||
let boxed =
|
||||
app.run("type.create", json!({"text": "boxed text", "size": 24, "x": 300, "y": 300, "box": [300, 300, 240, 180]})).unwrap()["layer"].as_u64().unwrap();
|
||||
app.run("layer.select", json!({"layer": point})).unwrap();
|
||||
app.run("layer.select", json!({"layer": boxed, "mode": "add"})).unwrap();
|
||||
assert_eq!(app.session.active().unwrap().selected_layers().len(), 2);
|
||||
let mut h = Harness::builder().with_size(vec2(320.0, 700.0)).build_ui_state(
|
||||
|ui, app: &mut PhotocraftApp| {
|
||||
if ui.ctx().fonts(|f| f.families().contains(&egui::FontFamily::Name("medium".into()))) {
|
||||
crate::type_tool::character_panel(app, ui, true);
|
||||
}
|
||||
},
|
||||
app,
|
||||
);
|
||||
PhotocraftApp::setup_context(&h.ctx, crate::theme::ThemeKind::ALL[0]);
|
||||
h.run_steps(4);
|
||||
assert!(h.get_by_label("Justify all").accesskit_node().is_disabled(), "one of the formatted layers is point text");
|
||||
}
|
||||
Reference in new issue
Block a user