Wizard fixes (#1802)

* Fixes #1791. Added Pos/Dim Function feature to automate layout.

* Added PosFunc/DimFunc class. and some more features.

* Fixes #1793. ScrollBarView is hiding if the host fit the available space.

* Fixes #1791. View not turn off AutoSize if TextFormatter.Size fit the Anchor.

* Done requested changes.

* Addressing feedback

* Added more AutoSize unit tests.

* wip

* Refactored and enhanced API

* Fixed test

Co-authored-by: BDisp <bd.bdisp@gmail.com>
This commit is contained in:
Tig Kindel
2022-06-14 08:54:33 -07:00
committed by GitHub
parent 10b410e406
commit 2451c19d15
6 changed files with 303 additions and 114 deletions

View File

@@ -93,6 +93,37 @@ namespace Terminal.Gui.Views {
// and that the title is correct
public void OneStepWizard_Shows ()
{
var d = ((FakeDriver)Application.Driver);
var title = "1234";
var stepTitle = "ABCD";
int width = 30;
int height = 7;
d.SetBufferSize (width, height);
var btnBackText = "Back";
var btnBack = string.Empty; // $"{d.LeftBracket} {btnBackText} {d.RightBracket}";
var btnNextText = "Finish"; // "Next";
var btnNext = $"{d.LeftBracket}{d.LeftDefaultIndicator} {btnNextText} {d.RightDefaultIndicator}{d.RightBracket}";
var topRow = $"{d.ULDCorner} {title} - {stepTitle} {new String (d.HDLine.ToString () [0], width - title.Length - stepTitle.Length - 7)}{d.URDCorner}";
var row2 = $"{d.VDLine}{new String (' ', width - 2)}{d.VDLine}";
var row3 = row2;
var row4 = row3;
var separatorRow = $"{d.VDLine}{new String (d.HLine.ToString () [0], width - 2)}{d.VDLine}";
var buttonRow = $"{d.VDLine}{btnBack}{new String (' ', width - btnBack.Length - btnNext.Length - 2)}{btnNext}{d.VDLine}";
var bottomRow = $"{d.LLDCorner}{new String (d.HDLine.ToString () [0], width - 2)}{d.LRDCorner}";
var wizard = new Wizard (title) { Width = width, Height = height };
wizard.AddStep (new Wizard.WizardStep (stepTitle));
//wizard.LayoutSubviews ();
var firstIteration = false;
var runstate = Application.Begin (wizard);
Application.RunMainLoopIteration (ref runstate, true, ref firstIteration);
GraphViewTests.AssertDriverContentsWithFrameAre ($"{topRow}\n{row2}\n{row3}\n{row4}\n{separatorRow}\n{buttonRow}\n{bottomRow}", output);
Application.End (runstate);
}
[Fact, AutoInitShutdown]
@@ -150,7 +181,7 @@ namespace Terminal.Gui.Views {
var separatorRow = $"{d.VDLine}{new String (d.HLine.ToString () [0], width - 2)}{d.VDLine}";
// Once this is fixed, revert to commented out line: https://github.com/migueldeicaza/gui.cs/issues/1791
var buttonRow = $"{d.VDLine}{new String (' ', width - btnNext.Length - 3)}{btnNext} {d.VDLine}";
var buttonRow = $"{d.VDLine}{new String (' ', width - btnNext.Length - 2)}{btnNext}{d.VDLine}";
//var buttonRow = $"{d.VDLine}{new String (' ', width - btnNext.Length - 2)}{btnNext}{d.VDLine}";
var bottomRow = $"{d.LLDCorner}{new String (d.HDLine.ToString () [0], width - 2)}{d.LRDCorner}";