feat: add page surfaces and collapsible sidebar

This commit is contained in:
2026-11-10 16:18:47 +08:00
parent e0eff7755f
commit 82f9256a84
35 changed files with 1480 additions and 1751 deletions
+11 -1
View File
@@ -3,6 +3,7 @@ use std::sync::Arc;
#[derive(Debug, Clone, PartialEq)]
pub struct UiNode {
pub surface: Option<crate::page::Surface>,
pub flex: f32,
pub flex_policy: crate::layout::FlexPolicy,
pub main_align: crate::layout::MainAlign,
@@ -17,6 +18,7 @@ impl UiNode {
pub fn children(&self) -> &[Arc<UiNode>] {
match &self.kind {
UiKind::Column { children, .. }
| UiKind::Canvas { children, .. }
| UiKind::Row { children, .. }
| UiKind::Button { children, .. }
| UiKind::Scroll { children, .. } => children,
@@ -29,7 +31,8 @@ impl UiNode {
}
pub fn shallow_eq(&self, other: &Self) -> bool {
if self.flex_policy != other.flex_policy
if self.surface != other.surface
|| self.flex_policy != other.flex_policy
|| self.flex != other.flex
|| self.main_align != other.main_align
|| self.block_id != other.block_id
@@ -48,6 +51,9 @@ impl UiNode {
.all(|(a, b)| Arc::ptr_eq(a, b))
};
match (&self.kind, &other.kind) {
(UiKind::Canvas { positions: a, .. }, UiKind::Canvas { positions: b, .. }) => {
a == b && same_children()
}
(
UiKind::Text {
value: a,
@@ -124,6 +130,10 @@ impl UiNode {
#[derive(Debug, Clone, PartialEq)]
pub enum UiKind {
Canvas {
positions: Vec<[f32; 2]>,
children: Vec<Arc<UiNode>>,
},
Button {
padding: f32,
gap: f32,