Quellcode durchsuchen

Added C# wrappers for GUISlider, GUIProgressBar and GUILayoutExplicit

Marko Pintera vor 11 Jahren
Ursprung
Commit
ffaba68be1

+ 11 - 0
BansheeEngine/Include/BsGUIElementBase.h

@@ -229,6 +229,11 @@ namespace BansheeEngine
 		 */
 		GUILayout& addLayoutYInternal(GUIElementBase* parent);
 
+		/**
+		 * @brief	Creates and adds a new explicit layout to the specified "parent" element.
+		 */
+		GUILayout& addLayoutExplicitInternal(GUIElementBase* parent);
+
 		/**
 		 * @brief	Removes an existing layout from this element.
 		 */
@@ -246,6 +251,12 @@ namespace BansheeEngine
 		 */
 		GUILayout& insertLayoutYInternal(GUIElementBase* parent, UINT32 idx);
 
+		/**
+		 * @brief	Creates and adds a new explicit layout to the specified "parent" element,
+		 *			at a specific child index. Caller must ensure index is in valid range.
+		 */
+		GUILayout& insertLayoutExplicitInternal(GUIElementBase* parent, UINT32 idx);
+
 		GUIWidget* mParentWidget;
 		GUIElementBase* mParentElement;
 		Vector<GUIElementBase*> mChildren;	

+ 10 - 0
BansheeEngine/Include/BsGUILayout.h

@@ -42,6 +42,11 @@ namespace BansheeEngine
 		 */
 		GUILayout& addLayoutY() { return addLayoutYInternal(this); }
 
+		/**
+		 * @brief	Adds a new explicit layout as a child of this layout.
+		 */
+		GUILayout& addLayoutExplicit() { return addLayoutExplicitInternal(this); }
+
 		/**
 		 * @brief	Removes the specified child layout.
 		 */
@@ -57,6 +62,11 @@ namespace BansheeEngine
 		 */
 		GUILayout& insertLayoutY(UINT32 idx) { return insertLayoutYInternal(this, idx); }
 
+		/**
+		 * @brief	Inserts an explicit layout before the element at the specified index.
+		 */
+		GUILayout& insertLayoutExplicit(UINT32 idx) { return insertLayoutExplicitInternal(this, idx); }
+
 		/**
 		 * @brief	Adds a fixed space as a child of this layout. Size of space is specified in pixels.
 		 */

+ 5 - 0
BansheeEngine/Include/BsPrerequisites.h

@@ -59,6 +59,7 @@ namespace BansheeEngine
 	class GUILayout;
 	class GUILayoutX;
 	class GUILayoutY;
+	class GUILayoutExplicit;
 	class GUIFixedSpace;
 	class GUIFlexibleSpace;
 	class GUIInputCaret;
@@ -76,6 +77,10 @@ namespace BansheeEngine
 	class GUIContextMenu;
 	class GUIDropDownHitBox;
 	class RenderableElement;
+	class GUISlider;
+	class GUISliderVert;
+	class GUISliderHorz;
+	class GUIProgressBar;
 
 	class RenderableController;
 	class ProfilerOverlay;

+ 34 - 0
BansheeEngine/Source/BsGUIElementBase.cpp

@@ -2,6 +2,7 @@
 #include "BsGUILayout.h"
 #include "BsGUILayoutX.h"
 #include "BsGUILayoutY.h"
+#include "BsGUILayoutExplicit.h"
 #include "BsGUIElement.h"
 #include "BsException.h"
 #include "BsGUIWidget.h"
@@ -170,6 +171,21 @@ namespace BansheeEngine
 		return *entry;
 	}
 
+	GUILayout& GUIElementBase::addLayoutExplicitInternal(GUIElementBase* parent)
+	{
+		GUILayoutExplicit* entry = bs_new<GUILayoutExplicit, PoolAlloc>();
+		entry->_setParent(parent);
+
+		mChildren.push_back(entry);
+
+		if (mIsDisabled)
+			entry->disableRecursively();
+
+		markContentAsDirty();
+
+		return *entry;
+	}
+
 	void GUIElementBase::removeLayoutInternal(GUILayout& layout)
 	{
 		bool foundElem = false;
@@ -228,6 +244,24 @@ namespace BansheeEngine
 		return *entry;
 	}
 
+	GUILayout& GUIElementBase::insertLayoutExplicitInternal(GUIElementBase* parent, UINT32 idx)
+	{
+		if (idx < 0 || idx >(UINT32)mChildren.size())
+			BS_EXCEPT(InvalidParametersException, "Index out of range: " + toString(idx) + ". Valid range: 0 .. " + toString((UINT32)mChildren.size()));
+
+		GUILayoutExplicit* entry = bs_new<GUILayoutExplicit, PoolAlloc>();
+		entry->_setParent(parent);
+
+		mChildren.insert(mChildren.begin() + idx, entry);
+
+		if (mIsDisabled)
+			entry->disableRecursively();
+
+		markContentAsDirty();
+
+		return *entry;
+	}
+
 	void GUIElementBase::_registerChildElement(GUIElement* element)
 	{
 		GUIElementBase* parentElement = element->_getParent();

+ 22 - 0
MBansheeEngine/GUI/GUILayout.cs

@@ -156,6 +156,22 @@ namespace BansheeEngine
             return layoutY;
         }
 
+        public GUILayoutExplicit AddLayoutExplicit()
+        {
+            GUILayoutExplicit layoutY = new GUILayoutExplicit(this);
+            AddElementInternal(layoutY);
+
+            return layoutY;
+        }
+
+        public GUILayoutExplicit InsertLayoutExplicit(int index)
+        {
+            GUILayoutExplicit layoutY = new GUILayoutExplicit(this, index);
+            InsertElementInternal(index, layoutY);
+
+            return layoutY;
+        }
+
         public void Remove(GUIElement element)
         {
             if (children.Contains(element))
@@ -207,12 +223,18 @@ namespace BansheeEngine
         [MethodImpl(MethodImplOptions.InternalCall)]
         protected static extern void Internal_CreateInstanceYFromLayoutAdd(GUILayout instance, GUILayout parentLayout);
 
+        [MethodImpl(MethodImplOptions.InternalCall)]
+        protected static extern void Internal_CreateInstanceExplicitFromLayoutAdd(GUILayout instance, GUILayout parentLayout);
+
         [MethodImpl(MethodImplOptions.InternalCall)]
         protected static extern void Internal_CreateInstanceXFromLayoutInsert(GUILayout instance, GUILayout parentLayout, int index);
 
         [MethodImpl(MethodImplOptions.InternalCall)]
         protected static extern void Internal_CreateInstanceYFromLayoutInsert(GUILayout instance, GUILayout parentLayout, int index);
 
+        [MethodImpl(MethodImplOptions.InternalCall)]
+        protected static extern void Internal_CreateInstanceExplicitFromLayoutInsert(GUILayout instance, GUILayout parentLayout, int index);
+
         [MethodImpl(MethodImplOptions.InternalCall)]
         protected static extern void Internal_AddElement(IntPtr instance, IntPtr element);
 

+ 18 - 0
MBansheeEngine/GUI/GUILayoutExplicit.cs

@@ -0,0 +1,18 @@
+using System;
+using System.Runtime.CompilerServices;
+
+namespace BansheeEngine
+{
+    public sealed class GUILayoutExplicit : GUILayout
+    {
+        internal GUILayoutExplicit(GUILayout parentLayout)
+        {
+            Internal_CreateInstanceExplicitFromLayoutAdd(this, parentLayout);
+        }
+
+        internal GUILayoutExplicit(GUILayout parentLayout, int index)
+        {
+            Internal_CreateInstanceExplicitFromLayoutInsert(this, parentLayout, index);
+        }
+    }
+}

+ 33 - 0
MBansheeEngine/GUI/GUIProgressBar.cs

@@ -0,0 +1,33 @@
+using System;
+using System.Runtime.CompilerServices;
+
+namespace BansheeEngine
+{
+    public sealed class GUIProgressBar : GUIElement
+    {
+        public float Percent
+        {
+            get { return Internal_GetPercent(mCachedPtr); }
+            set { Internal_SetPercent(mCachedPtr, value); }
+        }
+
+        public GUIProgressBar(string style, params GUIOption[] options)
+        {
+            Internal_CreateInstance(this, style, options);
+        }
+
+        public GUIProgressBar(string style)
+        {
+            Internal_CreateInstance(this, style, new GUIOption[0]);
+        }
+
+        [MethodImpl(MethodImplOptions.InternalCall)]
+        private static extern void Internal_CreateInstance(GUIProgressBar instance, string style, GUIOption[] options);
+
+        [MethodImpl(MethodImplOptions.InternalCall)]
+        private static extern float Internal_GetPercent(IntPtr nativeInstance);
+
+        [MethodImpl(MethodImplOptions.InternalCall)]
+        private static extern void Internal_SetPercent(IntPtr nativeInstance, float percent);
+    }
+}

+ 81 - 0
MBansheeEngine/GUI/GUISlider.cs

@@ -0,0 +1,81 @@
+using System;
+using System.Runtime.CompilerServices;
+
+namespace BansheeEngine
+{
+    public sealed class GUISliderH : GUIElement
+    {
+        public delegate void OnChangedDelegate(float percent);
+
+        public event OnChangedDelegate OnChanged;
+
+        public float Percent
+        {
+            get { return Internal_GetPercent(mCachedPtr); }
+            set { Internal_SetPercent(mCachedPtr, value); }
+        }
+
+        public GUISliderH(string style, params GUIOption[] options)
+        {
+            Internal_CreateInstance(this, style, options);
+        }
+
+        public GUISliderH(string style)
+        {
+            Internal_CreateInstance(this, style, new GUIOption[0]);
+        }
+
+        private void DoOnChanged(float percent)
+        {
+            if (OnChanged != null)
+                OnChanged(percent);
+        }
+
+        [MethodImpl(MethodImplOptions.InternalCall)]
+        private static extern void Internal_CreateInstance(GUISliderH instance, string style, GUIOption[] options);
+
+        [MethodImpl(MethodImplOptions.InternalCall)]
+        private static extern float Internal_GetPercent(IntPtr nativeInstance);
+
+        [MethodImpl(MethodImplOptions.InternalCall)]
+        private static extern void Internal_SetPercent(IntPtr nativeInstance, float percent);
+    }
+
+    public sealed class GUISliderV : GUIElement
+    {
+        public delegate void OnChangedDelegate(float percent);
+
+        public event OnChangedDelegate OnChanged;
+
+        public float Percent
+        {
+            get { return Internal_GetPercent(mCachedPtr); }
+            set { Internal_SetPercent(mCachedPtr, value); }
+        }
+
+        public GUISliderV(string style, params GUIOption[] options)
+        {
+            Internal_CreateInstance(this, style, options);
+        }
+
+        public GUISliderV(string style)
+        {
+            Internal_CreateInstance(this, style, new GUIOption[0]);
+        }
+
+        private void DoOnChanged(float percent)
+        {
+            if (OnChanged != null)
+                OnChanged(percent);
+        }
+
+        [MethodImpl(MethodImplOptions.InternalCall)]
+        private static extern void Internal_CreateInstance(GUISliderV instance, string style, GUIOption[] options);
+
+        [MethodImpl(MethodImplOptions.InternalCall)]
+        private static extern float Internal_GetPercent(IntPtr nativeInstance);
+
+        [MethodImpl(MethodImplOptions.InternalCall)]
+        private static extern void Internal_SetPercent(IntPtr nativeInstance, float percent);
+    }
+}

+ 3 - 0
MBansheeEngine/MBansheeEngine.csproj

@@ -58,6 +58,7 @@
     <Compile Include="Font.cs" />
     <Compile Include="GameObject.cs" />
     <Compile Include="GUI\GUIArea.cs" />
+    <Compile Include="GUI\GUILayoutExplicit.cs" />
     <Compile Include="GUI\GUILayoutUtility.cs" />
     <Compile Include="GUI\GUIPanel.cs" />
     <Compile Include="GUI\GUIButton.cs" />
@@ -66,8 +67,10 @@
     <Compile Include="GUI\GUIElementStateStyle.cs" />
     <Compile Include="GUI\GUIElementStyle.cs" />
     <Compile Include="GUI\GUIListBox.cs" />
+    <Compile Include="GUI\GUIProgressBar.cs" />
     <Compile Include="GUI\GUIRenderTexture.cs" />
     <Compile Include="GUI\GUIScrollArea.cs" />
+    <Compile Include="GUI\GUISlider.cs" />
     <Compile Include="GUI\GUITextBox.cs" />
     <Compile Include="GUI\GUILabel.cs" />
     <Compile Include="GUI\GUILayout.cs" />

+ 2 - 0
SBansheeEngine/Include/BsScriptGUILayout.h

@@ -17,8 +17,10 @@ namespace BansheeEngine
 		static void internal_createInstanceXFromArea(MonoObject* instance, MonoObject* parentArea);
 		static void internal_createInstanceXFromLayoutAdd(MonoObject* instance, MonoObject* parentLayout);
 		static void internal_createInstanceYFromLayoutAdd(MonoObject* instance, MonoObject* parentLayout);
+		static void internal_createInstanceExplicitFromLayoutAdd(MonoObject* instance, MonoObject* parentLayout);
 		static void internal_createInstanceXFromLayoutInsert(MonoObject* instance, MonoObject* parentLayout, UINT32 index);
 		static void internal_createInstanceYFromLayoutInsert(MonoObject* instance, MonoObject* parentLayout, UINT32 index);
+		static void internal_createInstanceExplicitFromLayoutInsert(MonoObject* instance, MonoObject* parentLayout, UINT32 index);
 		static void internal_createInstanceYFromScrollArea(MonoObject* instance, MonoObject* parentScrollArea);
 		static void internal_addElement(ScriptGUILayout* instance, ScriptGUIElementTBase* element);
 		static void internal_insertElement(ScriptGUILayout* instance, UINT32 index, ScriptGUIElementTBase* element);

+ 20 - 0
SBansheeEngine/Include/BsScriptGUIProgressBar.h

@@ -0,0 +1,20 @@
+#pragma once
+
+#include "BsScriptEnginePrerequisites.h"
+#include "BsScriptGUIElement.h"
+
+namespace BansheeEngine
+{
+	class BS_SCR_BE_EXPORT ScriptGUIProgressBar : public TScriptGUIElement <ScriptGUIProgressBar>
+	{
+	public:
+		SCRIPT_OBJ(BansheeEngineAssemblyName, "BansheeEngine", "GUIProgressBar")
+
+	private:
+		static void internal_createInstance(MonoObject* instance, MonoString* style, MonoArray* guiOptions);
+		static void internal_setPercent(ScriptGUIProgressBar* nativeInstance, float percent);
+		static float internal_getPercent(ScriptGUIProgressBar* nativeInstance);
+
+		ScriptGUIProgressBar(MonoObject* instance, GUIProgressBar* progressBar);
+	};
+}

+ 45 - 0
SBansheeEngine/Include/BsScriptGUISlider.h

@@ -0,0 +1,45 @@
+#pragma once
+
+#include "BsScriptEnginePrerequisites.h"
+#include "BsScriptGUIElement.h"
+
+namespace BansheeEngine
+{
+	class BS_SCR_BE_EXPORT ScriptGUISliderH : public TScriptGUIElement<ScriptGUISliderH>
+	{
+	public:
+		SCRIPT_OBJ(BansheeEngineAssemblyName, "BansheeEngine", "GUISliderH")
+
+	private:
+		static void internal_createInstance(MonoObject* instance, MonoString* style, MonoArray* guiOptions);
+		static void internal_setPercent(ScriptGUISliderH* nativeInstance, float percent);
+		static float internal_getPercent(ScriptGUISliderH* nativeInstance);
+
+		static void onChanged(MonoObject* instance, float percent);
+
+		ScriptGUISliderH(MonoObject* instance, GUISliderHorz* slider);
+
+		typedef void(__stdcall *OnChangedThunkDef) (MonoObject*, float, MonoException**);
+
+		static OnChangedThunkDef onChangedThunk;
+	};
+
+	class BS_SCR_BE_EXPORT ScriptGUISliderV : public TScriptGUIElement<ScriptGUISliderV>
+	{
+	public:
+		SCRIPT_OBJ(BansheeEngineAssemblyName, "BansheeEngine", "GUISliderV")
+
+	private:
+		static void internal_createInstance(MonoObject* instance, MonoString* style, MonoArray* guiOptions);
+		static void internal_setPercent(ScriptGUISliderV* nativeInstance, float percent);
+		static float internal_getPercent(ScriptGUISliderV* nativeInstance);
+
+		static void onChanged(MonoObject* instance, float percent);
+
+		ScriptGUISliderV(MonoObject* instance, GUISliderVert* slider);
+
+		typedef void(__stdcall *OnChangedThunkDef) (MonoObject*, float, MonoException**);
+
+		static OnChangedThunkDef onChangedThunk;
+	};
+}

+ 4 - 0
SBansheeEngine/SBansheeEngine.vcxproj

@@ -274,8 +274,10 @@
     <ClInclude Include="Include\BsScriptGUILabel.h" />
     <ClInclude Include="Include\BsScriptGUILayout.h" />
     <ClInclude Include="Include\BsScriptGUIListBox.h" />
+    <ClInclude Include="Include\BsScriptGUIProgressBar.h" />
     <ClInclude Include="Include\BsScriptGUIRenderTexture.h" />
     <ClInclude Include="Include\BsScriptGUIScrollArea.h" />
+    <ClInclude Include="Include\BsScriptGUISlider.h" />
     <ClInclude Include="Include\BsScriptGUITexture.h" />
     <ClInclude Include="Include\BsScriptGUIToggle.h" />
     <ClInclude Include="Include\BsScriptGUIToggleGroup.h" />
@@ -345,8 +347,10 @@
     <ClCompile Include="Source\BsScriptGUILabel.cpp" />
     <ClCompile Include="Source\BsScriptGUILayout.cpp" />
     <ClCompile Include="Source\BsScriptGUIListBox.cpp" />
+    <ClCompile Include="Source\BsScriptGUIProgressBar.cpp" />
     <ClCompile Include="Source\BsScriptGUIRenderTexture.cpp" />
     <ClCompile Include="Source\BsScriptGUIScrollArea.cpp" />
+    <ClCompile Include="Source\BsScriptGUISlider.cpp" />
     <ClCompile Include="Source\BsScriptGUITexture.cpp" />
     <ClCompile Include="Source\BsScriptGUIToggle.cpp" />
     <ClCompile Include="Source\BsScriptGUIToggleGroup.cpp" />

+ 12 - 0
SBansheeEngine/SBansheeEngine.vcxproj.filters

@@ -282,6 +282,12 @@
     <ClInclude Include="Include\BsManagedSerializableObjectDataRTTI.h">
       <Filter>Header Files\Serialization\RTTI</Filter>
     </ClInclude>
+    <ClInclude Include="Include\BsScriptGUISlider.h">
+      <Filter>Header Files\GUI</Filter>
+    </ClInclude>
+    <ClInclude Include="Include\BsScriptGUIProgressBar.h">
+      <Filter>Header Files\GUI</Filter>
+    </ClInclude>
   </ItemGroup>
   <ItemGroup>
     <ClCompile Include="Source\BsScriptTexture2D.cpp">
@@ -500,5 +506,11 @@
     <ClCompile Include="Source\BsManagedSerializableObjectData.cpp">
       <Filter>Source Files\Serialization</Filter>
     </ClCompile>
+    <ClCompile Include="Source\BsScriptGUISlider.cpp">
+      <Filter>Source Files\GUI</Filter>
+    </ClCompile>
+    <ClCompile Include="Source\BsScriptGUIProgressBar.cpp">
+      <Filter>Source Files\GUI</Filter>
+    </ClCompile>
   </ItemGroup>
 </Project>

+ 22 - 0
SBansheeEngine/Source/BsScriptGUILayout.cpp

@@ -22,8 +22,10 @@ namespace BansheeEngine
 		metaData.scriptClass->addInternalCall("Internal_CreateInstanceXFromArea", &ScriptGUILayout::internal_createInstanceXFromArea);
 		metaData.scriptClass->addInternalCall("Internal_CreateInstanceXFromLayoutAdd", &ScriptGUILayout::internal_createInstanceXFromLayoutAdd);
 		metaData.scriptClass->addInternalCall("Internal_CreateInstanceYFromLayoutAdd", &ScriptGUILayout::internal_createInstanceYFromLayoutAdd);
+		metaData.scriptClass->addInternalCall("Internal_CreateInstanceExplicitFromLayoutAdd", &ScriptGUILayout::internal_createInstanceExplicitFromLayoutAdd);
 		metaData.scriptClass->addInternalCall("Internal_CreateInstanceXFromLayoutInsert", &ScriptGUILayout::internal_createInstanceXFromLayoutInsert);
 		metaData.scriptClass->addInternalCall("Internal_CreateInstanceYFromLayoutInsert", &ScriptGUILayout::internal_createInstanceYFromLayoutInsert);
+		metaData.scriptClass->addInternalCall("Internal_CreateInstanceExplicitFromLayoutInsert", &ScriptGUILayout::internal_createInstanceExplicitFromLayoutInsert);
 		metaData.scriptClass->addInternalCall("Internal_CreateInstanceYFromScrollArea", &ScriptGUILayout::internal_createInstanceYFromScrollArea);
 		metaData.scriptClass->addInternalCall("Internal_AddElement", &ScriptGUILayout::internal_addElement);
 		metaData.scriptClass->addInternalCall("Internal_InsertElement", &ScriptGUILayout::internal_insertElement);
@@ -62,6 +64,16 @@ namespace BansheeEngine
 			ScriptGUILayout(instance, &layout, nativeLayout);
 	}
 
+	void ScriptGUILayout::internal_createInstanceExplicitFromLayoutAdd(MonoObject* instance, MonoObject* parentLayout)
+	{
+		ScriptGUILayout* scriptLayout = ScriptGUILayout::toNative(parentLayout);
+		GUILayout* nativeLayout = scriptLayout->getInternalValue();
+		GUILayout& layout = nativeLayout->addLayoutExplicit();
+
+		ScriptGUILayout* nativeInstance = new (bs_alloc<ScriptGUILayout>())
+			ScriptGUILayout(instance, &layout, nativeLayout);
+	}
+
 	void ScriptGUILayout::internal_createInstanceYFromLayoutAdd(MonoObject* instance, MonoObject* parentLayout)
 	{
 		ScriptGUILayout* scriptLayout = ScriptGUILayout::toNative(parentLayout);
@@ -92,6 +104,16 @@ namespace BansheeEngine
 			ScriptGUILayout(instance, &layout, nativeLayout);
 	}
 
+	void ScriptGUILayout::internal_createInstanceExplicitFromLayoutInsert(MonoObject* instance, MonoObject* parentLayout, UINT32 index)
+	{
+		ScriptGUILayout* scriptLayout = ScriptGUILayout::toNative(parentLayout);
+		GUILayout* nativeLayout = scriptLayout->getInternalValue();
+		GUILayout& layout = nativeLayout->insertLayoutExplicit(index);
+
+		ScriptGUILayout* nativeInstance = new (bs_alloc<ScriptGUILayout>())
+			ScriptGUILayout(instance, &layout, nativeLayout);
+	}
+
 	void ScriptGUILayout::internal_createInstanceYFromScrollArea(MonoObject* instance, MonoObject* parentScrollArea)
 	{
 		ScriptGUIScrollArea* scriptScrollArea = ScriptGUIScrollArea::toNative(parentScrollArea);

+ 58 - 0
SBansheeEngine/Source/BsScriptGUIProgressBar.cpp

@@ -0,0 +1,58 @@
+#include "BsScriptGUIProgressBar.h"
+#include "BsScriptMeta.h"
+#include "BsMonoField.h"
+#include "BsMonoClass.h"
+#include "BsMonoManager.h"
+#include "BsMonoMethod.h"
+#include "BsSpriteTexture.h"
+#include "BsMonoUtil.h"
+#include "BsGUILayout.h"
+#include "BsGUIProgressBar.h"
+#include "BsGUIOptions.h"
+#include "BsScriptGUIElementStyle.h"
+#include "BsScriptGUILayout.h"
+#include "BsScriptGUIArea.h"
+#include "BsScriptHString.h"
+#include "BsScriptGUIContent.h"
+
+using namespace std::placeholders;
+
+namespace BansheeEngine
+{
+	ScriptGUIProgressBar::ScriptGUIProgressBar(MonoObject* instance, GUIProgressBar* progressBar)
+		:TScriptGUIElement(instance, progressBar)
+	{
+
+	}
+
+	void ScriptGUIProgressBar::initRuntimeData()
+	{
+		metaData.scriptClass->addInternalCall("Internal_CreateInstance", &ScriptGUIProgressBar::internal_createInstance);
+		metaData.scriptClass->addInternalCall("Internal_SetPercent", &ScriptGUIProgressBar::internal_setPercent);
+		metaData.scriptClass->addInternalCall("Internal_GetPercent", &ScriptGUIProgressBar::internal_getPercent);
+	}
+
+	void ScriptGUIProgressBar::internal_createInstance(MonoObject* instance, MonoString* style, MonoArray* guiOptions)
+	{
+		GUIOptions options;
+
+		UINT32 arrayLen = (UINT32)mono_array_length(guiOptions);
+		for (UINT32 i = 0; i < arrayLen; i++)
+			options.addOption(mono_array_get(guiOptions, GUIOption, i));
+
+		GUIProgressBar* progressBar = GUIProgressBar::create(options, toString(MonoUtil::monoToWString(style)));
+		ScriptGUIProgressBar* nativeInstance = new (bs_alloc<ScriptGUIProgressBar>()) ScriptGUIProgressBar(instance, progressBar);
+	}
+
+	void ScriptGUIProgressBar::internal_setPercent(ScriptGUIProgressBar* nativeInstance, float percent)
+	{
+		GUIProgressBar* progressBar = (GUIProgressBar*)nativeInstance->getGUIElement();
+		progressBar->setPercent(percent);
+	}
+
+	float ScriptGUIProgressBar::internal_getPercent(ScriptGUIProgressBar* nativeInstance)
+	{
+		GUIProgressBar* progressBar = (GUIProgressBar*)nativeInstance->getGUIElement();
+		return progressBar->getPercent();
+	}
+}

+ 123 - 0
SBansheeEngine/Source/BsScriptGUISlider.cpp

@@ -0,0 +1,123 @@
+#include "BsScriptGUISlider.h"
+#include "BsScriptMeta.h"
+#include "BsMonoField.h"
+#include "BsMonoClass.h"
+#include "BsMonoManager.h"
+#include "BsMonoMethod.h"
+#include "BsSpriteTexture.h"
+#include "BsMonoUtil.h"
+#include "BsGUILayout.h"
+#include "BsGUISlider.h"
+#include "BsGUIOptions.h"
+#include "BsScriptGUIElementStyle.h"
+#include "BsScriptGUILayout.h"
+#include "BsScriptGUIArea.h"
+#include "BsScriptHString.h"
+#include "BsScriptGUIContent.h"
+
+using namespace std::placeholders;
+
+namespace BansheeEngine
+{
+	ScriptGUISliderH::OnChangedThunkDef ScriptGUISliderH::onChangedThunk;
+
+	ScriptGUISliderH::ScriptGUISliderH(MonoObject* instance, GUISliderHorz* slider)
+		:TScriptGUIElement(instance, slider)
+	{
+
+	}
+
+	void ScriptGUISliderH::initRuntimeData()
+	{
+		metaData.scriptClass->addInternalCall("Internal_CreateInstance", &ScriptGUISliderH::internal_createInstance);
+		metaData.scriptClass->addInternalCall("Internal_SetPercent", &ScriptGUISliderH::internal_setPercent);
+		metaData.scriptClass->addInternalCall("Internal_GetPercent", &ScriptGUISliderH::internal_getPercent);
+
+		onChangedThunk = (OnChangedThunkDef)metaData.scriptClass->getMethod("DoOnChanged", 1)->getThunk();
+	}
+
+	void ScriptGUISliderH::internal_createInstance(MonoObject* instance, MonoString* style, MonoArray* guiOptions)
+	{
+		GUIOptions options;
+
+		UINT32 arrayLen = (UINT32)mono_array_length(guiOptions);
+		for (UINT32 i = 0; i < arrayLen; i++)
+			options.addOption(mono_array_get(guiOptions, GUIOption, i));
+
+		GUISliderHorz* guiSlider = GUISliderHorz::create(options, toString(MonoUtil::monoToWString(style)));
+		guiSlider->onChanged.connect(std::bind(&ScriptGUISliderH::onChanged, instance, _1));
+
+		ScriptGUISliderH* nativeInstance = new (bs_alloc<ScriptGUISliderH>()) ScriptGUISliderH(instance, guiSlider);
+	}
+
+	void ScriptGUISliderH::internal_setPercent(ScriptGUISliderH* nativeInstance, float percent)
+	{
+		GUISliderHorz* slider = (GUISliderHorz*)nativeInstance->getGUIElement();
+		slider->setPercent(percent);
+	}
+
+	float ScriptGUISliderH::internal_getPercent(ScriptGUISliderH* nativeInstance)
+	{
+		GUISliderHorz* slider = (GUISliderHorz*)nativeInstance->getGUIElement();
+		return slider->getPercent();
+	}
+
+	void ScriptGUISliderH::onChanged(MonoObject* instance, float percent)
+	{
+		MonoException* exception = nullptr;
+		onChangedThunk(instance, percent, &exception);
+
+		MonoUtil::throwIfException(exception);
+	}
+
+	ScriptGUISliderV::OnChangedThunkDef ScriptGUISliderV::onChangedThunk;
+
+	ScriptGUISliderV::ScriptGUISliderV(MonoObject* instance, GUISliderVert* slider)
+		:TScriptGUIElement(instance, slider)
+	{
+
+	}
+
+	void ScriptGUISliderV::initRuntimeData()
+	{
+		metaData.scriptClass->addInternalCall("Internal_CreateInstance", &ScriptGUISliderV::internal_createInstance);
+		metaData.scriptClass->addInternalCall("Internal_SetPercent", &ScriptGUISliderV::internal_setPercent);
+		metaData.scriptClass->addInternalCall("Internal_GetPercent", &ScriptGUISliderV::internal_getPercent);
+
+		onChangedThunk = (OnChangedThunkDef)metaData.scriptClass->getMethod("DoOnChanged", 1)->getThunk();
+	}
+
+	void ScriptGUISliderV::internal_createInstance(MonoObject* instance, MonoString* style, MonoArray* guiOptions)
+	{
+		GUIOptions options;
+
+		UINT32 arrayLen = (UINT32)mono_array_length(guiOptions);
+		for (UINT32 i = 0; i < arrayLen; i++)
+			options.addOption(mono_array_get(guiOptions, GUIOption, i));
+
+		GUISliderVert* guiSlider = GUISliderVert::create(options, toString(MonoUtil::monoToWString(style)));
+		guiSlider->onChanged.connect(std::bind(&ScriptGUISliderV::onChanged, instance, _1));
+
+		ScriptGUISliderV* nativeInstance = new (bs_alloc<ScriptGUISliderV>()) ScriptGUISliderV(instance, guiSlider);
+	}
+
+	void ScriptGUISliderV::internal_setPercent(ScriptGUISliderV* nativeInstance, float percent)
+	{
+		GUISliderVert* slider = (GUISliderVert*)nativeInstance->getGUIElement();
+		slider->setPercent(percent);
+	}
+
+	float ScriptGUISliderV::internal_getPercent(ScriptGUISliderV* nativeInstance)
+	{
+		GUISliderVert* slider = (GUISliderVert*)nativeInstance->getGUIElement();
+		return slider->getPercent();
+	}
+
+	void ScriptGUISliderV::onChanged(MonoObject* instance, float percent)
+	{
+		MonoException* exception = nullptr;
+		onChangedThunk(instance, percent, &exception);
+
+		MonoUtil::throwIfException(exception);
+	}
+}

+ 4 - 1
TODO.txt

@@ -11,7 +11,10 @@ Test file/folder open/save dialog
 
 Add a simple way to create modal dialogs (ModalDialog in C#, similar to EditorWindow)
 
-Add C# wrappers for progress bar, slider, GUILayoutExplicit and GUIElement bounds and visible bounds (with ability to set non-visible bounds)
+Add C# wrappers GUIElement bounds and visible bounds (with ability to set non-visible bounds)
+
+Got a crash on shutdown that was caused by locking a mutex in an Event destructor. Event was Platform::onMouseCaptureChanged. 
+Issue happened when I closed the app via the X button (if that's relevant). It doesn't seem to happen always.
 
 <<<<<<Handles>>>>>>>>