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
include
asw
modules
ui
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
19
namespace
asw::ui
{
20
23
class
Label
:
public
Widget
{
24
public
:
27
Label
()
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
53
asw::Font
font
;
54
56
std::string
text
;
57
59
asw::TextJustify
justify
=
asw::TextJustify::Left
;
60
62
std::optional<asw::Color>
color
;
63
64
private
:
65
bool
_fit_text
=
false
;
66
};
67
68
}
// namespace asw::ui
69
70
#endif
// ASW_MODULES_UI_LABEL_H
asw::ui::Context
Shared state for the UI system.
Definition
context.h:97
asw::ui::Label
A text display widget.
Definition
label.h:23
asw::ui::Label::font
asw::Font font
The font. Uses the theme font when empty.
Definition
label.h:53
asw::ui::Label::color
std::optional< asw::Color > color
The text color. Uses the theme text color when empty.
Definition
label.h:62
asw::ui::Label::measure
void measure(Context &ctx) override
Size to the text if set_text asked for it.
Definition
label.cpp:12
asw::ui::Label::text
std::string text
The text to display.
Definition
label.h:56
asw::ui::Label::_fit_text
bool _fit_text
Definition
label.h:65
asw::ui::Label::Label
Label()
Default constructor.
Definition
label.h:27
asw::ui::Label::justify
asw::TextJustify justify
The text justification.
Definition
label.h:59
asw::ui::Label::set_text
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
asw::ui::Widget
Base class for all UI widgets.
Definition
widget.h:43
asw::ui::Widget::focusable
bool focusable
Whether the widget can receive focus. Focusable widgets are also the ones the pointer can press.
Definition
widget.h:88
context.h
UI context and focus management for the ASW UI module.
asw::ui
Definition
button.h:20
asw::Font
std::shared_ptr< TTF_Font > Font
Alias for a shared pointer to an TTF_Font.
Definition
types.h:79
asw::TextJustify
TextJustify
Text justification options for text rendering.
Definition
types.h:58
asw::TextJustify::Left
@ Left
types.h
Types used throughout the ASW library.
widget.h
Base widget class for the ASW UI module.
Generated by
1.12.0