From 08801367ba55b1b6fe64fe3df5ab4285181e81e8 Mon Sep 17 00:00:00 2001 From: CrispyPin Date: Sun, 6 Oct 2024 20:39:46 +0200 Subject: [PATCH] re-style text input --- src/util.rs | 27 +++++++++++++-------------- 1 file changed, 13 insertions(+), 14 deletions(-) diff --git a/src/util.rs b/src/util.rs index b21f229..5cd412a 100644 --- a/src/util.rs +++ b/src/util.rs @@ -92,13 +92,21 @@ pub fn text_input( is_selected: &mut bool, ) -> bool { let mut changed = false; - let (bg, border) = if *is_selected { + let (bg, underline) = if *is_selected { (Color::DARKCYAN, Color::CYAN) } else { (Color::GRAY, Color::DIMGRAY) }; - d.draw_rectangle_rec(bounds, border); - d.draw_rectangle_rec(shrink_rec(bounds, 2.), bg); + d.draw_rectangle_rec(bounds, bg); + d.draw_rectangle_rec( + Rectangle::new( + bounds.x + 2., + bounds.y + bounds.height - 5., + bounds.width - 4., + 3., + ), + underline, + ); let drawn_text = if *is_selected { &format!("{text}_") } else { @@ -180,15 +188,6 @@ pub fn texture_option_button( } } -pub fn shrink_rec(rec: Rectangle, a: f32) -> Rectangle { - Rectangle { - x: rec.x + a, - y: rec.y + a, - width: rec.width - a * 2., - height: rec.height - a * 2., - } -} - -pub fn userdata_dir()->PathBuf{ +pub fn userdata_dir() -> PathBuf { PathBuf::from("user") -} \ No newline at end of file +}