Bladeren bron

Added WIP GameObjectField

Marko Pintera 11 jaren geleden
bovenliggende
commit
33145efdd1

+ 4 - 0
BansheeEditor/BansheeEditor.vcxproj

@@ -279,7 +279,9 @@
     <ClInclude Include="Include\BsGUIColorField.h" />
     <ClInclude Include="Include\BsGUIColorField.h" />
     <ClInclude Include="Include\BsGUIFloatField.h" />
     <ClInclude Include="Include\BsGUIFloatField.h" />
     <ClInclude Include="Include\BsGUIFoldout.h" />
     <ClInclude Include="Include\BsGUIFoldout.h" />
+    <ClInclude Include="Include\BsGUIGameObjectField.h" />
     <ClInclude Include="Include\BsGUIIntField.h" />
     <ClInclude Include="Include\BsGUIIntField.h" />
+    <ClInclude Include="Include\BsGUIDropButton.h" />
     <ClInclude Include="Include\BsGUITextField.h" />
     <ClInclude Include="Include\BsGUITextField.h" />
     <ClInclude Include="Include\BsGUIToggleField.h" />
     <ClInclude Include="Include\BsGUIToggleField.h" />
     <ClInclude Include="Include\BsGUIVector3Field.h" />
     <ClInclude Include="Include\BsGUIVector3Field.h" />
@@ -333,8 +335,10 @@
     <ClCompile Include="Source\BsGUIDockSlider.cpp" />
     <ClCompile Include="Source\BsGUIDockSlider.cpp" />
     <ClCompile Include="Source\BsGUIFloatField.cpp" />
     <ClCompile Include="Source\BsGUIFloatField.cpp" />
     <ClCompile Include="Source\BsGUIFoldout.cpp" />
     <ClCompile Include="Source\BsGUIFoldout.cpp" />
+    <ClCompile Include="Source\BsGUIGameObjectField.cpp" />
     <ClCompile Include="Source\BsGUIIntField.cpp" />
     <ClCompile Include="Source\BsGUIIntField.cpp" />
     <ClCompile Include="Source\BsGUIMenuBar.cpp" />
     <ClCompile Include="Source\BsGUIMenuBar.cpp" />
+    <ClCompile Include="Source\BsGUIDropButton.cpp" />
     <ClCompile Include="Source\BsGUIResourceTreeView.cpp" />
     <ClCompile Include="Source\BsGUIResourceTreeView.cpp" />
     <ClCompile Include="Source\BsGUISceneTreeView.cpp" />
     <ClCompile Include="Source\BsGUISceneTreeView.cpp" />
     <ClCompile Include="Source\BsGUITabbedTitleBar.cpp" />
     <ClCompile Include="Source\BsGUITabbedTitleBar.cpp" />

+ 12 - 0
BansheeEditor/BansheeEditor.vcxproj.filters

@@ -183,6 +183,12 @@
     <ClInclude Include="Include\BsGUIFoldout.h">
     <ClInclude Include="Include\BsGUIFoldout.h">
       <Filter>Header Files\Editor</Filter>
       <Filter>Header Files\Editor</Filter>
     </ClInclude>
     </ClInclude>
+    <ClInclude Include="Include\BsGUIGameObjectField.h">
+      <Filter>Header Files\Editor</Filter>
+    </ClInclude>
+    <ClInclude Include="Include\BsGUIDropButton.h">
+      <Filter>Header Files\Editor</Filter>
+    </ClInclude>
   </ItemGroup>
   </ItemGroup>
   <ItemGroup>
   <ItemGroup>
     <ClCompile Include="Source\BsEditorWidgetContainer.cpp">
     <ClCompile Include="Source\BsEditorWidgetContainer.cpp">
@@ -317,5 +323,11 @@
     <ClCompile Include="Source\BsGUIFoldout.cpp">
     <ClCompile Include="Source\BsGUIFoldout.cpp">
       <Filter>Source Files\Editor</Filter>
       <Filter>Source Files\Editor</Filter>
     </ClCompile>
     </ClCompile>
+    <ClCompile Include="Source\BsGUIGameObjectField.cpp">
+      <Filter>Source Files\Editor</Filter>
+    </ClCompile>
+    <ClCompile Include="Source\BsGUIDropButton.cpp">
+      <Filter>Source Files\Editor</Filter>
+    </ClCompile>
   </ItemGroup>
   </ItemGroup>
 </Project>
 </Project>

+ 7 - 0
BansheeEditor/Include/BsEditorGUI.h

