StyleBoxFlat outward borders

Godot Version

4.6

Question

Hi everyone !

Goal: Add an outward outline to my panel_container.
Current situation: The StyleBoxFlatof the panel_containerhas border_width_* properties, but the borders grow inward, shrinking the panel’s content.

Workaround: Add another Panel as the parent of the first Panel and use the expand_margin_* properties of the StyleBoxFlat.

Issue: Since I have already created inherited controls from my panel_container (which is actualy a custom window but I simplified for the example) with border_width_* properties, I now need to update all of them to rearrange the layout.
Proposed solution: Add a toggle to determine whether StyleBoxFlat should draw borders inward or outward.

If cleaner workarounds exist, I would be interested in learning about them! :smiley:

Thanks by advance

You could try setting the StyleBoxFlat.expand_margin_* properties to the size of your border width and the StyleBox.content_margin_* properties to 0 instead of having multiple containers.

But then the borders would be colored with the panel’s color (blue in this case), not white, or did I miss something ?

you can create slighty bigger texture and place it under the original textur if you have problems with borders - but if you’ve set your border color, and width and expanded margins it should work well

Hoooo I understand! I didn’t think of this haha thank you both.

I set border_width_* to 5 and expand_margin_* to 5 and it seems to work perfectly

Edit: Important to set content_margin_* to 0, I don’t know why