mirror of
https://codeberg.org/unspeaker/tengri.git
synced 2026-07-18 00:07:00 +02:00
add Layout trait
This commit is contained in:
parent
1f60b43f61
commit
09463649c6
6 changed files with 208 additions and 222 deletions
126
src/draw/xywh.rs
126
src/draw/xywh.rs
|
|
@ -113,129 +113,3 @@ impl<N: Coord, T: Wide<N> + Tall<N>> Wh<N> for T {
|
|||
}
|
||||
|
||||
impl<N: Coord, T: Xy<N> + Wh<N>> Xywh<N> for T {}
|
||||
|
||||
/// Shrink drawing area symmetrically.
|
||||
///
|
||||
/// ```
|
||||
/// let padded = tengri::wh_pad("Hello");
|
||||
/// ```
|
||||
pub const fn wh_pad <T: Screen> (w: T::Unit, h: T::Unit, it: impl Draw<T>)
|
||||
-> impl Draw<T>
|
||||
{
|
||||
thunk(move|to: &mut T|it.draw(todo!()))
|
||||
}
|
||||
|
||||
/// Only draw content if area is above a certain size.
|
||||
///
|
||||
/// ```
|
||||
/// let min = tengri::wh_min(3, 5, "Hello"); // 5x5
|
||||
/// ```
|
||||
pub const fn wh_min <T: Screen> (w: Option<T::Unit>, h: Option<T::Unit>, it: impl Draw<T>)
|
||||
-> impl Draw<T>
|
||||
{
|
||||
thunk(move|to: &mut T|it.draw(todo!()))
|
||||
}
|
||||
|
||||
/// Set the maximum width and/or height of the content.
|
||||
///
|
||||
/// ```
|
||||
/// let max = tengri::wh_max(Some(3), Some(5), "Hello");
|
||||
/// ```
|
||||
pub const fn wh_max <T: Screen> (w: Option<T::Unit>, h: Option<T::Unit>, it: impl Draw<T>)
|
||||
-> impl Draw<T>
|
||||
{
|
||||
thunk(move|_to: &mut T|it.draw(todo!()))
|
||||
}
|
||||
|
||||
/// Set the maximum width and/or height of the content.
|
||||
///
|
||||
/// ```
|
||||
/// let exact = tengri::wh_exact(Some(3), Some(5), "Hello");
|
||||
/// ```
|
||||
pub const fn wh_exact <T: Screen> (w: Option<T::Unit>, h: Option<T::Unit>, it: impl Draw<T>)
|
||||
-> impl Draw<T>
|
||||
{
|
||||
thunk(move|_to: &mut T|it.draw(todo!()))
|
||||
}
|
||||
|
||||
/// Limit size of drawing area
|
||||
/// ```
|
||||
/// let clipped = tengri::wh_clip(Some(3), Some(5), "Hello");
|
||||
/// ```
|
||||
pub const fn wh_clip <T: Screen> (
|
||||
w: Option<T::Unit>, h: Option<T::Unit>, it: impl Draw<T>
|
||||
) -> impl Draw<T> {
|
||||
thunk(move|_to: &mut T|it.draw(todo!()))
|
||||
}
|
||||
|
||||
pub const fn wh_full <T: Screen> (a: impl Draw<T>) -> impl Draw<T> {
|
||||
todo!();
|
||||
a
|
||||
}
|
||||
|
||||
pub const fn w_full <T: Screen> (a: impl Draw<T>) -> impl Draw<T> {
|
||||
todo!();
|
||||
a
|
||||
}
|
||||
|
||||
pub const fn h_full <T: Screen> (a: impl Draw<T>) -> impl Draw<T> {
|
||||
todo!();
|
||||
a
|
||||
}
|
||||
|
||||
pub const fn h_max <T: Screen> (h: Option<T::Unit>, a: impl Draw<T>) -> impl Draw<T> {
|
||||
wh_max(None, h, a)
|
||||
}
|
||||
pub const fn h_min <T: Screen> (h: Option<T::Unit>, a: impl Draw<T>) -> impl Draw<T> {
|
||||
wh_min(None, h, a)
|
||||
}
|
||||
pub const fn h_exact <T: Screen> (h: T::Unit, c: impl Draw<T>) -> impl Draw<T> {
|
||||
wh_exact(None, Some(h), c)
|
||||
}
|
||||
pub const fn w_max <T: Screen> (w: Option<T::Unit>, a: impl Draw<T>) -> impl Draw<T> {
|
||||
wh_max(w, None, a)
|
||||
}
|
||||
pub const fn w_min <T: Screen> (w: Option<T::Unit>, a: impl Draw<T>) -> impl Draw<T> {
|
||||
wh_min(w, None, a)
|
||||
}
|
||||
pub const fn w_exact <T: Screen> (w: T::Unit, c: impl Draw<T>) -> impl Draw<T> {
|
||||
wh_exact(Some(w), None, c)
|
||||
}
|
||||
/// Shrink drawing area symmetrically.
|
||||
///
|
||||
/// ```
|
||||
/// let padded = tengri::space::w_pad(3, "Hello");
|
||||
/// ```
|
||||
pub const fn w_pad <T: Screen> (x: T::Unit, draw: impl Draw<T>) -> impl Draw<T> {
|
||||
thunk(move|to: &mut T|draw.draw(todo!()))
|
||||
}
|
||||
/// Shrink drawing area symmetrically.
|
||||
///
|
||||
/// ```
|
||||
/// let padded = tengri::space::w_pad(3, "Hello");
|
||||
/// ```
|
||||
pub const fn h_pad <T: Screen> (x: T::Unit, draw: impl Draw<T>) -> impl Draw<T> {
|
||||
thunk(move|to: &mut T|draw.draw(todo!()))
|
||||
}
|
||||
|
||||
pub const fn xy_push <T: Screen> (x: T::Unit, y: T::Unit, a: impl Draw<T>) -> impl Draw<T> {
|
||||
a
|
||||
}
|
||||
|
||||
pub const fn xy_pull <T: Screen> (x: T::Unit, y: T::Unit, a: impl Draw<T>) -> impl Draw<T> {
|
||||
a
|
||||
}
|
||||
|
||||
pub const fn x_push <T: Screen> (x: T::Unit, a: impl Draw<T>) -> impl Draw<T> {
|
||||
a
|
||||
}
|
||||
pub const fn x_pull <T: Screen> (x: T::Unit, a: impl Draw<T>) -> impl Draw<T> {
|
||||
a
|
||||
}
|
||||
|
||||
pub const fn y_push <T: Screen> (x: T::Unit, a: impl Draw<T>) -> impl Draw<T> {
|
||||
a
|
||||
}
|
||||
pub const fn y_pull <T: Screen> (x: T::Unit, a: impl Draw<T>) -> impl Draw<T> {
|
||||
a
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue