fix(chrono,timer): state text position
This commit is contained in:
@@ -195,13 +195,10 @@ fn render_frame(
|
||||
// Display pause state
|
||||
if chronometer.is_paused() {
|
||||
let text = "[PAUSE]";
|
||||
let x = width / 2 - (text.len() as i16) / 2;
|
||||
rendering::draw_text(
|
||||
text,
|
||||
x,
|
||||
y - symbols::SYMBOL_HEIGHT as i16 - symbols::SYMBOL_HEIGHT as i16 / 2,
|
||||
color,
|
||||
)?;
|
||||
let x = width / 2 - (text.len() as i16) / 2 - 1;
|
||||
let y = y - symbols::SYMBOL_HEIGHT as i16 + symbols::SYMBOL_HEIGHT as i16 / 2 + 1;
|
||||
|
||||
rendering::draw_text(text, x, y, color)?;
|
||||
}
|
||||
|
||||
return Ok(());
|
||||
|
||||
@@ -126,31 +126,24 @@ fn render_frame(config: &Config, timer: &Timer) -> io::Result<()> {
|
||||
let remaining = utils::format_duration(timer.time_left());
|
||||
rendering::draw_time(&remaining, color)?;
|
||||
|
||||
// Display pause state
|
||||
let (width, height) = rendering::get_terminal_size()?;
|
||||
let y = height / 2 + symbols::SYMBOL_HEIGHT as i16 / 2 + 2;
|
||||
if timer.is_paused() {
|
||||
let text = "[PAUSE]";
|
||||
let x = width / 2 - (text.len() as i16) / 2;
|
||||
|
||||
rendering::draw_text(
|
||||
text,
|
||||
x,
|
||||
y - symbols::SYMBOL_HEIGHT as i16 - symbols::SYMBOL_HEIGHT as i16 / 2,
|
||||
color,
|
||||
)?;
|
||||
}
|
||||
// Display finish state
|
||||
else if timer.is_finished() {
|
||||
if timer.is_finished() {
|
||||
let text = "[FINISHED]";
|
||||
let x = width / 2 - (text.len() as i16) / 2;
|
||||
let x = width / 2 - (text.len() as i16) / 2 - 1;
|
||||
let y = y - symbols::SYMBOL_HEIGHT as i16 + symbols::SYMBOL_HEIGHT as i16 / 2 + 1;
|
||||
|
||||
rendering::draw_text(
|
||||
text,
|
||||
x,
|
||||
y - symbols::SYMBOL_HEIGHT as i16 - symbols::SYMBOL_HEIGHT as i16 / 2,
|
||||
color,
|
||||
)?;
|
||||
rendering::draw_text(text, x, y, color)?;
|
||||
}
|
||||
// Display pause state
|
||||
else if timer.is_paused() {
|
||||
let text = "[PAUSE]";
|
||||
let x = width / 2 - (text.len() as i16) / 2 - 1;
|
||||
let y = y - symbols::SYMBOL_HEIGHT as i16 + symbols::SYMBOL_HEIGHT as i16 / 2 + 1;
|
||||
|
||||
rendering::draw_text(text, x, y, color)?;
|
||||
}
|
||||
|
||||
return Ok(());
|
||||
|
||||
Reference in New Issue
Block a user