0: cord-gui cleanup: strip cruft, drop unused dep, fix license

This commit is contained in:
jess 2026-03-31 13:04:06 -07:00
parent 97653580e5
commit 72c0e3c259
3 changed files with 5 additions and 19 deletions

View File

@ -3,7 +3,7 @@ name = "cord-gui"
version = "0.1.0" version = "0.1.0"
edition = "2021" edition = "2021"
description = "Interactive GUI editor for Cord geometry" description = "Interactive GUI editor for Cord geometry"
license = "MIT" license = "Unlicense"
repository = "https://github.com/pszsh/cord" repository = "https://github.com/pszsh/cord"
publish = false publish = false
@ -23,7 +23,6 @@ cord-expr = { path = "../cord-expr" }
iced = { version = "0.14", features = ["wgpu", "advanced", "markdown", "tokio", "canvas"] } iced = { version = "0.14", features = ["wgpu", "advanced", "markdown", "tokio", "canvas"] }
rfd = "0.15" rfd = "0.15"
bytemuck = { version = "1", features = ["derive"] } bytemuck = { version = "1", features = ["derive"] }
anyhow = "1"
serde_json = "1" serde_json = "1"
dirs = "6" dirs = "6"
arboard = "3" arboard = "3"

View File

@ -323,7 +323,6 @@ impl App {
added = true; added = true;
} }
if !added { if !added {
// Force a re-render even if nothing new
self.reparse(); self.reparse();
} }
} }
@ -474,8 +473,6 @@ impl App {
match parse_expr_scene(src) { match parse_expr_scene(src) {
Ok(scene) => { Ok(scene) => {
let mut graph = scene.graph; let mut graph = scene.graph;
// Collect all SDF roots: cast objects + plot expressions
let mut sdf_roots: Vec<cord_trig::ir::NodeId> = Vec::new(); let mut sdf_roots: Vec<cord_trig::ir::NodeId> = Vec::new();
let render_objects: Vec<(String, cord_trig::ir::NodeId)> = if scene.cast_all { let render_objects: Vec<(String, cord_trig::ir::NodeId)> = if scene.cast_all {
@ -489,7 +486,6 @@ impl App {
sdf_roots.push(id); sdf_roots.push(id);
} }
// Convert plot expressions to SDF geometry
let mut plot_nodes: Vec<cord_trig::ir::NodeId> = if scene.plot_all { let mut plot_nodes: Vec<cord_trig::ir::NodeId> = if scene.plot_all {
let mut nodes: Vec<_> = scene.all_vars.iter().map(|(_, id)| *id).collect(); let mut nodes: Vec<_> = scene.all_vars.iter().map(|(_, id)| *id).collect();
nodes.extend(&scene.bare_exprs); nodes.extend(&scene.bare_exprs);
@ -497,7 +493,6 @@ impl App {
} else { } else {
Vec::new() Vec::new()
}; };
// Always include explicit plot() targets and auto-instantiated functions
plot_nodes.extend(&scene.plots); plot_nodes.extend(&scene.plots);
for &node_id in &plot_nodes { for &node_id in &plot_nodes {
let info = classify_from(&graph, node_id); let info = classify_from(&graph, node_id);
@ -505,7 +500,6 @@ impl App {
sdf_roots.push(sdf); sdf_roots.push(sdf);
} }
// Union all geometry
if sdf_roots.len() >= 2 { if sdf_roots.len() >= 2 {
let mut root = sdf_roots[0]; let mut root = sdf_roots[0];
for &node in &sdf_roots[1..] { for &node in &sdf_roots[1..] {
@ -1092,7 +1086,7 @@ impl App {
InputMode::Expr => "expr", InputMode::Expr => "expr",
InputMode::Scad => "scad", InputMode::Scad => "scad",
}; };
let mut status_parts = format!("{mode_label}"); let mut status_parts = mode_label.to_string();
if let Some(ref info) = self.info { if let Some(ref info) = self.info {
status_parts += &format!( status_parts += &format!(
" | {} | {}n | {}C", " | {} | {}n | {}C",
@ -1273,7 +1267,7 @@ impl App {
]; ];
let mut layers: Vec<Element<Message>> = vec![base_layout.into()]; let mut layers: Vec<Element<Message>> = vec![base_layout.into()];
if let Some(_) = self.context_menu_pos { if self.context_menu_pos.is_some() {
layers.push( layers.push(
mouse_area(container(Space::new()).width(Fill).height(Fill)) mouse_area(container(Space::new()).width(Fill).height(Fill))
.on_press(Message::DismissOverlay) .on_press(Message::DismissOverlay)
@ -1423,7 +1417,7 @@ fn ttip<'a>(content: impl Into<Element<'a, Message>>, tip: &str) -> Element<'a,
.into() .into()
} }
// === Free functions (unchanged from original) === // === Free functions ===
fn build_notebook_md(src: &str) -> String { fn build_notebook_md(src: &str) -> String {
let mut md = String::new(); let mut md = String::new();
@ -1849,7 +1843,6 @@ const TRANSFORM_FUNCS: &[&str] = &[
"rx", "ry", "rz", "mx", "my", "mz", "mov", "move", "rx", "ry", "rz", "mx", "my", "mz", "mov", "move",
]; ];
/// Accumulated transform state — at most one of each kind.
#[derive(Default)] #[derive(Default)]
struct TransformStack { struct TransformStack {
translate: Option<(f32, f32, f32)>, translate: Option<(f32, f32, f32)>,
@ -1862,8 +1855,6 @@ struct TransformStack {
mirror_z: bool, mirror_z: bool,
} }
/// Peel all outermost transform wrappers off an expression,
/// accumulating them into a TransformStack.
fn peel_transforms<'a>(expr: &'a str, stack: &mut TransformStack) -> &'a str { fn peel_transforms<'a>(expr: &'a str, stack: &mut TransformStack) -> &'a str {
let mut current = expr.trim(); let mut current = expr.trim();
loop { loop {
@ -1906,7 +1897,6 @@ fn peel_transforms<'a>(expr: &'a str, stack: &mut TransformStack) -> &'a str {
current current
} }
/// Apply the new action to a TransformStack.
fn apply_action(stack: &mut TransformStack, action: &TransformAction) { fn apply_action(stack: &mut TransformStack, action: &TransformAction) {
match action { match action {
TransformAction::Translate(dx, dy, dz) => { TransformAction::Translate(dx, dy, dz) => {
@ -1934,8 +1924,7 @@ fn apply_action(stack: &mut TransformStack, action: &TransformAction) {
} }
} }
/// Re-wrap an inner expression with the collapsed transform stack. // Order: mirror -> scale -> rotate -> translate (inside-out)
/// Order: mirror → scale → rotate → translate (inside-out).
fn recompose_transforms(inner: &str, stack: &TransformStack) -> String { fn recompose_transforms(inner: &str, stack: &TransformStack) -> String {
let mut result = inner.to_string(); let mut result = inner.to_string();
@ -1974,7 +1963,6 @@ fn recompose_transforms(inner: &str, stack: &TransformStack) -> String {
result result
} }
/// Peel all transforms, merge the new action, recompose as at-most-one-of-each.
fn apply_transform_collapsed(expr: &str, action: &TransformAction) -> String { fn apply_transform_collapsed(expr: &str, action: &TransformAction) -> String {
let mut stack = TransformStack::default(); let mut stack = TransformStack::default();
let inner = peel_transforms(expr, &mut stack); let inner = peel_transforms(expr, &mut stack);

View File

@ -180,7 +180,6 @@ impl<Message: 'static> shader::Program<Message> for SdfViewport {
} }
} }
/// Mutable camera updates called from App::update
impl SdfViewport { impl SdfViewport {
pub fn on_drag(&mut self, dx: f32, dy: f32) { pub fn on_drag(&mut self, dx: f32, dy: f32) {
let sensitivity = 0.005; let sensitivity = 0.005;