diff --git a/es-core/src/components/ImageComponent.cpp b/es-core/src/components/ImageComponent.cpp index 6ad41d18e..4f1a6f0be 100644 --- a/es-core/src/components/ImageComponent.cpp +++ b/es-core/src/components/ImageComponent.cpp @@ -405,20 +405,14 @@ void ImageComponent::applyTheme(const std::shared_ptr& 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("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& theme, const s setMinSize(elem->get("minSize") * scale); } - // position + size also implies origin - if((properties & ORIGIN || (properties & POSITION && properties & ThemeFlags::SIZE)) && elem->has("origin")) - setOrigin(elem->get("origin")); - - if(elem->has("default")) { + if(elem->has("default")) setDefaultImage(elem->get("default")); - } if(properties & PATH && elem->has("path")) { @@ -457,23 +446,6 @@ void ImageComponent::applyTheme(const std::shared_ptr& theme, const s if (elem->has("gradientType")) setColorGradientHorizontal(!(elem->get("gradientType").compare("horizontal"))); } - - if(properties & ThemeFlags::ROTATION) { - if(elem->has("rotation")) - setRotationDegrees(elem->get("rotation")); - if(elem->has("rotationOrigin")) - setRotationOrigin(elem->get("rotationOrigin")); - } - - if(properties & ThemeFlags::Z_INDEX && elem->has("zIndex")) - setZIndex(elem->get("zIndex")); - else - setZIndex(getDefaultZIndex()); - - if(properties & ThemeFlags::VISIBLE && elem->has("visible")) - setVisible(elem->get("visible")); - else - setVisible(true); } std::vector ImageComponent::getHelpPrompts() diff --git a/es-core/src/components/VideoComponent.cpp b/es-core/src/components/VideoComponent.cpp index 0bd73c9c0..af3f4d168 100644 --- a/es-core/src/components/VideoComponent.cpp +++ b/es-core/src/components/VideoComponent.cpp @@ -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& 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("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& theme, const s setMaxSize(elem->get("maxSize") * scale); } - // position + size also implies origin - if (((properties & ORIGIN) || ((properties & POSITION) && (properties & ThemeFlags::SIZE))) && elem->has("origin")) - setOrigin(elem->get("origin")); - if(elem->has("default")) mConfig.defaultVideoPath = elem->get("default"); @@ -213,23 +207,6 @@ void VideoComponent::applyTheme(const std::shared_ptr& theme, const s if (elem->has("showSnapshotDelay")) mConfig.showSnapshotDelay = elem->get("showSnapshotDelay"); - - if(properties & ThemeFlags::ROTATION) { - if(elem->has("rotation")) - setRotationDegrees(elem->get("rotation")); - if(elem->has("rotationOrigin")) - setRotationOrigin(elem->get("rotationOrigin")); - } - - if(properties & ThemeFlags::Z_INDEX && elem->has("zIndex")) - setZIndex(elem->get("zIndex")); - else - setZIndex(getDefaultZIndex()); - - if(properties & ThemeFlags::VISIBLE && elem->has("visible")) - setVisible(elem->get("visible")); - else - setVisible(true); } std::vector VideoComponent::getHelpPrompts() diff --git a/es-core/src/components/VideoComponent.h b/es-core/src/components/VideoComponent.h index 8d8207b1c..8513129f9 100644 --- a/es-core/src/components/VideoComponent.h +++ b/es-core/src/components/VideoComponent.h @@ -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;