mirror of
https://github.com/gui-cs/Terminal.Gui.git
synced 2026-02-10 04:03:41 +01:00
merged
This commit is contained in:
@@ -5,8 +5,8 @@
|
||||
namespace ViewBaseTests.Layout;
|
||||
|
||||
/// <summary>
|
||||
/// Tests for the GetMinimumContribution method on Dim types.
|
||||
/// This method is used by DimAuto to get minimum size contribution during auto-sizing.
|
||||
/// Tests for the GetMinimumContribution method on Dim types.
|
||||
/// This method is used by DimAuto to get minimum size contribution during auto-sizing.
|
||||
/// </summary>
|
||||
public class GetMinimumContributionTests
|
||||
{
|
||||
@@ -24,7 +24,7 @@ public class GetMinimumContributionTests
|
||||
var view = new View { Width = Dim.Auto (), Height = Dim.Auto () };
|
||||
view.BeginInit ();
|
||||
view.EndInit ();
|
||||
|
||||
|
||||
// DimAuto calculates based on content
|
||||
int contribution = view.Width.GetMinimumContribution (0, 100, view, Dimension.Width);
|
||||
Assert.True (contribution >= 0);
|
||||
@@ -43,7 +43,7 @@ public class GetMinimumContributionTests
|
||||
{
|
||||
var targetView = new View { Width = 30, Height = 20 };
|
||||
Dim dim = Dim.Width (targetView);
|
||||
|
||||
|
||||
int contribution = dim.GetMinimumContribution (0, 100, null, Dimension.Width);
|
||||
Assert.Equal (30, contribution);
|
||||
}
|
||||
@@ -104,7 +104,7 @@ public class GetMinimumContributionTests
|
||||
// because the actual contribution depends on the To view's position, which DimAuto handles specially
|
||||
var toView = new View { X = 50, Y = 30 };
|
||||
Dim dim = Dim.Fill (toView);
|
||||
|
||||
|
||||
int contribution = dim.GetMinimumContribution (0, 100, null, Dimension.Width);
|
||||
Assert.Equal (0, contribution);
|
||||
}
|
||||
@@ -114,7 +114,7 @@ public class GetMinimumContributionTests
|
||||
{
|
||||
var toView = new View { X = 50, Y = 30 };
|
||||
Dim dim = Dim.Fill (5, toView);
|
||||
|
||||
|
||||
int contribution = dim.GetMinimumContribution (0, 100, null, Dimension.Width);
|
||||
Assert.Equal (0, contribution);
|
||||
}
|
||||
|
||||
@@ -52,23 +52,6 @@ Added `GetReferencedViews()` virtual method to `Dim` and `Pos` base classes to d
|
||||
|
||||
**Result:** `CollectDim` and `CollectPos` no longer need to know about `DimView`, `DimFill`, `DimCombine`, `PosView`, `PosCombine`.
|
||||
|
||||
### Phase 1b: `ReferencesOtherViews()` Simplification (✅ Done)
|
||||
|
||||
Changed `ReferencesOtherViews()` to use `GetReferencedViews().Any()` as default implementation, removing duplication.
|
||||
|
||||
**Changes:**
|
||||
- `Dim.ReferencesOtherViews()` - Now uses `GetReferencedViews().Any()` by default
|
||||
- `Pos.ReferencesOtherViews()` - Now uses `GetReferencedViews().Any()` by default
|
||||
- `DimFill.ReferencesOtherViews()` - Removed (uses default)
|
||||
- `PosFunc.ReferencesOtherViews()` - Removed (uses default)
|
||||
|
||||
**Kept for optimization (avoid iterator allocation):**
|
||||
- `DimView.ReferencesOtherViews()` - Always returns `true`
|
||||
- `PosView.ReferencesOtherViews()` - Always returns `true`
|
||||
- `DimCombine.ReferencesOtherViews()` - Short-circuits via `Left`/`Right`
|
||||
- `PosCombine.ReferencesOtherViews()` - Short-circuits via `Left`/`Right`
|
||||
- `PosAlign.ReferencesOtherViews()` - Always returns `true` (special case: alignment affects layout but doesn't track specific views)
|
||||
|
||||
## Proposed Future Refactoring
|
||||
|
||||
### Phase 2: `DependsOnSuperViewContentSize`
|
||||
@@ -149,7 +132,7 @@ internal virtual bool RequiresTargetLayout => false;
|
||||
## Implementation Order
|
||||
|
||||
1. ✅ `GetReferencedViews()` - Foundation for view dependencies
|
||||
2. ✅ `ReferencesOtherViews()` simplification - Uses `GetReferencedViews().Any()` as default
|
||||
2. 🔲 `ReferencesOtherViews()` simplification - Use `GetReferencedViews().Any()` as default
|
||||
3. 🔲 `DependsOnSuperViewContentSize` - Reduce type checking in `DimAuto`
|
||||
4. 🔲 `CanContributeToAutoSizing` - Simplify auto-sizing logic
|
||||
5. 🔲 `GetMinimumContribution()` - Move calculation logic into types
|
||||
|
||||
Reference in New Issue
Block a user