Impl hiding drawn text with "H" key
This commit is contained in:
parent
78c18afe5e
commit
ca714f6de2
1 changed files with 128 additions and 124 deletions
14
src/main.rs
14
src/main.rs
|
@ -10,6 +10,7 @@ use std::thread;
|
||||||
use std::time::{Duration, Instant};
|
use std::time::{Duration, Instant};
|
||||||
use structopt::StructOpt;
|
use structopt::StructOpt;
|
||||||
|
|
||||||
|
const BUF_SIZE: usize = 1024 * 4;
|
||||||
const POLL_DURATION: Duration = Duration::from_secs(2);
|
const POLL_DURATION: Duration = Duration::from_secs(2);
|
||||||
const TEXT_X_OFFSET: f32 = 16.0f32;
|
const TEXT_X_OFFSET: f32 = 16.0f32;
|
||||||
const TEXT_Y_OFFSET: f32 = 16.0f32;
|
const TEXT_Y_OFFSET: f32 = 16.0f32;
|
||||||
|
@ -267,7 +268,7 @@ fn read_line(
|
||||||
//}
|
//}
|
||||||
|
|
||||||
fn info_loop(shared_data: Arc<Mutex<Shared>>) -> Result<(), String> {
|
fn info_loop(shared_data: Arc<Mutex<Shared>>) -> Result<(), String> {
|
||||||
let mut buf: [u8; 4192] = [0; 4192];
|
let mut buf: [u8; BUF_SIZE] = [0; BUF_SIZE];
|
||||||
let mut init: bool = true;
|
let mut init: bool = true;
|
||||||
let mut saved: Vec<u8> = Vec::new();
|
let mut saved: Vec<u8> = Vec::new();
|
||||||
let mut saved_str: String = String::new();
|
let mut saved_str: String = String::new();
|
||||||
|
@ -292,8 +293,7 @@ fn info_loop(shared_data: Arc<Mutex<Shared>>) -> Result<(), String> {
|
||||||
if let Ok(mut lock) = lock_result {
|
if let Ok(mut lock) = lock_result {
|
||||||
let read_result = lock.stream.read(&mut buf);
|
let read_result = lock.stream.read(&mut buf);
|
||||||
if let Ok(count) = read_result {
|
if let Ok(count) = read_result {
|
||||||
let mut read_vec: Vec<u8> = Vec::from(buf);
|
let mut read_vec: Vec<u8> = Vec::from(&buf[0..count]);
|
||||||
read_vec.resize(count, 0);
|
|
||||||
loop {
|
loop {
|
||||||
let mut count = read_vec.len();
|
let mut count = read_vec.len();
|
||||||
if current_binary_size > 0 {
|
if current_binary_size > 0 {
|
||||||
|
@ -784,6 +784,7 @@ async fn main() -> Result<(), String> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if !is_key_down(KeyCode::H) {
|
||||||
temp_offset_y = 0.0;
|
temp_offset_y = 0.0;
|
||||||
if !filename.is_empty() && !opt.disable_show_filename {
|
if !filename.is_empty() && !opt.disable_show_filename {
|
||||||
if filename_font_size.is_none() {
|
if filename_font_size.is_none() {
|
||||||
|
@ -840,7 +841,8 @@ async fn main() -> Result<(), String> {
|
||||||
title_font_size -= 4;
|
title_font_size -= 4;
|
||||||
if title_font_size < 4 {
|
if title_font_size < 4 {
|
||||||
title_font_size = 4;
|
title_font_size = 4;
|
||||||
title_dim_opt = Some(measure_text(&title, None, title_font_size, 1.0f32));
|
title_dim_opt =
|
||||||
|
Some(measure_text(&title, None, title_font_size, 1.0f32));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -857,7 +859,8 @@ async fn main() -> Result<(), String> {
|
||||||
artist_font_size = ARTIST_INITIAL_FONT_SIZE;
|
artist_font_size = ARTIST_INITIAL_FONT_SIZE;
|
||||||
}
|
}
|
||||||
loop {
|
loop {
|
||||||
artist_dim_opt = Some(measure_text(&artist, None, artist_font_size, 1.0f32));
|
artist_dim_opt =
|
||||||
|
Some(measure_text(&artist, None, artist_font_size, 1.0f32));
|
||||||
if artist_dim_opt.as_ref().unwrap().width + TEXT_X_OFFSET > prev_width {
|
if artist_dim_opt.as_ref().unwrap().width + TEXT_X_OFFSET > prev_width {
|
||||||
artist_font_size -= 4;
|
artist_font_size -= 4;
|
||||||
if artist_font_size < 4 {
|
if artist_font_size < 4 {
|
||||||
|
@ -935,6 +938,7 @@ async fn main() -> Result<(), String> {
|
||||||
if !error_text.is_empty() {
|
if !error_text.is_empty() {
|
||||||
draw_text(&error_text, 0.0, 32.0f32, 32.0f32, WHITE);
|
draw_text(&error_text, 0.0, 32.0f32, 32.0f32, WHITE);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
next_frame().await
|
next_frame().await
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue