Fixes #3951. Adds View dependency to DimFunc and PosFunc (#4210)

* Fixes #4208. MainLoopSyncContext doesn't work with the v2 drivers

* Fixes #3951. Add DimFuncWithView with a View dependency

* Revert to iteration which will handle the necessary processes

* Revert "Revert to iteration which will handle the necessary processes"

This reverts commit 50015ac6da.

* Layout and draw before position cursor

* Add optional View parameter and property to the DimFunc and PosFunc

* Trying fix unit test error

* Revert layout changes

* Fixes #4216. Legacy drivers aren't refreshing the screen correctly on view drag

* Add assertion proving NeedsLayout is always false before call OnSubViewsLaidOut

* Fix unit test error

* Increasing time to abort

* Revert "Increasing time to abort"

This reverts commit d7306e72f3.

* Trying fix integration tests

* Still trying fix integrations unit tests

* Revert comment

* Layout is performed during the iteration

* Using Dim.Func with status bar view

* Still trying fix integrations tests by locking _subviews

* Still trying fix integrations tests by locking _subviews

* Add internal SnapshotSubviews method

* Remove lock from SnapshotSubviews method

* Using SnapshotSubviews method in the DrawSubViews method

* Remove lock from SnapshotSubviews method

* Using SnapshotSubviews method in the DrawSubViews method

* Using SnapshotSubviews

* Prevent new app if the previous wasn't yet finished

* Replace SnapshotSubviews method with ViewCollectionHelpers class

* Lock entire GuiTestContext constructor

* Using Snapshot in the ordered field

* Fixes #4221 Extra modifiers f1 to f4 in v2net (#4220)

* Assume we are running in a terminal that supports true color by default unless user explicitly forces 16

* Add support for extra modifiers for F1 to F4 keys

* Revert "Assume we are running in a terminal that supports true color by default unless user explicitly forces 16"

This reverts commit 4cc2530de0.

* Cleanup

* Update comments

* Code cleanup

---------

Co-authored-by: Tig <tig@users.noreply.github.com>

* Move ViewCollectionHelpers class to a separate file

* Remove Border.Layout call in the DoDrawAdornmentsSubViews method.

* Remove adornments layout call within the draw

---------

Co-authored-by: Tig <tig@users.noreply.github.com>
Co-authored-by: Thomas Nind <31306100+tznind@users.noreply.github.com>
This commit is contained in:
BDisp
2025-09-01 17:40:10 +01:00
committed by GitHub
parent 7ca765cef1
commit 00aaefb962
53 changed files with 426 additions and 247 deletions

View File

@@ -35,7 +35,7 @@ public class Adornments : Scenario
Title = "The _Window",
Arrangement = ViewArrangement.Overlapped | ViewArrangement.Movable,
Width = Dim.Fill (Dim.Func (() => editor.Frame.Width)),
Width = Dim.Fill (Dim.Func (_ => editor.Frame.Width)),
Height = Dim.Fill ()
};
app.Add (window);

View File

