From cf57f44933c45507e8de072e32c284f20f12ac7a Mon Sep 17 00:00:00 2001 From: same mf who else Date: Sat, 21 Mar 2026 20:56:42 +0200 Subject: [PATCH] stub fn origin and iter --- dizzle | 2 +- src/space.rs | 133 +++++++++++++++++++++++++++++++++++++++++++-------- 2 files changed, 115 insertions(+), 20 deletions(-) diff --git a/dizzle b/dizzle index 44b2be5..192a1d8 160000 --- a/dizzle +++ b/dizzle @@ -1 +1 @@ -Subproject commit 44b2be57ca8d1f69a95f2eb02f4b5474ec77ac0a +Subproject commit 192a1d8257a9f2ad43ebceacb7b5ca348c601471 diff --git a/src/space.rs b/src/space.rs index bb8532b..b7c7e96 100644 --- a/src/space.rs +++ b/src/space.rs @@ -57,11 +57,47 @@ impl XYWH { } /// Something that has `[0, 0]` at a particular point. -pub trait HasOrigin { - fn origin (&self) -> Origin; +pub trait HasOrigin { fn origin (&self) -> Origin; } -impl> HasOrigin for T { - fn origin (&self) -> Origin { *self.as_ref() } +impl> HasOrigin for T { fn origin (&self) -> Origin { *self.as_ref() } } +pub struct Anchor(Origin, T); +impl AsRef for Anchor { + fn as_ref (&self) -> &Origin { + &self.0 + } +} +impl> Draw for Anchor { + fn draw (self, to: &mut T) -> Usually> { + todo!() + } +} + +pub const fn origin_nw (a: impl Draw) -> impl Draw { + Anchor(Origin::NW, a) +} +pub const fn origin_n (a: impl Draw) -> impl Draw { + Anchor(Origin::N, a) +} +pub const fn origin_ne (a: impl Draw) -> impl Draw { + Anchor(Origin::NE, a) +} +pub const fn origin_w (a: impl Draw) -> impl Draw { + Anchor(Origin::W, a) +} +pub const fn origin_c (a: impl Draw) -> impl Draw { + Anchor(Origin::C, a) +} +pub const fn origin_e (a: impl Draw) -> impl Draw { + Anchor(Origin::E, a) +} +pub const fn origin_sw (a: impl Draw) -> impl Draw { + Anchor(Origin::SW, a) +} +pub const fn origin_s (a: impl Draw) -> impl Draw { + Anchor(Origin::S, a) +} +pub const fn origin_se (a: impl Draw) -> impl Draw { + Anchor(Origin::SE, a) } /// Where is [0, 0] located? @@ -203,21 +239,6 @@ impl Split { Self::Below => (C, C), } } - /// Iterate over a collection of renderables: - /// - /// ``` - /// use tengri::draw::{Origin::*, Split::*}; - /// let _ = Below.iter([ - /// NW.align(W(15).max(W(10).min("Leftbar"))), - /// NE.align(W(12).max(W(10).min("Rightbar"))), - /// Center.align(W(40).max(H(20.max("Center")))) - /// ].iter(), |x|x); - /// ``` - pub fn iter , F: Fn(U)->dyn Draw> ( - _items: impl Iterator, _cb: F - ) -> impl Draw { - thunk(move|_to: &mut T|{ todo!() }) - } } /// Horizontal axis. @@ -385,3 +406,77 @@ pub const fn wh_clip ( ) -> impl Draw { thunk(move|to: &mut T|draw.draw(todo!())) } + +pub const fn wh_full (a: impl Draw) -> impl Draw { a } +pub const fn w_full (a: impl Draw) -> impl Draw { a } +pub const fn h_full (a: impl Draw) -> impl Draw { a } + +#[macro_export] macro_rules! north { + ($($tt:tt)*) => { unimplemented!() }; +} +#[macro_export] macro_rules! south { + ($($tt:tt)*) => { unimplemented!() }; +} +#[macro_export] macro_rules! east { + ($($tt:tt)*) => { unimplemented!() }; +} +#[macro_export] macro_rules! west { + ($($tt:tt)*) => { unimplemented!() }; +} +#[macro_export] macro_rules! above { + ($($tt:tt)*) => { unimplemented!() }; +} +#[macro_export] macro_rules! below { + ($($tt:tt)*) => { unimplemented!() }; +} + +/// Iterate over a collection of renderables: +/// +/// ``` +/// use tengri::draw::{Origin::*, Split::*}; +/// let _ = Below.iter([ +/// NW.align(W(15).max(W(10).min("Leftbar"))), +/// NE.align(W(12).max(W(10).min("Rightbar"))), +/// Center.align(W(40).max(H(20.max("Center")))) +/// ].iter(), |x|x); +/// ``` +pub fn iter < + T: Screen, + V: Fn()->I, + I: Iterator>, + F: Fn(&dyn Draw)->dyn Draw, +> (_items: V, _cb: F) -> impl Draw { + thunk(move|_to: &mut T|{ todo!() }) +} +pub fn iter_north < + T: Screen, + V: Fn()->I, + I: Iterator>, + F: Fn(&dyn Draw)->dyn Draw, +> (_items: V, _cb: F) -> impl Draw { + thunk(move|_to: &mut T|{ todo!() }) +} +pub fn iter_east < + T: Screen, + V: Fn()->I, + I: Iterator>, + F: Fn(&dyn Draw)->dyn Draw, +> (_items: V, _cb: F) -> impl Draw { + thunk(move|_to: &mut T|{ todo!() }) +} +pub fn iter_south < + T: Screen, + V: Fn()->I, + I: Iterator>, + F: Fn(&dyn Draw)->dyn Draw, +> (_items: V, _cb: F) -> impl Draw { + thunk(move|_to: &mut T|{ todo!() }) +} +pub fn iter_west < + T: Screen, + V: Fn()->I, + I: Iterator>, + F: Fn(&dyn Draw)->dyn Draw, +> (_items: V, _cb: F) -> impl Draw { + thunk(move|_to: &mut T|{ todo!() }) +}