Another very short update.

Implemented tooltips!  (Imagine there’s a cursor in there — screen captures don’t capture the cursor.)

You may notice that the style tags from Label work just fine in tooltips.

A bit of technical detail on what I’m doing here…  The Widget class has a few static members and methods relating to tooltips.  Some members include:

  • A generic tooltip label-based widget.  This generic label is used for displaying tooltips such as the above, where all you want is some formatted text.  It’s up to the client to instantiate this widget, since there’s no way that aui will know things like what style to use, how wide to make it (to best suit the UI of the client) and stuff like that.  I could theoretically have that information passed in to some initialization method, but I like this for now.
  • A reference to the currently active tooltip widget.  This may or may not point at the generic label mentioned above.  A widget can provide its own custom widget as a tooltip, which will be handy for things like WoW-style equipment comparison tooltips, which are made up of a bunch of other widgets.
  • A reference to the control that called the tooltip.  During the tooltip updating process, this caller widget is polled to find out whether it still needs to be displaying a tooltip.  As long as this poll continues to return true, the tooltip will never be hidden.  (Note to future self: the fact that you have a memory leak due to controls sticking around forever is probably due to controls being deleted while they still have a tooltip active.)

It’s up to the client to call Widget.updateTooltip() and Widget.renderTooltip() in their main widget’s onUpdate() and onRender(), respectively.  This ensures that the tooltip exists within the input area — and renders in the same scale as — the main widget.

On a side note, I added a PanelLabel widget, which is effectively just a Label, but it will render a panel in the specified style behind the text.  Did this because it trivialized making the generic tooltip.  🙂

Next step: scrollbars!  After that, I should be able to dig into some Tako-specific screens.  Scrollbars are the first major compound widget I’ll be making, so here’s hoping that aui’s structure works out!

Advertisement