mirror of
https://github.com/gui-cs/Terminal.Gui.git
synced 2025-12-30 17:57:57 +01:00
* Fixes #2571. Wizards background shifts to gray when focusing, looks bad. * Fix margin being negative on Pos.AnchorEnd. * Fix background color in tab views. * All tabs need to be manually disposed.
This commit is contained in:
@@ -22,11 +22,13 @@ namespace Terminal.Gui {
|
||||
/// </summary>
|
||||
TabRowView tabsBar;
|
||||
|
||||
private class TabContentView : View { }
|
||||
|
||||
/// <summary>
|
||||
/// This sub view is the main client area of the current tab. It hosts the <see cref="Tab.View"/>
|
||||
/// of the tab, the <see cref="SelectedTab"/>
|
||||
/// </summary>
|
||||
View contentView;
|
||||
TabContentView contentView;
|
||||
private List<Tab> tabs = new List<Tab> ();
|
||||
|
||||
/// <summary>
|
||||
@@ -75,7 +77,13 @@ namespace Terminal.Gui {
|
||||
|
||||
if (selectedTab.View != null) {
|
||||
// remove old content
|
||||
contentView.Remove (selectedTab.View);
|
||||
if (selectedTab.View.Subviews.Count == 0) {
|
||||
contentView.Remove (selectedTab.View);
|
||||
} else {
|
||||
foreach (var view in selectedTab.View.Subviews) {
|
||||
contentView.Remove (view);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -85,7 +93,13 @@ namespace Terminal.Gui {
|
||||
|
||||
// add new content
|
||||
if (selectedTab.View != null) {
|
||||
contentView.Add (selectedTab.View);
|
||||
if (selectedTab.View.Subviews.Count == 0) {
|
||||
contentView.Add (selectedTab.View);
|
||||
} else {
|
||||
foreach (var view in selectedTab.View.Subviews) {
|
||||
contentView.Add (view);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -94,7 +108,6 @@ namespace Terminal.Gui {
|
||||
if (old != value) {
|
||||
OnSelectedTabChanged (old, value);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -111,7 +124,7 @@ namespace Terminal.Gui {
|
||||
public TabView () : base ()
|
||||
{
|
||||
CanFocus = true;
|
||||
contentView = new View ();
|
||||
contentView = new TabContentView ();
|
||||
tabsBar = new TabRowView (this);
|
||||
|
||||
ApplyStyleChanges ();
|
||||
@@ -195,7 +208,7 @@ namespace Terminal.Gui {
|
||||
int startAtY = Math.Max (0, GetTabHeight (true) - 1);
|
||||
|
||||
DrawFrame (new Rect (0, startAtY, bounds.Width,
|
||||
Math.Max (bounds.Height - spaceAtBottom - startAtY, 0)), 0, true);
|
||||
Math.Max (bounds.Height - spaceAtBottom - startAtY, 0)), 0, true);
|
||||
}
|
||||
|
||||
if (Tabs.Any ()) {
|
||||
@@ -215,14 +228,9 @@ namespace Terminal.Gui {
|
||||
{
|
||||
base.Dispose (disposing);
|
||||
|
||||
// The selected tab will automatically be disposed but
|
||||
// any tabs not visible will need to be manually disposed
|
||||
|
||||
// Manually dispose all tabs
|
||||
foreach (var tab in Tabs) {
|
||||
if (!Equals (SelectedTab, tab)) {
|
||||
tab.View?.Dispose ();
|
||||
}
|
||||
|
||||
tab.View?.Dispose ();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -187,7 +187,7 @@ namespace Terminal.Gui {
|
||||
if (i == 0) {
|
||||
// first (leftmost) button - always hard flush left
|
||||
var left = Bounds.Width - ((Border.DrawMarginFrame ? 2 : 0) + Border.BorderThickness.Left + Border.BorderThickness.Right);
|
||||
button.X = Pos.AnchorEnd (left);
|
||||
button.X = Pos.AnchorEnd (Math.Max (left, 0));
|
||||
} else {
|
||||
shiftLeft += button.Frame.Width + (spacing);
|
||||
button.X = Pos.AnchorEnd (shiftLeft);
|
||||
|
||||
@@ -158,8 +158,14 @@ namespace Terminal.Gui {
|
||||
/// </summary>
|
||||
public event Action<TitleEventArgs> TitleChanged;
|
||||
|
||||
// The contentView works like the ContentView in FrameView.
|
||||
private View contentView = new View () { Data = "WizardContentView" };
|
||||
/// <summary>
|
||||
/// WizardContentView is an internal implementation detail of Window. It is used to host Views added with <see cref="Add(View)"/>.
|
||||
/// Its ONLY reason for being is to provide a simple way for Window to expose to those SubViews that the Window's Bounds
|
||||
/// are actually deflated due to the border.
|
||||
/// </summary>
|
||||
class WizardContentView : View { }
|
||||
|
||||
private WizardContentView contentView = new WizardContentView ();
|
||||
|
||||
/// <summary>
|
||||
/// Sets or gets help text for the <see cref="WizardStep"/>.If <see cref="WizardStep.HelpText"/> is empty
|
||||
@@ -383,6 +389,7 @@ namespace Terminal.Gui {
|
||||
AddKeyBinding (Key.Esc, Command.QuitToplevel);
|
||||
}
|
||||
|
||||
Initialized += (s, e) => Wizard_Loaded ();
|
||||
}
|
||||
|
||||
private void Wizard_Loaded ()
|
||||
|
||||
Reference in New Issue
Block a user