-
Notifications
You must be signed in to change notification settings - Fork 673
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Views - View.Height += 1 does not have the expected behavior #1291
Comments
That is the way that view.Height = view.Bounds.Height + 1; |
I agree. Do you have some solution for this? |
I already found the bug and will submit a PR, unless you already have your own fix, which if it is the case please then say anything. |
I think it's here. void CollectPos (Pos pos, View from, ref HashSet<View> nNodes, ref HashSet<(View, View)> nEdges)
{
if (pos is Pos.PosView pv) {
if (pv.Target != this) {
nEdges.Add ((pv.Target, from));
}
foreach (var v in from.InternalSubviews) {
CollectAll (v, ref nNodes, ref nEdges);
}
return;
}
if (pos is Pos.PosCombine pc) {
foreach (var v in from.InternalSubviews) {
CollectPos (pc.left, from, ref nNodes, ref nEdges);
CollectPos (pc.right, from, ref nNodes, ref nEdges);
}
}
} and I changed to: void CollectPos (Pos pos, View from, ref HashSet<View> nNodes, ref HashSet<(View, View)> nEdges)
{
if (pos is Pos.PosView pv) {
if (pv.Target != this) {
nEdges.Add ((pv.Target, from));
}
foreach (var v in from.InternalSubviews) {
CollectAll (v, ref nNodes, ref nEdges);
}
return;
}
if (pos is Pos.PosCombine pc) {
foreach (var v in from.InternalSubviews) {
CollectPos (pc.left, v, ref nNodes, ref nEdges);
CollectPos (pc.right, v, ref nNodes, ref nEdges);
}
}
} But now I get error while running the tests here: [Fact]
public void PosCombine_Do_Not_Throws ()
{
Application.Init (new FakeDriver (), new FakeMainLoop (() => FakeConsole.ReadKey (true)));
var t = Application.Top;
var w = new Window ("w") {
X = Pos.Left (t) + 2,
Y = Pos.Top (t) + 2
};
var f = new FrameView ("f");
var v1 = new View ("v1") {
X = Pos.Left (w) + 2,
Y = Pos.Top (w) + 2
};
var v2 = new View ("v2") {
X = Pos.Left (v1) + 2,
Y = Pos.Top (v1) + 2
};
f.Add (v1, v2);
w.Add (f);
t.Add (w);
f.X = Pos.X (t) + Pos.X (v2) - Pos.X (v1);
f.Y = Pos.Y (t) + Pos.Y (v2) - Pos.Y (v1);
t.Ready += () => {
Assert.Equal (0, t.Frame.X);
Assert.Equal (0, t.Frame.Y);
Assert.Equal (2, w.Frame.X);
Assert.Equal (2, w.Frame.Y);
Assert.Equal (2, f.Frame.X);
Assert.Equal (2, f.Frame.Y);
Assert.Equal (4, v1.Frame.X);
Assert.Equal (4, v1.Frame.Y);
Assert.Equal (6, v2.Frame.X);
Assert.Equal (6, v2.Frame.Y);
};
Application.Iteration += () => Application.RequestStop ();
Application.Run ();
Application.Shutdown ();
}
Can we try to come to some conclusion together? |
I also have errors in the following scenarios:
|
Well, the problem is nothing related to it. It is only related to |
…t on a PosAbsolute or DimAbsolute.
@BDisp Sorry I couldn't help you.
Yes, there are many ways to do this, but I think that |
Before I use
view.Height = view.Subviews.Count;
, I had it in another way where I didview.Height += 1;
I remove a lot of other views with Dim and Pos to other views, thinking maybe was circular reference or something.
But no, the problem is just that line ....
view.Height += 1;
If you try this, it gets exponentially slower.
This is beacuse
Dim.Combine
. After 3 times,view.Height == {Dim.Combine(Dim.Combine(Dim.Combine(Dim.Absolute(0)+Dim.Absolute(1))+Dim.Absolute(1))+Dim.Absolute(1))}
Is this the expected behavior for this case ???
Maybe if it's the same instance, combine should behave differently, because I think that
view.Height += x
is something very basic to have such a behavior.The text was updated successfully, but these errors were encountered: