Page MenuHome

BLF word-wrapping support, w/ multi-line tooltips
ClosedPublic

Authored by Campbell Barton (campbellbarton) on Aug 29 2015, 1:45 PM.
Tokens
"Love" token, awarded by gandalf3."Love" token, awarded by codemanx."Love" token, awarded by Severin."Love" token, awarded by gregzaal.

Details

Summary
  • Adds support for word wrapping to Blender's BLF font library.
  • Splits lines when width limit is reached or on explicit \n newlines.
  • Tooltips wrap all text automatically (when it exceeds the default tooltip width).

IMHO this patch is ready for master.

Further work:

  • Currently drawing into off-screen pixel buffers (render stamp for eg). doesn't support word-wrapping, (not hard to support though).
  • Later on we could have wrapping for text labels if we want (though we'd need to ensure this works properly with the layout-engine).

As a test this patch makes the render button have a very long tooltip.


API details.

  • Word wrapping is used when BLF_WORD_WRAP flag is enabled.
  • There is a single loop to handle line wrapping, this runs callback, passing in a substring, this way we can avoid code-duplication for all word-wrapped versions of functions... OR... avoid having to add support for word-wrapping directly into each function.
  • The ResultBLF struct was added to be able to get the number of wrapped lines, when calling otherwise unrelated functions such as BLF_draw/BLF_width/BLF_boundbox, which can be passed as the last argument to BLF_*_ex() functions.
  • The ResultBLF struct is used to store the result of drawing (currently only the number of lines wrapped, and the width).

Diff Detail

Repository
rB Blender
Branch
temp-blf-wordwrap

Event Timeline

Campbell Barton (campbellbarton) retitled this revision from to BLF word-wrapping support, w/ multi-line tooltips.

Clamp tooltips within the window size.

BLF: replace pointer to int arg with a struct

scale the tooltip width with the zoom-level

+1 I like the Latin... I don't think standard users will like it :P

Julian Eisel (Severin) edited edge metadata.

Great, checked patch, LGTM

This revision is now accepted and ready to land.Aug 29 2015, 8:03 PM
Campbell Barton (campbellbarton) edited edge metadata.
  • more useful debug print info
  • BLF: Set width for single line ascii drawing BLF_draw_ascii_ex and all wrapped text drawing
  • expose BLF_height_max as an int
  • Move struct inline (was only used in one place)
  • Add Python API calls into wordwrap
  • rename BLF_WORDWRAP -> BLF_WORD_WRAP
  • Merge branch 'master' into temp-blf-wordwrap
  • Rename lines_wrap to lines, since this is used for \n newlines too.
  • Comment implementation details

Guess this can be closed.

Committed to master, closing