mirror of
https://github.com/gui-cs/Terminal.Gui.git
synced 2025-12-26 15:57:56 +01:00
* Initial plan * Fix Wizard v2 architecture issues - ScrollBar API, event handlers, key bindings Co-authored-by: tig <585482+tig@users.noreply.github.com> * Implement issue #4155 - Put nav buttons in bottom Padding, Help in right Padding Co-authored-by: tig <585482+tig@users.noreply.github.com> * Address code review feedback - Extract helper method, improve null checks Co-authored-by: tig <585482+tig@users.noreply.github.com> * Fix disposal issue - Ensure _helpTextView is always disposed Co-authored-by: tig <585482+tig@users.noreply.github.com> * Refactor & improvements. WIP * Tweaking layout * Wizard tweaks * Added View.GetSubViews that optinoally gets subviews of adornments * Refactor Wizard API: modern events, layout, and design - Replaced custom event args with standard .NET event args (CancelEventArgs, ValueChangingEventArgs, etc.) - Removed Finished event; use Accepting for wizard completion - Updated Cancelled, MovingBack, MovingNext to use CancelEventArgs - Refactored UICatalog scenarios and tests to new event model - Improved WizardStep sizing and wizard auto-resizing to content - Enhanced IDesignable for Wizard and WizardStep with richer design-time UI - Simplified help text padding logic in WizardStep - Removed obsolete code and modernized code style throughout - Improves API consistency, usability, and .NET idiomatic usage * Fixes #4515 - Navigating into and out of Adornments does not work * WIP. QUite broken. * All fixed? * Tweaks. * Exclude Margin subviews from drawing; add shadow tests Update Margin adornment to skip drawing subviews that are themselves Margin views, preventing unsupported nested Margin rendering. Add unit tests to verify that opaque-shadowed buttons in Margin are not drawn, while Border and Padding still support shadow rendering. Update test class to use output helper and assert driver output. * Final code cleanup and test improvements. * Update Margin.cs Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Update View.cs Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Update View.Hierarchy.cs Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Update View.Hierarchy.cs Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Refactor: code style, formatting, and minor logic cleanup - Standardized spacing and formatting for method signatures and object initializations. - Converted simple methods and properties to expression-bodied members for conciseness. - Replaced named arguments with positional arguments for consistency. - Improved XML documentation formatting for readability. - Simplified logic in event handlers (e.g., Wizard Back button). - Removed redundant checks where properties are guaranteed to exist. - Fixed minor bugs related to padding, height calculation, and event handling. - Adopted consistent use of `var` for local variables. - Corrected namespace declarations. - Refactored methods returning constants to use expression-bodied syntax. - General code cleanup for clarity and maintainability; no breaking changes. * api docs --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: tig <585482+tig@users.noreply.github.com> Co-authored-by: Tig <tig@users.noreply.github.com> Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
This commit is contained in:
@@ -1,21 +1,24 @@
|
||||
using Xunit.Abstractions;
|
||||
using UnitTests;
|
||||
using Xunit.Abstractions;
|
||||
|
||||
namespace ViewBaseTests.Adornments;
|
||||
|
||||
public class AdornmentSubViewTests ()
|
||||
public class AdornmentSubViewTests (ITestOutputHelper output)
|
||||
{
|
||||
private readonly ITestOutputHelper _output = output;
|
||||
|
||||
[Fact]
|
||||
public void Setting_Thickness_Causes_Adornment_SubView_Layout ()
|
||||
{
|
||||
var view = new View ();
|
||||
var subView = new View ();
|
||||
view.Margin!.Add (subView);
|
||||
view.Padding!.Add (subView);
|
||||
view.BeginInit ();
|
||||
view.EndInit ();
|
||||
var raised = false;
|
||||
|
||||
subView.SubViewLayout += LayoutStarted;
|
||||
view.Margin.Thickness = new Thickness (1, 2, 3, 4);
|
||||
view.Padding.Thickness = new (1, 2, 3, 4);
|
||||
view.Layout ();
|
||||
Assert.True (raised);
|
||||
|
||||
@@ -27,12 +30,12 @@ public class AdornmentSubViewTests ()
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData (0, 0, false)] // Margin has no thickness, so false
|
||||
[InlineData (0, 1, false)] // Margin has no thickness, so false
|
||||
[InlineData (0, 0, false)] // Padding has no thickness, so false
|
||||
[InlineData (0, 1, false)] // Padding has no thickness, so false
|
||||
[InlineData (1, 0, true)]
|
||||
[InlineData (1, 1, true)]
|
||||
[InlineData (2, 1, true)]
|
||||
public void Adornment_WithSubView_Finds (int viewMargin, int subViewMargin, bool expectedFound)
|
||||
public void Adornment_WithSubView_Finds (int viewPadding, int subViewPadding, bool expectedFound)
|
||||
{
|
||||
IApplication? app = Application.Create ();
|
||||
Runnable<bool> runnable = new ()
|
||||
@@ -42,9 +45,9 @@ public class AdornmentSubViewTests ()
|
||||
};
|
||||
app.Begin (runnable);
|
||||
|
||||
runnable.Margin!.Thickness = new Thickness (viewMargin);
|
||||
runnable.Padding!.Thickness = new (viewPadding);
|
||||
// Turn of TransparentMouse for the test
|
||||
runnable.Margin!.ViewportSettings = ViewportSettingsFlags.None;
|
||||
runnable.Padding!.ViewportSettings = ViewportSettingsFlags.None;
|
||||
|
||||
var subView = new View ()
|
||||
{
|
||||
@@ -53,16 +56,16 @@ public class AdornmentSubViewTests ()
|
||||
Width = 5,
|
||||
Height = 5
|
||||
};
|
||||
subView.Margin!.Thickness = new Thickness (subViewMargin);
|
||||
subView.Padding!.Thickness = new (subViewPadding);
|
||||
// Turn of TransparentMouse for the test
|
||||
subView.Margin!.ViewportSettings = ViewportSettingsFlags.None;
|
||||
subView.Padding!.ViewportSettings = ViewportSettingsFlags.None;
|
||||
|
||||
runnable.Margin!.Add (subView);
|
||||
runnable.Padding!.Add (subView);
|
||||
runnable.Layout ();
|
||||
|
||||
var foundView = runnable.GetViewsUnderLocation (new Point (0, 0), ViewportSettingsFlags.None).LastOrDefault ();
|
||||
View? foundView = runnable.GetViewsUnderLocation (new (0, 0), ViewportSettingsFlags.None).LastOrDefault ();
|
||||
|
||||
bool found = foundView == subView || foundView == subView.Margin;
|
||||
bool found = foundView == subView || foundView == subView.Padding;
|
||||
Assert.Equal (expectedFound, found);
|
||||
}
|
||||
|
||||
@@ -92,4 +95,84 @@ public class AdornmentSubViewTests ()
|
||||
Assert.Equal (runnable.Padding, runnable.GetViewsUnderLocation (new Point (0, 0), ViewportSettingsFlags.None).LastOrDefault ());
|
||||
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Button_With_Opaque_ShadowStyle_In_Border_Should_Draw_Shadow ()
|
||||
{
|
||||
// Arrange
|
||||
using IApplication app = Application.Create ();
|
||||
app.Init ("fake");
|
||||
app.Driver?.SetScreenSize (1, 4);
|
||||
app.Driver!.Force16Colors = true;
|
||||
|
||||
using Runnable window = new ();
|
||||
window.Width = Dim.Fill ();
|
||||
window.Height = Dim.Fill ();
|
||||
window.Text = @"XXXXXX";
|
||||
window.SetScheme (new (new Attribute (Color.Black, Color.White)));
|
||||
|
||||
// Setup padding with some thickness so we have space for the button
|
||||
window.Border!.Thickness = new (0, 3, 0, 0);
|
||||
|
||||
// Add a button with a transparent shadow to the Padding adornment
|
||||
Button buttonInBorder = new ()
|
||||
{
|
||||
X = 0,
|
||||
Y = 0,
|
||||
Text = "B",
|
||||
NoDecorations = true,
|
||||
NoPadding = true,
|
||||
ShadowStyle = ShadowStyle.Opaque,
|
||||
};
|
||||
|
||||
window.Border.Add (buttonInBorder);
|
||||
app.Begin (window);
|
||||
|
||||
DriverAssert.AssertDriverOutputIs ("""
|
||||
\x1b[30m\x1b[107mB▝ \x1b[97m\x1b[40mX
|
||||
""",
|
||||
_output,
|
||||
app.Driver);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Button_With_Opaque_ShadowStyle_In_Padding_Should_Draw_Shadow ()
|
||||
{
|
||||
// Arrange
|
||||
using IApplication app = Application.Create ();
|
||||
app.Init ("fake");
|
||||
app.Driver?.SetScreenSize (1, 4);
|
||||
app.Driver!.Force16Colors = true;
|
||||
|
||||
using Runnable window = new ();
|
||||
window.Width = Dim.Fill ();
|
||||
window.Height = Dim.Fill ();
|
||||
window.Text = @"XXXXXX";
|
||||
window.SetScheme (new (new Attribute (Color.Black, Color.White)));
|
||||
|
||||
// Setup padding with some thickness so we have space for the button
|
||||
window.Padding!.Thickness = new (0, 3, 0, 0);
|
||||
|
||||
// Add a button with a transparent shadow to the Padding adornment
|
||||
Button buttonInPadding = new ()
|
||||
{
|
||||
X = 0,
|
||||
Y = 0,
|
||||
Text = "B",
|
||||
NoDecorations = true,
|
||||
NoPadding = true,
|
||||
ShadowStyle = ShadowStyle.Opaque,
|
||||
};
|
||||
|
||||
window.Padding.Add (buttonInPadding);
|
||||
app.Begin (window);
|
||||
|
||||
DriverAssert.AssertDriverOutputIs ("""
|
||||
\x1b[97m\x1b[40mB\x1b[30m\x1b[107m▝ \x1b[97m\x1b[40mX
|
||||
""",
|
||||
_output,
|
||||
app.Driver);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user