placing a control with anchors and margins

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Andrea

Hello,
i´m feeling dumb, but i cannot place a simple panel at the bottom left of the screen.

I´m using a Control node (simple control, no container or anything), and i resize it every time with $Control.rect_size=OS.get_real_window_size() so that it is always of the same dimension of the screen.

Now, as a children of this control there is a 100x100 pixel panel.
In the editor of this panel, I set Top and Bottom anchor=1 while left and right =0. Doing so the anchor of the panel is at the bottom left of the screen.
Then i set the margins to 0 for left and bottom, Top=-100, Right=100.

Now if I look to the vertical positioning only, the panel bottom should lay at the bottom of the screen (0 pixel from the anchor) while the top of the panel should be 100 pixel above (-100 from the anchor).

BUT IT IS NOT WORKING! >:(

Somehow the panel top is around 50 pixel above the bottom of the screen.
I´m saying around because no matter what property i track (position, anchor, margin), everything has the right value and should place the panel in the right position, but i can clearly see the panel is not a square but a rectangle.
I´m getting crazy, please help!

EDIT:
can it be that the get_real_windows_size() include the dimension of the window borders and this offsets everything?
EDIT EDIT:
That was exactly the problem, the right function is get_window_size() without real (but this function is not displayed in the helper)

Instead of resizing your Control try using Layout → Full Rect. Layout is available in the same menu as Select Mode/Pan Mode if any Control Node is selected.

hilfazer | 2018-08-10 14:49

Thanks! I thought layout only placed the control in a position and then didnt update it in game, that’s much easier!

Andrea | 2018-08-12 14:27

:bust_in_silhouette: Reply From: Zylann

To make the first control cover the screen, you don’t need code in the first place.
Select the first control, and in the Layout menu, choose Fullscreen. It will setup the anchors so that it will always fill up the parent area, in your case the screen (if there is no parent control).

Then to place a child control at the bottom left, either use the Layout menu again, or do what you just did already.