Prechádzať zdrojové kódy

Starting work on scroll bars

Marko Pintera 12 rokov pred
rodič
commit
df62820663

+ 4 - 0
BansheeEngine/BansheeEngine.vcxproj

@@ -162,6 +162,8 @@
     <ClInclude Include="Include\BsGUILayoutX.h" />
     <ClInclude Include="Include\BsGUILayout.h" />
     <ClInclude Include="Include\BsGUILayoutY.h" />
+    <ClInclude Include="Include\BsGUIScrollBarHorz.h" />
+    <ClInclude Include="Include\BsGUIScrollBarVert.h" />
     <ClInclude Include="Include\BsGUISpace.h" />
     <ClInclude Include="Include\BsGUITexture.h" />
     <ClInclude Include="Include\BsGUIToggle.h" />
@@ -212,6 +214,8 @@
     <ClCompile Include="Source\BsGUIManager.cpp" />
     <ClCompile Include="Source\BsGUIMaterialManager.cpp" />
     <ClCompile Include="Source\BsGUIMouseEvent.cpp" />
+    <ClCompile Include="Source\BsGUIScrollBarHorz.cpp" />
+    <ClCompile Include="Source\BsGUIScrollBarVert.cpp" />
     <ClCompile Include="Source\BsGUISkin.cpp" />
     <ClCompile Include="Source\BsGUITexture.cpp" />
     <ClCompile Include="Source\BsGUIToggle.cpp" />

+ 12 - 0
BansheeEngine/BansheeEngine.vcxproj.filters

@@ -174,6 +174,12 @@
     <ClInclude Include="Include\BsGUIElementBase.h">
       <Filter>Header Files\GUI</Filter>
     </ClInclude>
+    <ClInclude Include="Include\BsGUIScrollBarVert.h">
+      <Filter>Header Files\GUI</Filter>
+    </ClInclude>
+    <ClInclude Include="Include\BsGUIScrollBarHorz.h">
+      <Filter>Header Files\GUI</Filter>
+    </ClInclude>
   </ItemGroup>
   <ItemGroup>
     <ClCompile Include="Source\BsGUIElement.cpp">
@@ -293,5 +299,11 @@
     <ClCompile Include="Source\BsGUIElementBase.cpp">
       <Filter>Source Files\GUI</Filter>
     </ClCompile>
+    <ClCompile Include="Source\BsGUIScrollBarVert.cpp">
+      <Filter>Source Files\GUI</Filter>
+    </ClCompile>
+    <ClCompile Include="Source\BsGUIScrollBarHorz.cpp">
+      <Filter>Source Files\GUI</Filter>
+    </ClCompile>
   </ItemGroup>
 </Project>

+ 24 - 0
BansheeEngine/Include/BsEngineGUI.h

@@ -42,5 +42,29 @@ namespace BansheeEngine
 		static const CM::String InputBoxNormalTex;
 		static const CM::String InputBoxHoverTex;
 		static const CM::String InputBoxFocusedTex;
+
+		static const CM::String ScrollBarUpNormalTex;
+		static const CM::String ScrollBarUpHoverTex;
+		static const CM::String ScrollBarUpActiveTex;
+
+		static const CM::String ScrollBarDownNormalTex;
+		static const CM::String ScrollBarDownHoverTex;
+		static const CM::String ScrollBarDownActiveTex;
+
+		static const CM::String ScrollBarLeftNormalTex;
+		static const CM::String ScrollBarLeftHoverTex;
+		static const CM::String ScrollBarLeftActiveTex;
+
+		static const CM::String ScrollBarRightNormalTex;
+		static const CM::String ScrollBarRightHoverTex;
+		static const CM::String ScrollBarRightActiveTex;
+
+		static const CM::String ScrollBarHandleHorzNormalTex;
+		static const CM::String ScrollBarHandleHorzHoverTex;
+		static const CM::String ScrollBarHandleHorzActiveTex;
+
+		static const CM::String ScrollBarHandleVertNormalTex;
+		static const CM::String ScrollBarHandleVertHoverTex;
+		static const CM::String ScrollBarHandleVertActiveTex;
 	};
 }

+ 54 - 0
BansheeEngine/Include/BsGUIScrollBarHorz.h

@@ -0,0 +1,54 @@
+#pragma once
+
+#include "BsPrerequisites.h"
+#include "BsGUIElement.h"
+
+namespace BansheeEngine
+{
+	class BS_EXPORT GUIScrollBarHorz : public GUIElement
+	{
+	public:
+		static const CM::String& getGUITypeName();
+
+		static GUIScrollBarHorz* create(GUIWidget& parent, const GUIElementStyle* style = nullptr);
+		static GUIScrollBarHorz* create(GUIWidget& parent, const GUILayoutOptions& layoutOptions, const GUIElementStyle* style = nullptr);
+
+		void setText(const CM::WString& text);
+
+	protected:
+		~GUIScrollBarHorz();
+
+		/**
+		 * @copydoc GUIElement::getNumRenderElements()
+		 */
+		virtual CM::UINT32 getNumRenderElements() const;
+
+		/**
+		 * @copydoc GUIElement::getMaterial()
+		 */
+		virtual const CM::HMaterial& getMaterial(CM::UINT32 renderElementIdx) const;
+
+		/**
+		 * @copydoc GUIElement::getNumQuads()
+		 */
+		virtual CM::UINT32 getNumQuads(CM::UINT32 renderElementIdx) const;
+
+		/**
+		 * @copydoc GUIElement::fillBuffer()
+		 */
+		virtual void fillBuffer(CM::UINT8* vertices, CM::UINT8* uv, CM::UINT32* indices, CM::UINT32 startingQuad, 
+			CM::UINT32 maxNumQuads, CM::UINT32 vertexStride, CM::UINT32 indexStride, CM::UINT32 renderElementIdx) const;
+
+		/**
+		 * @copydoc GUIElement::updateRenderElementsInternal()
+		 */
+		virtual void updateRenderElementsInternal();
+
+		virtual CM::UINT32 _getOptimalWidth() const;
+		virtual CM::UINT32 _getOptimalHeight() const;
+	private:
+		GUIScrollBarHorz(GUIWidget& parent, const GUIElementStyle* style, const GUILayoutOptions& layoutOptions);
+
+		GUILayout* mLayout;
+	};
+}

+ 54 - 0
BansheeEngine/Include/BsGUIScrollBarVert.h

@@ -0,0 +1,54 @@
+#pragma once
+
+#include "BsPrerequisites.h"
+#include "BsGUIElement.h"
+
+namespace BansheeEngine
+{
+	class BS_EXPORT GUIScrollBarVert : public GUIElement
+	{
+	public:
+		static const CM::String& getGUITypeName();
+
+		static GUIScrollBarVert* create(GUIWidget& parent, const GUIElementStyle* style = nullptr);
+		static GUIScrollBarVert* create(GUIWidget& parent, const GUILayoutOptions& layoutOptions, const GUIElementStyle* style = nullptr);
+
+		void setText(const CM::WString& text);
+
+	protected:
+		~GUIScrollBarVert();
+
+		/**
+		 * @copydoc GUIElement::getNumRenderElements()
+		 */
+		virtual CM::UINT32 getNumRenderElements() const;
+
+		/**
+		 * @copydoc GUIElement::getMaterial()
+		 */
+		virtual const CM::HMaterial& getMaterial(CM::UINT32 renderElementIdx) const;
+
+		/**
+		 * @copydoc GUIElement::getNumQuads()
+		 */
+		virtual CM::UINT32 getNumQuads(CM::UINT32 renderElementIdx) const;
+
+		/**
+		 * @copydoc GUIElement::fillBuffer()
+		 */
+		virtual void fillBuffer(CM::UINT8* vertices, CM::UINT8* uv, CM::UINT32* indices, CM::UINT32 startingQuad, 
+			CM::UINT32 maxNumQuads, CM::UINT32 vertexStride, CM::UINT32 indexStride, CM::UINT32 renderElementIdx) const;
+
+		/**
+		 * @copydoc GUIElement::updateRenderElementsInternal()
+		 */
+		virtual void updateRenderElementsInternal();
+
+		virtual CM::UINT32 _getOptimalWidth() const;
+		virtual CM::UINT32 _getOptimalHeight() const;
+	private:
+		GUIScrollBarVert(GUIWidget& parent, const GUIElementStyle* style, const GUILayoutOptions& layoutOptions);
+
+		GUILayout* mLayout;
+	};
+}

+ 24 - 0
BansheeEngine/Source/BsEngineGUI.cpp

@@ -42,6 +42,30 @@ namespace BansheeEngine
 	const String EngineGUI::InputBoxHoverTex = "C:\\Projects\\BansheeEngine\\Data\\Editor\\Skin\\InputBoxHover.psd";
 	const String EngineGUI::InputBoxFocusedTex = "C:\\Projects\\BansheeEngine\\Data\\Editor\\Skin\\InputBoxFocused.psd";
 
+	const String EngineGUI::ScrollBarUpNormalTex = "C:\\Projects\\BansheeEngine\\Data\\Editor\\Skin\\ScrollBarUpNormal.psd";
+	const String EngineGUI::ScrollBarUpHoverTex = "C:\\Projects\\BansheeEngine\\Data\\Editor\\Skin\\ScrollBarUpHover.psd";
+	const String EngineGUI::ScrollBarUpActiveTex = "C:\\Projects\\BansheeEngine\\Data\\Editor\\Skin\\ScrollBarUpActive.psd";
+
+	const String EngineGUI::ScrollBarDownNormalTex = "C:\\Projects\\BansheeEngine\\Data\\Editor\\Skin\\ScrollBarDownNormal.psd";
+	const String EngineGUI::ScrollBarDownHoverTex = "C:\\Projects\\BansheeEngine\\Data\\Editor\\Skin\\ScrollBarDownHover.psd";
+	const String EngineGUI::ScrollBarDownActiveTex = "C:\\Projects\\BansheeEngine\\Data\\Editor\\Skin\\ScrollBarDownActive.psd";
+
+	const String EngineGUI::ScrollBarLeftNormalTex = "C:\\Projects\\BansheeEngine\\Data\\Editor\\Skin\\ScrollBarLeftNormal.psd";
+	const String EngineGUI::ScrollBarLeftHoverTex = "C:\\Projects\\BansheeEngine\\Data\\Editor\\Skin\\ScrollBarLeftHover.psd";
+	const String EngineGUI::ScrollBarLeftActiveTex = "C:\\Projects\\BansheeEngine\\Data\\Editor\\Skin\\ScrollBarLeftActive.psd";
+
+	const String EngineGUI::ScrollBarRightNormalTex = "C:\\Projects\\BansheeEngine\\Data\\Editor\\Skin\\ScrollBarRightNormal.psd";
+	const String EngineGUI::ScrollBarRightHoverTex = "C:\\Projects\\BansheeEngine\\Data\\Editor\\Skin\\ScrollBarRightHover.psd";
+	const String EngineGUI::ScrollBarRightActiveTex = "C:\\Projects\\BansheeEngine\\Data\\Editor\\Skin\\ScrollBarRightActive.psd";
+
+	const String EngineGUI::ScrollBarHandleHorzNormalTex = "C:\\Projects\\BansheeEngine\\Data\\Editor\\Skin\\ScrollBarHorzHandleNormal.psd";
+	const String EngineGUI::ScrollBarHandleHorzHoverTex = "C:\\Projects\\BansheeEngine\\Data\\Editor\\Skin\\ScrollBarHorzHandleHover.psd";
+	const String EngineGUI::ScrollBarHandleHorzActiveTex = "C:\\Projects\\BansheeEngine\\Data\\Editor\\Skin\\ScrollBarHorzHandleActive.psd";
+
+	const String EngineGUI::ScrollBarHandleVertNormalTex = "C:\\Projects\\BansheeEngine\\Data\\Editor\\Skin\\ScrollBarVertHandleNormal.psd";
+	const String EngineGUI::ScrollBarHandleVertHoverTex = "C:\\Projects\\BansheeEngine\\Data\\Editor\\Skin\\ScrollBarVertHandleHover.psd";
+	const String EngineGUI::ScrollBarHandleVertActiveTex = "C:\\Projects\\BansheeEngine\\Data\\Editor\\Skin\\ScrollBarVertHandleActive.psd";
+
 	EngineGUI::EngineGUI()
 	{
 		// TODO - Normally I want to load this from some file

+ 83 - 0
BansheeEngine/Source/BsGUIScrollBarHorz.cpp

@@ -0,0 +1,83 @@
+#include "BsGUIScrollBarHorz.h"
+#include "BsGUIElementStyle.h"
+#include "BsGUISkin.h"
+#include "BsGUIWidget.h"
+#include "BsGUILayoutOptions.h"
+#include "BsGUILayout.h"
+#include "CmException.h"
+
+using namespace CamelotFramework;
+
+namespace BansheeEngine
+{
+	GUIScrollBarHorz::GUIScrollBarHorz(GUIWidget& parent, const GUIElementStyle* style, const GUILayoutOptions& layoutOptions)
+		:GUIElement(parent, style, layoutOptions), mLayout(nullptr)
+	{
+		// TODO - Init mLayout
+	}
+
+	GUIScrollBarHorz::~GUIScrollBarHorz()
+	{
+
+	}
+
+	UINT32 GUIScrollBarHorz::getNumRenderElements() const
+	{
+		return 0;
+	}
+
+	const HMaterial& GUIScrollBarHorz::getMaterial(UINT32 renderElementIdx) const
+	{
+		CM_EXCEPT(InternalErrorException, "Invalid render element index. This class has no render elements.");
+	}
+
+	UINT32 GUIScrollBarHorz::getNumQuads(UINT32 renderElementIdx) const
+	{
+		return 0;
+	}
+
+	void GUIScrollBarHorz::updateRenderElementsInternal()
+	{ }
+
+	UINT32 GUIScrollBarHorz::_getOptimalWidth() const
+	{
+		return mLayout->_getOptimalWidth();
+	}
+
+	UINT32 GUIScrollBarHorz::_getOptimalHeight() const
+	{
+		return mLayout->_getOptimalHeight();
+	}
+
+	void GUIScrollBarHorz::fillBuffer(UINT8* vertices, UINT8* uv, UINT32* indices, UINT32 startingQuad, UINT32 maxNumQuads, 
+		UINT32 vertexStride, UINT32 indexStride, UINT32 renderElementIdx) const
+	{ }
+
+	GUIScrollBarHorz* GUIScrollBarHorz::create(GUIWidget& parent, const GUIElementStyle* style)
+	{
+		if(style == nullptr)
+		{
+			const GUISkin* skin = parent.getSkin();
+			style = skin->getStyle(getGUITypeName());
+		}
+
+		return new (cm_alloc<GUIScrollBarHorz, PoolAlloc>()) GUIScrollBarHorz(parent, style, getDefaultLayoutOptions(style));
+	}
+
+	GUIScrollBarHorz* GUIScrollBarHorz::create(GUIWidget& parent, const GUILayoutOptions& layoutOptions, const GUIElementStyle* style)
+	{
+		if(style == nullptr)
+		{
+			const GUISkin* skin = parent.getSkin();
+			style = skin->getStyle(getGUITypeName());
+		}
+
+		return new (cm_alloc<GUIScrollBarHorz, PoolAlloc>()) GUIScrollBarHorz(parent, style, layoutOptions);
+	}
+
+	const String& GUIScrollBarHorz::getGUITypeName()
+	{
+		static String typeName = "ScrollBarHorz";
+		return typeName;
+	}
+}

+ 83 - 0
BansheeEngine/Source/BsGUIScrollBarVert.cpp

@@ -0,0 +1,83 @@
+#include "BsGUIScrollBarVert.h"
+#include "BsGUIElementStyle.h"
+#include "BsGUISkin.h"
+#include "BsGUIWidget.h"
+#include "BsGUILayoutOptions.h"
+#include "BsGUILayout.h"
+#include "CmException.h"
+
+using namespace CamelotFramework;
+
+namespace BansheeEngine
+{
+	GUIScrollBarVert::GUIScrollBarVert(GUIWidget& parent, const GUIElementStyle* style, const GUILayoutOptions& layoutOptions)
+		:GUIElement(parent, style, layoutOptions), mLayout(nullptr)
+	{
+		// TODO - Init mLayout
+	}
+
+	GUIScrollBarVert::~GUIScrollBarVert()
+	{
+
+	}
+
+	UINT32 GUIScrollBarVert::getNumRenderElements() const
+	{
+		return 0;
+	}
+
+	const HMaterial& GUIScrollBarVert::getMaterial(UINT32 renderElementIdx) const
+	{
+		CM_EXCEPT(InternalErrorException, "Invalid render element index. This class has no render elements.");
+	}
+
+	UINT32 GUIScrollBarVert::getNumQuads(UINT32 renderElementIdx) const
+	{
+		return 0;
+	}
+
+	void GUIScrollBarVert::updateRenderElementsInternal()
+	{ }
+
+	UINT32 GUIScrollBarVert::_getOptimalWidth() const
+	{
+		return mLayout->_getOptimalWidth();
+	}
+
+	UINT32 GUIScrollBarVert::_getOptimalHeight() const
+	{
+		return mLayout->_getOptimalHeight();
+	}
+
+	void GUIScrollBarVert::fillBuffer(UINT8* vertices, UINT8* uv, UINT32* indices, UINT32 startingQuad, UINT32 maxNumQuads, 
+		UINT32 vertexStride, UINT32 indexStride, UINT32 renderElementIdx) const
+	{ }
+
+	GUIScrollBarVert* GUIScrollBarVert::create(GUIWidget& parent, const GUIElementStyle* style)
+	{
+		if(style == nullptr)
+		{
+			const GUISkin* skin = parent.getSkin();
+			style = skin->getStyle(getGUITypeName());
+		}
+
+		return new (cm_alloc<GUIScrollBarVert, PoolAlloc>()) GUIScrollBarVert(parent, style, getDefaultLayoutOptions(style));
+	}
+
+	GUIScrollBarVert* GUIScrollBarVert::create(GUIWidget& parent, const GUILayoutOptions& layoutOptions, const GUIElementStyle* style)
+	{
+		if(style == nullptr)
+		{
+			const GUISkin* skin = parent.getSkin();
+			style = skin->getStyle(getGUITypeName());
+		}
+
+		return new (cm_alloc<GUIScrollBarVert, PoolAlloc>()) GUIScrollBarVert(parent, style, layoutOptions);
+	}
+
+	const String& GUIScrollBarVert::getGUITypeName()
+	{
+		static String typeName = "ScrollBarVert";
+		return typeName;
+	}
+}

+ 0 - 1
CamelotClient/CamelotClient.cpp

@@ -273,7 +273,6 @@ int CALLBACK WinMain(
 
 	//// Set the new state for the flag
 	//_CrtSetDbgFlag( tmpFlag );
-	Cursor::hide();
 
 	HTexture dbgCursor = static_resource_cast<Texture>(Importer::instance().import("C:\\CursorDbg.psd"));
 	PixelDataPtr cursorPixelData = dbgCursor->allocateSubresourceBuffer(0);