Viewport cutting around it's children's 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
User avatar
Kia
Eileen-Class Veteran
Posts: 1040
Joined: Fri Aug 01, 2014 7:49 am
Deviantart: KiaAzad
Discord: Kia#6810
Contact:

Viewport cutting around it's children's children.

#1 Post by Kia »

I was messing with viewport and found a behavior that doesn't make sense to me.

Code: Select all

screen vptest:
    modal True
    vbox spacing 10:
        viewport:
            yfill False
            frame background "#fff4" xfill True:
                fixed fit_first True xalign .5:
                    frame xsize 800:
                        text "inside a viewport."
                    text "Some name":
                        substitute False
                        xalign 0.0 xanchor 1.0 xoffset -30
        fixed:
            frame background "#fff4" xfill True:
                fixed fit_first True xalign .5:
                    frame xsize 800:
                        text "inside something else."
                    text "this is":
                        substitute False
                        xalign 0.0 xanchor 1.0 xoffset -30

label start:
    call screen vptest
    "ssdsd"

    return
The viewport seems to cut around it's children even multiple levels down. Anything offsetted outside the child area is not rendered. I assume it's related to the `child_size` mentioned in the docs, but `child_size(None,None)` doesn't seem to have any effect.

User avatar
Kia
Eileen-Class Veteran
Posts: 1040
Joined: Fri Aug 01, 2014 7:49 am
Deviantart: KiaAzad
Discord: Kia#6810
Contact:

Re: Viewport cutting around it's children's children.

#2 Post by Kia »

Anybody has any ideas of why this happens and how to circumvent it?

User avatar
m_from_space
Miko-Class Veteran
Posts: 957
Joined: Sun Feb 21, 2021 3:36 am
Contact:

Re: Viewport cutting around it's children's children.

#3 Post by m_from_space »

I'm not sure what exactly you are talking about to be honest.

Are you referring to your text "Some name" not showing up inside the viewport? The reason is, that you are positioning it outside of the screen (first you set xalign 0.0, which means xpos and xanchor to 0.0, then you set xanchor back to 1.0 and that means the right side of the text is going to align with the left side of the screen, pushing it outside. the xoffset only moves it further away). Just remove the xanchor 1.0 if you want to see it.

Maybe I am not understanding, what you are expecting here.

User avatar
Kia
Eileen-Class Veteran
Posts: 1040
Joined: Fri Aug 01, 2014 7:49 am
Deviantart: KiaAzad
Discord: Kia#6810
Contact:

Re: Viewport cutting around it's children's children.

#4 Post by Kia »

If you change the offset to a small number on the positive like 10, you'll notice that the text isn't outside of the screen, it's on the same place as the first example, but being cut off because it's just outside of the fixed container.
The only difference between the two is: one is indirectly inside a viewport.

User avatar
m_from_space
Miko-Class Veteran
Posts: 957
Joined: Sun Feb 21, 2021 3:36 am
Contact:

Re: Viewport cutting around it's children's children.

#5 Post by m_from_space »

Okay now I get you. The following screen makes your point much clearer. It only seems to cut top and left though.

Code: Select all

screen vptest:
    modal True
    vbox spacing 10:
        viewport:
            area (100, 100, 600, 400)
            text "viewport" xpos 0 ypos 0
            frame:
                background "#ffa9"
                fixed:
                    frame:
                        background "#aff9"
                        area (50, 50, 200, 50)
                        text "frame1_textA_textA_textA_textA" xoffset -20 yoffset -10
                        text "frame1_textB_textB_textB_textB" xoffset -20 ypos 35
            frame:
                area (300, 150, 200, 50)
                background "#afa9"
                text "frame2_textA" xoffset -20 yoffset -10
                text "frame2_textB" xpos 160 ypos 35
            text "viewport_text" xpos 250 ypos 250

User avatar
Kia
Eileen-Class Veteran
Posts: 1040
Joined: Fri Aug 01, 2014 7:49 am
Deviantart: KiaAzad
Discord: Kia#6810
Contact:

Re: Viewport cutting around it's children's children.

#6 Post by Kia »

Nice find, it never crossed my mind to test the other sides.

User avatar
m_from_space
Miko-Class Veteran
Posts: 957
Joined: Sun Feb 21, 2021 3:36 am
Contact:

Re: Viewport cutting around it's children's children.

#7 Post by m_from_space »

I'm still unsure if this is really a valid bug or just bad programming. When you create frame, your intention should be to put stuff inside that frame and not put it outside of it. Because if you want stuff outside of that frame, why create a frame in the first place?

User avatar
Kia
Eileen-Class Veteran
Posts: 1040
Joined: Fri Aug 01, 2014 7:49 am
Deviantart: KiaAzad
Discord: Kia#6810
Contact:

Re: Viewport cutting around it's children's children.

#8 Post by Kia »

There are several good reasons to arrange elements the way I've done. The one in this case is: It makes positioning elements much easier. You can't really do something like this in any other reasonable way:

Code: Select all

    frame:
        align .5,.5 xysize 800,600 background "#523"
        text "something " xanchor 1.0 xoffset -10
Imagine the frame's size is not a set size and changes depending on the content, and the text would change in size. All other tricks that might be able to mimic the look would go out of the window.

User avatar
m_from_space
Miko-Class Veteran
Posts: 957
Joined: Sun Feb 21, 2021 3:36 am
Contact:

Re: Viewport cutting around it's children's children.

#9 Post by m_from_space »

Well, you should probably create a bug report on https://github.com/renpy/renpy/issues

Congratz on 1000 posts by the way! :)

User avatar
Kia
Eileen-Class Veteran
Posts: 1040
Joined: Fri Aug 01, 2014 7:49 am
Deviantart: KiaAzad
Discord: Kia#6810
Contact:

Re: Viewport cutting around it's children's children.

#10 Post by Kia »

m_from_space wrote: Thu Aug 11, 2022 7:49 am Well, you should probably create a bug report
will do, just wanted to confirm that it's really a bug before doing so.
m_from_space wrote: Thu Aug 11, 2022 7:49 am Congratz on 1000 posts by the way! :)
Thank you ^^

Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot]