A drawing app built for agent/human collaboration
Rust
Layer settings, and settings as a modal with a sidebar
Indicode BV09a38ccd021d
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex 3ed5c4f..81d6cc7 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -20,7 +20,7 @@ The first builds, and klad's licences.- Bones: a layer or group gets a skeleton (`klad bone`, the bone tool J), weights from the bones or painted (`klad weights`), and poses that bend the drawing (`klad pose`, pose mode); in-betweens of two poses turn the bones. The bone tool lists the skeleton, picks a bone in every mode, and moves ends, joints and whole bones with their children (`klad bone --move` with `--by`).- A first start: the start window welcomes, offers first steps (draw a shape, fill it, hand the drawing to an agent, ticked off as you go; Help > First steps opens them again) and six sample drawings that open as copies (`klad samples` lists and copies them).- Menus: a menu bar (the Mac's own, an in-window one on Windows and Linux) holds every command in File, Edit, Tools, Layer, Frame, Animation, View, Window and Help, with short labels, its keys, ticks for what is on and greyed items for what cannot run now; File has close (cmd W) and recent drawings.-- Keys: layers, groups and shapes move, turn, scale and fade between frames with eases (`klad key`, the keys section of the inspector).+- Keys: layers, groups and shapes move, turn, scale and fade between frames with eases (`klad key`, the keys section of layer settings).- Godot: `--godot-rig` exports a Skeleton2D with Polygon2D parts and the poses as animations; `--godot-scene` a parallax scene with a Parallax2D per depth plane.- `klad paintover` (and "paint over" in the layers panel): brushwork from any picture, strokes that follow its forms and stop at its colour edges, big to small, detail where the picture has it; `--like` and `--frames` carry it through an animation without boiling.- `klad compare` (and "compare with the reference" in the editor): a drawing against a reference picture in numbers and words, with a heat map.diff --git a/Cargo.lock b/Cargo.lockindex 7486823..784509b 100644--- a/Cargo.lock+++ b/Cargo.lock@@ -1744,7 +1744,7 @@ dependencies = [[[package]]name = "klad-app"-version = "0.1.2"+version = "0.1.3"dependencies = ["anyhow","block2 0.6.2",@@ -1773,7 +1773,7 @@ dependencies = [[[package]]name = "klad-brush"-version = "0.1.2"+version = "0.1.3"dependencies = ["anyhow","bytemuck",@@ -1789,7 +1789,7 @@ dependencies = [[[package]]name = "klad-cli"-version = "0.1.2"+version = "0.1.3"dependencies = ["anyhow","clap",@@ -1815,7 +1815,7 @@ dependencies = [[[package]]name = "klad-core"-version = "0.1.2"+version = "0.1.3"dependencies = ["anyhow","half",@@ -1827,7 +1827,7 @@ dependencies = [[[package]]name = "klad-render"-version = "0.1.2"+version = "0.1.3"dependencies = ["anyhow","bytemuck",diff --git a/Cargo.toml b/Cargo.tomlindex 5b221a9..557ba95 100644--- a/Cargo.toml+++ b/Cargo.toml@@ -3,7 +3,7 @@ resolver = "3"members = ["crates/*"][workspace.package]-version = "0.1.2"+version = "0.1.3"edition = "2024"license-file = "LICENSE"repository = "https://github.com/klad-app/klad"diff --git a/crates/app/src/commands.rs b/crates/app/src/commands.rsindex 20aaafb..c23cad5 100644--- a/crates/app/src/commands.rs+++ b/crates/app/src/commands.rs@@ -1071,7 +1071,7 @@ impl Cmd {G::Layers,T::None,R::No,- "curves above the active layer, changing what is under it in its group; the inspector picks levels, hue, balance, a gradient map or a colour fill instead",+ "curves above the active layer, changing what is under it in its group; layer settings switch it to levels, hue, balance, a gradient map or a colour fill",),Cmd::NewVectorLayer => spec("layer.new-vector",@@ -1624,7 +1624,7 @@ impl Cmd {),Cmd::InspectorPane => spec("panel.inspector",- "inspector panel",+ "layer settings panel",icon::INSPECTOR,G::Panels,T::None,@@ -2187,7 +2187,7 @@ impl Cmd {Cmd::HideDock => "Hide dock",Cmd::LayersPane => "Layers",Cmd::ToolPane => "Colour and brush",- Cmd::InspectorPane => "Inspector",+ Cmd::InspectorPane => "Layer settings",Cmd::NotesPane => "Notes",Cmd::HistoryPane => "History",Cmd::Timeline => "Timeline",diff --git a/crates/app/src/editor.rs b/crates/app/src/editor.rsindex 0b6b7b1..df64714 100644--- a/crates/app/src/editor.rs+++ b/crates/app/src/editor.rs@@ -621,6 +621,7 @@ pub(crate) struct Editor {compare: Option<compare::Compared>,bones: bones::BoneTool,first: first::FirstSteps,+ settings_section: prefs::Section,report_drawing: bool,strip_tools: [f32; 2],strip_foot: [f32; 2],@@ -793,6 +794,7 @@ impl Editor {compare: None,bones: bones::BoneTool::default(),first: first::FirstSteps::default(),+ settings_section: prefs::Section::default(),report_drawing: false,strip_tools: [570.0, 480.0],strip_foot: [186.0, 166.0],@@ -868,6 +870,7 @@ impl Editor {let Some((key, modifiers)) = pressed else {return;};+ ui.ctx().input_mut(|i| i.consume_key(modifiers, key));self.capturing = None;if key == egui::Key::Escape {self.say(Tone::Info, "the key stays as it was");@@ -3995,57 +3998,80 @@ impl Editor {let mut curve = self.settings.curve(&key);let raw = self.readout.pressure;let peak = self.settings.peak(&key);- ui.label(if self.readout.device == 0 {- "pen: not identified yet (move it away from the tablet and back)".to_string()- } else {- format!("pen: {key}")- });- ui.add(egui::ProgressBar::new(raw).text(format!("pen {raw:.3}")));- ui.add(egui::ProgressBar::new(curve.apply(raw)).text(format!("recorded {:.3}", curve.apply(raw))));- ui.label(format!("heaviest press seen {peak:.3}"));let before = curve;- ui.add(egui::Slider::new(&mut curve.low, 0.0..=0.5).text("lightest"))- .hint("the pen's raw pressure that records as the lightest touch");- ui.add(egui::Slider::new(&mut curve.high, 0.05..=1.0).text("heaviest"))- .hint("the pen's raw pressure that records as full pressure");- ui.add(- egui::Slider::new(&mut curve.gamma, 0.3..=3.0)- .logarithmic(true)- .text("curve"),- )- .hint("below 1 light presses record heavier, above 1 lighter");- ui.horizontal_wrapped(|ui| {- if ui- .button("heaviest = my peak")- .hint("set heaviest to the hardest press seen with this pen")- .clicked()- && peak > 0.05- {- curve.high = peak;- }- if ui.button("reset").hint("the default curve").clicked() {- curve = PressureCurve::default();- }- if ui- .button("forget peak")- .hint("start measuring the hardest press again")- .clicked()- && let Some(pen) = self.settings.pens.get_mut(&key)- {- pen.peak = 0.0;- self.settings_dirty = true;- }+ ui.spacing_mut().slider_width = 220.0;+ prefs::grid(ui, "settings pen", |ui| {+ prefs::row_label(ui, "Pen");+ ui.label(if self.readout.device == 0 {+ "not identified yet: move it away from the tablet and back".to_string()+ } else {+ key.clone()+ });+ ui.end_row();+ prefs::row_label(ui, "Pressure");+ ui.vertical(|ui| {+ ui.add(+ egui::ProgressBar::new(raw)+ .desired_width(280.0)+ .text(format!("pen {raw:.3}")),+ );+ ui.add(+ egui::ProgressBar::new(curve.apply(raw))+ .desired_width(280.0)+ .text(format!("recorded {:.3}", curve.apply(raw))),+ );+ ui.label(egui::RichText::new(format!("heaviest press seen {peak:.3}")).color(crate::theme::WEAK));+ });+ ui.end_row();+ prefs::row_label(ui, "Lightest");+ ui.add(egui::Slider::new(&mut curve.low, 0.0..=0.5))+ .hint("the pen's raw pressure that records as the lightest touch");+ ui.end_row();+ prefs::row_label(ui, "Heaviest");+ ui.add(egui::Slider::new(&mut curve.high, 0.05..=1.0))+ .hint("the pen's raw pressure that records as full pressure");+ ui.end_row();+ prefs::row_label(ui, "Curve");+ ui.add(egui::Slider::new(&mut curve.gamma, 0.3..=3.0).logarithmic(true))+ .hint("below 1 light presses record heavier, above 1 lighter");+ ui.end_row();+ prefs::row_label(ui, "");+ ui.horizontal_wrapped(|ui| {+ if ui+ .button("heaviest = my peak")+ .hint("set heaviest to the hardest press seen with this pen")+ .clicked()+ && peak > 0.05+ {+ curve.high = peak;+ }+ if ui.button("reset").hint("the default curve").clicked() {+ curve = PressureCurve::default();+ }+ if ui+ .button("forget peak")+ .hint("start measuring the hardest press again")+ .clicked()+ && let Some(pen) = self.settings.pens.get_mut(&key)+ {+ pen.peak = 0.0;+ self.settings_dirty = true;+ }+ });+ ui.end_row();+ prefs::row_label(ui, "Response");+ let (rect, _) = ui.allocate_exact_size(vec2(220.0, 120.0), Sense::hover());+ let painter = ui.painter_at(rect);+ painter.rect_filled(rect, 2.0, Color32::from_gray(28));+ let at = |x: f32, y: f32| egui::pos2(rect.left() + x * rect.width(), rect.bottom() - y * rect.height());+ let line: Vec<Pos2> = (0..=40)+ .map(|i| i as f32 / 40.0)+ .map(|x| at(x, curve.apply(x)))+ .collect();+ painter.add(egui::Shape::line(line, egui::Stroke::new(1.5, Color32::LIGHT_BLUE)));+ painter.circle_filled(at(raw, curve.apply(raw)), 3.5, Color32::YELLOW);+ ui.end_row();});- let (rect, _) = ui.allocate_exact_size(vec2(160.0, 90.0), Sense::hover());- let painter = ui.painter_at(rect);- painter.rect_filled(rect, 2.0, Color32::from_gray(28));- let at = |x: f32, y: f32| egui::pos2(rect.left() + x * rect.width(), rect.bottom() - y * rect.height());- let line: Vec<Pos2> = (0..=40)- .map(|i| i as f32 / 40.0)- .map(|x| at(x, curve.apply(x)))- .collect();- painter.add(egui::Shape::line(line, egui::Stroke::new(1.5, Color32::LIGHT_BLUE)));- painter.circle_filled(at(raw, curve.apply(raw)), 3.5, Color32::YELLOW);if curve != before {curve.high = curve.high.max(curve.low + 0.05);self.settings.set_curve(&key, curve);diff --git a/crates/app/src/editor/commands.rs b/crates/app/src/editor/commands.rsindex ebe199b..df8156c 100644--- a/crates/app/src/editor/commands.rs+++ b/crates/app/src/editor/commands.rs@@ -848,9 +848,11 @@ impl Editor {.collect()});let mut done = BTreeSet::new();+ let modal = self.windows.settings;pressed.into_iter().filter_map(|(cmd, repeat, shift)| cmd.map(|c| (c, repeat, shift)))+ .filter(|(cmd, _, _)| !modal || *cmd == Cmd::Settings).try_for_each(|(cmd, repeat, shift)| {self.key_shift = shift;let skip = repeatdiff --git a/crates/app/src/editor/make.rs b/crates/app/src/editor/make.rsindex dce6a3e..6de69df 100644--- a/crates/app/src/editor/make.rs+++ b/crates/app/src/editor/make.rs@@ -216,7 +216,7 @@ impl Editor {self.selection = Some(made);self.say(Tone::Done,- format!("{id} is now inside a {kind}: the inspector sets how many copies and where they go"),+ format!("{id} is now inside a {kind}: layer settings set how many copies and where they go"),);Ok(())}@@ -577,7 +577,7 @@ impl Editor {self.say(Tone::Done,format!(- "{name} placed on a new layer: V moves and scales it, the inspector fades it or makes it a reference"+ "{name} placed on a new layer: V moves and scales it, layer settings fade it or make it a reference"),);Ok(())diff --git a/crates/app/src/editor/panels.rs b/crates/app/src/editor/panels.rsindex c156b9f..5def5d9 100644--- a/crates/app/src/editor/panels.rs+++ b/crates/app/src/editor/panels.rs@@ -433,10 +433,7 @@ impl Editor {});}- fn about_panel(&mut self, ui: &mut egui::Ui) {- static LINES: std::sync::OnceLock<Vec<&'static str>> = std::sync::OnceLock::new();- let lines = LINES.get_or_init(|| klad_core::notices::NOTICES.lines().collect());- ui.label(RichText::new(format!("klad {}", crate::VERSION)).strong());+ pub(super) fn update_rows(&mut self, ui: &mut egui::Ui) {if let Some(checked) = self.update_check.as_ref().and_then(|c| c.try_recv().ok()) {self.update_check = None;self.update_said = Some(crate::updates::outcome(&checked));@@ -470,6 +467,13 @@ impl Editor {ui.label(RichText::new(said).color(theme::WEAK));}});+ }++ fn about_panel(&mut self, ui: &mut egui::Ui) {+ static LINES: std::sync::OnceLock<Vec<&'static str>> = std::sync::OnceLock::new();+ let lines = LINES.get_or_init(|| klad_core::notices::NOTICES.lines().collect());+ ui.label(RichText::new(format!("klad {}", crate::VERSION)).strong());+ self.update_rows(ui);ui.label("Source-available licence, copyright Indicode BV. Built on the open source work listed below; klad licences prints the same.");ui.add_space(6.0);ui.style_mut().wrap_mode = Some(egui::TextWrapMode::Truncate);@@ -786,17 +790,7 @@ impl Editor {self.settings_dirty = true;}}- if self.windows.settings {- let mut open = true;- Self::window(- ctx,- "settings",- (format!("{} Settings", icon::SETTINGS), settings_at),- &mut open,- |ui| self.settings_panel(ui),- );- self.windows.settings &= open;- }+ self.settings_modal(ctx);if self.windows.brush {let mut open = true;Self::window(@@ -1028,34 +1022,6 @@ impl Editor {});}- fn settings_panel(&mut self, ui: &mut egui::Ui) {- ui.heading("Pen calibration");- self.pen_panel(ui);- ui.separator();- ui.heading("Defaults");- self.defaults_section(ui);- ui.separator();- ui.heading("Keys");- self.keys_section(ui);- ui.separator();- ui.heading("Layout");- self.scale_section(ui);- ui.separator();- ui.horizontal_wrapped(|ui| {- self.command_check(ui, Cmd::Numbers, "numbers panel");- self.command_check(ui, Cmd::Timeline, "timeline");- if ui- .button("reset the layout")- .hint("every panel back where it starts, at its first size")- .clicked()- {- self.settings.layout = Layout::default();- self.settings_dirty = true;- }- });- ui.small("Tab hides the panels, shift Tab the dock, cmd K finds any command.");- }-fn log_panel(&mut self, ui: &mut egui::Ui) {let now = Instant::now();let log: Vec<Message> = self.messages.log().rev().cloned().collect();diff --git a/crates/app/src/editor/prefs.rs b/crates/app/src/editor/prefs.rsindex 22e1939..1283a51 100644--- a/crates/app/src/editor/prefs.rs+++ b/crates/app/src/editor/prefs.rs@@ -1,80 +1,232 @@use super::Editor;use crate::commands::Cmd;+use crate::layout::Layout;use crate::messages::Tone;-use crate::theme::{self, Hint};-use egui::{RichText, vec2};+use crate::theme::{self, Hint, icon};+use egui::{Align, RichText, vec2};++#[derive(Clone, Copy, Debug, Default, PartialEq, Eq)]+pub(super) enum Section {+ #[default]+ Pen,+ Drawing,+ Keys,+ Layout,+ Updates,+}++impl Section {+ pub(super) const ALL: [Section; 5] = [+ Section::Pen,+ Section::Drawing,+ Section::Keys,+ Section::Layout,+ Section::Updates,+ ];++ pub(super) fn name(self) -> &'static str {+ match self {+ Section::Pen => "Pen",+ Section::Drawing => "Drawing",+ Section::Keys => "Keys",+ Section::Layout => "Layout",+ Section::Updates => "Updates",+ }+ }++ fn icon(self) -> &'static str {+ match self {+ Section::Pen => icon::PEN,+ Section::Drawing => icon::BRUSH,+ Section::Keys => icon::KEYBOARD,+ Section::Layout => icon::SIDEBAR,+ Section::Updates => icon::DOWNLOAD,+ }+ }++ fn about(self) -> &'static str {+ match self {+ Section::Pen => {+ "How hard you press, and the pressure your strokes record. Press on the tablet and watch the bars."+ }+ Section::Drawing => "What every new window starts with.",+ Section::Keys => "The key for every command. Change one by pressing the new key.",+ Section::Layout => "The size of everything around the canvas, and the panels.",+ Section::Updates => "klad asks its release page for a newer version. It never installs one by itself.",+ }+ }+}++const SIDEBAR: f32 = 160.0;+const LABELS: f32 = 150.0;++pub(super) fn grid(ui: &mut egui::Ui, id: &str, rows: impl FnOnce(&mut egui::Ui)) {+ egui::Grid::new(id)+ .num_columns(2)+ .min_col_width(LABELS)+ .spacing(vec2(16.0, 10.0))+ .show(ui, rows);+}++pub(super) fn row_label(ui: &mut egui::Ui, text: &str) -> egui::Response {+ ui.label(RichText::new(text).color(theme::WEAK))+}impl Editor {+ pub(super) fn settings_modal(&mut self, ctx: &egui::Context) {+ if !self.windows.settings {+ return;+ }+ let height = (ctx.content_rect().height() - 160.0).clamp(280.0, 520.0);+ let mut close = false;+ let modal = egui::Modal::new(egui::Id::unique("settings")).show(ctx, |ui| {+ ui.set_width(760.0);+ ui.horizontal(|ui| {+ ui.label(+ RichText::new(format!("{} Settings", icon::SETTINGS))+ .strong()+ .size(theme::HEADING),+ );+ ui.with_layout(egui::Layout::right_to_left(Align::Center), |ui| {+ close = ui+ .add(egui::Button::new(RichText::new(icon::CLOSE).size(theme::ICON)).frame(false))+ .hint("close the settings (Esc)")+ .clicked();+ });+ });+ ui.separator();+ ui.horizontal_top(|ui| {+ ui.allocate_ui_with_layout(+ vec2(SIDEBAR, height),+ egui::Layout::top_down_justified(Align::Min),+ |ui| {+ ui.set_min_size(vec2(SIDEBAR, height));+ Section::ALL.into_iter().for_each(|section| {+ let text = RichText::new(format!("{} {}", section.icon(), section.name()));+ if ui+ .add(+ egui::Button::selectable(self.settings_section == section, text)+ .min_size(vec2(SIDEBAR, 32.0)),+ )+ .hint(section.about())+ .clicked()+ {+ self.settings_section = section;+ }+ });+ },+ );+ ui.separator();+ let width = ui.available_width();+ ui.allocate_ui_with_layout(vec2(width, height), egui::Layout::top_down(Align::Min), |ui| {+ ui.set_min_size(vec2(width, height));+ let section = self.settings_section;+ ui.label(RichText::new(section.name()).strong().size(theme::HEADING));+ ui.add(egui::Label::new(RichText::new(section.about()).color(theme::WEAK)).wrap());+ ui.add_space(12.0);+ match section {+ Section::Keys => self.keys_section(ui),+ _ => {+ egui::ScrollArea::vertical()+ .id_salt(("settings", section.name()))+ .auto_shrink([false, false])+ .show(ui, |ui| match section {+ Section::Pen => self.pen_panel(ui),+ Section::Drawing => self.defaults_section(ui),+ Section::Layout => self.layout_section(ui),+ _ => self.updates_section(ui),+ });+ }+ }+ });+ });+ });+ if close || (modal.should_close() && self.capturing.is_none()) {+ self.windows.settings = false;+ }+ }+pub(super) fn defaults_section(&mut self, ui: &mut egui::Ui) {let mut changed = false;- let d = &mut self.settings.defaults;- ui.horizontal_wrapped(|ui| {- let now = match (&d.brush, d.size) {- (Some(b), Some(s)) => format!("new windows start with {b} at {s:.1} px"),- _ => "new windows start with the ink brush at 12 px".to_string(),- };- ui.label(now);- });let (brush, size) = (self.brush.clone(), self.size);- ui.horizontal_wrapped(|ui| {- if ui- .button("use the current brush and size")- .hint("the brush and size you have now become the ones every window starts with")- .clicked()- {- d.brush = Some(brush.clone());- d.size = Some(size);- changed = true;- }- if ui- .add_enabled(d.brush.is_some(), egui::Button::new("forget them"))- .hint("start with the ink brush at 12 px again")- .clicked()- {- d.brush = None;- d.size = None;- changed = true;- }- });- ui.horizontal(|ui| {- ui.label("shift K exposes on");- [1, 2, 3].into_iter().for_each(|n| {- if ui- .selectable_value(&mut d.exposure, n, format!("{n}s"))- .hint("how many frames each new drawing holds when shift K makes it")- .clicked()- {+ let d = &mut self.settings.defaults;+ grid(ui, "settings drawing", |ui| {+ row_label(ui, "Brush");+ ui.vertical(|ui| {+ ui.label(match (&d.brush, d.size) {+ (Some(b), Some(s)) => format!("{b} at {s:.1} px"),+ _ => "the ink brush at 12 px".to_string(),+ });+ ui.horizontal_wrapped(|ui| {+ if ui+ .button("use the current brush and size")+ .hint("the brush and size you have now become the ones every window starts with")+ .clicked()+ {+ d.brush = Some(brush.clone());+ d.size = Some(size);+ changed = true;+ }+ if ui+ .add_enabled(d.brush.is_some(), egui::Button::new("forget them"))+ .hint("start with the ink brush at 12 px again")+ .clicked()+ {+ d.brush = None;+ d.size = None;+ changed = true;+ }+ });+ });+ ui.end_row();+ row_label(ui, "New drawings hold");+ ui.horizontal(|ui| {+ [1, 2, 3].into_iter().for_each(|n| {+ if ui+ .selectable_value(+ &mut d.exposure,+ n,+ format!("{n} frame{}", if n == 1 { "" } else { "s" }),+ )+ .hint("how many frames each new drawing holds when shift K makes it")+ .clicked()+ {+ changed = true;+ }+ });+ });+ ui.end_row();+ row_label(ui, "Onion skin");+ ui.horizontal(|ui| {+ ui.label("before");+ changed |= ui+ .add(egui::DragValue::new(&mut d.onion_before).range(0..=8))+ .hint("drawings shown before, in red, when onion skin is on")+ .changed();+ ui.label("after");+ changed |= ui+ .add(egui::DragValue::new(&mut d.onion_after).range(0..=8))+ .hint("drawings shown after, in green")+ .changed();+ ui.label("opacity");+ changed |= ui+ .add(egui::DragValue::new(&mut d.onion_opacity).range(0.05..=1.0).speed(0.01))+ .hint("how strong the nearest ghost is")+ .changed();+ });+ ui.end_row();+ row_label(ui, "Around the canvas");+ ui.horizontal(|ui| {+ changed |= ui+ .color_edit_button_srgb(&mut d.surround)+ .hint("the grey around the canvas; neutral keeps colours true")+ .changed();+ if ui.button("neutral grey").hint("back to the neutral grey").clicked() {+ d.surround = theme::SURROUND;changed = true;}});- });- ui.horizontal(|ui| {- ui.label("onion before");- changed |= ui- .add(egui::DragValue::new(&mut d.onion_before).range(0..=8))- .hint("drawings shown before, in red, when onion skin is on")- .changed();- ui.label("after");- changed |= ui- .add(egui::DragValue::new(&mut d.onion_after).range(0..=8))- .hint("drawings shown after, in green")- .changed();- ui.label("opacity");- changed |= ui- .add(egui::DragValue::new(&mut d.onion_opacity).range(0.05..=1.0).speed(0.01))- .hint("how strong the nearest ghost is")- .changed();- });- ui.horizontal(|ui| {- ui.label("around the canvas");- changed |= ui- .color_edit_button_srgb(&mut d.surround)- .hint("the grey around the canvas; neutral keeps colours true")- .changed();- if ui.button("neutral grey").hint("back to the neutral grey").clicked() {- d.surround = theme::SURROUND;- changed = true;- }+ ui.end_row();});if changed {self.settings_dirty = true;@@ -82,10 +234,11 @@ impl Editor {}}- pub(super) fn scale_section(&mut self, ui: &mut egui::Ui) {- ui.horizontal(|ui| {- let label = ui.label("UI scale");+ fn layout_section(&mut self, ui: &mut egui::Ui) {+ grid(ui, "settings layout", |ui| {+ let label = row_label(ui, "Interface size");let mut scale = self.settings.ui_scale;+ ui.spacing_mut().slider_width = 220.0;let r = ui.add(egui::Slider::new(&mut scale, 0.75..=2.0).step_by(0.05)).labelled_by(label.id)@@ -94,16 +247,48 @@ impl Editor {self.settings.ui_scale = scale;self.settings_dirty = true;}+ ui.end_row();+ row_label(ui, "Panels");+ ui.vertical(|ui| {+ self.command_check(ui, Cmd::Timeline, "timeline");+ self.command_check(ui, Cmd::Numbers, "numbers");+ if ui+ .button("reset the layout")+ .hint("every panel back where it starts, at its first size")+ .clicked()+ {+ self.settings.layout = Layout::default();+ self.settings_dirty = true;+ }+ });+ ui.end_row();+ });+ ui.add_space(16.0);+ ui.label(+ RichText::new("Tab hides the panels, shift Tab the dock, cmd K finds any command.").color(theme::WEAK),+ );+ }++ fn updates_section(&mut self, ui: &mut egui::Ui) {+ grid(ui, "settings updates", |ui| {+ row_label(ui, "This version");+ ui.label(format!("klad {}", crate::VERSION));+ ui.end_row();+ row_label(ui, "Every day");+ let mut check = self.settings.check_updates;+ if ui+ .checkbox(&mut check, "check for a new version once a day")+ .hint("asks the release page on GitHub at most once a day; nothing is installed without you")+ .changed()+ {+ self.settings.check_updates = check;+ self.settings_dirty = true;+ }+ ui.end_row();+ row_label(ui, "Now");+ ui.vertical(|ui| self.update_rows(ui));+ ui.end_row();});- let mut check = self.settings.check_updates;- if ui- .checkbox(&mut check, "check for a new version once a day")- .hint("asks the release page on GitHub at most once a day; nothing is installed without you")- .changed()- {- self.settings.check_updates = check;- self.settings_dirty = true;- }}pub(super) fn keys_section(&mut self, ui: &mut egui::Ui) {@@ -144,7 +329,8 @@ impl Editor {let mut action: Option<(Cmd, &str)> = None;egui::ScrollArea::vertical().id_salt("keys list")- .max_height(320.0)+ .max_height(ui.available_height())+ .auto_shrink([false, false]).show(ui, |ui| {shown.iter().for_each(|cmd| {let spec = cmd.spec();diff --git a/crates/app/src/editor/text.rs b/crates/app/src/editor/text.rsindex 7f12b07..aeeb68f 100644--- a/crates/app/src/editor/text.rs+++ b/crates/app/src/editor/text.rs@@ -189,7 +189,7 @@ impl Editor {Err(_) => {self.say(Tone::Refused,- format!("the font {file} is not in the drawing; pick another in the inspector"),+ format!("the font {file} is not in the drawing; pick another in layer settings"),);None}@@ -374,7 +374,7 @@ impl Editor {self.used_colour();self.say(Tone::Done,- "text added: T and a click on it types more, V moves it, the inspector changes its font",+ "text added: T and a click on it types more, V moves it, layer settings change its font",);}}diff --git a/crates/app/src/editor/ui_tests.rs b/crates/app/src/editor/ui_tests.rsindex 2ad05b5..1a89381 100644--- a/crates/app/src/editor/ui_tests.rs+++ b/crates/app/src/editor/ui_tests.rs@@ -211,6 +211,46 @@ fn the_strip_shrinks_then_folds_its_foot_when_the_window_is_short() {let _ = std::fs::remove_dir_all(&path);}+#[test]+fn settings_is_a_modal_with_a_sidebar_and_esc_closes_it_unless_a_key_is_being_set() {+ let path = sample("settings-modal");+ let mut h = harness(editor(&path), vec2(1440.0, 1000.0));+ h.state_mut().invoke(Cmd::Settings).unwrap();+ h.run_steps(3);+ assert!(+ h.query_by_label_contains("heaviest = my peak").is_some(),+ "it opens on the pen"+ );+ assert!(h.query_by_label("reset every key").is_none(), "one section at a time");+ h.get_by_label_contains("Keys").click();+ h.run_steps(2);+ assert!(h.query_by_label("reset every key").is_some());+ assert!(h.query_by_label_contains("heaviest = my peak").is_none());+ h.get_by_label_contains("Updates").click();+ h.run_steps(2);+ assert!(h.query_by_label(&format!("klad {}", crate::VERSION)).is_some());+ h.state_mut().settings_section = super::prefs::Section::Keys;+ h.state_mut().capturing = Some(Cmd::Onion);+ h.run_steps(1);+ h.key_press(Key::Escape);+ h.run_steps(2);+ assert!(+ h.state().windows.settings,+ "Esc while a key is being set keeps the old key and the window"+ );+ assert!(h.state().capturing.is_none());+ h.state_mut().tool = Tool::Fill;+ h.key_press(Key::B);+ h.run_steps(2);+ assert_eq!(h.state().tool, Tool::Fill, "keys behind the modal stay still");+ h.key_press(Key::Escape);+ h.run_steps(2);+ assert!(!h.state().windows.settings, "Esc closes it");+ assert_eq!(Pane::Inspector.title(), "Layer settings");+ assert_eq!(Cmd::InspectorPane.menu(), "Layer settings");+ let _ = std::fs::remove_dir_all(&path);+}+#[test]fn every_control_is_pen_sized_and_has_a_hover_hint() {let path = sample("audit");@@ -257,6 +297,11 @@ fn every_control_is_pen_sized_and_has_a_hover_hint() {h.state_mut().say(Tone::Error, "a test error with a close button");h.run_steps(3);checked += audit(&h, "windows open");+ super::prefs::Section::ALL.into_iter().for_each(|section| {+ h.state_mut().settings_section = section;+ h.run_steps(2);+ checked += audit(&h, section.name());+ });{let ed = h.state_mut();ed.settings.layout.numbers = false;@@ -617,6 +662,7 @@ fn panel_pictures() {h.state_mut().timeline.span = None;}h.state_mut().windows.settings = true;+ h.state_mut().settings_section = super::prefs::Section::Keys;h.state_mut().key_filter = "layer".into();shot(&mut h, "9-settings-keys");h.state_mut().windows.settings = false;@@ -1213,6 +1259,7 @@ fn a_key_changed_in_the_settings_runs_its_command_and_a_taken_key_is_refused() {let mut h = harness(editor(&path), vec2(1440.0, 1000.0));activate(&mut h, "lines");h.state_mut().windows.settings = true;+ h.state_mut().settings_section = super::prefs::Section::Keys;h.state_mut().key_filter = "duplicate the layer".into();h.run_steps(3);h.get_by_role_and_label(Role::Button, "change").click();diff --git a/crates/app/src/layout.rs b/crates/app/src/layout.rsindex b928640..915cb60 100644--- a/crates/app/src/layout.rs+++ b/crates/app/src/layout.rs@@ -26,7 +26,7 @@ impl Pane {match self {Pane::Tool => "Colour and brush",Pane::Layers => "Layers",- Pane::Inspector => "Inspector",+ Pane::Inspector => "Layer settings",Pane::Notes => "Notes for the agent",Pane::History => "History",}diff --git a/docs/DESIGN.md b/docs/DESIGN.mdindex bc7a38a..2bc00b9 100644--- a/docs/DESIGN.md+++ b/docs/DESIGN.md@@ -1,4 +1,4 @@-_Last updated: 2026-11-07 09:41_+_Last updated: 2026-11-07 09:54_# klad: design@@ -237,11 +237,11 @@ Every layer has `blend`, `opacity`, `visible`, `locked`, optional `mask`, `clip`- **Blend modes.** `normal`, `multiply`, `screen`, `overlay`, `add`, and since M5 `color-dodge`, `soft-light`, `hard-light`, `lighten`, `darken`, `color`, `luminosity`, all as in the W3C compositing spec (Skia's modes; `look::blend_rgb` and `look::composite` hold the formulas the tests check them against).- **Effects (M5).** `"effects": [{"glow": {...}}, {"outline": {...}}]`, applied in order to the layer's content (after its mask; for a clip base, to the base and its clipped layers together) before its opacity and blend: `blur` (radius, a Gaussian sigma), `glow` (radius, strength, threshold: 0 glows from every pixel, higher only from the bright ones; color: a tint; blend: how the glow mixes with what is under the layer, screen by default, normal lays it like paint under the layer), `outline` (width, color, inside), `shadow` (x, y, radius, color, laid under the layer), `noise` (amount, size, seed, mono: a grain fixed to the canvas), `displace` (amount, size, seed, by: smooth waves, or a layer whose red pushes across and green down), `relief` (strength, light, highlight, shade, softness: lights the paint height of the layer's drawings, below). Each effect knows its reach (`look::reach`), so a tile is composed from its content within the tile plus that margin and tiles meet without seams; the pixels are computed in Rust (`klad-render/effects.rs`) on f32 with absolute coordinates, so a tile equals the same pixels of the whole image byte for byte (tested). Blurs use a direct kernel, below a sigma of 2 at full size and above it on a grid of 2, 4, ... px blocks anchored to the canvas, then sampled back.- **Adjustment layers (M5).** An `adjust` layer changes what is under it in its list: the layers below it in its group, or, clipped, its base. A group holding an adjustment is composed apart, so the adjustment stays inside it. The colour math is on unpremultiplied sRGB values with alpha kept: `hsl` (hue in degrees, saturation and lightness -1..1), `levels` (black, white, gamma, low, high), `curves` (points, and red, green, blue applied before them; monotone cubic, no overshoot), `balance` (shadows, midtones, highlights: cyan to red, magenta to green, yellow to blue, keepLight), `gradient-map` (stops by brightness). The layer's opacity, blend and mask decide how much of the adjusted colour replaces the colour under it. `fill` (a solid or gradient paint) is drawn like a content layer instead, with the layer's blend.-- **Rays (M5).** A vector node `{"type": "rays", "x", "y", "angle", "spread", "count", "length", "start", "falloff", "noise", "seed"}` draws soft beams from an origin (a gap `start` px wide), each a quad with a radial falloff and its own length and strength from the seed; the node's `fill` colours them and its `blur` softens them. Rays come from the agent (`klad add rays`); in the editor a selected rays node shows its settings in the inspector.-- **Depth and atmosphere (M5).** A layer at the top of the stack (a plane, usually a group) may have a `depth` (0 is near; validation refuses it deeper in the tree). The document's `atmosphere` (`color`, an optional `top` colour blended down over the canvas height, `density`, `blur`, `desaturate`) turns each plane's depth into two effects after its own (`Document::effects_of`): a `haze` towards the fog of `1 - e^(-density x depth)` with `desaturate x depth` of its colour taken out, and a blur of `blur x depth` px. `haze` is an ordinary effect too. The depths are kept for M6's Parallax2D export; in the editor a depth field sits in each plane's row and inspector, the inspector holds the atmosphere, and holding D shows the planes (each flattened alone, in the background) sliding by `offset x 0.08 / (1 + depth)` with the pointer.+- **Rays (M5).** A vector node `{"type": "rays", "x", "y", "angle", "spread", "count", "length", "start", "falloff", "noise", "seed"}` draws soft beams from an origin (a gap `start` px wide), each a quad with a radial falloff and its own length and strength from the seed; the node's `fill` colours them and its `blur` softens them. Rays come from the agent (`klad add rays`); in the editor a selected rays node shows its settings in layer settings.+- **Depth and atmosphere (M5).** A layer at the top of the stack (a plane, usually a group) may have a `depth` (0 is near; validation refuses it deeper in the tree). The document's `atmosphere` (`color`, an optional `top` colour blended down over the canvas height, `density`, `blur`, `desaturate`) turns each plane's depth into two effects after its own (`Document::effects_of`): a `haze` towards the fog of `1 - e^(-density x depth)` with `desaturate x depth` of its colour taken out, and a blur of `blur x depth` px. `haze` is an ordinary effect too. The depths are kept for M6's Parallax2D export; in the editor a depth field sits in each plane's row and layer settings, layer settings hold the atmosphere, and holding D shows the planes (each flattened alone, in the background) sliding by `offset x 0.08 / (1 + depth)` with the pointer.- **References (M5).** Any layer can be `reference: true`: the editor shows it, renders, hashes and exports leave it out unless asked (`--references`), and fills never see it.-- **Pictures (M5).** A picture is a vector node `{"type": "image", "src", "x", "y", "w", "h"}`, so V moves and scales it and the inspector fades it. Importing (`klad add layer image src=photo.jpg`, dropping a PNG or JPEG on the editor, or "import a picture") decodes PNG with `png` or JPEG with `zune-jpeg`, re-encodes it as PNG and stores it as `images/<content hash>.png`, so the same file twice is stored once and every machine draws the same pixels; it lands on a new vector layer, fitted inside the canvas. The renderer finds pictures and fonts in the folders of every bundle the process opened (`klad_render::assets`).-- **Generators (M5).** `scatter` (copies of its children over a region, `count`, `seed`, `size` and `turn` ranges, `avoid`: SVG paths no copy's centre may fall in), `repeat` (`count` copies, each `step` further, turning `turn` degrees and growing `scale` about `pivot`, or a grid `columns` wide with `row` between rows) and `mirror` (its children and their reflection across a line through `x, y` at `angle`) are nodes whose children are drawn once per instance (`generators.rs`); they stay settings, the inspector edits them, and "repeat it", "scatter it", "mirror it" put a selected shape inside one; "take the shapes out" removes one and keeps its shapes where its first copy was. Their children keep their ids, so V can still pick inside.+- **Pictures (M5).** A picture is a vector node `{"type": "image", "src", "x", "y", "w", "h"}`, so V moves and scales it and layer settings fade it. Importing (`klad add layer image src=photo.jpg`, dropping a PNG or JPEG on the editor, or "import a picture") decodes PNG with `png` or JPEG with `zune-jpeg`, re-encodes it as PNG and stores it as `images/<content hash>.png`, so the same file twice is stored once and every machine draws the same pixels; it lands on a new vector layer, fitted inside the canvas. The renderer finds pictures and fonts in the folders of every bundle the process opened (`klad_render::assets`).+- **Generators (M5).** `scatter` (copies of its children over a region, `count`, `seed`, `size` and `turn` ranges, `avoid`: SVG paths no copy's centre may fall in), `repeat` (`count` copies, each `step` further, turning `turn` degrees and growing `scale` about `pivot`, or a grid `columns` wide with `row` between rows) and `mirror` (its children and their reflection across a line through `x, y` at `angle`) are nodes whose children are drawn once per instance (`generators.rs`); they stay settings, layer settings edit them, and "repeat it", "scatter it", "mirror it" put a selected shape inside one; "take the shapes out" removes one and keeps its shapes where its first copy was. Their children keep their ids, so V can still pick inside.- **Text (M5).** `{"type": "text", "text", "font", "x", "y", "size", "tracking", "leading", "align", "weight"}` with the node's fill and outline. The font is a file in the bundle's `fonts/` folder, so a drawing renders the same anywhere. Each line is shaped by `harfrust` (HarfBuzz's shaping in Rust: GPOS and `kern` kerning, ligatures, marks, scripts), `weight` sets a variable font's `wght` axis, and the outlines come from the file through `skrifa`, each glyph's contours merged with Skia's path ops so an outline never shows the overlaps variable fonts are built with; they are drawn as one path, never by the system's font engine, so the Mac and the container draw the same pixels. A missing font is refused with its name.- **Fonts (M5, S5.26).** klad ships about fifty open families for game art in `fonts/` (sans, serif, mono, display, handwriting, pixel; OFL-1.1 or Apache-2.0, unchanged from the Google Fonts repository at a pinned commit, listed with their licences in the notices; `fonts/update.py` fetches them again). `klad_render::fonts` finds that folder next to the binary (also `../Resources/fonts` in a Mac app and the repository's `fonts/` for development builds; `KLAD_FONTS` overrides), and keeps families downloaded on request in a per-user folder (`~/Library/Application Support/klad/fonts`, `$XDG_DATA_HOME/klad/fonts`, `%APPDATA%\klad\fonts`). `fonts/catalogue.json` lists every open family on Google Fonts (about 1,900) with its group and folder at the same commit, so `klad fonts --search` works offline and a download (`klad fonts --get`, or naming a family anywhere a font is taken) fetches exactly that commit's files with `curl`. Choosing a font anywhere (the CLI's `font=`, `klad font`, the editor's picker) copies the file and its licence into the bundle; the node keeps the file name. This replaces M5 choice 3 (no fonts with the app). The editor's frame and plane caches fold `klad_render::RENDER_VERSION` into their keys, so pictures cached before a renderer change are not shown again. A light layer is no kind of its own: a paint layer set to `add` with a soft glow (a shortcut button for it only confused the layers pane).- **Foliage (M5, S5.27).** `foliage` is a shape op (CLI only, principle 7): each closed shape becomes a clump built from leaf strokes on a jittered grid, each coloured from the clump lit as a round form (a normal from its bounding ellipse, mixed with the normal of an optional `mass` shape so clumps turn with the whole crown, a key light or a lamp, the underside darker) and stepped into three value families between `shade`, `color` and `lit` (OKLab; by default darker and cooler, lighter and warmer), with more variety in the light; then leaves along the outline, kept more where the outline faces the light or the sky, a few in `glow` on the shadow edge. Strokes are sorted dark to light so lit leaves land on top. It puts how foliage is painted (light families on the clump, the big mass before the texture, a broken silhouette) into one op, so an agent does not scatter leaves like confetti.@@ -433,7 +433,7 @@ Scripts are any language that prints edit ops as JSON lines into `klad apply`. G## The editor- Canvas: pan, zoom, rotate; pen pressure, tilt and eraser end; 120 Hz on Apple Silicon. The window around the canvas is a neutral grey (`theme::SURROUND`), so colours read true.-- Layout (M4 batch 1): a tool strip on the left (the tools with their key letter, undo and redo, and at its foot the document and panels menus, the command palette, numbers and settings; the strip only has the height between the menu bar and the timeline, so when both groups do not fit its buttons shrink from 36 to 28 pt, then the foot folds into one menu pinned at the bottom, and last the tools scroll, never overlapping; each size is measured as it is drawn, so the choice does not flicker); a dock on the right holding panes (colour and brush, layers, inspector, notes for the agent, history), each with a title row that folds it, closes it and, dragged at its top edge, resizes the pane above; the timeline along the bottom, resizable and foldable to its toolbar; a status line under everything. Panes share the dock's height: they keep the sizes the user gave them, the last open one takes what is left, and when they do not fit they shrink towards their minimums and scroll inside (`layout::Layout::bodies`). Tab hides every panel but the status line, shift Tab the dock. Which panels are open, the dock's width, the timeline's height and each pane's size are kept in the user's settings (`layout`) and restored, clamped to the window. Pen calibration lives in the settings window (cmd ,); the performance numbers in a numbers window that can stay open over the canvas.+- Layout (M4 batch 1): a tool strip on the left (the tools with their key letter, undo and redo, and at its foot the document and panels menus, the command palette, numbers and settings; the strip only has the height between the menu bar and the timeline, so when both groups do not fit its buttons shrink from 36 to 28 pt, then the foot folds into one menu pinned at the bottom, and last the tools scroll, never overlapping; each size is measured as it is drawn, so the choice does not flicker); a dock on the right holding panes (colour and brush, layers, layer settings (`Pane::Inspector` in code), notes for the agent, history), each with a title row that folds it, closes it and, dragged at its top edge, resizes the pane above; the timeline along the bottom, resizable and foldable to its toolbar; a status line under everything. Panes share the dock's height: they keep the sizes the user gave them, the last open one takes what is left, and when they do not fit they shrink towards their minimums and scroll inside (`layout::Layout::bodies`). Tab hides every panel but the status line, shift Tab the dock. Which panels are open, the dock's width, the timeline's height and each pane's size are kept in the user's settings (`layout`) and restored, clamped to the window. Pen calibration lives in the settings modal (cmd ,); the performance numbers in a numbers window that can stay open over the canvas.- Commands (M4 batch 1): every editor action is a `Cmd` in one list (`commands.rs`): an id (`tool.brush`, `drawing.new`, kept in settings), a name in plain words, a Phosphor icon, a group, its keys or the hold that triggers it, whether a held key repeats it, and a line on what it does. Keys, the strip, panel buttons, the timeline's buttons and context menu, and the palette all run commands through `Editor::invoke`, which first asks `can_run` (a reason when it cannot, shown as a refusal) and remembers the last twelve run. A key matches only with exactly its modifiers (shift K is not K); key repeats run commands that repeat (`=`, `[`, cmd Z) and frame steps only once the frame on screen caught up. cmd K opens the palette: type to filter (name start, then a key, a word, a substring, the letters in order, the group; hyphens ignored, so "inb" finds in-between), arrows and Return run, rows grey out with the reason, recent commands first; `?` opens it too. Every control has a hover hint after 0.35 s (from its command where there is one) and is at least 24 pt high; a test walks every control of every panel and window to keep it so.- Tool options and selections (M4 batch 2): a bar over the canvas holds the active tool's settings (brush: picker, size, opacity, flow, and a "more" menu for hardness, lightest size, curve, taper, stabiliser and smoothing; fill: reference, gap, tolerance, grow, opacity; strokes: cut at the lasso edge, select all; points: corner, smooth, simplify, make it a path). The strip shows the eraser while the eraser brush or the pen's eraser end is on, and two colours (the current one over the second; X or a click swaps them; picking a colour from a swatch, the hex field or the eyedropper makes the old one the second). cmd alt drag sideways on the canvas sizes the brush (doubling every 120 pt), the circle staying where the drag began. H flips the view left-right (the view's mappings and the GPU matrix mirror; the document does not change); the status line's zoom takes a click for 100% and a double-click to fit, its rotation a click to turn upright. A selection bar sits under (or over) the selection's box: for strokes flips, quarter turns, recolour, thinner, thicker, opacity, copy, paste, duplicate in place, delete, deselect; for a shape flips (sx or sy negated and its rotation mirrored), quarter turns, duplicate in place (an `add` of the node without ids, above it), delete, deselect; for points corner, smooth, nudges, delete. Arrows nudge strokes, a shape or points by 1 px, 10 px with shift. Strokes select across layers (M5 batch 2 round 1): cmd or shift click on rows in the layers panel adds paint layers to the active one (marked with a blue edge); S then lassos, clicks and selects all on all of them, and the selection (one part per layer) moves, turns, scales, flips, recolours, cuts at the lasso edge, copies and deletes as one edit, each layer's marks staying on their layer. A selection on several layers drags as its outline (no GPU lift) and lands on release; copies of several layers paste back into their own layers, a copy of one layer into the active one. The strip's panels button lists the five panels and the timeline with a tick each, so a closed panel always has a way back. U draws rectangles and ellipses on a vector layer (shift for a square or circle, alt from the centre, rounded corners for rectangles; fill, outline and width shared with the pen, the fill in the first colour and the outline in the second, as for the pen's paths) as `rect` and `ellipse` nodes. Mirror painting (the brush bar's "mirror" and its axis) paints every stroke's mirror image as it is drawn, in a second stroke buffer landed after the first, and commits both as plain marks in one history step. Handles are drawn at 12 pt and hit within 12 pt (`grab`); shapes whose rotation is a quarter turn get edge handles too (`lift::stretched` scales their own axis). Pen events that arrive while a shape move or point edit is being written are held and replayed in order after it. The colour and brush pane shows the palette (swatches drag to reorder; the x in a hovered swatch's corner, or a right-click, removes it), recent colours, size presets and the brushes as tiles, each with a sample stroke drawn by `klad-brush` once per brush definition.- First start (S8.7, `start.rs`, `editor/first.rs`, `klad_core::samples`): until the settings say `welcomed` (set when any drawing opens, or by "Not now"), the start window opens with a welcome offering first steps. First steps make `first steps.klad` (1280 by 800 on paper, one paint layer) in the drawings folder and open it with a small window of three steps that tick as they happen: a brush stroke is saved, a fill is saved, the request for an agent is copied (a sentence with the drawing's path asking the agent to read `klad skill`, render the drawing and add a shadow; "install the klad command" sits next to it). Help > First steps opens and closes the window on any drawing. The checklist is the editor's alone: it teaches the hands on the canvas, and an agent's first steps are `klad skill`. Revisit the third step when klad is an MCP server (S8.10). Under the recent drawings the start window shows the samples: the drawings `samples/shipped.json` names (name, bundle, a line on what it shows), each a card with its thumbnail and that line; a click copies it into the drawings folder without its `.cache` (`samples::copy`, `<name>.klad` or `<name> 2.klad`) and opens the copy, so a sample is never changed. `klad samples` lists the same set and `--copy <name> [--into folder]` copies one (default the current folder). Samples are found like the fonts: `KLAD_SAMPLES`, then `samples/` next to the binary, `../Resources/samples`, `../share/klad/samples`, and a source checkout's `samples/` up to five folders above the binary (where they exist after `just samples`; a sample not built is left out). `packaging/samples.sh` puts them in every build: it builds any that are missing with that build's `klad` (through the sample's `build.sh`, `PYTHON` naming the interpreter), copies them without caches, and renders each one's `<name>.thumb.png` next to it at 336 px, so the start window never renders into the app (a thumbnail outside the bundle is used as it is; only recent drawings' `.cache/thumb.png` are remade when the drawing changes). `app.sh` puts them in `Resources/samples`, `archive.sh` in the archive's `samples/` and the AppImage's `usr/share/klad/samples`; the six weigh about 4 MB.@@ -441,15 +441,15 @@ Scripts are any language that prints edit ops as JSON lines into `klad apply`. G- Menus (S8.6, `commands::MENUS`, `menus.rs`): one list of menus holds every command but the holds (pan, zoom, the eyedropper, flipping, rolling, the parallax preview and sizing on the canvas, which are gestures), so the menus, the palette and the keys stay one list; a test fails when a command is in no menu or in two. The menus, in order: File (new, open, recent, close; import; export; the path and the command line tool), Edit (undo; copy, paste, duplicate, delete; selecting; Transform, Strokes and Points submenus), Tools (the tools, the brush, the colours), Layer (new, duplicate, rename, group, delete; show, lock, clip, lock alpha; Mask and Shape generators submenus, paint over; refill and gaps), Frame (stepping, drawings, holds and moves, inserting and removing frames), Animation (playback, onion skin, exposure, Selected frames and Clip submenus, the checks across frames), View (zoom, rotation, flip, the reference), Window (the panels, the message log, numbers) and Help. Each command has a short menu label (`Cmd::menu`: "Show", "Clip to layer below", "Export…"), since the menu says what it acts on, while the palette and hints keep the longer names; "…" marks a command that opens a window. Items show one key each (Backspace for delete); toggles show a tick, except commands that open a window; a command that cannot run now is greyed out (its reason is the palette's). A test keeps labels unique in each menu and under 30 characters. On macOS the list becomes the system menu bar (`menus::install`, rebuilt when the keys or the recent drawings change): an app menu with About, Settings, Services, hide and Quit, then the list, whose Window menu also gets the system's Minimize, Zoom and Bring all to front (it is the app's windows menu). Items target one Objective-C object (`KladMenuTarget`, `define_class!`) whose `kladRun:` queues the command for the next frame (the editor runs it through `Editor::invoke` as any key would) and whose `validateMenuItem:` reads a snapshot of what is off and on that the app refreshes every 0.4 s. The item keys are shown but not claimed: the object is each menu's delegate and answers no to `menuHasKeyEquivalent:forEvent:target:action:`, so a key still reaches the editor's own dispatch (which knows holds, repeats and text fields) and nothing runs twice; only the app menu's own keys (cmd , cmd Q cmd H) and Window's cmd M are AppKit's. On Windows and Linux (and in tests) the same list is an egui menu bar over the window, hidden with the panels (Tab). File > Open recent lists the last ten drawings; File > Close the drawing (cmd W, refused while a job runs) goes back to the start window, where only new, open, recent and quit run. Settings and Quit sit in the app menu on macOS and in Edit and File elsewhere; About (with the licences) is in Help everywhere and also in the macOS app menu.- Messages and jobs (M4 batch 1): every result, refusal and error goes through `Editor::say` with a tone (info, done, refused, error). Done and refused messages show for 3.5 and 6 s as a toast next to the pointer where the user acted (jobs' messages at the bottom right), errors until dismissed, info only in the status line; the status line shows the latest message (a click opens the message log, the last 200 with times), the frame, where the next stroke goes ("draws into c12 on lines, frames 4 to 7"), running jobs with a cancel button, slow internal work (preparing a selection, drawing an edited path, loading a frame), zoom and rotation. Times that used to be status text (stroke, fill, edit, undo, sync, frame step, last play, last job) are kept by name for the numbers window. Background jobs (in-betweens, Godot export) run the same `klad` binary through one job list (`jobs.rs`); when the CLI exits with code 75 (the document changed while it computed) the job runs again, up to three times, so an edit made in the editor meanwhile is never overwritten.- Tools: brush, eraser, smudge, fill (inside lines, gap closing), lasso select and transform, move/rotate/scale handles, path point editing, eyedropper.-- Stroke select (S, M2): click picks the topmost stroke or fill on the active paint layer under the pointer, a dragged loop picks every stroke whose samples are all inside it and every fill whose pixels are, shift adds or toggles. With "a lasso cuts strokes at its edge" (on by default) the loop also takes the parts of strokes and fills crossing it: the selection shows the dashed lasso and the parts that will move, and the first edit (move, recolour, delete, ...) writes one `lasso` op that splits them, after which the selection is the moved marks. The selection shows as thin lines and a box with corner handles (uniform scale), edge handles (stretch one axis; dragging past the other edge flips) and a rotate knob; dragging moves it on the GPU (the selected marks drawn alone, over the cel replayed without them) and release writes one `transform` or `lasso` op. The inspector recolours (the current colour), makes thinner or thicker, sets opacity, flips left-right or up-down and deletes, each as one history step. The selection is shared with the agent as addresses.-- Layers (M2 batch 4): the inspector sets clip to the layer below and lock alpha, adds a mask (empty, or hiding all), turns it on and off, removes it, and "paint on the mask" makes the mask the active layer (it also has its own row under its layer). Painting on a mask hides the layer under the strokes; the eraser shows it again. While a mask is active, what it hides is tinted red ("show the mask in red", on by default), and the brush panel says whether the brush or the eraser is on. The brush and fill tools record lock alpha from the active layer.+- Stroke select (S, M2): click picks the topmost stroke or fill on the active paint layer under the pointer, a dragged loop picks every stroke whose samples are all inside it and every fill whose pixels are, shift adds or toggles. With "a lasso cuts strokes at its edge" (on by default) the loop also takes the parts of strokes and fills crossing it: the selection shows the dashed lasso and the parts that will move, and the first edit (move, recolour, delete, ...) writes one `lasso` op that splits them, after which the selection is the moved marks. The selection shows as thin lines and a box with corner handles (uniform scale), edge handles (stretch one axis; dragging past the other edge flips) and a rotate knob; dragging moves it on the GPU (the selected marks drawn alone, over the cel replayed without them) and release writes one `transform` or `lasso` op. Layer settings recolour (the current colour), makes thinner or thicker, sets opacity, flips left-right or up-down and deletes, each as one history step. The selection is shared with the agent as addresses.+- Layers (M2 batch 4): layer settings sets clip to the layer below and lock alpha, adds a mask (empty, or hiding all), turns it on and off, removes it, and "paint on the mask" makes the mask the active layer (it also has its own row under its layer). Painting on a mask hides the layer under the strokes; the eraser shows it again. While a mask is active, what it hides is tinted red ("show the mask in red", on by default), and the brush panel says whether the brush or the eraser is on. The brush and fill tools record lock alpha from the active layer.- Live previews and clipping: the editor composes the active layer between cached images of everything below and above it only when that is exact (the active layer and the groups around it are not clipped, masked or a clip base); otherwise each dirty tile composes the whole stack. The GPU lift of a dragged shape or of selected strokes falls back to the outline (the result appears on release) when the dragged layer is clipped, masked or a clip base, when a group around it is, when a layer above it uses overlay, or when a lock-alpha mark lies at or after the first selected mark in its cel. Clip groups above the dragged layer stay live: they compose as one plane with the base's blend.-- Direct select (A, M2): click a path, rect or ellipse (inside groups too) to show its points; clicking the selected shape again steps down to the next shape under the pointer, and the inspector lists them all; click or shift click points, drag on empty canvas for a box; drag points or handles; alt click the outline adds a point, alt click a point toggles corner and smooth, alt drag a handle breaks it; delete removes points; the inspector has corner, smooth, delete points, simplify and "make it a path". While dragging, the edited outline is drawn live; on release the edit is one `path` op whose layer is rendered in the background, then swapped in.-- Select and move (V, M4 test): a press picks what is under the pen and drags it at once: a stroke or fill on the active paint layer first, then a vector shape (clicking a shape again steps to the one under it), then the topmost visible, unlocked paint layer with a mark there, which becomes the active layer. A stroke picked this way is the same selection as S makes (its bar, inspector, nudges, delete, copy), so V is the one tool for "move this". A press on empty canvas lassoes strokes on the active layer. Alt drag drags a copy: the copy is made (duplicate in place, one step) when the drag first moves, and the drag moves the copy (two history steps). A, the point editor, says so when a click lands on a brush stroke: strokes are samples, not paths.+- Direct select (A, M2): click a path, rect or ellipse (inside groups too) to show its points; clicking the selected shape again steps down to the next shape under the pointer, and layer settings list them all; click or shift click points, drag on empty canvas for a box; drag points or handles; alt click the outline adds a point, alt click a point toggles corner and smooth, alt drag a handle breaks it; delete removes points; layer settings have corner, smooth, delete points, simplify and "make it a path". While dragging, the edited outline is drawn live; on release the edit is one `path` op whose layer is rendered in the background, then swapped in.+- Select and move (V, M4 test): a press picks what is under the pen and drags it at once: a stroke or fill on the active paint layer first, then a vector shape (clicking a shape again steps to the one under it), then the topmost visible, unlocked paint layer with a mark there, which becomes the active layer. A stroke picked this way is the same selection as S makes (its bar, layer settings, nudges, delete, copy), so V is the one tool for "move this". A press on empty canvas lassoes strokes on the active layer. Alt drag drags a copy: the copy is made (duplicate in place, one step) when the drag first moves, and the drag moves the copy (two history steps). A, the point editor, says so when a click lands on a brush stroke: strokes are samples, not paths.- Pen (P, M4 test): draws vector paths on a vector layer: a click places a corner, a drag pulls out symmetric handles, a click on the first point closes the path, Return finishes it open, Esc drops it, and another tool finishes it. The path is one `add` node op into the layer at the current frame, in the current colour: closed paths are filled (unless "fill" is off) and outlined (unless "outline" is off), open ones always outlined, at the width in the options bar. On other layers it refuses and says why; the brush says so on a vector layer.- Colour (M2): a hue ring with a saturation and value square, hex, alpha; the document palette as swatches (click picks, right-click removes, "add colour" adds the current one with an optional name, all as ops); the last 16 colours used, kept in the user's settings. Alt-click with the brush or fill tool picks the colour of the image under the pointer, shift alt-click that of the active layer.- Fill tool (G, M2): click fills inside the lines of this layer, all visible layers or a chosen layer, with gap, tolerance, expand and opacity settings; drag a loop to lasso fill.-- Inspector gradients (M2): a shape's fill switches between none, solid, linear and radial; gradients edit their geometry and stops (position, colour, add, remove).+- Gradients in layer settings (M2): a shape's fill switches between none, solid, linear and radial; gradients edit their geometry and stops (position, colour, add, remove).- Canvas mipmaps (M2): every uploaded tile brings its own mip chain (box filtered on the CPU, down to one pixel per tile), so zoomed-out views sample trilinearly instead of shimmering.- Frames (M3): the canvas, painting, fills (their reference at that frame), selection, lifts, notes and the shared selection all work at the current frame. Painting paints into the drawing exposed there (on a link into its source, which the timeline says), and painting on a blank frame starts a drawing there. `,` and `.` step a frame, alt `,` and alt `.` jump to the previous and next drawing on the active layer, Home and End go to the first and last frame. The scene keeps drawings loaded across frames, so going back to a frame only recomposes it; a frame with drawings not loaded yet loads in a background frame job while the last frame stays on screen (drawings a job loaded before the document changed are not kept, and load again when needed; see the frame cache below). Drawings away from the current frame drop their replay checkpoints, and beyond 1 GB the least recently shown are evicted; a drawing changed from outside while it is not shown is evicted and reloads when its frame comes back.- Timeline panel (M3), along the bottom: a frame ruler with the playhead, one row per layer top first (groups fold, a mask row opens under its layer with `[m+]`), each cel a block across its exposure (drawings blue or green for vector, links purple marked `->c1`), blanks empty. Click a cell to go to that frame and layer; drag on the ruler or on empty cells to scrub; drag the right end of a block to change its exposure (later cels of the layer move); drag a block by its first frame to move it. Buttons, the context menu and keys: new drawing (K), duplicate to the next frame (the copy is placed after the exposure, later cels move back), show a drawing here (a link, picked from the layer's drawings), unlink, delete, hold longer and shorter (`=` and `-`), insert a frame (I, shift for every layer) and remove one, fps and length fields, "+ paint" and "+ vector" layers. Every action is one op and one history step. A row of playback controls sits above the buttons: play, the loop range (drawn orange on the ruler), onion skin and its settings, the shift K exposure, and the dropped frames of the last play; each layer name has an onion dot at its right end.@@ -472,9 +472,9 @@ Scripts are any language that prints edit ops as JSON lines into `klad apply`. G- In-between panel (M4 batch 4, `editor/between.rs`): "in-between" (the selection toolbar, the context menu, cmd K) opens a window instead of a menu: the first selected row's two keys as thumbnails with their frames (a frame not loaded yet says so), one on every frame or a count, spacing with the chart an animator draws between keys (key ticks at the ends, a tick per in-between where the spacing puts it), pairing (id, order, nearest shape; parts both keys have are named, they pair first), marks in one key only (leave, pop, fade, draw-on), and "make the in-betweens", which runs `klad inbetween` as a job (`between::args`). When the job ends its output is parsed into rows (`between::report`): each layer's pairs, parts and touching ends; an unpaired mark is a button that goes to the other key's frame, turns on the stroke tool and waits for one stroke to be picked, then makes the in-betweens again with that pair added to `--pair` (`pair_from`); a fill left out goes to its frame. "Check what a redo would remake" lists the in-betweens of the selection (or all) with their state from their marks' hash and authors (`redo_rows`): remade, drawn on by hand (keep them on top, the default; in-between them too; leave it) or edited (in-between it again, or leave it, the default); "redo them" runs one `klad inbetween --redo --only ... --keep-cels ... --force-cels ...`, one history step.- History (M4 batch 4, `editor/history.rs`): the History pane lists the redo stack (as "undone" with who made the step, farthest first), a "the document is here" marker and the undo stack, latest first: who (you for the editor, the agent for the CLI), what, how long ago. Clicking a row undoes or redoes as many steps as it takes to stand right after it (`steps_to`), timed in the status line. The list is read again when the document's revision changes.- Notes on the canvas (M4 batch 4, `editor/pins.rs`): every open note is a pin, those of other frames dimmed with their frame, done ones on this frame checked in green. With the note tool a click on a pin opens its popover (the text to edit and save, done, remove, close); elsewhere it opens a popover for a new note at that spot ("pin it"). A right click on any pin, of this frame or a dimmed one of another, goes to its frame and selects it (an accent ring and its popover); Delete removes the selected note. The Notes pane lists the open notes (a click goes to the frame and opens the pin) and the done ones folded, each can be opened again; every note is one line, cut to the pane's width (a done note's "open again" is laid out first, at the right, so the row never runs past the pane), and "clear all" beside the done header removes the done notes (`notes::clear_done`, `klad notes --clear-done`). The editor watches `.cache/notes.json`, so the agent's `klad notes --done` shows at once.-- Settings (M4 batch 4, `settings.rs`, `editor/prefs.rs`): the settings file carries a `version` (2; files without one, the M1 to M4 ones, load with the new fields at their defaults and are stamped 2), `keys` (command id to key labels such as `shift D`, only the changed ones), `uiScale` (0.75 to 2, egui's zoom factor, so every control grows with it) and `defaults` (brush and size for new windows, the shift K exposure, onion before, after and opacity, the grey around the canvas). The window has pen calibration, defaults, keys (search, change by pressing the key, no key, reset one or all) and layout. `commands::Bindings` holds the keys: a changed command's keys replace its first ones, a key another command already uses is refused and that command named (`taken_by`), holds (Q, W, space) keep their keys, and every key lookup (dispatch, hints, the palette, the strip's letters) goes through it.+- Settings (M4 batch 4, `settings.rs`, `editor/prefs.rs`): the settings file carries a `version` (2; files without one, the M1 to M4 ones, load with the new fields at their defaults and are stamped 2), `keys` (command id to key labels such as `shift D`, only the changed ones), `uiScale` (0.75 to 2, egui's zoom factor, so every control grows with it) and `defaults` (brush and size for new windows, the shift K exposure, onion before, after and opacity, the grey around the canvas). Settings is a modal (cmd , or klad > Settings…; Esc, the close button or a click outside closes it, except while a new key is being pressed) with a sidebar of five sections and one section in the body at a time (`editor/prefs.rs`, `prefs::Section`): Pen (the pressure bars, lightest, heaviest, curve and the response graph), Drawing (the brush and size new windows start with, how long shift K's drawings hold, onion skin, the grey around the canvas), Keys (search, change by pressing the key, no key, reset one or all; the list fills the body), Layout (interface size, the timeline and numbers, reset the layout) and Updates (this version, the daily check, check now). Each section is a two-column grid, the label in grey on the left. While the modal is open the editor's own keys do nothing except cmd , (the modal blocks the pointer, and now the keys too). `commands::Bindings` holds the keys: a changed command's keys replace its first ones, a key another command already uses is refused and that command named (`taken_by`), holds (Q, W, space) keep their keys, and every key lookup (dispatch, hints, the palette, the strip's letters) goes through it.- Export to Godot (M3 batch 3): the clip row has a "Godot folder" field (the document's `export.godot`; a typed folder is relative to the folder holding the bundle) and an "export to Godot" button, which runs `klad export <bundle> --godot` (with the typed folder and `--store` when it differs) as a background job of the same binary, so the CLI and the editor write the same files; its summary or error is a message.-- CLI forms in the editor (M5, S5.25, `editor/checks.rs`, `editor/export.rs`): refill this drawing and show gaps (the fill tool's options and the palette), fill like the first drawing (the timeline selection toolbar), a part name for the selected marks (the stroke inspector, the `part` op), show parts and show arcs of the selected mark or part over the clip (the palette), an export window (the document menu, cmd E: this frame, a layer, numbered frames or a sprite sheet, and Godot) and add a font file (the document menu and the text inspector, with the macOS open panel). The text tool (T, S5.26, `editor/text.rs`): a click starts a text on the active vector layer (or a new one when it is committed), typing shows on the canvas at once as a picture drawn by the same renderer while the node stays out of the document (an existing node is hidden in memory while it is edited), and Esc, a click outside or another tool commits it as one edit; a double click on text with V or T edits it in place. While typing the canvas holds egui's keyboard focus, so command keys type instead of switching tools. The font picker (the tool's options and the text inspector) lists klad's families drawn in their own face, the drawing's own files and, for a search, open families to download as a background `klad fonts --get` job. Paint with body (S5.23): a body slider at the top of the brush window, and relief in the inspector's effects with a light dial (click or drag towards the light). Everything but the part name runs the `klad` binary as a background job with the same arguments a person would type (`crate::start::draw_binary` finds it next to the editor, and next to the test binaries in tests), so the CLI and the editor do the same thing by construction; gaps and arcs read the command's `--json` and draw on the canvas until the next edit. The ops that draw from shapes (`ink`, `light`, `hatch`, `paint`, `scatter`) stay CLI only (principle 7).+- CLI forms in the editor (M5, S5.25, `editor/checks.rs`, `editor/export.rs`): refill this drawing and show gaps (the fill tool's options and the palette), fill like the first drawing (the timeline selection toolbar), a part name for the selected marks (layer settings for strokes, the `part` op), show parts and show arcs of the selected mark or part over the clip (the palette), an export window (the document menu, cmd E: this frame, a layer, numbered frames or a sprite sheet, and Godot) and add a font file (the document menu and layer settings for text, with the macOS open panel). The text tool (T, S5.26, `editor/text.rs`): a click starts a text on the active vector layer (or a new one when it is committed), typing shows on the canvas at once as a picture drawn by the same renderer while the node stays out of the document (an existing node is hidden in memory while it is edited), and Esc, a click outside or another tool commits it as one edit; a double click on text with V or T edits it in place. While typing the canvas holds egui's keyboard focus, so command keys type instead of switching tools. The font picker (the tool's options and layer settings for text) lists klad's families drawn in their own face, the drawing's own files and, for a search, open families to download as a background `klad fonts --get` job. Paint with body (S5.23): a body slider at the top of the brush window, and relief in the effects of layer settings with a light dial (click or drag towards the light). Everything but the part name runs the `klad` binary as a background job with the same arguments a person would type (`crate::start::draw_binary` finds it next to the editor, and next to the test binaries in tests), so the CLI and the editor do the same thing by construction; gaps and arcs read the command's `--json` and draw on the canvas until the next edit. The ops that draw from shapes (`ink`, `light`, `hatch`, `paint`, `scatter`) stay CLI only (principle 7).- Agent channel: the current selection and pinned notes are written to `.cache/selection.json` and `.cache/notes.json` for `klad selection` and `klad notes`; both carry the frame.- Vector layers are rasterised into tiles when opened and when their nodes change; per-tile composition then only draws one tile per layer.