ASW Lib
A.D.S. Games SDL Wrapper Library. A library targeted at Allegro4 users who want to switch to SDL3 and use modern c++.
Loading...
Searching...
No Matches
label.h
Go to the documentation of this file.
1
8
9#ifndef ASW_MODULES_UI_LABEL_H
10#define ASW_MODULES_UI_LABEL_H
11
12#include <optional>
13#include <string>
14
15#include "../types.h"
16#include "context.h"
17#include "widget.h"
18
19namespace asw::ui {
20
23class Label : public Widget {
24public:
28 {
29 focusable = false;
30 }
31
36 void draw(Context& ctx) override;
37
44 void set_text(const std::string& t, bool auto_size = false);
45
50 void measure(Context& ctx) override;
51
54
56 std::string text;
57
60
62 std::optional<asw::Color> color;
63
64private:
65 bool _fit_text = false;
66};
67
68} // namespace asw::ui
69
70#endif // ASW_MODULES_UI_LABEL_H
Shared state for the UI system.
Definition context.h:97
A text display widget.
Definition label.h:23
asw::Font font
The font. Uses the theme font when empty.
Definition label.h:53
std::optional< asw::Color > color
The text color. Uses the theme text color when empty.
Definition label.h:62
void measure(Context &ctx) override
Size to the text if set_text asked for it.
Definition label.cpp:12
std::string text
The text to display.
Definition label.h:56
bool _fit_text
Definition label.h:65
Label()
Default constructor.
Definition label.h:27
asw::TextJustify justify
The text justification.
Definition label.h:59
void set_text(const std::string &t, bool auto_size=false)
Set the text, optionally sizing the label to fit it, so layouts such as VBox and Modal give it room.
Definition label.cpp:6
Base class for all UI widgets.
Definition widget.h:43
bool focusable
Whether the widget can receive focus. Focusable widgets are also the ones the pointer can press.
Definition widget.h:88
UI context and focus management for the ASW UI module.
std::shared_ptr< TTF_Font > Font
Alias for a shared pointer to an TTF_Font.
Definition types.h:79
TextJustify
Text justification options for text rendering.
Definition types.h:58
Types used throughout the ASW library.
Base widget class for the ASW UI module.