How to get frame to autoscale when having fixed children?

Discuss how to use the Ren'Py engine to create visual novels and story-based games. New releases are announced in this section.
Forum rules
This is the right place for Ren'Py help. Please ask one question per thread, use a descriptive subject like 'NotFound error in option.rpy' , and include all the relevant information - especially any relevant code and traceback messages. Use the code tag to format scripts.
Post Reply
Message
Author
newbiemate
Regular
Posts: 85
Joined: Tue Dec 19, 2017 1:36 pm
Contact:

How to get frame to autoscale when having fixed children?

#1 Post by newbiemate »

I have this code:

Code: Select all

screen test:
    frame:
        xpos 100
        ypos 100

        vbox:
            fixed:
                text "hello"
The "fixed:" code seems to expand the vbox or frame to a huge size, probably to the screen size. This is the result: https://imgur.com/a/sKxwzc2

How can I get the frame to auto-scale with the child? So if the text was longer, like "blahblahblahblahblah", then the frame's width auto-scales to hold that text, and nothing more?

User avatar
Alex
Lemma-Class Veteran
Posts: 3094
Joined: Fri Dec 11, 2009 5:25 pm
Contact:

Re: How to get frame to autoscale when having fixed children?

#2 Post by Alex »

Get rid of 'fixed", neh?

newbiemate
Regular
Posts: 85
Joined: Tue Dec 19, 2017 1:36 pm
Contact:

Re: How to get frame to autoscale when having fixed children?

#3 Post by newbiemate »

Is it standard behavior to have "fixed" take up the whole screen?

User avatar
MaydohMaydoh
Regular
Posts: 165
Joined: Mon Jul 09, 2018 5:49 am
Projects: Fuwa Fuwa Panic
Tumblr: maydohmaydoh
Location: The Satellite of Love
Contact:

Re: How to get frame to autoscale when having fixed children?

#4 Post by MaydohMaydoh »

"This creates an area to which children can be added. By default, the fixed expands to fill the available area, but the xmaximum and ymaximum properties can change this."
https://www.renpy.org/doc/html/screens.html#fixed

And as far as I'm aware, you should only really use fixed if you have no other container. I think.

newbiemate
Regular
Posts: 85
Joined: Tue Dec 19, 2017 1:36 pm
Contact:

Re: How to get frame to autoscale when having fixed children?

#5 Post by newbiemate »

Ah yeah, I figured xmaximum and such would do it, and it does work. However, I'm using fixed because I wanted to stack different elements together. ie, stacking a screen text and imagebutton together is done using fixed.

I was hoping the frame would still auto-calculate the size of the children, but because fixed screws up, I'll have to precalculate the sizes instead. Unless there is a more friendly way to stack a text on top of an imagebutton?

User avatar
MaydohMaydoh
Regular
Posts: 165
Joined: Mon Jul 09, 2018 5:49 am
Projects: Fuwa Fuwa Panic
Tumblr: maydohmaydoh
Location: The Satellite of Love
Contact:

Re: How to get frame to autoscale when having fixed children?

#6 Post by MaydohMaydoh »

Don't know if this would help you or not but instead of using imagebuttons with text, I use textbutton and just change the background, hover_background etc.

Also I never use fixed so I'm not sure how it works, but try giving it the xfit False and yfit False styles.
https://www.renpy.org/doc/html/style_pr ... properties

Post Reply

Who is online

Users browsing this forum: Bing [Bot]