mirror of
https://github.com/RetroDECK/ES-DE.git
synced 2025-01-18 07:05:39 +00:00
Added size restrictions to the 'size' and 'maxSize' theme properties for the image and video elements.
This commit is contained in:
parent
2ac706e0c5
commit
3ecb821c00
|
@ -501,12 +501,26 @@ void ImageComponent::applyTheme(const std::shared_ptr<ThemeData>& theme,
|
|||
glm::vec2(Renderer::getScreenWidth(), Renderer::getScreenHeight())};
|
||||
|
||||
if (properties & ThemeFlags::SIZE) {
|
||||
if (elem->has("size"))
|
||||
setResize(elem->get<glm::vec2>("size") * scale);
|
||||
else if (elem->has("maxSize"))
|
||||
setMaxSize(elem->get<glm::vec2>("maxSize") * scale);
|
||||
else if (elem->has("minSize"))
|
||||
setMinSize(elem->get<glm::vec2>("minSize") * scale);
|
||||
if (elem->has("size")) {
|
||||
glm::vec2 imageSize {elem->get<glm::vec2>("size")};
|
||||
if (imageSize == glm::vec2 {0.0f, 0.0f}) {
|
||||
LOG(LogWarning) << "ImageComponent: Invalid theme configuration, property <size> "
|
||||
"for element \""
|
||||
<< element.substr(6) << "\" is set to zero";
|
||||
imageSize = {0.001f, 0.001f};
|
||||
}
|
||||
if (imageSize.x > 0.0f)
|
||||
imageSize.x = glm::clamp(imageSize.x, 0.001f, 2.0f);
|
||||
if (imageSize.y > 0.0f)
|
||||
imageSize.y = glm::clamp(imageSize.y, 0.001f, 2.0f);
|
||||
setResize(imageSize * scale);
|
||||
}
|
||||
else if (elem->has("maxSize")) {
|
||||
glm::vec2 imageMaxSize {elem->get<glm::vec2>("maxSize")};
|
||||
imageMaxSize.x = glm::clamp(imageMaxSize.x, 0.001f, 2.0f);
|
||||
imageMaxSize.y = glm::clamp(imageMaxSize.y, 0.001f, 2.0f);
|
||||
setMaxSize(imageMaxSize * scale);
|
||||
}
|
||||
}
|
||||
|
||||
if (elem->has("interpolation")) {
|
||||
|
|
|
@ -119,12 +119,26 @@ void VideoComponent::applyTheme(const std::shared_ptr<ThemeData>& theme,
|
|||
|
||||
if (properties & ThemeFlags::SIZE) {
|
||||
if (elem->has("size")) {
|
||||
setResize(elem->get<glm::vec2>("size") * scale);
|
||||
mVideoAreaSize = elem->get<glm::vec2>("size") * scale;
|
||||
glm::vec2 videoSize {elem->get<glm::vec2>("size")};
|
||||
if (videoSize == glm::vec2 {0.0f, 0.0f}) {
|
||||
LOG(LogWarning) << "VideoComponent: Invalid theme configuration, property <size> "
|
||||
"for element \""
|
||||
<< element.substr(6) << "\" is set to zero";
|
||||
videoSize = {0.01f, 0.01f};
|
||||
}
|
||||
if (videoSize.x > 0.0f)
|
||||
videoSize.x = glm::clamp(videoSize.x, 0.01f, 2.0f);
|
||||
if (videoSize.y > 0.0f)
|
||||
videoSize.y = glm::clamp(videoSize.y, 0.01f, 2.0f);
|
||||
setResize(videoSize * scale);
|
||||
mVideoAreaSize = videoSize * scale;
|
||||
}
|
||||
else if (elem->has("maxSize")) {
|
||||
setMaxSize(elem->get<glm::vec2>("maxSize") * scale);
|
||||
mVideoAreaSize = elem->get<glm::vec2>("maxSize") * scale;
|
||||
glm::vec2 videoMaxSize {elem->get<glm::vec2>("maxSize")};
|
||||
videoMaxSize.x = glm::clamp(videoMaxSize.x, 0.01f, 2.0f);
|
||||
videoMaxSize.y = glm::clamp(videoMaxSize.y, 0.01f, 2.0f);
|
||||
setMaxSize(videoMaxSize * scale);
|
||||
mVideoAreaSize = videoMaxSize * scale;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue