Browse Source

Made GUIDropDownBox more generic so it accepts different styles for listbox, context menu and menu bar

Marko Pintera 12 years ago
parent
commit
cf2ec84061

+ 2 - 2
BansheeEngine/BansheeEngine.vcxproj

@@ -237,7 +237,7 @@
     <ClInclude Include="Include\BsGUICommandEvent.h" />
     <ClInclude Include="Include\BsGUICommandEvent.h" />
     <ClInclude Include="Include\BsGUIContent.h" />
     <ClInclude Include="Include\BsGUIContent.h" />
     <ClInclude Include="Include\BsGUIDropDownBox.h" />
     <ClInclude Include="Include\BsGUIDropDownBox.h" />
-    <ClInclude Include="Include\BsGUIDropDownList.h" />
+    <ClInclude Include="Include\BsGUIListBox.h" />
     <ClInclude Include="Include\BsGUIElementBase.h" />
     <ClInclude Include="Include\BsGUIElementBase.h" />
     <ClInclude Include="Include\BsGUIInputTool.h" />
     <ClInclude Include="Include\BsGUIInputTool.h" />
     <ClInclude Include="Include\BsGUIInputBox.h" />
     <ClInclude Include="Include\BsGUIInputBox.h" />
@@ -295,7 +295,7 @@
     <ClCompile Include="Source\BsGUIButton.cpp" />
     <ClCompile Include="Source\BsGUIButton.cpp" />
     <ClCompile Include="Source\BsGUIContent.cpp" />
     <ClCompile Include="Source\BsGUIContent.cpp" />
     <ClCompile Include="Source\BsGUIDropDownBox.cpp" />
     <ClCompile Include="Source\BsGUIDropDownBox.cpp" />
-    <ClCompile Include="Source\BsGUIDropDownList.cpp" />
+    <ClCompile Include="Source\BsGUIListBox.cpp" />
     <ClCompile Include="Source\BsGUIElement.cpp" />
     <ClCompile Include="Source\BsGUIElement.cpp" />
     <ClCompile Include="Source\BsGUIElementBase.cpp" />
     <ClCompile Include="Source\BsGUIElementBase.cpp" />
     <ClCompile Include="Source\BsGUIInputBox.cpp" />
     <ClCompile Include="Source\BsGUIInputBox.cpp" />

+ 6 - 6
BansheeEngine/BansheeEngine.vcxproj.filters

@@ -198,15 +198,15 @@
     <ClInclude Include="Include\BsDrawHelper3D.h">
     <ClInclude Include="Include\BsDrawHelper3D.h">
       <Filter>Header Files</Filter>
       <Filter>Header Files</Filter>
     </ClInclude>
     </ClInclude>
-    <ClInclude Include="Include\BsGUIDropDownList.h">
-      <Filter>Header Files\GUI</Filter>
-    </ClInclude>
     <ClInclude Include="Include\BsGUIDropDownBox.h">
     <ClInclude Include="Include\BsGUIDropDownBox.h">
       <Filter>Header Files\GUI</Filter>
       <Filter>Header Files\GUI</Filter>
     </ClInclude>
     </ClInclude>
     <ClInclude Include="Include\BsGUIContent.h">
     <ClInclude Include="Include\BsGUIContent.h">
       <Filter>Header Files\GUI</Filter>
       <Filter>Header Files\GUI</Filter>
     </ClInclude>
     </ClInclude>
+    <ClInclude Include="Include\BsGUIListBox.h">
+      <Filter>Header Files\GUI</Filter>
+    </ClInclude>
   </ItemGroup>
   </ItemGroup>
   <ItemGroup>
   <ItemGroup>
     <ClCompile Include="Source\BsGUIElement.cpp">
     <ClCompile Include="Source\BsGUIElement.cpp">
@@ -350,14 +350,14 @@
     <ClCompile Include="Source\BsDrawHelper3D.cpp">
     <ClCompile Include="Source\BsDrawHelper3D.cpp">
       <Filter>Source Files</Filter>
       <Filter>Source Files</Filter>
     </ClCompile>
     </ClCompile>
-    <ClCompile Include="Source\BsGUIDropDownList.cpp">
-      <Filter>Source Files\GUI</Filter>
-    </ClCompile>
     <ClCompile Include="Source\BsGUIDropDownBox.cpp">
     <ClCompile Include="Source\BsGUIDropDownBox.cpp">
       <Filter>Source Files\GUI</Filter>
       <Filter>Source Files\GUI</Filter>
     </ClCompile>
     </ClCompile>
     <ClCompile Include="Source\BsGUIContent.cpp">
     <ClCompile Include="Source\BsGUIContent.cpp">
       <Filter>Source Files\GUI</Filter>
       <Filter>Source Files\GUI</Filter>
     </ClCompile>
     </ClCompile>
+    <ClCompile Include="Source\BsGUIListBox.cpp">
+      <Filter>Source Files\GUI</Filter>
+    </ClCompile>
   </ItemGroup>
   </ItemGroup>
 </Project>
 </Project>

+ 12 - 1
BansheeEngine/Include/BsGUIDropDownBox.h

@@ -30,6 +30,17 @@ namespace BansheeEngine
 		Type mType; 
 		Type mType; 
 	};
 	};
 
 
+	enum class GUIDropDownType
+	{
+		ListBox,
+		ContextMenu,
+		MenuBar
+	};
+
+	/**
+	 * @brief	This is a generic GUI drop down box class that can be used for:
+	 * 			list boxes, menu bars or context menus.
+	 */
 	class BS_EXPORT GUIDropDownBox : public GUIWidget
 	class BS_EXPORT GUIDropDownBox : public GUIWidget
 	{
 	{
 	public:
 	public:
@@ -37,7 +48,7 @@ namespace BansheeEngine
 		~GUIDropDownBox();
 		~GUIDropDownBox();
 
 
 		void initialize(CM::Viewport* target, CM::RenderWindow* window, GUIElement* parentElem,
 		void initialize(CM::Viewport* target, CM::RenderWindow* window, GUIElement* parentElem,
-			const CM::Vector<GUIDropDownData>::type& elements, const GUISkin& skin);
+			const CM::Vector<GUIDropDownData>::type& elements, const GUISkin& skin, GUIDropDownType type);
 	private:
 	private:
 		static const CM::UINT32 DROP_DOWN_BOX_WIDTH;
 		static const CM::UINT32 DROP_DOWN_BOX_WIDTH;
 
 

+ 5 - 5
BansheeEngine/Include/BsGUIDropDownList.h → BansheeEngine/Include/BsGUIListBox.h

@@ -7,17 +7,17 @@
 
 
 namespace BansheeEngine
 namespace BansheeEngine
 {
 {
-	class BS_EXPORT GUIDropDownList : public GUIElement
+	class BS_EXPORT GUIListBox : public GUIElement
 	{
 	{
 	public:
 	public:
 		static const CM::String& getGUITypeName();
 		static const CM::String& getGUITypeName();
 
 
-		static GUIDropDownList* create(GUIWidget& parent, const CM::Vector<CM::WString>::type& elements, const GUIElementStyle* style = nullptr);
-		static GUIDropDownList* create(GUIWidget& parent, const CM::Vector<CM::WString>::type& elements, const GUILayoutOptions& layoutOptions, const GUIElementStyle* style = nullptr);
+		static GUIListBox* create(GUIWidget& parent, const CM::Vector<CM::WString>::type& elements, const GUIElementStyle* style = nullptr);
+		static GUIListBox* create(GUIWidget& parent, const CM::Vector<CM::WString>::type& elements, const GUILayoutOptions& layoutOptions, const GUIElementStyle* style = nullptr);
 	
 	
 		boost::signal<void(CM::UINT32)> onSelectionChanged;
 		boost::signal<void(CM::UINT32)> onSelectionChanged;
 	protected:
 	protected:
-		~GUIDropDownList();
+		~GUIListBox();
 
 
 		/**
 		/**
 		 * @copydoc GUIElement::getNumRenderElements()
 		 * @copydoc GUIElement::getNumRenderElements()
@@ -63,7 +63,7 @@ namespace BansheeEngine
 		IMAGE_SPRITE_DESC mImageDesc;
 		IMAGE_SPRITE_DESC mImageDesc;
 		CM::Vector<CM::WString>::type mElements;
 		CM::Vector<CM::WString>::type mElements;
 
 
-		GUIDropDownList(GUIWidget& parent, const GUIElementStyle* style, const CM::Vector<CM::WString>::type& elements, const GUILayoutOptions& layoutOptions);
+		GUIListBox(GUIWidget& parent, const GUIElementStyle* style, const CM::Vector<CM::WString>::type& elements, const GUILayoutOptions& layoutOptions);
 
 
 		virtual bool mouseEvent(const GUIMouseEvent& ev);
 		virtual bool mouseEvent(const GUIMouseEvent& ev);
 
 

+ 2 - 2
BansheeEngine/Include/BsGUIManager.h

@@ -48,7 +48,7 @@ namespace BansheeEngine
 		void update();
 		void update();
 		void render(CM::ViewportPtr& target, CM::RenderQueue& renderQueue) const;
 		void render(CM::ViewportPtr& target, CM::RenderQueue& renderQueue) const;
 
 
-		void openDropDownBox(GUIDropDownList* parentList, const CM::Vector<CM::WString>::type& elements, 
+		void openDropDownListBox(GUIListBox* parentList, const CM::Vector<CM::WString>::type& elements, 
 			std::function<void(CM::UINT32)> selectedCallback, const GUISkin& skin);
 			std::function<void(CM::UINT32)> selectedCallback, const GUISkin& skin);
 
 
 		void queueForDestroy(GUIElement* element);
 		void queueForDestroy(GUIElement* element);
@@ -143,7 +143,7 @@ namespace BansheeEngine
 
 
 		bool handleMouseOver(GUIWidget* widget, GUIElement* element, const CM::Int2& screenMousePos, float wheelScrollAmount = 0.0f);
 		bool handleMouseOver(GUIWidget* widget, GUIElement* element, const CM::Int2& screenMousePos, float wheelScrollAmount = 0.0f);
 
 
-		void closeDropDownBox(CM::INT32 selectedIdx);
+		void closeDropDownListBox(CM::INT32 selectedIdx);
 
 
 		GUIMouseButton buttonToMouseButton(CM::ButtonCode code) const;
 		GUIMouseButton buttonToMouseButton(CM::ButtonCode code) const;
 		CM::Int2 getWidgetRelativePos(const GUIWidget& widget, const CM::Int2& screenPos) const;
 		CM::Int2 getWidgetRelativePos(const GUIWidget& widget, const CM::Int2& screenPos) const;

+ 1 - 1
BansheeEngine/Include/BsPrerequisites.h

@@ -53,7 +53,7 @@ namespace BansheeEngine
 	class GUIInputSelection;
 	class GUIInputSelection;
 	struct GUILayoutOptions;
 	struct GUILayoutOptions;
 	class GUIToggleGroup;
 	class GUIToggleGroup;
-	class GUIDropDownList;
+	class GUIListBox;
 	class GUIDropDownBox;
 	class GUIDropDownBox;
 	class DragAndDropManager;
 	class DragAndDropManager;
 	class GUIContent;
 	class GUIContent;

+ 27 - 11
BansheeEngine/Source/BsEngineGUI.cpp

@@ -401,7 +401,7 @@ namespace BansheeEngine
 		/* 								DROP DOWN BOX                      		*/
 		/* 								DROP DOWN BOX                      		*/
 		/************************************************************************/
 		/************************************************************************/
 
 
-		// DropDown button
+		// ListBox button
 		HTexture dropDownListNormal = static_resource_cast<Texture>(Importer::instance().import(FileSystem::getCurrentPath() + "\\" + DropDownBtnNormalTex));
 		HTexture dropDownListNormal = static_resource_cast<Texture>(Importer::instance().import(FileSystem::getCurrentPath() + "\\" + DropDownBtnNormalTex));
 		HTexture dropDownListHover = static_resource_cast<Texture>(Importer::instance().import(FileSystem::getCurrentPath() + "\\" + DropDownBtnHoverTex));
 		HTexture dropDownListHover = static_resource_cast<Texture>(Importer::instance().import(FileSystem::getCurrentPath() + "\\" + DropDownBtnHoverTex));
 
 
@@ -426,7 +426,7 @@ namespace BansheeEngine
 		dropDownListStyle.textHorzAlign = THA_Left;
 		dropDownListStyle.textHorzAlign = THA_Left;
 		dropDownListStyle.textVertAlign = TVA_Top;
 		dropDownListStyle.textVertAlign = TVA_Top;
 
 
-		mSkin.setStyle("DropDownList", dropDownListStyle);
+		mSkin.setStyle("ListBox", dropDownListStyle);
 
 
 		// DropDown scroll up button arrow
 		// DropDown scroll up button arrow
 		HTexture dropDownBtnScrollUpArrow = static_resource_cast<Texture>(Importer::instance().import(FileSystem::getCurrentPath() + "\\" + DropDownBoxBtnUpArrowTex));
 		HTexture dropDownBtnScrollUpArrow = static_resource_cast<Texture>(Importer::instance().import(FileSystem::getCurrentPath() + "\\" + DropDownBoxBtnUpArrowTex));
@@ -444,7 +444,9 @@ namespace BansheeEngine
 		dropDownScrollUpBtnArrowStyle.border.top = 1;
 		dropDownScrollUpBtnArrowStyle.border.top = 1;
 		dropDownScrollUpBtnArrowStyle.border.bottom = 1;
 		dropDownScrollUpBtnArrowStyle.border.bottom = 1;
 
 
-		mSkin.setStyle("DropDownScrollUpBtnArrow", dropDownScrollUpBtnArrowStyle);
+		mSkin.setStyle("ListBoxScrollUpBtnArrow", dropDownScrollUpBtnArrowStyle);
+		mSkin.setStyle("MenuBarScrollUpBtnArrow", dropDownScrollUpBtnArrowStyle);
+		mSkin.setStyle("ContextMenuScrollUpBtnArrow", dropDownScrollUpBtnArrowStyle);
 
 
 		// DropDown scroll up button
 		// DropDown scroll up button
 		HTexture dropDownBtnScrollUpNormal = static_resource_cast<Texture>(Importer::instance().import(FileSystem::getCurrentPath() + "\\" + DropDownBoxBtnUpNormalTex));
 		HTexture dropDownBtnScrollUpNormal = static_resource_cast<Texture>(Importer::instance().import(FileSystem::getCurrentPath() + "\\" + DropDownBoxBtnUpNormalTex));
@@ -462,7 +464,9 @@ namespace BansheeEngine
 		dropDownScrollUpBtnStyle.border.top = 1;
 		dropDownScrollUpBtnStyle.border.top = 1;
 		dropDownScrollUpBtnStyle.border.bottom = 1;
 		dropDownScrollUpBtnStyle.border.bottom = 1;
 
 
-		mSkin.setStyle("DropDownScrollUpBtn", dropDownScrollUpBtnStyle);
+		mSkin.setStyle("ListBoxScrollUpBtn", dropDownScrollUpBtnStyle);
+		mSkin.setStyle("MenuBarScrollUpBtn", dropDownScrollUpBtnStyle);
+		mSkin.setStyle("ContextMenuScrollUpBtn", dropDownScrollUpBtnStyle);
 
 
 		// DropDown scroll down button arrow
 		// DropDown scroll down button arrow
 		HTexture dropDownBtnScrollDownArrow = static_resource_cast<Texture>(Importer::instance().import(FileSystem::getCurrentPath() + "\\" + DropDownBoxBtnDownArrowTex));
 		HTexture dropDownBtnScrollDownArrow = static_resource_cast<Texture>(Importer::instance().import(FileSystem::getCurrentPath() + "\\" + DropDownBoxBtnDownArrowTex));
@@ -480,7 +484,9 @@ namespace BansheeEngine
 		dropDownScrollDownBtnArrowStyle.border.top = 1;
 		dropDownScrollDownBtnArrowStyle.border.top = 1;
 		dropDownScrollDownBtnArrowStyle.border.bottom = 1;
 		dropDownScrollDownBtnArrowStyle.border.bottom = 1;
 		
 		
-		mSkin.setStyle("DropDownScrollDownBtnArrow", dropDownScrollDownBtnArrowStyle);
+		mSkin.setStyle("ListBoxScrollDownBtnArrow", dropDownScrollDownBtnArrowStyle);
+		mSkin.setStyle("MenuBarScrollDownBtnArrow", dropDownScrollDownBtnArrowStyle);
+		mSkin.setStyle("ContextMenuScrollDownBtnArrow", dropDownScrollDownBtnArrowStyle);
 
 
 		// DropDown scroll down button
 		// DropDown scroll down button
 		HTexture dropDownBtnScrollDownNormal = static_resource_cast<Texture>(Importer::instance().import(FileSystem::getCurrentPath() + "\\" + DropDownBoxBtnDownNormalTex));
 		HTexture dropDownBtnScrollDownNormal = static_resource_cast<Texture>(Importer::instance().import(FileSystem::getCurrentPath() + "\\" + DropDownBoxBtnDownNormalTex));
@@ -498,8 +504,10 @@ namespace BansheeEngine
 		dropDownScrollDownBtnStyle.border.top = 1;
 		dropDownScrollDownBtnStyle.border.top = 1;
 		dropDownScrollDownBtnStyle.border.bottom = 1;
 		dropDownScrollDownBtnStyle.border.bottom = 1;
 
 
-		mSkin.setStyle("DropDownScrollDownBtn", dropDownScrollDownBtnStyle);
-		
+		mSkin.setStyle("ListBoxScrollDownBtn", dropDownScrollDownBtnStyle);
+		mSkin.setStyle("MenuBarScrollDownBtn", dropDownScrollDownBtnStyle);
+		mSkin.setStyle("ContextMenuScrollDownBtn", dropDownScrollDownBtnStyle);
+
 		// DropDown entry button
 		// DropDown entry button
 		HTexture dropDownEntryBtnNormal = static_resource_cast<Texture>(Importer::instance().import(FileSystem::getCurrentPath() + "\\" + DropDownBoxEntryNormalTex));
 		HTexture dropDownEntryBtnNormal = static_resource_cast<Texture>(Importer::instance().import(FileSystem::getCurrentPath() + "\\" + DropDownBoxEntryNormalTex));
 		HTexture dropDownEntryBtnHover = static_resource_cast<Texture>(Importer::instance().import(FileSystem::getCurrentPath() + "\\" + DropDownBoxEntryHoverTex));
 		HTexture dropDownEntryBtnHover = static_resource_cast<Texture>(Importer::instance().import(FileSystem::getCurrentPath() + "\\" + DropDownBoxEntryHoverTex));
@@ -521,7 +529,9 @@ namespace BansheeEngine
 		dropDownEntryBtnStyle.textHorzAlign = THA_Left;
 		dropDownEntryBtnStyle.textHorzAlign = THA_Left;
 		dropDownEntryBtnStyle.textVertAlign = TVA_Top;
 		dropDownEntryBtnStyle.textVertAlign = TVA_Top;
 
 
-		mSkin.setStyle("DropDownEntryBtn", dropDownEntryBtnStyle);
+		mSkin.setStyle("ListBoxEntryBtn", dropDownEntryBtnStyle);
+		mSkin.setStyle("MenuBarEntryBtn", dropDownEntryBtnStyle);
+		mSkin.setStyle("ContextMenuEntryBtn", dropDownEntryBtnStyle);
 
 
 		// DropDown entry button with expand
 		// DropDown entry button with expand
 		HTexture dropDownExpEntryBtnNormal = static_resource_cast<Texture>(Importer::instance().import(FileSystem::getCurrentPath() + "\\" + DropDownBoxEntryExpNormalTex));
 		HTexture dropDownExpEntryBtnNormal = static_resource_cast<Texture>(Importer::instance().import(FileSystem::getCurrentPath() + "\\" + DropDownBoxEntryExpNormalTex));
@@ -544,7 +554,9 @@ namespace BansheeEngine
 		dropDownEntryExpBtnStyle.textHorzAlign = THA_Left;
 		dropDownEntryExpBtnStyle.textHorzAlign = THA_Left;
 		dropDownEntryExpBtnStyle.textVertAlign = TVA_Top;
 		dropDownEntryExpBtnStyle.textVertAlign = TVA_Top;
 
 
-		mSkin.setStyle("DropDownEntryExpBtn", dropDownEntryExpBtnStyle);
+		mSkin.setStyle("ListBoxEntryExpBtn", dropDownEntryExpBtnStyle);
+		mSkin.setStyle("MenuBarEntryExpBtn", dropDownEntryExpBtnStyle);
+		mSkin.setStyle("ContextMenuEntryExpBtn", dropDownEntryExpBtnStyle);
 
 
 		// DropDown box frame
 		// DropDown box frame
 		HTexture dropDownBoxBgTex = static_resource_cast<Texture>(Importer::instance().import(FileSystem::getCurrentPath() + "\\" + DropDownBoxBgTex));
 		HTexture dropDownBoxBgTex = static_resource_cast<Texture>(Importer::instance().import(FileSystem::getCurrentPath() + "\\" + DropDownBoxBgTex));
@@ -562,7 +574,9 @@ namespace BansheeEngine
 		dropDownBoxStyle.border.top = 1;
 		dropDownBoxStyle.border.top = 1;
 		dropDownBoxStyle.border.bottom = 1;
 		dropDownBoxStyle.border.bottom = 1;
 
 
-		mSkin.setStyle("DropDownBox", dropDownBoxStyle);
+		mSkin.setStyle("ListBoxFrame", dropDownBoxStyle);
+		mSkin.setStyle("MenuBarFrame", dropDownBoxStyle);
+		mSkin.setStyle("ContextMenuFrame", dropDownBoxStyle);
 
 
 		// Drop down separator
 		// Drop down separator
 		HTexture dropDownSeparatorTex = static_resource_cast<Texture>(Importer::instance().import(FileSystem::getCurrentPath() + "\\" + DropDownSeparatorTex));
 		HTexture dropDownSeparatorTex = static_resource_cast<Texture>(Importer::instance().import(FileSystem::getCurrentPath() + "\\" + DropDownSeparatorTex));
@@ -580,6 +594,8 @@ namespace BansheeEngine
 		dropDownSeparatorStyle.border.top = 1;
 		dropDownSeparatorStyle.border.top = 1;
 		dropDownSeparatorStyle.border.bottom = 1;
 		dropDownSeparatorStyle.border.bottom = 1;
 
 
-		mSkin.setStyle("DropDownSeparator", dropDownSeparatorStyle);
+		mSkin.setStyle("ListBoxSeparator", dropDownSeparatorStyle);
+		mSkin.setStyle("MenuBarSeparator", dropDownSeparatorStyle);
+		mSkin.setStyle("ContextMenuSeparator", dropDownSeparatorStyle);
 	}
 	}
 }
 }

+ 25 - 11
BansheeEngine/Source/BsGUIDropDownBox.cpp

@@ -6,7 +6,7 @@
 #include "BsGUIContent.h"
 #include "BsGUIContent.h"
 #include "BsGUISkin.h"
 #include "BsGUISkin.h"
 #include "CmViewport.h"
 #include "CmViewport.h"
-#include "BsGUIDropDownList.h"
+#include "BsGUIListBox.h"
 
 
 using namespace CamelotFramework;
 using namespace CamelotFramework;
 
 
@@ -48,21 +48,35 @@ namespace BansheeEngine
 	}
 	}
 
 
 	void GUIDropDownBox::initialize(Viewport* target, RenderWindow* window, GUIElement* parentElem, 
 	void GUIDropDownBox::initialize(Viewport* target, RenderWindow* window, GUIElement* parentElem, 
-		const CM::Vector<GUIDropDownData>::type& elements, const GUISkin& skin)
+		const CM::Vector<GUIDropDownData>::type& elements, const GUISkin& skin, GUIDropDownType type)
 	{
 	{
 		GUIWidget::initialize(target, window);
 		GUIWidget::initialize(target, window);
 
 
+		String stylePrefix = "";
+		switch(type)
+		{
+		case GUIDropDownType::ContextMenu:
+			stylePrefix = "ContextMenu";
+			break;
+		case GUIDropDownType::ListBox:
+			stylePrefix = "ListBox";
+			break;
+		case GUIDropDownType::MenuBar:
+			stylePrefix = "MenuBar";
+			break;
+		}
+
 		mElements = elements;
 		mElements = elements;
 
 
-		mScrollUpStyle = skin.getStyle("DropDownScrollUpBtn");
-		mScrollDownStyle = skin.getStyle("DropDownScrollDownBtn");
-		mEntryBtnStyle = skin.getStyle("DropDownEntryBtn");
-		mEntryExpBtnStyle = skin.getStyle("DropDownEntryExpBtn");
-		mSeparatorStyle = skin.getStyle("DropDownSeparator");
-		mBackgroundStyle = skin.getStyle("DropDownBox");
+		mScrollUpStyle = skin.getStyle(stylePrefix + "ScrollUpBtn");
+		mScrollDownStyle = skin.getStyle(stylePrefix + "ScrollDownBtn");
+		mEntryBtnStyle = skin.getStyle(stylePrefix + "EntryBtn");
+		mEntryExpBtnStyle = skin.getStyle(stylePrefix + "EntryExpBtn");
+		mSeparatorStyle = skin.getStyle(stylePrefix + "Separator");
+		mBackgroundStyle = skin.getStyle(stylePrefix + "Frame");
 
 
-		mScrollUpBtnArrow = skin.getStyle("DropDownScrollUpBtnArrow")->normal.texture;
-		mScrollDownBtnArrow = skin.getStyle("DropDownScrollDownBtnArrow")->normal.texture;
+		mScrollUpBtnArrow = skin.getStyle("ScrollUpBtnArrow")->normal.texture;
+		mScrollDownBtnArrow = skin.getStyle("ScrollDownBtnArrow")->normal.texture;
 
 
 		setDepth(0); // Needs to be in front of everything
 		setDepth(0); // Needs to be in front of everything
 
 
@@ -127,7 +141,7 @@ namespace BansheeEngine
 		// Background frame
 		// Background frame
 		mBackgroundArea = GUIArea::create(*this, position.x, position.y, width, height);
 		mBackgroundArea = GUIArea::create(*this, position.x, position.y, width, height);
 		mBackgroundArea->setDepth(102);
 		mBackgroundArea->setDepth(102);
-		mBackgroundArea->getLayout().addElement(GUITexture::create(*this, GUIImageScaleMode::ScaleToFit, skin.getStyle("DropDownBox")));
+		mBackgroundArea->getLayout().addElement(GUITexture::create(*this, GUIImageScaleMode::ScaleToFit, mBackgroundStyle));
 
 
 		updateGUIElements(position.x, position.y, width, height);
 		updateGUIElements(position.x, position.y, width, height);
 	}
 	}

