Browse Source

Added Color field

Marko Pintera 11 years ago
parent
commit
ef90dfe7e7

+ 2 - 0
BansheeEditor/BansheeEditor.vcxproj

@@ -276,6 +276,7 @@
     <ClInclude Include="Include\BsEditorWidgetLayoutRTTI.h" />
     <ClInclude Include="Include\BsEditorWidgetManager.h" />
     <ClInclude Include="Include\BsGUIColor.h" />
+    <ClInclude Include="Include\BsGUIColorField.h" />
     <ClInclude Include="Include\BsGUIFloatField.h" />
     <ClInclude Include="Include\BsGUIIntField.h" />
     <ClInclude Include="Include\BsGUITextField.h" />
@@ -327,6 +328,7 @@
     <ClCompile Include="Source\BsEditorWindowBase.cpp" />
     <ClCompile Include="Source\BsEditorWindowManager.cpp" />
     <ClCompile Include="Source\BsGUIColor.cpp" />
+    <ClCompile Include="Source\BsGUIColorField.cpp" />
     <ClCompile Include="Source\BsGUIDockSlider.cpp" />
     <ClCompile Include="Source\BsGUIFloatField.cpp" />
     <ClCompile Include="Source\BsGUIIntField.cpp" />

+ 6 - 0
BansheeEditor/BansheeEditor.vcxproj.filters

@@ -177,6 +177,9 @@
     <ClInclude Include="Include\BsGUIColor.h">
       <Filter>Header Files\Editor</Filter>
     </ClInclude>
+    <ClInclude Include="Include\BsGUIColorField.h">
+      <Filter>Header Files\Editor</Filter>
+    </ClInclude>
   </ItemGroup>
   <ItemGroup>
     <ClCompile Include="Source\BsEditorWidgetContainer.cpp">
@@ -305,5 +308,8 @@
     <ClCompile Include="Source\BsGUIColor.cpp">
       <Filter>Source Files\Editor</Filter>
     </ClCompile>
+    <ClCompile Include="Source\BsGUIColorField.cpp">
+      <Filter>Source Files\Editor</Filter>
+    </ClCompile>
   </ItemGroup>
 </Project>

+ 7 - 0
BansheeEditor/Include/BsEditorGUI.h

@@ -43,6 +43,13 @@ namespace BansheeEditor
 		static const CM::WString ButtonNormalTex;
 		static const CM::WString ButtonHoverTex;
 
+		static const CM::WString ToggleNormalTex;
+		static const CM::WString ToggleHoverTex;
+		static const CM::WString ToggleActiveTex;
+		static const CM::WString ToggleNormalOnTex;
+		static const CM::WString ToggleHoverOnTex;
+		static const CM::WString ToggleActiveOnTex;
+
 		static const CM::WString InputBoxNormalTex;
 		static const CM::WString InputBoxHoverTex;
 		static const CM::WString InputBoxFocusedTex;

+ 1 - 0
BansheeEditor/Include/BsEditorPrerequisites.h

@@ -34,6 +34,7 @@ namespace BansheeEditor
 	class GUIIntField;
 	class GUIFloatField;
 	class GUITextField;
+	class GUIColor;
 	class EditorWindowManager;
 	class DockManager;
 	class DockManagerLayout;

+ 56 - 0
BansheeEditor/Include/BsGUIColorField.h

@@ -0,0 +1,56 @@
+#pragma once
+
+#include "BsEditorPrerequisites.h"
+#include "BsGUIElementContainer.h"
+
+namespace BansheeEditor
+{
+	class BS_ED_EXPORT GUIColorField : public BS::GUIElementContainer
+	{
+		struct PrivatelyConstruct {};
+
+	public:
+		static const CM::String& getGUITypeName();
+
+		static GUIColorField* create(BS::GUIWidget& parent, const BS::GUIContent& labelContent, 
+			const BS::GUIOptions& layoutOptions, BS::GUIElementStyle* labelStyle = nullptr, BS::GUIElementStyle* toggleStyle = nullptr);
+
+		static GUIColorField* create(BS::GUIWidget& parent, const CM::HString& labelText, 
+			const BS::GUIOptions& layoutOptions, BS::GUIElementStyle* labelStyle = nullptr, BS::GUIElementStyle* toggleStyle = nullptr);
+
+		static GUIColorField* create(BS::GUIWidget& parent, 
+			const BS::GUIOptions& layoutOptions, BS::GUIElementStyle* labelStyle = nullptr, BS::GUIElementStyle* toggleStyle = nullptr);
+
+		static GUIColorField* create(BS::GUIWidget& parent, const BS::GUIContent& labelContent, 
+			BS::GUIElementStyle* labelStyle = nullptr, BS::GUIElementStyle* toggleStyle = nullptr);
+
+		static GUIColorField* create(BS::GUIWidget& parent, const CM::HString& labelText, 
+			BS::GUIElementStyle* labelStyle = nullptr, BS::GUIElementStyle* toggleStyle = nullptr);
+
+		static GUIColorField* create(BS::GUIWidget& parent, 
+			BS::GUIElementStyle* labelStyle = nullptr, BS::GUIElementStyle* toggleStyle = nullptr);
+
+		GUIColorField(const PrivatelyConstruct& dummy, BS::GUIWidget& parent, const BS::GUIContent& labelContent, 
+			BS::GUIElementStyle* labelStyle, BS::GUIElementStyle* toggleStyle, const BS::GUILayoutOptions& layoutOptions);
+
+		GUIColorField(const PrivatelyConstruct& dummy, BS::GUIWidget& parent, 
+			BS::GUIElementStyle* labelStyle, BS::GUIElementStyle* toggleStyle, const BS::GUILayoutOptions& layoutOptions);
+
+		CM::Color getValue() const;
+		void setValue(const CM::Color& value);
+
+		void setLabelWidth(CM::UINT32 width);
+
+		void _updateLayoutInternal(CM::INT32 x, CM::INT32 y, CM::UINT32 width, CM::UINT32 height,
+			CM::RectI clipRect, CM::UINT8 widgetDepth, CM::UINT16 areaDepth);
+
+		CM::Vector2I _getOptimalSize() const;
+	protected:
+		virtual ~GUIColorField();
+
+	protected:
+		CM::UINT32 mLabelWidth;
+		BS::GUILabel* mLabel;
+		GUIColor* mColor;
+	};
+}

+ 36 - 0
BansheeEditor/Source/BsEditorGUI.cpp

@@ -4,6 +4,8 @@
 #include "BsGUILabel.h"
 #include "BsGUIButton.h"
 #include "BsGUIInputBox.h"
+#include "BsGUIToggle.h"
+#include "BsGUIColor.h"
 #include "BsTextSprite.h"
 #include "BsSpriteTexture.h"
 #include "BsGUITreeViewEditBox.h"
@@ -29,6 +31,13 @@ namespace BansheeEditor
 	const WString EditorGUI::ButtonNormalTex = L"ButtonNormal.psd";
 	const WString EditorGUI::ButtonHoverTex = L"ButtonHover.psd";
 
+	const WString EditorGUI::ToggleNormalTex = L"ToggleNormal.psd";
+	const WString EditorGUI::ToggleHoverTex = L"ToggleHover.psd";
+	const WString EditorGUI::ToggleActiveTex = L"ToggleActive.psd";
+	const WString EditorGUI::ToggleNormalOnTex = L"ToggleOnNormal.psd";
+	const WString EditorGUI::ToggleHoverOnTex = L"ToggleOnHover.psd";
+	const WString EditorGUI::ToggleActiveOnTex = L"ToggleOnActive.psd";
+
 	const WString EditorGUI::WindowFrameNormal = L"WindowFrameNormal.psd";
 	const WString EditorGUI::WindowFrameFocused = L"WindowFrameFocused.psd";
 
@@ -186,6 +195,33 @@ namespace BansheeEditor
 
 		mSkin.setStyle(GUIButton::getGUITypeName(), buttonStyle);
 
+		// Toggle
+		GUIElementStyle toggleStyle;
+		toggleStyle.normal.texture = getTexture(ToggleNormalTex);
+		toggleStyle.hover.texture = getTexture(ToggleHoverTex);
+		toggleStyle.active.texture = getTexture(ToggleActiveTex);
+		toggleStyle.normalOn.texture = getTexture(ToggleNormalOnTex);
+		toggleStyle.hoverOn.texture = getTexture(ToggleHoverOnTex);
+		toggleStyle.activeOn.texture = getTexture(ToggleActiveOnTex);
+		toggleStyle.fixedHeight = true;
+		toggleStyle.fixedWidth = true;
+		toggleStyle.height = 15;
+		toggleStyle.width = 15;
+
+		mSkin.setStyle(GUIToggle::getGUITypeName(), toggleStyle);
+
+		// Color
+		GUIElementStyle colorStyle;
+		colorStyle.margins.left = 2;
+		colorStyle.margins.right = 2;
+		colorStyle.margins.top = 2;
+		colorStyle.margins.bottom = 2;
+		colorStyle.fixedHeight = true;
+		colorStyle.height = 10;
+		colorStyle.minWidth = 10;
+
+		mSkin.setStyle(GUIColor::getGUITypeName(), colorStyle);
+
 		// Window background texture
 		GUIElementStyle windowBgStyle;
 		windowBgStyle.normal.texture = getTexture(WindowBackgroundTexture);

+ 1 - 2
BansheeEditor/Source/BsGUIColor.cpp

@@ -131,7 +131,7 @@ namespace BansheeEditor
 
 	Vector2I GUIColor::_getOptimalSize() const
 	{
-		return Vector2I(80, 20); // Arbitrary
+		return GUIHelper::calcOptimalContentsSize(Vector2I(80, 10), *mStyle, _getLayoutOptions()); // Arbitrary size
 	}
 
 	void GUIColor::fillBuffer(UINT8* vertices, UINT8* uv, UINT32* indices, UINT32 startingQuad, UINT32 maxNumQuads, 
@@ -154,7 +154,6 @@ namespace BansheeEditor
 
 			RectI alphaClipRect = mClipRect;
 			alphaClipRect.x -= xOffset;
-			alphaClipRect.width = (UINT32)std::max(0, (INT32)alphaClipRect.width - (INT32)xOffset);
 
 			mAlphaSprite->fillBuffer(vertices, uv, indices, startingQuad, maxNumQuads, 
 				vertexStride, indexStride, alphaSpriteIdx - renderElementIdx, alphaOffset, alphaClipRect);

+ 173 - 0
BansheeEditor/Source/BsGUIColorField.cpp

@@ -0,0 +1,173 @@
+#include "BsGUIColorField.h"
+#include "BsGUIArea.h"
+#include "BsGUILayout.h"
+#include "BsGUILabel.h"
+#include "BsGUIColor.h"
+#include "BsBuiltinResources.h"
+#include "BsGUIWidget.h"
+#include "BsGUIMouseEvent.h"
+#include "BsGUIWidget.h"
+
+using namespace CamelotFramework;
+using namespace BansheeEngine;
+
+namespace BansheeEditor
+{
+	GUIColorField::GUIColorField(const PrivatelyConstruct& dummy, GUIWidget& parent, const GUIContent& labelContent, 
+		GUIElementStyle* labelStyle, GUIElementStyle* colorStyle, const GUILayoutOptions& layoutOptions)
+		:GUIElementContainer(parent, layoutOptions), mLabel(nullptr), mColor(nullptr), mLabelWidth(100)
+	{
+		const GUIElementStyle* curLabelStyle = labelStyle;
+		const GUIElementStyle* curColorStyle = colorStyle;
+
+		if(curLabelStyle == nullptr)
+			curLabelStyle = parent.getSkin().getStyle("Label");
+
+		if(curColorStyle == nullptr)
+			curColorStyle = parent.getSkin().getStyle("Color");
+
+		mLabel = GUILabel::create(parent, labelContent, curLabelStyle);
+		mColor = GUIColor::create(parent, curColorStyle);
+
+		_registerChildElement(mLabel);
+		_registerChildElement(mColor);
+	}
+
+	GUIColorField::GUIColorField(const PrivatelyConstruct& dummy, GUIWidget& parent, 
+		GUIElementStyle* labelStyle, GUIElementStyle* colorStyle, const GUILayoutOptions& layoutOptions)
+		:GUIElementContainer(parent, layoutOptions), mLabel(nullptr), mColor(nullptr), mLabelWidth(100)
+	{
+		const GUIElementStyle* curColorStyle = colorStyle;
+
+		if(curColorStyle == nullptr)
+			curColorStyle = parent.getSkin().getStyle("Color");
+
+		mColor = GUIColor::create(parent, curColorStyle);
+
+		_registerChildElement(mColor);
+	}
+
+	GUIColorField::~GUIColorField()
+	{
+
+	}
+
+	GUIColorField* GUIColorField::create(GUIWidget& parent, const GUIContent& labelContent, const GUIOptions& layoutOptions, 
+		GUIElementStyle* labelStyle, GUIElementStyle* toggleStyle)
+	{
+		return cm_new<GUIColorField>(PrivatelyConstruct(), parent, labelContent, labelStyle, toggleStyle, 
+			GUILayoutOptions::create(layoutOptions, &GUISkin::DefaultStyle));
+	}
+
+	GUIColorField* GUIColorField::create(GUIWidget& parent, const GUIContent& labelContent, GUIElementStyle* labelStyle, 
+		GUIElementStyle* toggleStyle)
+	{
+		return cm_new<GUIColorField>(PrivatelyConstruct(), parent, labelContent, labelStyle, toggleStyle, 
+			GUILayoutOptions::create(&GUISkin::DefaultStyle));
+	}
+
+	GUIColorField* GUIColorField::create(GUIWidget& parent, const HString& labelContent, const GUIOptions& layoutOptions, 
+		GUIElementStyle* labelStyle, GUIElementStyle* toggleStyle)
+	{
+		return cm_new<GUIColorField>(PrivatelyConstruct(), parent, GUIContent(labelContent), labelStyle, 
+			toggleStyle, GUILayoutOptions::create(layoutOptions, &GUISkin::DefaultStyle));
+	}
+
+	GUIColorField* GUIColorField::create(GUIWidget& parent, const HString& labelContent, GUIElementStyle* labelStyle, 
+		GUIElementStyle* toggleStyle)
+	{
+		return cm_new<GUIColorField>(PrivatelyConstruct(), parent, GUIContent(labelContent), labelStyle, toggleStyle, 
+			GUILayoutOptions::create(&GUISkin::DefaultStyle));
+	}
+
+	GUIColorField* GUIColorField::create(GUIWidget& parent, const GUIOptions& layoutOptions, GUIElementStyle* labelStyle, 
+		GUIElementStyle* toggleStyle)
+	{
+		return cm_new<GUIColorField>(PrivatelyConstruct(), parent, labelStyle, toggleStyle, 
+			GUILayoutOptions::create(layoutOptions, &GUISkin::DefaultStyle));
+	}
+
+	GUIColorField* GUIColorField::create(GUIWidget& parent, GUIElementStyle* labelStyle, GUIElementStyle* toggleStyle)
+	{
+		return cm_new<GUIColorField>(PrivatelyConstruct(), parent, labelStyle, toggleStyle, GUILayoutOptions::create(&GUISkin::DefaultStyle));
+	}
+
+	Color GUIColorField::getValue() const
+	{
+		return mColor->getColor();
+	}
+
+	void GUIColorField::setValue(const CM::Color& color)
+	{
+		mColor->setColor(color);
+	}
+
+	void GUIColorField::setLabelWidth(UINT32 width)
+	{
+		mLabelWidth = width;
+
+		markContentAsDirty();
+	}
+
+	void GUIColorField::_updateLayoutInternal(INT32 x, INT32 y, UINT32 width, UINT32 height,
+		RectI clipRect, UINT8 widgetDepth, UINT16 areaDepth)
+	{
+		UINT32 colorOffset = 0;
+		UINT32 colorWidth = width;
+
+		if(mLabel != nullptr)
+		{
+			UINT32 labelWidth = mLabelWidth;
+
+			Vector2I optimalSize = mLabel->_getOptimalSize();
+			INT32 yOffset = Math::roundToInt((height - optimalSize.y) * 0.5f);
+
+			Vector2I offset(x, y + yOffset);
+			mLabel->_setOffset(offset);
+			mLabel->_setWidth(labelWidth);
+			mLabel->_setHeight(optimalSize.y);
+			mLabel->_setAreaDepth(areaDepth);
+			mLabel->_setWidgetDepth(widgetDepth);
+
+			RectI elemClipRect(clipRect.x - offset.x, clipRect.y - offset.y, clipRect.width, clipRect.height);
+			mLabel->_setClipRect(elemClipRect);
+
+			colorOffset = labelWidth;
+			colorWidth = width - labelWidth;
+		}
+
+		{
+			Vector2I optimalSize = mColor->_getOptimalSize();
+			INT32 yOffset = Math::roundToInt((height - optimalSize.y) * 0.5f);
+
+			Vector2I offset(x + colorOffset, y + yOffset);
+			mColor->_setOffset(offset);
+			mColor->_setWidth(colorWidth);
+			mColor->_setHeight(optimalSize.y);
+			mColor->_setAreaDepth(areaDepth);
+			mColor->_setWidgetDepth(widgetDepth);
+
+			RectI elemClipRect(clipRect.x - offset.x, clipRect.y - offset.y, clipRect.width, clipRect.height);
+			mColor->_setClipRect(elemClipRect);
+		}
+	}
+
+	Vector2I GUIColorField::_getOptimalSize() const
+	{
+		Vector2I optimalsize = mColor->_getOptimalSize();
+
+		if(mLabel != nullptr)
+		{
+			optimalsize.x += mLabel->_getOptimalSize().x;
+			optimalsize.y = std::max(optimalsize.y, mLabel->_getOptimalSize().y);
+		}
+
+		return optimalsize;
+	}
+
+	const String& GUIColorField::getGUITypeName()
+	{
+		static String typeName = "GUIColorField";
+		return typeName;
+	}
+}

+ 1 - 5
BansheeEditor/Source/BsGUIToggleField.cpp

@@ -116,7 +116,6 @@ namespace BansheeEditor
 		RectI clipRect, UINT8 widgetDepth, UINT16 areaDepth)
 	{
 		UINT32 toggleOffset = 0;
-		UINT32 toggleWidth = width;
 
 		if(mLabel != nullptr)
 		{
@@ -136,18 +135,15 @@ namespace BansheeEditor
 			mLabel->_setClipRect(elemClipRect);
 
 			toggleOffset = labelWidth;
-			toggleWidth = width - labelWidth;
 		}
 
-		Vector2I toggleSize = mToggle->_getOptimalSize();
-
 		{
 			Vector2I optimalSize = mToggle->_getOptimalSize();
 			INT32 yOffset = Math::roundToInt((height - optimalSize.y) * 0.5f);
 
 			Vector2I offset(x + toggleOffset, y + yOffset);
 			mToggle->_setOffset(offset);
-			mToggle->_setWidth(toggleWidth);
+			mToggle->_setWidth(optimalSize.x);
 			mToggle->_setHeight(optimalSize.y);
 			mToggle->_setAreaDepth(areaDepth);
 			mToggle->_setWidgetDepth(widgetDepth);

+ 7 - 0
BansheeEditor/Source/DbgEditorWidget2.cpp

@@ -12,6 +12,8 @@
 #include "BsGUIVector2Field.h"
 #include "BsGUIVector3Field.h"
 #include "BsGUIVector4Field.h"
+#include "BsGUIToggleField.h"
+#include "BsGUIColorField.h"
 #include "BsGUISpace.h"
 #include "CmHString.h"
 
@@ -33,6 +35,9 @@ namespace BansheeEditor
 		GUIVector4Field* vec4Field = GUIVector4Field::create(getParentWidget(), HString(L"Vec4 Field"), GUIOptions(GUIOption::fixedWidth(200)));
 		GUIVector3Field* vec3Field = GUIVector3Field::create(getParentWidget(), HString(L"Vec3 Field"), GUIOptions(GUIOption::fixedWidth(200)));
 		GUIVector2Field* vec2Field = GUIVector2Field::create(getParentWidget(), HString(L"Vec2 Field"), GUIOptions(GUIOption::fixedWidth(200)));
+		GUIToggleField* toggleField = GUIToggleField::create(getParentWidget(), HString(L"Toggle Field"), GUIOptions(GUIOption::fixedWidth(200)));
+		GUIColorField* colorField = GUIColorField::create(getParentWidget(), HString(L"Color Field"), GUIOptions(GUIOption::fixedWidth(200)));
+		colorField->setValue(Color::Red);
 
 		layout.addElement(intField);
 		layout.addElement(floatField);
@@ -40,6 +45,8 @@ namespace BansheeEditor
 		layout.addElement(vec4Field);
 		layout.addElement(vec3Field);
 		layout.addElement(vec2Field);
+		layout.addElement(toggleField);
+		layout.addElement(colorField);
 
 		layout.addFlexibleSpace();
 	}

+ 7 - 0
BansheeEngine/Include/BsBuiltinResources.h

@@ -56,6 +56,13 @@ namespace BansheeEngine
 		static const CM::WString ButtonNormalTex;
 		static const CM::WString ButtonHoverTex;
 
+		static const CM::WString ToggleNormalTex;
+		static const CM::WString ToggleHoverTex;
+		static const CM::WString ToggleActiveTex;
+		static const CM::WString ToggleNormalOnTex;
+		static const CM::WString ToggleHoverOnTex;
+		static const CM::WString ToggleActiveOnTex;
+
 		static const CM::WString InputBoxNormalTex;
 		static const CM::WString InputBoxHoverTex;
 		static const CM::WString InputBoxFocusedTex;

+ 1 - 0
BansheeEngine/Include/BsGUIHelper.h

@@ -9,6 +9,7 @@ namespace BansheeEngine
 	class BS_EXPORT GUIHelper
 	{
 	public:
+		static CM::Vector2I calcOptimalContentsSize(const CM::Vector2I& contentSize, const GUIElementStyle& style, const GUILayoutOptions& layoutOptions);
 		static CM::Vector2I calcOptimalContentsSize(const GUIContent& content, const GUIElementStyle& style, const GUILayoutOptions& layoutOptions);
 		static CM::Vector2I calcOptimalContentsSize(const CM::WString& text, const GUIElementStyle& style, const GUILayoutOptions& layoutOptions);
 	};

+ 23 - 0
BansheeEngine/Source/BsBuiltinResources.cpp

@@ -4,6 +4,7 @@
 #include "BsGUILabel.h"
 #include "BsGUIButton.h"
 #include "BsGUIInputBox.h"
+#include "BsGUIToggle.h"
 #include "BsTextSprite.h"
 #include "BsSpriteTexture.h"
 
@@ -29,6 +30,13 @@ namespace BansheeEngine
 	const WString BuiltinResources::ButtonNormalTex = L"ButtonNormal.psd";
 	const WString BuiltinResources::ButtonHoverTex = L"ButtonHover.psd";
 
+	const WString BuiltinResources::ToggleNormalTex = L"ToggleNormal.psd";
+	const WString BuiltinResources::ToggleHoverTex = L"ToggleHover.psd";
+	const WString BuiltinResources::ToggleActiveTex = L"ToggleActive.psd";
+	const WString BuiltinResources::ToggleNormalOnTex = L"ToggleOnNormal.psd";
+	const WString BuiltinResources::ToggleHoverOnTex = L"ToggleOnHover.psd";
+	const WString BuiltinResources::ToggleActiveOnTex = L"ToggleOnActive.psd";
+
 	const WString BuiltinResources::InputBoxNormalTex = L"InputBoxNormal.psd";
 	const WString BuiltinResources::InputBoxHoverTex = L"InputBoxHover.psd";
 	const WString BuiltinResources::InputBoxFocusedTex = L"InputBoxFocused.psd";
@@ -210,6 +218,21 @@ namespace BansheeEngine
 
 		mSkin.setStyle(GUIButton::getGUITypeName(), buttonStyle);
 
+		// Toggle
+		GUIElementStyle toggleStyle;
+		toggleStyle.normal.texture = getSkinTexture(ToggleNormalTex);
+		toggleStyle.hover.texture = getSkinTexture(ToggleHoverTex);
+		toggleStyle.active.texture = getSkinTexture(ToggleActiveTex);
+		toggleStyle.normalOn.texture = getSkinTexture(ToggleNormalOnTex);
+		toggleStyle.hoverOn.texture = getSkinTexture(ToggleHoverOnTex);
+		toggleStyle.activeOn.texture = getSkinTexture(ToggleActiveOnTex);
+		toggleStyle.fixedHeight = true;
+		toggleStyle.fixedWidth = true;
+		toggleStyle.height = 15;
+		toggleStyle.width = 15;
+
+		mSkin.setStyle(GUIToggle::getGUITypeName(), toggleStyle);
+
 		// Input box
 		GUIElementStyle inputBoxStyle;
 		inputBoxStyle.normal.texture = getSkinTexture(InputBoxNormalTex);

+ 8 - 0
BansheeEngine/Source/BsGUIHelper.cpp

@@ -8,6 +8,14 @@ using namespace CamelotFramework;
 
 namespace BansheeEngine
 {
+	Vector2I GUIHelper::calcOptimalContentsSize(const Vector2I& contentSize, const GUIElementStyle& style, const GUILayoutOptions& layoutOptions)
+	{
+		UINT32 contentWidth = style.margins.left + style.margins.right + style.contentOffset.left + style.contentOffset.right;
+		UINT32 contentHeight = style.margins.top + style.margins.bottom + style.contentOffset.top + style.contentOffset.bottom;
+
+		return Vector2I(std::max((UINT32)contentSize.x, contentWidth), std::max((UINT32)contentSize.y, contentHeight));
+	}
+
 	Vector2I GUIHelper::calcOptimalContentsSize(const GUIContent& content, const GUIElementStyle& style, const GUILayoutOptions& layoutOptions)
 	{
 		Vector2I textContentBounds = calcOptimalContentsSize(content.getText(), style, layoutOptions);

+ 16 - 17
CamelotCore/Source/CmPass.cpp

@@ -9,21 +9,20 @@
 
 namespace CamelotFramework
 {
-    //-----------------------------------------------------------------------------
 	Pass::Pass()
 		:mStencilRefValue(0)
     { }
-    //-----------------------------------------------------------------------------
+
 	Pass::Pass(const Pass& oth)
     {
         *this = oth;
     }
-    //-----------------------------------------------------------------------------
+
     Pass::~Pass()
     {
 	
     }
-    //-----------------------------------------------------------------------------
+
     Pass& Pass::operator=(const Pass& oth)
     {
 	    // Default blending (overwrite)
@@ -41,7 +40,7 @@ namespace CamelotFramework
 
 		return *this;
     }
-    //-----------------------------------------------------------------------
+
     bool Pass::isTransparent(void) const
     {
 		bool transparent = false;
@@ -64,47 +63,47 @@ namespace CamelotFramework
 
 		return transparent;
     }
-	//----------------------------------------------------------------------
+
 	void Pass::setBlendState(HBlendState& blendState)
 	{
 		mBlendState = blendState;
 	}
-	//----------------------------------------------------------------------
+
 	HBlendState Pass::getBlendState() const
 	{
 		return mBlendState;
 	}
-	//----------------------------------------------------------------------
+
 	void Pass::setRasterizerState(HRasterizerState& rasterizerState)
 	{
 		mRasterizerState = rasterizerState;
 	}
-	//----------------------------------------------------------------------
+
 	HRasterizerState Pass::getRasterizerState() const
 	{
 		return mRasterizerState;
 	}
-	//-----------------------------------------------------------------------
+
 	void Pass::setDepthStencilState(HDepthStencilState& depthStencilState)
 	{
 		mDepthStencilState = depthStencilState;
 	}
-	//-----------------------------------------------------------------------
+
 	HDepthStencilState Pass::getDepthStencilState() const
 	{
 		return mDepthStencilState;
 	}
-	//----------------------------------------------------------------------
+
 	void Pass::setStencilRefValue(UINT32 refValue)
 	{
 		mStencilRefValue = refValue;
 	}
-	//----------------------------------------------------------------------
+
 	UINT32 Pass::getStencilRefValue() const
 	{
 		return mStencilRefValue;
 	}
-	//----------------------------------------------------------------------
+
 	void Pass::activate(CoreAccessor& coreAccessor) const
 	{
 		HGpuProgram vertProgram = getVertexProgram();
@@ -161,7 +160,7 @@ namespace CamelotFramework
 		else
 			coreAccessor.setRasterizerState(RasterizerState::getDefault());
 	}
-	//----------------------------------------------------------------------
+
 	void Pass::bindParameters(CoreAccessor& coreAccessor, const PassParametersPtr& params) const
 	{
 		HGpuProgram vertProgram = getVertexProgram();
@@ -188,12 +187,12 @@ namespace CamelotFramework
 		if(computeProgram)
 			coreAccessor.bindGpuParams(GPT_COMPUTE_PROGRAM, params->mComputeParams);
 	}
-	//----------------------------------------------------------------------
+
 	RTTITypeBase* Pass::getRTTIStatic()
 	{
 		return PassRTTI::instance();
 	}
-	//----------------------------------------------------------------------
+
 	RTTITypeBase* Pass::getRTTI() const
 	{
 		return Pass::getRTTIStatic();