From 871735d3af9ad8b9ef042f6704bdb0d2bc945c6c Mon Sep 17 00:00:00 2001
From: Sam Lantinga <[EMAIL REDACTED]>
Date: Mon, 6 Apr 2026 13:06:45 -0700
Subject: [PATCH] Added support for 9-grid textures
---
screenlib/UIElement.cpp | 10 ++++++++++
screenlib/UITexture.cpp | 4 ++--
2 files changed, 12 insertions(+), 2 deletions(-)
diff --git a/screenlib/UIElement.cpp b/screenlib/UIElement.cpp
index 440793f0..d8519d04 100644
--- a/screenlib/UIElement.cpp
+++ b/screenlib/UIElement.cpp
@@ -191,6 +191,11 @@ UIElement::Load(rapidxml::xml_node<> *node, const UITemplates *templates)
SDL_Log("Warning: Couldn't load background '%s'", attr->value());
return false;
}
+
+ int cornerSize;
+ if (LoadNumber(node, "background_corner", cornerSize)) {
+ m_background->SetStretchGrid(cornerSize);
+ }
}
attr = node->first_attribute("image", 0, false);
@@ -199,6 +204,11 @@ UIElement::Load(rapidxml::xml_node<> *node, const UITemplates *templates)
SDL_Log("Warning: Couldn't load image '%s'", attr->value());
return false;
}
+
+ int cornerSize;
+ if (LoadNumber(node, "image_corner", cornerSize)) {
+ m_image->SetStretchGrid(cornerSize);
+ }
}
child = node->first_node("ImageArea", 0, false);
diff --git a/screenlib/UITexture.cpp b/screenlib/UITexture.cpp
index d7352d44..8f6af6f8 100644
--- a/screenlib/UITexture.cpp
+++ b/screenlib/UITexture.cpp
@@ -88,12 +88,12 @@ UITexture::SetStretchGrid(int cornerSize)
// Slide the texture into a grid based on the center
//
- // For example, if we have a 9x9 texture with a corner size of 1
+ // For example, if we have a 3x3 texture with a corner size of 1
// we would have a set of stretch areas like this:
// STRETCH_CENTER 1,1 1x1
// STRETCH_LEFT 0,1 1x1
// STRETCH_RIGHT 2,1 1x1
- // STRETCH_TOP 1,0 1x1
+ // STRETCH_TOP 1,0 1x1
// STRETCH_BOTTOM 1,2 1x1
// STRETCH_UPPER_LEFT 0,0 1x1
// STRETCH_UPPER_RIGHT 2,0 1x1