mirror of
https://github.com/GraphiteEditor/Graphite.git
synced 2026-10-01 05:28:11 +08:00
Add the leveled extent_at/depth trait surface and the push_level context helper
This commit is contained in:
@@ -989,6 +989,21 @@ impl<'a> ContextImpl<'a> {
|
|||||||
..*self
|
..*self
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// The promote half of decompose-and-promote: derives the context for the
|
||||||
|
/// content of one copy at a pushed structure level. `copy` becomes the
|
||||||
|
/// enclosing level's index (held in `frame`, which the caller owns for the
|
||||||
|
/// derived context's scope) and `inner` is the content's lane within that
|
||||||
|
/// copy. The structure node computes `copy`/`inner` from its own
|
||||||
|
/// extent-driven decomposition of the current lane.
|
||||||
|
pub fn push_level<'s>(&self, frame: &'s mut IndexLink<'s>, copy: u64, inner: u64) -> ContextImpl<'s>
|
||||||
|
where
|
||||||
|
'a: 's,
|
||||||
|
{
|
||||||
|
frame.index = copy;
|
||||||
|
frame.outer = self.index.outer;
|
||||||
|
self.promoted(frame, inner)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Ctx for ContextImpl<'_> {}
|
impl Ctx for ContextImpl<'_> {}
|
||||||
|
|||||||
@@ -181,6 +181,20 @@ pub trait Node<Input> {
|
|||||||
GPoll::Final(Extent::Free)
|
GPoll::Final(Extent::Free)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// The count of items at one absolute nesting level (innermost `0`). The
|
||||||
|
/// leveled primitive a structure node overrides to report a pushed level's
|
||||||
|
/// size; the scalar base is one item at every level. Uncertainty rides the
|
||||||
|
/// `GPoll` status axis, as with [`extent`](Node::extent).
|
||||||
|
fn extent_at(&self, _input: &Input, _level: u8) -> GPoll<Extent> {
|
||||||
|
GPoll::Final(Extent::Exactly(1))
|
||||||
|
}
|
||||||
|
|
||||||
|
/// The node's domain depth (number of nesting levels; `0` = scalar), baked
|
||||||
|
/// into the record layout at wiring.
|
||||||
|
fn depth(&self) -> u8 {
|
||||||
|
self.layout().depth
|
||||||
|
}
|
||||||
|
|
||||||
/// Introspection access to node-resident records; `None` for ordinary nodes.
|
/// Introspection access to node-resident records; `None` for ordinary nodes.
|
||||||
fn serialize(&self) -> Option<std::sync::Arc<dyn std::any::Any + Send + Sync>> {
|
fn serialize(&self) -> Option<std::sync::Arc<dyn std::any::Any + Send + Sync>> {
|
||||||
None
|
None
|
||||||
@@ -252,6 +266,10 @@ where
|
|||||||
(**self).extent(input)
|
(**self).extent(input)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn extent_at(&self, input: &Input, level: u8) -> GPoll<Extent> {
|
||||||
|
(**self).extent_at(input, level)
|
||||||
|
}
|
||||||
|
|
||||||
fn serialize(&self) -> Option<std::sync::Arc<dyn std::any::Any + Send + Sync>> {
|
fn serialize(&self) -> Option<std::sync::Arc<dyn std::any::Any + Send + Sync>> {
|
||||||
(**self).serialize()
|
(**self).serialize()
|
||||||
}
|
}
|
||||||
@@ -282,6 +300,10 @@ where
|
|||||||
(**self).extent(input)
|
(**self).extent(input)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn extent_at(&self, input: &Input, level: u8) -> GPoll<Extent> {
|
||||||
|
(**self).extent_at(input, level)
|
||||||
|
}
|
||||||
|
|
||||||
fn serialize(&self) -> Option<std::sync::Arc<dyn std::any::Any + Send + Sync>> {
|
fn serialize(&self) -> Option<std::sync::Arc<dyn std::any::Any + Send + Sync>> {
|
||||||
(**self).serialize()
|
(**self).serialize()
|
||||||
}
|
}
|
||||||
@@ -312,6 +334,10 @@ where
|
|||||||
(**self).extent(input)
|
(**self).extent(input)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn extent_at(&self, input: &Input, level: u8) -> GPoll<Extent> {
|
||||||
|
(**self).extent_at(input, level)
|
||||||
|
}
|
||||||
|
|
||||||
fn serialize(&self) -> Option<std::sync::Arc<dyn std::any::Any + Send + Sync>> {
|
fn serialize(&self) -> Option<std::sync::Arc<dyn std::any::Any + Send + Sync>> {
|
||||||
(**self).serialize()
|
(**self).serialize()
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user