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