Zappy GUI
C++ graphic client: renderer, camera, network
Loading...
Searching...
No Matches
TooltipRenderer.hpp
Go to the documentation of this file.
1#pragma once
2
3#include <string>
4#include <vector>
5
6#include "raylib.h"
7
14 public:
15 enum class Anchor {
16 TopLeft,
20 Center,
25 };
26
27 class Builder {
28 public:
29 Builder();
30
37 Builder& addLine(const std::string& text, Color color = WHITE);
38
46 Builder& addColoredText(const std::vector<std::string>& segments,
47 const std::vector<Color>& colors);
48
54 Builder& setBackgroundColor(Color color);
55
61 Builder& setBackgroundAlpha(unsigned char alpha);
62
68 Builder& setBorderColor(Color color);
69
75 Builder& setBorderThickness(int thickness);
76
82 Builder& setFontSize(int size);
83
89 Builder& setPadding(int padding);
90
96 Builder& setAnchor(Anchor anchor);
97
102 void draw(Vector2 position);
103
104 private:
106 std::string text;
107 Color color;
108 };
109
110 std::vector<std::vector<ColoredSegment>> _lines;
111 Color _bgColor;
112 unsigned char _bgAlpha;
118
119 Vector2 _calculateAnchoredPosition(Vector2 position, int boxWidth, int boxHeight) const;
120 };
121
126 static Builder create();
127};
Builder & setFontSize(int size)
Sets the font size for all text.
Builder & addColoredText(const std::vector< std::string > &segments, const std::vector< Color > &colors)
Adds a line with multiple colored segments.
std::vector< std::vector< ColoredSegment > > _lines
Builder & setPadding(int padding)
Sets the internal padding.
Builder & setBorderColor(Color color)
Sets the border color.
Builder & addLine(const std::string &text, Color color=WHITE)
Adds a single-color line to the tooltip.
Vector2 _calculateAnchoredPosition(Vector2 position, int boxWidth, int boxHeight) const
void draw(Vector2 position)
Draws the tooltip at the given position.
Builder & setBackgroundAlpha(unsigned char alpha)
Sets the background alpha transparency.
Builder & setBackgroundColor(Color color)
Sets the background color (ignoring alpha).
Builder & setBorderThickness(int thickness)
Sets the border thickness.
Builder & setAnchor(Anchor anchor)
Sets the anchor point for positioning.
Builder-pattern renderer for multiline tooltips with flexible styling.
static Builder create()
Creates a new tooltip builder.