Added a new cropSize property to the image element.

This commit is contained in:
Leon Styhre 2023-03-01 20:13:07 +01:00
parent fa7b317982
commit b9a2a146b7
2 changed files with 8 additions and 0 deletions

View file

@ -169,6 +169,7 @@ std::map<std::string, std::map<std::string, ThemeData::ElementPropertyType>>
{"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<std::string, std::map<std::string, ThemeData::ElementPropertyType>>
{"image",
{{"pos", NORMALIZED_PAIR},
{"size", NORMALIZED_PAIR},
{"cropSize", NORMALIZED_PAIR},
{"maxSize", NORMALIZED_PAIR},
{"origin", NORMALIZED_PAIR},
{"rotation", FLOAT},

View file

@ -467,6 +467,12 @@ void ImageComponent::applyTheme(const std::shared_ptr<ThemeData>& theme,
imageMaxSize.y = glm::clamp(imageMaxSize.y, 0.001f, 3.0f);
setMaxSize(imageMaxSize * scale);
}
else if (elem->has("cropSize")) {
glm::vec2 imageCropSize {elem->get<glm::vec2>("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")) {