43 lines
982 B
C++
43 lines
982 B
C++
/**
|
|
* @file Label.h
|
|
* @author apio (cloudapio.eu)
|
|
* @brief A simple one-line text widget.
|
|
*
|
|
* @copyright Copyright (c) 2023, the Luna authors.
|
|
*
|
|
*/
|
|
|
|
#pragma once
|
|
#include <ui/Alignment.h>
|
|
#include <ui/Font.h>
|
|
#include <ui/Widget.h>
|
|
|
|
namespace ui
|
|
{
|
|
/**
|
|
* @brief Displays one line of text.
|
|
*
|
|
* This component does not handle newlines.
|
|
*/
|
|
class Label final : public Widget
|
|
{
|
|
public:
|
|
Label(StringView text, ui::Color color = ui::WHITE, VerticalAlignment valign = VerticalAlignment::Center,
|
|
HorizontalAlignment halign = HorizontalAlignment::Center, SharedPtr<Font> font = Font::default_font());
|
|
|
|
void set_text(StringView text)
|
|
{
|
|
m_text = text;
|
|
}
|
|
|
|
Result<void> draw(Canvas& canvas) override;
|
|
|
|
private:
|
|
StringView m_text;
|
|
VerticalAlignment m_valign;
|
|
HorizontalAlignment m_halign;
|
|
ui::Color m_color;
|
|
SharedPtr<Font> m_font;
|
|
};
|
|
}
|