Reduce the title drawing cut-off point by 2 characters.

Panels and dialogs have borders with corners.
Previously, the title would draw over the border corner, including its own end-points.
Now the cut-off point is such that we do not draw the title if the right-hand end point and the border-corner do not also fit.
This commit is contained in:
Chris Vest 2019-03-03 10:37:50 +01:00
parent 40adcffbf5
commit 7564a5d1db
2 changed files with 8 additions and 6 deletions

View File

@ -461,14 +461,15 @@ impl Dialog {
fn draw_title(&self, printer: &Printer<'_, '_>) {
if !self.title.is_empty() {
let len = self.title.width();
if len + 4 > printer.size.x {
let spacing = 3; //minimum distance to borders
let spacing_both_ends = 2 * spacing;
if len + spacing_both_ends > printer.size.x {
return;
}
let spacing = 3; //minimum distance to borders
let x = spacing
+ self
.title_position
.get_offset(len, printer.size.x - 2 * spacing);
.get_offset(len, printer.size.x - spacing_both_ends);
printer.with_high_border(false, |printer| {
printer.print((x - 2, 0), "");
printer.print((x + len, 0), "");

View File

@ -65,14 +65,15 @@ impl<V: View> Panel<V> {
fn draw_title(&self, printer: &Printer<'_, '_>) {
if !self.title.is_empty() {
let len = self.title.width();
if len + 4 > printer.size.x {
let spacing = 3; //minimum distance to borders
let spacing_both_ends = 2 * spacing;
if len + spacing_both_ends > printer.size.x {
return;
}
let spacing = 3; //minimum distance to borders
let x = spacing
+ self
.title_position
.get_offset(len, printer.size.x - 2 * spacing);
.get_offset(len, printer.size.x - spacing_both_ends);
printer.with_high_border(false, |printer| {
printer.print((x - 2, 0), "");
printer.print((x + len, 0), "");