-
Notifications
You must be signed in to change notification settings - Fork 700
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
Fix "Border.ForgroundColor" typo #2515
Conversation
You know, I kind of feel like this should be using an Attribute instead of separate fields for Foreground and Background. |
No, because theses colors is normally used alone to provide the same color for foreground and background, by calling |
To provide some more context on why we typically use
Hopefully that clarifies things? Thanks for this fix :) |
The current v1 What I'd like to ask @Nutzzz instead is: Given the new My current idea is to keep it really simple for most use cases: var view = new View () { BorderStyle = BorderStyle.Single }; The implementation: /// <summary>
/// Gets or sets whether the view has a one row/col thick border.
/// </summary>
/// <remarks>
/// <para>
/// This is a helper for manipulating the view's <see cref="BorderFrame"/>. Setting this property to any value other than
/// <see cref="BorderStyle.None"/> is equivalent to setting <see cref="BorderFrame"/>'s <see cref="Frame.Thickness"/>
/// to `1` and <see cref="BorderStyle"/> to the value.
/// </para>
/// <para>
/// Setting this property to <see cref="BorderStyle.None"/> is equivalent to setting <see cref="BorderFrame"/>'s <see cref="Frame.Thickness"/>
/// to `0` and <see cref="BorderStyle"/> to <see cref="BorderStyle.None"/>.
/// </para>
/// <para>
/// For more advanced customization of the view's border, manipulate see <see cref="BorderFrame"/> directly.
/// </para>
/// </remarks>
public BorderStyle BorderStyle {
get {
return BorderFrame?.BorderStyle ?? BorderStyle.None;
}
set {
if (BorderFrame == null) {
throw new InvalidOperationException ("BorderFrame is null; this is likely a bug.");
}
if (value != BorderStyle.None) {
BorderFrame.Thickness = new Thickness (1);
} else {
BorderFrame.Thickness = new Thickness (0);
}
BorderFrame.BorderStyle = value;
LayoutFrames ();
}
}
var view = new View () { BorderStyle = BorderStyle.Single };
view.BorderFrame.ColorScheme = Colors.ColorScheme ["Error"];
// or, if custom colors are wanted (not recommended):
view.BorderFrame.ColorScheme = new ColorScheme() {
Normal = new Terminal.Gui.Attribute(Color.Red, Color.White),
HotNormal = new Terminal.Gui.Attribute (Color.Magenta, Color.White),
Disabled = new Terminal.Gui.Attribute (Color.Gray, Color.White),
Focus = new Terminal.Gui.Attribute (Color.Blue, Color.White),
HotFocus = new Terminal.Gui.Attribute (Color.BrightBlue, Color.White),
}; What do you think? |
That looks fine... Would applying custom colors/styles to the superview's BorderFrames be inherited by child BorderFrames? Is there an easy way to change the color of the border title independent of the frame? |
Can you explain the use case for each of these? |
My vision is When v2 is done, the actual rendering of the border and title will be done by subviews of So, yes. |
Sure. Inheritance here would be to easily maintain a consistent look-and-feel. It's certainly easy enough to create the style once and apply every time you create a child, but ColorSchemes are inherited, and it's the same idea there. I also have the planned title styling in mind here. It is slightly more complicated for BorderFrames since we don't want to show a border by default for every kind of view. Changing the color of the title so it's not the same as the border lines could be a stylistic choice, or a way to draw attention to a change or an error, or to which window/pane/group etc. is focused. |
Pull Request checklist:
CTRL-K-D
to automatically reformat your files before committing.dotnet test
before commit///
style comments)