From b9a2a146b7e173eec029215b910e8bd2821d400a Mon Sep 17 00:00:00 2001 From: Leon Styhre Date: Wed, 1 Mar 2023 20:13:07 +0100 Subject: [PATCH] Added a new cropSize property to the image element. --- es-core/src/ThemeData.cpp | 2 ++ es-core/src/components/ImageComponent.cpp | 6 ++++++ 2 files changed, 8 insertions(+) diff --git a/es-core/src/ThemeData.cpp b/es-core/src/ThemeData.cpp index 79abe4525..c72613168 100644 --- a/es-core/src/ThemeData.cpp +++ b/es-core/src/ThemeData.cpp @@ -169,6 +169,7 @@ std::map> {"reflectionsOpacity", FLOAT}, {"reflectionsFalloff", FLOAT}, {"unfocusedItemOpacity", FLOAT}, + {"imageFit", STRING}, {"fastScrolling", BOOLEAN}, {"defaultLogo", PATH}, // For backward compatibility with legacy themes. {"logoSize", NORMALIZED_PAIR}, // For backward compatibility with legacy themes. @@ -286,6 +287,7 @@ std::map> {"image", {{"pos", NORMALIZED_PAIR}, {"size", NORMALIZED_PAIR}, + {"cropSize", NORMALIZED_PAIR}, {"maxSize", NORMALIZED_PAIR}, {"origin", NORMALIZED_PAIR}, {"rotation", FLOAT}, diff --git a/es-core/src/components/ImageComponent.cpp b/es-core/src/components/ImageComponent.cpp index e4727e5f6..bbeedd24a 100644 --- a/es-core/src/components/ImageComponent.cpp +++ b/es-core/src/components/ImageComponent.cpp @@ -467,6 +467,12 @@ void ImageComponent::applyTheme(const std::shared_ptr& theme, imageMaxSize.y = glm::clamp(imageMaxSize.y, 0.001f, 3.0f); setMaxSize(imageMaxSize * scale); } + else if (elem->has("cropSize")) { + glm::vec2 imageCropSize {elem->get("cropSize")}; + imageCropSize.x = glm::clamp(imageCropSize.x, 0.001f, 3.0f); + imageCropSize.y = glm::clamp(imageCropSize.y, 0.001f, 3.0f); + setCroppedSize(imageCropSize * scale); + } } if (elem->has("interpolation")) {