Split layout and draw for slots (#524)

* Split layout and draw for slots

* nit

* nit

* Fix serialization

* Move effect (highlight/invalid) to layout calculation

* nit

* Fix type issue

* Resolve review comments
This commit is contained in:
Chenlei Hu
2025-02-13 20:20:57 -05:00
committed by GitHub
parent 5d03f4477e
commit ce44cea409
6 changed files with 130 additions and 68 deletions

21
src/utils/layout.ts Normal file
View File

@@ -0,0 +1,21 @@
import { Point, ReadOnlyRect } from "@/interfaces"
export class LayoutElement<T> {
public readonly value: T
public readonly boundingRect: ReadOnlyRect
constructor(o: {
value: T
boundingRect: ReadOnlyRect
}) {
this.value = o.value
this.boundingRect = o.boundingRect
}
get center(): Point {
return [
this.boundingRect[0] + this.boundingRect[2] / 2,
this.boundingRect[1] + this.boundingRect[3] / 2,
]
}
}