Преглед на файлове

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 преди 12 години
родител
ревизия
34ab708547

+ 4 - 1
BansheeEngine/Include/BsGUIElement.h

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

+ 0 - 4
BansheeEngine/Include/BsGUIElementBase.h

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

+ 4 - 4
BansheeEngine/Source/BsGUIArea.cpp

@@ -15,13 +15,13 @@ namespace BansheeEngine
 
 		if(width <= 0)
 		{
-			mWidth = mWidget.getTarget()->getWidth();
+			mWidth = mWidget.getTarget()->getWidth() - mX;
 			mResizeWidthWithWindow = true;
 		}
 
 		if(height <= 0)
 		{
-			mHeight = mWidget.getTarget()->getHeight();
+			mHeight = mWidget.getTarget()->getHeight() - mY;
 			mResizeHeightWithWindow = true;
 		}
 
@@ -70,10 +70,10 @@ namespace BansheeEngine
 	void GUIArea::notifyWindowResized(UINT32 newWidth, UINT32 newHeight)
 	{
 		if(mResizeWidthWithWindow)
-			mWidth = newWidth;
+			mWidth = newWidth - mX;
 
 		if(mResizeHeightWithWindow)
-			mHeight = newHeight;
+			mHeight = newHeight - mY;
 
 		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)
 		:mParent(parent), mLayoutOptions(layoutOptions), mWidth(0), mHeight(0), mDepth(0), mStyle(style),
-		mAcceptsKeyboardFocus(acceptsKeyboardFocus)
+		mAcceptsKeyboardFocus(acceptsKeyboardFocus), mParentLayout(nullptr)
 	{
 		mParent.registerElement(this);
 	}

+ 4 - 13
BansheeEngine/Source/BsGUIElementBase.cpp

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

+ 4 - 1
BansheeEngine/Source/BsGUILayout.cpp

@@ -23,7 +23,10 @@ namespace BansheeEngine
 			if(child->_getType() != GUIElementBase::Type::Element)
 				cm_delete<PoolAlloc>(child);
 			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 "BsGUISkin.h"
 #include "BsGUIButton.h"
+#include "BsGUISpace.h"
 #include "CmException.h"
 
 using namespace CamelotFramework;
@@ -19,10 +20,12 @@ namespace BansheeEngine
 
 		GUIButton* upBtn = GUIButton::create(parent, L"", parent.getSkin()->getStyle("ScrollUpBtn"));
 		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->addSpace(2);
 		mLayout->addElement(handleBtn); // We might want a special element for this?
+		mLayout->addSpace(2);
 		mLayout->addElement(downBtn);
 	}
 

+ 6 - 5
CamelotClient/BsGUITabbedTitleBar.cpp

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

+ 1 - 1
CamelotClient/CmEditorWindow.cpp

@@ -66,7 +66,7 @@ namespace BansheeEditor
 
 		//// 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();
 		//
 		//mDbgLabel = GUILabel::create(*mGUI, "Testing test");