From 989440173fd488f497a752fb9574ff776293f8de Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E5=BE=B7=E5=AE=87?= Date: Thu, 10 Sep 2026 11:03:01 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=8C=E5=96=84=E7=BB=91=E5=AE=9A=E5=8C=BA?= =?UTF-8?q?=E5=9F=9F=E5=80=BC=E7=B1=BB=E5=9E=8B=E7=BA=A6=E6=9D=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 为 BindingArea 增加 Eq 以支持分离区域比较 --- .../ui_editor/commands/separation/marker.rs | 18 ++++++++++++------ .../commands/separation/model/binding.rs | 2 +- 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/apps/ai-game-creator-shell/src-tauri/src/ui_editor/commands/separation/marker.rs b/apps/ai-game-creator-shell/src-tauri/src/ui_editor/commands/separation/marker.rs index b02abafe1..a14245995 100644 --- a/apps/ai-game-creator-shell/src-tauri/src/ui_editor/commands/separation/marker.rs +++ b/apps/ai-game-creator-shell/src-tauri/src/ui_editor/commands/separation/marker.rs @@ -1,4 +1,4 @@ -use super::model::{SeparationNode, SeparationNote, TextMaskArea}; +use super::model::SeparationNode; use base64::Engine as _; use std::path::Path; use std::path::PathBuf; @@ -246,6 +246,7 @@ fn draw_brush( #[cfg(test)] mod tests { use super::*; + use crate::ui_editor::commands::separation::{SeparationNote, TextMaskArea}; #[test] fn draw_frame_adds_green_cross_corner_lines() { @@ -287,10 +288,15 @@ mod tests { height_px: 6, note: SeparationNote::default(), text_mask_areas: vec![TextMaskArea { - global_pos_x_px: 2, - global_pos_y_px: 3, - width_px: 2, - height_px: 2, + global_pos_x_px: 0, + global_pos_y_px: 0, + width_px: 1, + height_px: 1, + }, TextMaskArea { + global_pos_x_px: 1, + global_pos_y_px: 1, + width_px: 1, + height_px: 1, }], children: vec![], rework_count: 0, @@ -316,7 +322,7 @@ mod tests { 8, 8, ); - assert_eq!(*image.get_pixel(2, 4), PURPLE_FILL); + assert_eq!(*image.get_pixel(0, 0), PURPLE_FILL); assert_eq!(*image.get_pixel(1, 1), image::Rgba([0, 255, 0, 255])); } } diff --git a/apps/ai-game-creator-shell/src-tauri/src/ui_editor/commands/separation/model/binding.rs b/apps/ai-game-creator-shell/src-tauri/src/ui_editor/commands/separation/model/binding.rs index d552e8b12..c21b4388d 100644 --- a/apps/ai-game-creator-shell/src-tauri/src/ui_editor/commands/separation/model/binding.rs +++ b/apps/ai-game-creator-shell/src-tauri/src/ui_editor/commands/separation/model/binding.rs @@ -2,7 +2,7 @@ use crate::ui_editor::utils::NodeId; use schemars::JsonSchema; use serde::{Deserialize, Serialize}; -#[derive(Clone, Copy, Debug, Deserialize, PartialEq, Serialize, JsonSchema)] +#[derive(Clone, Copy, Debug, Deserialize, Eq, PartialEq, Serialize, JsonSchema)] #[schemars(deny_unknown_fields)] pub struct BindingArea { pub global_pos_x_px: u32,