@@ -42,6 +42,7 @@ namespace BansheeEditor
 
 
 		static const CM::WString ButtonNormalTex;
 		static const CM::WString ButtonNormalTex;
 		static const CM::WString ButtonHoverTex;
 		static const CM::WString ButtonHoverTex;
+		static const CM::WString ButtonActiveTex;
 
 
 		static const CM::WString ToggleNormalTex;
 		static const CM::WString ToggleNormalTex;
 		static const CM::WString ToggleHoverTex;
 		static const CM::WString ToggleHoverTex;
@@ -50,6 +51,12 @@ namespace BansheeEditor
 		static const CM::WString ToggleHoverOnTex;
 		static const CM::WString ToggleHoverOnTex;
 		static const CM::WString ToggleActiveOnTex;
 		static const CM::WString ToggleActiveOnTex;
 
 
+		static const CM::WString ObjectDropBtnNormalTex;
+		static const CM::WString ObjectDropBtnNormalOnTex;
+		static const CM::WString ObjectClearBtnNormalTex;
+		static const CM::WString ObjectClearBtnHoverTex;
+		static const CM::WString ObjectClearBtnActiveTex;
+
 		static const CM::WString FoldoutOpenNormalTex;
 		static const CM::WString FoldoutOpenNormalTex;
 		static const CM::WString FoldoutOpenHoverTex;
 		static const CM::WString FoldoutOpenHoverTex;
 		static const CM::WString FoldoutClosedNormalTex;
 		static const CM::WString FoldoutClosedNormalTex;

+ 1 - 0
BansheeEditor/Include/BsEditorPrerequisites.h

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

+ 32 - 0
BansheeEditor/Include/BsGUIDropButton.h

@@ -0,0 +1,32 @@
+#pragma once
+
+#include "BsEditorPrerequisites.h"
+#include "BsGUIButtonBase.h"
+#include "BsGUIToggleGroup.h"
+#include "BsImageSprite.h"
+#include "BsTextSprite.h"
+#include "BsGUIContent.h"
+#include "boost/signal.hpp"
+
+namespace BansheeEditor
+{
+	class GUIDropButton : public BS::GUIButtonBase
+	{
+	public:
+		static const CM::String& getGUITypeName();
+
+		static GUIDropButton* create(BS::GUIWidget& parent, CM::UINT32 dragType, const BS::GUIElementStyle* style = nullptr);
+		static GUIDropButton* create(BS::GUIWidget& parent, CM::UINT32 dragType, const BS::GUIOptions& layoutOptions, const BS::GUIElementStyle* style = nullptr);
+
+		boost::signal<void(void*)> onDataDropped;
+	protected:
+		virtual ~GUIDropButton();
+
+	protected:
+		GUIDropButton(BS::GUIWidget& parent, CM::UINT32 dragType, const BS::GUIElementStyle* style, const BS::GUILayoutOptions& layoutOptions);
+
+		virtual bool mouseEvent(const BS::GUIMouseEvent& ev);
+
+		CM::UINT32 mDragType;
+	};
+}

+ 74 - 0
BansheeEditor/Include/BsGUIGameObjectField.h

@@ -0,0 +1,74 @@
+#pragma once
+
+#include "BsEditorPrerequisites.h"
+#include "BsGUIElementContainer.h"
+
+namespace BansheeEditor
+{
+	class BS_ED_EXPORT GUIGameObjectField : public BS::GUIElementContainer
+	{
+		struct PrivatelyConstruct {};
+
+	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,
+			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,
+			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, 
+			BS::GUIElementStyle* labelStyle = nullptr, BS::GUIElementStyle* dropButtonStyle = nullptr,
+			BS::GUIElementStyle* clearButtonStyle = nullptr);
+
+		static GUIGameObjectField* create(BS::GUIWidget& parent, 
+			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);
+
+		GUIGameObjectField(const PrivatelyConstruct& dummy, BS::GUIWidget& parent, 
+			BS::GUIElementStyle* labelStyle, BS::GUIElementStyle* dropButtonStyle,
+			BS::GUIElementStyle* clearButtonStyle, const BS::GUILayoutOptions& layoutOptions);
+
+		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);
+
+		CM::Vector2I _getOptimalSize() const;
+	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;
+		BS::GUILayout* mLayout;
+		BS::GUILabel* mLabel;
+		GUIDropButton* mDropButton;
+		BS::GUIButton* mClearButton;
+
+		CM::UINT64 mInstanceId;
+	};
+}

+ 9 - 9
BansheeEditor/Include/BsGUISceneTreeView.h

@@ -6,6 +6,15 @@
 
 
 namespace BansheeEditor
 namespace BansheeEditor
 {
 {
+	struct DraggedSceneObjects
+	{
+		DraggedSceneObjects(CM::UINT32 numObjects);
+		~DraggedSceneObjects();
+
+		CM::UINT32 numObjects;
+		CM::HSceneObject* objects;
+	};
+
 	class GUISceneTreeView : public GUITreeView
 	class GUISceneTreeView : public GUITreeView
 	{
 	{
 		struct SceneTreeElement : public GUITreeView::TreeElement
 		struct SceneTreeElement : public GUITreeView::TreeElement
@@ -18,15 +27,6 @@ namespace BansheeEditor
 			CM::UINT64 mId;
 			CM::UINT64 mId;
 		};
 		};
 
 
-		struct DraggedSceneObjects
-		{
-			DraggedSceneObjects(CM::UINT32 numObjects);
-			~DraggedSceneObjects();
-
-			CM::UINT32 numObjects;
-			CM::HSceneObject* objects;
-		};
-
 	public:
 	public:
 		static const CM::String& getGUITypeName();
 		static const CM::String& getGUITypeName();
 
 

+ 43 - 12
BansheeEditor/Source/BsEditorGUI.cpp

@@ -30,6 +30,7 @@ namespace BansheeEditor
 
 
 	const WString EditorGUI::ButtonNormalTex = L"ButtonNormal.psd";
 	const WString EditorGUI::ButtonNormalTex = L"ButtonNormal.psd";
 	const WString EditorGUI::ButtonHoverTex = L"ButtonHover.psd";
 	const WString EditorGUI::ButtonHoverTex = L"ButtonHover.psd";
+	const WString EditorGUI::ButtonActiveTex = L"ButtonActive.psd";
 
 
 	const WString EditorGUI::ToggleNormalTex = L"ToggleNormal.psd";
 	const WString EditorGUI::ToggleNormalTex = L"ToggleNormal.psd";
 	const WString EditorGUI::ToggleHoverTex = L"ToggleHover.psd";
 	const WString EditorGUI::ToggleHoverTex = L"ToggleHover.psd";
@@ -38,6 +39,12 @@ namespace BansheeEditor
 	const WString EditorGUI::ToggleHoverOnTex = L"ToggleOnHover.psd";
 	const WString EditorGUI::ToggleHoverOnTex = L"ToggleOnHover.psd";
 	const WString EditorGUI::ToggleActiveOnTex = L"ToggleOnActive.psd";
 	const WString EditorGUI::ToggleActiveOnTex = L"ToggleOnActive.psd";
 
 
+	const WString EditorGUI::ObjectDropBtnNormalTex = L"ObjectFieldDropNormal.psd";
+	const WString EditorGUI::ObjectDropBtnNormalOnTex = L"ObjectFieldDropNormalOn.psd";
+	const WString EditorGUI::ObjectClearBtnNormalTex = L"ObjectFieldBtnNormal.psd";
+	const WString EditorGUI::ObjectClearBtnHoverTex = L"ObjectFieldBtnHover.psd";
+	const WString EditorGUI::ObjectClearBtnActiveTex = L"ObjectFieldBtnActive.psd";
+
 	const WString EditorGUI::FoldoutOpenNormalTex = L"FoldoutOpenNormal.psd";
 	const WString EditorGUI::FoldoutOpenNormalTex = L"FoldoutOpenNormal.psd";
 	const WString EditorGUI::FoldoutOpenHoverTex = L"FoldoutOpenHover.psd";
 	const WString EditorGUI::FoldoutOpenHoverTex = L"FoldoutOpenHover.psd";
 	const WString EditorGUI::FoldoutClosedNormalTex = L"FoldoutClosedNormal.psd";
 	const WString EditorGUI::FoldoutClosedNormalTex = L"FoldoutClosedNormal.psd";
@@ -180,19 +187,15 @@ namespace BansheeEditor
 		GUIElementStyle buttonStyle;
 		GUIElementStyle buttonStyle;
 		buttonStyle.normal.texture = getTexture(ButtonNormalTex);
 		buttonStyle.normal.texture = getTexture(ButtonNormalTex);
 		buttonStyle.hover.texture = getTexture(ButtonHoverTex);
 		buttonStyle.hover.texture = getTexture(ButtonHoverTex);
-		buttonStyle.active.texture = buttonStyle.hover.texture;
-		buttonStyle.border.left = 5;
-		buttonStyle.border.right = 5;
-		buttonStyle.border.top = 5;
-		buttonStyle.border.bottom = 5;
-		buttonStyle.margins.left = 4;
-		buttonStyle.margins.right = 4;
-		buttonStyle.margins.top = 4;
-		buttonStyle.margins.bottom = 4;
-		buttonStyle.contentOffset.left = 2;
-		buttonStyle.contentOffset.right = 2;
+		buttonStyle.active.texture = getTexture(ButtonActiveTex);
+		buttonStyle.border.left = 6;
+		buttonStyle.border.right = 6;
+		buttonStyle.border.top = 6;
+		buttonStyle.border.bottom = 6;
+		buttonStyle.contentOffset.left = 3;
+		buttonStyle.contentOffset.right = 3;
 		buttonStyle.fixedHeight = true;
 		buttonStyle.fixedHeight = true;
-		buttonStyle.height = 21;
+		buttonStyle.height = 15;
 		buttonStyle.minWidth = 50;
 		buttonStyle.minWidth = 50;
 		buttonStyle.font = font;
 		buttonStyle.font = font;
 		buttonStyle.fontSize = DefaultFontSize;
 		buttonStyle.fontSize = DefaultFontSize;
@@ -786,6 +789,34 @@ namespace BansheeEditor
 		treeViewElementSepHighlight.border.bottom = 1;
 		treeViewElementSepHighlight.border.bottom = 1;
 
 
 		mSkin.setStyle("TreeViewElementSepHighlight", treeViewElementSepHighlight);
 		mSkin.setStyle("TreeViewElementSepHighlight", treeViewElementSepHighlight);
+	
+		/************************************************************************/
+		/* 							OBJECT DROP FIELD                      		*/
+		/************************************************************************/
+		GUIElementStyle objectDropStyle;
+		objectDropStyle.normal.texture = getTexture(ObjectDropBtnNormalTex);
+		objectDropStyle.normalOn.texture = getTexture(ObjectDropBtnNormalOnTex);
+		objectDropStyle.fixedHeight = true;
+		objectDropStyle.height = 15;
+		objectDropStyle.minWidth = 50;
+		objectDropStyle.font = font;
+		objectDropStyle.fontSize = DefaultFontSize;
+		objectDropStyle.textHorzAlign = THA_Center;
+		objectDropStyle.textVertAlign = TVA_Center;
+
+		mSkin.setStyle("DropButton", objectDropStyle);
+
+		GUIElementStyle objectClearBtnStyle;
+		objectClearBtnStyle.normal.texture = getTexture(ObjectClearBtnNormalTex);
+		objectClearBtnStyle.hover.texture = getTexture(ObjectClearBtnHoverTex);
+		objectClearBtnStyle.active.texture = getTexture(ObjectClearBtnActiveTex);
+		objectClearBtnStyle.fixedHeight = true;
+		objectClearBtnStyle.fixedWidth = true;
+		objectClearBtnStyle.height = 15;
+		objectClearBtnStyle.width = 13;
+
+		mSkin.setStyle("ObjectClearButton", objectClearBtnStyle);
+
 	}
 	}
 
 
 	HSpriteTexture EditorGUI::getTexture(const CM::WString& name)
 	HSpriteTexture EditorGUI::getTexture(const CM::WString& name)

