mirror of
https://codeberg.org/unspeaker/tek.git
synced 2025-12-06 19:56:42 +01:00
align scene cells at both edges
This commit is contained in:
parent
7dc435754a
commit
76cefdca61
2 changed files with 37 additions and 25 deletions
|
|
@ -1,4 +1,5 @@
|
|||
use crate::*;
|
||||
use crate::Color::*;
|
||||
macro_rules! impl_content_layout_render {
|
||||
($Output:ty: |$self:ident: $Struct:ty, $to:ident| layout = $layout:expr; render = $render:expr) => {
|
||||
impl Content<$Output> for $Struct {
|
||||
|
|
@ -114,11 +115,8 @@ pub struct Phat<T> {
|
|||
pub width: u16,
|
||||
pub height: u16,
|
||||
pub content: T,
|
||||
pub fg: Color,
|
||||
pub top: Option<Color>,
|
||||
pub mid: Color,
|
||||
pub low: Option<Color>,
|
||||
pub selected: bool
|
||||
pub colors: [Color;4],
|
||||
pub selected: bool,
|
||||
}
|
||||
impl<T> Phat<T> {
|
||||
/// A phat line
|
||||
|
|
@ -132,11 +130,11 @@ impl<T> Phat<T> {
|
|||
}
|
||||
impl<T: Content<TuiOut>> Content<TuiOut> for Phat<T> {
|
||||
fn content (&self) -> impl Render<TuiOut> {
|
||||
let top = Fixed::y(1, self.top.map(|top|Self::lo(self.mid, top)));
|
||||
let low = Fixed::y(1, self.low.map(|low|Self::hi(self.mid, low)));
|
||||
let content = Tui::fg_bg(self.fg, self.mid, &self.content);
|
||||
let phat = Bsp::s(top, Bsp::n(low, Fill::xy(content)));
|
||||
Min::xy(self.width, self.height, phat)
|
||||
let [fg, bg, hi, lo] = self.colors;
|
||||
let top = Fixed::y(1, Self::lo(bg, hi));
|
||||
let low = Fixed::y(1, Self::hi(bg, lo));
|
||||
let content = Tui::fg_bg(fg, bg, &self.content);
|
||||
Min::xy(self.width, self.height, Bsp::s(top, Bsp::n(low, Fill::xy(content))))
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue