ZenitUI
Retained-mode C++20 UI framework
Loading...
Searching...
No Matches
ZenitUI::UI::Tooltip Class Reference

A portal-based hover label. More...

#include <Tooltip.hpp>

Inheritance diagram for ZenitUI::UI::Tooltip:
[legend]

Public Member Functions

 Tooltip (std::string text)
 Construct a tooltip with the given text.
void setText (std::string text)
const std::string & getText () const
void setAnchor (std::weak_ptr< Layout > a)
 Change the anchor (advanced).
void setShowDelay (float s)
 Change the delay in seconds before the tooltip appears.
void show ()
 Begin the countdown to show.
void hide ()
 Hide immediately and cancel any pending countdown.
void arrange (Rect) override
 No-op: the tooltip owns its rect via onUpdate.
Public Member Functions inherited from ZenitUI::TLayout< Tooltip, Panel >
 TLayout (Args &&...args)
 Forward constructor arguments to Base.
std::shared_ptr< Tooltip > cls (const std::string &name)
 Fluent addClass; returns typed shared_ptr<Derived>.
std::shared_ptr< Tooltip > id (const std::string &node_id)
 Fluent setId; returns typed shared_ptr<Derived>.
std::shared_ptr< Tooltip > withRef (const std::string &r)
 Fluent setRef; returns typed shared_ptr<Derived>.
std::shared_ptr< Tooltip > size (Value w, Value h)
 Fluent setSize; returns typed shared_ptr<Derived>.
std::shared_ptr< Tooltip > passThrough (bool p=true)
 Fluent setPassThrough; returns typed shared_ptr<Derived>.
std::shared_ptr< Tooltip > with (std::shared_ptr< Layout > c)
 Fluent addChild; returns typed shared_ptr<Derived>.
std::shared_ptr< Tooltip > self ()
 Return shared_from_this() statically cast to Derived.

Static Public Member Functions

static std::shared_ptr< Tooltip > attach (std::shared_ptr< Layout > owner, std::string text, float showDelay=0.4f)
 Attach a tooltip to owner.
Static Public Member Functions inherited from ZenitUI::TLayout< Tooltip, Panel >
static std::shared_ptr< Tooltip > create (Args &&...args)
 Construct a shared_ptr<Derived> and call onBuild().

Protected Member Functions

void onBuild () override
 Hook: called once after create() finishes constructing the object.
void onUpdate (float dt) override

Detailed Description

A portal-based hover label.

Style tag: "Tooltip". Portal by default. Not interactive, does not block raycast. arrange() is a no-op; the tooltip positions itself via onUpdate once the label has been measured.

Constructor & Destructor Documentation

◆ Tooltip()

ZenitUI::UI::Tooltip::Tooltip ( std::string text)
explicit

Construct a tooltip with the given text.

Note
Use Tooltip::attach unless you are managing the anchor and parenting manually.

Member Function Documentation

◆ attach()

std::shared_ptr< Tooltip > ZenitUI::UI::Tooltip::attach ( std::shared_ptr< Layout > owner,
std::string text,
float showDelay = 0.4f )
static

Attach a tooltip to owner.

Parameters
ownerNode to attach to. Must be non-null.
textText to display.
showDelaySeconds the pointer must remain over the owner before the tooltip appears.
Returns
The created tooltip, for further customization.
Examples
00_demo/main.cpp, and 10_overlays_cursors/main.cpp.

◆ onBuild()

void ZenitUI::UI::Tooltip::onBuild ( )
overrideprotectedvirtual

Hook: called once after create() finishes constructing the object.

Reimplemented from ZenitUI::TLayout< Tooltip, Panel >.

◆ show()

void ZenitUI::UI::Tooltip::show ( )

Begin the countdown to show.

Idempotent while hovering.


The documentation for this class was generated from the following file: