Explorar o código

Updated how are dirty flags on GUIElementBase changed
Removed parent layout from GUIElementBase and moved it to GUIElement because only GUIElement uses it
Fixed an issue with auto-resizing GUIAreas, where the area would end up being larger than the widget

Marko Pintera %!s(int64=12) %!d(string=hai) anos
pai
achega
34ab708547

+ 4 - 1
BansheeEngine/Include/BsGUIElement.h

@@ -90,13 +90,15 @@ namespace BansheeEngine
 		void _setWidth(CM::UINT32 width);
 		void _setWidth(CM::UINT32 width);
 		void _setHeight(CM::UINT32 height);
 		void _setHeight(CM::UINT32 height);
 		void _setClipRect(const CM::Rect& clipRect);
 		void _setClipRect(const CM::Rect& clipRect);
+		void _setParentLayout(GUILayout* layout) { mParentLayout = layout; }
 		virtual void _setFocus(bool focus) {}
 		virtual void _setFocus(bool focus) {}
-
+		
 		CM::UINT32 _getWidth() const { return mWidth; }
 		CM::UINT32 _getWidth() const { return mWidth; }
 		CM::UINT32 _getHeight() const { return mHeight; }
 		CM::UINT32 _getHeight() const { return mHeight; }
 		CM::Int2 _getOffset() const { return mOffset; }
 		CM::Int2 _getOffset() const { return mOffset; }
 		virtual CM::UINT32 _getRenderElementDepth(CM::UINT32 renderElementIdx) const { return _getDepth(); }
 		virtual CM::UINT32 _getRenderElementDepth(CM::UINT32 renderElementIdx) const { return _getDepth(); }
 		Type _getType() const { return GUIElementBase::Type::Element; }
 		Type _getType() const { return GUIElementBase::Type::Element; }
+		GUILayout* _getParentLayout() const { return mParentLayout; }
 
 
 		const CM::Rect& _getBounds() const { return mBounds; }
 		const CM::Rect& _getBounds() const { return mBounds; }
 		CM::UINT32 _getDepth() const { return mDepth; }
 		CM::UINT32 _getDepth() const { return mDepth; }
@@ -119,6 +121,7 @@ namespace BansheeEngine
 		static GUILayoutOptions getDefaultLayoutOptions(const GUIElementStyle* style);
 		static GUILayoutOptions getDefaultLayoutOptions(const GUIElementStyle* style);
 
 
 		GUIWidget& mParent;
 		GUIWidget& mParent;
+		GUILayout* mParentLayout;
 		GUILayoutOptions mLayoutOptions;
 		GUILayoutOptions mLayoutOptions;
 		CM::Rect mBounds;
 		CM::Rect mBounds;
 
 

+ 0 - 4
BansheeEngine/Include/BsGUIElementBase.h

@@ -37,9 +37,6 @@ namespace BansheeEngine
 		virtual CM::UINT32 _getOptimalHeight() const = 0;
 		virtual CM::UINT32 _getOptimalHeight() const = 0;
 		virtual Type _getType() const = 0;
 		virtual Type _getType() const = 0;
 
 
-		GUILayout* _getParentLayout() const { return mParentLayout; }
-		void _setParentLayout(GUILayout* layout) { mParentLayout = layout; }
-
 		void _markAsClean() { mIsDirty = 0; }
 		void _markAsClean() { mIsDirty = 0; }
 		virtual void _setFocus(bool focus) {}
 		virtual void _setFocus(bool focus) {}
 
 
@@ -64,7 +61,6 @@ namespace BansheeEngine
 		GUILayout& insertLayoutXInternal(CM::UINT32 idx);
 		GUILayout& insertLayoutXInternal(CM::UINT32 idx);
 		GUILayout& insertLayoutYInternal(CM::UINT32 idx);
 		GUILayout& insertLayoutYInternal(CM::UINT32 idx);
 
 
-		GUILayout* mParentLayout;
 		CM::Vector<GUIElementBase*>::type mChildren;	
 		CM::Vector<GUIElementBase*>::type mChildren;	
 		CM::UINT8 mIsDirty;
 		CM::UINT8 mIsDirty;
 	};
 	};

+ 4 - 4
BansheeEngine/Source/BsGUIArea.cpp

@@ -15,13 +15,13 @@ namespace BansheeEngine
 
 
 		if(width <= 0)
 		if(width <= 0)
 		{
 		{
-			mWidth = mWidget.getTarget()->getWidth();
+			mWidth = mWidget.getTarget()->getWidth() - mX;
 			mResizeWidthWithWindow = true;
 			mResizeWidthWithWindow = true;
 		}
 		}
 
 
 		if(height <= 0)
 		if(height <= 0)
 		{
 		{
-			mHeight = mWidget.getTarget()->getHeight();
+			mHeight = mWidget.getTarget()->getHeight() - mY;
 			mResizeHeightWithWindow = true;
 			mResizeHeightWithWindow = true;
 		}
 		}
 
 