+ 21 - 21
BansheeEngine/Source/BsGUIDropDownList.cpp → BansheeEngine/Source/BsGUIListBox.cpp

@@ -1,4 +1,4 @@
-#include "BsGUIDropDownList.h"
+#include "BsGUIListBox.h"
 #include "BsImageSprite.h"
 #include "BsImageSprite.h"
 #include "BsGUIWidget.h"
 #include "BsGUIWidget.h"
 #include "BsGUISkin.h"
 #include "BsGUISkin.h"
@@ -13,13 +13,13 @@ using namespace CamelotFramework;
 
 
 namespace BansheeEngine
 namespace BansheeEngine
 {
 {
-	const String& GUIDropDownList::getGUITypeName()
+	const String& GUIListBox::getGUITypeName()
 	{
 	{
-		static String name = "DropDownList";
+		static String name = "ListBox";
 		return name;
 		return name;
 	}
 	}
 
 
-	GUIDropDownList::GUIDropDownList(GUIWidget& parent, const GUIElementStyle* style, const Vector<WString>::type& elements, const GUILayoutOptions& layoutOptions)
+	GUIListBox::GUIListBox(GUIWidget& parent, const GUIElementStyle* style, const Vector<WString>::type& elements, const GUILayoutOptions& layoutOptions)
 		:GUIElement(parent, style, layoutOptions), mElements(elements), mNumImageRenderElements(0), mSelectedIdx(0)
 		:GUIElement(parent, style, layoutOptions), mElements(elements), mNumImageRenderElements(0), mSelectedIdx(0)
 	{
 	{
 		mImageSprite = cm_new<ImageSprite, PoolAlloc>();
 		mImageSprite = cm_new<ImageSprite, PoolAlloc>();
@@ -39,13 +39,13 @@ namespace BansheeEngine
 		mImageDesc.borderBottom = mStyle->border.bottom;
 		mImageDesc.borderBottom = mStyle->border.bottom;
 	}
 	}
 
 
-	GUIDropDownList::~GUIDropDownList()
+	GUIListBox::~GUIListBox()
 	{
 	{
 		cm_delete<PoolAlloc>(mTextSprite);
 		cm_delete<PoolAlloc>(mTextSprite);
 		cm_delete<PoolAlloc>(mImageSprite);
 		cm_delete<PoolAlloc>(mImageSprite);
 	}
 	}
 
 
-	GUIDropDownList* GUIDropDownList::create(GUIWidget& parent, const Vector<WString>::type& elements, const GUIElementStyle* style)
+	GUIListBox* GUIListBox::create(GUIWidget& parent, const Vector<WString>::type& elements, const GUIElementStyle* style)
 	{
 	{
 		if(style == nullptr)
 		if(style == nullptr)
 		{
 		{
@@ -53,10 +53,10 @@ namespace BansheeEngine
 			style = skin.getStyle(getGUITypeName());
 			style = skin.getStyle(getGUITypeName());
 		}
 		}
 
 
-		return new (cm_alloc<GUIDropDownList, PoolAlloc>()) GUIDropDownList(parent, style, elements, getDefaultLayoutOptions(style));
+		return new (cm_alloc<GUIListBox, PoolAlloc>()) GUIListBox(parent, style, elements, getDefaultLayoutOptions(style));
 	}
 	}
 
 
-	GUIDropDownList* GUIDropDownList::create(GUIWidget& parent, const Vector<WString>::type& elements, const GUILayoutOptions& layoutOptions, const GUIElementStyle* style)
+	GUIListBox* GUIListBox::create(GUIWidget& parent, const Vector<WString>::type& elements, const GUILayoutOptions& layoutOptions, const GUIElementStyle* style)
 	{
 	{
 		if(style == nullptr)
 		if(style == nullptr)
 		{
 		{
@@ -64,10 +64,10 @@ namespace BansheeEngine
 			style = skin.getStyle(getGUITypeName());
 			style = skin.getStyle(getGUITypeName());
 		}
 		}
 
 
-		return new (cm_alloc<GUIDropDownList, PoolAlloc>()) GUIDropDownList(parent, style, elements, layoutOptions);
+		return new (cm_alloc<GUIListBox, PoolAlloc>()) GUIListBox(parent, style, elements, layoutOptions);
 	}
 	}
 
 
-	UINT32 GUIDropDownList::getNumRenderElements() const
+	UINT32 GUIListBox::getNumRenderElements() const
 	{
 	{
 		UINT32 numElements = mImageSprite->getNumRenderElements();
 		UINT32 numElements = mImageSprite->getNumRenderElements();
 		numElements += mTextSprite->getNumRenderElements();
 		numElements += mTextSprite->getNumRenderElements();
@@ -75,7 +75,7 @@ namespace BansheeEngine
 		return numElements;
 		return numElements;
 	}
 	}
 
 
-	const HMaterial& GUIDropDownList::getMaterial(UINT32 renderElementIdx) const
+	const HMaterial& GUIListBox::getMaterial(UINT32 renderElementIdx) const
 	{
 	{
 		if(renderElementIdx >= mNumImageRenderElements)
 		if(renderElementIdx >= mNumImageRenderElements)
 			return mTextSprite->getMaterial(mNumImageRenderElements - renderElementIdx);
 			return mTextSprite->getMaterial(mNumImageRenderElements - renderElementIdx);
@@ -83,7 +83,7 @@ namespace BansheeEngine
 			return mImageSprite->getMaterial(renderElementIdx);
 			return mImageSprite->getMaterial(renderElementIdx);
 	}
 	}
 
 
-	UINT32 GUIDropDownList::getNumQuads(UINT32 renderElementIdx) const
+	UINT32 GUIListBox::getNumQuads(UINT32 renderElementIdx) const
 	{
 	{
 		UINT32 numQuads = 0;
 		UINT32 numQuads = 0;
 		if(renderElementIdx >= mNumImageRenderElements)
 		if(renderElementIdx >= mNumImageRenderElements)
@@ -94,7 +94,7 @@ namespace BansheeEngine
 		return numQuads;
 		return numQuads;
 	}
 	}
 
 
-	void GUIDropDownList::updateRenderElementsInternal()
+	void GUIListBox::updateRenderElementsInternal()
 	{		
 	{		
 		mImageDesc.width = mWidth;
 		mImageDesc.width = mWidth;
 		mImageDesc.height = mHeight;
 		mImageDesc.height = mHeight;
@@ -119,12 +119,12 @@ namespace BansheeEngine
 		GUIElement::updateRenderElementsInternal();
 		GUIElement::updateRenderElementsInternal();
 	}
 	}
 
 
-	void GUIDropDownList::updateClippedBounds()
+	void GUIListBox::updateClippedBounds()
 	{
 	{
 		mClippedBounds = mImageSprite->getBounds(mOffset, mClipRect);
 		mClippedBounds = mImageSprite->getBounds(mOffset, mClipRect);
 	}
 	}
 
 
-	UINT32 GUIDropDownList::_getOptimalWidth() const
+	UINT32 GUIListBox::_getOptimalWidth() const
 	{
 	{
 		if(mImageDesc.texture != nullptr)
 		if(mImageDesc.texture != nullptr)
 		{
 		{
@@ -134,7 +134,7 @@ namespace BansheeEngine
 		return 0;
 		return 0;
 	}
 	}
 
 
-	UINT32 GUIDropDownList::_getOptimalHeight() const
+	UINT32 GUIListBox::_getOptimalHeight() const
 	{
 	{
 		if(mImageDesc.texture != nullptr)
 		if(mImageDesc.texture != nullptr)
 		{
 		{
@@ -144,7 +144,7 @@ namespace BansheeEngine
 		return 0;
 		return 0;
 	}
 	}
 
 
-	UINT32 GUIDropDownList::_getRenderElementDepth(UINT32 renderElementIdx) const
+	UINT32 GUIListBox::_getRenderElementDepth(UINT32 renderElementIdx) const
 	{
 	{
 		if(renderElementIdx >= mNumImageRenderElements)
 		if(renderElementIdx >= mNumImageRenderElements)
 			return _getDepth();
 			return _getDepth();
@@ -152,7 +152,7 @@ namespace BansheeEngine
 			return _getDepth() + 1;
 			return _getDepth() + 1;
 	}
 	}
 
 
-	void GUIDropDownList::fillBuffer(UINT8* vertices, UINT8* uv, UINT32* indices, UINT32 startingQuad, UINT32 maxNumQuads, 
+	void GUIListBox::fillBuffer(UINT8* vertices, UINT8* uv, UINT32* indices, UINT32 startingQuad, UINT32 maxNumQuads, 
 		UINT32 vertexStride, UINT32 indexStride, UINT32 renderElementIdx) const
 		UINT32 vertexStride, UINT32 indexStride, UINT32 renderElementIdx) const
 	{
 	{
 		if(renderElementIdx >= mNumImageRenderElements)
 		if(renderElementIdx >= mNumImageRenderElements)
@@ -171,7 +171,7 @@ namespace BansheeEngine
 		}
 		}
 	}
 	}
 
 
-	bool GUIDropDownList::mouseEvent(const GUIMouseEvent& ev)
+	bool GUIListBox::mouseEvent(const GUIMouseEvent& ev)
 	{
 	{
 		if(ev.getType() == GUIMouseEventType::MouseOver)
 		if(ev.getType() == GUIMouseEventType::MouseOver)
 		{
 		{
@@ -192,7 +192,7 @@ namespace BansheeEngine
 			mImageDesc.texture = mStyle->active.texture;
 			mImageDesc.texture = mStyle->active.texture;
 			markContentAsDirty();
 			markContentAsDirty();
 
 
-			GUIManager::instance().openDropDownBox(this, mElements, boost::bind(&GUIDropDownList::elementSelected, this, _1), _getParentWidget().getSkin());
+			GUIManager::instance().openDropDownListBox(this, mElements, boost::bind(&GUIListBox::elementSelected, this, _1), _getParentWidget().getSkin());
 
 
 			return true;
 			return true;
 		}
 		}
@@ -207,7 +207,7 @@ namespace BansheeEngine
 		return false;
 		return false;
 	}
 	}
 
 
-	void GUIDropDownList::elementSelected(CM::UINT32 idx)
+	void GUIListBox::elementSelected(CM::UINT32 idx)
 	{
 	{
 		if(!onSelectionChanged.empty())
 		if(!onSelectionChanged.empty())
 			onSelectionChanged(idx);
 			onSelectionChanged(idx);

+ 7 - 7
BansheeEngine/Source/BsGUIManager.cpp

@@ -20,7 +20,7 @@
 #include "CmRenderQueue.h"
 #include "CmRenderQueue.h"
 #include "BsGUIInputCaret.h"
 #include "BsGUIInputCaret.h"
 #include "BsGUIInputSelection.h"
 #include "BsGUIInputSelection.h"
-#include "BsGUIDropDownList.h"
+#include "BsGUIListBox.h"
 #include "BsGUIDropDownBox.h"
 #include "BsGUIDropDownBox.h"
 #include "BsDragAndDropManager.h"
 #include "BsDragAndDropManager.h"
 
 
@@ -502,11 +502,11 @@ namespace BansheeEngine
 		}
 		}
 	}
 	}
 
 
-	void GUIManager::openDropDownBox(GUIDropDownList* parentList, const CM::Vector<WString>::type& elements, 
+	void GUIManager::openDropDownListBox(GUIListBox* parentList, const CM::Vector<WString>::type& elements, 
 		std::function<void(CM::UINT32)> selectedCallback, const GUISkin& skin)
 		std::function<void(CM::UINT32)> selectedCallback, const GUISkin& skin)
 	{
 	{
 		if(mDropDownBoxOpenScheduled || mDropDownBoxActive)
 		if(mDropDownBoxOpenScheduled || mDropDownBoxActive)
-			closeDropDownBox(-1);
+			closeDropDownListBox(-1);
 
 
 		mDropDownSO = SceneObject::create("DropDownBox");
 		mDropDownSO = SceneObject::create("DropDownBox");
 		mDropDownBox = mDropDownSO->addComponent<GUIDropDownBox>();
 		mDropDownBox = mDropDownSO->addComponent<GUIDropDownBox>();
@@ -517,17 +517,17 @@ namespace BansheeEngine
 		UINT32 i = 0;
 		UINT32 i = 0;
 		for(auto& elem : elements)
 		for(auto& elem : elements)
 		{
 		{
-			dropDownData.push_back(GUIDropDownData::button(elem, boost::bind(&GUIManager::closeDropDownBox, this, i)));
+			dropDownData.push_back(GUIDropDownData::button(elem, boost::bind(&GUIManager::closeDropDownListBox, this, i)));
 			i++;
 			i++;
 		}
 		}
 
 
-		mDropDownBox->initialize(widget.getTarget(), widget.getOwnerWindow(), parentList, dropDownData, skin);
+		mDropDownBox->initialize(widget.getTarget(), widget.getOwnerWindow(), parentList, dropDownData, skin, GUIDropDownType::ListBox);
 
 
 		mDropDownBoxOpenScheduled = true;
 		mDropDownBoxOpenScheduled = true;
 		mDropDownSelectionMade = selectedCallback;
 		mDropDownSelectionMade = selectedCallback;
 	}
 	}
 
 
-	void GUIManager::closeDropDownBox(INT32 selectedIdx)
+	void GUIManager::closeDropDownListBox(INT32 selectedIdx)
 	{
 	{
 		if(selectedIdx != -1)
 		if(selectedIdx != -1)
 			mDropDownSelectionMade(selectedIdx);
 			mDropDownSelectionMade(selectedIdx);
@@ -644,7 +644,7 @@ namespace BansheeEngine
 			{
 			{
 				if(mMouseOverElement == nullptr || (&mMouseOverElement->_getParentWidget() != mDropDownBox.get()))
 				if(mMouseOverElement == nullptr || (&mMouseOverElement->_getParentWidget() != mDropDownBox.get()))
 				{
 				{
-					closeDropDownBox(-1);
+					closeDropDownListBox(-1);
 				}
 				}
 			}
 			}
 		}
 		}

+ 2 - 2
CamelotClient/Source/CmTestTextSprite.cpp

@@ -7,7 +7,7 @@
 #include "CmFont.h"
 #include "CmFont.h"
 #include "CmMaterial.h"
 #include "CmMaterial.h"
 #include "BsGUILabel.h"
 #include "BsGUILabel.h"
-#include "BsGUIDropDownList.h"
+#include "BsGUIListBox.h"
 #include "BsGUISkin.h"
 #include "BsGUISkin.h"
 #include "BsOverlayManager.h"
 #include "BsOverlayManager.h"
 #include "BsSpriteTexture.h"
 #include "BsSpriteTexture.h"
@@ -50,7 +50,7 @@ namespace CamelotFramework
 		dropDownElements.push_back(L"Ejlement #1");
 		dropDownElements.push_back(L"Ejlement #1");
 		dropDownElements.push_back(L"Element #2");
 		dropDownElements.push_back(L"Element #2");
 		dropDownElements.push_back(L"Element #3");
 		dropDownElements.push_back(L"Element #3");
-		area->getLayout().addElement(GUIDropDownList::create(*this, dropDownElements, GUILayoutOptions::fixed(50, 13)));
+		area->getLayout().addElement(GUIListBox::create(*this, dropDownElements, GUILayoutOptions::fixed(50, 13)));
 		area->getLayout().addFlexibleSpace();
 		area->getLayout().addFlexibleSpace();
 	}
 	}
 
 

+ 6 - 14
DropDown.txt

@@ -1,20 +1,12 @@
 GUI ignores image in GUIContent for most elements.
 GUI ignores image in GUIContent for most elements.
 
 
 Immediate TODO:
 Immediate TODO:
- - Add separator images
-   - Make it in PS, just a single image
-   - Add support for it in DropDownBox
-      - Elements with "-" as contents automatically become separators
-	  - PROBLEM: With scrolling. Right now I assume all elements are the same size but when separators
-	    are used I can no longer scroll that way. TODO
-		 - Add a better way of updating GUIButtons (a way that actuall adds/removes them)
-		 - Can also be used for handling of add/remove scrollup/scrolldown buttons
- - Add expand right arrow
-   - Add scale9grid where the right side has the arrow
-   - Callback hooked up just opens another context window
-     - Managing this is taken care of on a higher level (GUIManager or similar)
- - Upon scroll up/down remove ScrollUp or ScrollDown buttons if that direction isn't usable anymore
-  - Delete its GUIArea and offset the content area, and possibly ScrollDown area
+ - Hook up ScrollUp and ScrollDown events in GUIDropDownBox
+ - Add support for different skins for context menu, drop down list and drop down menu
+    - Just add a prefix to GUIDropDownBox constructor
+ - Add support to GUIManager to deal with multiple different GUIDropDownBoxes
+
+Figure out how to deal with sub-menus
 
 
 ----------------------------
 ----------------------------
  - Elements can call addContextAction("Name", "Callback")
  - Elements can call addContextAction("Name", "Callback")