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