@@ -70,10 +70,10 @@ namespace BansheeEngine
 	void GUIArea::notifyWindowResized(UINT32 newWidth, UINT32 newHeight)
 	void GUIArea::notifyWindowResized(UINT32 newWidth, UINT32 newHeight)
 	{
 	{
 		if(mResizeWidthWithWindow)
 		if(mResizeWidthWithWindow)
-			mWidth = newWidth;
+			mWidth = newWidth - mX;
 
 
 		if(mResizeHeightWithWindow)
 		if(mResizeHeightWithWindow)
-			mHeight = newHeight;
+			mHeight = newHeight - mY;
 
 
 		if(mResizeWidthWithWindow || mResizeHeightWithWindow)
 		if(mResizeWidthWithWindow || mResizeHeightWithWindow)
 		{
 		{

+ 1 - 1
BansheeEngine/Source/BsGUIElement.cpp

@@ -10,7 +10,7 @@ namespace BansheeEngine
 {
 {
 	GUIElement::GUIElement(GUIWidget& parent, const GUIElementStyle* style, const GUILayoutOptions& layoutOptions, bool acceptsKeyboardFocus)
 	GUIElement::GUIElement(GUIWidget& parent, const GUIElementStyle* style, const GUILayoutOptions& layoutOptions, bool acceptsKeyboardFocus)
 		:mParent(parent), mLayoutOptions(layoutOptions), mWidth(0), mHeight(0), mDepth(0), mStyle(style),
 		:mParent(parent), mLayoutOptions(layoutOptions), mWidth(0), mHeight(0), mDepth(0), mStyle(style),
-		mAcceptsKeyboardFocus(acceptsKeyboardFocus)
+		mAcceptsKeyboardFocus(acceptsKeyboardFocus), mParentLayout(nullptr)
 	{
 	{
 		mParent.registerElement(this);
 		mParent.registerElement(this);
 	}
 	}

+ 4 - 13
BansheeEngine/Source/BsGUIElementBase.cpp

@@ -9,7 +9,7 @@ using namespace CamelotFramework;
 namespace BansheeEngine
 namespace BansheeEngine
 {
 {
 	GUIElementBase::GUIElementBase()
 	GUIElementBase::GUIElementBase()
-		:mIsDirty(true), mParentLayout(nullptr)
+		:mIsDirty(true)
 	{
 	{
 
 
 	}
 	}
@@ -21,11 +21,8 @@ namespace BansheeEngine
 
 
 		for(auto& child : mChildren)
 		for(auto& child : mChildren)
 		{
 		{
-			if(child->_getType() == Type::Layout)
-			{
-				if(child->_isContentDirty())
-					return true;
-			}
+			if(child->_isContentDirty())
+				return true;
 		}
 		}
 
 
 		return false;
 		return false;
@@ -38,13 +35,7 @@ namespace BansheeEngine
 
 
 	void GUIElementBase::markContentAsDirty() 
 	void GUIElementBase::markContentAsDirty() 
 	{ 
 	{ 
-		if(!_isContentDirty())
-		{
-			if(mParentLayout != nullptr)
-				mParentLayout->markContentAsDirty();
-
-			mIsDirty |= 0x01; 
-		}
+		mIsDirty |= 0x01; 
 	}
 	}
 
 
 	void GUIElementBase::markMeshAsDirty()
 	void GUIElementBase::markMeshAsDirty()

+ 4 - 1
BansheeEngine/Source/BsGUILayout.cpp

@@ -23,7 +23,10 @@ namespace BansheeEngine
 			if(child->_getType() != GUIElementBase::Type::Element)
 			if(child->_getType() != GUIElementBase::Type::Element)
 				cm_delete<PoolAlloc>(child);
 				cm_delete<PoolAlloc>(child);
 			else
 			else
-				child->_setParentLayout(nullptr);
+			{
+				GUIElement* element = static_cast<GUIElement*>(child);
+				element->_setParentLayout(nullptr);
+			}
 		}
 		}
 	}
 	}
 
 

+ 4 - 1
BansheeEngine/Source/BsGUIScrollBarVert.cpp

@@ -6,6 +6,7 @@
 #include "BsGUILayout.h"
 #include "BsGUILayout.h"
 #include "BsGUISkin.h"
 #include "BsGUISkin.h"
 #include "BsGUIButton.h"
 #include "BsGUIButton.h"
+#include "BsGUISpace.h"
 #include "CmException.h"
 #include "CmException.h"
 
 
 using namespace CamelotFramework;
 using namespace CamelotFramework;
@@ -19,10 +20,12 @@ namespace BansheeEngine
 
 
 		GUIButton* upBtn = GUIButton::create(parent, L"", parent.getSkin()->getStyle("ScrollUpBtn"));
 		GUIButton* upBtn = GUIButton::create(parent, L"", parent.getSkin()->getStyle("ScrollUpBtn"));
 		GUIButton* downBtn = GUIButton::create(parent, L"", parent.getSkin()->getStyle("ScrollDownBtn"));
 		GUIButton* downBtn = GUIButton::create(parent, L"", parent.getSkin()->getStyle("ScrollDownBtn"));
-		GUIButton* handleBtn = GUIButton::create(parent, L"", parent.getSkin()->getStyle("ScrollBarVertBtn"));
+		GUIButton* handleBtn = GUIButton::create(parent, L"", GUILayoutOptions::expandableY(6), parent.getSkin()->getStyle("ScrollBarVertBtn"));
 
 
 		mLayout->addElement(upBtn);
 		mLayout->addElement(upBtn);
+		mLayout->addSpace(2);
 		mLayout->addElement(handleBtn); // We might want a special element for this?
 		mLayout->addElement(handleBtn); // We might want a special element for this?
+		mLayout->addSpace(2);
 		mLayout->addElement(downBtn);
 		mLayout->addElement(downBtn);
 	}
 	}
 
 

+ 6 - 5
CamelotClient/BsGUITabbedTitleBar.cpp

@@ -4,6 +4,7 @@
 #include "BsGUITexture.h"
 #include "BsGUITexture.h"
 #include "BsGUIButton.h"
 #include "BsGUIButton.h"
 #include "BsGUIToggle.h"
 #include "BsGUIToggle.h"
+#include "BsGUISpace.h"
 #include "BsGUIWindowMover.h"
 #include "BsGUIWindowMover.h"
 #include "BsEngineGUI.h"
 #include "BsEngineGUI.h"
 #include "CmMath.h"
 #include "CmMath.h"
@@ -63,9 +64,9 @@ namespace BansheeEditor
 
 
 		GUIArea* backgroundArea = GUIArea::create(*this, 0, 1, 0, 13, 500);
 		GUIArea* backgroundArea = GUIArea::create(*this, 0, 1, 0, 13, 500);
 		GUIWindowMover* titleBarBg = GUIWindowMover::create(*this, getSkin()->getStyle("TitleBarBackground"));
 		GUIWindowMover* titleBarBg = GUIWindowMover::create(*this, getSkin()->getStyle("TitleBarBackground"));
-		GUIFixedSpace& space1 = backgroundArea->getLayout().addSpace(1);
+		backgroundArea->getLayout().addSpace(1);
 		backgroundArea->getLayout().addElement(titleBarBg);
 		backgroundArea->getLayout().addElement(titleBarBg);
-		GUIFixedSpace& space2 = backgroundArea->getLayout().addSpace(1);
+		backgroundArea->getLayout().addSpace(1);
 
 
 		mMainArea = GUIArea::create(*this, 0, 1, 0, 13, 499);
 		mMainArea = GUIArea::create(*this, 0, 1, 0, 13, 499);
 
 
@@ -75,13 +76,13 @@ namespace BansheeEditor
 		mMinBtn = GUIButton::create(*this, L"", getSkin()->getStyle("WinMinimizeBtn"));
 		mMinBtn = GUIButton::create(*this, L"", getSkin()->getStyle("WinMinimizeBtn"));
 		mCloseBtn = GUIButton::create(*this, L"", getSkin()->getStyle("WinCloseBtn"));
 		mCloseBtn = GUIButton::create(*this, L"", getSkin()->getStyle("WinCloseBtn"));
 
 
-		GUIFixedSpace& space3 = mMainArea->getLayout().addSpace(1);
+		mMainArea->getLayout().addSpace(1);
 		mMainLayout = &mMainArea->getLayout().addLayoutX();
 		mMainLayout = &mMainArea->getLayout().addLayoutX();
 		mMainLayout->addElement(dragDropElement);
 		mMainLayout->addElement(dragDropElement);
 		mMainLayout->addElement(mMinBtn);
 		mMainLayout->addElement(mMinBtn);
-		GUIFixedSpace& space4 = mMainLayout->addSpace(3);
+		mMainLayout->addSpace(3);
 		mMainLayout->addElement(mCloseBtn);
 		mMainLayout->addElement(mCloseBtn);
-		GUIFixedSpace& space5 = mMainArea->getLayout().addSpace(3);
+		mMainArea->getLayout().addSpace(3);
 
 
 		addTab("TEST!");
 		addTab("TEST!");
 	}
 	}

+ 1 - 1
CamelotClient/CmEditorWindow.cpp

@@ -66,7 +66,7 @@ namespace BansheeEditor
 
 
 		//// DEBUG
 		//// DEBUG
 		
 		
-		GUIArea* dbgArea = GUIArea::create(*mGUI, 5, 13, 190, 0, 475);
+		GUIArea* dbgArea = GUIArea::create(*mGUI, 5, 14, 190, 0, 475);
 		GUILayout& layout = dbgArea->getLayout();
 		GUILayout& layout = dbgArea->getLayout();
 		//
 		//
 		//mDbgLabel = GUILabel::create(*mGUI, "Testing test");
 		//mDbgLabel = GUILabel::create(*mGUI, "Testing test");