Merge pull request #40 from BDisp/tig_v2_2491-Arrangement-Overlapped-fix

Remove ClearOnVisibleFalse property.
This commit is contained in:
Tig
2024-08-28 12:38:25 -07:00
committed by GitHub
5 changed files with 53 additions and 53 deletions

View File

@@ -202,11 +202,6 @@ public partial class View // Drawing APIs
/// </remarks>
public void Draw ()
{
if (!CanBeVisible (this))
{
return;
}
OnDrawAdornments ();
if (ColorScheme is { })
@@ -477,6 +472,11 @@ public partial class View // Drawing APIs
Clear ();
}
if (!CanBeVisible (this))
{
return;
}
if (!string.IsNullOrEmpty (TextFormatter.Text))
{
if (TextFormatter is { })

View File

@@ -373,10 +373,6 @@ public partial class View : Responder, ISupportInitializeNotification
{
HasFocus = false;
}
if (IsInitialized && ClearOnVisibleFalse)
{
Clear ();
}
}
if (_visible && CanFocus && Enabled && !HasFocus
@@ -393,9 +389,6 @@ public partial class View : Responder, ISupportInitializeNotification
/// <summary>Method invoked when the <see cref="Visible"/> property from a view is changed.</summary>
public virtual void OnVisibleChanged () { VisibleChanged?.Invoke (this, EventArgs.Empty); }
/// <summary>Gets or sets whether a view is cleared if the <see cref="Visible"/> property is <see langword="false"/>.</summary>
public bool ClearOnVisibleFalse { get; set; } = true;
/// <summary>Event fired when the <see cref="Visible"/> value is being changed.</summary>
public event EventHandler? VisibleChanged;

View File

@@ -38,7 +38,6 @@ public class ScrollBarView : View
public ScrollBarView ()
{
WantContinuousButtonPressed = true;
ClearOnVisibleFalse = false;
Added += (s, e) => CreateBottomRightCorner (e.Parent);
Initialized += ScrollBarView_Initialized;
@@ -103,7 +102,6 @@ public class ScrollBarView : View
ShowScrollIndicator = true;
CreateBottomRightCorner (Host);
ClearOnVisibleFalse = false;
}
/// <summary>If true the vertical/horizontal scroll bars won't be showed if it's not needed.</summary>
@@ -216,7 +214,7 @@ public class ScrollBarView : View
/// <value><c>true</c> if show vertical or horizontal scroll indicator; otherwise, <c>false</c>.</value>
public bool ShowScrollIndicator
{
get => _showScrollIndicator;
get => _showScrollIndicator && Visible;
set
{
//if (value == showScrollIndicator) {
@@ -266,7 +264,7 @@ public class ScrollBarView : View
}
}
private bool _showBothScrollIndicator => OtherScrollBarView?._showScrollIndicator == true && _showScrollIndicator;
private bool _showBothScrollIndicator => OtherScrollBarView?.ShowScrollIndicator == true && ShowScrollIndicator;
/// <summary>This event is raised when the position on the scrollbar has changed.</summary>
public event EventHandler ChangedPosition;
@@ -316,7 +314,7 @@ public class ScrollBarView : View
return true;
}
if (_showScrollIndicator
if (ShowScrollIndicator
&& (mouseEvent.Flags == MouseFlags.WheeledDown
|| mouseEvent.Flags == MouseFlags.WheeledUp
|| mouseEvent.Flags == MouseFlags.WheeledRight
@@ -448,9 +446,9 @@ public class ScrollBarView : View
/// <inheritdoc/>
public override void OnDrawContent (Rectangle viewport)
{
if (ColorScheme is null || ((!_showScrollIndicator || Size == 0) && AutoHideScrollBars && Visible))
if (ColorScheme is null || ((!ShowScrollIndicator || Size == 0) && AutoHideScrollBars && Visible))
{
if ((!_showScrollIndicator || Size == 0) && AutoHideScrollBars && Visible)
if ((!ShowScrollIndicator || Size == 0) && AutoHideScrollBars && Visible)
{
ShowHideScrollBars (false);
}
@@ -696,7 +694,7 @@ public class ScrollBarView : View
if (barsize == 0 || barsize >= scrollBarView._size)
{
if (scrollBarView._showScrollIndicator)
if (scrollBarView.ShowScrollIndicator)
{
scrollBarView.ShowScrollIndicator = false;
}
@@ -708,7 +706,7 @@ public class ScrollBarView : View
}
else if (barsize > 0 && barsize == scrollBarView._size && scrollBarView.OtherScrollBarView is { } && pending)
{
if (scrollBarView._showScrollIndicator)
if (scrollBarView.ShowScrollIndicator)
{
scrollBarView.ShowScrollIndicator = false;
}
@@ -747,7 +745,7 @@ public class ScrollBarView : View
}
}
if (!scrollBarView._showScrollIndicator)
if (!scrollBarView.ShowScrollIndicator)
{
scrollBarView.ShowScrollIndicator = true;
}
@@ -953,13 +951,13 @@ public class ScrollBarView : View
? Host != SuperView ? Dim.Height (Host) - 1 : Dim.Fill () - 1
: 1;
}
else if (_showScrollIndicator)
else if (ShowScrollIndicator)
{
Width = _vertical ? 1 :
Host != SuperView ? Dim.Width (Host) : Dim.Fill ();
Height = _vertical ? Host != SuperView ? Dim.Height (Host) : Dim.Fill () : 1;
}
else if (_otherScrollBarView?._showScrollIndicator == true)
else if (_otherScrollBarView?.ShowScrollIndicator == true)
{
_otherScrollBarView.Width = _otherScrollBarView._vertical ? 1 :
Host != SuperView ? Dim.Width (Host) : Dim.Fill () - 0;
@@ -1014,7 +1012,7 @@ public class ScrollBarView : View
_otherScrollBarView._contentBottomRightCorner.Visible = true;
}
}
else if (!_showScrollIndicator)
else if (!ShowScrollIndicator)
{
if (_contentBottomRightCorner is { })
{
@@ -1039,12 +1037,12 @@ public class ScrollBarView : View
_otherScrollBarView._contentBottomRightCorner.Visible = false;
}
if (Host?.Visible == true && _showScrollIndicator && !Visible)
if (Host?.Visible == true && ShowScrollIndicator && !Visible)
{
Visible = true;
}
if (Host?.Visible == true && _otherScrollBarView?._showScrollIndicator == true && !_otherScrollBarView.Visible)
if (Host?.Visible == true && _otherScrollBarView?.ShowScrollIndicator == true && !_otherScrollBarView.Visible)
{
_otherScrollBarView.Visible = true;
}
@@ -1054,12 +1052,12 @@ public class ScrollBarView : View
return;
}
if (_showScrollIndicator)
if (ShowScrollIndicator)
{
Draw ();
}
if (_otherScrollBarView is { } && _otherScrollBarView._showScrollIndicator)
if (_otherScrollBarView is { } && _otherScrollBarView.ShowScrollIndicator)
{
_otherScrollBarView.Draw ();
}
@@ -1078,7 +1076,6 @@ public class ScrollBarView : View
{
public ContentBottomRightCorner ()
{
ClearOnVisibleFalse = false;
ColorScheme = ColorScheme;
}
}

View File

@@ -77,7 +77,7 @@ public class BackgroundWorkerCollection : Scenario
() => Quit (),
null,
null,
(KeyCode)Application.QuitKey
Application.QuitKey
)
}
),
@@ -281,7 +281,7 @@ public class BackgroundWorkerCollection : Scenario
_listView = new ListView { X = 0, Y = 2, Width = Dim.Fill (), Height = Dim.Fill (2), Enabled = false };
Add (_listView);
_start = new Button { Text = "Start", IsDefault = true, ClearOnVisibleFalse = false };
_start = new Button { Text = "Start", IsDefault = true };
_start.Accept += (s, e) =>
{
@@ -302,19 +302,28 @@ public class BackgroundWorkerCollection : Scenario
}
};
LayoutStarted += (s, e) =>
{
int btnsWidth = _start.Frame.Width + _close.Frame.Width + 2 - 1;
int shiftLeft = Math.Max ((Viewport.Width - btnsWidth) / 2 - 2, 0);
LayoutStarted += StagingUIController_LayoutStarted;
Disposing += StagingUIController_Disposing;
}
shiftLeft += _close.Frame.Width + 1;
_close.X = Pos.AnchorEnd (shiftLeft);
_close.Y = Pos.AnchorEnd (1);
private void StagingUIController_Disposing (object sender, EventArgs e)
{
LayoutStarted -= StagingUIController_LayoutStarted;
Disposing -= StagingUIController_Disposing;
}
shiftLeft += _start.Frame.Width + 1;
_start.X = Pos.AnchorEnd (shiftLeft);
_start.Y = Pos.AnchorEnd (1);
};
private void StagingUIController_LayoutStarted (object sender, LayoutEventArgs e)
{
int btnsWidth = _start.Frame.Width + _close.Frame.Width + 2 - 1;
int shiftLeft = Math.Max ((Viewport.Width - btnsWidth) / 2 - 2, 0);
shiftLeft += _close.Frame.Width + 1;
_close.X = Pos.AnchorEnd (shiftLeft);
_close.Y = Pos.AnchorEnd (1);
shiftLeft += _start.Frame.Width + 1;
_start.X = Pos.AnchorEnd (shiftLeft);
_start.Y = Pos.AnchorEnd (1);
}
public Staging Staging { get; private set; }
@@ -371,11 +380,12 @@ public class BackgroundWorkerCollection : Scenario
{
CancelWorker ();
}
private void WorkerApp_Closing (object sender, ToplevelClosingEventArgs e)
{
Toplevel top = ApplicationOverlapped.OverlappedChildren!.Find (x => x.Data.ToString () == "WorkerApp");
if (Visible && top == this)
if (e.RequestingTop == this && Visible && top == this)
{
Visible = false;
e.Cancel = true;

View File

@@ -294,7 +294,7 @@ public class ScrollBarViewTests
[Fact]
[AutoInitShutdown]
public void ClearOnVisibleFalse_Gets_Sets ()
public void Visible_Gets_Sets ()
{
var text =
"This is a test\nThis is a test\nThis is a test\nThis is a test\nThis is a test\nThis is a test";
@@ -302,7 +302,7 @@ public class ScrollBarViewTests
var top = new Toplevel ();
top.Add (label);
var sbv = new ScrollBarView (label, true, false) { Size = 100, ClearOnVisibleFalse = false };
var sbv = new ScrollBarView (label, true, false) { Size = 100 };
Application.Begin (top);
Assert.True (sbv.Visible);
@@ -351,18 +351,18 @@ This is a tes▼
_output
);
sbv.ClearOnVisibleFalse = true;
sbv.Visible = false;
Assert.False (sbv.Visible);
top.Draw ();
TestHelpers.AssertDriverContentsWithFrameAre (
@"
This is a tes
This is a tes
This is a tes
This is a tes
This is a tes
This is a tes
This is a test
This is a test
This is a test
This is a test
This is a test
This is a test
",
_output
);