-
Notifications
You must be signed in to change notification settings - Fork 696
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Centering window label #2541
Comments
In v1 there is no option for that. But in the v2 will have. |
See #2505 Closing. |
@josefreichelt while this feature is appearing in v2 you can still achieve a similar thing in v1 with some manual drawing. See the code I had for this in the FileDialog. Something similar will ultimately mainfest in v2 so you can just remove it later on when you upgrade. This code gives something like: public override void Redraw (Rect bounds)
{
base.Redraw (bounds);
this.Move (1, 0, false);
// TODO: Refactor this to some Title drawing options class
if (ustring.IsNullOrEmpty (Title)) {
return;
}
var title = this.Title.ToString ();
var titleWidth = title.Sum (c => Rune.ColumnWidth (c));
if (titleWidth > bounds.Width) {
title = title.Substring (0, bounds.Width);
} else {
if (titleWidth + 2 < bounds.Width) {
title = '╡' + this.Title.ToString () + '╞';
}
titleWidth += 2;
}
var padLeft = ((bounds.Width - titleWidth) / 2) - 1;
padLeft = Math.Min (bounds.Width, padLeft);
padLeft = Math.Max (0, padLeft);
var padRight = bounds.Width - (padLeft + titleWidth + 2);
padRight = Math.Min (bounds.Width, padRight);
padRight = Math.Max (0, padRight);
Driver.SetAttribute (
new Attribute (this.ColorScheme.Normal.Foreground, this.ColorScheme.Normal.Background));
Driver.AddStr (ustring.Make (Enumerable.Repeat (Driver.HDLine, padLeft)));
Driver.SetAttribute (
new Attribute (this.ColorScheme.Normal.Foreground, this.ColorScheme.Normal.Background));
Driver.AddStr (title);
Driver.SetAttribute (
new Attribute (this.ColorScheme.Normal.Foreground, this.ColorScheme.Normal.Background));
Driver.AddStr (ustring.Make (Enumerable.Repeat (Driver.HDLine, padRight)));
} |
Ah I see, thank you very much for the response |
There doesnt seem to be a way to center the window title label.
Using v1
I'd expect TextAlignment to affect it, but it doesnt.
Is there a way to do this?
The text was updated successfully, but these errors were encountered: