mirror of
https://github.com/RetroDECK/ES-DE.git
synced 2024-11-22 14:15:38 +00:00
Merge pull request #599 from jrassa/image-video-component-theme-cleanup
Image video component theme cleanup
This commit is contained in:
commit
eda3fe9c3b
|
@ -405,20 +405,14 @@ void ImageComponent::applyTheme(const std::shared_ptr<ThemeData>& theme, const s
|
|||
{
|
||||
using namespace ThemeFlags;
|
||||
|
||||
GuiComponent::applyTheme(theme, view, element, (properties ^ SIZE) | ((properties & (SIZE | POSITION)) ? ORIGIN : 0));
|
||||
|
||||
const ThemeData::ThemeElement* elem = theme->getElement(view, element, "image");
|
||||
if(!elem)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Vector2f scale = getParent() ? getParent()->getSize() : Vector2f((float)Renderer::getScreenWidth(), (float)Renderer::getScreenHeight());
|
||||
|
||||
if(properties & POSITION && elem->has("pos"))
|
||||
{
|
||||
Vector2f denormalized = elem->get<Vector2f>("pos") * scale;
|
||||
setPosition(Vector3f(denormalized.x(), denormalized.y(), 0));
|
||||
}
|
||||
|
||||
if(properties & ThemeFlags::SIZE)
|
||||
{
|
||||
if(elem->has("size"))
|
||||
|
@ -429,13 +423,8 @@ void ImageComponent::applyTheme(const std::shared_ptr<ThemeData>& theme, const s
|
|||
setMinSize(elem->get<Vector2f>("minSize") * scale);
|
||||
}
|
||||
|
||||
// position + size also implies origin
|
||||
if((properties & ORIGIN || (properties & POSITION && properties & ThemeFlags::SIZE)) && elem->has("origin"))
|
||||
setOrigin(elem->get<Vector2f>("origin"));
|
||||
|
||||
if(elem->has("default")) {
|
||||
if(elem->has("default"))
|
||||
setDefaultImage(elem->get<std::string>("default"));
|
||||
}
|
||||
|
||||
if(properties & PATH && elem->has("path"))
|
||||
{
|
||||
|
@ -457,23 +446,6 @@ void ImageComponent::applyTheme(const std::shared_ptr<ThemeData>& theme, const s
|
|||
if (elem->has("gradientType"))
|
||||
setColorGradientHorizontal(!(elem->get<std::string>("gradientType").compare("horizontal")));
|
||||
}
|
||||
|
||||
if(properties & ThemeFlags::ROTATION) {
|
||||
if(elem->has("rotation"))
|
||||
setRotationDegrees(elem->get<float>("rotation"));
|
||||
if(elem->has("rotationOrigin"))
|
||||
setRotationOrigin(elem->get<Vector2f>("rotationOrigin"));
|
||||
}
|
||||
|
||||
if(properties & ThemeFlags::Z_INDEX && elem->has("zIndex"))
|
||||
setZIndex(elem->get<float>("zIndex"));
|
||||
else
|
||||
setZIndex(getDefaultZIndex());
|
||||
|
||||
if(properties & ThemeFlags::VISIBLE && elem->has("visible"))
|
||||
setVisible(elem->get<bool>("visible"));
|
||||
else
|
||||
setVisible(true);
|
||||
}
|
||||
|
||||
std::vector<HelpPrompt> ImageComponent::getHelpPrompts()
|
||||
|
|
|
@ -90,6 +90,11 @@ void VideoComponent::onOriginChanged()
|
|||
// Update the embeded static image
|
||||
mStaticImage.setOrigin(mOrigin);
|
||||
}
|
||||
void VideoComponent::onPositionChanged()
|
||||
{
|
||||
// Update the embeded static image
|
||||
mStaticImage.setPosition(mPosition);
|
||||
}
|
||||
|
||||
void VideoComponent::onSizeChanged()
|
||||
{
|
||||
|
@ -175,21 +180,14 @@ void VideoComponent::applyTheme(const std::shared_ptr<ThemeData>& theme, const s
|
|||
{
|
||||
using namespace ThemeFlags;
|
||||
|
||||
GuiComponent::applyTheme(theme, view, element, (properties ^ SIZE) | ((properties & (SIZE | POSITION)) ? ORIGIN : 0));
|
||||
|
||||
const ThemeData::ThemeElement* elem = theme->getElement(view, element, "video");
|
||||
if(!elem)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Vector2f scale = getParent() ? getParent()->getSize() : Vector2f((float)Renderer::getScreenWidth(), (float)Renderer::getScreenHeight());
|
||||
|
||||
if ((properties & POSITION) && elem->has("pos"))
|
||||
{
|
||||
Vector2f denormalized = elem->get<Vector2f>("pos") * scale;
|
||||
setPosition(Vector3f(denormalized.x(), denormalized.y(), 0));
|
||||
mStaticImage.setPosition(Vector3f(denormalized.x(), denormalized.y(), 0));
|
||||
}
|
||||
|
||||
if(properties & ThemeFlags::SIZE)
|
||||
{
|
||||
if(elem->has("size"))
|
||||
|
@ -198,10 +196,6 @@ void VideoComponent::applyTheme(const std::shared_ptr<ThemeData>& theme, const s
|
|||
setMaxSize(elem->get<Vector2f>("maxSize") * scale);
|
||||
}
|
||||
|
||||
// position + size also implies origin
|
||||
if (((properties & ORIGIN) || ((properties & POSITION) && (properties & ThemeFlags::SIZE))) && elem->has("origin"))
|
||||
setOrigin(elem->get<Vector2f>("origin"));
|
||||
|
||||
if(elem->has("default"))
|
||||
mConfig.defaultVideoPath = elem->get<std::string>("default");
|
||||
|
||||
|
@ -213,23 +207,6 @@ void VideoComponent::applyTheme(const std::shared_ptr<ThemeData>& theme, const s
|
|||
|
||||
if (elem->has("showSnapshotDelay"))
|
||||
mConfig.showSnapshotDelay = elem->get<bool>("showSnapshotDelay");
|
||||
|
||||
if(properties & ThemeFlags::ROTATION) {
|
||||
if(elem->has("rotation"))
|
||||
setRotationDegrees(elem->get<float>("rotation"));
|
||||
if(elem->has("rotationOrigin"))
|
||||
setRotationOrigin(elem->get<Vector2f>("rotationOrigin"));
|
||||
}
|
||||
|
||||
if(properties & ThemeFlags::Z_INDEX && elem->has("zIndex"))
|
||||
setZIndex(elem->get<float>("zIndex"));
|
||||
else
|
||||
setZIndex(getDefaultZIndex());
|
||||
|
||||
if(properties & ThemeFlags::VISIBLE && elem->has("visible"))
|
||||
setVisible(elem->get<bool>("visible"));
|
||||
else
|
||||
setVisible(true);
|
||||
}
|
||||
|
||||
std::vector<HelpPrompt> VideoComponent::getHelpPrompts()
|
||||
|
|
|
@ -45,6 +45,7 @@ public:
|
|||
virtual void topWindow(bool isTop) override;
|
||||
|
||||
void onOriginChanged() override;
|
||||
void onPositionChanged() override;
|
||||
void onSizeChanged() override;
|
||||
void setOpacity(unsigned char opacity) override;
|
||||
|
||||
|
|
Loading…
Reference in a new issue