2020-09-15 20:57:54 +00:00
|
|
|
// SPDX-License-Identifier: MIT
|
2020-05-24 08:29:29 +00:00
|
|
|
//
|
2020-09-15 20:57:54 +00:00
|
|
|
// EmulationStation Desktop Edition
|
2020-06-21 12:25:28 +00:00
|
|
|
// GuiComponent.cpp
|
2020-05-24 08:29:29 +00:00
|
|
|
//
|
2020-06-21 12:25:28 +00:00
|
|
|
// Basic GUI component handling such as placement, rotation, Z-order, rendering and animation.
|
2020-05-24 08:29:29 +00:00
|
|
|
//
|
|
|
|
|
2013-06-02 15:08:32 +00:00
|
|
|
#include "GuiComponent.h"
|
2017-11-01 22:21:10 +00:00
|
|
|
|
2013-06-02 16:11:29 +00:00
|
|
|
#include "Log.h"
|
2014-01-01 05:39:22 +00:00
|
|
|
#include "ThemeData.h"
|
2017-11-01 22:21:10 +00:00
|
|
|
#include "Window.h"
|
2021-07-07 18:31:46 +00:00
|
|
|
#include "animations/Animation.h"
|
|
|
|
#include "renderers/Renderer.h"
|
2020-09-15 20:57:54 +00:00
|
|
|
|
2018-01-29 22:50:10 +00:00
|
|
|
#include <algorithm>
|
2013-06-02 15:08:32 +00:00
|
|
|
|
2020-05-24 08:29:29 +00:00
|
|
|
GuiComponent::GuiComponent(Window* window)
|
2021-07-07 18:31:46 +00:00
|
|
|
: mWindow(window)
|
|
|
|
, mParent(nullptr)
|
2021-09-18 07:53:26 +00:00
|
|
|
, mOpacity(255)
|
2021-07-07 18:31:46 +00:00
|
|
|
, mColor(0)
|
2021-09-18 07:53:26 +00:00
|
|
|
, mSaturation(1.0f)
|
2021-07-07 18:31:46 +00:00
|
|
|
, mColorShift(0)
|
|
|
|
, mColorShiftEnd(0)
|
2021-08-15 17:30:31 +00:00
|
|
|
, mPosition({})
|
2021-08-16 16:25:01 +00:00
|
|
|
, mOrigin({})
|
2021-07-07 18:31:46 +00:00
|
|
|
, mRotationOrigin(0.5f, 0.5f)
|
2021-08-16 16:25:01 +00:00
|
|
|
, mSize({})
|
2021-07-07 18:31:46 +00:00
|
|
|
, mIsProcessing(false)
|
|
|
|
, mVisible(true)
|
|
|
|
, mEnabled(true)
|
2021-09-18 07:53:26 +00:00
|
|
|
, mTransform(Renderer::getIdentity())
|
2020-05-24 08:29:29 +00:00
|
|
|
{
|
2020-06-21 12:25:28 +00:00
|
|
|
for (unsigned char i = 0; i < MAX_ANIMATIONS; i++)
|
2020-06-23 18:07:00 +00:00
|
|
|
mAnimationMap[i] = nullptr;
|
2013-06-02 15:08:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
GuiComponent::~GuiComponent()
|
|
|
|
{
|
2020-06-21 12:25:28 +00:00
|
|
|
mWindow->removeGui(this);
|
2013-06-02 15:08:32 +00:00
|
|
|
|
2020-06-21 12:25:28 +00:00
|
|
|
cancelAllAnimations();
|
2013-12-13 03:17:59 +00:00
|
|
|
|
2020-06-21 12:25:28 +00:00
|
|
|
if (mParent)
|
|
|
|
mParent->removeChild(this);
|
2013-06-19 01:12:30 +00:00
|
|
|
|
2020-06-21 12:25:28 +00:00
|
|
|
for (unsigned int i = 0; i < getChildCount(); i++)
|
2020-06-23 18:07:00 +00:00
|
|
|
getChild(i)->setParent(nullptr);
|
2013-06-02 15:08:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
bool GuiComponent::input(InputConfig* config, Input input)
|
|
|
|
{
|
2020-06-21 12:25:28 +00:00
|
|
|
for (unsigned int i = 0; i < getChildCount(); i++) {
|
|
|
|
if (getChild(i)->input(config, input))
|
|
|
|
return true;
|
|
|
|
}
|
2013-06-02 15:08:32 +00:00
|
|
|
|
2020-06-21 12:25:28 +00:00
|
|
|
return false;
|
2013-06-02 15:08:32 +00:00
|
|
|
}
|
|
|
|
|
2014-06-05 19:29:07 +00:00
|
|
|
void GuiComponent::updateSelf(int deltaTime)
|
2013-06-02 15:08:32 +00:00
|
|
|
{
|
2020-06-21 12:25:28 +00:00
|
|
|
for (unsigned char i = 0; i < MAX_ANIMATIONS; i++)
|
|
|
|
advanceAnimation(i, deltaTime);
|
2014-06-05 19:29:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void GuiComponent::updateChildren(int deltaTime)
|
|
|
|
{
|
2020-06-21 12:25:28 +00:00
|
|
|
for (unsigned int i = 0; i < getChildCount(); i++)
|
|
|
|
getChild(i)->update(deltaTime);
|
2013-06-02 15:08:32 +00:00
|
|
|
}
|
|
|
|
|
2014-06-05 19:29:07 +00:00
|
|
|
void GuiComponent::update(int deltaTime)
|
|
|
|
{
|
2020-06-21 12:25:28 +00:00
|
|
|
updateSelf(deltaTime);
|
|
|
|
updateChildren(deltaTime);
|
2014-06-05 19:29:07 +00:00
|
|
|
}
|
|
|
|
|
2021-08-15 17:30:31 +00:00
|
|
|
void GuiComponent::render(const glm::mat4& parentTrans)
|
2013-06-02 19:34:50 +00:00
|
|
|
{
|
2020-06-21 12:25:28 +00:00
|
|
|
if (!isVisible())
|
|
|
|
return;
|
2019-07-22 03:13:48 +00:00
|
|
|
|
2021-08-17 16:41:45 +00:00
|
|
|
glm::mat4 trans{parentTrans * getTransform()};
|
2020-06-21 12:25:28 +00:00
|
|
|
renderChildren(trans);
|
2013-06-02 19:34:50 +00:00
|
|
|
}
|
|
|
|
|
2021-08-15 17:30:31 +00:00
|
|
|
void GuiComponent::renderChildren(const glm::mat4& transform) const
|
2013-06-02 15:08:32 +00:00
|
|
|
{
|
2020-06-21 12:25:28 +00:00
|
|
|
for (unsigned int i = 0; i < getChildCount(); i++)
|
|
|
|
getChild(i)->render(transform);
|
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
|
|
|
{
|
2021-09-28 19:46:45 +00:00
|
|
|
if (mPosition.x == x && mPosition.y == y && mPosition.z == z)
|
|
|
|
return;
|
|
|
|
|
2021-08-17 16:41:45 +00:00
|
|
|
mPosition = glm::vec3{x, y, z};
|
2020-06-21 12:25:28 +00:00
|
|
|
onPositionChanged();
|
2013-06-02 15:08:32 +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
|
|
|
{
|
2021-09-28 19:46:45 +00:00
|
|
|
if (mOrigin.x == x && mOrigin.y == y)
|
|
|
|
return;
|
|
|
|
|
2021-08-17 16:41:45 +00:00
|
|
|
mOrigin = glm::vec2{x, y};
|
2020-06-21 12:25:28 +00:00
|
|
|
onOriginChanged();
|
2013-06-02 22:33:49 +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
|
|
|
{
|
2021-09-28 19:46:45 +00:00
|
|
|
if (mSize.x == w && mSize.y == h)
|
|
|
|
return;
|
|
|
|
|
2021-08-17 16:41:45 +00:00
|
|
|
mSize = glm::vec2{w, h};
|
2013-07-02 23:48:39 +00:00
|
|
|
onSizeChanged();
|
|
|
|
}
|
|
|
|
|
2021-08-16 16:25:01 +00:00
|
|
|
glm::vec2 GuiComponent::getCenter() const
|
2017-07-17 03:10:29 +00:00
|
|
|
{
|
2021-08-17 16:41:45 +00:00
|
|
|
return glm::vec2{mPosition.x - (getSize().x * mOrigin.x) + getSize().x / 2.0f,
|
|
|
|
mPosition.y - (getSize().y * mOrigin.y) + getSize().y / 2.0f};
|
2017-07-17 03:10:29 +00:00
|
|
|
}
|
|
|
|
|
2013-06-02 16:11:29 +00:00
|
|
|
void GuiComponent::addChild(GuiComponent* cmp)
|
|
|
|
{
|
2020-06-21 12:25:28 +00:00
|
|
|
mChildren.push_back(cmp);
|
2013-06-02 16:11:29 +00:00
|
|
|
|
2020-06-21 12:25:28 +00:00
|
|
|
if (cmp->getParent())
|
|
|
|
cmp->getParent()->removeChild(cmp);
|
2013-06-02 16:11:29 +00:00
|
|
|
|
2020-06-21 12:25:28 +00:00
|
|
|
cmp->setParent(this);
|
2013-06-02 16:11:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void GuiComponent::removeChild(GuiComponent* cmp)
|
|
|
|
{
|
2020-06-21 12:25:28 +00:00
|
|
|
if (!cmp->getParent())
|
|
|
|
return;
|
2013-11-12 23:28:15 +00:00
|
|
|
|
2020-06-25 17:52:38 +00:00
|
|
|
if (cmp->getParent() != this) {
|
2020-06-21 12:25:28 +00:00
|
|
|
LOG(LogError) << "Tried to remove child from incorrect parent!";
|
2020-06-25 17:52:38 +00:00
|
|
|
}
|
2013-06-02 16:11:29 +00:00
|
|
|
|
2020-06-23 18:07:00 +00:00
|
|
|
cmp->setParent(nullptr);
|
2013-06-02 16:11:29 +00:00
|
|
|
|
2020-06-21 12:25:28 +00:00
|
|
|
for (auto i = mChildren.cbegin(); i != mChildren.cend(); i++) {
|
|
|
|
if (*i == cmp) {
|
|
|
|
mChildren.erase(i);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
2013-06-02 16:11:29 +00:00
|
|
|
}
|
|
|
|
|
2017-04-22 14:15:16 +00:00
|
|
|
void GuiComponent::sortChildren()
|
|
|
|
{
|
2020-06-21 12:25:28 +00:00
|
|
|
std::stable_sort(mChildren.begin(), mChildren.end(), [](GuiComponent* a, GuiComponent* b) {
|
|
|
|
return b->getZIndex() > a->getZIndex();
|
|
|
|
});
|
2017-04-22 14:15:16 +00:00
|
|
|
}
|
|
|
|
|
2020-12-15 17:49:43 +00:00
|
|
|
int GuiComponent::getChildIndex() const
|
|
|
|
{
|
|
|
|
std::vector<GuiComponent*>::iterator it =
|
2021-07-07 18:31:46 +00:00
|
|
|
std::find(getParent()->mChildren.begin(), getParent()->mChildren.end(), this);
|
2020-12-15 17:49:43 +00:00
|
|
|
|
|
|
|
if (it != getParent()->mChildren.end())
|
2020-12-29 10:06:01 +00:00
|
|
|
return static_cast<int>(std::distance(getParent()->mChildren.begin(), it));
|
2020-12-15 17:49:43 +00:00
|
|
|
else
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2013-07-02 14:51:33 +00:00
|
|
|
void GuiComponent::setOpacity(unsigned char opacity)
|
|
|
|
{
|
2021-09-28 19:46:45 +00:00
|
|
|
if (mOpacity == opacity)
|
|
|
|
return;
|
|
|
|
|
2020-06-21 12:25:28 +00:00
|
|
|
mOpacity = opacity;
|
|
|
|
for (auto it = mChildren.cbegin(); it != mChildren.cend(); it++)
|
|
|
|
(*it)->setOpacity(opacity);
|
2013-07-03 00:12:49 +00:00
|
|
|
}
|
2013-07-10 11:29:43 +00:00
|
|
|
|
2021-08-15 17:30:31 +00:00
|
|
|
const glm::mat4& GuiComponent::getTransform()
|
2013-07-10 11:29:43 +00:00
|
|
|
{
|
2021-08-15 17:30:31 +00:00
|
|
|
mTransform = Renderer::getIdentity();
|
|
|
|
mTransform = glm::translate(mTransform, mPosition);
|
2021-07-07 18:31:46 +00:00
|
|
|
|
|
|
|
if (mScale != 1.0f)
|
2021-08-17 16:41:45 +00:00
|
|
|
mTransform = glm::scale(mTransform, glm::vec3{mScale});
|
2021-07-07 18:31:46 +00:00
|
|
|
|
|
|
|
if (mRotation != 0.0f) {
|
2020-09-04 17:05:48 +00:00
|
|
|
// Calculate offset as difference between origin and rotation origin.
|
2021-08-17 16:41:45 +00:00
|
|
|
glm::vec2 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
|
|
|
|
2020-09-04 17:05:48 +00:00
|
|
|
// Transform to offset point.
|
2021-07-07 18:31:46 +00:00
|
|
|
if (xOff != 0.0f || yOff != 0.0f)
|
2021-08-17 16:41:45 +00:00
|
|
|
mTransform = glm::translate(mTransform, glm::vec3{xOff * -1.0f, yOff * -1.0f, 0.0f});
|
2017-07-17 03:10:29 +00:00
|
|
|
|
2020-09-04 17:05:48 +00:00
|
|
|
// Apply rotation transform.
|
2021-08-17 16:41:45 +00:00
|
|
|
mTransform = glm::rotate(mTransform, mRotation, glm::vec3{0.0f, 0.0f, 1.0f});
|
2017-07-17 03:10:29 +00:00
|
|
|
|
2020-09-04 17:05:48 +00:00
|
|
|
// Transform back to original point.
|
2021-07-07 18:31:46 +00:00
|
|
|
if (xOff != 0.0f || yOff != 0.0f)
|
2021-08-17 16:41:45 +00:00
|
|
|
mTransform = glm::translate(mTransform, glm::vec3{xOff, yOff, 0.0f});
|
2020-06-21 12:25:28 +00:00
|
|
|
}
|
2021-08-16 16:25:01 +00:00
|
|
|
mTransform = glm::translate(
|
2021-08-17 16:41:45 +00:00
|
|
|
mTransform, glm::vec3{mOrigin.x * mSize.x * -1.0f, mOrigin.y * mSize.y * -1.0f, 0.0f});
|
2021-08-15 17:30:31 +00:00
|
|
|
|
2020-06-21 12:25:28 +00:00
|
|
|
return mTransform;
|
2013-07-10 11:29:43 +00:00
|
|
|
}
|
2013-08-14 12:16:49 +00:00
|
|
|
|
2020-12-16 22:59:00 +00:00
|
|
|
void GuiComponent::textInput(const std::string& text)
|
2013-08-19 15:36:48 +00:00
|
|
|
{
|
2020-06-21 12:25:28 +00:00
|
|
|
for (auto iter = mChildren.cbegin(); iter != mChildren.cend(); iter++)
|
|
|
|
(*iter)->textInput(text);
|
2013-08-19 15:36:48 +00:00
|
|
|
}
|
2013-12-08 17:35:43 +00:00
|
|
|
|
2021-07-07 18:31: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
|
|
|
{
|
2020-06-21 12:25:28 +00:00
|
|
|
assert(slot < MAX_ANIMATIONS);
|
2013-12-13 03:17:59 +00:00
|
|
|
|
2020-06-21 12:25:28 +00:00
|
|
|
AnimationController* oldAnim = mAnimationMap[slot];
|
|
|
|
mAnimationMap[slot] = new AnimationController(anim, delay, finishedCallback, reverse);
|
2013-12-13 03:17:59 +00:00
|
|
|
|
2020-06-21 12:25:28 +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
|
|
|
{
|
2020-06-21 12:25:28 +00:00
|
|
|
assert(slot < MAX_ANIMATIONS);
|
|
|
|
if (mAnimationMap[slot]) {
|
|
|
|
delete mAnimationMap[slot];
|
2020-06-23 18:07:00 +00:00
|
|
|
mAnimationMap[slot] = nullptr;
|
2020-06-21 12:25:28 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
return false;
|
|
|
|
}
|
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
|
|
|
{
|
2020-06-21 12:25:28 +00:00
|
|
|
assert(slot < MAX_ANIMATIONS);
|
|
|
|
if (mAnimationMap[slot]) {
|
|
|
|
mAnimationMap[slot]->removeFinishedCallback();
|
|
|
|
delete mAnimationMap[slot];
|
2020-06-23 18:07:00 +00:00
|
|
|
mAnimationMap[slot] = nullptr;
|
2020-06-21 12:25:28 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
return false;
|
|
|
|
}
|
2014-04-18 17:19:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
bool GuiComponent::finishAnimation(unsigned char slot)
|
|
|
|
{
|
2020-06-21 12:25:28 +00:00
|
|
|
assert(slot < MAX_ANIMATIONS);
|
2020-11-16 16:44:33 +00:00
|
|
|
AnimationController* anim = mAnimationMap[slot];
|
|
|
|
if (anim) {
|
2020-09-04 17:05:48 +00:00
|
|
|
// Skip to animation's end.
|
2020-11-16 16:44:33 +00:00
|
|
|
const bool done = anim->update(anim->getAnimation()->getDuration() - anim->getTime());
|
2021-06-11 15:02:06 +00:00
|
|
|
if (done) {
|
2020-11-16 16:44:33 +00:00
|
|
|
mAnimationMap[slot] = nullptr;
|
|
|
|
delete anim; // Will also call finishedCallback.
|
|
|
|
}
|
2020-06-21 12:25:28 +00:00
|
|
|
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)
|
|
|
|
{
|
2020-06-21 12:25:28 +00:00
|
|
|
assert(slot < MAX_ANIMATIONS);
|
|
|
|
AnimationController* anim = mAnimationMap[slot];
|
|
|
|
if (anim) {
|
|
|
|
bool done = anim->update(time);
|
|
|
|
if (done) {
|
2020-06-23 18:07:00 +00:00
|
|
|
mAnimationMap[slot] = nullptr;
|
2020-11-16 16:44:33 +00:00
|
|
|
delete anim; // Will also call finishedCallback.
|
2020-06-21 12:25:28 +00:00
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
return false;
|
|
|
|
}
|
2014-05-15 01:58:16 +00:00
|
|
|
}
|
|
|
|
|
2014-04-15 02:03:11 +00:00
|
|
|
void GuiComponent::stopAllAnimations()
|
|
|
|
{
|
2020-06-21 12:25:28 +00:00
|
|
|
for (unsigned char i = 0; i < MAX_ANIMATIONS; i++)
|
|
|
|
stopAnimation(i);
|
2014-04-15 02:03:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void GuiComponent::cancelAllAnimations()
|
|
|
|
{
|
2020-06-21 12:25:28 +00:00
|
|
|
for (unsigned char i = 0; i < MAX_ANIMATIONS; i++)
|
|
|
|
cancelAnimation(i);
|
2014-04-15 02:03:11 +00:00
|
|
|
}
|
|
|
|
|
2020-05-24 08:29:29 +00:00
|
|
|
void GuiComponent::applyTheme(const std::shared_ptr<ThemeData>& theme,
|
2021-07-07 18:31:46 +00:00
|
|
|
const std::string& view,
|
|
|
|
const std::string& element,
|
|
|
|
unsigned int properties)
|
2014-01-01 05:39:22 +00:00
|
|
|
{
|
2021-08-17 16:41:45 +00:00
|
|
|
glm::vec2 scale{getParent() ? getParent()->getSize() :
|
|
|
|
glm::vec2{static_cast<float>(Renderer::getScreenWidth()),
|
|
|
|
static_cast<float>(Renderer::getScreenHeight())}};
|
2014-01-01 05:39:22 +00:00
|
|
|
|
2020-06-21 12:25:28 +00:00
|
|
|
const ThemeData::ThemeElement* elem = theme->getElement(view, element, "");
|
|
|
|
if (!elem)
|
|
|
|
return;
|
2014-01-01 05:39:22 +00:00
|
|
|
|
2020-06-21 12:25:28 +00:00
|
|
|
using namespace ThemeFlags;
|
|
|
|
if (properties & POSITION && elem->has("pos")) {
|
2021-08-17 16:41:45 +00:00
|
|
|
glm::vec2 denormalized{elem->get<glm::vec2>("pos") * scale};
|
|
|
|
setPosition(glm::vec3{denormalized.x, denormalized.y, 0.0f});
|
2020-06-21 12:25:28 +00:00
|
|
|
}
|
2014-01-01 05:39:22 +00:00
|
|
|
|
2020-06-21 12:25:28 +00:00
|
|
|
if (properties & ThemeFlags::SIZE && elem->has("size"))
|
2021-08-16 16:25:01 +00:00
|
|
|
setSize(elem->get<glm::vec2>("size") * scale);
|
2017-04-22 14:15:16 +00:00
|
|
|
|
2021-07-07 18:31:46 +00:00
|
|
|
// Position + size also implies origin.
|
|
|
|
if ((properties & ORIGIN || (properties & POSITION && properties & ThemeFlags::SIZE)) &&
|
|
|
|
elem->has("origin")) {
|
2021-08-16 16:25:01 +00:00
|
|
|
setOrigin(elem->get<glm::vec2>("origin"));
|
2020-06-21 12:25:28 +00:00
|
|
|
}
|
2017-07-17 03:10:29 +00:00
|
|
|
|
2020-06-21 12:25:28 +00:00
|
|
|
if (properties & ThemeFlags::ROTATION) {
|
|
|
|
if (elem->has("rotation"))
|
|
|
|
setRotationDegrees(elem->get<float>("rotation"));
|
|
|
|
if (elem->has("rotationOrigin"))
|
2021-08-16 16:25:01 +00:00
|
|
|
setRotationOrigin(elem->get<glm::vec2>("rotationOrigin"));
|
2020-06-21 12:25:28 +00:00
|
|
|
}
|
2017-07-17 03:10:29 +00:00
|
|
|
|
2020-06-21 12:25:28 +00:00
|
|
|
if (properties & ThemeFlags::Z_INDEX && elem->has("zIndex"))
|
|
|
|
setZIndex(elem->get<float>("zIndex"));
|
|
|
|
else
|
|
|
|
setZIndex(getDefaultZIndex());
|
2019-07-22 03:13:48 +00:00
|
|
|
|
2020-06-21 12:25:28 +00:00
|
|
|
if (properties & ThemeFlags::VISIBLE && elem->has("visible"))
|
|
|
|
setVisible(elem->get<bool>("visible"));
|
|
|
|
else
|
|
|
|
setVisible(true);
|
2014-01-01 05:39:22 +00:00
|
|
|
}
|
2014-01-25 23:34:29 +00:00
|
|
|
|
|
|
|
void GuiComponent::updateHelpPrompts()
|
|
|
|
{
|
2020-06-21 12:25:28 +00:00
|
|
|
if (getParent()) {
|
|
|
|
getParent()->updateHelpPrompts();
|
|
|
|
return;
|
|
|
|
}
|
2014-01-25 23:34:29 +00:00
|
|
|
|
2020-06-21 12:25:28 +00:00
|
|
|
std::vector<HelpPrompt> prompts = getHelpPrompts();
|
2014-01-25 23:34:29 +00:00
|
|
|
|
2020-06-21 12:25:28 +00:00
|
|
|
if (mWindow->peekGui() == this)
|
|
|
|
mWindow->setHelpPrompts(prompts, getHelpStyle());
|
2014-05-29 20:41:47 +00:00
|
|
|
}
|
|
|
|
|
2016-12-04 23:47:34 +00:00
|
|
|
void GuiComponent::onShow()
|
|
|
|
{
|
2020-06-21 12:25:28 +00:00
|
|
|
for (unsigned int i = 0; i < getChildCount(); i++)
|
|
|
|
getChild(i)->onShow();
|
2016-12-04 23:47:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void GuiComponent::onHide()
|
|
|
|
{
|
2020-06-21 12:25:28 +00:00
|
|
|
for (unsigned int i = 0; i < getChildCount(); i++)
|
|
|
|
getChild(i)->onHide();
|
2016-12-04 23:47:34 +00:00
|
|
|
}
|
|
|
|
|
2021-01-31 19:51:24 +00:00
|
|
|
void GuiComponent::onStopVideo()
|
|
|
|
{
|
|
|
|
for (unsigned int i = 0; i < getChildCount(); i++)
|
|
|
|
getChild(i)->onStopVideo();
|
|
|
|
}
|
|
|
|
|
2020-09-15 20:57:54 +00:00
|
|
|
void GuiComponent::onPauseVideo()
|
|
|
|
{
|
|
|
|
for (unsigned int i = 0; i < getChildCount(); i++)
|
|
|
|
getChild(i)->onPauseVideo();
|
|
|
|
}
|
|
|
|
|
2020-09-26 20:15:36 +00:00
|
|
|
void GuiComponent::onUnpauseVideo()
|
|
|
|
{
|
|
|
|
for (unsigned int i = 0; i < getChildCount(); i++)
|
|
|
|
getChild(i)->onUnpauseVideo();
|
|
|
|
}
|
|
|
|
|
2020-11-10 21:33:57 +00:00
|
|
|
void GuiComponent::onScreensaverActivate()
|
2017-01-25 15:00:56 +00:00
|
|
|
{
|
2020-06-21 12:25:28 +00:00
|
|
|
for (unsigned int i = 0; i < getChildCount(); i++)
|
2020-11-10 21:33:57 +00:00
|
|
|
getChild(i)->onScreensaverActivate();
|
2017-01-25 15:00:56 +00:00
|
|
|
}
|
2016-12-04 23:47:34 +00:00
|
|
|
|
2020-11-10 21:33:57 +00:00
|
|
|
void GuiComponent::onScreensaverDeactivate()
|
2017-01-25 15:00:56 +00:00
|
|
|
{
|
2020-06-21 12:25:28 +00:00
|
|
|
for (unsigned int i = 0; i < getChildCount(); i++)
|
2020-11-10 21:33:57 +00:00
|
|
|
getChild(i)->onScreensaverDeactivate();
|
2017-01-25 15:00:56 +00:00
|
|
|
}
|
|
|
|
|
2020-07-18 11:21:44 +00:00
|
|
|
void GuiComponent::onGameLaunchedActivate()
|
|
|
|
{
|
|
|
|
for (unsigned int i = 0; i < getChildCount(); i++)
|
|
|
|
getChild(i)->onGameLaunchedActivate();
|
|
|
|
}
|
|
|
|
|
|
|
|
void GuiComponent::onGameLaunchedDeactivate()
|
|
|
|
{
|
|
|
|
for (unsigned int i = 0; i < getChildCount(); i++)
|
|
|
|
getChild(i)->onGameLaunchedDeactivate();
|
|
|
|
}
|
|
|
|
|
2017-01-25 15:00:56 +00:00
|
|
|
void GuiComponent::topWindow(bool isTop)
|
|
|
|
{
|
2020-06-21 12:25:28 +00:00
|
|
|
for (unsigned int i = 0; i < getChildCount(); i++)
|
|
|
|
getChild(i)->topWindow(isTop);
|
2020-05-24 08:29:29 +00:00
|
|
|
}
|