From f485079404b8dd65906c339c5d24b95dda4fe757 Mon Sep 17 00:00:00 2001 From: Manos Pitsidianakis Date: Thu, 3 Oct 2019 14:38:58 +0300 Subject: [PATCH] ui: align buttons in Selector Correct alignment of Ok, Cancel buttons --- ui/src/components/utilities.rs | 35 +++++++++++++++++++++++++++------- 1 file changed, 28 insertions(+), 7 deletions(-) diff --git a/ui/src/components/utilities.rs b/ui/src/components/utilities.rs index 7204d1e3c..9c744fb16 100644 --- a/ui/src/components/utilities.rs +++ b/ui/src/components/utilities.rs @@ -1698,7 +1698,10 @@ impl Component for Selector { | (UIEvent::Input(Key::Up), SelectorCursor::Cancel) => { change_colors( &mut self.content, - ((width / 2, height - 2), (width - 1, height - 2)), + ( + ((width - "OK Cancel".len()) / 2, height - 3), + (width - 1, height - 3), + ), Color::Default, Color::Default, ); @@ -1761,7 +1764,10 @@ impl Component for Selector { ); change_colors( &mut self.content, - ((width / 2, height - 2), (width / 2 + 1, height - 2)), + ( + ((width - "OK Cancel".len()) / 2, height - 3), + ((width - "OK Cancel".len()) / 2 + 1, height - 3), + ), Color::Default, Color::Byte(8), ); @@ -1773,13 +1779,19 @@ impl Component for Selector { self.cursor = SelectorCursor::Cancel; change_colors( &mut self.content, - ((width / 2, height - 2), (width / 2 + 1, height - 2)), + ( + ((width - "OK Cancel".len()) / 2, height - 3), + ((width - "OK Cancel".len()) / 2 + 1, height - 3), + ), Color::Default, Color::Default, ); change_colors( &mut self.content, - ((width / 2 + 6, height - 2), (width / 2 + 11, height - 2)), + ( + ((width - "OK Cancel".len()) / 2 + 6, height - 3), + ((width - "OK Cancel".len()) / 2 + 11, height - 3), + ), Color::Default, Color::Byte(8), ); @@ -1790,13 +1802,19 @@ impl Component for Selector { self.cursor = SelectorCursor::Ok; change_colors( &mut self.content, - ((width / 2, height - 2), (width / 2 + 1, height - 2)), + ( + ((width - "OK Cancel".len()) / 2, height - 3), + ((width - "OK Cancel".len()) / 2 + 1, height - 3), + ), Color::Default, Color::Byte(8), ); change_colors( &mut self.content, - ((width / 2 + 6, height - 2), (width / 2 + 11, height - 2)), + ( + ((width - "OK Cancel".len()) / 2 + 6, height - 3), + ((width - "OK Cancel".len()) / 2 + 11, height - 3), + ), Color::Default, Color::Default, ); @@ -1970,7 +1988,10 @@ impl Selector { Color::Default, Color::Default, Attr::Bold, - ((width / 2, height - 2), (width - 1, height - 2)), + ( + ((width - "OK Cancel".len()) / 2, height - 3), + (width - 1, height - 3), + ), false, ); }