simplified offset calculation in dialogboxtitle

This commit is contained in:
Marcel Hellwig 2017-12-12 09:07:13 +01:00
parent 592ecf4c09
commit f8e7427f75

View File

@ -362,11 +362,8 @@ impl Dialog {
if len + 4 > printer.size.x { if len + 4 > printer.size.x {
return; return;
} }
let x = match self.title_position { let spacing = 3; //minimum distance to borders
HAlign::Left => 3, let x = spacing + self.title_position.get_offset(len, printer.size.x - 2 * spacing);
HAlign::Center => (printer.size.x - len) / 2,
HAlign::Right => printer.size.x - len - 3,
};
printer.with_high_border(false, |printer| { printer.with_high_border(false, |printer| {
printer.print((x - 2, 0), ""); printer.print((x - 2, 0), "");
printer.print((x + len, 0), ""); printer.print((x + len, 0), "");