Page MenuHome

Multiline descriptions in tooltips
AbandonedPublic

Authored by Julian Eisel (Severin) on Jun 28 2014, 4:14 PM.

Details

Summary

Multiline descriptions in tooltips

Motivation

It is a known issue that Blender's tooltips are useless in a lot of cases. One reason for this, is that the descriptions of the tools need to be really short, in order to prevent oversized tooltips. Developers have to think of a description that is really short but delivers all the information needed. This leads to useless descriptions, making the tooltip itself useless.
Allowing multiline description allows descriptions, which can carry far more information without creating oversized tooltips.

Screenshots

Just as an example to see what is possible:

Further plans

In my personal vision, all tooltips should show the name of the operator/enum item/... and a short description consisting out of a few sentences (max. 2-3 lines). Therefore some further steps are needed:

  • Support descriptions for all Buttons (descriptions in tooltips are currently only implemented for enum-typed buttons afaik)
  • Rewrite a lot of tooltips to make use of multiline descriptions (I'll do a “tooltip marathon”, to update as much tooltips as possible, soon. If anyone is interested to help, you're welcome :)

Diff Detail

Event Timeline

LGTM, one minor remark only.

source/blender/editors/interface/interface_regions.c
385

might be nice to also allow newline characters to be used here as well.

Campbell Barton (campbellbarton) requested changes to this revision.Jun 28 2014, 6:22 PM
Campbell Barton (campbellbarton) added inline comments.
source/blender/editors/interface/interface_regions.c
382

This should really be based on text width, not the number of characters, Especially since some unicode characters can be multi-byte.

I would prefer to move most of the logic here into BLF, So you could give it a string and it could return an array of offsets into the string array given.

This way we could use it anywhere multi-line was needed.

Here's hoping the needed changes are soon made and committed to Master, I see it potentially going quite a ways in reducing the need of trying to look up information in the docs. or on Blenderartists (as long as one tries to keep tooltips inside of 2 lines, or 3 lines for complex operators). I know that tooltips are not intended to be documentation, but as of now you even have to look up information for some of the small stuff.

This would also go hand in hand in creating tooltips for operators that don't have them as of now due to how they would become easier to write. I know I've looked at tools where I wished it had a better tooltip (or actually had a tip).

Julian Eisel (Severin) updated this object.
Julian Eisel (Severin) edited edge metadata.

Rewrote the patch to fulfill the suggestions made by @Antonis Ryakiotakis (psy-fi) and @Campbell Barton (campbellbarton)

After rewriting the entire patch to make it callable from BLI, I got a crash which I wasn't able to solve for some time. However after I saw that some of you are really interested in getting this into master, I got back to it and I finally found out how to fix the crash (just to excuse the ultra long delay ;)

The update contains the following changes:

  • Moved the logic from the old patch to BLI by creating a function BLI_str_make_multilined(const int fontid, const char *src, const float maxwidth)
  • The maximum width is now defined in pixels rather than the number of characters
  • Support for the multiline character '\n'
Julian Eisel (Severin) edited edge metadata.

Talked on IRC and this should really be handled in BLF, using some API calls,
eg:

  • BLF_draw_wrap(..., width),
  • BLF_boundbox_wrap(..., width, &nlines);

Then any part of blender can request some wrapped width to draw into and BLF can do the rest.

Campbell Barton (campbellbarton) requested changes to this revision.Aug 5 2014, 10:02 PM
Campbell Barton (campbellbarton) edited edge metadata.
This revision now requires changes to proceed.Aug 5 2014, 10:02 PM

Edit, BLF_boundbox could be used in this case, so words just wrap at the bounds.

Some suggestions for API...

  • BLF_draw_lines (like BLF_draw but supports \n)
  • BLF_draw_wrap (like BLF_draw, but split at word white-space word boundaries), using the boundbox.
  • we would want a function to return the number of lines too (I think BLF_width_and_height_multiline(..., &nlines))

having _multiline suffix all over isnt ideal,

Uploaded a new diff which implements word-wrapping in BLF. D1493