From f8e7427f75ffb4b8a33b823408284b9989f9554f Mon Sep 17 00:00:00 2001 From: Marcel Hellwig Date: Tue, 12 Dec 2017 09:07:13 +0100 Subject: [PATCH] simplified offset calculation in dialogboxtitle --- src/views/dialog.rs | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/src/views/dialog.rs b/src/views/dialog.rs index 6d470c2..26adf22 100644 --- a/src/views/dialog.rs +++ b/src/views/dialog.rs @@ -362,11 +362,8 @@ impl Dialog { if len + 4 > printer.size.x { return; } - let x = match self.title_position { - HAlign::Left => 3, - HAlign::Center => (printer.size.x - len) / 2, - HAlign::Right => printer.size.x - len - 3, - }; + let spacing = 3; //minimum distance to borders + let x = spacing + self.title_position.get_offset(len, printer.size.x - 2 * spacing); printer.with_high_border(false, |printer| { printer.print((x - 2, 0), "┤ "); printer.print((x + len, 0), " ├");