mirror of
https://github.com/storytold/photocraft.git
synced 2026-11-28 14:18:22 -08:00
cargo fmt --all
This commit is contained in:
1 parent
8cd8e5e2e4
commit
fcda1c5b4b
20 files changed
+63
-131
No files matched your search
@@ -144,21 +144,21 @@ pub use enabled::has_pixel_or_channel;
|
||||
pub use enabled::is_mask_target;
|
||||
pub use enabled::paint_surface;
|
||||
use enabled::{can_redo, can_undo, has_doc, has_layer, has_selection};
|
||||
pub use layer_params::explicit_layer;
|
||||
pub use layer_params::layer_param;
|
||||
pub use layer_params::mask_at_depth;
|
||||
pub use layer_params::selection_mask;
|
||||
pub(crate) use layer_params::{NEW_LAYER_PATH, layer_listing, layer_panel_option, mask_new_layer};
|
||||
pub use layer_params::explicit_layer;
|
||||
pub(crate) use layer_references::{recorded_drop, recorded_layer};
|
||||
pub use ops::translate_layer;
|
||||
use ops::{arrange, merge_group, move_mask, set_mask, set_mask_and_deselect};
|
||||
pub(crate) use ops::{layer_copy, translate_layer_wrapped};
|
||||
pub use ops::translate_layer;
|
||||
pub use params::color_param;
|
||||
pub use params::parse_hex;
|
||||
use params::{bad, set_clipped};
|
||||
pub(crate) use params::{check_f32_values, cmyk_param, int, int_i32};
|
||||
pub use params::u32_id;
|
||||
pub use params::u32_id_param;
|
||||
use params::{bad, set_clipped};
|
||||
pub(crate) use params::{check_f32_values, cmyk_param, int, int_i32};
|
||||
pub use photocraft_color::blend::parse_blend;
|
||||
|
||||
pub use crate::registry::{CommandSpec, list_entry, list_entry_matches, search_keywords};
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
//! Rotation (right angles, flips and arbitrary), also off the new canvas; other marks still follow
|
||||
//! the image, and Crop keeps today's behaviour.
|
||||
|
||||
use serde_json::{json};
|
||||
use serde_json::json;
|
||||
|
||||
#[test]
|
||||
fn ruler_straighten_with_crop_asks_the_gate_for_its_rotation() {
|
||||
|
||||
@@ -55,20 +55,20 @@ pub(crate) use open::{batch_open_notice, batch_open_params, remember_batch_open}
|
||||
pub use open_as_smart_object::admit_as_smart_object;
|
||||
use open_as_smart_object::open_as_smart_object;
|
||||
use paths::is_file;
|
||||
pub use paths::join;
|
||||
pub(crate) use paths::openable_name;
|
||||
pub use paths::sanitize;
|
||||
pub use paths::stem;
|
||||
pub use paths::{
|
||||
extension, holds, holds_at, is_template, layered_extension, list_images, losses_at, portable_device_name, same_destination, same_file, saves_in_place,
|
||||
template_name, untitled_name,
|
||||
};
|
||||
pub(crate) use paths::{file_name, forward_slashes, is_windows_device_name, read_file, read_file_limited, write_file};
|
||||
pub use paths::join;
|
||||
pub use paths::sanitize;
|
||||
pub use paths::stem;
|
||||
pub(crate) use place_steps::PlaceSteps;
|
||||
use processing::{conditional_mode_change, fit_image, flatten_all_effects, flatten_all_masks, image_processor, load_files_into_stack};
|
||||
use save::save_a_copy;
|
||||
pub(crate) use save::{encode};
|
||||
pub use save::SaveOpts;
|
||||
pub(crate) use save::encode;
|
||||
use save::save_a_copy;
|
||||
pub use save::save_doc;
|
||||
pub use save::{
|
||||
dds_param, dpx_bits_param, jpeg_format_param, jpeg_quality, maximize_compatibility_param, pcraft_full_composite_param, pdf_spot_plates_param,
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
//! document, not one named after the first file.
|
||||
|
||||
use crate::EngineError;
|
||||
use photocraft_doc::{Layer};
|
||||
use photocraft_doc::Layer;
|
||||
use serde_json::json;
|
||||
|
||||
/// Two textured PNGs named a_base.png and b_shift.png (texture, so Auto-Align finds features).
|
||||
|
||||
@@ -26,13 +26,13 @@ pub use moves::shift_surface;
|
||||
pub(crate) use moves::with_links;
|
||||
pub use moves::{move_targets, move_to, moved, moved_target, moved_wrapping, moves_mask_alone, preview_move, translate, wrapped_delta};
|
||||
pub(crate) use moves::{wrap_path, wrap_surface, wraps_linked_masks};
|
||||
pub use selection::targets;
|
||||
pub use selection::top_level;
|
||||
use selection::{doc_state, find_layers, select_all_layers, select_linked};
|
||||
pub(crate) use selection::{mask_targets, recorded_step, reselect};
|
||||
pub use selection::targets;
|
||||
pub use selection::{select, selected, set_selection};
|
||||
pub(crate) use structure::{check_group_depth, relink_copies};
|
||||
pub use structure::deletion_neighbours;
|
||||
pub(crate) use structure::{check_group_depth, relink_copies};
|
||||
pub use structure::{delete_selected, duplicate_selected, group_layers, set_visible_selected};
|
||||
use structure::{link_layers, lock_layers, merge_layers, rename_layer, reverse};
|
||||
|
||||
|
||||
@@ -195,20 +195,20 @@ pub use placing::detach_psd;
|
||||
pub(crate) use placing::{affine_homography, set_placement, shift_smart, transform_placement};
|
||||
use placing::{convert, reset_transform, shift_layer, via_copy};
|
||||
pub use placing::{layer_to_smart, layers_to_smart, placement};
|
||||
pub use rendering::WarningRenderSources;
|
||||
use rendering::refresh_or_fail;
|
||||
pub use rendering::render_with_warnings_using;
|
||||
#[cfg(test)]
|
||||
use rendering::{NativeDigests, blend_surfaces, place, render_in};
|
||||
pub use rendering::{SourceCacheStatistics, source_cache_statistics};
|
||||
pub(crate) use rendering::{render_with_warnings, source_box};
|
||||
pub use rendering::WarningRenderSources;
|
||||
pub use rendering::render_with_warnings_using;
|
||||
pub use rendering::{apply_smart_filters, purge_stack_cache, refresh, refresh_layer, render, render_below_filter, stack_cache_bytes, stack_image};
|
||||
pub(crate) use rendering::{render_with_warnings, source_box};
|
||||
#[cfg(test)]
|
||||
use source::svg_source_image_in;
|
||||
pub use source::vector_scale;
|
||||
pub use source::{SourceImage, purge_source_cache, source_bytes, source_cache_bytes, source_decode_count, source_image, svg_source_image};
|
||||
use source::{authorize_source, authorized_source_bytes};
|
||||
pub(crate) use source::{restore_unrendered, take_caches};
|
||||
pub use source::vector_scale;
|
||||
|
||||
const SO: &[&str] = &["Layer", "Smart Objects"];
|
||||
const SF: &[&str] = &["Layer", "Smart Filter"];
|
||||
|
||||
@@ -69,25 +69,25 @@ mod paths;
|
||||
mod shape;
|
||||
mod vector_mask;
|
||||
|
||||
pub use params::{layer_id};
|
||||
pub use params::layer_id;
|
||||
pub use params::nums;
|
||||
pub use params::op_from;
|
||||
pub use params::pt;
|
||||
pub use params::{parse_path, parse_stroke, path_json};
|
||||
pub use paths::STROKE_PATH_TOOLS;
|
||||
pub use paths::is_work;
|
||||
pub use paths::path_mut;
|
||||
use paths::{
|
||||
clipping_path_clear, clipping_path_set, path_delete, path_fill, path_rename, path_set, path_stroke, path_to_selection, path_to_selection_with_mode,
|
||||
path_transform, paths_list, resolve_path, select_to_work_path,
|
||||
};
|
||||
pub use paths::{is_work};
|
||||
pub use paths::path_mut;
|
||||
pub(crate) use shape::{map_path, map_shape, shift_shape, translate_vectors_wrapped};
|
||||
pub use shape::bake_path;
|
||||
pub use shape::with_shape;
|
||||
use shape::{
|
||||
can_paste_shape_fill, can_paste_shape_stroke, combine_shapes, copy_shape_fill, copy_shape_stroke, has_shape_fill, has_shape_stroke, merge_components,
|
||||
paste_shape_fill, paste_shape_stroke, path_to_shape, selection_to_shape, shape_create, shape_edit, shape_info, shape_rasterize,
|
||||
};
|
||||
pub(crate) use shape::{map_path, map_shape, shift_shape, translate_vectors_wrapped};
|
||||
pub use shape::{preview_shape_stroke, refresh_shape, shape_path, transform_shape, translate_vectors};
|
||||
use vector_mask::{toggle_vector_mask, vector_mask_add, vector_mask_delete, vector_mask_edit, vector_mask_info, vector_mask_rasterize, with};
|
||||
|
||||
|
||||
@@ -20,7 +20,10 @@ pub use photocraft_engine_paint::{
|
||||
sampler_cmds, stamp_cmds,
|
||||
};
|
||||
// The vector-area commands' modules, likewise.
|
||||
pub use photocraft_engine_vector::{align_cmds, comps_cmds, layer_css_cmds, layer_xmp_cmds, notes_cmds, path_edit_cmds, rasterize_style_cmds, smart_svg_cmds, trap_cmds, type_area_cmds, type_caret_cmds, type_mask_cmds, type_styles_cmds};
|
||||
pub use photocraft_engine_vector::{
|
||||
align_cmds, comps_cmds, layer_css_cmds, layer_xmp_cmds, notes_cmds, path_edit_cmds, rasterize_style_cmds, smart_svg_cmds, trap_cmds, type_area_cmds,
|
||||
type_caret_cmds, type_mask_cmds, type_styles_cmds,
|
||||
};
|
||||
|
||||
mod install;
|
||||
|
||||
@@ -35,7 +38,10 @@ pub mod commands {
|
||||
adjustment_brush_cmds, brush_cmds, brush_key_cmds, eraser_cmds, face_cmds, fill_cmds, fill_key_cmds, paint_cmds, pick_cmds, redeye_cmds, retouch_cmds,
|
||||
sampler_cmds, stamp_cmds,
|
||||
};
|
||||
pub use photocraft_engine_vector::cmd::{align_cmds, comps_cmds, layer_css_cmds, layer_xmp_cmds, notes_cmds, path_edit_cmds, rasterize_style_cmds, smart_svg_cmds, trap_cmds, type_area_cmds, type_caret_cmds, type_mask_cmds, type_styles_cmds};
|
||||
pub use photocraft_engine_vector::cmd::{
|
||||
align_cmds, comps_cmds, layer_css_cmds, layer_xmp_cmds, notes_cmds, path_edit_cmds, rasterize_style_cmds, smart_svg_cmds, trap_cmds, type_area_cmds,
|
||||
type_caret_cmds, type_mask_cmds, type_styles_cmds,
|
||||
};
|
||||
}
|
||||
pub use commands as cmd;
|
||||
|
||||
|
||||
@@ -1,12 +1,10 @@
|
||||
//! Tests that run vector commands, moved from the engine-core `actions_record` tests: 1 test(s).
|
||||
|
||||
|
||||
use photocraft_doc::LayerId;
|
||||
|
||||
use serde_json::{json};
|
||||
|
||||
use photocraft_engine::{Session};
|
||||
use serde_json::json;
|
||||
|
||||
use photocraft_engine::Session;
|
||||
|
||||
fn session() -> Session {
|
||||
let mut s = Session::new();
|
||||
@@ -14,12 +12,10 @@ fn session() -> Session {
|
||||
s
|
||||
}
|
||||
|
||||
|
||||
fn new_layer(s: &mut Session, name: &str) -> u64 {
|
||||
s.execute("layer.new.layer", json!({"name": name})).unwrap()["layer"].as_u64().unwrap()
|
||||
}
|
||||
|
||||
|
||||
#[test]
|
||||
fn selection_actions_keep_the_active_layer_as_their_source() {
|
||||
let mut s = session();
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
//! Tests that run vector commands, moved from the engine-core `atn_cmds` tests: 2 test(s).
|
||||
|
||||
use craft_psd::atn::{self};
|
||||
use crate::atn_fixtures::*;
|
||||
use photocraft_engine::{Session};
|
||||
use photocraft_engine::atn_cmds::{PHOTOSHOP_STEP};
|
||||
use craft_psd::atn::{self};
|
||||
use photocraft_engine::Session;
|
||||
use photocraft_engine::atn_cmds::PHOTOSHOP_STEP;
|
||||
|
||||
use photocraft_engine::actions_cmds::ActionStep;
|
||||
|
||||
@@ -15,7 +15,6 @@ use craft_psd::descriptor::{Descriptor, ReferenceItem, UnicodeString, Value as D
|
||||
|
||||
use serde_json::json;
|
||||
|
||||
|
||||
fn item(event: &str, label: &str, d: Option<Descriptor>) -> AtnItem {
|
||||
let event = match event.as_bytes() {
|
||||
[a, b, c, dd] => AtnEvent::Code([*a, *b, *c, *dd]),
|
||||
@@ -24,12 +23,10 @@ fn item(event: &str, label: &str, d: Option<Descriptor>) -> AtnItem {
|
||||
AtnItem { event, dictionary: label.as_bytes().to_vec(), descriptor: d, ..Default::default() }
|
||||
}
|
||||
|
||||
|
||||
fn b64(bytes: &[u8]) -> String {
|
||||
photocraft_paint::tile::b64_encode(bytes)
|
||||
}
|
||||
|
||||
|
||||
#[test]
|
||||
fn layer_comp_apply_imports_plays_and_undoes() {
|
||||
let name = "合成 𠮷";
|
||||
@@ -64,7 +61,6 @@ fn layer_comp_apply_imports_plays_and_undoes() {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#[test]
|
||||
fn layer_comp_apply_unknown_references_are_kept_and_stop_playback() {
|
||||
let references = [
|
||||
@@ -105,7 +101,6 @@ fn layer_comp_apply_unknown_references_are_kept_and_stop_playback() {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
fn set_of(name: &str, actions: Vec<(&str, Vec<AtnItem>)>) -> String {
|
||||
let file = AtnFile {
|
||||
name: UnicodeString::new_nul(name),
|
||||
|
||||
@@ -1,10 +1,8 @@
|
||||
//! Tests that run vector commands, moved from the engine-core `automate_cmds` tests: 2 test(s).
|
||||
|
||||
use photocraft_doc::{Layer, LayerContent};
|
||||
use serde_json::{json};
|
||||
use photocraft_engine::{EngineError, Session};
|
||||
|
||||
|
||||
use serde_json::json;
|
||||
|
||||
pub(super) fn tmp(name: &str) -> String {
|
||||
let d = std::env::temp_dir().join(format!("photocraft-automate-{}-{name}", std::process::id()));
|
||||
@@ -13,7 +11,6 @@ pub(super) fn tmp(name: &str) -> String {
|
||||
d.to_string_lossy().into_owned()
|
||||
}
|
||||
|
||||
|
||||
#[test]
|
||||
fn stacked_smart_object_holds_the_loaded_layers_at_its_top_level() {
|
||||
// Like Photoshop, Load Files into Stack › Create Smart Object (Statistics without alignment) and
|
||||
@@ -51,7 +48,6 @@ fn stacked_smart_object_holds_the_loaded_layers_at_its_top_level() {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// #4671: Load Files into Stack's Attempt to Automatically Align Source Images runs Auto-Align
|
||||
/// Layers on the loaded layers, then (with Create Smart Object) puts them in one smart object;
|
||||
/// without the smart object they stay loose layers, selected.
|
||||
|
||||
@@ -1,15 +1,11 @@
|
||||
//! Tests that run vector commands, moved from the engine-core `count_resize` tests: 4 test(s).
|
||||
|
||||
|
||||
use serde_json::{Value, json};
|
||||
|
||||
|
||||
use photocraft_engine::Session;
|
||||
|
||||
|
||||
const POINT: [f64; 2] = [99.3, 99.7];
|
||||
|
||||
|
||||
fn doc() -> Session {
|
||||
let mut s = Session::new();
|
||||
s.execute("file.new", json!({"width": 600, "height": 400})).unwrap();
|
||||
@@ -18,17 +14,14 @@ fn doc() -> Session {
|
||||
s
|
||||
}
|
||||
|
||||
|
||||
fn count_point(s: &Session) -> [f64; 2] {
|
||||
s.active().unwrap().doc.measurement.count_groups[0].points[0]
|
||||
}
|
||||
|
||||
|
||||
fn note(s: &Session) -> [f64; 2] {
|
||||
s.active().unwrap().doc.notes[0].position
|
||||
}
|
||||
|
||||
|
||||
#[test]
|
||||
fn count_points_keep_their_coordinates() {
|
||||
// The note at [100, 100] on the 600×400 canvas, where each command moves it.
|
||||
@@ -54,7 +47,6 @@ fn count_points_keep_their_coordinates() {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#[test]
|
||||
fn all_three_in_a_row_leave_the_point_where_it_was() {
|
||||
let mut s = doc();
|
||||
@@ -64,7 +56,6 @@ fn all_three_in_a_row_leave_the_point_where_it_was() {
|
||||
assert_eq!(count_point(&s), POINT);
|
||||
}
|
||||
|
||||
|
||||
#[test]
|
||||
fn crop_still_moves_count_points() {
|
||||
let mut s = doc();
|
||||
@@ -72,7 +63,6 @@ fn crop_still_moves_count_points() {
|
||||
assert_ne!(count_point(&s), POINT, "not measured: Crop keeps today's behaviour");
|
||||
}
|
||||
|
||||
|
||||
#[test]
|
||||
fn ruler_straighten_with_crop_moves_count_points_with_the_image() {
|
||||
let mut s = Session::new();
|
||||
|
||||
@@ -8,7 +8,6 @@ use photocraft_doc::{Layer, LayerContent};
|
||||
|
||||
use serde_json::json;
|
||||
|
||||
|
||||
/// Two textured PNGs named a_base.png and b_shift.png (texture, so Auto-Align finds features).
|
||||
fn two_files(dir: &std::path::Path) -> Result<Vec<String>, Box<dyn std::error::Error>> {
|
||||
let mut s = Session::new();
|
||||
@@ -31,7 +30,6 @@ fn two_files(dir: &std::path::Path) -> Result<Vec<String>, Box<dyn std::error::E
|
||||
Ok(paths)
|
||||
}
|
||||
|
||||
|
||||
/// The smart object keeps the first file's name with and without aligning; only the document's
|
||||
/// name changes.
|
||||
#[test]
|
||||
|
||||
@@ -1,26 +1,21 @@
|
||||
//! Tests that run vector commands, moved from the engine-core `layer_copy_cmds` tests: 5 test(s).
|
||||
|
||||
|
||||
use photocraft_color::{ColorMode};
|
||||
use photocraft_color::ColorMode;
|
||||
|
||||
use photocraft_doc::{Document, LayerContent, LayerId};
|
||||
|
||||
use serde_json::{Value, json};
|
||||
|
||||
|
||||
use photocraft_engine::Session;
|
||||
|
||||
|
||||
fn doc(s: &Session, i: usize) -> &Document {
|
||||
&s.documents()[i].doc
|
||||
}
|
||||
|
||||
|
||||
fn copied(r: &Value) -> LayerId {
|
||||
LayerId(r["layers"][0].as_u64().unwrap())
|
||||
}
|
||||
|
||||
|
||||
/// The type layer `id` of document `i`.
|
||||
fn text(s: &Session, i: usize, id: LayerId) -> &photocraft_doc::TextLayer {
|
||||
match &doc(s, i).layer(id).unwrap().content {
|
||||
@@ -29,12 +24,10 @@ fn text(s: &Session, i: usize, id: LayerId) -> &photocraft_doc::TextLayer {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
fn close(a: f32, b: f32) -> bool {
|
||||
(a - b).abs() <= 1e-4 * b.abs().max(1.0)
|
||||
}
|
||||
|
||||
|
||||
/// Document 0 at 72 ppi with "Hello" in Paragraph Style 1 (24 pt) and "He" also in Character
|
||||
/// Style 1 (24 pt, underlined); document 1 at 300 ppi, its own styles made by `dest`.
|
||||
fn styled_type_docs(dest: impl FnOnce(&mut Session)) -> (Session, LayerId) {
|
||||
@@ -51,7 +44,6 @@ fn styled_type_docs(dest: impl FnOnce(&mut Session)) -> (Session, LayerId) {
|
||||
(s, LayerId(t))
|
||||
}
|
||||
|
||||
|
||||
/// The styles panel state of `range` in layer `id` of document 1.
|
||||
fn styles_of(s: &mut Session, id: LayerId, range: [usize; 2]) -> (Value, Value) {
|
||||
s.set_active(1);
|
||||
@@ -60,7 +52,6 @@ fn styles_of(s: &mut Session, id: LayerId, range: [usize; 2]) -> (Value, Value)
|
||||
(c, p)
|
||||
}
|
||||
|
||||
|
||||
/// #10500: type copied to a document of another resolution brings the styles it uses, as in
|
||||
/// the reference application (measured with Duplicate Layer from 72 to 300 ppi): a style the
|
||||
/// destination lacks arrives under its name, scaled like the text (24 pt → 5.76 pt), so the
|
||||
@@ -94,7 +85,6 @@ fn copied_type_brings_its_styles_scaled() {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// A destination that already has a style of the same name keeps its definition (24 pt), and
|
||||
/// the copy, at 5.76 pt, shows a local override ("+"), as in the reference application.
|
||||
#[test]
|
||||
@@ -112,7 +102,6 @@ fn copied_type_uses_the_destinations_same_named_style() {
|
||||
assert!(close(text(&s, 1, id).runs[0].style.size_pt, 5.76));
|
||||
}
|
||||
|
||||
|
||||
/// Duplicate Layer › New Document brings the styles the type uses (at the same size).
|
||||
#[test]
|
||||
fn type_duplicated_to_a_new_document_keeps_its_styles() {
|
||||
@@ -129,7 +118,6 @@ fn type_duplicated_to_a_new_document_keeps_its_styles() {
|
||||
assert_eq!(text(&s, i, id).runs, text(&s, 0, t).runs);
|
||||
}
|
||||
|
||||
|
||||
/// Document 0 (RGB, 72 ppi) with "Hello" whose "He" is in Character Style 1 (red); document 1
|
||||
/// (CMYK, 72 ppi). The type layer is selected in document 0.
|
||||
fn red_styled_type_docs() -> (Session, LayerId) {
|
||||
@@ -143,7 +131,6 @@ fn red_styled_type_docs() -> (Session, LayerId) {
|
||||
(s, LayerId(t))
|
||||
}
|
||||
|
||||
|
||||
/// The colour Character Style 1 of document `i` sets, and whether "He" of `id` overrides it.
|
||||
fn style_color(s: &mut Session, i: usize, id: LayerId) -> (photocraft_color::Color, bool) {
|
||||
s.set_active(i);
|
||||
@@ -152,7 +139,6 @@ fn style_color(s: &mut Session, i: usize, id: LayerId) -> (photocraft_color::Col
|
||||
(serde_json::from_value(style["attrs"]["color"].clone()).unwrap(), c["current"]["characterOverride"].as_bool().unwrap())
|
||||
}
|
||||
|
||||
|
||||
/// Type copied to a document of another colour mode converts its run colours, and the style it
|
||||
/// brings converts with the same transform: the run matches its style (no override), so a later
|
||||
/// change to the style's colour still reaches it. Converting the document itself (Image › Mode,
|
||||
@@ -182,7 +168,6 @@ fn copied_type_styles_convert_their_colours_with_the_type() {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// Duplicate Layer › New Document keeps the source's Basic Paragraph: type that inherits its
|
||||
/// size from it has no override there, and Clear Override leaves it as it was.
|
||||
#[test]
|
||||
|
||||
@@ -1,16 +1,12 @@
|
||||
//! Tests that run vector commands, moved from the engine-core `param_schema` tests: 1 test(s).
|
||||
|
||||
|
||||
|
||||
use photocraft_engine::param_schema::{Params};
|
||||
|
||||
use photocraft_engine::param_schema::Params;
|
||||
|
||||
fn specs() -> &'static [photocraft_engine::commands::CommandSpec] {
|
||||
photocraft_engine::install().unwrap();
|
||||
photocraft_engine::commands::command_specs()
|
||||
}
|
||||
|
||||
|
||||
/// The registry docs written in another notation (unquoted keys): not checked for unknown keys
|
||||
/// until rewritten in the grammar. The list may only shrink.
|
||||
const UNPARSED: &[&str] = &[
|
||||
@@ -26,7 +22,6 @@ const UNPARSED: &[&str] = &[
|
||||
"timeline.setProps",
|
||||
];
|
||||
|
||||
|
||||
#[test]
|
||||
fn every_registry_doc_parses_and_renders_back_byte_for_byte() {
|
||||
let mut unparsed = Vec::new();
|
||||
|
||||
@@ -1,11 +1,10 @@
|
||||
//! Tests that run vector commands, moved from the engine-core `type_extra_cmds` tests: 2 test(s).
|
||||
|
||||
use photocraft_doc::text::{TextShape};
|
||||
use photocraft_doc::text::TextShape;
|
||||
use photocraft_doc::vector::{Path, Subpath};
|
||||
use photocraft_doc::{LayerContent, LayerId, TextLayer};
|
||||
use serde_json::{json};
|
||||
use photocraft_engine::{Session};
|
||||
|
||||
use photocraft_engine::Session;
|
||||
use serde_json::json;
|
||||
|
||||
fn session(depth: u32) -> Session {
|
||||
let mut s = Session::new();
|
||||
@@ -13,13 +12,11 @@ fn session(depth: u32) -> Session {
|
||||
s
|
||||
}
|
||||
|
||||
|
||||
fn text_layer(s: &mut Session, text: &str) -> LayerId {
|
||||
let r = s.execute("type.create", json!({"x": 20, "y": 70, "text": text, "size": 36, "color": "#000000"})).unwrap();
|
||||
LayerId(r["layer"].as_u64().unwrap())
|
||||
}
|
||||
|
||||
|
||||
fn text(s: &Session, id: LayerId) -> &TextLayer {
|
||||
match &s.active().unwrap().doc.layer(id).unwrap().content {
|
||||
LayerContent::Text(t) => t,
|
||||
@@ -27,12 +24,10 @@ fn text(s: &Session, id: LayerId) -> &TextLayer {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
fn ink(s: &Session, id: LayerId) -> photocraft_geom::Rect {
|
||||
s.active().unwrap().doc.layer(id).unwrap().surface().unwrap().content_bounds()
|
||||
}
|
||||
|
||||
|
||||
/// #9114: type on a path follows its own path when the path is edited (Direct Selection's
|
||||
/// `path.*` commands with `"name": "layer"`), as Photoshop's Type Path does; the Paths list names
|
||||
/// it, an edit is one undo step, and an edit that leaves no path is refused.
|
||||
@@ -68,7 +63,6 @@ fn type_follows_its_path_when_the_path_is_edited() {
|
||||
assert_eq!(ink(&s, id), before);
|
||||
}
|
||||
|
||||
|
||||
/// #9114: a type-on-a-path layer's vector mask is still what `"name": "layer"` edits, as on main
|
||||
/// and as `path.info` reads it; `"typePath": true` edits the Type Path; `path.list` reports both.
|
||||
#[test]
|
||||
|
||||
@@ -1,16 +1,14 @@
|
||||
//! Tests that run vector commands, moved from the engine-core `type_indexed_mode` tests: 3 test(s).
|
||||
|
||||
use photocraft_color::{ColorMode};
|
||||
use photocraft_doc::{LayerContent};
|
||||
use photocraft_color::ColorMode;
|
||||
use photocraft_doc::LayerContent;
|
||||
use photocraft_engine::Session;
|
||||
use photocraft_engine::cmd::type_cmds::name_selection_commit;
|
||||
use serde_json::{Value, json};
|
||||
use photocraft_engine::{Session};
|
||||
use photocraft_engine::cmd::{type_cmds::name_selection_commit};
|
||||
|
||||
|
||||
/// The typing session's coalesce key, as `ui-egui`'s `session_key` gives one.
|
||||
const SESSION: &str = "type-session-12041";
|
||||
|
||||
|
||||
/// The text the tool commits, at a baseline inside every document used here. `coalesce` for the
|
||||
/// tool's own calls (one step for the session), without it for a script's or the pin's.
|
||||
fn typed(coalesce: bool) -> Value {
|
||||
@@ -21,7 +19,6 @@ fn typed(coalesce: bool) -> Value {
|
||||
p
|
||||
}
|
||||
|
||||
|
||||
/// A blank RGB document, to be converted to the mode under test.
|
||||
fn blank() -> Session {
|
||||
let mut s = Session::new();
|
||||
@@ -29,7 +26,6 @@ fn blank() -> Session {
|
||||
s
|
||||
}
|
||||
|
||||
|
||||
fn indexed() -> Session {
|
||||
let mut s = blank();
|
||||
s.execute("image.mode.indexedColor", json!({"palette": "exact", "dither": "none", "forced": "none"})).unwrap();
|
||||
@@ -37,7 +33,6 @@ fn indexed() -> Session {
|
||||
s
|
||||
}
|
||||
|
||||
|
||||
fn bitmap() -> Session {
|
||||
let mut s = blank();
|
||||
s.execute("image.mode.grayscale", json!({})).unwrap();
|
||||
@@ -46,12 +41,10 @@ fn bitmap() -> Session {
|
||||
s
|
||||
}
|
||||
|
||||
|
||||
fn mode(s: &Session) -> ColorMode {
|
||||
s.active().unwrap().doc.mode
|
||||
}
|
||||
|
||||
|
||||
/// The Type tool's commit of the session's working layer in a document [`commits_as_selection`]
|
||||
/// names: the Type Mask tools' conversion, in the session's one step, which keeps the name the step
|
||||
/// was opened with.
|
||||
@@ -60,17 +53,14 @@ fn commit(s: &mut Session, layer: u64) {
|
||||
name_selection_commit(s);
|
||||
}
|
||||
|
||||
|
||||
fn text_layers(s: &Session) -> usize {
|
||||
s.active().unwrap().doc.walk().into_iter().filter(|(_, _, l)| matches!(l.content, LayerContent::Text(_))).count()
|
||||
}
|
||||
|
||||
|
||||
fn layers(s: &Session) -> usize {
|
||||
s.active().unwrap().doc.walk().len()
|
||||
}
|
||||
|
||||
|
||||
/// The selection's coverage over the whole canvas, in document pixels.
|
||||
fn coverage(s: &Session) -> Vec<f32> {
|
||||
let d = s.active().unwrap().doc.clone();
|
||||
@@ -84,13 +74,11 @@ fn coverage(s: &Session) -> Vec<f32> {
|
||||
out
|
||||
}
|
||||
|
||||
|
||||
/// The selection's bounds, as its corners.
|
||||
fn selection_corners(s: &Session) -> Option<[i32; 4]> {
|
||||
s.active().unwrap().doc.selection.as_ref().map(|m| m.content_bounds()).map(|r| [r.x0, r.y0, r.x1, r.y1])
|
||||
}
|
||||
|
||||
|
||||
/// Every layer's pixels, quantised: what the commit must leave exactly as it was.
|
||||
fn pixels(s: &Session) -> Vec<u8> {
|
||||
let d = s.active().unwrap().doc.clone();
|
||||
@@ -107,12 +95,10 @@ fn pixels(s: &Session) -> Vec<u8> {
|
||||
out
|
||||
}
|
||||
|
||||
|
||||
fn history(s: &Session) -> Vec<String> {
|
||||
s.active().unwrap().history.entries()
|
||||
}
|
||||
|
||||
|
||||
#[test]
|
||||
fn committing_in_indexed_color_or_bitmap_leaves_the_glyphs_selected_and_no_layer() {
|
||||
for (name, make) in [("Indexed Color", indexed as fn() -> Session), ("Bitmap", bitmap as fn() -> Session)] {
|
||||
@@ -146,7 +132,6 @@ fn committing_in_indexed_color_or_bitmap_leaves_the_glyphs_selected_and_no_layer
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#[test]
|
||||
fn the_selection_is_the_glyph_shape_the_type_mask_of_the_same_text_makes() {
|
||||
for (name, make) in [("Indexed Color", indexed as fn() -> Session), ("Bitmap", bitmap as fn() -> Session)] {
|
||||
@@ -163,7 +148,6 @@ fn the_selection_is_the_glyph_shape_the_type_mask_of_the_same_text_makes() {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// An edit that does not carry the session's `coalesce` key ends its coalesce group - in the tool
|
||||
/// that is the deliberately per-press Alt+arrow kerning step. The commit then makes a state of its
|
||||
/// own, which is what the Type Mask tools' commit and the plain layer's rename do in the same
|
||||
|
||||
@@ -1,24 +1,21 @@
|
||||
//! Tests that run vector commands, moved from the engine-core `type_spell_cmds` tests: 1 test(s).
|
||||
|
||||
use serde_json::{json};
|
||||
use photocraft_engine::{Session};
|
||||
use photocraft_engine::Session;
|
||||
use serde_json::json;
|
||||
|
||||
fn session(text: &str) -> (Session, u64) {
|
||||
let mut s = Session::new();
|
||||
s.execute("file.new", json!({"width": 300, "height": 100, "background": "white"})).unwrap();
|
||||
let r = s.execute("type.create", json!({"x": 10, "y": 50, "text": text, "size": 12})).unwrap();
|
||||
(s, r["layer"].as_u64().unwrap())
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn insert_crlf_reports_caret_in_normalized_text() {
|
||||
let (mut s, id) = session("");
|
||||
let inserted = s.execute("type.insertText", json!({"layer": id, "text": "x\r\ny"})).unwrap();
|
||||
|
||||
fn session(text: &str) -> (Session, u64) {
|
||||
let mut s = Session::new();
|
||||
s.execute("file.new", json!({"width": 300, "height": 100, "background": "white"})).unwrap();
|
||||
let r = s.execute("type.create", json!({"x": 10, "y": 50, "text": text, "size": 12})).unwrap();
|
||||
(s, r["layer"].as_u64().unwrap())
|
||||
}
|
||||
|
||||
|
||||
#[test]
|
||||
fn insert_crlf_reports_caret_in_normalized_text() {
|
||||
let (mut s, id) = session("");
|
||||
let inserted = s.execute("type.insertText", json!({"layer": id, "text": "x\r\ny"})).unwrap();
|
||||
|
||||
assert_eq!(inserted["caret"], 3);
|
||||
assert_eq!(s.execute("type.info", json!({"layer": id})).unwrap()["text"], "x\ny");
|
||||
assert_eq!(s.execute("type.caret", json!({"layer": id, "index": inserted["caret"]})).unwrap()["index"], inserted["caret"]);
|
||||
}
|
||||
assert_eq!(inserted["caret"], 3);
|
||||
assert_eq!(s.execute("type.info", json!({"layer": id})).unwrap()["text"], "x\ny");
|
||||
assert_eq!(s.execute("type.caret", json!({"layer": id, "index": inserted["caret"]})).unwrap()["index"], inserted["caret"]);
|
||||
}
|
||||
@@ -1,24 +1,19 @@
|
||||
//! Tests that run vector commands, moved from the engine-core `type_vertical_history_name` tests: 1 test(s).
|
||||
|
||||
|
||||
use serde_json::{json};
|
||||
|
||||
use serde_json::json;
|
||||
|
||||
use photocraft_engine::Session;
|
||||
|
||||
|
||||
fn session() -> Session {
|
||||
let mut s = Session::new();
|
||||
s.execute("file.new", json!({"width": 300, "height": 300})).unwrap();
|
||||
s
|
||||
}
|
||||
|
||||
|
||||
fn entries(s: &Session) -> Vec<String> {
|
||||
s.active().unwrap().history.entries()
|
||||
}
|
||||
|
||||
|
||||
/// The Type Mask tools' commands: a hidden working layer from `type.create`, then
|
||||
/// `type.createSelection` removing it, all coalesced into the session's one step.
|
||||
#[test]
|
||||
|
||||
+2
-1
@@ -81,7 +81,8 @@ pub const TABLE: &[(&str, Class)] = &[
|
||||
/// `geom`, which the §3 diagram draws on one line. The GPU backend (`gpu`)
|
||||
/// reuses the CPU reference (`compose`) for LUTs and parity tests. The engine's crates form one
|
||||
/// chain per leaf crate, from `engine-core` to the top crate `engine` (photocraft#15710).
|
||||
pub const INTRA_LAYER_ORDER: &[&[&str]] = &[&["geom", "color", "raster"], &["compose", "gpu"], &["engine-core", "engine-paint", "engine"], &["engine-core", "engine-vector", "engine"]];
|
||||
pub const INTRA_LAYER_ORDER: &[&[&str]] =
|
||||
&[&["geom", "color", "raster"], &["compose", "gpu"], &["engine-core", "engine-paint", "engine"], &["engine-core", "engine-vector", "engine"]];
|
||||
|
||||
fn intra_layer_allowed(from: &str, to: &str) -> bool {
|
||||
let (from, to) = (short_name(from), short_name(to));
|
||||
|
||||
Reference in new issue
Block a user