-
Notifications
You must be signed in to change notification settings - Fork 694
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
A view referencing a View that's not a peer (same superview) in Dim/Pos should not be allowed #2461
Comments
The test is very confuse and I purpose did it. If you look better all them belong to the same hierarchy (t, w, f, v1 and v2). For this to work I did changes to the |
Ahhh.... Now it makes much more sense to me. Do you think it would be a good idea to NOT allow these funky scenarios? |
Ok I agree to avoid steaming heads :-) |
Separate from the work I'm doing now, I'm going to implement this and see how much actually breaks. I'm guessing I may find some use cases where referencing a superview may be very useful... Or not. |
Well for the |
|
On layout, a inner subview can reference a outer sujperview, but a superview never can reference a subview. See #2504. |
Can you give an example of a useful scenario where a subview references it's superview (or superview's superview)? I tried to think of one but couldn't. |
Sure, here is a small example: Application.Init ();
var top = Application.Top;
var win1 = new Window ("win1");
var win2 = new Window (new Rect (0, 0, 60, 20), "win2");
var win3 = new Window (new Rect (0, 0, 30, 10), "win3");
var leftLabel = new Label ("move to right") { X = Pos.Left (win2) };
var rightLabel = new Label ("move to left") { X = 90 - 14 - Pos.Right (win2), Y = Pos.AnchorEnd (1) };
win3.Add (leftLabel, rightLabel);
win2.Add (win3);
win1.Add (win2);
top.Add (win1);
Application.Run ();
Application.Shutdown (); Maybe we can leverage this for scrolling, what do think? @tig see the dragging is exceeds the right side and the bottom side of the superview. Also when I start the drag by pressing the mouse the frame move down one line and the mouse isn't aligned at the top. |
@tig the numeration is broke again. We need to create a unit test for this doesn't happens again. |
The reason is you removed the code which pass the |
This effect is cool, but I'm not sure why it's useful. I'm pushing on this because I want us to simplify the Terminal.Gui for developers and my intuition (based on my experience, and the fact that I'm not a very smart programmers) is that Pos/Dim are powerful-yet-confusing. By making the rule "Pos/Dim can only reference peer-Views" we can make it easier to understand. If some developer comes along later with a REAL and useful scenario that is not possible with this limitation, we can back it out. In the meantime, developers will make fewer mistakes. I'm COMPLETELY willing to have my mind changed on this. I have a feeling you have a real scenario in mind, but you've just not been able to articulate it yet. So please do. Note this is not something we need to decide right now! We can let it stew ;-). |
Right. The documentation for TextFormatter is confusing. We need to fix that because I've made this mistake before. |
@tig the scrolling issue wasn't related with I said before, sorry. The main cause was the |
I'm going to close this issue. I think @BDisp shows an interesting use-case. |
I was debugging tests and came across this test:
https://github.com/gui-cs/Terminal.Gui/blob/33c9a5fad44256ab1ade0d9ac478dab6af89b9b6/UnitTests/Types/DimTests.cs#LL541C3-L585C4
I have decided this test is totally bogus because views are referencing superviews.
This code would guard against this:
And this test would verify:
This breaks a lot of existing code (e.g.
TileView
does this internally). So I'm not sure I'm correct.Please debate ;-).
Thanks.
The text was updated successfully, but these errors were encountered: