Sparkle 0.0.1
Loading...
Searching...
No Matches
spk_text_label.hpp
1#pragma once
2
3#include "structure/widget/components/spk_nine_slice_background.hpp"
4#include "structure/widget/components/spk_text_region.hpp"
5#include "structure/widget/spk_widget.hpp"
6
7namespace spk
8{
19 class TextLabel : public spk::Widget
20 {
21 private:
22 NineSliceBackground _background;
23 TextRegion _textRegion;
24
25 protected:
29 void _onGeometryChange() override;
34 void _onPaintEvent(spk::PaintEvent &p_event) override;
35
36 public:
42 TextLabel(const std::wstring &p_name, spk::Widget *p_parent);
43
48 void setCornerSize(const spk::Vector2UInt &p_cornerSize);
53 const spk::Vector2UInt &cornerSize() const;
54
59 void setTexture(const spk::SpriteSheet *p_spriteSheet);
64 const spk::SpriteSheet *texture() const;
65
70 void setFont(spk::Font *p_font);
75 spk::Font *font() const;
76
81 void setFontSize(const spk::Font::Size &p_size);
86 const spk::Font::Size &fontSize() const;
87
93 void setColors(const spk::Color &p_glyphColor, const spk::Color &p_outlineColor);
98 const spk::Color &glyphColor() const;
103 const spk::Color &outlineColor() const;
104
109 void setText(const std::wstring &p_text);
114 const std::wstring &text() const;
115
121 void setAlignment(HorizontalAlignment p_horizontalAlignment, VerticalAlignment p_verticalAlignment);
126 HorizontalAlignment horizontalAlignment() const;
131 VerticalAlignment verticalAlignment() const;
132 };
133}
Loads font data and provides cached bitmap atlases per size.
Definition spk_font.hpp:33
Renders a scalable nine-slice background using a sprite sheet.
Definition spk_nine_slice_background.hpp:25
Loads an image and exposes individual sprite regions.
Definition spk_sprite_sheet.hpp:21
const spk::Color & outlineColor() const
Returns the current outline color.
Definition spk_text_label.cpp:72
TextLabel(const std::wstring &p_name, spk::Widget *p_parent)
Creates a text label widget.
Definition spk_text_label.cpp:5
spk::Font * font() const
Returns the font used for the label text.
Definition spk_text_label.cpp:46
const spk::Color & glyphColor() const
Returns the current glyph color.
Definition spk_text_label.cpp:67
void _onPaintEvent(spk::PaintEvent &p_event) override
Paints the background and text regions.
Definition spk_text_label.cpp:109
HorizontalAlignment horizontalAlignment() const
Returns the current horizontal alignment.
Definition spk_text_label.cpp:93
const std::wstring & text() const
Returns the current label text.
Definition spk_text_label.cpp:83
void setFont(spk::Font *p_font)
Sets the font used for the label text.
Definition spk_text_label.cpp:40
VerticalAlignment verticalAlignment() const
Returns the current vertical alignment.
Definition spk_text_label.cpp:98
const spk::SpriteSheet * texture() const
Returns the sprite sheet used for the background.
Definition spk_text_label.cpp:35
void _onGeometryChange() override
Updates background and text geometry when the widget size changes.
Definition spk_text_label.cpp:103
void setTexture(const spk::SpriteSheet *p_spriteSheet)
Assigns the sprite sheet used for the background.
Definition spk_text_label.cpp:30
const spk::Vector2UInt & cornerSize() const
Returns the current corner size for the background.
Definition spk_text_label.cpp:25
void setText(const std::wstring &p_text)
Updates the label text.
Definition spk_text_label.cpp:77
const spk::Font::Size & fontSize() const
Returns the current font size for the label text.
Definition spk_text_label.cpp:57
void setColors(const spk::Color &p_glyphColor, const spk::Color &p_outlineColor)
Sets the glyph and outline colors for the label text.
Definition spk_text_label.cpp:62
void setFontSize(const spk::Font::Size &p_size)
Sets the font size for the label text.
Definition spk_text_label.cpp:51
void setAlignment(HorizontalAlignment p_horizontalAlignment, VerticalAlignment p_verticalAlignment)
Sets the horizontal and vertical alignment for the text.
Definition spk_text_label.cpp:88
void setCornerSize(const spk::Vector2UInt &p_cornerSize)
Sets the corner size for the nine-slice background.
Definition spk_text_label.cpp:18
Renders formatted text within a geometry region.
Definition spk_text_region.hpp:24
Base class for interactive UI elements handling focus and events.
Definition spk_widget.hpp:52
RGBA color utility storing normalized floating components.
Definition spk_color.hpp:18
Defines glyph and outline sizes for a font bitmap.
Definition spk_font.hpp:40
Event emitted when a drawable region needs repainting.
Definition spk_paint_event.hpp:19