https://github.com/libsdl-org/Maelstrom/commit/4929488bbd9eb12fb0b39dd2d678157571bd0512
From 4929488bbd9eb12fb0b39dd2d678157571bd0512 Mon Sep 17 00:00:00 2001
From: Sam Lantinga <[EMAIL REDACTED]>
Date: Sun, 14 Oct 2012 09:48:06 -0700
Subject: [PATCH] Added border spacing for containers
---
screenlib/UIContainer.cpp | 13 +++++++++++--
screenlib/UIContainer.h | 1 +
2 files changed, 12 insertions(+), 2 deletions(-)
diff --git a/screenlib/UIContainer.cpp b/screenlib/UIContainer.cpp
index f3c16ed7..daa87bc3 100644
--- a/screenlib/UIContainer.cpp
+++ b/screenlib/UIContainer.cpp
@@ -31,6 +31,7 @@ UIContainer::UIContainer(UIBaseElement *parent, const char *name, UIDrawEngine *
{
m_layoutType = LAYOUT_VERTICAL;
m_spacing = 0;
+ m_borderSpacing = 0;
m_layoutInProgress = false;
}
@@ -53,6 +54,7 @@ UIContainer::Load(rapidxml::xml_node<> *node, const UITemplates *templates)
}
LoadNumber(node, "spacing", m_spacing);
+ LoadNumber(node, "borderSpacing", m_borderSpacing);
return true;
}
@@ -75,9 +77,12 @@ UIContainer::LayoutChildren()
anchor = NULL;
for (i = 0; i < m_elements.length(); ++i) {
if (m_elements[i]->IsShown()) {
+ int anchorOffset = m_borderSpacing;
+ if (HasBorder()) {
+ anchorOffset += 1;
+ }
m_elements[i]->SetAnchor(TOPLEFT, TOPLEFT, this,
- HasBorder() ? 1 : 0,
- HasBorder() ? 1 : 0);
+ anchorOffset, anchorOffset);
anchor = m_elements[i];
break;
}
@@ -118,6 +123,8 @@ UIContainer::LayoutChildren()
w += 1;
}
}
+ w += 1*m_borderSpacing;
+ h += 2*m_borderSpacing;
} else {
// Width is the max of children, height is the sum of children
for (i = 0; i < m_elements.length(); ++i) {
@@ -136,6 +143,8 @@ UIContainer::LayoutChildren()
h += 1;
}
}
+ w += 2*m_borderSpacing;
+ h += 1*m_borderSpacing;
}
AutoSize(w, h);
diff --git a/screenlib/UIContainer.h b/screenlib/UIContainer.h
index cbaf0907..381c4630 100644
--- a/screenlib/UIContainer.h
+++ b/screenlib/UIContainer.h
@@ -55,6 +55,7 @@ DECLARE_TYPESAFE_CLASS(UIElement)
protected:
LAYOUT_TYPE m_layoutType;
int m_spacing;
+ int m_borderSpacing;
bool m_layoutInProgress;
protected: