Updated some docs
This commit is contained in:
81
archive/ui/finished/UILabel.hpp
Normal file
81
archive/ui/finished/UILabel.hpp
Normal file
@ -0,0 +1,81 @@
|
||||
// Copyright (c) 2022 Dominic Masters
|
||||
//
|
||||
// This software is released under the MIT License.
|
||||
// https://opensource.org/licenses/MIT
|
||||
|
||||
#pragma once
|
||||
#include "UIComponent.hpp"
|
||||
#include "display/mesh/QuadMesh.hpp"
|
||||
#include "display/font/Font.hpp"
|
||||
|
||||
namespace Dawn {
|
||||
class UILabel : public UIComponent {
|
||||
private:
|
||||
Mesh mesh;
|
||||
bool_t needsRebuffering = true;
|
||||
Font *font = nullptr;
|
||||
std::string key = "";
|
||||
float_t fontSize = 10.0f;
|
||||
bool_t hasText = false;
|
||||
std::function<void()> evtLangUpdated;
|
||||
|
||||
void updatePositions() override;
|
||||
|
||||
std::vector<struct ShaderPassItem> getSelfPassItems(
|
||||
glm::mat4 projection,
|
||||
glm::mat4 view,
|
||||
glm::mat4 transform
|
||||
) override;
|
||||
|
||||
public:
|
||||
struct FontMeasure measure;
|
||||
int32_t startQuad = 0;
|
||||
int32_t quadCount = -1;
|
||||
|
||||
/** The colour of this label */
|
||||
struct Color textColor = COLOR_MAGENTA;
|
||||
|
||||
UILabel(UICanvas *canvas);
|
||||
virtual float_t getContentWidth() override;
|
||||
virtual float_t getContentHeight() override;
|
||||
void setTransform(
|
||||
UIComponentAlign xAlign,
|
||||
UIComponentAlign yAlign,
|
||||
glm::vec4 alignment,
|
||||
float_t z
|
||||
) override;
|
||||
|
||||
/**
|
||||
* Internal method to force the font mesh to be recreated.
|
||||
*/
|
||||
void updateMesh();
|
||||
|
||||
/**
|
||||
* Set the font to use for the label.
|
||||
*
|
||||
* @param font Font to use.
|
||||
*/
|
||||
void setFont(Font *font);
|
||||
|
||||
/**
|
||||
* Sets the text for the label to use.
|
||||
*
|
||||
* @param key Localzied string key for the label to use.
|
||||
*/
|
||||
void setText(std::string key);
|
||||
|
||||
/**
|
||||
* Sets / Updates the font size for the label.
|
||||
*
|
||||
* @param fontSize Font size to use.
|
||||
*/
|
||||
void setFontSize(float_t fontSize);
|
||||
|
||||
/**
|
||||
* Get the labels' current font size.
|
||||
*
|
||||
* @return Font size of the label.
|
||||
*/
|
||||
float_t getFontSize();
|
||||
};
|
||||
}
|
Reference in New Issue
Block a user