@@ -101,7 +101,7 @@ public class AllViewsTester : Scenario
{
Title = "Arrangement [_3]",
X = Pos.Right (_classListView) - 1,
Y = Pos.Bottom (_adornmentsEditor) - Pos.Func (() => _adornmentsEditor.Frame.Height == 1 ? 0 : 1),
Y = Pos.Bottom (_adornmentsEditor) - Pos.Func (_ => _adornmentsEditor.Frame.Height == 1 ? 0 : 1),
Width = Dim.Width (_adornmentsEditor),
Height = Dim.Fill (),
AutoSelectViewToEdit = false,
@@ -134,7 +134,7 @@ public class AllViewsTester : Scenario
{
Title = "ViewportSettings [_5]",
X = Pos.Right (_arrangementEditor) - 1,
Y = Pos.Bottom (_layoutEditor) - Pos.Func (() => _layoutEditor.Frame.Height == 1 ? 0 : 1),
Y = Pos.Bottom (_layoutEditor) - Pos.Func (_ => _layoutEditor.Frame.Height == 1 ? 0 : 1),
Width = Dim.Width (_layoutEditor),
Height = Dim.Auto (),
CanFocus = true,
@@ -148,7 +148,7 @@ public class AllViewsTester : Scenario
{
Title = "View Properties [_6]",
X = Pos.Right (_adornmentsEditor) - 1,
Y = Pos.Bottom (_viewportSettingsEditor) - Pos.Func (() => _viewportSettingsEditor.Frame.Height == 1 ? 0 : 1),
Y = Pos.Bottom (_viewportSettingsEditor) - Pos.Func (_ => _viewportSettingsEditor.Frame.Height == 1 ? 0 : 1),
Width = Dim.Width (_layoutEditor),
Height = Dim.Auto (),
CanFocus = true,
@@ -171,7 +171,7 @@ public class AllViewsTester : Scenario
_layoutEditor.Width = Dim.Fill (
Dim.Func (
() =>
_ =>
{
if (_eventLog.NeedsLayout)
{

View File

@@ -66,7 +66,7 @@ public class Arrangement : Scenario
View tiledView3 = CreateTiledView (2, Pos.Right (tiledView2) - 1, Pos.Top (tiledView2));
tiledView3.Height = Dim.Height (tiledView1);
View tiledView4 = CreateTiledView (3, Pos.Left (tiledView1), Pos.Bottom (tiledView1) - 1);
tiledView4.Width = Dim.Func (() => tiledView3.Frame.Width + tiledView2.Frame.Width + tiledView1.Frame.Width - 2);
tiledView4.Width = Dim.Func (_ => tiledView3.Frame.Width + tiledView2.Frame.Width + tiledView1.Frame.Width - 2);
View movableSizeableWithProgress = CreateOverlappedView (2, 10, 8);
movableSizeableWithProgress.Title = "Movable _& Sizable";

View File

@@ -39,7 +39,6 @@ public class CharacterMap : Scenario
{
X = 0,
Y = 1,
Width = Dim.Fill (Dim.Func (() => _categoryList!.Frame.Width)),
Height = Dim.Fill (),
// SchemeName = "Base"
@@ -172,6 +171,8 @@ public class CharacterMap : Scenario
};
top.Add (menu);
_charMap.Width = Dim.Fill (Dim.Func (v => v!.Frame.Width, _categoryList));
_charMap.SelectedCodePoint = 0;
_charMap.SetFocus ();

View File

@@ -55,7 +55,7 @@ public class ConfigurationEditor : Scenario
_tabView = new ()
{
Width = Dim.Fill (),
Height = Dim.Fill (Dim.Func (() => statusBar.Frame.Height))
Height = Dim.Fill (Dim.Func (_ => statusBar.Frame.Height))
};
win.Add (_tabView, statusBar);

View File

@@ -598,7 +598,7 @@ public class DynamicMenuBar : Scenario
X = Pos.Right (btnPrevious) + 1,
Y = Pos.Top (btnPrevious),
Width = Dim.Fill () - Dim.Func (() => btnAdd.Frame.Width + 1),
Width = Dim.Fill () - Dim.Func (_ => btnAdd.Frame.Width + 1),
Height = 1
};

View File

@@ -100,7 +100,7 @@ public class AdornmentEditor : EditorBase
_leftEdit = new ()
{
X = Pos.Left (_topEdit) - Pos.Func (() => _topEdit.Text.Length) - 2, Y = Pos.Bottom (_topEdit),
X = Pos.Left (_topEdit) - Pos.Func (_ => _topEdit.Text.Length) - 2, Y = Pos.Bottom (_topEdit),
Format = _topEdit.Format
};

View File

@@ -122,7 +122,7 @@ public class AdornmentsEditor : EditorBase
PaddingEditor.Border!.Thickness = PaddingEditor.Border.Thickness with { Bottom = 0 };
Add (PaddingEditor);
Width = Dim.Auto (maximumContentDim: Dim.Func (() => MarginEditor.Frame.Width - 2));
Width = Dim.Auto (maximumContentDim: Dim.Func (_ => MarginEditor.Frame.Width - 2));
MarginEditor.ExpanderButton!.Collapsed = true;
BorderEditor.ExpanderButton!.Collapsed = true;

View File

@@ -68,7 +68,7 @@ public class DimEditor : EditorBase
break;
case DimFunc func:
_valueEdit.Enabled = true;
_value = func.Fn ();
_value = func.Fn (null);
_valueEdit!.Text = _value.ToString ();
break;
case DimPercent percent:
@@ -98,7 +98,7 @@ public class DimEditor : EditorBase
{
X = Pos.Right (label) + 1,
Y = 0,
Width = Dim.Func (() => _radioItems.Max (i => i.GetColumns ()) - label.Frame.Width + 1),
Width = Dim.Func (_ => _radioItems.Max (i => i.GetColumns ()) - label.Frame.Width + 1),
Text = $"{_value}"
};
@@ -141,7 +141,7 @@ public class DimEditor : EditorBase
0 => Dim.Absolute (_value),
1 => Dim.Auto (),
2 => Dim.Fill (_value),
3 => Dim.Func (() => _value),
3 => Dim.Func (_ => _value),
4 => Dim.Percent (_value),
_ => Dimension == Dimension.Width ? ViewToEdit.Width : ViewToEdit.Height
};

View File

@@ -20,7 +20,7 @@ public class EventLog : ListView
Y = 0;
Width = Dim.Func (
() =>
_ =>
{
if (!IsInitialized)
{

View File

@@ -70,7 +70,7 @@ public class PosEditor : EditorBase
break;
case PosFunc func:
_valueEdit.Enabled = true;
_value = func.Fn ();
_value = func.Fn (null);
_valueEdit!.Text = _value.ToString ();
break;
@@ -98,7 +98,7 @@ public class PosEditor : EditorBase
{
X = Pos.Right (label) + 1,
Y = 0,
Width = Dim.Func (() => _radioItems.Max (i => i.GetColumns ()) - label.Frame.Width + 1),
Width = Dim.Func (_ => _radioItems.Max (i => i.GetColumns ()) - label.Frame.Width + 1),
Text = $"{_value}"
};
@@ -142,7 +142,7 @@ public class PosEditor : EditorBase
1 => Pos.Align (Alignment.Start),
2 => new PosAnchorEnd (),
3 => Pos.Center (),
4 => Pos.Func (() => _value),
4 => Pos.Func (_ => _value),
5 => Pos.Percent (_value),
_ => Dimension == Dimension.Width ? ViewToEdit.X : ViewToEdit.Y
};

View File

@@ -252,7 +252,7 @@ public class ListColumns : Scenario
top.Add (menu, appWindow, statusBar);
appWindow.Y = 1;
appWindow.Height = Dim.Fill(Dim.Func (() => statusBar.Frame.Height));
appWindow.Height = Dim.Fill(Dim.Func (_ => statusBar.Frame.Height));
// Run - Start the application.
Application.Run (top);

View File

@@ -76,7 +76,7 @@ public class ListViewWithSelection : Scenario
Title = "_ListView",
X = 0,
Y = Pos.Bottom (_allowMarkingCb),
Width = Dim.Func (() => _listView?.MaxLength ?? 10),
Width = Dim.Func (_ => _listView?.MaxLength ?? 10),
Height = Dim.Fill (),
AllowsMarking = false,
AllowsMultipleSelection = false,

View File

@@ -109,7 +109,7 @@ public class Mouse : Scenario
X = 0,
Y = 0,
Width = Dim.Fill (),
Height = Dim.Func (() => demo.Padding.Thickness.Top),
Height = Dim.Func (_ => demo.Padding.Thickness.Top),
Title = "inPadding",
Id = "inPadding"
});

View File

@@ -72,7 +72,7 @@ public class ScrollBarDemo : Scenario
Text = "_Width/Height:",
TextAlignment = Alignment.End,
Y = Pos.Align (Alignment.Start, AlignmentModes.StartToEnd, groupId: 1),
Width = Dim.Func (() => GetMaxLabelWidth (1))
Width = Dim.Func (_ => GetMaxLabelWidth (1))
};
demoFrame.Add (lblWidthHeight);
@@ -114,7 +114,7 @@ public class ScrollBarDemo : Scenario
Text = "_Orientation:",
TextAlignment = Alignment.End,
Y = Pos.Align (Alignment.Start, groupId: 1),
Width = Dim.Func (() => GetMaxLabelWidth (1))
Width = Dim.Func (_ => GetMaxLabelWidth (1))
};
demoFrame.Add (lblOrientationLabel);
@@ -160,7 +160,7 @@ public class ScrollBarDemo : Scenario
Text = "Scrollable_ContentSize:",
TextAlignment = Alignment.End,
Y = Pos.Align (Alignment.Start, groupId: 1),
Width = Dim.Func (() => GetMaxLabelWidth (1))
Width = Dim.Func (_ => GetMaxLabelWidth (1))
};
demoFrame.Add (lblSize);
@@ -193,7 +193,7 @@ public class ScrollBarDemo : Scenario
Text = "_VisibleContentSize:",
TextAlignment = Alignment.End,
Y = Pos.Align (Alignment.Start, groupId: 1),
Width = Dim.Func (() => GetMaxLabelWidth (1))
Width = Dim.Func (_ => GetMaxLabelWidth (1))
};
demoFrame.Add (lblVisibleContentSize);
@@ -226,7 +226,7 @@ public class ScrollBarDemo : Scenario
Text = "_Position:",
TextAlignment = Alignment.End,
Y = Pos.Align (Alignment.Start, groupId: 1),
Width = Dim.Func (() => GetMaxLabelWidth (1))
Width = Dim.Func (_ => GetMaxLabelWidth (1))
};
demoFrame.Add (lblPosition);
@@ -264,7 +264,7 @@ public class ScrollBarDemo : Scenario
Text = "Options:",
TextAlignment = Alignment.End,
Y = Pos.Align (Alignment.Start, groupId: 1),
Width = Dim.Func (() => GetMaxLabelWidth (1))
Width = Dim.Func (_ => GetMaxLabelWidth (1))
};
demoFrame.Add (lblOptions);
var autoShow = new CheckBox
@@ -282,7 +282,7 @@ public class ScrollBarDemo : Scenario
Text = "SliderPosition:",
TextAlignment = Alignment.End,
Y = Pos.Align (Alignment.Start, groupId: 1),
Width = Dim.Func (() => GetMaxLabelWidth (1))
Width = Dim.Func (_ => GetMaxLabelWidth (1))
};
demoFrame.Add (lblSliderPosition);
@@ -299,7 +299,7 @@ public class ScrollBarDemo : Scenario
Text = "Scrolled:",
TextAlignment = Alignment.End,
Y = Pos.Align (Alignment.Start, groupId: 1),
Width = Dim.Func (() => GetMaxLabelWidth (1))
Width = Dim.Func (_ => GetMaxLabelWidth (1))
};
demoFrame.Add (lblScrolled);

