Merge pull request #321 from chrisvest/panel-title-space

Reduce the title drawing cut-off point by 2 characters.
This commit is contained in:
Alexandre Bury 2019-03-03 10:40:44 -08:00 committed by GitHub
commit 786ad83413
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
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), "");