Added libarchive support to Dawn.
This commit is contained in:
@ -71,17 +71,6 @@ void UIComponent::updateAlignment() {
|
||||
glm::vec2(align[0], align[2])
|
||||
);
|
||||
} else {
|
||||
UIComponent::calculateDimensions(
|
||||
this->alignY,
|
||||
this->alignUnitTop,
|
||||
this->alignUnitBottom,
|
||||
&translate.y,
|
||||
&this->height,
|
||||
parentInnerHeight,
|
||||
this->getContentHeight(),
|
||||
this->width,
|
||||
glm::vec2(align[1], align[3])
|
||||
);
|
||||
UIComponent::calculateDimensions(
|
||||
this->alignX,
|
||||
this->alignUnitLeft,
|
||||
@ -93,6 +82,17 @@ void UIComponent::updateAlignment() {
|
||||
this->height,
|
||||
glm::vec2(align[0], align[2])
|
||||
);
|
||||
UIComponent::calculateDimensions(
|
||||
this->alignY,
|
||||
this->alignUnitTop,
|
||||
this->alignUnitBottom,
|
||||
&translate.y,
|
||||
&this->height,
|
||||
parentInnerHeight,
|
||||
this->getContentHeight(),
|
||||
this->width,
|
||||
glm::vec2(align[1], align[3])
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@ -104,6 +104,38 @@ void UIComponent::updateAlignment() {
|
||||
this->eventAlignmentUpdated.invoke();
|
||||
}
|
||||
|
||||
float_t UIComponent::getWidthFromAlignment() {
|
||||
switch(this->alignX) {
|
||||
case UI_COMPONENT_ALIGN_STRETCH:
|
||||
case UI_COMPONENT_ALIGN_START:
|
||||
case UI_COMPONENT_ALIGN_MIDDLE:
|
||||
return alignment._realValue[2];
|
||||
|
||||
case UI_COMPONENT_ALIGN_END:
|
||||
return alignment._realValue[0];
|
||||
|
||||
default:
|
||||
assertUnreachable("UIComponent::getWidthFromAlignment: Unknown alignment");
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
float_t UIComponent::getHeightFromAlignment() {
|
||||
switch(this->alignY) {
|
||||
case UI_COMPONENT_ALIGN_STRETCH:
|
||||
case UI_COMPONENT_ALIGN_START:
|
||||
case UI_COMPONENT_ALIGN_MIDDLE:
|
||||
return alignment._realValue[3];
|
||||
|
||||
case UI_COMPONENT_ALIGN_END:
|
||||
return alignment._realValue[1];
|
||||
|
||||
default:
|
||||
assertUnreachable("UIComponent::getWidthFromAlignment: Unknown alignment");
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
float_t UIComponent::calculateAlignmentValue(
|
||||
float_t alignmentValue,
|
||||
float_t parentSize,
|
||||
|
@ -44,6 +44,24 @@ namespace Dawn {
|
||||
* Internal method to update the alignment of this item.
|
||||
*/
|
||||
virtual void updateAlignment();
|
||||
|
||||
/**
|
||||
* Helper function used for UI components that intend to use whatever the
|
||||
* dimensions that are set within the alignment parameter are for their
|
||||
* width.
|
||||
*
|
||||
* @return The width as defined in the alignment.
|
||||
*/
|
||||
float_t getWidthFromAlignment();
|
||||
|
||||
/**
|
||||
* Helper function used for UI components that intend to use whatever the
|
||||
* dimensions that are set within the alignment parameter are for their
|
||||
* height.
|
||||
*
|
||||
* @return The height as defined in the alignment.
|
||||
*/
|
||||
float_t getHeightFromAlignment();
|
||||
|
||||
public:
|
||||
StateProperty<bool_t> alignmentNeedsUpdating;
|
||||
|
@ -10,10 +10,10 @@ using namespace Dawn;
|
||||
UIEmpty::UIEmpty(SceneItem *item) : UIComponent(item) { }
|
||||
|
||||
float_t UIEmpty::getContentWidth() {
|
||||
return this->getWidth();
|
||||
return this->getWidthFromAlignment();
|
||||
}
|
||||
float_t UIEmpty::getContentHeight() {
|
||||
return this->getHeight();
|
||||
return this->getHeightFromAlignment();
|
||||
}
|
||||
float_t UIEmpty::getChildOffsetX() { return 0.0f; }
|
||||
float_t UIEmpty::getChildOffsetY() { return 0.0f; }
|
@ -10,7 +10,8 @@ using namespace Dawn;
|
||||
|
||||
UILabel::UILabel(SceneItem *item) :
|
||||
UIComponentRenderable(item),
|
||||
lineHeight(1.0f)
|
||||
lineHeight(1.0f),
|
||||
textAlign(UI_LABEL_TEXT_ALIGN_LEFT)
|
||||
{
|
||||
|
||||
}
|
||||
|
@ -43,6 +43,13 @@ namespace Dawn {
|
||||
UI_LABEL_VERTICAL_ALIGN_BOTTOM
|
||||
};
|
||||
|
||||
enum UILabelTextAlign {
|
||||
UI_LABEL_TEXT_ALIGN_LEFT,
|
||||
UI_LABEL_TEXT_ALIGN_CENTER,
|
||||
UI_LABEL_TEXT_ALIGN_RIGHT
|
||||
// TODO: Add justify
|
||||
};
|
||||
|
||||
class UILabel : public UIComponentRenderable {
|
||||
private:
|
||||
Mesh mesh;
|
||||
@ -68,6 +75,9 @@ namespace Dawn {
|
||||
// @optional
|
||||
StateProperty<float_t> lineHeight;
|
||||
|
||||
// @optional
|
||||
StateProperty<enum UILabelTextAlign> textAlign;
|
||||
|
||||
UILabel(SceneItem *item);
|
||||
|
||||
void onStart() override;
|
||||
|
Reference in New Issue
Block a user