From 9583d9238aaa503b3d27d231fe3abd3cd9b4a3d9 Mon Sep 17 00:00:00 2001 From: aiongg Date: Tue, 24 Nov 2026 00:54:30 +0000 Subject: [PATCH] minimal-port rewrite: 14 edits (split rename 6, dock 2, deps 2, dock rename 1, split 1, keymap 1, keymap rename 1) --- Cargo.toml | 1 + crates/ui-egui/Cargo.toml | 1 + crates/ui-egui/src/docking.rs | 20 +++++++++++--------- crates/ui-egui/src/menus.rs | 4 ++-- 4 files changed, 15 insertions(+), 11 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 0380d751..870bff04 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -95,6 +95,7 @@ craft-materialx = { git = "https://github.com/aiongg/craft-libs", rev = "22e82c9 # MCMAT v3 uses its merged archive revision and the matching ZIP crate craft-mcmat = { git = "https://github.com/aiongg/craft-libs", rev = "22e82c930ec7062fba45757a8cac8ba5e3cb94bc" } craft-ui = { git = "https://github.com/aiongg/craft-libs", rev = "22e82c930ec7062fba45757a8cac8ba5e3cb94bc" } +craft-behavior = { git = "https://github.com/aiongg/craft-libs", rev = "22e82c930ec7062fba45757a8cac8ba5e3cb94bc" } # Keyboard bindings (chords, dispatch and display text): storytold/craft-libs, MIT OR Apache-2.0 craft-keymap = { git = "https://github.com/aiongg/craft-libs", rev = "22e82c930ec7062fba45757a8cac8ba5e3cb94bc", features = ["egui"] } # Native dialogs that do not block the event loop: storytold/craft-libs, MIT OR Apache-2.0 diff --git a/crates/ui-egui/Cargo.toml b/crates/ui-egui/Cargo.toml index 45b01576..f6b7d5bb 100644 --- a/crates/ui-egui/Cargo.toml +++ b/crates/ui-egui/Cargo.toml @@ -14,6 +14,7 @@ materialcraft-render = { workspace = true } eframe = { workspace = true, features = ["default_fonts", "wgpu", "persistence"] } egui = { workspace = true } craft-ui = { workspace = true } +craft-behavior = { workspace = true } craft-keymap = { workspace = true, features = ["egui"] } egui-phosphor = { version = "0.14", features = ["regular"] } serde = { workspace = true } diff --git a/crates/ui-egui/src/docking.rs b/crates/ui-egui/src/docking.rs index f2ca03a9..bc6742a6 100644 --- a/crates/ui-egui/src/docking.rs +++ b/crates/ui-egui/src/docking.rs @@ -8,8 +8,10 @@ //! cannot close or float. The layout persists with `UiState` as a craft-ui `Workspace`; a layout //! that does not load or validate becomes the default. -use craft_ui::docking::{Action, DockArea, DockContent, DockStyle, Layout, Location, Node, PanelLimits, PanelState, Permissions, Placement}; -use craft_ui::layout::{SplitAxis, SplitSize}; +use craft_behavior::dock::{Action, DockPlacement, Layout, Location, Node, PanelState, Permissions}; +use craft_ui::docking::{DockArea, DockContent, DockStyle, PanelLimits}; +use craft_behavior::flow::Axis; +use craft_behavior::dock::SplitSize; use egui::{Id, Margin, RichText, Ui, vec2}; use serde::{Deserialize, Serialize}; use serde_json::Value; @@ -75,7 +77,7 @@ impl Panel { } /// The saved panel arrangement: craft-ui's workspace over MaterialCraft's panels. -pub type Workspace = craft_ui::docking::Workspace; +pub type Workspace = craft_behavior::dock::Workspace; /// The graph never moves, floats, closes or takes tabs; panels dock beside it. pub fn permissions(panel: &Panel) -> Permissions { @@ -86,7 +88,7 @@ fn tabs(panels: &[Panel]) -> Node { Node::Tabs { panels: panels.to_vec(), active: 0 } } -fn split(axis: SplitAxis, ratio: f32, first: Node, second: Node) -> Node { +fn split(axis: Axis, ratio: f32, first: Node, second: Node) -> Node { Node::Split { axis, size: SplitSize::Ratio(ratio), first: Box::new(first), second: Box::new(second) } } @@ -94,17 +96,17 @@ fn split(axis: SplitAxis, ratio: f32, first: Node, second: Node) - /// middle; properties on the right. Console and history are closed and open floating. pub fn default_workspace() -> Workspace { use Panel::*; - let left = split(SplitAxis::Vertical, 0.36, tabs(&[Explorer]), tabs(&[Library])); - let views = split(SplitAxis::Horizontal, 0.5, tabs(&[View3d]), tabs(&[View2d])); - let center = split(SplitAxis::Vertical, 0.52, tabs(&[Graph]), views); - let root = split(SplitAxis::Horizontal, 0.15, left, split(SplitAxis::Horizontal, 0.8, center, tabs(&[Properties]))); + let left = split(Axis::Y, 0.36, tabs(&[Explorer]), tabs(&[Library])); + let views = split(Axis::X, 0.5, tabs(&[View3d]), tabs(&[View2d])); + let center = split(Axis::Y, 0.52, tabs(&[Graph]), views); + let root = split(Axis::X, 0.15, left, split(Axis::X, 0.8, center, tabs(&[Properties]))); let mut workspace = Workspace::new(Layout { root: Some(root), floating: Vec::new() }); for panel in Panel::ALL { if let Some(rect) = panel.float_rect() { let location = Location { floating: Some(rect), anchor: None, - placement: Placement::Tab { before: None }, + placement: DockPlacement::Tab { before: None }, size: None, stack: None, sibling: Vec::new(), diff --git a/crates/ui-egui/src/menus.rs b/crates/ui-egui/src/menus.rs index 915ceee6..f8c1b33c 100644 --- a/crates/ui-egui/src/menus.rs +++ b/crates/ui-egui/src/menus.rs @@ -1,6 +1,6 @@ //! Menu actions and shortcuts share stable command ids -use craft_keymap::{Active, Bindable, Binding, Chord, Keymap, Platform, Scope, Scopes}; +use craft_keymap::{Active, Binding, Chord, CommandDef, Keymap, Platform, Scope, Scopes}; use egui::class::HasClasses as _; use serde_json::Value; @@ -318,7 +318,7 @@ pub(crate) fn shortcut_table() -> Vec<(&'static str, &'static str)> { pub(crate) fn keymap(platform: Platform) -> Keymap { let catalog = shortcut_table() .into_iter() - .filter_map(|(id, text)| Some(Bindable::new(id, id, Scope::app()).with_default(Binding::new(parse_shortcut(text)?)))) + .filter_map(|(id, text)| Some(CommandDef::new(id, id, Scope::app()).with_default(Binding::new(parse_shortcut(text)?)))) .collect(); Keymap::new(catalog, Scopes::new(), platform) }