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

Refactored editor fields so they internally use GUILayout

Marko Pintera 12 лет назад
Родитель
Сommit
7f79e1badb

+ 26 - 21
BansheeEditor/Include/BsGUIGameObjectField.h

@@ -12,43 +12,51 @@ namespace BansheeEditor
 	public:
 		static const CM::String& getGUITypeName();
 
-		static GUIGameObjectField* create(BS::GUIWidget& parent, const BS::GUIContent& labelContent, 
-			const BS::GUIOptions& layoutOptions, BS::GUIElementStyle* labelStyle = nullptr, BS::GUIElementStyle* dropButtonStyle = nullptr,
+		static GUIGameObjectField* create(BS::GUIWidget& parent, const BS::GUIContent& labelContent, CM::UINT32 labelWidth, const BS::GUIOptions& layoutOptions, 
+			BS::GUIElementStyle* labelStyle = nullptr, BS::GUIElementStyle* dropButtonStyle = nullptr,
 			BS::GUIElementStyle* clearButtonStyle = nullptr);
 
-		static GUIGameObjectField* create(BS::GUIWidget& parent, const CM::HString& labelText, 
-			const BS::GUIOptions& layoutOptions, BS::GUIElementStyle* labelStyle = nullptr, BS::GUIElementStyle* dropButtonStyle = nullptr,
+		static GUIGameObjectField* create(BS::GUIWidget& parent, const BS::GUIContent& labelContent, const BS::GUIOptions& layoutOptions, 
+			BS::GUIElementStyle* labelStyle = nullptr, BS::GUIElementStyle* dropButtonStyle = nullptr,
+			BS::GUIElementStyle* clearButtonStyle = nullptr);
+
+		static GUIGameObjectField* create(BS::GUIWidget& parent, const CM::HString& labelText, CM::UINT32 labelWidth, const BS::GUIOptions& layoutOptions, 
+			BS::GUIElementStyle* labelStyle = nullptr, BS::GUIElementStyle* dropButtonStyle = nullptr,
+			BS::GUIElementStyle* clearButtonStyle = nullptr);
+
+		static GUIGameObjectField* create(BS::GUIWidget& parent, const CM::HString& labelText, const BS::GUIOptions& layoutOptions, 
+			BS::GUIElementStyle* labelStyle = nullptr, BS::GUIElementStyle* dropButtonStyle = nullptr,
 			BS::GUIElementStyle* clearButtonStyle = nullptr);
 
-		static GUIGameObjectField* create(BS::GUIWidget& parent, 
-			const BS::GUIOptions& layoutOptions, BS::GUIElementStyle* labelStyle = nullptr, BS::GUIElementStyle* dropButtonStyle = nullptr,
+		static GUIGameObjectField* create(BS::GUIWidget& parent, const BS::GUIOptions& layoutOptions, BS::GUIElementStyle* dropButtonStyle = nullptr,
+			BS::GUIElementStyle* clearButtonStyle = nullptr);
+
+		static GUIGameObjectField* create(BS::GUIWidget& parent, const BS::GUIContent& labelContent, CM::UINT32 labelWidth, 
+			BS::GUIElementStyle* labelStyle = nullptr, BS::GUIElementStyle* dropButtonStyle = nullptr,
 			BS::GUIElementStyle* clearButtonStyle = nullptr);
 
 		static GUIGameObjectField* create(BS::GUIWidget& parent, const BS::GUIContent& labelContent, 
 			BS::GUIElementStyle* labelStyle = nullptr, BS::GUIElementStyle* dropButtonStyle = nullptr,
 			BS::GUIElementStyle* clearButtonStyle = nullptr);
 
-		static GUIGameObjectField* create(BS::GUIWidget& parent, const CM::HString& labelText, 
+		static GUIGameObjectField* create(BS::GUIWidget& parent, const CM::HString& labelText, CM::UINT32 labelWidth, 
 			BS::GUIElementStyle* labelStyle = nullptr, BS::GUIElementStyle* dropButtonStyle = nullptr,
 			BS::GUIElementStyle* clearButtonStyle = nullptr);
 
-		static GUIGameObjectField* create(BS::GUIWidget& parent, 
+		static GUIGameObjectField* create(BS::GUIWidget& parent, const CM::HString& labelText, 
 			BS::GUIElementStyle* labelStyle = nullptr, BS::GUIElementStyle* dropButtonStyle = nullptr,
 			BS::GUIElementStyle* clearButtonStyle = nullptr);
 
-		GUIGameObjectField(const PrivatelyConstruct& dummy, BS::GUIWidget& parent, const BS::GUIContent& labelContent, 
-			BS::GUIElementStyle* labelStyle, BS::GUIElementStyle* dropButtonStyle,
-			BS::GUIElementStyle* clearButtonStyle, const BS::GUILayoutOptions& layoutOptions);
+		static GUIGameObjectField* create(BS::GUIWidget& parent, BS::GUIElementStyle* dropButtonStyle = nullptr,
+			BS::GUIElementStyle* clearButtonStyle = nullptr);
 
-		GUIGameObjectField(const PrivatelyConstruct& dummy, BS::GUIWidget& parent, 
-			BS::GUIElementStyle* labelStyle, BS::GUIElementStyle* dropButtonStyle,
-			BS::GUIElementStyle* clearButtonStyle, const BS::GUILayoutOptions& layoutOptions);
+		GUIGameObjectField(const PrivatelyConstruct& dummy, BS::GUIWidget& parent, const BS::GUIContent& labelContent, 
+			CM::UINT32 labelWidth, BS::GUIElementStyle* labelStyle, BS::GUIElementStyle* dropButtonStyle,
+			BS::GUIElementStyle* clearButtonStyle, const BS::GUILayoutOptions& layoutOptions, bool withLabel);
 
 		CM::HGameObject getValue() const;
 		void setValue(const CM::HGameObject& 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);
 
@@ -56,14 +64,11 @@ namespace BansheeEditor
 	private:
 		virtual ~GUIGameObjectField();
 
-		void construct(BS::GUIWidget& parent, const BS::GUIContent& labelContent, 
-			BS::GUIElementStyle* labelStyle, BS::GUIElementStyle* dropButtonStyle,
-			BS::GUIElementStyle* clearButtonStyle, const BS::GUILayoutOptions& layoutOptions, bool withLabel);
-
 		void dataDropped(void* data);
 
 	private:
-		CM::UINT32 mLabelWidth;
+		static const CM::UINT32 DEFAULT_LABEL_WIDTH;
+
 		BS::GUILayout* mLayout;
 		BS::GUILabel* mLabel;
 		GUIDropButton* mDropButton;

+ 5 - 36
BansheeEditor/Include/BsGUIToggleField.h

@@ -1,56 +1,25 @@
 #pragma once
 
 #include "BsEditorPrerequisites.h"
-#include "BsGUIElementContainer.h"
+#include "BsGUIFieldBase.h"
 
 namespace BansheeEditor
 {
-	class BS_ED_EXPORT GUIToggleField : public BS::GUIElementContainer
+	class BS_ED_EXPORT GUIToggleField : public TGUIField<GUIToggleField>
 	{
-		struct PrivatelyConstruct {};
-
 	public:
 		static const CM::String& getGUITypeName();
 
-		static GUIToggleField* create(BS::GUIWidget& parent, const BS::GUIContent& labelContent, 
-			const BS::GUIOptions& layoutOptions, BS::GUIElementStyle* labelStyle = nullptr, BS::GUIElementStyle* toggleStyle = nullptr);
-
-		static GUIToggleField* create(BS::GUIWidget& parent, const CM::HString& labelText, 
-			const BS::GUIOptions& layoutOptions, BS::GUIElementStyle* labelStyle = nullptr, BS::GUIElementStyle* toggleStyle = nullptr);
-
-		static GUIToggleField* create(BS::GUIWidget& parent, 
-			const BS::GUIOptions& layoutOptions, BS::GUIElementStyle* labelStyle = nullptr, BS::GUIElementStyle* toggleStyle = nullptr);
-
-		static GUIToggleField* create(BS::GUIWidget& parent, const BS::GUIContent& labelContent, 
-			BS::GUIElementStyle* labelStyle = nullptr, BS::GUIElementStyle* toggleStyle = nullptr);
-
-		static GUIToggleField* create(BS::GUIWidget& parent, const CM::HString& labelText, 
-			BS::GUIElementStyle* labelStyle = nullptr, BS::GUIElementStyle* toggleStyle = nullptr);
-
-		static GUIToggleField* create(BS::GUIWidget& parent, 
-			BS::GUIElementStyle* labelStyle = nullptr, BS::GUIElementStyle* toggleStyle = nullptr);
-
-		GUIToggleField(const PrivatelyConstruct& dummy, BS::GUIWidget& parent, const BS::GUIContent& labelContent, 
-			BS::GUIElementStyle* labelStyle, BS::GUIElementStyle* toggleStyle, const BS::GUILayoutOptions& layoutOptions);
-
-		GUIToggleField(const PrivatelyConstruct& dummy, BS::GUIWidget& parent, 
-			BS::GUIElementStyle* labelStyle, BS::GUIElementStyle* toggleStyle, const BS::GUILayoutOptions& layoutOptions);
+		GUIToggleField(const PrivatelyConstruct& dummy, BS::GUIWidget& parent, const BS::GUIContent& labelContent, CM::UINT32 labelWidth,
+			BS::GUIElementStyle* labelStyle, BS::GUIElementStyle* toggleStyle, const BS::GUILayoutOptions& layoutOptions, bool withLabel);
 
 		bool getValue() const;
 		void setValue(bool 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 ~GUIToggleField();
+		virtual ~GUIToggleField() { }
 
 	protected:
-		CM::UINT32 mLabelWidth;
-		BS::GUILabel* mLabel;
 		BS::GUIToggle* mToggle;
 	};
 }

+ 5 - 36
BansheeEditor/Include/BsGUIVector2Field.h

@@ -1,60 +1,29 @@
 #pragma once
 
 #include "BsEditorPrerequisites.h"
-#include "BsGUIElementContainer.h"
+#include "BsGUIFieldBase.h"
 #include "CmVector2.h"
 
 namespace BansheeEditor
 {
-	class BS_ED_EXPORT GUIVector2Field : public BS::GUIElementContainer
+	class BS_ED_EXPORT GUIVector2Field : public TGUIField<GUIVector2Field>
 	{
-		struct PrivatelyConstruct {};
-
 	public:
 		static const CM::String& getGUITypeName();
 
-		static GUIVector2Field* create(BS::GUIWidget& parent, const BS::GUIContent& labelContent, 
-			const BS::GUIOptions& layoutOptions, BS::GUIElementStyle* labelStyle = nullptr, BS::GUIElementStyle* inputBoxStyle = nullptr);
-
-		static GUIVector2Field* create(BS::GUIWidget& parent, const CM::HString& labelText, 
-			const BS::GUIOptions& layoutOptions, BS::GUIElementStyle* labelStyle = nullptr, BS::GUIElementStyle* inputBoxStyle = nullptr);
-
-		static GUIVector2Field* create(BS::GUIWidget& parent, 
-			const BS::GUIOptions& layoutOptions, BS::GUIElementStyle* labelStyle = nullptr, BS::GUIElementStyle* inputBoxStyle = nullptr);
-
-		static GUIVector2Field* create(BS::GUIWidget& parent, const BS::GUIContent& labelContent, 
-			BS::GUIElementStyle* labelStyle = nullptr, BS::GUIElementStyle* inputBoxStyle = nullptr);
-
-		static GUIVector2Field* create(BS::GUIWidget& parent, const CM::HString& labelText, 
-			BS::GUIElementStyle* labelStyle = nullptr, BS::GUIElementStyle* inputBoxStyle = nullptr);
-
-		static GUIVector2Field* create(BS::GUIWidget& parent, 
-			BS::GUIElementStyle* labelStyle = nullptr, BS::GUIElementStyle* inputBoxStyle = nullptr);
-
-		GUIVector2Field(const PrivatelyConstruct& dummy, BS::GUIWidget& parent, const BS::GUIContent& labelContent, 
-			BS::GUIElementStyle* labelStyle, BS::GUIElementStyle* inputBoxStyle, const BS::GUILayoutOptions& layoutOptions);
-
-		GUIVector2Field(const PrivatelyConstruct& dummy, BS::GUIWidget& parent, 
-			BS::GUIElementStyle* labelStyle, BS::GUIElementStyle* inputBoxStyle, const BS::GUILayoutOptions& layoutOptions);
+		GUIVector2Field(const PrivatelyConstruct& dummy, BS::GUIWidget& parent, const BS::GUIContent& labelContent, CM::UINT32 labelWidth,
+			BS::GUIElementStyle* labelStyle, BS::GUIElementStyle* inputBoxStyle, const BS::GUILayoutOptions& layoutOptions, bool withLabel);
 
 		CM::Vector2 getValue() const;
 		void setValue(const CM::Vector2& value);
 
-		CM::Vector2I _getOptimalSize() const;
 	protected:
-		virtual ~GUIVector2Field();
-
-		void _updateLayoutInternal(CM::INT32 x, CM::INT32 y, CM::UINT32 width, CM::UINT32 height,
-			CM::RectI clipRect, CM::UINT8 widgetDepth, CM::UINT16 areaDepth);
+		virtual ~GUIVector2Field() { }
 
 	protected:
 		static const CM::UINT32 ELEMENT_LABEL_WIDTH;
 
-		BS::GUILabel* mLabel;
 		GUIFloatField* mFieldX;
 		GUIFloatField* mFieldY;
-
-		void construct(BS::GUIWidget& parent, const BS::GUIContent& labelContent, BS::GUIElementStyle* labelStyle, 
-			BS::GUIElementStyle* inputBoxStyle, const BS::GUILayoutOptions& layoutOptions, bool withLabel);
 	};
 }

+ 5 - 36
BansheeEditor/Include/BsGUIVector3Field.h

@@ -1,61 +1,30 @@
 #pragma once
 
 #include "BsEditorPrerequisites.h"
-#include "BsGUIElementContainer.h"
+#include "BsGUIFieldBase.h"
 #include "CmVector3.h"
 
 namespace BansheeEditor
 {
-	class BS_ED_EXPORT GUIVector3Field : public BS::GUIElementContainer
+	class BS_ED_EXPORT GUIVector3Field : public TGUIField<GUIVector3Field>
 	{
-		struct PrivatelyConstruct {};
-
 	public:
 		static const CM::String& getGUITypeName();
 
-		static GUIVector3Field* create(BS::GUIWidget& parent, const BS::GUIContent& labelContent, 
-			const BS::GUIOptions& layoutOptions, BS::GUIElementStyle* labelStyle = nullptr, BS::GUIElementStyle* inputBoxStyle = nullptr);
-
-		static GUIVector3Field* create(BS::GUIWidget& parent, const CM::HString& labelText, 
-			const BS::GUIOptions& layoutOptions, BS::GUIElementStyle* labelStyle = nullptr, BS::GUIElementStyle* inputBoxStyle = nullptr);
-
-		static GUIVector3Field* create(BS::GUIWidget& parent, 
-			const BS::GUIOptions& layoutOptions, BS::GUIElementStyle* labelStyle = nullptr, BS::GUIElementStyle* inputBoxStyle = nullptr);
-
-		static GUIVector3Field* create(BS::GUIWidget& parent, const BS::GUIContent& labelContent, 
-			BS::GUIElementStyle* labelStyle = nullptr, BS::GUIElementStyle* inputBoxStyle = nullptr);
-
-		static GUIVector3Field* create(BS::GUIWidget& parent, const CM::HString& labelText, 
-			BS::GUIElementStyle* labelStyle = nullptr, BS::GUIElementStyle* inputBoxStyle = nullptr);
-
-		static GUIVector3Field* create(BS::GUIWidget& parent, 
-			BS::GUIElementStyle* labelStyle = nullptr, BS::GUIElementStyle* inputBoxStyle = nullptr);
-
-		GUIVector3Field(const PrivatelyConstruct& dummy, BS::GUIWidget& parent, const BS::GUIContent& labelContent, 
-			BS::GUIElementStyle* labelStyle, BS::GUIElementStyle* inputBoxStyle, const BS::GUILayoutOptions& layoutOptions);
-
-		GUIVector3Field(const PrivatelyConstruct& dummy, BS::GUIWidget& parent, 
-			BS::GUIElementStyle* labelStyle, BS::GUIElementStyle* inputBoxStyle, const BS::GUILayoutOptions& layoutOptions);
+		GUIVector3Field(const PrivatelyConstruct& dummy, BS::GUIWidget& parent, const BS::GUIContent& labelContent, CM::UINT32 labelWidth,
+			BS::GUIElementStyle* labelStyle, BS::GUIElementStyle* inputBoxStyle, const BS::GUILayoutOptions& layoutOptions, bool withLabel);
 
 		CM::Vector3 getValue() const;
 		void setValue(const CM::Vector3& value);
 
-		CM::Vector2I _getOptimalSize() const;
 	protected:
-		virtual ~GUIVector3Field();
-
-		void _updateLayoutInternal(CM::INT32 x, CM::INT32 y, CM::UINT32 width, CM::UINT32 height,
-			CM::RectI clipRect, CM::UINT8 widgetDepth, CM::UINT16 areaDepth);
+		virtual ~GUIVector3Field() { }
 
 	protected:
 		static const CM::UINT32 ELEMENT_LABEL_WIDTH;
 
-		BS::GUILabel* mLabel;
 		GUIFloatField* mFieldX;
 		GUIFloatField* mFieldY;
 		GUIFloatField* mFieldZ;
-
-		void construct(BS::GUIWidget& parent, const BS::GUIContent& labelContent, BS::GUIElementStyle* labelStyle, 
-			BS::GUIElementStyle* inputBoxStyle, const BS::GUILayoutOptions& layoutOptions, bool withLabel);
 	};
 }

+ 5 - 36
BansheeEditor/Include/BsGUIVector4Field.h

@@ -1,62 +1,31 @@
 #pragma once
 
 #include "BsEditorPrerequisites.h"
-#include "BsGUIElementContainer.h"
+#include "BsGUIFieldBase.h"
 #include "CmVector4.h"
 
 namespace BansheeEditor
 {
-	class BS_ED_EXPORT GUIVector4Field : public BS::GUIElementContainer
+	class BS_ED_EXPORT GUIVector4Field : public TGUIField<GUIVector4Field>
 	{
-		struct PrivatelyConstruct {};
-
 	public:
 		static const CM::String& getGUITypeName();
 
-		static GUIVector4Field* create(BS::GUIWidget& parent, const BS::GUIContent& labelContent, 
-			const BS::GUIOptions& layoutOptions, BS::GUIElementStyle* labelStyle = nullptr, BS::GUIElementStyle* inputBoxStyle = nullptr);
-
-		static GUIVector4Field* create(BS::GUIWidget& parent, const CM::HString& labelText, 
-			const BS::GUIOptions& layoutOptions, BS::GUIElementStyle* labelStyle = nullptr, BS::GUIElementStyle* inputBoxStyle = nullptr);
-
-		static GUIVector4Field* create(BS::GUIWidget& parent, 
-			const BS::GUIOptions& layoutOptions, BS::GUIElementStyle* labelStyle = nullptr, BS::GUIElementStyle* inputBoxStyle = nullptr);
-
-		static GUIVector4Field* create(BS::GUIWidget& parent, const BS::GUIContent& labelContent, 
-			BS::GUIElementStyle* labelStyle = nullptr, BS::GUIElementStyle* inputBoxStyle = nullptr);
-
-		static GUIVector4Field* create(BS::GUIWidget& parent, const CM::HString& labelText, 
-			BS::GUIElementStyle* labelStyle = nullptr, BS::GUIElementStyle* inputBoxStyle = nullptr);
-
-		static GUIVector4Field* create(BS::GUIWidget& parent, 
-			BS::GUIElementStyle* labelStyle = nullptr, BS::GUIElementStyle* inputBoxStyle = nullptr);
-
-		GUIVector4Field(const PrivatelyConstruct& dummy, BS::GUIWidget& parent, const BS::GUIContent& labelContent, 
-			BS::GUIElementStyle* labelStyle, BS::GUIElementStyle* inputBoxStyle, const BS::GUILayoutOptions& layoutOptions);
-
-		GUIVector4Field(const PrivatelyConstruct& dummy, BS::GUIWidget& parent, 
-			BS::GUIElementStyle* labelStyle, BS::GUIElementStyle* inputBoxStyle, const BS::GUILayoutOptions& layoutOptions);
+		GUIVector4Field(const PrivatelyConstruct& dummy, BS::GUIWidget& parent, const BS::GUIContent& labelContent, CM::UINT32 labelWidth,
+			BS::GUIElementStyle* labelStyle, BS::GUIElementStyle* inputBoxStyle, const BS::GUILayoutOptions& layoutOptions, bool withLabel);
 
 		CM::Vector4 getValue() const;
 		void setValue(const CM::Vector4& value);
 
-		CM::Vector2I _getOptimalSize() const;
 	protected:
-		virtual ~GUIVector4Field();
-
-		void _updateLayoutInternal(CM::INT32 x, CM::INT32 y, CM::UINT32 width, CM::UINT32 height,
-			CM::RectI clipRect, CM::UINT8 widgetDepth, CM::UINT16 areaDepth);
+		virtual ~GUIVector4Field() { }
 
 	protected:
 		static const CM::UINT32 ELEMENT_LABEL_WIDTH;
 
-		BS::GUILabel* mLabel;
 		GUIFloatField* mFieldX;
 		GUIFloatField* mFieldY;
 		GUIFloatField* mFieldZ;
 		GUIFloatField* mFieldW;
-
-		void construct(BS::GUIWidget& parent, const BS::GUIContent& labelContent, BS::GUIElementStyle* labelStyle, 
-			BS::GUIElementStyle* inputBoxStyle, const BS::GUILayoutOptions& layoutOptions, bool withLabel);
 	};
 }

+ 61 - 56
BansheeEditor/Source/BsGUIGameObjectField.cpp

@@ -16,28 +16,11 @@ using namespace BansheeEngine;
 
 namespace BansheeEditor
 {
-	GUIGameObjectField::GUIGameObjectField(const PrivatelyConstruct& dummy, GUIWidget& parent, const GUIContent& labelContent, 
-		GUIElementStyle* labelStyle, GUIElementStyle* dropButtonStyle, GUIElementStyle* clearButtonStyle, const GUILayoutOptions& layoutOptions)
-		:GUIElementContainer(parent, layoutOptions), mLabel(nullptr), mClearButton(nullptr), mDropButton(nullptr), mLabelWidth(100), mInstanceId(0)
-	{
-		construct(parent, labelContent, labelStyle, dropButtonStyle, clearButtonStyle, layoutOptions, true);
-	}
+	const UINT32 GUIGameObjectField::DEFAULT_LABEL_WIDTH = 100;
 
-	GUIGameObjectField::GUIGameObjectField(const PrivatelyConstruct& dummy, GUIWidget& parent, 
-		GUIElementStyle* labelStyle, GUIElementStyle* dropButtonStyle, GUIElementStyle* clearButtonStyle, const GUILayoutOptions& layoutOptions)
-		:GUIElementContainer(parent, layoutOptions), mLabel(nullptr), mClearButton(nullptr), mDropButton(nullptr), mLabelWidth(100), mInstanceId(0)
-	{
-		construct(parent, GUIContent(), labelStyle, dropButtonStyle, clearButtonStyle, layoutOptions, false);
-	}
-
-	GUIGameObjectField::~GUIGameObjectField()
-	{
-
-	}
-
-	void GUIGameObjectField::construct(GUIWidget& parent, const GUIContent& labelContent, 
-		GUIElementStyle* labelStyle, GUIElementStyle* dropButtonStyle,
-		GUIElementStyle* clearButtonStyle, const GUILayoutOptions& layoutOptions, bool withLabel)
+	GUIGameObjectField::GUIGameObjectField(const PrivatelyConstruct& dummy, GUIWidget& parent, const GUIContent& labelContent, CM::UINT32 labelWidth,
+		GUIElementStyle* labelStyle, GUIElementStyle* dropButtonStyle, GUIElementStyle* clearButtonStyle, const GUILayoutOptions& layoutOptions, bool withLabel)
+		:GUIElementContainer(parent, layoutOptions), mLabel(nullptr), mClearButton(nullptr), mDropButton(nullptr), mInstanceId(0)
 	{
 		mLayout = &addLayoutXInternal(this);
 
@@ -48,7 +31,7 @@ namespace BansheeEditor
 			if(curLabelStyle == nullptr)
 				curLabelStyle = parent.getSkin().getStyle("Label");
 
-			mLabel = GUILabel::create(parent, labelContent, GUIOptions(GUIOption::fixedWidth(mLabelWidth)), curLabelStyle);
+			mLabel = GUILabel::create(parent, labelContent, GUIOptions(GUIOption::fixedWidth(labelWidth)), curLabelStyle);
 			mLayout->addElement(mLabel);
 		}
 
@@ -70,46 +53,78 @@ namespace BansheeEditor
 		mDropButton->onDataDropped.connect(boost::bind(&GUIGameObjectField::dataDropped, this, _1));
 	}
 
-	GUIGameObjectField* GUIGameObjectField::create(GUIWidget& parent, const GUIContent& labelContent, const GUIOptions& layoutOptions, 
-		GUIElementStyle* labelStyle, GUIElementStyle* dropButtonStyle, GUIElementStyle* clearButtonStyle)
+	GUIGameObjectField::~GUIGameObjectField()
+	{
+
+	}
+
+	GUIGameObjectField* GUIGameObjectField::create(BS::GUIWidget& parent, const BS::GUIContent& labelContent, CM::UINT32 labelWidth, const BS::GUIOptions& layoutOptions, 
+		BS::GUIElementStyle* labelStyle, BS::GUIElementStyle* dropButtonStyle, BS::GUIElementStyle* clearButtonStyle)
 	{
-		return cm_new<GUIGameObjectField>(PrivatelyConstruct(), parent, labelContent, labelStyle, dropButtonStyle, clearButtonStyle,
-			GUILayoutOptions::create(layoutOptions, &GUISkin::DefaultStyle));
+		return cm_new<GUIGameObjectField>(PrivatelyConstruct(), parent, labelContent, labelWidth, labelStyle, dropButtonStyle, clearButtonStyle,
+			GUILayoutOptions::create(layoutOptions, &GUISkin::DefaultStyle), true);
 	}
 
-	GUIGameObjectField* GUIGameObjectField::create(GUIWidget& parent, const GUIContent& labelContent, GUIElementStyle* labelStyle, 
-		GUIElementStyle* dropButtonStyle, GUIElementStyle* clearButtonStyle)
+	GUIGameObjectField* GUIGameObjectField::create(BS::GUIWidget& parent, const BS::GUIContent& labelContent, const BS::GUIOptions& layoutOptions, 
+		BS::GUIElementStyle* labelStyle, BS::GUIElementStyle* dropButtonStyle, BS::GUIElementStyle* clearButtonStyle)
 	{
-		return cm_new<GUIGameObjectField>(PrivatelyConstruct(), parent, labelContent, labelStyle, dropButtonStyle, clearButtonStyle,
-			GUILayoutOptions::create(&GUISkin::DefaultStyle));
+		return cm_new<GUIGameObjectField>(PrivatelyConstruct(), parent, labelContent, DEFAULT_LABEL_WIDTH, labelStyle, dropButtonStyle, clearButtonStyle,
+			GUILayoutOptions::create(layoutOptions, &GUISkin::DefaultStyle), true);
 	}
 
-	GUIGameObjectField* GUIGameObjectField::create(GUIWidget& parent, const HString& labelContent, const GUIOptions& layoutOptions, 
-		GUIElementStyle* labelStyle, GUIElementStyle* dropButtonStyle, GUIElementStyle* clearButtonStyle)
+	GUIGameObjectField* GUIGameObjectField::create(BS::GUIWidget& parent, const CM::HString& labelText, CM::UINT32 labelWidth, const BS::GUIOptions& layoutOptions, 
+		BS::GUIElementStyle* labelStyle, BS::GUIElementStyle* dropButtonStyle, BS::GUIElementStyle* clearButtonStyle)
 	{
-		return cm_new<GUIGameObjectField>(PrivatelyConstruct(), parent, GUIContent(labelContent), labelStyle, 
-			dropButtonStyle, clearButtonStyle, GUILayoutOptions::create(layoutOptions, &GUISkin::DefaultStyle));
+		return cm_new<GUIGameObjectField>(PrivatelyConstruct(), parent, BS::GUIContent(labelText), labelWidth, labelStyle, dropButtonStyle, clearButtonStyle,
+			GUILayoutOptions::create(layoutOptions, &GUISkin::DefaultStyle), true);
 	}
 
-	GUIGameObjectField* GUIGameObjectField::create(GUIWidget& parent, const HString& labelContent, GUIElementStyle* labelStyle, 
-		GUIElementStyle* dropButtonStyle, GUIElementStyle* clearButtonStyle)
+	GUIGameObjectField* GUIGameObjectField::create(BS::GUIWidget& parent, const CM::HString& labelText, const BS::GUIOptions& layoutOptions, 
+		BS::GUIElementStyle* labelStyle, BS::GUIElementStyle* dropButtonStyle, BS::GUIElementStyle* clearButtonStyle)
 	{
-		return cm_new<GUIGameObjectField>(PrivatelyConstruct(), parent, GUIContent(labelContent), labelStyle, dropButtonStyle, 
-			clearButtonStyle, GUILayoutOptions::create(&GUISkin::DefaultStyle));
+		return cm_new<GUIGameObjectField>(PrivatelyConstruct(), parent, BS::GUIContent(labelText), DEFAULT_LABEL_WIDTH, labelStyle, dropButtonStyle, clearButtonStyle, 
+			GUILayoutOptions::create(layoutOptions, &GUISkin::DefaultStyle), true);
 	}
 
-	GUIGameObjectField* GUIGameObjectField::create(GUIWidget& parent, const GUIOptions& layoutOptions, GUIElementStyle* labelStyle, 
-		GUIElementStyle* dropButtonStyle, GUIElementStyle* clearButtonStyle)
+	GUIGameObjectField* GUIGameObjectField::create(BS::GUIWidget& parent, const BS::GUIOptions& layoutOptions, BS::GUIElementStyle* dropButtonStyle,
+		BS::GUIElementStyle* clearButtonStyle)
 	{
-		return cm_new<GUIGameObjectField>(PrivatelyConstruct(), parent, labelStyle, dropButtonStyle, clearButtonStyle, 
-			GUILayoutOptions::create(layoutOptions, &GUISkin::DefaultStyle));
+		return cm_new<GUIGameObjectField>(PrivatelyConstruct(), parent, BS::GUIContent(), 0, nullptr, dropButtonStyle, clearButtonStyle,
+			GUILayoutOptions::create(layoutOptions, &GUISkin::DefaultStyle), false);
 	}
 
-	GUIGameObjectField* GUIGameObjectField::create(GUIWidget& parent, GUIElementStyle* labelStyle, GUIElementStyle* dropButtonStyle, 
-		GUIElementStyle* clearButtonStyle)
+	GUIGameObjectField* GUIGameObjectField::create(BS::GUIWidget& parent, const BS::GUIContent& labelContent, CM::UINT32 labelWidth, 
+		BS::GUIElementStyle* labelStyle, BS::GUIElementStyle* dropButtonStyle, BS::GUIElementStyle* clearButtonStyle)
 	{
-		return cm_new<GUIGameObjectField>(PrivatelyConstruct(), parent, labelStyle, dropButtonStyle, clearButtonStyle, 
-			GUILayoutOptions::create(&GUISkin::DefaultStyle));
+		return cm_new<GUIGameObjectField>(PrivatelyConstruct(), parent, labelContent, labelWidth, labelStyle, dropButtonStyle, clearButtonStyle,
+			GUILayoutOptions::create(&GUISkin::DefaultStyle), true);
+	}
+
+	GUIGameObjectField* GUIGameObjectField::create(BS::GUIWidget& parent, const BS::GUIContent& labelContent, 
+		BS::GUIElementStyle* labelStyle, BS::GUIElementStyle* dropButtonStyle, BS::GUIElementStyle* clearButtonStyle)
+	{
+		return cm_new<GUIGameObjectField>(PrivatelyConstruct(), parent, labelContent, DEFAULT_LABEL_WIDTH, labelStyle, dropButtonStyle, clearButtonStyle,
+			GUILayoutOptions::create(&GUISkin::DefaultStyle), true);
+	}
+
+	GUIGameObjectField* GUIGameObjectField::create(BS::GUIWidget& parent, const CM::HString& labelText, CM::UINT32 labelWidth, 
+		BS::GUIElementStyle* labelStyle, BS::GUIElementStyle* dropButtonStyle, BS::GUIElementStyle* clearButtonStyle)
+	{
+		return cm_new<GUIGameObjectField>(PrivatelyConstruct(), parent, BS::GUIContent(labelText), labelWidth, labelStyle, dropButtonStyle, clearButtonStyle,
+			GUILayoutOptions::create(&GUISkin::DefaultStyle), true);
+	}
+
+	GUIGameObjectField* GUIGameObjectField::create(BS::GUIWidget& parent, const CM::HString& labelText, 
+		BS::GUIElementStyle* labelStyle, BS::GUIElementStyle* dropButtonStyle, BS::GUIElementStyle* clearButtonStyle)
+	{
+		return cm_new<GUIGameObjectField>(PrivatelyConstruct(), parent, BS::GUIContent(labelText), DEFAULT_LABEL_WIDTH, labelStyle, dropButtonStyle, clearButtonStyle, 
+			GUILayoutOptions::create(&GUISkin::DefaultStyle), true);
+	}
+
+	GUIGameObjectField* GUIGameObjectField::create(BS::GUIWidget& parent, BS::GUIElementStyle* dropButtonStyle, BS::GUIElementStyle* clearButtonStyle)
+	{
+		return cm_new<GUIGameObjectField>(PrivatelyConstruct(), parent, BS::GUIContent(), 0, nullptr, dropButtonStyle, clearButtonStyle,
+			GUILayoutOptions::create(&GUISkin::DefaultStyle), false);
 	}
 
 	CM::HGameObject GUIGameObjectField::getValue() const
@@ -136,16 +151,6 @@ namespace BansheeEditor
 		}		
 	}
 
-	void GUIGameObjectField::setLabelWidth(UINT32 width)
-	{
-		mLabelWidth = width;
-
-		if(mLabel != nullptr)
-		{
-			//mLabel->
-		}
-	}
-
 	void GUIGameObjectField::_updateLayoutInternal(INT32 x, INT32 y, UINT32 width, UINT32 height,
 		RectI clipRect, UINT8 widgetDepth, UINT16 areaDepth)
 	{

+ 3 - 130
BansheeEditor/Source/BsGUIToggleField.cpp

@@ -14,28 +14,8 @@ using namespace BansheeEngine;
 namespace BansheeEditor
 {
 	GUIToggleField::GUIToggleField(const PrivatelyConstruct& dummy, GUIWidget& parent, const GUIContent& labelContent, 
-		GUIElementStyle* labelStyle, GUIElementStyle* toggleStyle, const GUILayoutOptions& layoutOptions)
-		:GUIElementContainer(parent, layoutOptions), mLabel(nullptr), mToggle(nullptr), mLabelWidth(100)
-	{
-		const GUIElementStyle* curLabelStyle = labelStyle;
-		const GUIElementStyle* curToggleStyle = toggleStyle;
-
-		if(curLabelStyle == nullptr)
-			curLabelStyle = parent.getSkin().getStyle("Label");
-
-		if(curToggleStyle == nullptr)
-			curToggleStyle = parent.getSkin().getStyle("Toggle");
-
-		mLabel = GUILabel::create(parent, labelContent, curLabelStyle);
-		mToggle = GUIToggle::create(parent, HString(L""), curToggleStyle);
-
-		_registerChildElement(mLabel);
-		_registerChildElement(mToggle);
-	}
-
-	GUIToggleField::GUIToggleField(const PrivatelyConstruct& dummy, GUIWidget& parent, 
-		GUIElementStyle* labelStyle, GUIElementStyle* toggleStyle, const GUILayoutOptions& layoutOptions)
-		:GUIElementContainer(parent, layoutOptions), mLabel(nullptr), mToggle(nullptr), mLabelWidth(100)
+		UINT32 labelWidth, GUIElementStyle* labelStyle, GUIElementStyle* toggleStyle, const GUILayoutOptions& layoutOptions, bool withLabel)
+		:TGUIField(dummy, parent, labelContent, labelWidth, labelStyle, layoutOptions, withLabel), mToggle(nullptr)
 	{
 		const GUIElementStyle* curToggleStyle = toggleStyle;
 
@@ -43,53 +23,7 @@ namespace BansheeEditor
 			curToggleStyle = parent.getSkin().getStyle("Toggle");
 
 		mToggle = GUIToggle::create(parent, HString(L""), curToggleStyle);
-
-		_registerChildElement(mToggle);
-	}
-
-	GUIToggleField::~GUIToggleField()
-	{
-
-	}
-
-	GUIToggleField* GUIToggleField::create(GUIWidget& parent, const GUIContent& labelContent, const GUIOptions& layoutOptions, 
-		GUIElementStyle* labelStyle, GUIElementStyle* toggleStyle)
-	{
-		return cm_new<GUIToggleField>(PrivatelyConstruct(), parent, labelContent, labelStyle, toggleStyle, 
-			GUILayoutOptions::create(layoutOptions, &GUISkin::DefaultStyle));
-	}
-
-	GUIToggleField* GUIToggleField::create(GUIWidget& parent, const GUIContent& labelContent, GUIElementStyle* labelStyle, 
-		GUIElementStyle* toggleStyle)
-	{
-		return cm_new<GUIToggleField>(PrivatelyConstruct(), parent, labelContent, labelStyle, toggleStyle, 
-			GUILayoutOptions::create(&GUISkin::DefaultStyle));
-	}
-
-	GUIToggleField* GUIToggleField::create(GUIWidget& parent, const HString& labelContent, const GUIOptions& layoutOptions, 
-		GUIElementStyle* labelStyle, GUIElementStyle* toggleStyle)
-	{
-		return cm_new<GUIToggleField>(PrivatelyConstruct(), parent, GUIContent(labelContent), labelStyle, 
-			toggleStyle, GUILayoutOptions::create(layoutOptions, &GUISkin::DefaultStyle));
-	}
-
-	GUIToggleField* GUIToggleField::create(GUIWidget& parent, const HString& labelContent, GUIElementStyle* labelStyle, 
-		GUIElementStyle* toggleStyle)
-	{
-		return cm_new<GUIToggleField>(PrivatelyConstruct(), parent, GUIContent(labelContent), labelStyle, toggleStyle, 
-			GUILayoutOptions::create(&GUISkin::DefaultStyle));
-	}
-
-	GUIToggleField* GUIToggleField::create(GUIWidget& parent, const GUIOptions& layoutOptions, GUIElementStyle* labelStyle, 
-		GUIElementStyle* toggleStyle)
-	{
-		return cm_new<GUIToggleField>(PrivatelyConstruct(), parent, labelStyle, toggleStyle, 
-			GUILayoutOptions::create(layoutOptions, &GUISkin::DefaultStyle));
-	}
-
-	GUIToggleField* GUIToggleField::create(GUIWidget& parent, GUIElementStyle* labelStyle, GUIElementStyle* toggleStyle)
-	{
-		return cm_new<GUIToggleField>(PrivatelyConstruct(), parent, labelStyle, toggleStyle, GUILayoutOptions::create(&GUISkin::DefaultStyle));
+		mLayout->addElement(mToggle);
 	}
 
 	bool GUIToggleField::getValue() const
@@ -105,67 +39,6 @@ namespace BansheeEditor
 			mToggle->toggleOff();
 	}
 
-	void GUIToggleField::setLabelWidth(UINT32 width)
-	{
-		mLabelWidth = width;
-
-		markContentAsDirty();
-	}
-
-	void GUIToggleField::_updateLayoutInternal(INT32 x, INT32 y, UINT32 width, UINT32 height,
-		RectI clipRect, UINT8 widgetDepth, UINT16 areaDepth)
-	{
-		UINT32 toggleOffset = 0;
-
-		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);
-
-			toggleOffset = labelWidth;
-		}
-
-		{
-			Vector2I optimalSize = mToggle->_getOptimalSize();
-			INT32 yOffset = Math::roundToInt((height - optimalSize.y) * 0.5f);
-
-			Vector2I offset(x + toggleOffset, y + yOffset);
-			mToggle->_setOffset(offset);
-			mToggle->_setWidth(optimalSize.x);
-			mToggle->_setHeight(optimalSize.y);
-			mToggle->_setAreaDepth(areaDepth);
-			mToggle->_setWidgetDepth(widgetDepth);
-
-			RectI elemClipRect(clipRect.x - offset.x, clipRect.y - offset.y, clipRect.width, clipRect.height);
-			mToggle->_setClipRect(elemClipRect);
-		}
-	}
-
-	Vector2I GUIToggleField::_getOptimalSize() const
-	{
-		Vector2I optimalsize = mToggle->_getOptimalSize();
-
-		if(mLabel != nullptr)
-		{
-			optimalsize.x += mLabel->_getOptimalSize().x;
-			optimalsize.y = std::max(optimalsize.y, mLabel->_getOptimalSize().y);
-		}
-
-		return optimalsize;
-	}
-
 	const String& GUIToggleField::getGUITypeName()
 	{
 		static String typeName = "GUIToggleField";

+ 10 - 144
BansheeEditor/Source/BsGUIVector2Field.cpp

@@ -16,83 +16,21 @@ namespace BansheeEditor
 	const UINT32 GUIVector2Field::ELEMENT_LABEL_WIDTH = 10;
 
 	GUIVector2Field::GUIVector2Field(const PrivatelyConstruct& dummy, GUIWidget& parent, const GUIContent& labelContent, 
-		GUIElementStyle* labelStyle, GUIElementStyle* inputBoxStyle, const GUILayoutOptions& layoutOptions)
-		:GUIElementContainer(parent, layoutOptions), mLabel(nullptr), mFieldX(nullptr), mFieldY(nullptr)
+		CM::UINT32 labelWidth, GUIElementStyle* labelStyle, GUIElementStyle* inputBoxStyle, const GUILayoutOptions& layoutOptions, bool withLabel)
+		:TGUIField(dummy, parent, labelContent, labelWidth, labelStyle, layoutOptions, withLabel), mFieldX(nullptr), mFieldY(nullptr)
 	{
-		construct(parent, labelContent, labelStyle, inputBoxStyle, layoutOptions, true);
-	}
-
-	GUIVector2Field::GUIVector2Field(const PrivatelyConstruct& dummy, GUIWidget& parent, 
-		GUIElementStyle* labelStyle, GUIElementStyle* inputBoxStyle, const GUILayoutOptions& layoutOptions)
-		:GUIElementContainer(parent, layoutOptions), mLabel(nullptr), mFieldX(nullptr), mFieldY(nullptr)
-	{
-		construct(parent, GUIContent(HString()), labelStyle, inputBoxStyle, layoutOptions, false);
-	}
-
-	GUIVector2Field::~GUIVector2Field()
-	{
-
-	}
-
-	GUIVector2Field* GUIVector2Field::create(GUIWidget& parent, const GUIContent& labelContent, const GUIOptions& layoutOptions, 
-		GUIElementStyle* labelStyle, GUIElementStyle* inputBoxStyle)
-	{
-		return cm_new<GUIVector2Field>(PrivatelyConstruct(), parent, labelContent, labelStyle, inputBoxStyle, 
-			GUILayoutOptions::create(layoutOptions, &GUISkin::DefaultStyle));
-	}
-
-	GUIVector2Field* GUIVector2Field::create(GUIWidget& parent, const GUIContent& labelContent, GUIElementStyle* labelStyle, 
-		GUIElementStyle* inputBoxStyle)
-	{
-		return cm_new<GUIVector2Field>(PrivatelyConstruct(), parent, labelContent, labelStyle, inputBoxStyle, 
-			GUILayoutOptions::create(&GUISkin::DefaultStyle));
-	}
-
-	GUIVector2Field* GUIVector2Field::create(GUIWidget& parent, const HString& labelContent, const GUIOptions& layoutOptions, 
-		GUIElementStyle* labelStyle, GUIElementStyle* inputBoxStyle)
-	{
-		return cm_new<GUIVector2Field>(PrivatelyConstruct(), parent, GUIContent(labelContent), labelStyle, 
-			inputBoxStyle, GUILayoutOptions::create(layoutOptions, &GUISkin::DefaultStyle));
-	}
-
-	GUIVector2Field* GUIVector2Field::create(GUIWidget& parent, const HString& labelContent, GUIElementStyle* labelStyle, 
-		GUIElementStyle* inputBoxStyle)
-	{
-		return cm_new<GUIVector2Field>(PrivatelyConstruct(), parent, GUIContent(labelContent), labelStyle, inputBoxStyle, 
-			GUILayoutOptions::create(&GUISkin::DefaultStyle));
-	}
-
-	GUIVector2Field* GUIVector2Field::create(GUIWidget& parent, const GUIOptions& layoutOptions, GUIElementStyle* labelStyle, 
-		GUIElementStyle* inputBoxStyle)
-	{
-		return cm_new<GUIVector2Field>(PrivatelyConstruct(), parent, labelStyle, inputBoxStyle, 
-			GUILayoutOptions::create(layoutOptions, &GUISkin::DefaultStyle));
-	}
-
-	GUIVector2Field* GUIVector2Field::create(GUIWidget& parent, GUIElementStyle* labelStyle, GUIElementStyle* inputBoxStyle)
-	{
-		return cm_new<GUIVector2Field>(PrivatelyConstruct(), parent, labelStyle, inputBoxStyle, GUILayoutOptions::create(&GUISkin::DefaultStyle));
-	}
+		mFieldX = GUIFloatField::create(parent, HString(L"X"), ELEMENT_LABEL_WIDTH, labelStyle, inputBoxStyle);
+		mFieldY = GUIFloatField::create(parent, HString(L"Y"), ELEMENT_LABEL_WIDTH, labelStyle, inputBoxStyle);
 
-	void GUIVector2Field::construct(GUIWidget& parent, const GUIContent& labelContent, GUIElementStyle* labelStyle, 
-		GUIElementStyle* inputBoxStyle, const GUILayoutOptions& layoutOptions, bool withLabel)
-	{
-		if(withLabel)
-		{
-			const GUIElementStyle* curLabelStyle = labelStyle;
+		mLayout->removeElement(mLabel);
 
-			if(curLabelStyle == nullptr)
-				curLabelStyle = parent.getSkin().getStyle("Label");
+		GUILayout* layout = &mLayout->addLayoutY();
+		layout->addElement(mLabel);
 
-			mLabel = GUILabel::create(parent, labelContent, curLabelStyle);
-		}
+		GUILayout* elementLayout = &layout->addLayoutX();
 
-		mFieldX = GUIFloatField::create(parent, HString(L"X"), ELEMENT_LABEL_WIDTH, labelStyle, inputBoxStyle);
-		mFieldY = GUIFloatField::create(parent, HString(L"Y"), ELEMENT_LABEL_WIDTH, labelStyle, inputBoxStyle);
-
-		_registerChildElement(mLabel);
-		_registerChildElement(mFieldX);
-		_registerChildElement(mFieldY);
+		elementLayout->addElement(mFieldX);
+		elementLayout->addElement(mFieldY);
 	}
 
 	Vector2 GUIVector2Field::getValue() const
@@ -110,78 +48,6 @@ namespace BansheeEditor
 		mFieldY->setValue(value.y);
 	}
 
-	void GUIVector2Field::_updateLayoutInternal(INT32 x, INT32 y, UINT32 width, UINT32 height,
-		RectI clipRect, UINT8 widgetDepth, UINT16 areaDepth)
-	{
-		UINT32 inputBoxYOffset = 0;
-
-		if(mLabel != nullptr)
-		{
-			Vector2I optimalSize = mLabel->_getOptimalSize();
-			Vector2I offset(x, y);
-			mLabel->_setOffset(offset);
-			mLabel->_setWidth(width);
-			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);
-
-			inputBoxYOffset = optimalSize.y;
-		}
-
-		GUIFloatField* fields[] = { mFieldX, mFieldY };
-		UINT32 numFields = sizeof(fields) / sizeof(fields[0]);
-
-		UINT32 sizePerField = width / numFields;
-		UINT32 inputBoxXOffset = 0;
-
-		for(UINT32 i = 0; i < numFields; i++)
-		{
-			Vector2I optimalSize = fields[i]->_getOptimalSize();
-			INT32 yOffset = Math::roundToInt((height - optimalSize.y) * 0.5f);
-
-			Vector2I offset(x + inputBoxXOffset, y + inputBoxYOffset);
-			fields[i]->_setOffset(offset);
-			fields[i]->_setWidth(sizePerField);
-			fields[i]->_setHeight(optimalSize.y);
-			fields[i]->_setAreaDepth(areaDepth);
-			fields[i]->_setWidgetDepth(widgetDepth);
-
-			RectI elemClipRect(clipRect.x - offset.x, clipRect.y - offset.y, clipRect.width, clipRect.height);
-			fields[i]->_setClipRect(elemClipRect);
-
-			RectI newClipRect(offset.x, offset.y, sizePerField, optimalSize.y);
-			newClipRect.clip(clipRect);
-			fields[i]->_updateLayoutInternal(offset.x, offset.y, sizePerField, optimalSize.y, newClipRect, widgetDepth, areaDepth);
-
-			inputBoxXOffset += sizePerField;
-		}
-	}
-
-	Vector2I GUIVector2Field::_getOptimalSize() const
-	{
-		GUIFloatField* fields[] = { mFieldX, mFieldY };
-		UINT32 numFields = sizeof(fields) / sizeof(fields[0]);
-
-		Vector2I optimalSize;
-
-		for(UINT32 i = 0; i < numFields; i++)
-		{
-			optimalSize.x += fields[i]->_getOptimalSize().x;
-			optimalSize.y = std::max(optimalSize.y, fields[i]->_getOptimalSize().y);
-		}
-
-		if(mLabel != nullptr)
-		{
-			optimalSize.x = std::max(optimalSize.x, mLabel->_getOptimalSize().x);
-			optimalSize.y += mLabel->_getOptimalSize().y;
-		}
-
-		return optimalSize;
-	}
-
 	const String& GUIVector2Field::getGUITypeName()
 	{
 		static String typeName = "GUIVector2Field";

+ 12 - 148
BansheeEditor/Source/BsGUIVector3Field.cpp

@@ -16,87 +16,23 @@ namespace BansheeEditor
 	const UINT32 GUIVector3Field::ELEMENT_LABEL_WIDTH = 10;
 
 	GUIVector3Field::GUIVector3Field(const PrivatelyConstruct& dummy, GUIWidget& parent, const GUIContent& labelContent, 
-		GUIElementStyle* labelStyle, GUIElementStyle* inputBoxStyle, const GUILayoutOptions& layoutOptions)
-		:GUIElementContainer(parent, layoutOptions), mLabel(nullptr), mFieldX(nullptr), mFieldY(nullptr),
-		mFieldZ(nullptr)
+		CM::UINT32 labelWidth, GUIElementStyle* labelStyle, GUIElementStyle* inputBoxStyle, const GUILayoutOptions& layoutOptions, bool withLabel)
+		:TGUIField(dummy, parent, labelContent, labelWidth, labelStyle, layoutOptions, withLabel), mFieldX(nullptr), mFieldY(nullptr)
 	{
-		construct(parent, labelContent, labelStyle, inputBoxStyle, layoutOptions, true);
-	}
-
-	GUIVector3Field::GUIVector3Field(const PrivatelyConstruct& dummy, GUIWidget& parent, 
-		GUIElementStyle* labelStyle, GUIElementStyle* inputBoxStyle, const GUILayoutOptions& layoutOptions)
-		:GUIElementContainer(parent, layoutOptions), mLabel(nullptr), mFieldX(nullptr), mFieldY(nullptr),
-		mFieldZ(nullptr)
-	{
-		construct(parent, GUIContent(HString()), labelStyle, inputBoxStyle, layoutOptions, false);
-	}
-
-	GUIVector3Field::~GUIVector3Field()
-	{
-
-	}
-
-	GUIVector3Field* GUIVector3Field::create(GUIWidget& parent, const GUIContent& labelContent, const GUIOptions& layoutOptions, 
-		GUIElementStyle* labelStyle, GUIElementStyle* inputBoxStyle)
-	{
-		return cm_new<GUIVector3Field>(PrivatelyConstruct(), parent, labelContent, labelStyle, inputBoxStyle, 
-			GUILayoutOptions::create(layoutOptions, &GUISkin::DefaultStyle));
-	}
-
-	GUIVector3Field* GUIVector3Field::create(GUIWidget& parent, const GUIContent& labelContent, GUIElementStyle* labelStyle, 
-		GUIElementStyle* inputBoxStyle)
-	{
-		return cm_new<GUIVector3Field>(PrivatelyConstruct(), parent, labelContent, labelStyle, inputBoxStyle, 
-			GUILayoutOptions::create(&GUISkin::DefaultStyle));
-	}
-
-	GUIVector3Field* GUIVector3Field::create(GUIWidget& parent, const HString& labelContent, const GUIOptions& layoutOptions, 
-		GUIElementStyle* labelStyle, GUIElementStyle* inputBoxStyle)
-	{
-		return cm_new<GUIVector3Field>(PrivatelyConstruct(), parent, GUIContent(labelContent), labelStyle, 
-			inputBoxStyle, GUILayoutOptions::create(layoutOptions, &GUISkin::DefaultStyle));
-	}
-
-	GUIVector3Field* GUIVector3Field::create(GUIWidget& parent, const HString& labelContent, GUIElementStyle* labelStyle, 
-		GUIElementStyle* inputBoxStyle)
-	{
-		return cm_new<GUIVector3Field>(PrivatelyConstruct(), parent, GUIContent(labelContent), labelStyle, inputBoxStyle, 
-			GUILayoutOptions::create(&GUISkin::DefaultStyle));
-	}
-
-	GUIVector3Field* GUIVector3Field::create(GUIWidget& parent, const GUIOptions& layoutOptions, GUIElementStyle* labelStyle, 
-		GUIElementStyle* inputBoxStyle)
-	{
-		return cm_new<GUIVector3Field>(PrivatelyConstruct(), parent, labelStyle, inputBoxStyle, 
-			GUILayoutOptions::create(layoutOptions, &GUISkin::DefaultStyle));
-	}
-
-	GUIVector3Field* GUIVector3Field::create(GUIWidget& parent, GUIElementStyle* labelStyle, GUIElementStyle* inputBoxStyle)
-	{
-		return cm_new<GUIVector3Field>(PrivatelyConstruct(), parent, labelStyle, inputBoxStyle, GUILayoutOptions::create(&GUISkin::DefaultStyle));
-	}
-
-	void GUIVector3Field::construct(GUIWidget& parent, const GUIContent& labelContent, GUIElementStyle* labelStyle, 
-		GUIElementStyle* inputBoxStyle, const GUILayoutOptions& layoutOptions, bool withLabel)
-	{
-		if(withLabel)
-		{
-			const GUIElementStyle* curLabelStyle = labelStyle;
-
-			if(curLabelStyle == nullptr)
-				curLabelStyle = parent.getSkin().getStyle("Label");
-
-			mLabel = GUILabel::create(parent, labelContent, curLabelStyle);
-		}
-
 		mFieldX = GUIFloatField::create(parent, HString(L"X"), ELEMENT_LABEL_WIDTH, labelStyle, inputBoxStyle);
 		mFieldY = GUIFloatField::create(parent, HString(L"Y"), ELEMENT_LABEL_WIDTH, labelStyle, inputBoxStyle);
 		mFieldZ = GUIFloatField::create(parent, HString(L"Z"), ELEMENT_LABEL_WIDTH, labelStyle, inputBoxStyle);
 
-		_registerChildElement(mLabel);
-		_registerChildElement(mFieldX);
-		_registerChildElement(mFieldY);
-		_registerChildElement(mFieldZ);
+		mLayout->removeElement(mLabel);
+
+		GUILayout* layout = &mLayout->addLayoutY();
+		layout->addElement(mLabel);
+
+		GUILayout* elementLayout = &layout->addLayoutX();
+
+		elementLayout->addElement(mFieldX);
+		elementLayout->addElement(mFieldY);
+		elementLayout->addElement(mFieldZ);
 	}
 
 	Vector3 GUIVector3Field::getValue() const
@@ -116,78 +52,6 @@ namespace BansheeEditor
 		mFieldZ->setValue(value.z);
 	}
 
-	void GUIVector3Field::_updateLayoutInternal(INT32 x, INT32 y, UINT32 width, UINT32 height,
-		RectI clipRect, UINT8 widgetDepth, UINT16 areaDepth)
-	{
-		UINT32 inputBoxYOffset = 0;
-
-		if(mLabel != nullptr)
-		{
-			Vector2I optimalSize = mLabel->_getOptimalSize();
-			Vector2I offset(x, y);
-			mLabel->_setOffset(offset);
-			mLabel->_setWidth(width);
-			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);
-
-			inputBoxYOffset = optimalSize.y;
-		}
-
-		GUIFloatField* fields[] = { mFieldX, mFieldY, mFieldZ };
-		UINT32 numFields = sizeof(fields) / sizeof(fields[0]);
-
-		UINT32 sizePerField = width / numFields;
-		UINT32 inputBoxXOffset = 0;
-
-		for(UINT32 i = 0; i < numFields; i++)
-		{
-			Vector2I optimalSize = fields[i]->_getOptimalSize();
-			INT32 yOffset = Math::roundToInt((height - optimalSize.y) * 0.5f);
-
-			Vector2I offset(x + inputBoxXOffset, y + inputBoxYOffset);
-			fields[i]->_setOffset(offset);
-			fields[i]->_setWidth(sizePerField);
-			fields[i]->_setHeight(optimalSize.y);
-			fields[i]->_setAreaDepth(areaDepth);
-			fields[i]->_setWidgetDepth(widgetDepth);
-
-			RectI elemClipRect(clipRect.x - offset.x, clipRect.y - offset.y, clipRect.width, clipRect.height);
-			fields[i]->_setClipRect(elemClipRect);
-
-			RectI newClipRect(offset.x, offset.y, sizePerField, optimalSize.y);
-			newClipRect.clip(clipRect);
-			fields[i]->_updateLayoutInternal(offset.x, offset.y, sizePerField, optimalSize.y, newClipRect, widgetDepth, areaDepth);
-
-			inputBoxXOffset += sizePerField;
-		}
-	}
-
-	Vector2I GUIVector3Field::_getOptimalSize() const
-	{
-		GUIFloatField* fields[] = { mFieldX, mFieldY, mFieldZ };
-		UINT32 numFields = sizeof(fields) / sizeof(fields[0]);
-
-		Vector2I optimalSize;
-
-		for(UINT32 i = 0; i < numFields; i++)
-		{
-			optimalSize.x += fields[i]->_getOptimalSize().x;
-			optimalSize.y = std::max(optimalSize.y, fields[i]->_getOptimalSize().y);
-		}
-
-		if(mLabel != nullptr)
-		{
-			optimalSize.x = std::max(optimalSize.x, mLabel->_getOptimalSize().x);
-			optimalSize.y += mLabel->_getOptimalSize().y;
-		}
-
-		return optimalSize;
-	}
-
 	const String& GUIVector3Field::getGUITypeName()
 	{
 		static String typeName = "GUIVector3Field";

+ 13 - 149
BansheeEditor/Source/BsGUIVector4Field.cpp

@@ -16,89 +16,25 @@ namespace BansheeEditor
 	const UINT32 GUIVector4Field::ELEMENT_LABEL_WIDTH = 10;
 
 	GUIVector4Field::GUIVector4Field(const PrivatelyConstruct& dummy, GUIWidget& parent, const GUIContent& labelContent, 
-		GUIElementStyle* labelStyle, GUIElementStyle* inputBoxStyle, const GUILayoutOptions& layoutOptions)
-		:GUIElementContainer(parent, layoutOptions), mLabel(nullptr), mFieldX(nullptr), mFieldY(nullptr),
-		mFieldZ(nullptr), mFieldW(nullptr)
+		CM::UINT32 labelWidth, GUIElementStyle* labelStyle, GUIElementStyle* inputBoxStyle, const GUILayoutOptions& layoutOptions, bool withLabel)
+		:TGUIField(dummy, parent, labelContent, labelWidth, labelStyle, layoutOptions, withLabel), mFieldX(nullptr), mFieldY(nullptr)
 	{
-		construct(parent, labelContent, labelStyle, inputBoxStyle, layoutOptions, true);
-	}
-
-	GUIVector4Field::GUIVector4Field(const PrivatelyConstruct& dummy, GUIWidget& parent, 
-		GUIElementStyle* labelStyle, GUIElementStyle* inputBoxStyle, const GUILayoutOptions& layoutOptions)
-		:GUIElementContainer(parent, layoutOptions), mLabel(nullptr), mFieldX(nullptr), mFieldY(nullptr),
-		mFieldZ(nullptr), mFieldW(nullptr)
-	{
-		construct(parent, GUIContent(HString()), labelStyle, inputBoxStyle, layoutOptions, false);
-	}
-
-	GUIVector4Field::~GUIVector4Field()
-	{
-
-	}
-
-	GUIVector4Field* GUIVector4Field::create(GUIWidget& parent, const GUIContent& labelContent, const GUIOptions& layoutOptions, 
-		GUIElementStyle* labelStyle, GUIElementStyle* inputBoxStyle)
-	{
-		return cm_new<GUIVector4Field>(PrivatelyConstruct(), parent, labelContent, labelStyle, inputBoxStyle, 
-			GUILayoutOptions::create(layoutOptions, &GUISkin::DefaultStyle));
-	}
-
-	GUIVector4Field* GUIVector4Field::create(GUIWidget& parent, const GUIContent& labelContent, GUIElementStyle* labelStyle, 
-		GUIElementStyle* inputBoxStyle)
-	{
-		return cm_new<GUIVector4Field>(PrivatelyConstruct(), parent, labelContent, labelStyle, inputBoxStyle, 
-			GUILayoutOptions::create(&GUISkin::DefaultStyle));
-	}
-
-	GUIVector4Field* GUIVector4Field::create(GUIWidget& parent, const HString& labelContent, const GUIOptions& layoutOptions, 
-		GUIElementStyle* labelStyle, GUIElementStyle* inputBoxStyle)
-	{
-		return cm_new<GUIVector4Field>(PrivatelyConstruct(), parent, GUIContent(labelContent), labelStyle, 
-			inputBoxStyle, GUILayoutOptions::create(layoutOptions, &GUISkin::DefaultStyle));
-	}
-
-	GUIVector4Field* GUIVector4Field::create(GUIWidget& parent, const HString& labelContent, GUIElementStyle* labelStyle, 
-		GUIElementStyle* inputBoxStyle)
-	{
-		return cm_new<GUIVector4Field>(PrivatelyConstruct(), parent, GUIContent(labelContent), labelStyle, inputBoxStyle, 
-			GUILayoutOptions::create(&GUISkin::DefaultStyle));
-	}
-
-	GUIVector4Field* GUIVector4Field::create(GUIWidget& parent, const GUIOptions& layoutOptions, GUIElementStyle* labelStyle, 
-		GUIElementStyle* inputBoxStyle)
-	{
-		return cm_new<GUIVector4Field>(PrivatelyConstruct(), parent, labelStyle, inputBoxStyle, 
-			GUILayoutOptions::create(layoutOptions, &GUISkin::DefaultStyle));
-	}
-
-	GUIVector4Field* GUIVector4Field::create(GUIWidget& parent, GUIElementStyle* labelStyle, GUIElementStyle* inputBoxStyle)
-	{
-		return cm_new<GUIVector4Field>(PrivatelyConstruct(), parent, labelStyle, inputBoxStyle, GUILayoutOptions::create(&GUISkin::DefaultStyle));
-	}
-
-	void GUIVector4Field::construct(GUIWidget& parent, const GUIContent& labelContent, GUIElementStyle* labelStyle, 
-		GUIElementStyle* inputBoxStyle, const GUILayoutOptions& layoutOptions, bool withLabel)
-	{
-		if(withLabel)
-		{
-			const GUIElementStyle* curLabelStyle = labelStyle;
-
-			if(curLabelStyle == nullptr)
-				curLabelStyle = parent.getSkin().getStyle("Label");
-
-			mLabel = GUILabel::create(parent, labelContent, curLabelStyle);
-		}
-
 		mFieldX = GUIFloatField::create(parent, HString(L"X"), ELEMENT_LABEL_WIDTH, labelStyle, inputBoxStyle);
 		mFieldY = GUIFloatField::create(parent, HString(L"Y"), ELEMENT_LABEL_WIDTH, labelStyle, inputBoxStyle);
 		mFieldZ = GUIFloatField::create(parent, HString(L"Z"), ELEMENT_LABEL_WIDTH, labelStyle, inputBoxStyle);
 		mFieldW = GUIFloatField::create(parent, HString(L"W"), ELEMENT_LABEL_WIDTH, labelStyle, inputBoxStyle);
 
-		_registerChildElement(mLabel);
-		_registerChildElement(mFieldX);
-		_registerChildElement(mFieldY);
-		_registerChildElement(mFieldZ);
-		_registerChildElement(mFieldW);
+		mLayout->removeElement(mLabel);
+
+		GUILayout* layout = &mLayout->addLayoutY();
+		layout->addElement(mLabel);
+
+		GUILayout* elementLayout = &layout->addLayoutX();
+
+		elementLayout->addElement(mFieldX);
+		elementLayout->addElement(mFieldY);
+		elementLayout->addElement(mFieldZ);
+		elementLayout->addElement(mFieldW);
 	}
 
 	Vector4 GUIVector4Field::getValue() const
@@ -120,78 +56,6 @@ namespace BansheeEditor
 		mFieldW->setValue(value.w);
 	}
 
-	void GUIVector4Field::_updateLayoutInternal(INT32 x, INT32 y, UINT32 width, UINT32 height,
-		RectI clipRect, UINT8 widgetDepth, UINT16 areaDepth)
-	{
-		UINT32 inputBoxYOffset = 0;
-
-		if(mLabel != nullptr)
-		{
-			Vector2I optimalSize = mLabel->_getOptimalSize();
-			Vector2I offset(x, y);
-			mLabel->_setOffset(offset);
-			mLabel->_setWidth(width);
-			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);
-
-			inputBoxYOffset = optimalSize.y;
-		}
-
-		GUIFloatField* fields[] = { mFieldX, mFieldY, mFieldZ, mFieldW };
-		UINT32 numFields = sizeof(fields) / sizeof(fields[0]);
-
-		UINT32 sizePerField = width / numFields;
-		UINT32 inputBoxXOffset = 0;
-
-		for(UINT32 i = 0; i < numFields; i++)
-		{
-			Vector2I optimalSize = fields[i]->_getOptimalSize();
-			INT32 yOffset = Math::roundToInt((height - optimalSize.y) * 0.5f);
-
-			Vector2I offset(x + inputBoxXOffset, y + inputBoxYOffset);
-			fields[i]->_setOffset(offset);
-			fields[i]->_setWidth(sizePerField);
-			fields[i]->_setHeight(optimalSize.y);
-			fields[i]->_setAreaDepth(areaDepth);
-			fields[i]->_setWidgetDepth(widgetDepth);
-
-			RectI elemClipRect(clipRect.x - offset.x, clipRect.y - offset.y, clipRect.width, clipRect.height);
-			fields[i]->_setClipRect(elemClipRect);
-
-			RectI newClipRect(offset.x, offset.y, sizePerField, optimalSize.y);
-			newClipRect.clip(clipRect);
-			fields[i]->_updateLayoutInternal(offset.x, offset.y, sizePerField, optimalSize.y, newClipRect, widgetDepth, areaDepth);
-
-			inputBoxXOffset += sizePerField;
-		}
-	}
-
-	Vector2I GUIVector4Field::_getOptimalSize() const
-	{
-		GUIFloatField* fields[] = { mFieldX, mFieldY, mFieldZ, mFieldW };
-		UINT32 numFields = sizeof(fields) / sizeof(fields[0]);
-
-		Vector2I optimalSize;
-
-		for(UINT32 i = 0; i < numFields; i++)
-		{
-			optimalSize.x += fields[i]->_getOptimalSize().x;
-			optimalSize.y = std::max(optimalSize.y, fields[i]->_getOptimalSize().y);
-		}
-
-		if(mLabel != nullptr)
-		{
-			optimalSize.x = std::max(optimalSize.x, mLabel->_getOptimalSize().x);
-			optimalSize.y += mLabel->_getOptimalSize().y;
-		}
-
-		return optimalSize;
-	}
-
 	const String& GUIVector4Field::getGUITypeName()
 	{
 		static String typeName = "GUIVector4Field";

+ 3 - 2
Inspector.txt

@@ -22,8 +22,9 @@ Other:
 REFACTOR c++ GUI a bit:
  - Add new graphic for input boxes and add object field graphics
  - Add "padding" to GUIElementStyle and make sure GUILayout (and whatever else) uses it
- - Edit all Editor *Field classes and make sure they use GUILayout internally (where possible, probably not for Foldout which has a background element that would require 2 layers)
-
+ - GameObjectField
+   - When dragging over GameObjectField cursor needs to change depending whether drop will be accepted or not
+   - How will I limit it to just certain component types?
 
 How will I add editor fields to GUILayout? Right now I have a bunch of Add* methods and that won't work for Editor-only fields. I could extend GUILayout to EditorGUILayout but then GUIArea needs to be aware of that as well...