Totally refactored UILabel
This commit is contained in:
@ -6,20 +6,71 @@
|
||||
#pragma once
|
||||
#include "scene/SceneItemComponent.hpp"
|
||||
#include "UICanvas.hpp"
|
||||
#include "display/shader/Shader.hpp"
|
||||
#include "util/mathutils.hpp"
|
||||
|
||||
namespace Dawn {
|
||||
class UIComponentRendaerable {
|
||||
public:
|
||||
int32_t cum;
|
||||
enum UIComponentAlign {
|
||||
UI_COMPONENT_ALIGN_START,
|
||||
UI_COMPONENT_ALIGN_MIDDLE,
|
||||
UI_COMPONENT_ALIGN_END,
|
||||
UI_COMPONENT_ALIGN_STRETCH
|
||||
};
|
||||
|
||||
class UIComponent : public SceneItemComponent {
|
||||
private:
|
||||
UICanvas *canvas = nullptr;
|
||||
class UIComponentRenderable {
|
||||
public:
|
||||
virtual std::vector<struct ShaderPassItem> getPassItems(
|
||||
glm::mat4 projection,
|
||||
glm::mat4 view
|
||||
) = 0;
|
||||
};
|
||||
|
||||
class UIComponent : public SceneItemComponent, public UIComponentDimensional {
|
||||
protected:
|
||||
// Calculated (and cached) values
|
||||
float_t width = 1;
|
||||
float_t height = 1;
|
||||
|
||||
StateEvent<> eventAlignmentUpdated;
|
||||
UIComponentDimensional * getParentDimensional();
|
||||
|
||||
void updateAlignment();
|
||||
|
||||
public:
|
||||
StateProperty<bool_t> alignmentNeedsUpdating;
|
||||
|
||||
/**
|
||||
* Method used to calculate alignment dimensions.
|
||||
*
|
||||
* @param align Alignment value enumator.
|
||||
* @param position Output position floating point.
|
||||
* @param size Output size floating point.
|
||||
* @param outerSize Outer size (of the parent).
|
||||
* @param innerSize Inner size (of this element's content).
|
||||
* @param alignment Alignment settings.
|
||||
*/
|
||||
static void calculateDimensions(
|
||||
enum UIComponentAlign align,
|
||||
float_t *position,
|
||||
float_t *size,
|
||||
float_t outerSize,
|
||||
float_t innerSize,
|
||||
glm::vec2 alignment
|
||||
);
|
||||
|
||||
//
|
||||
|
||||
StateProperty<UIComponentAlign> alignX;
|
||||
StateProperty<UIComponentAlign> alignY;
|
||||
StateProperty<glm::vec4> alignment;
|
||||
|
||||
UIComponent(SceneItem *item);
|
||||
|
||||
float_t getWidth() override;
|
||||
float_t getHeight() override;
|
||||
|
||||
void onStart() override;
|
||||
|
||||
friend class UICanvas;
|
||||
};
|
||||
}
|
Reference in New Issue
Block a user