Bring back floating images in font renderer

Bug #1751620 reported by GunChleoc
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
widelands
Fix Released
Wishlist
Unassigned

Bug Description

We had the capability of having text float around images in the old font renderer. The new renderer can't do that yet. Would be nice e.g. for campaign dialogs with character images. A second use case are long lore strings in the building help.

Related branches

GunChleoc (gunchleoc)
description: updated
Revision history for this message
Notabilis (notabilis27) wrote :

I tried to implement it, see the attachment for the current state.
However, I had to change the definition of li_image() to make it work. The current (trunk) definition is:

function li_image(imagepath, text)
   return
      div("width=100%",
         div(p(vspace(6) .. img(imagepath) .. space(6))) ..
         div(p(space(6))) ..
         div("width=*", p(vspace(6) .. text .. vspace(12)))
      )
end

I changed it to:

      div("width=100%",
         div("float=left width=134", p(img(imagepath, "width=128"))) ..
         p(text)
      )

The primary change is to add the floating div inside the div containing the text. Due to the hierarchical layouting done in the code, I needed them to be on the same "div-level" to interact correctly. Otherwise, the div around the text creates a rectangular box that is placed next to the image but does not flow around it. It could probably be made to work, but would break the hierarchical structure of the code.
The space() calls around image and text doesn't really seem to do anything useful, so I dropped them. The fixed width of the image and the div is a (bad) hack to gain some horizontal space between image and text. Unfortunately I wasn't able to do this with space() calls, they seem to be ignored.

Revision history for this message
GunChleoc (gunchleoc) wrote :

I see only 1 problem with the new code, and that's the hard-coded width parameters - we will want this function for both the images in the help section and the campaign portraits, and they have really different sizes. Also, this will break if the size of the multilineeditbox is changed - story message boxes come in different sizes.

Revision history for this message
Notabilis (notabilis27) wrote :

Turns out there is a padding attribute which can be used to specify a fixed space between image and text. I uploaded a branch with my changes.

GunChleoc (gunchleoc)
Changed in widelands:
milestone: none → build20-rc1
status: Confirmed → Fix Committed
Revision history for this message
GunChleoc (gunchleoc) wrote :

Fixed in build20-rc1

Changed in widelands:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Bug attachments

Remote bug watches

Bug watches keep track of this bug in other bug trackers.