#I can't figure out how to make NinePatchRect bigger than its content (See screenshots)

4 messages · Page 1 of 1 (latest)

smoky inlet
#

This has been an issue for over a month. I'm trying to make a RPG and I have a basic setup for a battle screen.

I have an AspectRatioContainer to make sure the UI stays consistent for the 5 boxes reserved for the playable characters currently in the party, each separated evenly via a HBoxContainer.

Problem is as you can clearly see the NinePatchRect box is very small, it's smaller than the text displayed "inside" it infact. I want the box to retain the aspect ratio, but I also want the box to also be bigger. It should fill the entire AspectRatioContainer vertically atleast.

It's probably a setting or something I haven't thought of when trying to fix the problem. Using Godot 3.4.

I've already tried to do these things to fix this issue to no avail:
-I changed the size flags.
-I changed the grow direction.
-I changed the margin.
-I physically changed the size of the node, but it resets immedately afterwards.
-I changed the hiearchy several times whilst keeping the NinePatchRect box inside the aspect ratio node.
-I changed the anchor, nothing too.

The only thing that "fixes" the problem is to place the NinePatchRect outside the AspectRatioContainer. At this point, the NinePatchRect actually extends fully vertically and the text, as seen in the screenshots, correctly shows up inside the box, but that completely defeats the point.

It's a RPG if I have a character that has 9999 HP and another who has only 1 HP then the boxes won't be the same width. Just imagine how much space "1/1" takes compared to "9999/9999". Because it's uneven it triggers my nonexistent OCD. This is why I even use AspectRatioContainer.

So, is there a way to expand NinePatchRect past the borders of AspectRatioContainer? Is there a way to make this work?

I'm willing to use a different node from NinePatchRect. If there's a way to get a similar UI or hell if it's possible to keep the aspect ratio of the box w/o AspectRatioContaier (or programmatically instead) then I'm all ears.

slender meteor
#

What about changing rect min size

random steeple
#

I tried recreating that as best I could and I seem to have done what you want (ninepatch expands vertically and horizontally, and the text size doesn't change the width of the ninepatch:

create CenterContainer

  • create HBoxContainer As its child
    • create AspectRatioContainer as its child
      • create NinePatchRect as its child
      • create CenterContainer as its child
        • create VBoxContainer as its child with bunch of Label as children

Now settings:

Set the labels to their values.
Set the sprite for NinePatchRect.
Set Stretch Mode in AspectRatioContainer to Cover and look for Min Size then set X to something like 90. this sets the minimum width.
In VBoxContainer set Min Size X to something smaller so you'll have a margin, like 80.
Now select all Label nodes and check Clip Text this way the width stays at 80 or whatever you set in Min Size.

now the size wont change whether its Lv. 9000 or Lv. 5.

random steeple
#

try it out here, you can duplicate AspectRatioContainer to add the other characters