View File

@@ -43,14 +43,14 @@ public class Shortcuts : Scenario
};
eventLog.Width = Dim.Func (
() => Math.Min (
Application.Top.Viewport.Width / 2,
eventLog?.MaxLength + eventLog!.GetAdornmentsThickness ().Horizontal ?? 0));
_ => Math.Min (
Application.Top.Viewport.Width / 2,
eventLog?.MaxLength + eventLog!.GetAdornmentsThickness ().Horizontal ?? 0));
eventLog.Width = Dim.Func (
() => Math.Min (
eventLog.SuperView!.Viewport.Width / 2,
eventLog?.MaxLength + eventLog!.GetAdornmentsThickness ().Horizontal ?? 0));
_ => Math.Min (
eventLog.SuperView!.Viewport.Width / 2,
eventLog?.MaxLength + eventLog!.GetAdornmentsThickness ().Horizontal ?? 0));
Application.Top.Add (eventLog);
var alignKeysShortcut = new Shortcut
@@ -193,7 +193,7 @@ public class Shortcuts : Scenario
Id = "appShortcut",
X = 0,
Y = Pos.Bottom (canFocusShortcut),
Width = Dim.Fill (Dim.Func (() => eventLog.Frame.Width)),
Width = Dim.Fill (Dim.Func (_ => eventLog.Frame.Width)),
Title = "A_pp Shortcut",
Key = Key.F1,
Text = "Width is DimFill",

