godot: StyleBoxTexture expand margins not working and bleeding out to bottom
Operating system or device - Godot version: 3.0 master. Working fine in 2.2
Issue description: EDIT: It seems this issue only persists on my system, as toger5 and me found out now. The following discussion was made in the stance of thinking this is a general bug or was never implemented correctly.
On my system, I have issues with StyleBoxTexture
s: The expand margin has absolutely no effect, and style boxes bleed out to the bottom.
Have a look at the WindowDialog
image. Remember that the titlebar at the top and the chrome of the window expand into negative coordinates and the inner panel (“client area”) of the windows starts at (0,0), to the confusion of some users.
With the margins defined in default_theme.cpp
visualized on the image, it will look like this:
Ref<StyleBoxTexture> style_pp_win = sb_expand(make_stylebox(popup_window_png, 10, 26, 10, 8), 8, 24, 8, 6);
- The red lines are the margin (10, 26, 10, 8) to cut out the 9-patch frames determining the stretching parts of the image, those are fine and not in question here.
- The green area is an outset (8, 24, 8, 6), mostly used for all those tiny 2-pixel shadows around tabs, buttons (god I wish we get a flat design soon 👅 ) and in this case , as said, for the whole window chrome. They’re easily configurable with
sb_expand()
.
Now if I retrieve this StyleBoxTexture
and call sb->draw(canvas, Rect2(0, 0, 100, 100))
, you expect the areas covered by the expand margins to be drawn outside of the Rect2
. Sadly, this is not the case on my system.
On top of that, I have a “bleeding” issue, styleboxes extend towards the bottom with no sense:
Since I have this issue since some time, I unknowingly wrote idiotic hilarious WindowDialog
drawing code like this to get that done:
Ref<StyleBox> panel = get_stylebox("panel", "WindowDialog");
int margin_left = static_cast<int>(panel->get_margin(MARGIN_LEFT));
int margin_top = static_cast<int>(panel->get_margin(MARGIN_TOP));
int margin_right = static_cast<int>(panel->get_margin(MARGIN_RIGHT));
int margin_bottom = static_cast<int>(panel->get_margin(MARGIN_BOTTOM));
Rect2 rect;
rect.pos.x = -margin_left;
rect.pos.y = -margin_top;
rect.size.width = size.width + margin_left + margin_right;
rect.size.height = size.height + margin_top + margin_bottom;
panel->draw(canvas, rect);
I was stupid enough to not query the expanded margin with get_expand_margin_size
and used the wrong 9-patch margins, but that’s barely noticable in the buggy Godot UI on my PC.
Anyway, what’s important is that all this ridiculous code is necessary for me draw the expanded / outset stuff really outside of the rect
given.
PS: Someone recently fuzzled around with the Panel
content margins I believe, everything looks thinned out and ugly, on my system now. This is possibly related.
About this issue
- Original URL
- State: closed
- Created 7 years ago
- Comments: 19 (19 by maintainers)
Mistake, meant to archive #8365.
Yeah, I changed it to
Now the panels dont look thinned out anymore aswell! Looks like someone didn’t test or is kinda blind.
There we go: Oh you were faster… (as an excuse im on my phone…)