|
Zappy GUI
C++ graphic client: renderer, camera, network
|
A configurable, stateful tooltip panel. More...
#include <TooltipWidget.hpp>
Inheritance diagram for TooltipWidget:
Collaboration diagram for TooltipWidget:Classes | |
| struct | Line |
Public Types | |
| enum class | Anchor { None , TopLeft , TopCenter , TopRight , MiddleLeft , Center , MiddleRight , BottomLeft , BottomCenter , BottomRight } |
| enum class | TextAlign { Left , Center } |
Public Member Functions | |
| TooltipWidget ()=default | |
| ~TooltipWidget () override=default | |
| TooltipWidget & | addLine (const std::string &text, Color color=WHITE) |
| Adds a single-color text line. | |
| TooltipWidget & | addColoredLine (const std::vector< std::string > &segments, const std::vector< Color > &colors) |
| Adds a line with multiple colored segments (inline spans). | |
| TooltipWidget & | clearLines () |
| Removes all lines. | |
| TooltipWidget & | setPosition (float x, float y) |
| Absolute position. Sets anchor to None. | |
| TooltipWidget & | setAnchor (Anchor anchor, float margin=10.0f) |
| Auto-positioning relative to screen edges. | |
| TooltipWidget & | setMinWidth (float minWidth) |
| Override minimum panel width (0 = fit to content). | |
| TooltipWidget & | setExtraBottomPadding (float px) |
| Adds extra blank space at the bottom of the box (e.g. to reserve room for a button). | |
| TooltipWidget & | setTextAlign (TextAlign align) |
| TooltipWidget & | setBackgroundColor (Color color) |
| TooltipWidget & | setBackgroundAlpha (unsigned char alpha) |
| TooltipWidget & | setBorderColor (Color color) |
| TooltipWidget & | setBorderThickness (int thickness) |
| TooltipWidget & | setPadding (int padding) |
| void | draw (int scaledFontSize) const override |
| Draws the widget. | |
| bool | handleInput () override |
| Always returns false — tooltip panels are display-only. | |
| Rectangle | getLastBounds () const |
| Returns the bounding rectangle for the last drawn frame. Useful for positioning sibling widgets (e.g. a button below the panel). | |
Public Member Functions inherited from IWidget | |
| virtual | ~IWidget ()=default |
Private Member Functions | |
| Vector2 | _resolvePosition (float boxWidth, float boxHeight) const |
Private Attributes | |
| std::vector< Line > | _lines |
| float | _x = 0.0f |
| float | _y = 0.0f |
| Anchor | _anchor = Anchor::None |
| float | _margin = 10.0f |
| float | _minWidth = 0.0f |
| float | _extraBottomPadding = 0.0f |
| Color | _bgColor = {20, 25, 35, 220} |
| unsigned char | _bgAlpha = 220 |
| Color | _borderColor = {60, 70, 90, 200} |
| int | _borderThickness = 2 |
| int | _padding = 12 |
| TextAlign | _textAlign = TextAlign::Left |
| Rectangle | _lastBounds = {} |
A configurable, stateful tooltip panel.
Wraps TooltipRenderer::Builder to provide an IWidget-compatible component. Content is built once via the fluent API and drawn each frame until changed. Never handles input (handleInput always returns false) — it is display-only.
Positioning modes:
Definition at line 22 of file TooltipWidget.hpp.
|
strong |
| Enumerator | |
|---|---|
| None | |
| TopLeft | |
| TopCenter | |
| TopRight | |
| MiddleLeft | |
| Center | |
| MiddleRight | |
| BottomLeft | |
| BottomCenter | |
| BottomRight | |
Definition at line 24 of file TooltipWidget.hpp.
|
strong |
| Enumerator | |
|---|---|
| Left | |
| Center | |
Definition at line 66 of file TooltipWidget.hpp.
|
default |
|
overridedefault |
|
private |
Definition at line 94 of file TooltipWidget.cpp.
References _anchor, _margin, _x, _y, BottomCenter, BottomLeft, BottomRight, Center, MiddleLeft, MiddleRight, None, TopCenter, TopLeft, and TopRight.
Referenced by draw().
Here is the caller graph for this function:| TooltipWidget & TooltipWidget::addColoredLine | ( | const std::vector< std::string > & | segments, |
| const std::vector< Color > & | colors | ||
| ) |
Adds a line with multiple colored segments (inline spans).
Definition at line 16 of file TooltipWidget.cpp.
References _lines.
Referenced by EntityTooltipWidget::_rebuild(), and WinScreen::_rebuildPanel().
Here is the caller graph for this function:| TooltipWidget & TooltipWidget::addLine | ( | const std::string & | text, |
| Color | color = WHITE |
||
| ) |
Adds a single-color text line.
Definition at line 10 of file TooltipWidget.cpp.
References _lines.
Referenced by EntityTooltipWidget::_rebuild(), WinScreen::_rebuildPanel(), and PlayerPanel::handleInput().
Here is the caller graph for this function:| TooltipWidget & TooltipWidget::clearLines | ( | ) |
Removes all lines.
Definition at line 25 of file TooltipWidget.cpp.
References _lines.
Referenced by EntityTooltipWidget::_rebuild(), WinScreen::_rebuildPanel(), and PlayerPanel::handleInput().
Here is the caller graph for this function:
|
overridevirtual |
Draws the widget.
| scaledFontSize | Base font size for UI scaling. |
Implements IWidget.
Definition at line 125 of file TooltipWidget.cpp.
References _bgAlpha, _bgColor, _borderColor, _borderThickness, _extraBottomPadding, _lastBounds, _lines, _minWidth, _padding, _resolvePosition(), _textAlign, Center, TextRenderer::draw(), and TextRenderer::measure().
Referenced by EntityTooltipWidget::draw(), PlayerPanel::draw(), and WinScreen::draw().
Here is the call graph for this function:
Here is the caller graph for this function:
|
inline |
Returns the bounding rectangle for the last drawn frame. Useful for positioning sibling widgets (e.g. a button below the panel).
Definition at line 83 of file TooltipWidget.hpp.
References _lastBounds.
Referenced by EntityTooltipWidget::_positionButton(), WinScreen::draw(), and PlayerPanel::handleInput().
Here is the caller graph for this function:
|
inlineoverridevirtual |
Always returns false — tooltip panels are display-only.
Implements IWidget.
Definition at line 79 of file TooltipWidget.hpp.
| TooltipWidget & TooltipWidget::setAnchor | ( | Anchor | anchor, |
| float | margin = 10.0f |
||
| ) |
Auto-positioning relative to screen edges.
| margin | Pixel gap from the anchored edge. |
Definition at line 39 of file TooltipWidget.cpp.
References _anchor, and _margin.
Referenced by EntityTooltipWidget::EntityTooltipWidget(), PlayerPanel::handleInput(), and WinScreen::WinScreen().
Here is the caller graph for this function:| TooltipWidget & TooltipWidget::setBackgroundAlpha | ( | unsigned char | alpha | ) |
Definition at line 70 of file TooltipWidget.cpp.
References _bgAlpha.
Referenced by EntityTooltipWidget::EntityTooltipWidget().
Here is the caller graph for this function:| TooltipWidget & TooltipWidget::setBackgroundColor | ( | Color | color | ) |
Definition at line 64 of file TooltipWidget.cpp.
References _bgColor.
Referenced by EntityTooltipWidget::EntityTooltipWidget(), and WinScreen::WinScreen().
Here is the caller graph for this function:| TooltipWidget & TooltipWidget::setBorderColor | ( | Color | color | ) |
Definition at line 76 of file TooltipWidget.cpp.
References _borderColor.
Referenced by EntityTooltipWidget::EntityTooltipWidget(), and WinScreen::WinScreen().
Here is the caller graph for this function:| TooltipWidget & TooltipWidget::setBorderThickness | ( | int | thickness | ) |
Definition at line 82 of file TooltipWidget.cpp.
References _borderThickness.
Referenced by EntityTooltipWidget::EntityTooltipWidget(), and WinScreen::WinScreen().
Here is the caller graph for this function:| TooltipWidget & TooltipWidget::setExtraBottomPadding | ( | float | px | ) |
Adds extra blank space at the bottom of the box (e.g. to reserve room for a button).
Definition at line 52 of file TooltipWidget.cpp.
References _extraBottomPadding.
Referenced by EntityTooltipWidget::_rebuild(), PlayerPanel::handleInput(), and WinScreen::WinScreen().
Here is the caller graph for this function:| TooltipWidget & TooltipWidget::setMinWidth | ( | float | minWidth | ) |
Override minimum panel width (0 = fit to content).
Definition at line 46 of file TooltipWidget.cpp.
References _minWidth.
Referenced by EntityTooltipWidget::_rebuild(), PlayerPanel::handleInput(), and WinScreen::WinScreen().
Here is the caller graph for this function:| TooltipWidget & TooltipWidget::setPadding | ( | int | padding | ) |
Definition at line 88 of file TooltipWidget.cpp.
References _padding.
Referenced by EntityTooltipWidget::EntityTooltipWidget(), and WinScreen::WinScreen().
Here is the caller graph for this function:| TooltipWidget & TooltipWidget::setPosition | ( | float | x, |
| float | y | ||
| ) |
| TooltipWidget & TooltipWidget::setTextAlign | ( | TextAlign | align | ) |
Definition at line 58 of file TooltipWidget.cpp.
References _textAlign.
Referenced by PlayerPanel::handleInput(), and WinScreen::WinScreen().
Here is the caller graph for this function:
|
private |
Definition at line 95 of file TooltipWidget.hpp.
Referenced by _resolvePosition(), setAnchor(), and setPosition().
|
private |
Definition at line 101 of file TooltipWidget.hpp.
Referenced by draw(), and setBackgroundAlpha().
|
private |
Definition at line 100 of file TooltipWidget.hpp.
Referenced by draw(), and setBackgroundColor().
|
private |
Definition at line 102 of file TooltipWidget.hpp.
Referenced by draw(), and setBorderColor().
|
private |
Definition at line 103 of file TooltipWidget.hpp.
Referenced by draw(), and setBorderThickness().
|
private |
Definition at line 98 of file TooltipWidget.hpp.
Referenced by draw(), and setExtraBottomPadding().
|
mutableprivate |
Definition at line 107 of file TooltipWidget.hpp.
Referenced by draw(), and getLastBounds().
|
private |
Definition at line 91 of file TooltipWidget.hpp.
Referenced by addColoredLine(), addLine(), clearLines(), and draw().
|
private |
Definition at line 96 of file TooltipWidget.hpp.
Referenced by _resolvePosition(), and setAnchor().
|
private |
Definition at line 97 of file TooltipWidget.hpp.
Referenced by draw(), and setMinWidth().
|
private |
Definition at line 104 of file TooltipWidget.hpp.
Referenced by draw(), and setPadding().
|
private |
Definition at line 105 of file TooltipWidget.hpp.
Referenced by draw(), and setTextAlign().
|
private |
Definition at line 93 of file TooltipWidget.hpp.
Referenced by _resolvePosition(), and setPosition().
|
private |
Definition at line 94 of file TooltipWidget.hpp.
Referenced by _resolvePosition(), and setPosition().