+ 96 - 0
BansheeEditor/Source/BsGUIDropButton.cpp

@@ -0,0 +1,96 @@
+#include "BsGUIDropButton.h"
+#include "BsImageSprite.h"
+#include "BsGUIWidget.h"
+#include "BsGUISkin.h"
+#include "BsSpriteTexture.h"
+#include "BsTextSprite.h"
+#include "BsGUILayoutOptions.h"
+#include "BsGUIMouseEvent.h"
+#include "BsGUIHelper.h"
+#include "CmTexture.h"
+#include "BsDragAndDropManager.h"
+
+using namespace CamelotFramework;
+using namespace BansheeEngine;
+
+namespace BansheeEditor
+{
+	const String& GUIDropButton::getGUITypeName()
+	{
+		static String name = "DropButton";
+		return name;
+	}
+
+	GUIDropButton::GUIDropButton(GUIWidget& parent, CM::UINT32 dragType, const GUIElementStyle* style, const GUILayoutOptions& layoutOptions)
+		:GUIButtonBase(parent, style, GUIContent(HString(L"None")), layoutOptions)
+	{
+
+	}
+
+	GUIDropButton::~GUIDropButton()
+	{ }
+
+	GUIDropButton* GUIDropButton::create(GUIWidget& parent, CM::UINT32 dragType, const GUIElementStyle* style)
+	{
+		if(style == nullptr)
+		{
+			const GUISkin& skin = parent.getSkin();
+			style = skin.getStyle(getGUITypeName());
+		}
+
+		return new (cm_alloc<GUIDropButton, PoolAlloc>()) GUIDropButton(parent, dragType, style, GUILayoutOptions::create(style));
+	}
+
+	GUIDropButton* GUIDropButton::create(GUIWidget& parent, CM::UINT32 dragType, const GUIOptions& layoutOptions, const GUIElementStyle* style)
+	{
+		if(style == nullptr)
+		{
+			const GUISkin& skin = parent.getSkin();
+			style = skin.getStyle(getGUITypeName());
+		}
+
+		return new (cm_alloc<GUIDropButton, PoolAlloc>()) GUIDropButton(parent, dragType, style, GUILayoutOptions::create(layoutOptions, style));
+	}
+
+	bool GUIDropButton::mouseEvent(const GUIMouseEvent& ev)
+	{
+		bool processed = GUIButtonBase::mouseEvent(ev);
+
+		if(ev.getType() == GUIMouseEventType::MouseDragAndDropDragged)
+		{
+			if(DragAndDropManager::instance().isDragInProgress())
+			{
+				if(DragAndDropManager::instance().getDragTypeId() == mDragType)
+				{
+					if(!_isOn())
+						_setOn(true);
+				}
+				else
+				{
+					if(_isOn())
+						_setOn(false);
+				}
+			}
+			else
+			{
+				if(_isOn())
+					_setOn(false);
+			}
+
+			processed = true;
+		}
+		else if(ev.getType() == GUIMouseEventType::MouseDragAndDropDropped)
+		{
+			if(_isOn())
+				_setOn(false);
+
+			if(DragAndDropManager::instance().isDragInProgress() && DragAndDropManager::instance().getDragTypeId() == mDragType)
+			{
+				if(!onDataDropped.empty())
+					onDataDropped(DragAndDropManager::instance().getDragData());
+			}
+		}
+
+		return processed;
+	}
+}

+ 172 - 0
BansheeEditor/Source/BsGUIGameObjectField.cpp

@@ -0,0 +1,172 @@
+#include "BsGUIGameObjectField.h"
+#include "BsGUIArea.h"
+#include "BsGUILayout.h"
+#include "BsGUILabel.h"
+#include "BsGUIDropButton.h"
+#include "BsGUIButton.h"
+#include "BsBuiltinResources.h"
+#include "BsGUIWidget.h"
+#include "BsGUIMouseEvent.h"
+#include "BsGUISceneTreeView.h"
+#include "BsGUIWidget.h"
+#include "CmGameObjectManager.h"
+
+using namespace CamelotFramework;
+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);
+	}
+
+	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)
+	{
+		mLayout = &addLayoutXInternal(this);
+
+		if(withLabel)
+		{
+			const GUIElementStyle* curLabelStyle = labelStyle;
+
+			if(curLabelStyle == nullptr)
+				curLabelStyle = parent.getSkin().getStyle("Label");
+
+			mLabel = GUILabel::create(parent, labelContent, GUIOptions(GUIOption::fixedWidth(mLabelWidth)), curLabelStyle);
+			mLayout->addElement(mLabel);
+		}
+
+		const GUIElementStyle* curDropButtonStyle = dropButtonStyle;
+		const GUIElementStyle* curClearButtonStyle = clearButtonStyle;
+
+		if(curDropButtonStyle == nullptr)
+			curDropButtonStyle = parent.getSkin().getStyle("DropButton");
+
+		if(curClearButtonStyle == nullptr)
+			curClearButtonStyle = parent.getSkin().getStyle("ObjectClearButton");
+
+		mDropButton = GUIDropButton::create(parent, (UINT32)DragAndDropType::SceneObject, GUIOptions(GUIOption::flexibleWidth()), curDropButtonStyle);
+		mClearButton = GUIButton::create(parent, HString(L""), curClearButtonStyle);
+
+		mLayout->addElement(mDropButton);
+		mLayout->addElement(mClearButton);
+
+		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)
+	{
+		return cm_new<GUIGameObjectField>(PrivatelyConstruct(), parent, labelContent, labelStyle, dropButtonStyle, clearButtonStyle,
+			GUILayoutOptions::create(layoutOptions, &GUISkin::DefaultStyle));
+	}
+
+	GUIGameObjectField* GUIGameObjectField::create(GUIWidget& parent, const GUIContent& labelContent, GUIElementStyle* labelStyle, 
+		GUIElementStyle* dropButtonStyle, GUIElementStyle* clearButtonStyle)
+	{
+		return cm_new<GUIGameObjectField>(PrivatelyConstruct(), parent, labelContent, labelStyle, dropButtonStyle, clearButtonStyle,
+			GUILayoutOptions::create(&GUISkin::DefaultStyle));
+	}
+
+	GUIGameObjectField* GUIGameObjectField::create(GUIWidget& parent, const HString& labelContent, const GUIOptions& layoutOptions, 
+		GUIElementStyle* labelStyle, GUIElementStyle* dropButtonStyle, GUIElementStyle* clearButtonStyle)
+	{
+		return cm_new<GUIGameObjectField>(PrivatelyConstruct(), parent, GUIContent(labelContent), labelStyle, 
+			dropButtonStyle, clearButtonStyle, GUILayoutOptions::create(layoutOptions, &GUISkin::DefaultStyle));
+	}
+
+	GUIGameObjectField* GUIGameObjectField::create(GUIWidget& parent, const HString& labelContent, GUIElementStyle* labelStyle, 
+		GUIElementStyle* dropButtonStyle, GUIElementStyle* clearButtonStyle)
+	{
+		return cm_new<GUIGameObjectField>(PrivatelyConstruct(), parent, GUIContent(labelContent), labelStyle, dropButtonStyle, 
+			clearButtonStyle, GUILayoutOptions::create(&GUISkin::DefaultStyle));
+	}
+
+	GUIGameObjectField* GUIGameObjectField::create(GUIWidget& parent, const GUIOptions& layoutOptions, GUIElementStyle* labelStyle, 
+		GUIElementStyle* dropButtonStyle, GUIElementStyle* clearButtonStyle)
+	{
+		return cm_new<GUIGameObjectField>(PrivatelyConstruct(), parent, labelStyle, dropButtonStyle, clearButtonStyle, 
+			GUILayoutOptions::create(layoutOptions, &GUISkin::DefaultStyle));
+	}
+
+	GUIGameObjectField* GUIGameObjectField::create(GUIWidget& parent, GUIElementStyle* labelStyle, GUIElementStyle* dropButtonStyle, 
+		GUIElementStyle* clearButtonStyle)
+	{
+		return cm_new<GUIGameObjectField>(PrivatelyConstruct(), parent, labelStyle, dropButtonStyle, clearButtonStyle, 
+			GUILayoutOptions::create(&GUISkin::DefaultStyle));
+	}
+
+	CM::HGameObject GUIGameObjectField::getValue() const
+	{
+		HGameObject obj;
+
+		if(mInstanceId != 0)
+			GameObjectManager::instance().tryGetObject(mInstanceId, obj);
+
+		return obj;
+	}
+
+	void GUIGameObjectField::setValue(const CM::HGameObject& value)
+	{
+		if(value)
+		{
+			mInstanceId = value->getInstanceId();
+			mDropButton->setContent(GUIContent(HString(toWString(value->getName()))));
+		}
+		else
+		{
+			mInstanceId = 0;
+			mDropButton->setContent(GUIContent(HString(L"None")));
+		}		
+	}
+
+	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)
+	{
+		mLayout->_updateLayoutInternal(x, y, width, height, clipRect, widgetDepth, areaDepth);
+	}
+
+	Vector2I GUIGameObjectField::_getOptimalSize() const
+	{
+		return mLayout->_getOptimalSize();
+	}
+
+	void GUIGameObjectField::dataDropped(void* data)
+	{
+		DraggedSceneObjects* draggedSceneObjects = reinterpret_cast<DraggedSceneObjects*>(data);
+
+		// TODO
+	}
+
+	const String& GUIGameObjectField::getGUITypeName()
+	{
+		static String typeName = "GUIGameObjectField";
+		return typeName;
+	}
+}

+ 2 - 2
BansheeEditor/Source/BsGUISceneTreeView.cpp

@@ -11,13 +11,13 @@ using namespace BansheeEngine;
 
 
 namespace BansheeEditor
 namespace BansheeEditor
 {
 {
-	GUISceneTreeView::DraggedSceneObjects::DraggedSceneObjects(UINT32 numObjects)
+	DraggedSceneObjects::DraggedSceneObjects(UINT32 numObjects)
 		:numObjects(numObjects)
 		:numObjects(numObjects)
 	{
 	{
 		objects = cm_newN<HSceneObject>(numObjects);
 		objects = cm_newN<HSceneObject>(numObjects);
 	}
 	}
 
 
-	GUISceneTreeView::DraggedSceneObjects::~DraggedSceneObjects()
+	DraggedSceneObjects::~DraggedSceneObjects()
 	{
 	{
 		cm_deleteN(objects, numObjects);
 		cm_deleteN(objects, numObjects);
 		objects = nullptr;
 		objects = nullptr;

+ 7 - 0
BansheeEditor/Source/DbgEditorWidget2.cpp

@@ -14,6 +14,8 @@
 #include "BsGUIVector4Field.h"
 #include "BsGUIVector4Field.h"
 #include "BsGUIToggleField.h"
 #include "BsGUIToggleField.h"
 #include "BsGUIColorField.h"
 #include "BsGUIColorField.h"
+#include "BsGUIGameObjectField.h"
+#include "BsGUIButton.h"
 #include "BsGUIFoldout.h"
 #include "BsGUIFoldout.h"
 #include "BsGUISpace.h"
 #include "BsGUISpace.h"
 #include "CmHString.h"
 #include "CmHString.h"
@@ -39,8 +41,11 @@ namespace BansheeEditor
 		GUIToggleField* toggleField = GUIToggleField::create(getParentWidget(), HString(L"Toggle 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)));
 		GUIColorField* colorField = GUIColorField::create(getParentWidget(), HString(L"Color Field"), GUIOptions(GUIOption::fixedWidth(200)));
 		GUIFoldout* foldout = GUIFoldout::create(getParentWidget(), GUIOptions(GUIOption::fixedWidth(200)));
 		GUIFoldout* foldout = GUIFoldout::create(getParentWidget(), GUIOptions(GUIOption::fixedWidth(200)));
+		GUIGameObjectField* gameObjectField = GUIGameObjectField::create(getParentWidget(), HString(L"Object Field"), GUIOptions(GUIOption::fixedWidth(200)));
 		colorField->setValue(Color::Red);
 		colorField->setValue(Color::Red);
 
 
+		GUIButton* button = GUIButton::create(getParentWidget(), HString(L"Testing"), GUIOptions(GUIOption::fixedWidth(100)));
+
 		layout.addElement(intField);
 		layout.addElement(intField);
 		layout.addElement(floatField);
 		layout.addElement(floatField);
 		layout.addElement(textField);
 		layout.addElement(textField);
@@ -50,6 +55,8 @@ namespace BansheeEditor
 		layout.addElement(toggleField);
 		layout.addElement(toggleField);
 		layout.addElement(colorField);
 		layout.addElement(colorField);
 		layout.addElement(foldout);
 		layout.addElement(foldout);
+		layout.addElement(button);
+		layout.addElement(gameObjectField);
 
 
 		layout.addFlexibleSpace();
 		layout.addFlexibleSpace();
 	}
 	}

+ 1 - 0
BansheeEngine/Include/BsBuiltinResources.h

@@ -55,6 +55,7 @@ namespace BansheeEngine
 
 
 		static const CM::WString ButtonNormalTex;
 		static const CM::WString ButtonNormalTex;
 		static const CM::WString ButtonHoverTex;
 		static const CM::WString ButtonHoverTex;
+		static const CM::WString ButtonActiveTex;
 
 
 		static const CM::WString ToggleNormalTex;
 		static const CM::WString ToggleNormalTex;
 		static const CM::WString ToggleHoverTex;
 		static const CM::WString ToggleHoverTex;

+ 1 - 0
BansheeEngine/Include/BsGUIContent.h

@@ -6,6 +6,7 @@ namespace BansheeEngine
 	class BS_EXPORT GUIContent
 	class BS_EXPORT GUIContent
 	{
 	{
 	public:
 	public:
+		GUIContent();
 		explicit GUIContent(const CM::HString& text);
 		explicit GUIContent(const CM::HString& text);
 		GUIContent(const CM::HString& text, const CM::HString& tooltip);
 		GUIContent(const CM::HString& text, const CM::HString& tooltip);
 
 

+ 9 - 12
BansheeEngine/Source/BsBuiltinResources.cpp

@@ -29,6 +29,7 @@ namespace BansheeEngine
 
 
 	const WString BuiltinResources::ButtonNormalTex = L"ButtonNormal.psd";
 	const WString BuiltinResources::ButtonNormalTex = L"ButtonNormal.psd";
 	const WString BuiltinResources::ButtonHoverTex = L"ButtonHover.psd";
 	const WString BuiltinResources::ButtonHoverTex = L"ButtonHover.psd";
+	const WString BuiltinResources::ButtonActiveTex = L"ButtonActive.psd";
 
 
 	const WString BuiltinResources::ToggleNormalTex = L"ToggleNormal.psd";
 	const WString BuiltinResources::ToggleNormalTex = L"ToggleNormal.psd";
 	const WString BuiltinResources::ToggleHoverTex = L"ToggleHover.psd";
 	const WString BuiltinResources::ToggleHoverTex = L"ToggleHover.psd";
@@ -197,19 +198,15 @@ namespace BansheeEngine
 		GUIElementStyle buttonStyle;
 		GUIElementStyle buttonStyle;
 		buttonStyle.normal.texture = getSkinTexture(ButtonNormalTex);
 		buttonStyle.normal.texture = getSkinTexture(ButtonNormalTex);
 		buttonStyle.hover.texture = getSkinTexture(ButtonHoverTex);
 		buttonStyle.hover.texture = getSkinTexture(ButtonHoverTex);
-		buttonStyle.active.texture = buttonStyle.hover.texture;
-		buttonStyle.border.left = 5;
-		buttonStyle.border.right = 5;
-		buttonStyle.border.top = 5;
-		buttonStyle.border.bottom = 5;
-		buttonStyle.margins.left = 4;
-		buttonStyle.margins.right = 4;
-		buttonStyle.margins.top = 4;
-		buttonStyle.margins.bottom = 4;
-		buttonStyle.contentOffset.left = 2;
-		buttonStyle.contentOffset.right = 2;
+		buttonStyle.active.texture = getSkinTexture(ButtonActiveTex);
+		buttonStyle.border.left = 6;
+		buttonStyle.border.right = 6;
+		buttonStyle.border.top = 6;
+		buttonStyle.border.bottom = 6;
+		buttonStyle.contentOffset.left = 3;
+		buttonStyle.contentOffset.right = 3;
 		buttonStyle.fixedHeight = true;
 		buttonStyle.fixedHeight = true;
-		buttonStyle.height = 21;
+		buttonStyle.height = 15;
 		buttonStyle.minWidth = 50;
 		buttonStyle.minWidth = 50;
 		buttonStyle.font = font;
 		buttonStyle.font = font;
 		buttonStyle.fontSize = DefaultFontSize;
 		buttonStyle.fontSize = DefaultFontSize;

+ 4 - 0
BansheeEngine/Source/BsGUIContent.cpp

@@ -4,6 +4,10 @@ using namespace CamelotFramework;
 
 
 namespace BansheeEngine
 namespace BansheeEngine
 {
 {
+	GUIContent::GUIContent()
+		:mText(L"")
+	{ }
+
 	GUIContent::GUIContent(const CM::HString& text)
 	GUIContent::GUIContent(const CM::HString& text)
 		:mText(text)
 		:mText(text)
 	{ }
 	{ }

+ 1 - 0
CamelotCore/Include/CmGameObjectManager.h

@@ -16,6 +16,7 @@ namespace CamelotFramework
 		void unregisterObject(const GameObjectHandleBase& object);
 		void unregisterObject(const GameObjectHandleBase& object);
 
 
 		GameObjectHandleBase getObject(UINT64 id) const;
 		GameObjectHandleBase getObject(UINT64 id) const;
+		bool tryGetObject(UINT64 id, GameObjectHandleBase& object) const;
 		bool objectExists(UINT64 id) const;
 		bool objectExists(UINT64 id) const;
 
 
 		/************************************************************************/
 		/************************************************************************/

+ 13 - 0
CamelotCore/Source/CmGameObjectManager.cpp

@@ -22,6 +22,19 @@ namespace CamelotFramework
 		return nullptr;
 		return nullptr;
 	}
 	}
 
 
+	bool GameObjectManager::tryGetObject(UINT64 id, GameObjectHandleBase& object) const
+	{
+		auto iterFind = mObjects.find(id);
+
+		if(iterFind != mObjects.end())
+		{
+			object = iterFind->second;
+			return true;
+		}
+
+		return false;
+	}
+
 	bool GameObjectManager::objectExists(UINT64 id) const 
 	bool GameObjectManager::objectExists(UINT64 id) const 
 	{ 
 	{ 
 		return mObjects.find(id) != mObjects.end(); 
 		return mObjects.find(id) != mObjects.end(); 

+ 6 - 0
Inspector.txt

@@ -19,6 +19,12 @@ 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)
+
+
 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...
 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...
 
 
 GUIElement has GetChild/GetNumChildren, which isn't really useful for elements like GUIToggle, GUIButton, etc.
 GUIElement has GetChild/GetNumChildren, which isn't really useful for elements like GUIToggle, GUIButton, etc.