Updated some docs

This commit is contained in:
2023-03-05 23:49:58 -08:00
parent ee2dc931f2
commit 7a0c86e383
4 changed files with 53 additions and 7 deletions

View File

@ -11,9 +11,32 @@
namespace Dawn { namespace Dawn {
class UIComponentDimensional { class UIComponentDimensional {
public: public:
/**
* Returns the width of this dimensional UI item.
*
* @return Width of this item.
*/
virtual float_t getWidth() = 0; virtual float_t getWidth() = 0;
/**
* Returns the height of this dimensional UI item.
*
* @return Height of this item.
*/
virtual float_t getHeight() = 0; virtual float_t getHeight() = 0;
/**
* Returns the content width of this dimensional UI item.
*
* @return Content width of this item.
*/
virtual float_t getContentWidth() = 0; virtual float_t getContentWidth() = 0;
/**
* Returns the content height of this dimensional UI item.
*
* @return Content height of this item.
*/
virtual float_t getContentHeight() = 0; virtual float_t getContentHeight() = 0;
}; };
@ -54,7 +77,6 @@ namespace Dawn {
float_t getHeight() override; float_t getHeight() override;
float_t getContentWidth() override; float_t getContentWidth() override;
float_t getContentHeight() override; float_t getContentHeight() override;
void onStart() override; void onStart() override;
void onDispose() override; void onDispose() override;
}; };

View File

@ -19,6 +19,15 @@ namespace Dawn {
class UIComponentRenderable { class UIComponentRenderable {
public: public:
/**
* Implemented UI Components that have rendering should implement this and
* return their rendering items. Items are passed back to the render
* pipeline.
*
* @param projection Camera projection, obtained from the canvas.
* @param view Camera view, obtained from the canvas.
* @return A list of renderable shader pass items for this renderable.
*/
virtual std::vector<struct ShaderPassItem> getPassItems( virtual std::vector<struct ShaderPassItem> getPassItems(
glm::mat4 projection, glm::mat4 projection,
glm::mat4 view glm::mat4 view
@ -27,13 +36,22 @@ namespace Dawn {
class UIComponent : public SceneItemComponent, public UIComponentDimensional { class UIComponent : public SceneItemComponent, public UIComponentDimensional {
protected: protected:
// Calculated (and cached) values
float_t width = 1; float_t width = 1;
float_t height = 1; float_t height = 1;
StateEvent<> eventAlignmentUpdated; StateEvent<> eventAlignmentUpdated;
/**
* Simply returns this UI Components' dimensional parent, used for the
* alignment of this item.
*
* @return Pointer to the parent dimensional.
*/
UIComponentDimensional * getParentDimensional(); UIComponentDimensional * getParentDimensional();
/**
* Internal method to update the alignment of this item.
*/
void updateAlignment(); void updateAlignment();
public: public:
@ -58,8 +76,6 @@ namespace Dawn {
glm::vec2 alignment glm::vec2 alignment
); );
//
StateProperty<UIComponentAlign> alignX; StateProperty<UIComponentAlign> alignX;
StateProperty<UIComponentAlign> alignY; StateProperty<UIComponentAlign> alignY;
StateProperty<glm::vec4> alignment; StateProperty<glm::vec4> alignment;
@ -68,7 +84,6 @@ namespace Dawn {
float_t getWidth() override; float_t getWidth() override;
float_t getHeight() override; float_t getHeight() override;
void onStart() override; void onStart() override;
friend class UICanvas; friend class UICanvas;

View File

@ -30,8 +30,8 @@ void UILabel::updateMesh() {
if(!this->hasText()) return; if(!this->hasText()) return;
float_t width = this->maxWidth; float_t width = this->maxWidth;
assertTrue(width == 0 || width == -1 || width > 0); assertTrue(width == UI_LABEL_MAX_WIDTH_NONE || width == UI_LABEL_MAX_WIDTH_ALIGN || width > 0);
if(width == 0) { if(width == UI_LABEL_MAX_WIDTH_ALIGN) {
auto dimensional = this->getParentDimensional(); auto dimensional = this->getParentDimensional();
auto align = (glm::vec4)this->alignment; auto align = (glm::vec4)this->alignment;
float_t x; float_t x;

View File

@ -16,7 +16,16 @@ namespace Dawn {
bool_t needsRebuffering = true; bool_t needsRebuffering = true;
Mesh mesh; Mesh mesh;
/**
* Returns true if the label contains renderable text.
*
* @return True if the label has text, otherwise false.
*/
bool_t hasText(); bool_t hasText();
/**
* Internally performs the mesh update.
*/
void updateMesh(); void updateMesh();
public: public: