Forráskód Böngészése

Window frame focus

Marko Pintera 12 éve
szülő
commit
c4a59e1523

+ 2 - 0
BansheeEngine/Include/BsGUIWindowFrame.h

@@ -13,6 +13,8 @@ namespace BansheeEngine
 
 		static GUIWindowFrame* create(GUIWidget& parent, const GUIElementStyle* style = nullptr);
 		static GUIWindowFrame* create(GUIWidget& parent, const GUILayoutOptions& layoutOptions, const GUIElementStyle* style = nullptr);
+
+		void setFocused(bool focused);
 	protected:
 		~GUIWindowFrame();
 

+ 1 - 0
BansheeEngine/Include/BsPrerequisites.h

@@ -33,6 +33,7 @@ namespace BansheeEngine
 	class GUIButton;
 	class GUITexture;
 	class GUIToggle;
+	class GUIWindowFrame;
 	class GUISkin;
 	struct GUIElementStyle;
 	class GUIMouseEvent;

+ 0 - 3
BansheeEngine/Source/BsGUILabel.cpp

@@ -102,9 +102,6 @@ namespace BansheeEngine
 	{
 		mDesc.text = text;
 
-		mTextSprite->update(mDesc);
-		mBounds = mTextSprite->getBounds();
-
 		markAsDirty();
 	}
 

+ 10 - 0
BansheeEngine/Source/BsGUIWindowFrame.cpp

@@ -116,6 +116,16 @@ namespace BansheeEngine
 		mImageSprite->fillBuffer(vertices, uv, indices, startingQuad, maxNumQuads, vertexStride, indexStride, renderElementIdx);
 	}
 
+	void GUIWindowFrame::setFocused(bool focused)
+	{
+		if(focused)
+			mDesc.texture = mStyle->focused.texture;
+		else
+			mDesc.texture = mStyle->normal.texture;
+
+		markAsDirty();
+	}
+
 	bool GUIWindowFrame::mouseEvent(const GUIMouseEvent& ev)
 	{
 		if(ev.getType() == GUIMouseEventType::MouseMove || ev.getType() == GUIMouseEventType::MouseDrag)

+ 9 - 1
CamelotClient/BsGUIWindowFrameWidget.cpp

@@ -5,6 +5,7 @@
 #include "BsGUIWindowFrame.h"
 #include "BsEngineGUI.h"
 #include "BsGUIMouseEvent.h"
+#include "CmRenderWindow.h"
 #include "CmMath.h"
 
 using namespace CamelotFramework;
@@ -31,7 +32,9 @@ namespace BansheeEditor
 		backgroundArea->getLayout().addElement(GUITexture::create(*this, GUILayoutOptions::expandableXY(), GUIImageScaleMode::RepeatToFit, getSkin()->getStyle("WindowBackground")));
 
 		mWindowFrameArea = GUIArea::create(*this, 0, 0, 0, 0, 499);
-		mWindowFrameArea->getLayout().addElement(GUIWindowFrame::create(*this, getSkin()->getStyle("WindowFrame")));
+
+		mWindowFrame = GUIWindowFrame::create(*this, getSkin()->getStyle("WindowFrame"));
+		mWindowFrameArea->getLayout().addElement(mWindowFrame);
 	}
 
 	void WindowFrameWidget::update()
@@ -43,4 +46,9 @@ namespace BansheeEditor
 	{
 		return GUIWidget::_mouseEvent(element, ev);
 	}
+
+	void WindowFrameWidget::ownerWindowFocusChanged(CM::RenderWindow* window)
+	{
+		mWindowFrame->setFocused(window->hasFocus());
+	}
 }

+ 2 - 0
CamelotClient/BsGUIWindowFrameWidget.h

@@ -16,9 +16,11 @@ namespace BansheeEditor
 
 	protected:
 		BS::GUIArea* mWindowFrameArea;
+		BS::GUIWindowFrame* mWindowFrame;
 
 		virtual void update();
 
 		virtual bool _mouseEvent(BS::GUIElement* element, const BS::GUIMouseEvent& ev);
+		virtual void ownerWindowFocusChanged(CM::RenderWindow* window);
 	};
 }