Documented font
This commit is contained in:
@ -11,6 +11,12 @@ UILabel::UILabel(UICanvas &canvas) : UIComponent(canvas) {
|
||||
|
||||
}
|
||||
|
||||
void UILabel::updatePositions() {
|
||||
UIComponent::updatePositions();
|
||||
|
||||
this->updateMesh();
|
||||
}
|
||||
|
||||
void UILabel::updateMesh() {
|
||||
if(!this->needsRebuffering) return;
|
||||
if(this->font == nullptr) return;
|
||||
@ -18,7 +24,7 @@ void UILabel::updateMesh() {
|
||||
this->font->buffer(
|
||||
this->text,
|
||||
this->fontSize,
|
||||
-1,
|
||||
this->getWidth(),
|
||||
this->mesh,
|
||||
&this->measure
|
||||
);
|
||||
|
@ -18,19 +18,47 @@ namespace Dawn {
|
||||
std::string text = "";
|
||||
float_t fontSize = 10.0f;
|
||||
|
||||
void updatePositions() override;
|
||||
|
||||
/**
|
||||
* Internal method to force the font mesh to be recreated.
|
||||
*/
|
||||
void updateMesh();
|
||||
|
||||
public:
|
||||
/** The colour of this label */
|
||||
struct Color textColor = COLOR_MAGENTA;
|
||||
|
||||
UILabel(UICanvas &canvas);
|
||||
|
||||
UILabel(UICanvas &canvas);
|
||||
void drawSelf(UIShader &shader, glm::mat4 selfTransform);
|
||||
|
||||
/**
|
||||
* Returns the current text that the label has.
|
||||
*
|
||||
* @return The current label string.
|
||||
*/
|
||||
std::string getText();
|
||||
|
||||
/**
|
||||
* 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 text Text for the label to use.
|
||||
*/
|
||||
void setText(std::string text);
|
||||
|
||||
/**
|
||||
* Sets / Updates the font size for the label.
|
||||
*
|
||||
* @param fontSize Font size to use.
|
||||
*/
|
||||
void setFontSize(float_t fontSize);
|
||||
|
||||
void drawSelf(UIShader &shader, glm::mat4 selfTransform);
|
||||
};
|
||||
}
|
@ -14,8 +14,6 @@ UISprite::UISprite(UICanvas &canvas) : UIComponent(canvas) {
|
||||
void UISprite::updatePositions() {
|
||||
UIComponent::updatePositions();
|
||||
|
||||
std::cout << "Updating" << std::endl;
|
||||
|
||||
QuadMesh::bufferQuadMesh(
|
||||
this->mesh,
|
||||
glm::vec2(0, 0), glm::vec2(0, 0),
|
||||
|
@ -17,9 +17,12 @@ namespace Dawn {
|
||||
Mesh mesh;
|
||||
Texture *texture;
|
||||
|
||||
/**
|
||||
* UI Sprite Constructor, use the UIElement / UIComponent create instead.
|
||||
*
|
||||
* @param canvas Canvas that this sprite belongs to.
|
||||
*/
|
||||
UISprite(UICanvas &canvas);
|
||||
|
||||
// void update() override;
|
||||
void drawSelf(UIShader &uiShader, glm::mat4 selfTransform) override;
|
||||
};
|
||||
}
|
Reference in New Issue
Block a user