Browse Source

Added managed GUIElementStyle sub styles

Marko Pintera 11 years ago
parent
commit
62e7ec3fc8

+ 11 - 0
MBansheeEngine/GUI/GUIElementStyle.cs

@@ -186,6 +186,14 @@ namespace BansheeEngine
             set { Internal_SetFixedHeight(mCachedPtr, value); }
         }
 
+        public void AddSubStyle(string guiType, string styleName)
+        {
+            if (guiType == null || styleName == null)
+                return;
+
+            Internal_AddSubStyle(mCachedPtr, guiType, styleName);
+        }
+
         [MethodImpl(MethodImplOptions.InternalCall)]
         private static extern void Internal_CreateInstance(GUIElementStyle instance);
 
@@ -317,5 +325,8 @@ namespace BansheeEngine
         private static extern void Internal_GetFixedHeight(IntPtr nativeInstance, out bool value);
         [MethodImpl(MethodImplOptions.InternalCall)] 
         private static extern void Internal_SetFixedHeight(IntPtr nativeInstance, bool value);
+
+        [MethodImpl(MethodImplOptions.InternalCall)]
+        private static extern void Internal_AddSubStyle(IntPtr nativeInstance, string guiType, string styleName);
     }
 }

+ 1 - 0
SBansheeEngine/Include/BsScriptGUIElementStyle.h

@@ -30,6 +30,7 @@ namespace BansheeEngine
 	private:
 		static void internal_createInstance(MonoObject* instance, MonoString* name);
 		static void internal_createInstanceExternal(MonoObject* instance, MonoString* name, GUIElementStyle* externalStyle);
+		static void internal_addSubStyle(ScriptGUIElementStyle* nativeInstance, MonoString* guiType, MonoString* styleName);
 
 		BS_SCRIPT_GETSET_OBJECT_SHRDPTR(ScriptGUIElementStyle, ScriptFont, Font, mElementStyle->font, mFont);
 

+ 10 - 0
SBansheeEngine/Source/BsScriptGUIElementStyle.cpp

@@ -7,6 +7,7 @@
 #include "BsException.h"
 #include "BsGUIElementStyle.h"
 #include "BsScriptGUIElementStateStyle.h"
+#include "BsMonoUtil.h"
 
 namespace BansheeEngine
 {
@@ -33,6 +34,7 @@ namespace BansheeEngine
 	void ScriptGUIElementStyle::initRuntimeData()
 	{
 		metaData.scriptClass->addInternalCall("Internal_CreateInstance", &ScriptGUIElementStyle::internal_createInstance);
+		metaData.scriptClass->addInternalCall("Internal_AddSubStyle", &ScriptGUIElementStyle::internal_addSubStyle);
 
 		BS_SCRIPT_SETGET_META(ScriptGUIElementStyle, Font);
 
@@ -83,4 +85,12 @@ namespace BansheeEngine
 
 		ScriptGUIElementStyle* nativeInstance = new (bs_alloc<ScriptGUIElementStyle>()) ScriptGUIElementStyle(instance, styleName, externalStyle);
 	}
+
+	void ScriptGUIElementStyle::internal_addSubStyle(ScriptGUIElementStyle* nativeInstance, MonoString* guiType, MonoString* styleName)
+	{
+		String guiTypeStr = MonoUtil::monoToString(guiType);
+		String styleNameStr = MonoUtil::monoToString(styleName);
+
+		nativeInstance->getInternalValue()->subStyles[guiTypeStr] = styleNameStr;
+	}
 }