Added a check for whether a text element has a width defined when the container property is set

This commit is contained in:
Leon Styhre 2024-08-22 17:29:39 +02:00
parent ce3d50d2b3
commit b9f8d4cfdd

View file

@ -641,7 +641,13 @@ void TextComponent::applyTheme(const std::shared_ptr<ThemeData>& theme,
} }
if (elem->has("container") && elem->get<bool>("container")) { if (elem->has("container") && elem->get<bool>("container")) {
if (elem->has("containerType")) { if (!elem->has("size") || (elem->has("size") && elem->get<glm::vec2>("size").x == 0.0f)) {
LOG(LogError) << "TextComponent: Invalid theme configuration, property "
"\"container\" for element \""
<< element.substr(5)
<< "\" can't be used as a horizontal size has not been defined";
}
else if (elem->has("containerType")) {
const std::string& containerType {elem->get<std::string>("containerType")}; const std::string& containerType {elem->get<std::string>("containerType")};
if (containerType == "horizontal") { if (containerType == "horizontal") {
if (elem->has("containerScrollSpeed")) { if (elem->has("containerScrollSpeed")) {