mirror of
https://codeberg.org/unspeaker/tek.git
synced 2025-12-06 11:46:41 +01:00
special handling of borders where w/h is 1
This commit is contained in:
parent
15751ea137
commit
958885686e
4 changed files with 29 additions and 26 deletions
|
|
@ -24,9 +24,7 @@ pub struct ItemPalette {
|
|||
pub darker: ItemColor,
|
||||
pub darkest: ItemColor,
|
||||
}
|
||||
/// Adds TUI RGB representation to an OKHSL value.
|
||||
from!(|okhsl: Okhsl<f32>|ItemColor = Self { okhsl, rgb: okhsl_to_rgb(okhsl) });
|
||||
/// Adds OKHSL representation to a TUI RGB value.
|
||||
from!(|rgb: Color|ItemColor = Self { rgb, okhsl: rgb_to_okhsl(rgb) });
|
||||
// A single color within item theme parameters, in OKHSL and RGB representations.
|
||||
impl ItemColor {
|
||||
|
|
|
|||
|
|
@ -64,12 +64,10 @@ render!(<Tui>|self: ArrangerTui|{
|
|||
let play = Fixed::wh(5, 2, PlayPause(self.clock.is_rolling()));
|
||||
let transport = TransportView::from((self, None, true));
|
||||
let with_transport = |x|col!([row!(![&play, &transport]), &x]);
|
||||
let with_pool = |x|Split::left(false, if self.show_pool {
|
||||
self.splits[1]
|
||||
} else {
|
||||
0
|
||||
}, PhraseListView(&self.phrases), x);
|
||||
with_transport(with_pool(col!([
|
||||
let with_pool = |x|Split::left(false,
|
||||
if self.show_pool { self.splits[1] } else { 0 },
|
||||
PhraseListView(&self.phrases), x);
|
||||
with_pool(with_transport(col!([
|
||||
&self.size,
|
||||
Fill::w(Fixed::h(20, arranger())),
|
||||
Fill::w(Fixed::h(25, &self.editor)),
|
||||
|
|
|
|||
|
|
@ -188,7 +188,7 @@ render!(<Tui>|self: ArrangerVCursor|render(move|to: &mut TuiOutput|{
|
|||
area
|
||||
},
|
||||
};
|
||||
let bg = TuiTheme::border_bg();
|
||||
let bg = Color::Rgb(0, 255, 0);
|
||||
if let Some([x, y, width, height]) = track_area {
|
||||
to.fill_fg([x, y, 1, height], bg);
|
||||
to.fill_fg([x + width, y, 1, height], bg);
|
||||
|
|
|
|||
|
|
@ -44,6 +44,12 @@ pub trait BorderStyle: Send + Sync + Copy {
|
|||
const S: &'static str = "";
|
||||
const SW: &'static str = "";
|
||||
const W: &'static str = "";
|
||||
|
||||
const N0: &'static str = "";
|
||||
const S0: &'static str = "";
|
||||
const W0: &'static str = "";
|
||||
const E0: &'static str = "";
|
||||
|
||||
fn n (&self) -> &str { Self::N }
|
||||
fn s (&self) -> &str { Self::S }
|
||||
fn e (&self) -> &str { Self::E }
|
||||
|
|
@ -67,30 +73,26 @@ pub trait BorderStyle: Send + Sync + Copy {
|
|||
let style = style.or_else(||self.style_horizontal());
|
||||
let [x, x2, y, y2] = area.lrtb();
|
||||
for x in x..x2.saturating_sub(1) {
|
||||
self.draw_north(to, x, y, style);
|
||||
self.draw_south(to, x, y2.saturating_sub(1), style);
|
||||
to.blit(&Self::N, x, y, style);
|
||||
to.blit(&Self::S, x, y2.saturating_sub(1), style)
|
||||
}
|
||||
Ok(area)
|
||||
}
|
||||
#[inline] fn draw_north (
|
||||
&self, to: &mut TuiOutput, x: u16, y: u16, style: Option<Style>
|
||||
) -> () {
|
||||
to.blit(&Self::N, x, y, style)
|
||||
}
|
||||
#[inline] fn draw_south (
|
||||
&self, to: &mut TuiOutput, x: u16, y: u16, style: Option<Style>
|
||||
) -> () {
|
||||
to.blit(&Self::S, x, y, style)
|
||||
}
|
||||
#[inline] fn draw_vertical (
|
||||
&self, to: &mut TuiOutput, style: Option<Style>
|
||||
) -> Usually<[u16;4]> {
|
||||
let area = to.area();
|
||||
let style = style.or_else(||self.style_vertical());
|
||||
let [x, x2, y, y2] = area.lrtb();
|
||||
for y in y..y2.saturating_sub(1) {
|
||||
to.blit(&Self::W, x, y, style);
|
||||
to.blit(&Self::E, x2.saturating_sub(1), y, style);
|
||||
let h = y2 - y;
|
||||
if h > 1 {
|
||||
for y in y..y2.saturating_sub(1) {
|
||||
to.blit(&Self::W, x, y, style);
|
||||
to.blit(&Self::E, x2.saturating_sub(1), y, style);
|
||||
}
|
||||
} else if h > 0 {
|
||||
to.blit(&Self::W0, x, y, style);
|
||||
to.blit(&Self::E0, x2.saturating_sub(1), y, style);
|
||||
}
|
||||
Ok(area)
|
||||
}
|
||||
|
|
@ -100,7 +102,7 @@ pub trait BorderStyle: Send + Sync + Copy {
|
|||
let area = to.area();
|
||||
let style = style.or_else(||self.style_corners());
|
||||
let [x, y, width, height] = area.xywh();
|
||||
if width > 0 && height > 0 {
|
||||
if width > 1 && height > 1 {
|
||||
to.blit(&Self::NW, x, y, style);
|
||||
to.blit(&Self::NE, x + width - 1, y, style);
|
||||
to.blit(&Self::SW, x, y + height - 1, style);
|
||||
|
|
@ -198,7 +200,12 @@ border! {
|
|||
Brackets {
|
||||
"⎡" "" "⎤"
|
||||
"" ""
|
||||
"⎣" "" "⎦" fn style (&self) -> Option<Style> { Some(self.0) }
|
||||
"⎣" "" "⎦"
|
||||
const W0: &'static str = "[";
|
||||
const E0: &'static str = "]";
|
||||
const N0: &'static str = "⎴";
|
||||
const S0: &'static str = "⎵";
|
||||
fn style (&self) -> Option<Style> { Some(self.0) }
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue