mirror of
https://codeberg.org/unspeaker/tengri.git
synced 2025-12-07 12:16:44 +01:00
output: more big refactors
This commit is contained in:
parent
194f2f9874
commit
5e6338fad8
68 changed files with 1604 additions and 1016 deletions
10
output/src/widget/widget_border.rs
Normal file
10
output/src/widget/widget_border.rs
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
use crate::*;
|
||||
|
||||
pub struct Border<S>(pub bool, pub S);
|
||||
impl<O: Out, S: Layout<O>> Layout<O> for Border<S> {
|
||||
fn layout (&self, area: O::Area) -> O::Area {
|
||||
self.1.layout(area)
|
||||
}
|
||||
}
|
||||
|
||||
pub struct Bordered<S, W>(pub bool, pub S, pub W);
|
||||
25
output/src/widget/widget_field.rs
Normal file
25
output/src/widget/widget_field.rs
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
use crate::*;
|
||||
|
||||
pub struct FieldH<Theme, Label, Value>(pub Theme, pub Label, pub Value);
|
||||
impl<O: Out, T, L: Draw<O>, V: Draw<O>> Layout<O> for FieldH<T, L, V> where Self: Content<O> {
|
||||
fn layout (&self, to: O::Area) -> O::Area {
|
||||
self.content().layout(to)
|
||||
}
|
||||
}
|
||||
impl<O: Out, T, L: Draw<O>, V: Draw<O>> Draw<O> for FieldH<T, L, V> where Self: Content<O> {
|
||||
fn draw (&self, to: &mut O) {
|
||||
self.content().draw(to)
|
||||
}
|
||||
}
|
||||
|
||||
pub struct FieldV<Theme, Label, Value>(pub Theme, pub Label, pub Value);
|
||||
impl<O: Out, T, L: Draw<O>, V: Draw<O>> Layout<O> for FieldV<T, L, V> where Self: Content<O> {
|
||||
fn layout (&self, to: O::Area) -> O::Area {
|
||||
self.content().layout(to)
|
||||
}
|
||||
}
|
||||
impl<O: Out, T, L: Draw<O>, V: Draw<O>> Draw<O> for FieldV<T, L, V> where Self: Content<O> {
|
||||
fn draw (&self, to: &mut O) {
|
||||
self.content().draw(to)
|
||||
}
|
||||
}
|
||||
15
output/src/widget/widget_style.rs
Normal file
15
output/src/widget/widget_style.rs
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
#[allow(unused)] use crate::*;
|
||||
|
||||
pub struct Foreground<Color, Item>(pub Color, pub Item);
|
||||
impl<O: Out, Color, Item: Layout<O>> Layout<O> for Foreground<Color, Item> {
|
||||
fn layout (&self, to: O::Area) -> O::Area {
|
||||
self.1.layout(to)
|
||||
}
|
||||
}
|
||||
|
||||
pub struct Background<Color, Item>(pub Color, pub Item);
|
||||
impl<O: Out, Color, Item: Layout<O>> Layout<O> for Background<Color, Item> {
|
||||
fn layout (&self, to: O::Area) -> O::Area {
|
||||
self.1.layout(to)
|
||||
}
|
||||
}
|
||||
31
output/src/widget/widget_tryptich.rs
Normal file
31
output/src/widget/widget_tryptich.rs
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
#[allow(unused)] use crate::*;
|
||||
|
||||
/// A three-column layout.
|
||||
pub struct Tryptich<A, B, C> {
|
||||
pub top: bool,
|
||||
pub h: u16,
|
||||
pub left: (u16, A),
|
||||
pub middle: (u16, B),
|
||||
pub right: (u16, C),
|
||||
}
|
||||
|
||||
impl Tryptich<(), (), ()> {
|
||||
pub fn center (h: u16) -> Self {
|
||||
Self { h, top: false, left: (0, ()), middle: (0, ()), right: (0, ()) }
|
||||
}
|
||||
pub fn top (h: u16) -> Self {
|
||||
Self { h, top: true, left: (0, ()), middle: (0, ()), right: (0, ()) }
|
||||
}
|
||||
}
|
||||
|
||||
impl<A, B, C> Tryptich<A, B, C> {
|
||||
pub fn left <D> (self, w: u16, content: D) -> Tryptich<D, B, C> {
|
||||
Tryptich { left: (w, content), ..self }
|
||||
}
|
||||
pub fn middle <D> (self, w: u16, content: D) -> Tryptich<A, D, C> {
|
||||
Tryptich { middle: (w, content), ..self }
|
||||
}
|
||||
pub fn right <D> (self, w: u16, content: D) -> Tryptich<A, B, D> {
|
||||
Tryptich { right: (w, content), ..self }
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue