Implementing HTML-like floating via the screen language

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
rivvil
Regular
Posts: 26
Joined: Fri Feb 20, 2015 3:05 pm
Location: Russia
Contact:

Implementing HTML-like floating via the screen language

#1 Post by rivvil »

Hi.
Is it possible to implement something like style="float: right" from HTML via the screen language?
For example, I have:

Code: Select all

screen scr:
    frame:
        xsize 300 # frame has fixed width
        ...
I attached schematic image of frame contents illustrating what I want. Note that widths and heights of first, second, third and fourth are not fixed. And some of these elements may be absent at all. So, I can't do something like that:

Code: Select all

frame:
    vbox:
        hbox:
            vbox:
                text 'first'
                text 'second'

            text 'float'

        text 'third'
        text 'fourth'
Attachments
1.png
1.png (2.89 KiB) Viewed 641 times

User avatar
Zetsubou
Miko-Class Veteran
Posts: 522
Joined: Wed Mar 05, 2014 1:00 am
Completed: See my signature
Github: koroshiya
itch: zetsuboushita
Contact:

Re: Implementing HTML-like floating via the screen language

#2 Post by Zetsubou »

I think the closest you'll get to float:right is xalign. Read through a couple of the style properties in the documentation, especially the xalign and xanchor properties.

For the widths of the other elements, you should check for their existence first, then set xsize and ypos accordingly.
Finished games
-My games: Sickness, Wander No More, Max Massacre, Humanity Must Perish, Tomboys Need Love Too, Sable's Grimoire, My Heart Grows Fonder, Man And Elf, A Dragon's Treasure, An Adventurer's Gallantry
-Commissions: No One But You, Written In The Sky, Diamond Rose, To Libertad, Catch Canvas, Love Ribbon, Happy Campers, Wolf Tails

Working on:
Sable's Grimoire 2

https://zetsubou.games

rivvil
Regular
Posts: 26
Joined: Fri Feb 20, 2015 3:05 pm
Location: Russia
Contact:

Re: Implementing HTML-like floating via the screen language

#3 Post by rivvil »

Yeah, I thought about calculating sizes and positions manually... but hoped that it's possible to avoid that :)
BTW, is there way to get size of a widget? Something like that maybe:

Code: Select all

screen scr:
    text 'some text' id 'my_text'
    $ size = get_size('my_text')

philat
Eileen-Class Veteran
Posts: 1909
Joined: Wed Dec 04, 2013 12:33 pm
Contact:

Re: Implementing HTML-like floating via the screen language

#4 Post by philat »

Hmm. This is how I would go about it: have the frame on the right be a separate screen and use it in the first screen. Have a vbox with the first two elements, with a max width and min height to match the frame on the right. Have another vbox with the other two elements. Seems like it should get close enough.

rivvil
Regular
Posts: 26
Joined: Fri Feb 20, 2015 3:05 pm
Location: Russia
Contact:

Re: Implementing HTML-like floating via the screen language

#5 Post by rivvil »

philat, problem is that I don't know heights of first and second in advance. I can't say for sure that first.height + second.height == float.height. It is totally possible, for example, that height of first will be equal to height of float, so second should be full-width.
That's why I need a way to get size of widget during run-time.

philat
Eileen-Class Veteran
Posts: 1909
Joined: Wed Dec 04, 2013 12:33 pm
Contact:

Re: Implementing HTML-like floating via the screen language

#6 Post by philat »

Ah, I see I misunderstood the OP -- I thought if the elements weren't there, you would leave blank spaces. I don't think there's an easy way to do this, but someone more learned than I am in the intricacies of screen language may have a better idea.

Post Reply

Who is online

Users browsing this forum: bonnie_641