Implement stable serialization and restoration for dock layouts, including auto-hidden and floating panels
- Add `persistence.rs` for stable serialization of dock layouts without runtime identifiers. - Introduce `preview.rs` for geometry handling of dock drop previews. - Create `sizing.rs` to manage content-aware sizing policies and constraint solving for dock panels. - Implement `welcome.rs` to provide a welcome surface when no documents are open, featuring New and Open actions.
This commit is contained in:
@@ -1,11 +1,13 @@
|
||||
use hcie_engine_api::{Engine, BrushTip, BrushStyle};
|
||||
use hcie_engine_api::{BrushStyle, BrushTip, Engine};
|
||||
|
||||
#[test]
|
||||
fn bitmap_brush_stamp_shape() {
|
||||
let mut engine = Engine::new(64, 64);
|
||||
// 4x4 solid white square bitmap stamp
|
||||
let mut pixels = vec![0u8; 16];
|
||||
for i in 0..16 { pixels[i] = 255; }
|
||||
for i in 0..16 {
|
||||
pixels[i] = 255;
|
||||
}
|
||||
let brush = BrushTip {
|
||||
style: BrushStyle::Bitmap,
|
||||
size: 8.0,
|
||||
@@ -25,25 +27,46 @@ fn bitmap_brush_stamp_shape() {
|
||||
|
||||
// Check that the painted area is roughly 4x4, not a circular blob.
|
||||
// Count alpha > 0 pixels and bounding box.
|
||||
let mut min_x = 63; let mut max_x = 0; let mut min_y = 63; let mut max_y = 0;
|
||||
let mut min_x = 63;
|
||||
let mut max_x = 0;
|
||||
let mut min_y = 63;
|
||||
let mut max_y = 0;
|
||||
let mut count = 0;
|
||||
for y in 0..64 {
|
||||
for x in 0..64 {
|
||||
let a = output[(y*64+x)*4+3];
|
||||
let a = output[(y * 64 + x) * 4 + 3];
|
||||
if a > 0 {
|
||||
count += 1;
|
||||
if x < min_x { min_x = x; }
|
||||
if x > max_x { max_x = x; }
|
||||
if y < min_y { min_y = y; }
|
||||
if y > max_y { max_y = y; }
|
||||
if x < min_x {
|
||||
min_x = x;
|
||||
}
|
||||
if x > max_x {
|
||||
max_x = x;
|
||||
}
|
||||
if y < min_y {
|
||||
min_y = y;
|
||||
}
|
||||
if y > max_y {
|
||||
max_y = y;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
let w = (max_x - min_x + 1) as i32;
|
||||
let h = (max_y - min_y + 1) as i32;
|
||||
// Should fit inside ~8x8 because size=8 and stamp 4x4 scaled up
|
||||
assert!(w <= 8 && h <= 8, "bitmap dab bounding box {}x{} too large for 4x4 stamp", w, h);
|
||||
assert!(
|
||||
w <= 8 && h <= 8,
|
||||
"bitmap dab bounding box {}x{} too large for 4x4 stamp",
|
||||
w,
|
||||
h
|
||||
);
|
||||
assert!(count >= 8, "bitmap dab should paint some pixels");
|
||||
// Square-ish: aspect ratio not too far from 1 (was very low for circle vs square?)
|
||||
assert!(w.abs_diff(h) <= 2, "bitmap dab bounding box should be roughly square, got {}x{}", w, h);
|
||||
assert!(
|
||||
w.abs_diff(h) <= 2,
|
||||
"bitmap dab bounding box should be roughly square, got {}x{}",
|
||||
w,
|
||||
h
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user