diff --git a/CHANGES.md b/CHANGES.md index e4a72ed2..6ab53f46 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,3 +1,8 @@ +* 0.2.10 + * BUGFIX: `on_mount` is now called after the children are generated + * BUGFIX: `on_tick` is now run before the cycle call + * BUGFIX: `expand` would make the constraints tight, this is no longer the + case * 0.2.9 * New function: truncate * New border style: "rounded" diff --git a/Cargo.toml b/Cargo.toml index 06a585c8..02dd4062 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "anathema" edition = "2024" -version = "0.2.9" +version = "0.2.10" license = "MIT" description = "Create beautiful, easily customisable terminal applications" keywords = ["tui", "terminal", "widgets", "ui", "layout"] @@ -11,6 +11,7 @@ documentation = "https://togglebyte.github.io/anathema-guide/" homepage = "https://github.com/togglebyte/anathema" repository = "https://github.com/togglebyte/anathema" publish = true +rust-version = "1.88" [dependencies] anathema-backend = { workspace = true } @@ -39,7 +40,7 @@ workspace = true [workspace.package] edition = "2024" -version = "0.2.9" +version = "0.2.10" [workspace.dependencies] bitflags = "2.4.1" @@ -47,16 +48,16 @@ crossterm = "0.28.1" unicode-width = "0.1.11" flume = "0.11.0" notify = "6.1.1" -anathema-default-widgets = { path = "./anathema-default-widgets", version = "0.2.9" } -anathema-backend = { path = "./anathema-backend", version = "0.2.9" } -anathema-runtime = { path = "./anathema-runtime", version = "0.2.9" } -anathema-state = { path = "./anathema-state", version = "0.2.9" } -anathema-state-derive = { path = "./anathema-state-derive", version = "0.2.9" } -anathema-store = { path = "./anathema-store", version = "0.2.9" } -anathema-templates = { path = "./anathema-templates", version = "0.2.9" } -anathema-widgets = { path = "./anathema-widgets", version = "0.2.9" } -anathema-geometry = { path = "./anathema-geometry", version = "0.2.9" } -anathema-value-resolver = { path = "./anathema-value-resolver", version = "0.2.9" } +anathema-default-widgets = { path = "./anathema-default-widgets", version = "0.2.10" } +anathema-backend = { path = "./anathema-backend", version = "0.2.10" } +anathema-runtime = { path = "./anathema-runtime", version = "0.2.10" } +anathema-state = { path = "./anathema-state", version = "0.2.10" } +anathema-state-derive = { path = "./anathema-state-derive", version = "0.2.10" } +anathema-store = { path = "./anathema-store", version = "0.2.10" } +anathema-templates = { path = "./anathema-templates", version = "0.2.10" } +anathema-widgets = { path = "./anathema-widgets", version = "0.2.10" } +anathema-geometry = { path = "./anathema-geometry", version = "0.2.10" } +anathema-value-resolver = { path = "./anathema-value-resolver", version = "0.2.10" } [workspace] members = [ @@ -83,6 +84,7 @@ should_implement_trait = "allow" type_complexity = "allow" too_many_arguments = "allow" wrong_self_convention = "allow" +collapsible_if = "allow" [package.metadata.release] shared-version = true diff --git a/anathema-default-widgets/src/layout/expand.rs b/anathema-default-widgets/src/layout/expand.rs index d3eb9e8a..9edbb96c 100644 --- a/anathema-default-widgets/src/layout/expand.rs +++ b/anathema-default-widgets/src/layout/expand.rs @@ -85,14 +85,14 @@ pub fn layout_all_expansions<'bp>( let mut constraints = Constraints::new(sub_size, constraints.max_height()); // Ensure that the rounding doesn't push the constraint outside of the max width - constraints.min_width = constraints.max_width(); + constraints.min_width = constraints.min_width.min(constraints.max_width()); constraints } Axis::Vertical => { let mut constraints = Constraints::new(constraints.max_width(), sub_size); // Ensure that the rounding doesn't push the constraint outside of the max height - constraints.min_height = constraints.max_height(); + constraints.min_height = constraints.min_height.min(constraints.max_height()); constraints } }; diff --git a/anathema-geometry/src/region.rs b/anathema-geometry/src/region.rs index d2ba16cc..6046638c 100644 --- a/anathema-geometry/src/region.rs +++ b/anathema-geometry/src/region.rs @@ -49,8 +49,8 @@ impl Region { } /// Check if a region contains a position. - /// Regions are inclusive, so a region from 0,0 to 10, 10 contains both Pos::ZERO and - /// Pos::New(10, 10) + /// Regions are exclusive, so a region from 0,0 to 10, 10 contains `Pos::ZERO` + /// but not `Pos::New(10, 10)` pub const fn contains(&self, pos: Pos) -> bool { pos.x >= self.from.x && pos.x < self.to.x && pos.y >= self.from.y && pos.y < self.to.y } diff --git a/anathema-runtime/src/runtime/mod.rs b/anathema-runtime/src/runtime/mod.rs index 316292b5..cba995d1 100644 --- a/anathema-runtime/src/runtime/mod.rs +++ b/anathema-runtime/src/runtime/mod.rs @@ -385,11 +385,11 @@ impl<'rt, 'bp, G: GlobalEventHandler> Frame<'rt, 'bp, G> { puffin::GlobalProfiler::lock().new_frame(); let now = Instant::now(); - self.init_new_components(); let elapsed = self.handle_messages(now); self.poll_events(elapsed, now, backend); self.drain_deferred_commands(); self.drain_assoc_events(); + self.tick_components(self.dt.elapsed()); // TODO: // this secondary call is here to deal with changes causing changes @@ -397,9 +397,9 @@ impl<'rt, 'bp, G: GlobalEventHandler> Frame<'rt, 'bp, G> { self.apply_changes()?; self.apply_changes()?; - self.tick_components(self.dt.elapsed()); self.cycle(backend)?; + self.init_new_components(); self.post_cycle_events(); *self.dt = Instant::now(); diff --git a/anathema-testutils/Cargo.toml b/anathema-testutils/Cargo.toml index 59542d64..30784387 100644 --- a/anathema-testutils/Cargo.toml +++ b/anathema-testutils/Cargo.toml @@ -9,7 +9,7 @@ homepage = "https://github.com/togglebyte/anathema" repository = "https://github.com/togglebyte/anathema" [dependencies] -anathema = { path = "../", version = "0.2.9" } +anathema = { path = "../", version = "0.2.10" } [lints] workspace = true diff --git a/anathema-widgets/src/nodes/eval.rs b/anathema-widgets/src/nodes/eval.rs index c9628396..232e3c79 100644 --- a/anathema-widgets/src/nodes/eval.rs +++ b/anathema-widgets/src/nodes/eval.rs @@ -303,9 +303,7 @@ impl Evaluator for ComponentEval { .ok_or_else(|| ctx.error(ErrorKind::TreeTransactionFailed))?; ctx.new_components.push((widget_id, state_id)); - let path = tree.path(widget_id); - ctx.components - .push(path, component_id, widget_id, state_id, accept_ticks); + ctx.components.push(component_id, widget_id, state_id, accept_ticks); Ok(()) } diff --git a/anathema-widgets/src/widget/mod.rs b/anathema-widgets/src/widget/mod.rs index 5f393c4d..f87a3085 100644 --- a/anathema-widgets/src/widget/mod.rs +++ b/anathema-widgets/src/widget/mod.rs @@ -1,5 +1,4 @@ use std::any::Any; -use std::cmp::Ordering; use std::fmt::{self, Debug}; use std::ops::ControlFlow; @@ -39,27 +38,6 @@ pub struct CompEntry { pub accept_ticks: bool, component_id: ComponentBlueprintId, - path: Box<[u16]>, -} - -impl PartialOrd for CompEntry { - fn partial_cmp(&self, other: &Self) -> Option { - Some(self.path.cmp(&other.path)) - } -} - -impl Ord for CompEntry { - fn cmp(&self, other: &Self) -> Ordering { - self.path.cmp(&other.path) - } -} - -impl Eq for CompEntry {} - -impl PartialEq for CompEntry { - fn eq(&self, other: &Self) -> bool { - self.path.eq(&other.path) - } } /// Store a list of components currently in the tree @@ -74,14 +52,12 @@ impl Components { pub fn push( &mut self, - path: Box<[u16]>, component_id: ComponentBlueprintId, widget_id: WidgetId, state_id: StateId, accept_ticks: bool, ) { let entry = CompEntry { - path, component_id, widget_id, state_id,