View File

@@ -83,7 +83,7 @@ public class SingleBackgroundWorker : Scenario
workerLogTop.Add (_listLog);
workerLogTop.Y = 1;
workerLogTop.Height = Dim.Fill (Dim.Func (() => statusBar.Frame.Height));
workerLogTop.Height = Dim.Fill (Dim.Func (_ => statusBar.Frame.Height));
Add (menu, workerLogTop, statusBar);
Title = "MainApp";

View File

@@ -124,8 +124,8 @@ public class ViewportSettings : Scenario
var view = new ViewportSettingsDemoView
{
Title = "ViewportSettings Demo View",
Width = Dim.Fill (Dim.Func (() => app.IsInitialized ? adornmentsEditor.Frame.Width + 1 : 1)),
Height = Dim.Fill (Dim.Func (() => app.IsInitialized ? viewportSettingsEditor.Frame.Height : 1))
Width = Dim.Fill (Dim.Func (_ => app.IsInitialized ? adornmentsEditor.Frame.Width + 1 : 1)),
Height = Dim.Fill (Dim.Func (_ => app.IsInitialized ? viewportSettingsEditor.Frame.Height : 1))
};
app.Add (view);
@@ -164,7 +164,7 @@ public class ViewportSettings : Scenario
{
X = Pos.Center (),
Y = Pos.Bottom (textView) + 1,
Width = Dim.Auto (DimAutoStyle.Content, maximumContentDim: Dim.Func (() => view.GetContentSize ().Width)),
Width = Dim.Auto (DimAutoStyle.Content, maximumContentDim: Dim.Func (_ => view.GetContentSize ().Width)),
Height = Dim.Auto (DimAutoStyle.Content, maximumContentDim: Dim.Percent (20)),
};

View File

@@ -282,11 +282,11 @@ public class Wizards : Scenario
someText.Height = Dim.Fill (
Dim.Func (
() => someText.SuperView is { IsInitialized: true }
? someText.SuperView.SubViews
.First (view => view.Y.Has<PosAnchorEnd> (out _))
.Frame.Height
: 1));
v => someText.SuperView is { IsInitialized: true }
? someText.SuperView.SubViews
.First (view => view.Y.Has<PosAnchorEnd> (out _))
.Frame.Height
: 1));
var help = "This is helpful.";
fourthStep.Add (someText);