浏览代码

Add support for specifying padding and margin as a single float value in form files (to be applied to all sides) for UI controls.

sgrenier 11 年之前
父节点
当前提交
aaf19a9c10
共有 1 个文件被更改,包括 12 次插入0 次删除
  1. 12 0
      gameplay/src/Control.cpp

+ 12 - 0
gameplay/src/Control.cpp

@@ -226,6 +226,18 @@ void Control::initialize(const char* typeName, Theme::Style* style, Properties*
         // Parse the auto-size mode for the control (this overrides explicit sizes and legacy autoWidth/autoHeight)
         _autoSize = parseAutoSize(properties->getString("autoSize"));
 
+        // If there is are simple padding or margin variables, parse them
+        if (properties->exists("padding"))
+        {
+            float pad = properties->getFloat("padding");
+            setPadding(pad, pad, pad, pad);
+        }
+        if (properties->exists("margin"))
+        {
+            float margin = properties->getFloat("margin");
+            setPadding(margin, margin, margin, margin);
+        }
+
 		if (properties->exists("enabled"))
 		{
 			setEnabled(properties->getBool("enabled"));