How are floating divs supposed to work?

I’m working on some test cases for the Dialog compiler, but I confess I’ve never really understood the specification for floating divs, which makes it hard to be sure if the behavior I’m seeing is intended or not.

Suppose I wanted to make a status bar like this:

Location                    Time
<=========Progress Bar=========>

How would I do that, in current Dialog? Leaving a floating div always returns the cursor to the top line on Z-machine, and I don’t really understand why, or what that’s supposed to accomplish. So the best I can think of is that I’d make three floating divs: “location” with float:left and width:75%, “time” with float:right and width:25%, and “progress bar” with float:left and margin-top:1em. But that doesn’t feel right, and I don’t know if it would work right on Å-machine; don’t divs normally not overlap each other in normal CSS?

My inclination would be to move the cursor back to the original y-position when ending a floating div, rather than the top of the screen, so that you could do location div, time div, (line) (setting the y-position to 2), progress bar div. But I’m hesitant to mess with the functionality of something without understanding why it’s the way it is to begin with.

Oh, yes. I should note that leaving and also entering a floating div resets the Y-position to the top of the status bar, and any divs inside a status bar are considered floating, even if they don’t specify it in the style class.

It seems like the intent is that all floating divs are anchored to the top of the status bar: you can divide things horizontally with floats, and you can divide things vertically with line breaks, but you cannot combine the two. This seems unnecessarily limiting, but there may be an important reason behind it that I can’t see.

I have taken the liberty of editing the title. floating divs for me means the FDIV math coprocessor instruction… (floating-point division) and honestly seeing the title, I was wondering why one talks about floating division instruction on the Z machine…

Best regards from Italy,
dott. Piergiorgio.

It’s a bit confusing, but “divs” is the official term used by Dialog, coming from the <div> HTML tag.

1 Like

Okay, so here’s the official announcement of floating divs.

It seems I’d been conceptualizing them wrong!

The key is that floating divs were replacing an earlier system, involving moving to specific X and Y coordinates in the status bar, and then drawing there. Floating divs aren’t meant to be nesting inside each other like Matryoshka dolls. Instead, floating divs are the new way of specifying those X and Y coordinates! The float parameters determine the X, and the margin-top determines the Y. That’s why drawing multiple floating divs in a row makes them overlap. I’m effectively specifying the same Y coordinate every time.

Now I understand somewhat better why this was done. But I still find it deeply unintuitive. So here’s my new proposal: divs defined with position: absolute will use the old system, always positioned relative to the top left corner of the status bar, while divs defined with position: relative will instead use the current cursor Y position, after drawing the surrounding divs.

So something like this:

(style class @status) height: 2em;
(style class @line) width: 100\%;

(status bar @status) {
    (div @line) { Line One }
    (div @line) { (space 10) Line Two }
}

Will produce the following if @line has position: absolute (the old behavior):

Line One  Line Two

And the following if @line has position: relative:

Line One
          Line Two

What do you all think of this? Does it seem like a reasonable compromise? And most importantly: can someone who actually knows CSS wizardry tell me if this is how it would work in an actual web browser (like the Å-machine interpreter)?

In HTML, the “float” CSS property is used to create several horizontal columns of text, or to position text horizontally next to a large image. (That’s my primitive understanding, there’s likely a lot more to it).

So I’m guessing Dialog is using it in that sense. And since the Z-machine provides no positioning control in the lower window, it only works in the status area?

P.S. As for “absolute” positioning, I personally don’t like the idea of being able to make text areas which overlap (whether it’s on a HTML page or in the Z-machine), but that’s rather a gut feeling rather than being able to say why it’s potentially problematic.