mirror of
https://codeberg.org/unspeaker/tek.git
synced 2025-12-06 19:56:42 +01:00
fix: reset display size on render
This commit is contained in:
parent
eb122585d6
commit
4320e6f6b4
4 changed files with 12 additions and 20 deletions
|
|
@ -104,6 +104,7 @@ impl Tui {
|
|||
if engine.exited() {
|
||||
break
|
||||
}
|
||||
engine.area = engine.backend.size().expect("get size failed");
|
||||
state.render(&mut engine).expect("render failed");
|
||||
engine.flip();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -21,7 +21,6 @@ pub trait BorderStyle {
|
|||
#[inline]
|
||||
fn draw_horizontal (&self, to: &mut Tui, style: Option<Style>) -> Usually<Rect> {
|
||||
let area = to.area();
|
||||
let buf = to.buffer();
|
||||
let style = style.or_else(||self.style_horizontal());
|
||||
for x in area.x..(area.x+area.width).saturating_sub(1) {
|
||||
self.draw_north(to, x, area.y, style)?;
|
||||
|
|
|
|||
|
|
@ -51,29 +51,22 @@ impl<'a> Render<Tui> for Split<'a, Tui> {
|
|||
|
||||
impl<'a> Split<'a, Tui> {
|
||||
pub fn render_areas (&self, to: &mut Tui) -> Usually<(Rect, Vec<Rect>)> {
|
||||
//Ok((Rect::default(), vec![]))
|
||||
let Rect { mut x, mut y, mut width, mut height } = to.area();
|
||||
let mut areas = vec![];
|
||||
for (index, item) in self.items.0.iter().enumerate() {
|
||||
if width == 0 || height == 0 {
|
||||
break
|
||||
}
|
||||
if let Some(result) = item.render(to.with_area(x, y, width, height))? {
|
||||
match self.direction {
|
||||
Direction::Down => {
|
||||
y += result.height;
|
||||
height = height.saturating_sub(result.height);
|
||||
},
|
||||
Direction::Right => {
|
||||
x += result.width;
|
||||
width = width.saturating_sub(result.width);
|
||||
},
|
||||
_ => unimplemented!()
|
||||
};
|
||||
areas.push(result);
|
||||
if self.focus == Some(index) {
|
||||
Corners(Style::default().green().not_dim()).draw(to.with_rect(result))?;
|
||||
}
|
||||
let result = item.render(to.with_area(x, y, width, height))?.unwrap_or(Rect::default());
|
||||
let Rect { width: w, height: h, .. } = result;
|
||||
match self.direction {
|
||||
Direction::Down => { y += h; height = height.saturating_sub(h); },
|
||||
Direction::Right => { x += w; width = width.saturating_sub(w); },
|
||||
_ => unimplemented!()
|
||||
};
|
||||
areas.push(result);
|
||||
if self.focus == Some(index) {
|
||||
Corners(Style::default().green().not_dim()).draw(to.with_rect(result))?;
|
||||
}
|
||||
}
|
||||
Ok((to.area, areas))
|
||||
|
|
|
|||
|
|
@ -1,8 +1,7 @@
|
|||
/// Phrase editor.
|
||||
|
||||
pub(crate) use tek_core::*;
|
||||
pub(crate) use tek_core::ratatui::prelude::*;
|
||||
pub(crate) use tek_core::crossterm::event::{KeyCode, KeyModifiers};
|
||||
pub(crate) use tek_core::crossterm::event::KeyCode;
|
||||
pub(crate) use tek_core::midly::{num::u7, live::LiveEvent, MidiMessage};
|
||||
pub(crate) use tek_core::jack::*;
|
||||
pub(crate) use std::sync::{Arc, RwLock};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue