Просмотр исходного кода

Finishing up ColorPicker
Changed how GUISliderHandle works so it retains its position even after its size changes
GUI element will now have default bounds assigned when their styles change, so that elements in explicit layouts have non zero bounds without requiring user to set them
Changed GUI area depth so it is anchored around 0

Marko Pintera 11 лет назад
Родитель
Сommit
c3af909c9d

+ 6 - 6
BansheeEditor/Source/BsBuiltinEditorResources.cpp

@@ -1089,8 +1089,8 @@ namespace BansheeEngine
 		GUIElementStyle colorPickerSliderHorzHandleStyle;
 		colorPickerSliderHorzHandleStyle.fixedHeight = true;
 		colorPickerSliderHorzHandleStyle.fixedWidth = true;
-		colorPickerSliderHorzHandleStyle.height = 32;
-		colorPickerSliderHorzHandleStyle.width = 10;
+		colorPickerSliderHorzHandleStyle.height = 20;
+		colorPickerSliderHorzHandleStyle.width = 7;
 		colorPickerSliderHorzHandleStyle.normal.texture = getGUITexture(ColorPickerSliderHorzHandleTex);
 		colorPickerSliderHorzHandleStyle.hover.texture = colorPickerSliderHorzHandleStyle.normal.texture;
 		colorPickerSliderHorzHandleStyle.active.texture = colorPickerSliderHorzHandleStyle.normal.texture;
@@ -1100,7 +1100,7 @@ namespace BansheeEngine
 		GUIElementStyle colorPickerSliderHorzStyle;
 		colorPickerSliderHorzHandleStyle.fixedHeight = true;
 		colorPickerSliderHorzHandleStyle.height = 32;
-		colorPickerSliderHorzHandleStyle.minWidth = 50;
+		colorPickerSliderHorzHandleStyle.minWidth = 20;
 		colorPickerSliderHorzStyle.subStyles[GUISlider::getHandleStyleType()] = "ColorSliderHorzHandle";
 
 		mSkin.setStyle("ColorSliderHorz", colorPickerSliderHorzStyle);
@@ -1108,8 +1108,8 @@ namespace BansheeEngine
 		GUIElementStyle colorPickerSliderVertHandleStyle;
 		colorPickerSliderVertHandleStyle.fixedHeight = true;
 		colorPickerSliderVertHandleStyle.fixedWidth = true;
-		colorPickerSliderVertHandleStyle.height = 10;
-		colorPickerSliderVertHandleStyle.width = 30;
+		colorPickerSliderVertHandleStyle.height = 7;
+		colorPickerSliderVertHandleStyle.width = 45;
 		colorPickerSliderVertHandleStyle.normal.texture = getGUITexture(ColorPickerSliderVertHandleTex);
 		colorPickerSliderVertHandleStyle.hover.texture = colorPickerSliderVertHandleStyle.normal.texture;
 		colorPickerSliderVertHandleStyle.active.texture = colorPickerSliderVertHandleStyle.normal.texture;
@@ -1119,7 +1119,7 @@ namespace BansheeEngine
 		GUIElementStyle colorPickerSliderVertStyle;
 		colorPickerSliderVertStyle.fixedWidth = true;
 		colorPickerSliderVertStyle.width = 30;
-		colorPickerSliderVertStyle.minHeight = 50;
+		colorPickerSliderVertStyle.minHeight = 20;
 		colorPickerSliderVertStyle.subStyles[GUISlider::getHandleStyleType()] = "ColorSliderVertHandle";
 
 		mSkin.setStyle("ColorSliderVert", colorPickerSliderVertStyle);

+ 6 - 1
BansheeEngine/Include/BsGUISliderHandle.h

@@ -130,6 +130,11 @@ namespace BansheeEngine
 	private:
 		GUISliderHandle(bool horizontal, bool jumpOnClick, const String& styleName, const GUILayoutOptions& layoutOptions);
 
+		/**
+		 * @brief	Returns the position of the slider handle, in pixels.
+		 */
+		INT32 getHandlePosPx() const;
+
 		/**
 		 * @copydoc	GUIElement::mouseEvent
 		 */
@@ -151,7 +156,7 @@ namespace BansheeEngine
 
 		bool mHorizontal; // Otherwise its vertical
 		bool mJumpOnClick;
-		float mHandlePos;
+		float mPctHandlePos;
 		INT32 mDragStartPos;
 		bool mMouseOverHandle;
 		bool mHandleDragged;

+ 9 - 2
BansheeEngine/Source/BsGUIElement.cpp

@@ -9,10 +9,11 @@
 namespace BansheeEngine
 {
 	GUIElement::GUIElement(const String& styleName, const GUILayoutOptions& layoutOptions)
-		:mLayoutOptions(layoutOptions), mDepth(0), mStyle(nullptr),
+		:mLayoutOptions(layoutOptions), mDepth(0), mStyle(&GUISkin::DefaultStyle),
 		mIsDestroyed(false), mStyleName(styleName)
 	{
-		_refreshStyle();
+		// Style is set to default here, and the proper one is assigned once GUI element
+		// is assigned to a parent (that's when the active GUI skin becomes known)
 	}
 
 	GUIElement::~GUIElement()
@@ -250,6 +251,12 @@ namespace BansheeEngine
 			mLayoutOptions.updateWithStyle(mStyle);
 			styleUpdated();
 
+			// Immediately update size, in case element is part of an explicit layout
+			// (In which case it would never get updated unless user set it explicitly)
+			LayoutSizeRange sizeRange = _calculateLayoutSizeRange();
+			mWidth = (UINT32)sizeRange.optimal.x;
+			mHeight = (UINT32)sizeRange.optimal.y;
+
 			markContentAsDirty();
 		}
 	}

+ 33 - 46
BansheeEngine/Source/BsGUISliderHandle.cpp

@@ -18,7 +18,7 @@ namespace BansheeEngine
 	}
 
 	GUISliderHandle::GUISliderHandle(bool horizontal, bool jumpOnClick, const String& styleName, const GUILayoutOptions& layoutOptions)
-		:GUIElement(styleName, layoutOptions), mHorizontal(horizontal), mHandleSize(0), mMouseOverHandle(false), mHandlePos(0), mDragStartPos(0),
+		:GUIElement(styleName, layoutOptions), mHorizontal(horizontal), mHandleSize(0), mMouseOverHandle(false), mPctHandlePos(0.0f), mDragStartPos(0),
 		mHandleDragged(false), mState(State::Normal), mJumpOnClick(jumpOnClick)
 	{
 		mImageSprite = bs_new<ImageSprite, PoolAlloc>();
@@ -49,22 +49,14 @@ namespace BansheeEngine
 
 	void GUISliderHandle::setHandlePos(float pct)
 	{
-		pct = Math::clamp01(pct);
-
-		UINT32 maxScrollAmount = getMaxSize() - mHandleSize;
-		mHandlePos = pct * maxScrollAmount;
+		mPctHandlePos = Math::clamp01(pct);
 
 		markContentAsDirty();
 	}
 
 	float GUISliderHandle::getHandlePos() const
 	{
-		UINT32 maxScrollAmount = getMaxSize() - mHandleSize;
-
-		if(maxScrollAmount > 0.0f)
-			return mHandlePos / maxScrollAmount;
-		else
-			return 0.0f;
+		return mPctHandlePos;;
 	}
 
 	UINT32 GUISliderHandle::getScrollableSize() const
@@ -148,15 +140,15 @@ namespace BansheeEngine
 	{
 		Vector2I offset = mOffset;
 		if(mHorizontal)
-			offset.x += Math::floorToInt(mHandlePos);
+			offset.x += getHandlePosPx();
 		else
-			offset.y += Math::floorToInt(mHandlePos);
+			offset.y += getHandlePosPx();
 
 		Rect2I clipRect = mClipRect;
 		if(mHorizontal)
-			clipRect.x -= Math::floorToInt(mHandlePos);
+			clipRect.x -= getHandlePosPx();
 		else
-			clipRect.y -= Math::floorToInt(mHandlePos);
+			clipRect.y -= getHandlePosPx();
 
 		mImageSprite->fillBuffer(vertices, uv, indices, startingQuad, maxNumQuads, 
 			vertexStride, indexStride, renderElementIdx, offset, clipRect);
@@ -199,23 +191,25 @@ namespace BansheeEngine
 
 			if (mJumpOnClick)
 			{
+				float handlePosPx = 0.0f;
+
 				if (mHorizontal)
-					mHandlePos = (float)(ev.getPosition().x - (INT32)mOffset.x - mHandleSize * 0.5f);
+					handlePosPx = (float)(ev.getPosition().x - (INT32)mOffset.x - mHandleSize * 0.5f);
 				else
-					mHandlePos = (float)(ev.getPosition().y - (INT32)mOffset.y - mHandleSize * 0.5f);
+					handlePosPx = (float)(ev.getPosition().y - (INT32)mOffset.y - mHandleSize * 0.5f);
 
 				float maxScrollAmount = (float)getMaxSize() - mHandleSize;
-				mHandlePos = Math::clamp(mHandlePos, 0.0f, maxScrollAmount);
+				mPctHandlePos = Math::clamp01(handlePosPx / maxScrollAmount);
 			}
 
 			if(mHorizontal)
 			{
-				INT32 left = (INT32)mOffset.x + Math::floorToInt(mHandlePos);
+				INT32 left = (INT32)mOffset.x + getHandlePosPx();
 				mDragStartPos = ev.getPosition().x - left;
 			}
 			else
 			{
-				INT32 top = (INT32)mOffset.y + Math::floorToInt(mHandlePos);
+				INT32 top = (INT32)mOffset.y + getHandlePosPx();
 				mDragStartPos = ev.getPosition().y - top;
 			}
 
@@ -225,26 +219,20 @@ namespace BansheeEngine
 
 		if(ev.getType() == GUIMouseEventType::MouseDrag && mHandleDragged)
 		{
+			float handlePosPx = 0.0f;
 			if(mHorizontal)
 			{
-				mHandlePos = (float)(ev.getPosition().x - mDragStartPos - mOffset.x);
+				handlePosPx = (float)(ev.getPosition().x - mDragStartPos - mOffset.x);
 			}
 			else
 			{
-				mHandlePos = float(ev.getPosition().y - mDragStartPos - mOffset.y);
+				handlePosPx = (float)(ev.getPosition().y - mDragStartPos - mOffset.y);
 			}
 
 			float maxScrollAmount = (float)getMaxSize() - mHandleSize;
-			mHandlePos = Math::clamp(mHandlePos, 0.0f, maxScrollAmount);
+			mPctHandlePos = Math::clamp01(handlePosPx / maxScrollAmount);
 
-			if(!onHandleMoved.empty())
-			{
-				float pct = 0.0f;
-				if(maxScrollAmount > 0.0f)
-					pct = mHandlePos / maxScrollAmount;
-				
-				onHandleMoved(pct);
-			}
+			onHandleMoved(mPctHandlePos);
 
 			markContentAsDirty();
 			return true;
@@ -267,12 +255,13 @@ namespace BansheeEngine
 				mState = State::Normal;
 			
 			// If we clicked above or below the scroll handle, scroll by one page
+			INT32 handlePosPx = getHandlePosPx();
 			if (!mJumpOnClick)
 			{
 				INT32 handleOffset = 0;
 				if (mHorizontal)
 				{
-					INT32 handleLeft = (INT32)mOffset.x + Math::floorToInt(mHandlePos);
+					INT32 handleLeft = (INT32)mOffset.x + handlePosPx;
 					INT32 handleRight = handleLeft + mHandleSize;
 
 					if (ev.getPosition().x < handleLeft)
@@ -282,7 +271,7 @@ namespace BansheeEngine
 				}
 				else
 				{
-					INT32 handleTop = (INT32)mOffset.y + Math::floorToInt(mHandlePos);
+					INT32 handleTop = (INT32)mOffset.y + handlePosPx;
 					INT32 handleBottom = handleTop + mHandleSize;
 
 					if (ev.getPosition().y < handleTop)
@@ -291,21 +280,13 @@ namespace BansheeEngine
 						handleOffset += mHandleSize;
 				}
 
-				mHandlePos += handleOffset;
+				handlePosPx += handleOffset;
 			}
 
 			float maxScrollAmount = (float)getMaxSize() - mHandleSize;
-			mHandlePos = Math::clamp(mHandlePos, 0.0f, maxScrollAmount);
+			mPctHandlePos = Math::clamp01(handlePosPx / maxScrollAmount);
 
-			if(!onHandleMoved.empty())
-			{
-				float pct = 0.0f;
-				
-				if(maxScrollAmount > 0.0f)
-					pct = (float)mHandlePos / maxScrollAmount;
-
-				onHandleMoved(pct);
-			}
+			onHandleMoved(mPctHandlePos);
 
 			markContentAsDirty();
 			return true;
@@ -331,7 +312,7 @@ namespace BansheeEngine
 	{
 		if(mHorizontal)
 		{
-			INT32 left = (INT32)mOffset.x + Math::floorToInt(mHandlePos);
+			INT32 left = (INT32)mOffset.x + getHandlePosPx();
 			INT32 right = left + mHandleSize;
 
 			if(pos.x >= left && pos.x < right)
@@ -339,7 +320,7 @@ namespace BansheeEngine
 		}
 		else
 		{
-			INT32 top = (INT32)mOffset.y + Math::floorToInt(mHandlePos);
+			INT32 top = (INT32)mOffset.y + getHandlePosPx();
 			INT32 bottom = top + mHandleSize;
 
 			if(pos.y >= top && pos.y < bottom)
@@ -349,6 +330,12 @@ namespace BansheeEngine
 		return false;
 	}
 
+	INT32 GUISliderHandle::getHandlePosPx() const
+	{
+		UINT32 maxScrollAmount = getMaxSize() - mHandleSize;
+		return Math::floorToInt(mPctHandlePos * maxScrollAmount);
+	}
+
 	UINT32 GUISliderHandle::getMaxSize() const
 	{
 		UINT32 maxSize = mHeight;

+ 67 - 36
MBansheeEditor/ColorPicker.cs

@@ -22,8 +22,8 @@ namespace BansheeEditor
         private ColorSlider2D colorBox;
         private ColorSlider1DVert sideSlider;
 
-        private ColorBoxMode colorBoxMode;
-        private SliderMode sliderMode;
+        private ColorBoxMode colorBoxMode = ColorBoxMode.BG_R;
+        private SliderMode sliderMode = SliderMode.HSV;
 
         private GUIColorField guiColor;
         private GUITexture guiSlider2DTex;
@@ -242,6 +242,13 @@ namespace BansheeEditor
 
             colorBox.OnValueChanged += OnColorBoxValueChanged;
 
+            Color startA = new Color(0, 0, 0, 1);
+            Color stepA = new Color(1, 1, 1, 0);
+            sliderA.UpdateTexture(startA, stepA, false);
+            guiInputA.SetRange(0, 255);
+            guiInputA.Value = 255;
+            guiSliderAHorz.Percent = 1.0f;
+
             guiColor.Value = SelectedColor;
             UpdateInputBoxValues();
             Update2DSliderTextures();
@@ -249,11 +256,6 @@ namespace BansheeEditor
             Update1DSliderTextures();
             Update1DSliderValues();
             UpdateSliderMode();
-
-            Color startA = new Color(0, 0, 0, 1);
-            Color stepA = new Color(1, 1, 1, 0);
-            sliderA.UpdateTexture(startA, stepA, false);
-            guiInputA.SetRange(0, 255);
         }
 
         private void OnEditorUpdate()
@@ -274,13 +276,14 @@ namespace BansheeEditor
                 downDelta = downGradient / (height - 1);
 
             Color verticalColor = start;
-            int idx = 0;
             for (int y = 0; y < height; y++)
             {
+                int rowIdx = (height - y - 1) * width;
+
                 Color currentColor = verticalColor;
                 for (int x = 0; x < width; x++)
                 {
-                    colors[idx++] = currentColor;
+                    colors[rowIdx + x] = currentColor;
                     currentColor += rightDelta;
                 }
                 verticalColor += downDelta;
@@ -335,13 +338,13 @@ namespace BansheeEditor
             switch (colorBoxMode)
             {
                 case ColorBoxMode.BG_R:
-                    colGreen = value.x;
-                    colBlue = value.y;
+                    colBlue = value.x;
+                    colGreen = value.y;
                     RGBToHSV();
                     break;
                 case ColorBoxMode.BR_G:
-                    colRed = value.x;
-                    colBlue = value.y;
+                    colBlue = value.x;
+                    colRed = value.y;
                     RGBToHSV();
                     break;
                 case ColorBoxMode.RG_B:
@@ -370,10 +373,19 @@ namespace BansheeEditor
             UpdateInputBoxValues();
             Update1DSliderTextures();
             Update1DSliderValues();
+            UpdateSideSliderTexture();
+
+            Vector2 xy;
+            float z;
+
+            GetColorBoxValues(out xy, out z);
+            guiSliderVert.Percent = 1.0f - z;
         }
 
         void OnSliderVertChanged(float percent)
         {
+            percent = 1.0f - percent;
+
             switch (colorBoxMode)
             {
                 case ColorBoxMode.BG_R:
@@ -473,7 +485,7 @@ namespace BansheeEditor
             colAlpha = percent;
 
             guiColor.Value = SelectedColor;
-            guiInputA.Value = MathEx.RoundToInt(colValue * 255.0f);
+            guiInputA.Value = MathEx.RoundToInt(colAlpha * 255.0f);
         }
 
         void OnInputRChanged(int value)
@@ -618,10 +630,10 @@ namespace BansheeEditor
             }
         }
 
-        void Update2DSliderValues()
+        void GetColorBoxValues(out Vector2 xy, out float z)
         {
-            Vector2 xy = Vector2.zero;
-            float z = 0.0f;
+            xy = Vector2.zero;
+            z = 0.0f;
 
             switch (colorBoxMode)
             {
@@ -631,8 +643,8 @@ namespace BansheeEditor
                     z = colRed;
                     break;
                 case ColorBoxMode.BR_G:
-                    xy.x = colRed;
-                    xy.y = colBlue;
+                    xy.x = colBlue;
+                    xy.y = colRed;
                     z = colGreen;
                     break;
                 case ColorBoxMode.RG_B:
@@ -656,6 +668,14 @@ namespace BansheeEditor
                     z = colValue;
                     break;
             }
+        }
+
+        void Update2DSliderValues()
+        {
+            Vector2 xy = Vector2.zero;
+            float z = 0.0f;
+
+            GetColorBoxValues(out xy, out z);
 
             colorBox.SetValue(xy);
             guiSliderVert.Percent = z;
@@ -670,17 +690,17 @@ namespace BansheeEditor
                 Color startH = new Color(0, 1, 1);
                 Color stepH = new Color(1, 0, 0, 0);
 
-                sliderR.UpdateTexture(startH, stepH, false);
+                sliderR.UpdateTexture(startH, stepH, true);
 
                 Color startS = new Color(colHue, 0, MathEx.Max(colValue, 0.2f));
                 Color stepS = new Color(0, 1, 0, 0);
 
-                sliderG.UpdateTexture(startS, stepS, false);
+                sliderG.UpdateTexture(startS, stepS, true);
 
                 Color startV = new Color(colHue, colSaturation, 0);
                 Color stepV = new Color(0, 0, 1, 0);
 
-                sliderB.UpdateTexture(startV, stepV, false);
+                sliderB.UpdateTexture(startV, stepV, true);
             }
             else
             {
@@ -701,7 +721,7 @@ namespace BansheeEditor
             }
         }
 
-        void Update2DSliderTextures()
+        void UpdateSideSliderTexture()
         {
             switch (colorBoxMode)
             {
@@ -724,6 +744,11 @@ namespace BansheeEditor
                     sideSlider.UpdateTexture(new Color(colHue, colSaturation, 0, 1), new Color(0, 0, 1, 0), true);
                     break;
             }
+        }
+
+        void Update2DSliderTextures()
+        {
+            UpdateSideSliderTexture();
 
             float[] valueLookup = new float[] { colRed, colGreen, colBlue, colHue, colSaturation, colValue };
             colorBox.UpdateTexture(colorBoxMode, valueLookup[(int)colorBoxMode]);
@@ -731,7 +756,8 @@ namespace BansheeEditor
 
         public class ColorSlider1DHorz
         {
-            private const int SLIDER_HEIGHT = 8;
+            private const int SLIDER_X_OFFSET = 3;
+            private const int SLIDER_Y_OFFSET = 5;
 
             private int width, height;
             private Texture2D texture;
@@ -766,17 +792,19 @@ namespace BansheeEditor
                 guiTexture.SetTexture(spriteTexture);
 
                 Rect2I sliderBounds = guiTexture.Bounds;
-                sliderBounds.y -= SLIDER_HEIGHT;
-                sliderBounds.height += SLIDER_HEIGHT;
+                sliderBounds.x -= SLIDER_X_OFFSET;
+                sliderBounds.width += SLIDER_X_OFFSET*2;
+                sliderBounds.y -= SLIDER_Y_OFFSET;
+                sliderBounds.height += SLIDER_Y_OFFSET;
 
-                Debug.Log("SLIDER BOUNDS HORZ: " + sliderBounds);
                 guiSlider.Bounds = sliderBounds;
             }
         }
 
         public class ColorSlider1DVert
         {
-            private const int SLIDER_WIDTH = 7;
+            private const int SLIDER_X_OFFSET = 5;
+            private const int SLIDER_Y_OFFSET = 3;
 
             private int width, height;
             private Texture2D texture;
@@ -811,10 +839,11 @@ namespace BansheeEditor
                 guiTexture.SetTexture(spriteTexture);
 
                 Rect2I sliderBounds = guiTexture.Bounds;
-                sliderBounds.x -= SLIDER_WIDTH;
-                sliderBounds.width += SLIDER_WIDTH;
+                sliderBounds.x -= SLIDER_X_OFFSET;
+                sliderBounds.width += SLIDER_X_OFFSET;
+                sliderBounds.y -= SLIDER_Y_OFFSET;
+                sliderBounds.height += SLIDER_Y_OFFSET * 2;
 
-                Debug.Log("SLIDER BOUNDS VERT: " + sliderBounds);
                 guiSlider.Bounds = sliderBounds;
             }
         }
@@ -828,7 +857,7 @@ namespace BansheeEditor
             private GUITexture guiTexture;
             private GUITexture guiSliderHandle;
 
-            private Vector2 oldValue;
+            private Vector2 oldValue = new Vector2(-1, -1);
 
             public delegate void OnValueChangedDelegate(Vector2 value);
             public event OnValueChangedDelegate OnValueChanged;
@@ -891,7 +920,7 @@ namespace BansheeEditor
                     {
                         Vector2 newValue = Vector2.zero;
                         newValue.x = (windowPos.x - bounds.x) / (float)bounds.width;
-                        newValue.y = (windowPos.y - bounds.y) / (float)bounds.height;
+                        newValue.y = 1.0f - (windowPos.y - bounds.y) / (float)bounds.height;
 
                         SetValue(newValue);
                     }
@@ -900,17 +929,19 @@ namespace BansheeEditor
 
             public void SetValue(Vector2 value)
             {
+                Vector2 pos = value;
+                pos.y = 1.0f - pos.y;
+
                 if (oldValue == value)
                     return;
 
                 Rect2I handleBounds = guiSliderHandle.Bounds;
                 Rect2I boxBounds = guiTexture.Bounds;
 
-                handleBounds.x = boxBounds.x + MathEx.RoundToInt(value.x * boxBounds.width) - handleBounds.width / 2;
-                handleBounds.y = boxBounds.y + MathEx.RoundToInt(value.y * boxBounds.height) - handleBounds.height / 2;
+                handleBounds.x = boxBounds.x + MathEx.RoundToInt(pos.x * boxBounds.width) - handleBounds.width / 2;
+                handleBounds.y = boxBounds.y + MathEx.RoundToInt(pos.y * boxBounds.height) - handleBounds.height / 2;
 
                 guiSliderHandle.Bounds = handleBounds;
-
                 oldValue = value;
 
                 if (OnValueChanged != null)

+ 1 - 1
MBansheeEngine/Color.cs

@@ -136,7 +136,7 @@ namespace BansheeEngine
             else
             {
                 output.g = 0.0f;
-                output.r = float.NaN;
+                output.r = 0.0f;
                 return output;
             }
 

+ 2 - 2
SBansheeEngine/Include/BsScriptGUIArea.h

@@ -18,11 +18,11 @@ namespace BansheeEngine
 
 	private:
 		static void internal_createInstance(MonoObject* instance, MonoObject* parentGUI, INT32 x, INT32 y, UINT32 width, UINT32 height, 
-			UINT16 depth, GUILayoutType layoutType);
+			INT16 depth, GUILayoutType layoutType);
 
 		static void internal_destroy(ScriptGUIArea* thisPtr);
 		static void internal_setVisible(ScriptGUIArea* thisPtr, bool visible);
-		static void internal_setArea(ScriptGUIArea* thisPtr, INT32 x, INT32 y, UINT32 width, UINT32 height, UINT16 depth);
+		static void internal_setArea(ScriptGUIArea* thisPtr, INT32 x, INT32 y, UINT32 width, UINT32 height, INT16 depth);
 
 		ScriptGUIArea(MonoObject* instance, GUIArea* area, ScriptGUIPanel* panel);
 

+ 8 - 4
SBansheeEngine/Source/BsScriptGUIArea.cpp

@@ -38,10 +38,12 @@ namespace BansheeEngine
 	}
 
 	void ScriptGUIArea::internal_createInstance(MonoObject* instance, MonoObject* panel, INT32 x, INT32 y, UINT32 width, 
-		UINT32 height, UINT16 depth, GUILayoutType layoutType)
+		UINT32 height, INT16 depth, GUILayoutType layoutType)
 	{
+		UINT16 signedDepth = depth + 32768;
+
 		ScriptGUIPanel* scriptGUIPanel = ScriptGUIPanel::toNative(panel);
-		GUIArea* nativeArea = GUIArea::create(scriptGUIPanel->getWidget(), x, y, width, height, depth, layoutType);
+		GUIArea* nativeArea = GUIArea::create(scriptGUIPanel->getWidget(), x, y, width, height, signedDepth, layoutType);
 
 		ScriptGUIArea* nativeInstance = new (bs_alloc<ScriptGUIArea>()) ScriptGUIArea(instance, nativeArea, scriptGUIPanel);
 	}
@@ -59,15 +61,17 @@ namespace BansheeEngine
 			thisPtr->mGUIArea->disable();
 	}
 
-	void ScriptGUIArea::internal_setArea(ScriptGUIArea* thisPtr, INT32 x, INT32 y, UINT32 width, UINT32 height, UINT16 depth)
+	void ScriptGUIArea::internal_setArea(ScriptGUIArea* thisPtr, INT32 x, INT32 y, UINT32 width, UINT32 height, INT16 depth)
 	{
+		UINT16 signedDepth = depth + 32768;
+
 		thisPtr->mArea.x = x;
 		thisPtr->mArea.y = y;
 		thisPtr->mArea.width = width;
 		thisPtr->mArea.height = height;
 
 		thisPtr->updateArea();
-		thisPtr->mGUIArea->setDepth(depth);
+		thisPtr->mGUIArea->setDepth(signedDepth);
 	}
 
 	void ScriptGUIArea::updateArea()

+ 1 - 0
TODO.txt

@@ -105,6 +105,7 @@ Other simple stuff:
  - Font doesn't have a C# interface
  - Material/Shader/Technique/Pass don't have a C# interface
  - Get rid of PoolAlloc and other unused allocators (plus fix bs_new and others which have weird overloads)
+ - Call stack from C# to use in Debug.Log calls
 
 ----------------------------------------------------------------------
 Handles