2013-06-02 15:08:32 +00:00
|
|
|
#include "GuiComponent.h"
|
2017-11-01 22:21:10 +00:00
|
|
|
|
|
|
|
#include "animations/Animation.h"
|
|
|
|
#include "animations/AnimationController.h"
|
2013-06-02 16:11:29 +00:00
|
|
|
#include "Log.h"
|
2013-06-02 19:34:50 +00:00
|
|
|
#include "Renderer.h"
|
2014-01-01 05:39:22 +00:00
|
|
|
#include "ThemeData.h"
|
2017-11-01 22:21:10 +00:00
|
|
|
#include "Window.h"
|
2018-01-29 22:50:10 +00:00
|
|
|
#include <algorithm>
|
2013-06-02 15:08:32 +00:00
|
|
|
|
2017-01-25 15:00:56 +00:00
|
|
|
GuiComponent::GuiComponent(Window* window) : mWindow(window), mParent(NULL), mOpacity(255),
|
2017-10-28 20:24:35 +00:00
|
|
|
mPosition(Vector3f::Zero()), mOrigin(Vector2f::Zero()), mRotationOrigin(0.5, 0.5),
|
|
|
|
mSize(Vector2f::Zero()), mTransform(Transform4x4f::Identity()), mIsProcessing(false)
|
2013-06-02 15:08:32 +00:00
|
|
|
{
|
2013-12-13 03:17:59 +00:00
|
|
|
for(unsigned char i = 0; i < MAX_ANIMATIONS; i++)
|
|
|
|
mAnimationMap[i] = NULL;
|
2013-06-02 15:08:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
GuiComponent::~GuiComponent()
|
|
|
|
{
|
|
|
|
mWindow->removeGui(this);
|
|
|
|
|
2014-04-15 02:03:11 +00:00
|
|
|
cancelAllAnimations();
|
2013-12-13 03:17:59 +00:00
|
|
|
|
2013-06-02 15:08:32 +00:00
|
|
|
if(mParent)
|
|
|
|
mParent->removeChild(this);
|
2013-06-19 01:12:30 +00:00
|
|
|
|
|
|
|
for(unsigned int i = 0; i < getChildCount(); i++)
|
|
|
|
getChild(i)->setParent(NULL);
|
2013-06-02 15:08:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
bool GuiComponent::input(InputConfig* config, Input input)
|
|
|
|
{
|
|
|
|
for(unsigned int i = 0; i < getChildCount(); i++)
|
|
|
|
{
|
|
|
|
if(getChild(i)->input(config, input))
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2014-06-05 19:29:07 +00:00
|
|
|
void GuiComponent::updateSelf(int deltaTime)
|
2013-06-02 15:08:32 +00:00
|
|
|
{
|
2013-12-13 03:17:59 +00:00
|
|
|
for(unsigned char i = 0; i < MAX_ANIMATIONS; i++)
|
2014-05-15 01:58:16 +00:00
|
|
|
advanceAnimation(i, deltaTime);
|
2014-06-05 19:29:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void GuiComponent::updateChildren(int deltaTime)
|
|
|
|
{
|
2013-06-02 15:08:32 +00:00
|
|
|
for(unsigned int i = 0; i < getChildCount(); i++)
|
|
|
|
{
|
|
|
|
getChild(i)->update(deltaTime);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-06-05 19:29:07 +00:00
|
|
|
void GuiComponent::update(int deltaTime)
|
|
|
|
{
|
|
|
|
updateSelf(deltaTime);
|
|
|
|
updateChildren(deltaTime);
|
|
|
|
}
|
|
|
|
|
2017-10-28 20:24:35 +00:00
|
|
|
void GuiComponent::render(const Transform4x4f& parentTrans)
|
2013-06-02 19:34:50 +00:00
|
|
|
{
|
2017-10-28 20:24:35 +00:00
|
|
|
Transform4x4f trans = parentTrans * getTransform();
|
2013-07-10 11:29:43 +00:00
|
|
|
renderChildren(trans);
|
2013-06-02 19:34:50 +00:00
|
|
|
}
|
|
|
|
|
2017-10-28 20:24:35 +00:00
|
|
|
void GuiComponent::renderChildren(const Transform4x4f& transform) const
|
2013-06-02 15:08:32 +00:00
|
|
|
{
|
|
|
|
for(unsigned int i = 0; i < getChildCount(); i++)
|
|
|
|
{
|
2013-07-10 11:29:43 +00:00
|
|
|
getChild(i)->render(transform);
|
2013-06-02 15:08:32 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-10-28 20:24:35 +00:00
|
|
|
Vector3f GuiComponent::getPosition() const
|
2013-06-02 15:08:32 +00:00
|
|
|
{
|
2013-07-10 11:29:43 +00:00
|
|
|
return mPosition;
|
2013-06-02 15:08:32 +00:00
|
|
|
}
|
|
|
|
|
2017-07-17 03:10:29 +00:00
|
|
|
void GuiComponent::setPosition(float x, float y, float z)
|
2013-06-02 15:08:32 +00:00
|
|
|
{
|
2017-10-28 20:24:35 +00:00
|
|
|
mPosition = Vector3f(x, y, z);
|
2013-07-10 11:29:43 +00:00
|
|
|
onPositionChanged();
|
2013-06-02 15:08:32 +00:00
|
|
|
}
|
|
|
|
|
2017-10-28 20:24:35 +00:00
|
|
|
Vector2f GuiComponent::getOrigin() const
|
2013-06-02 15:08:32 +00:00
|
|
|
{
|
2017-07-17 03:10:29 +00:00
|
|
|
return mOrigin;
|
2013-06-02 15:08:32 +00:00
|
|
|
}
|
2013-06-02 16:11:29 +00:00
|
|
|
|
2017-07-17 03:10:29 +00:00
|
|
|
void GuiComponent::setOrigin(float x, float y)
|
2013-06-02 22:33:49 +00:00
|
|
|
{
|
2017-10-28 20:24:35 +00:00
|
|
|
mOrigin = Vector2f(x, y);
|
2017-07-17 03:10:29 +00:00
|
|
|
onOriginChanged();
|
2013-06-02 22:33:49 +00:00
|
|
|
}
|
|
|
|
|
2017-10-28 20:24:35 +00:00
|
|
|
Vector2f GuiComponent::getRotationOrigin() const
|
2013-07-02 23:48:39 +00:00
|
|
|
{
|
2017-07-17 03:10:29 +00:00
|
|
|
return mRotationOrigin;
|
|
|
|
}
|
|
|
|
|
|
|
|
void GuiComponent::setRotationOrigin(float x, float y)
|
|
|
|
{
|
2017-10-28 20:24:35 +00:00
|
|
|
mRotationOrigin = Vector2f(x, y);
|
2017-07-17 03:10:29 +00:00
|
|
|
}
|
|
|
|
|
2017-10-28 20:24:35 +00:00
|
|
|
Vector2f GuiComponent::getSize() const
|
2017-07-17 03:10:29 +00:00
|
|
|
{
|
|
|
|
return mSize;
|
2013-07-02 23:48:39 +00:00
|
|
|
}
|
|
|
|
|
2013-07-10 11:29:43 +00:00
|
|
|
void GuiComponent::setSize(float w, float h)
|
2013-07-02 23:48:39 +00:00
|
|
|
{
|
2017-10-28 20:24:35 +00:00
|
|
|
mSize = Vector2f(w, h);
|
2013-07-02 23:48:39 +00:00
|
|
|
onSizeChanged();
|
|
|
|
}
|
|
|
|
|
2017-07-17 03:10:29 +00:00
|
|
|
float GuiComponent::getRotation() const
|
|
|
|
{
|
|
|
|
return mRotation;
|
|
|
|
}
|
|
|
|
|
|
|
|
void GuiComponent::setRotation(float rotation)
|
|
|
|
{
|
|
|
|
mRotation = rotation;
|
|
|
|
}
|
|
|
|
|
|
|
|
float GuiComponent::getScale() const
|
|
|
|
{
|
|
|
|
return mScale;
|
|
|
|
}
|
|
|
|
|
|
|
|
void GuiComponent::setScale(float scale)
|
|
|
|
{
|
|
|
|
mScale = scale;
|
|
|
|
}
|
|
|
|
|
2017-04-22 14:15:16 +00:00
|
|
|
float GuiComponent::getZIndex() const
|
|
|
|
{
|
|
|
|
return mZIndex;
|
|
|
|
}
|
|
|
|
|
|
|
|
void GuiComponent::setZIndex(float z)
|
|
|
|
{
|
|
|
|
mZIndex = z;
|
|
|
|
}
|
|
|
|
|
|
|
|
float GuiComponent::getDefaultZIndex() const
|
|
|
|
{
|
|
|
|
return mDefaultZIndex;
|
|
|
|
}
|
|
|
|
|
|
|
|
void GuiComponent::setDefaultZIndex(float z)
|
|
|
|
{
|
|
|
|
mDefaultZIndex = z;
|
|
|
|
}
|
|
|
|
|
2017-10-28 20:24:35 +00:00
|
|
|
Vector2f GuiComponent::getCenter() const
|
2017-07-17 03:10:29 +00:00
|
|
|
{
|
2017-10-28 20:24:35 +00:00
|
|
|
return Vector2f(mPosition.x() - (getSize().x() * mOrigin.x()) + getSize().x() / 2,
|
|
|
|
mPosition.y() - (getSize().y() * mOrigin.y()) + getSize().y() / 2);
|
2017-07-17 03:10:29 +00:00
|
|
|
}
|
|
|
|
|
2013-06-02 19:34:50 +00:00
|
|
|
//Children stuff.
|
2013-06-02 16:11:29 +00:00
|
|
|
void GuiComponent::addChild(GuiComponent* cmp)
|
|
|
|
{
|
|
|
|
mChildren.push_back(cmp);
|
|
|
|
|
|
|
|
if(cmp->getParent())
|
|
|
|
cmp->getParent()->removeChild(cmp);
|
|
|
|
|
|
|
|
cmp->setParent(this);
|
|
|
|
}
|
|
|
|
|
|
|
|
void GuiComponent::removeChild(GuiComponent* cmp)
|
|
|
|
{
|
2013-11-12 23:28:15 +00:00
|
|
|
if(!cmp->getParent())
|
|
|
|
return;
|
|
|
|
|
2013-06-02 16:11:29 +00:00
|
|
|
if(cmp->getParent() != this)
|
|
|
|
{
|
|
|
|
LOG(LogError) << "Tried to remove child from incorrect parent!";
|
|
|
|
}
|
|
|
|
|
|
|
|
cmp->setParent(NULL);
|
|
|
|
|
2017-11-11 14:56:22 +00:00
|
|
|
for(auto i = mChildren.cbegin(); i != mChildren.cend(); i++)
|
2013-06-02 16:11:29 +00:00
|
|
|
{
|
|
|
|
if(*i == cmp)
|
|
|
|
{
|
|
|
|
mChildren.erase(i);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void GuiComponent::clearChildren()
|
|
|
|
{
|
|
|
|
mChildren.clear();
|
|
|
|
}
|
|
|
|
|
2017-04-22 14:15:16 +00:00
|
|
|
void GuiComponent::sortChildren()
|
|
|
|
{
|
2017-10-18 14:19:32 +00:00
|
|
|
std::stable_sort(mChildren.begin(), mChildren.end(), [](GuiComponent* a, GuiComponent* b) {
|
2017-04-22 14:15:16 +00:00
|
|
|
return b->getZIndex() > a->getZIndex();
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2013-07-10 11:29:43 +00:00
|
|
|
unsigned int GuiComponent::getChildCount() const
|
2013-06-02 16:11:29 +00:00
|
|
|
{
|
2017-11-17 14:58:52 +00:00
|
|
|
return (int)mChildren.size();
|
2013-06-02 16:11:29 +00:00
|
|
|
}
|
|
|
|
|
2013-07-10 11:29:43 +00:00
|
|
|
GuiComponent* GuiComponent::getChild(unsigned int i) const
|
2013-06-02 16:11:29 +00:00
|
|
|
{
|
|
|
|
return mChildren.at(i);
|
|
|
|
}
|
2013-06-02 19:34:50 +00:00
|
|
|
|
|
|
|
void GuiComponent::setParent(GuiComponent* parent)
|
|
|
|
{
|
|
|
|
mParent = parent;
|
|
|
|
}
|
|
|
|
|
2013-07-10 11:29:43 +00:00
|
|
|
GuiComponent* GuiComponent::getParent() const
|
2013-06-02 19:34:50 +00:00
|
|
|
{
|
|
|
|
return mParent;
|
|
|
|
}
|
2013-07-02 14:51:33 +00:00
|
|
|
|
2013-07-10 11:29:43 +00:00
|
|
|
unsigned char GuiComponent::getOpacity() const
|
2013-07-02 14:51:33 +00:00
|
|
|
{
|
|
|
|
return mOpacity;
|
|
|
|
}
|
|
|
|
|
|
|
|
void GuiComponent::setOpacity(unsigned char opacity)
|
|
|
|
{
|
|
|
|
mOpacity = opacity;
|
2017-11-11 14:56:22 +00:00
|
|
|
for(auto it = mChildren.cbegin(); it != mChildren.cend(); it++)
|
2013-10-10 21:14:33 +00:00
|
|
|
{
|
|
|
|
(*it)->setOpacity(opacity);
|
|
|
|
}
|
2013-07-03 00:12:49 +00:00
|
|
|
}
|
2013-07-10 11:29:43 +00:00
|
|
|
|
2017-10-28 20:24:35 +00:00
|
|
|
const Transform4x4f& GuiComponent::getTransform()
|
2013-07-10 11:29:43 +00:00
|
|
|
{
|
2017-10-28 20:24:35 +00:00
|
|
|
mTransform = Transform4x4f::Identity();
|
2013-07-10 11:29:43 +00:00
|
|
|
mTransform.translate(mPosition);
|
2017-07-17 03:10:29 +00:00
|
|
|
if (mScale != 1.0)
|
|
|
|
{
|
2017-10-30 19:43:58 +00:00
|
|
|
mTransform.scale(mScale);
|
2017-07-17 03:10:29 +00:00
|
|
|
}
|
|
|
|
if (mRotation != 0.0)
|
|
|
|
{
|
|
|
|
// Calculate offset as difference between origin and rotation origin
|
2018-01-23 00:34:30 +00:00
|
|
|
Vector2f rotationSize = getRotationSize();
|
|
|
|
float xOff = (mOrigin.x() - mRotationOrigin.x()) * rotationSize.x();
|
|
|
|
float yOff = (mOrigin.y() - mRotationOrigin.y()) * rotationSize.y();
|
2017-07-17 03:10:29 +00:00
|
|
|
|
|
|
|
// transform to offset point
|
|
|
|
if (xOff != 0.0 || yOff != 0.0)
|
2017-10-28 20:24:35 +00:00
|
|
|
mTransform.translate(Vector3f(xOff * -1, yOff * -1, 0.0f));
|
2017-07-17 03:10:29 +00:00
|
|
|
|
2017-10-30 19:43:58 +00:00
|
|
|
// apply rotation transform
|
|
|
|
mTransform.rotateZ(mRotation);
|
2017-07-17 03:10:29 +00:00
|
|
|
|
|
|
|
// Tranform back to original point
|
|
|
|
if (xOff != 0.0 || yOff != 0.0)
|
2017-10-28 20:24:35 +00:00
|
|
|
mTransform.translate(Vector3f(xOff, yOff, 0.0f));
|
2017-07-17 03:10:29 +00:00
|
|
|
}
|
2017-10-28 20:24:35 +00:00
|
|
|
mTransform.translate(Vector3f(mOrigin.x() * mSize.x() * -1, mOrigin.y() * mSize.y() * -1, 0.0f));
|
2013-07-10 11:29:43 +00:00
|
|
|
return mTransform;
|
|
|
|
}
|
2013-08-14 12:16:49 +00:00
|
|
|
|
2017-11-17 14:58:52 +00:00
|
|
|
void GuiComponent::setValue(const std::string& /*value*/)
|
2013-08-14 12:16:49 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
std::string GuiComponent::getValue() const
|
|
|
|
{
|
|
|
|
return "";
|
|
|
|
}
|
2013-08-19 15:36:48 +00:00
|
|
|
|
|
|
|
void GuiComponent::textInput(const char* text)
|
|
|
|
{
|
2017-11-11 14:56:22 +00:00
|
|
|
for(auto iter = mChildren.cbegin(); iter != mChildren.cend(); iter++)
|
2013-08-19 15:36:48 +00:00
|
|
|
{
|
|
|
|
(*iter)->textInput(text);
|
|
|
|
}
|
|
|
|
}
|
2013-12-08 17:35:43 +00:00
|
|
|
|
2014-04-18 17:19:46 +00:00
|
|
|
void GuiComponent::setAnimation(Animation* anim, int delay, std::function<void()> finishedCallback, bool reverse, unsigned char slot)
|
2013-12-08 17:35:43 +00:00
|
|
|
{
|
2013-12-13 03:17:59 +00:00
|
|
|
assert(slot < MAX_ANIMATIONS);
|
|
|
|
|
|
|
|
AnimationController* oldAnim = mAnimationMap[slot];
|
2014-04-18 17:19:46 +00:00
|
|
|
mAnimationMap[slot] = new AnimationController(anim, delay, finishedCallback, reverse);
|
2013-12-13 03:17:59 +00:00
|
|
|
|
|
|
|
if(oldAnim)
|
|
|
|
delete oldAnim;
|
2013-12-08 17:35:43 +00:00
|
|
|
}
|
|
|
|
|
2014-04-18 17:19:46 +00:00
|
|
|
bool GuiComponent::stopAnimation(unsigned char slot)
|
2013-12-08 17:35:43 +00:00
|
|
|
{
|
2013-12-13 03:17:59 +00:00
|
|
|
assert(slot < MAX_ANIMATIONS);
|
|
|
|
if(mAnimationMap[slot])
|
|
|
|
{
|
|
|
|
delete mAnimationMap[slot];
|
|
|
|
mAnimationMap[slot] = NULL;
|
2014-04-18 17:19:46 +00:00
|
|
|
return true;
|
|
|
|
}else{
|
|
|
|
return false;
|
2013-12-13 03:17:59 +00:00
|
|
|
}
|
2013-12-08 17:35:43 +00:00
|
|
|
}
|
2014-01-01 05:39:22 +00:00
|
|
|
|
2014-04-18 17:19:46 +00:00
|
|
|
bool GuiComponent::cancelAnimation(unsigned char slot)
|
2014-04-15 02:03:11 +00:00
|
|
|
{
|
|
|
|
assert(slot < MAX_ANIMATIONS);
|
|
|
|
if(mAnimationMap[slot])
|
|
|
|
{
|
|
|
|
mAnimationMap[slot]->removeFinishedCallback();
|
|
|
|
delete mAnimationMap[slot];
|
|
|
|
mAnimationMap[slot] = NULL;
|
2014-04-18 17:19:46 +00:00
|
|
|
return true;
|
|
|
|
}else{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
bool GuiComponent::finishAnimation(unsigned char slot)
|
|
|
|
{
|
|
|
|
assert(slot < MAX_ANIMATIONS);
|
|
|
|
if(mAnimationMap[slot])
|
|
|
|
{
|
|
|
|
// skip to animation's end
|
|
|
|
const bool done = mAnimationMap[slot]->update(mAnimationMap[slot]->getAnimation()->getDuration() - mAnimationMap[slot]->getTime());
|
|
|
|
assert(done);
|
|
|
|
|
|
|
|
delete mAnimationMap[slot]; // will also call finishedCallback
|
|
|
|
mAnimationMap[slot] = NULL;
|
|
|
|
return true;
|
|
|
|
}else{
|
|
|
|
return false;
|
2014-04-15 02:03:11 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-05-15 01:58:16 +00:00
|
|
|
bool GuiComponent::advanceAnimation(unsigned char slot, unsigned int time)
|
|
|
|
{
|
|
|
|
assert(slot < MAX_ANIMATIONS);
|
|
|
|
AnimationController* anim = mAnimationMap[slot];
|
|
|
|
if(anim)
|
|
|
|
{
|
|
|
|
bool done = anim->update(time);
|
|
|
|
if(done)
|
|
|
|
{
|
|
|
|
mAnimationMap[slot] = NULL;
|
|
|
|
delete anim;
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}else{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-04-15 02:03:11 +00:00
|
|
|
void GuiComponent::stopAllAnimations()
|
|
|
|
{
|
|
|
|
for(unsigned char i = 0; i < MAX_ANIMATIONS; i++)
|
|
|
|
stopAnimation(i);
|
|
|
|
}
|
|
|
|
|
|
|
|
void GuiComponent::cancelAllAnimations()
|
|
|
|
{
|
|
|
|
for(unsigned char i = 0; i < MAX_ANIMATIONS; i++)
|
|
|
|
cancelAnimation(i);
|
|
|
|
}
|
|
|
|
|
2014-01-25 00:10:13 +00:00
|
|
|
bool GuiComponent::isAnimationPlaying(unsigned char slot) const
|
|
|
|
{
|
|
|
|
return mAnimationMap[slot] != NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool GuiComponent::isAnimationReversed(unsigned char slot) const
|
|
|
|
{
|
|
|
|
assert(mAnimationMap[slot] != NULL);
|
|
|
|
return mAnimationMap[slot]->isReversed();
|
|
|
|
}
|
|
|
|
|
|
|
|
int GuiComponent::getAnimationTime(unsigned char slot) const
|
|
|
|
{
|
|
|
|
assert(mAnimationMap[slot] != NULL);
|
|
|
|
return mAnimationMap[slot]->getTime();
|
|
|
|
}
|
|
|
|
|
2014-01-01 05:39:22 +00:00
|
|
|
void GuiComponent::applyTheme(const std::shared_ptr<ThemeData>& theme, const std::string& view, const std::string& element, unsigned int properties)
|
|
|
|
{
|
2017-10-28 20:24:35 +00:00
|
|
|
Vector2f scale = getParent() ? getParent()->getSize() : Vector2f((float)Renderer::getScreenWidth(), (float)Renderer::getScreenHeight());
|
2014-01-01 05:39:22 +00:00
|
|
|
|
|
|
|
const ThemeData::ThemeElement* elem = theme->getElement(view, element, "");
|
2014-01-03 14:26:39 +00:00
|
|
|
if(!elem)
|
|
|
|
return;
|
2014-01-01 05:39:22 +00:00
|
|
|
|
|
|
|
using namespace ThemeFlags;
|
|
|
|
if(properties & POSITION && elem->has("pos"))
|
|
|
|
{
|
2017-10-28 20:24:35 +00:00
|
|
|
Vector2f denormalized = elem->get<Vector2f>("pos") * scale;
|
|
|
|
setPosition(Vector3f(denormalized.x(), denormalized.y(), 0));
|
2014-01-01 05:39:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if(properties & ThemeFlags::SIZE && elem->has("size"))
|
2017-10-28 20:24:35 +00:00
|
|
|
setSize(elem->get<Vector2f>("size") * scale);
|
2017-04-22 14:15:16 +00:00
|
|
|
|
2017-07-17 03:10:29 +00:00
|
|
|
// position + size also implies origin
|
|
|
|
if((properties & ORIGIN || (properties & POSITION && properties & ThemeFlags::SIZE)) && elem->has("origin"))
|
2017-10-28 20:24:35 +00:00
|
|
|
setOrigin(elem->get<Vector2f>("origin"));
|
2017-07-17 03:10:29 +00:00
|
|
|
|
|
|
|
if(properties & ThemeFlags::ROTATION) {
|
|
|
|
if(elem->has("rotation"))
|
|
|
|
setRotationDegrees(elem->get<float>("rotation"));
|
|
|
|
if(elem->has("rotationOrigin"))
|
2017-10-28 20:24:35 +00:00
|
|
|
setRotationOrigin(elem->get<Vector2f>("rotationOrigin"));
|
2017-07-17 03:10:29 +00:00
|
|
|
}
|
|
|
|
|
2017-04-22 14:15:16 +00:00
|
|
|
if(properties & ThemeFlags::Z_INDEX && elem->has("zIndex"))
|
|
|
|
setZIndex(elem->get<float>("zIndex"));
|
|
|
|
else
|
|
|
|
setZIndex(getDefaultZIndex());
|
2014-01-01 05:39:22 +00:00
|
|
|
}
|
2014-01-25 23:34:29 +00:00
|
|
|
|
|
|
|
void GuiComponent::updateHelpPrompts()
|
|
|
|
{
|
|
|
|
if(getParent())
|
|
|
|
{
|
|
|
|
getParent()->updateHelpPrompts();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
std::vector<HelpPrompt> prompts = getHelpPrompts();
|
|
|
|
|
|
|
|
if(mWindow->peekGui() == this)
|
2014-05-29 20:41:47 +00:00
|
|
|
mWindow->setHelpPrompts(prompts, getHelpStyle());
|
|
|
|
}
|
|
|
|
|
|
|
|
HelpStyle GuiComponent::getHelpStyle()
|
|
|
|
{
|
|
|
|
return HelpStyle();
|
2014-01-25 23:34:29 +00:00
|
|
|
}
|
2016-09-12 11:31:44 +00:00
|
|
|
|
|
|
|
bool GuiComponent::isProcessing() const
|
|
|
|
{
|
|
|
|
return mIsProcessing;
|
|
|
|
}
|
2016-12-04 23:47:34 +00:00
|
|
|
|
|
|
|
void GuiComponent::onShow()
|
|
|
|
{
|
|
|
|
for(unsigned int i = 0; i < getChildCount(); i++)
|
|
|
|
getChild(i)->onShow();
|
|
|
|
}
|
|
|
|
|
|
|
|
void GuiComponent::onHide()
|
|
|
|
{
|
|
|
|
for(unsigned int i = 0; i < getChildCount(); i++)
|
|
|
|
getChild(i)->onHide();
|
|
|
|
}
|
|
|
|
|
2017-01-25 15:00:56 +00:00
|
|
|
void GuiComponent::onScreenSaverActivate()
|
|
|
|
{
|
|
|
|
for(unsigned int i = 0; i < getChildCount(); i++)
|
|
|
|
getChild(i)->onScreenSaverActivate();
|
|
|
|
}
|
2016-12-04 23:47:34 +00:00
|
|
|
|
2017-01-25 15:00:56 +00:00
|
|
|
void GuiComponent::onScreenSaverDeactivate()
|
|
|
|
{
|
|
|
|
for(unsigned int i = 0; i < getChildCount(); i++)
|
|
|
|
getChild(i)->onScreenSaverDeactivate();
|
|
|
|
}
|
|
|
|
|
|
|
|
void GuiComponent::topWindow(bool isTop)
|
|
|
|
{
|
|
|
|
for(unsigned int i = 0; i < getChildCount(); i++)
|
|
|
|
getChild(i)->topWindow(isTop);
|
|
|
|
}
|