// Copyright (c) 2023 Dominic Masters // // This software is released under the MIT License. // https://opensource.org/licenses/MIT #pragma once #include "UIComponent.hpp" #include "display/font/Font.hpp" #define UI_LABEL_MAX_WIDTH_NONE -1 #define UI_LABEL_MAX_WIDTH_ALIGN 0 namespace Dawn { class UILabel : public UIComponent, public UIComponentRenderable { private: bool_t needsRebuffering = true; Mesh mesh; /** * Returns true if the label contains renderable text. * * @return True if the label has text, otherwise false. */ bool_t hasText(); /** * Internally performs the mesh update. */ void updateMesh(); public: //@optional StateProperty text; // @optional StateProperty fontSize; /* @optional */ StateProperty font; /* @optional */ StateProperty maxWidth; /* @optional */ struct Color textColor = COLOR_WHITE; // @optional StateProperty startQuad; // @optional StateProperty quadCount; StateEvent<> eventFontRebuffered; StateEvent<> eventTextChanged; struct FontMeasure measure; UILabel(SceneItem *item); float_t getContentWidth() override; float_t getContentHeight() override; std::vector getRenderPasses() override; void onStart() override; }; }