Zappy GUI
C++ graphic client: renderer, camera, network
Loading...
Searching...
No Matches
TooltipRenderer::Builder Class Reference

#include <TooltipRenderer.hpp>

+ Collaboration diagram for TooltipRenderer::Builder:

Classes

struct  ColoredSegment
 

Public Member Functions

 Builder ()
 
BuilderaddLine (const std::string &text, Color color=WHITE)
 Adds a single-color line to the tooltip.
 
BuilderaddColoredText (const std::vector< std::string > &segments, const std::vector< Color > &colors)
 Adds a line with multiple colored segments.
 
BuildersetBackgroundColor (Color color)
 Sets the background color (ignoring alpha).
 
BuildersetBackgroundAlpha (unsigned char alpha)
 Sets the background alpha transparency.
 
BuildersetBorderColor (Color color)
 Sets the border color.
 
BuildersetBorderThickness (int thickness)
 Sets the border thickness.
 
BuildersetFontSize (int size)
 Sets the font size for all text.
 
BuildersetPadding (int padding)
 Sets the internal padding.
 
BuildersetAnchor (Anchor anchor)
 Sets the anchor point for positioning.
 
void draw (Vector2 position)
 Draws the tooltip at the given position.
 

Private Member Functions

Vector2 _calculateAnchoredPosition (Vector2 position, int boxWidth, int boxHeight) const
 

Private Attributes

std::vector< std::vector< ColoredSegment > > _lines
 
Color _bgColor
 
unsigned char _bgAlpha
 
Color _borderColor
 
int _borderThickness
 
int _fontSize
 
int _padding
 
Anchor _anchor
 

Detailed Description

Definition at line 27 of file TooltipRenderer.hpp.

Constructor & Destructor Documentation

◆ Builder()

TooltipRenderer::Builder::Builder ( )

Definition at line 9 of file TooltipRenderer.cpp.

Member Function Documentation

◆ _calculateAnchoredPosition()

Vector2 TooltipRenderer::Builder::_calculateAnchoredPosition ( Vector2  position,
int  boxWidth,
int  boxHeight 
) const
private

◆ addColoredText()

TooltipRenderer::Builder & TooltipRenderer::Builder::addColoredText ( const std::vector< std::string > &  segments,
const std::vector< Color > &  colors 
)

Adds a line with multiple colored segments.

Parameters
segmentsVector of text segments.
colorsVector of colors (must match segments size).
Returns
Reference to this builder.
Exceptions
std::invalid_argumentif segments.size() != colors.size().

Definition at line 26 of file TooltipRenderer.cpp.

◆ addLine()

TooltipRenderer::Builder & TooltipRenderer::Builder::addLine ( const std::string &  text,
Color  color = WHITE 
)

Adds a single-color line to the tooltip.

Parameters
textText content.
colorText color.
Returns
Reference to this builder.

Definition at line 20 of file TooltipRenderer.cpp.

Referenced by RaylibRenderer::_render2D().

+ Here is the caller graph for this function:

◆ draw()

void TooltipRenderer::Builder::draw ( Vector2  position)

Draws the tooltip at the given position.

Parameters
positionScreen position (anchor point).

Definition at line 83 of file TooltipRenderer.cpp.

References TextRenderer::draw(), and TextRenderer::measure().

Referenced by RaylibRenderer::_render2D().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setAnchor()

TooltipRenderer::Builder & TooltipRenderer::Builder::setAnchor ( Anchor  anchor)

Sets the anchor point for positioning.

Parameters
anchorAnchor position.
Returns
Reference to this builder.

Definition at line 77 of file TooltipRenderer.cpp.

Referenced by RaylibRenderer::_render2D().

+ Here is the caller graph for this function:

◆ setBackgroundAlpha()

TooltipRenderer::Builder & TooltipRenderer::Builder::setBackgroundAlpha ( unsigned char  alpha)

Sets the background alpha transparency.

Parameters
alphaAlpha value (0-255).
Returns
Reference to this builder.

Definition at line 47 of file TooltipRenderer.cpp.

◆ setBackgroundColor()

TooltipRenderer::Builder & TooltipRenderer::Builder::setBackgroundColor ( Color  color)

Sets the background color (ignoring alpha).

Parameters
colorBackground color.
Returns
Reference to this builder.

Definition at line 41 of file TooltipRenderer.cpp.

Referenced by RaylibRenderer::_render2D().

+ Here is the caller graph for this function:

◆ setBorderColor()

TooltipRenderer::Builder & TooltipRenderer::Builder::setBorderColor ( Color  color)

Sets the border color.

Parameters
colorBorder color.
Returns
Reference to this builder.

Definition at line 53 of file TooltipRenderer.cpp.

Referenced by RaylibRenderer::_render2D().

+ Here is the caller graph for this function:

◆ setBorderThickness()

TooltipRenderer::Builder & TooltipRenderer::Builder::setBorderThickness ( int  thickness)

Sets the border thickness.

Parameters
thicknessBorder thickness in pixels (0 = no border).
Returns
Reference to this builder.

Definition at line 59 of file TooltipRenderer.cpp.

Referenced by RaylibRenderer::_render2D().

+ Here is the caller graph for this function:

◆ setFontSize()

TooltipRenderer::Builder & TooltipRenderer::Builder::setFontSize ( int  size)

Sets the font size for all text.

Parameters
sizeFont size in pixels.
Returns
Reference to this builder.

Definition at line 65 of file TooltipRenderer.cpp.

Referenced by RaylibRenderer::_render2D().

+ Here is the caller graph for this function:

◆ setPadding()

TooltipRenderer::Builder & TooltipRenderer::Builder::setPadding ( int  padding)

Sets the internal padding.

Parameters
paddingPadding in pixels.
Returns
Reference to this builder.

Definition at line 71 of file TooltipRenderer.cpp.

Referenced by RaylibRenderer::_render2D().

+ Here is the caller graph for this function:

Member Data Documentation

◆ _anchor

Anchor TooltipRenderer::Builder::_anchor
private

Definition at line 117 of file TooltipRenderer.hpp.

◆ _bgAlpha

unsigned char TooltipRenderer::Builder::_bgAlpha
private

Definition at line 112 of file TooltipRenderer.hpp.

◆ _bgColor

Color TooltipRenderer::Builder::_bgColor
private

Definition at line 111 of file TooltipRenderer.hpp.

◆ _borderColor

Color TooltipRenderer::Builder::_borderColor
private

Definition at line 113 of file TooltipRenderer.hpp.

◆ _borderThickness

int TooltipRenderer::Builder::_borderThickness
private

Definition at line 114 of file TooltipRenderer.hpp.

◆ _fontSize

int TooltipRenderer::Builder::_fontSize
private

Definition at line 115 of file TooltipRenderer.hpp.

◆ _lines

std::vector<std::vector<ColoredSegment> > TooltipRenderer::Builder::_lines
private

Definition at line 110 of file TooltipRenderer.hpp.

◆ _padding

int TooltipRenderer::Builder::_padding
private

Definition at line 116 of file TooltipRenderer.hpp.


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