Marko Pintera пре 10 година
родитељ
комит
734411f94d

+ 2 - 0
BansheeEditor/BansheeEditor.vcxproj

@@ -294,6 +294,7 @@
     <ClInclude Include="Include\BsGUIFoldout.h" />
     <ClInclude Include="Include\BsGUIIntField.h" />
     <ClInclude Include="Include\BsGUIDropButton.h" />
+    <ClInclude Include="Include\BsGUIStatusBar.h" />
     <ClInclude Include="Include\BsGUITextField.h" />
     <ClInclude Include="Include\BsGUIToggleField.h" />
     <ClInclude Include="Include\BsGUIVector3Field.h" />
@@ -375,6 +376,7 @@
     <ClCompile Include="Source\BsGUIDropButton.cpp" />
     <ClCompile Include="Source\BsGUIResourceTreeView.cpp" />
     <ClCompile Include="Source\BsGUISceneTreeView.cpp" />
+    <ClCompile Include="Source\BsGUIStatusBar.cpp" />
     <ClCompile Include="Source\BsGUITabbedTitleBar.cpp" />
     <ClCompile Include="Source\BsGUITabButton.cpp" />
     <ClCompile Include="Source\BsGUITextField.cpp" />

+ 6 - 0
BansheeEditor/BansheeEditor.vcxproj.filters

@@ -258,6 +258,9 @@
     <ClInclude Include="Include\BsProjectResourceMetaRTTI.h">
       <Filter>Header Files\RTTI</Filter>
     </ClInclude>
+    <ClInclude Include="Include\BsGUIStatusBar.h">
+      <Filter>Header Files</Filter>
+    </ClInclude>
   </ItemGroup>
   <ItemGroup>
     <ClCompile Include="Source\BsEditorCommand.cpp">
@@ -461,5 +464,8 @@
     <ClCompile Include="Source\BsUndoRedo.cpp">
       <Filter>Source Files</Filter>
     </ClCompile>
+    <ClCompile Include="Source\BsGUIStatusBar.cpp">
+      <Filter>Source Files</Filter>
+    </ClCompile>
   </ItemGroup>
 </Project>

+ 19 - 0
BansheeEditor/Include/BsBuiltinEditorResources.h

@@ -15,6 +15,14 @@ namespace BansheeEngine
 		Folder, Mesh, Font, Texture, PlainText, ScriptCode, SpriteTexture, Shader, ShaderInclude, Material, Prefab
 	};
 
+	/**
+	 * @brief	Types of icons to be used along with log messages depending on their severity.
+	 */
+	enum class LogMessageIcon
+	{
+		Info, Warning, Error
+	};
+
 	/**
 	 * @brief	Contains a set of built-in resources used by the editor.
 	 */
@@ -95,6 +103,11 @@ namespace BansheeEngine
 		 */
 		HSpriteTexture getLibraryIcon(ProjectIcon icon) const;
 
+		/**
+		 * @brief	Retrieves an icon that represents a specific log message type.
+		 */
+		HSpriteTexture getLogMessageIcon(LogMessageIcon icon) const;
+
 		static const String ObjectFieldStyleName;
 		static const String ObjectFieldLabelStyleName;
 		static const String ObjectFieldDropBtnStyleName;
@@ -186,6 +199,10 @@ namespace BansheeEngine
 		static const WString SpriteTextureIconTex;
 		static const WString PrefabIconTex;
 
+		static const WString LogInfoIconTex;
+		static const WString LogWarningIconTex;
+		static const WString LogErrorIconTex;
+
 		static const WString WindowBackgroundTexture;
 
 		static const WString WindowFrameNormal;
@@ -319,6 +336,8 @@ namespace BansheeEngine
 		static const WString XButtonNormalTex;
 		static const WString XButtonHoverTex;
 
+		static const WString StatusBarBgTex;
+
 		static const WString ShaderDockOverlayFile;
 		static const WString ShaderSceneGridFile;
 		static const WString ShaderPickingCullNoneFile;

+ 1 - 0
BansheeEditor/Include/BsEditorPrerequisites.h

@@ -42,6 +42,7 @@ namespace BansheeEngine
 	class GUIColor;
 	class GUIComponentFoldout;
 	class GUIFoldout;
+	class GUIStatusBar;
 	class GUIDropButton;
 	class EditorWindowManager;
 	class DockManager;

+ 100 - 0
BansheeEditor/Include/BsGUIStatusBar.h

@@ -0,0 +1,100 @@
+#pragma once
+
+#include "BsEditorPrerequisites.h"
+#include "BsGUIElementContainer.h"
+
+namespace BansheeEngine
+{
+	/**
+	 * @brief  Editor window status bar that displays log messages and various other information.
+	 */
+	class BS_ED_EXPORT GUIStatusBar : public GUIElementContainer
+	{
+		struct PrivatelyConstruct {};
+
+	public:
+		/**
+		 * Returns type name of the GUI element used for finding GUI element styles. 
+		 */
+		static const String& getGUITypeName();
+
+		/**
+		 * Returns type name of the internal background GUI element. 
+		 */
+		static const String& getGUIBackgroundTypeName();
+
+		/**
+		 * Returns type name of the internal message button GUI element. 
+		 */
+		static const String& getGUIMessageTypeName();
+
+		/**
+		 * @brief	Creates a new GUI status bar.
+		 *
+		 * @param	options			Options that allow you to control how is the element positioned and sized.
+		 *							This will override any similar options set by style.
+		 * @param	styleName		Optional style to use for the element. Style will be retrieved
+		 *							from GUISkin of the GUIWidget the element is used on. If not specified
+		 *							default style is used.
+		 */
+		static GUIStatusBar* create(const GUIOptions& options, const String& style = StringUtil::BLANK);
+
+		/**
+		 * @brief	Creates a new GUI status bar.
+		 *
+		 * @param	options			Options that allow you to control how is the element positioned and sized.
+		 *							This will override any similar options set by style.
+		 * @param	styleName		Optional style to use for the element. Style will be retrieved
+		 *							from GUISkin of the GUIWidget the element is used on. If not specified
+		 *							default style is used.
+		 */
+		static GUIStatusBar* create(const String& style = StringUtil::BLANK);
+
+		GUIStatusBar(const PrivatelyConstruct& dummy, const String& style, const GUIDimensions& dimensions);
+
+		/**
+		 * @copydoc	GUIElement::setTint
+		 */
+		virtual void setTint(const Color& color) override;
+
+		/**
+		 * @copydoc	GUIElement::_updateLayoutInternal
+		 */
+		void _updateLayoutInternal(const GUILayoutData& data) override;
+
+		/**
+		 * @copydoc	GUIElement::_getOptimalSize
+		 */
+		Vector2I _getOptimalSize() const override;
+
+		Event<void()> onMessageClicked; /**< Triggered when the user clicks on the console message. */
+	private:
+		virtual ~GUIStatusBar();
+
+		/**
+		 * @copydoc	GUIElement::styleUpdated
+		 */
+		void styleUpdated() override;
+
+		/**
+		 * @brief	Triggered when a new entry is added to the debug Log.
+		 */
+		void logEntryAdded(const LogEntry& entry);
+
+		/**
+		 * @brief	Triggered when the user clicks on the message display.
+		 */
+		void messageBtnClicked();
+
+	private:
+		static const UINT32 DEFAULT_LABEL_WIDTH;
+
+		GUIPanel* mPanel;
+		GUIPanel* mBgPanel;
+		GUIButton* mMessage;
+		GUITexture* mBackground;
+
+		HEvent mLogEntryAddedConn;
+		HEvent mMessageBtnPressedConn;
+	};
+}

+ 1 - 0
BansheeEditor/Include/BsMainEditorWindow.h

@@ -52,6 +52,7 @@ namespace BansheeEngine
 	protected:
 		GUIMenuBar* mMenuBar;
 		DockManager* mDockManager;
+		GUIStatusBar* mStatusBar;
 		HProfilerOverlay mProfilerOverlay;
 
 		/**

+ 53 - 0
BansheeEditor/Source/BsBuiltinEditorResources.cpp

@@ -25,6 +25,7 @@
 #include "BsGUIProgressBar.h"
 #include "BsGUISlider.h"
 #include "BsGUIDropDownContent.h"
+#include "BsGUIStatusBar.h"
 
 #include "BsFont.h"
 #include "BsFontImportOptions.h"
@@ -90,6 +91,10 @@ namespace BansheeEngine
 	const WString BuiltinEditorResources::SpriteTextureIconTex = L"SpriteIcon.psd";
 	const WString BuiltinEditorResources::PrefabIconTex = L"PrefabIcon.psd";
 
+	const WString BuiltinEditorResources::LogInfoIconTex = L"IconInfo.psd";
+	const WString BuiltinEditorResources::LogWarningIconTex = L"IconWarning.psd";
+	const WString BuiltinEditorResources::LogErrorIconTex = L"IconError.psd";
+
 	const WString BuiltinEditorResources::WindowBackgroundTexture = L"WindowBgTile.psd";
 
 	const WString BuiltinEditorResources::ButtonNormalTex = L"ButtonNormal.psd";
@@ -222,6 +227,8 @@ namespace BansheeEngine
 	const WString BuiltinEditorResources::XButtonNormalTex = L"XButtonNormal.psd";
 	const WString BuiltinEditorResources::XButtonHoverTex = L"XButtonHover.psd";
 
+	const WString BuiltinEditorResources::StatusBarBgTex = L"StatusBarBg.psd";
+
 	/************************************************************************/
 	/* 									SHADERS                      		*/
 	/************************************************************************/
@@ -1265,6 +1272,37 @@ namespace BansheeEngine
 
 		skin->setStyle("ColorSlider2DHandle", colorPickerSlider2DHandleStyle);
 
+		/************************************************************************/
+		/* 								STATUS BAR                      		*/
+		/************************************************************************/
+		GUIElementStyle statusBarBgStyle;
+		statusBarBgStyle.fixedHeight = true;
+		statusBarBgStyle.height = 13;
+		statusBarBgStyle.normal.texture = getGUITexture(StatusBarBgTex);
+
+		skin->setStyle(GUIStatusBar::getGUIBackgroundTypeName(), statusBarBgStyle);
+
+		GUIElementStyle statusBarMessageBtnStyle;
+		statusBarMessageBtnStyle.font = font;
+		statusBarMessageBtnStyle.fontSize = DefaultFontSize;
+		statusBarMessageBtnStyle.fixedWidth = false;
+		statusBarMessageBtnStyle.fixedHeight = true;
+		statusBarMessageBtnStyle.height = 13;
+		statusBarMessageBtnStyle.minWidth = 10;
+		statusBarMessageBtnStyle.textHorzAlign = THA_Left;
+		statusBarMessageBtnStyle.imagePosition = GUIImagePosition::Left;
+
+		skin->setStyle(GUIStatusBar::getGUIMessageTypeName(), statusBarMessageBtnStyle);
+
+		GUIElementStyle statusBarStyle;
+		statusBarStyle.fixedHeight = true;
+		statusBarStyle.height = 13;
+
+		statusBarStyle.subStyles[GUIStatusBar::getGUIBackgroundTypeName()] = GUIStatusBar::getGUIBackgroundTypeName();
+		statusBarStyle.subStyles[GUIStatusBar::getGUIMessageTypeName()] = GUIStatusBar::getGUIMessageTypeName();
+
+		skin->setStyle(GUIStatusBar::getGUITypeName(), statusBarStyle);
+
 		/************************************************************************/
 		/* 									OTHER                      			*/
 		/************************************************************************/
@@ -1439,4 +1477,19 @@ namespace BansheeEngine
 
 		return HSpriteTexture();
 	}
+
+	HSpriteTexture BuiltinEditorResources::getLogMessageIcon(LogMessageIcon icon) const
+	{
+		switch (icon)
+		{
+		case LogMessageIcon::Info:
+			return getGUIIcon(LogInfoIconTex);
+		case LogMessageIcon::Warning:
+			return getGUIIcon(LogWarningIconTex);
+		case LogMessageIcon::Error:
+			return getGUIIcon(LogErrorIconTex);
+		}
+
+		return HSpriteTexture();
+	}
 }

+ 134 - 0
BansheeEditor/Source/BsGUIStatusBar.cpp

@@ -0,0 +1,134 @@
+#include "BsGUIStatusBar.h"
+#include "BsGUILayoutX.h"
+#include "BsGUILayoutY.h"
+#include "BsGUILabel.h"
+#include "BsGUIButton.h"
+#include "BsGUITexture.h"
+#include "BsGUIPanel.h"
+#include "BsGUISpace.h"
+#include "BsDebug.h"
+#include "BsBuiltinEditorResources.h"
+
+using namespace std::placeholders;
+
+namespace BansheeEngine
+{
+	GUIStatusBar::GUIStatusBar(const PrivatelyConstruct& dummy,
+		const String& style, const GUIDimensions& dimensions)
+		:GUIElementContainer(dimensions, style)
+	{
+		mPanel = GUIPanel::create();
+		mBgPanel = GUIPanel::create(1);
+		_registerChildElement(mPanel);
+		_registerChildElement(mBgPanel);
+
+		mBackground = GUITexture::create(GUIOptions(GUIOption::flexibleWidth()), getSubStyleName(getGUIBackgroundTypeName()));
+		mMessage = GUIButton::create(HString(L""), GUIOptions(GUIOption::flexibleWidth()), getSubStyleName(getGUIMessageTypeName()));
+
+		GUILayoutX* horzLayout = mPanel->addNewElement<GUILayoutX>();
+		horzLayout->addNewElement<GUIFixedSpace>(10);
+		horzLayout->addElement(mMessage);
+		horzLayout->addNewElement<GUIFixedSpace>(20);
+
+		mBgPanel->addElement(mBackground);
+
+		mLogEntryAddedConn = gDebug().getLog().onEntryAdded.connect(std::bind(&GUIStatusBar::logEntryAdded, this, _1));
+		mMessageBtnPressedConn = mMessage->onClick.connect(std::bind(&GUIStatusBar::messageBtnClicked, this));
+	}
+
+	GUIStatusBar::~GUIStatusBar()
+	{
+		mLogEntryAddedConn.disconnect();
+		mMessageBtnPressedConn.disconnect();
+	}
+
+	GUIStatusBar* GUIStatusBar::create(const GUIOptions& options, const String& style)
+	{
+		const String* curStyle = &style;
+		if (*curStyle == StringUtil::BLANK)
+			curStyle = &getGUITypeName();
+
+		return bs_new<GUIStatusBar>(PrivatelyConstruct(), *curStyle, GUIDimensions::create(options));
+	}
+
+	GUIStatusBar* GUIStatusBar::create(const String& style)
+	{
+		const String* curStyle = &style;
+		if (*curStyle == StringUtil::BLANK)
+			curStyle = &getGUITypeName();
+
+		return bs_new<GUIStatusBar>(PrivatelyConstruct(), *curStyle, GUIDimensions::create());
+	}
+	
+	void GUIStatusBar::setTint(const Color& color)
+	{
+		mBackground->setTint(color);
+		mMessage->setTint(color);
+	}
+
+	void GUIStatusBar::_updateLayoutInternal(const GUILayoutData& data)
+	{
+		mPanel->_setLayoutData(data);
+		mPanel->_updateLayoutInternal(data);
+
+		mBgPanel->_setLayoutData(data);
+		mBgPanel->_updateLayoutInternal(data);
+	}
+
+	Vector2I GUIStatusBar::_getOptimalSize() const
+	{
+		return mBgPanel->_getOptimalSize();
+	}
+	
+	void GUIStatusBar::styleUpdated()
+	{
+		mBackground->setStyle(getSubStyleName(getGUIBackgroundTypeName()));
+		mMessage->setStyle(getSubStyleName(getGUIMessageTypeName()));
+	}
+
+	void GUIStatusBar::logEntryAdded(const LogEntry& entry)
+	{
+		HSpriteTexture iconTexture;
+
+		UINT32 logChannel = entry.getChannel();
+		switch (logChannel)
+		{
+		case (UINT32)DebugChannel::Info:
+		case (UINT32)DebugChannel::Debug:
+			iconTexture = BuiltinEditorResources::instance().getLogMessageIcon(LogMessageIcon::Info);
+			break;
+		case (UINT32)DebugChannel::Warning:
+			iconTexture = BuiltinEditorResources::instance().getLogMessageIcon(LogMessageIcon::Warning);
+			break;
+		case (UINT32)DebugChannel::Error:
+			iconTexture = BuiltinEditorResources::instance().getLogMessageIcon(LogMessageIcon::Error);
+			break;
+		}
+
+		GUIContent messageContent(HString(toWString(entry.getMessage())), iconTexture);
+		mMessage->setContent(messageContent);
+	}
+
+	void GUIStatusBar::messageBtnClicked()
+	{
+		onMessageClicked();
+	}
+
+	const String& GUIStatusBar::getGUITypeName()
+	{
+		static String TypeName = "GUIStatusBar";
+		return TypeName;
+	}
+
+	const String& GUIStatusBar::getGUIBackgroundTypeName()
+	{
+		static String TypeName = "GUIStatusBarBg";
+		return TypeName;
+	}
+
+	const String& GUIStatusBar::getGUIMessageTypeName()
+	{
+		static String TypeName = "GUIStatusBarMessage";
+		return TypeName;
+	}
+}

+ 10 - 1
BansheeEditor/Source/BsMainEditorWindow.cpp

@@ -4,6 +4,7 @@
 #include "BsGUIMenuBar.h"
 #include "BsGUIWidget.h"
 #include "BsGUIPanel.h"
+#include "BsGUIStatusBar.h"
 #include "BsEditorTestSuite.h"
 #include "BsTestOutput.h"
 
@@ -20,6 +21,8 @@ namespace BansheeEngine
 	{
 		mDockManager = DockManager::create(this);
 		mGUI->getPanel()->addElement(mDockManager);
+		mStatusBar = GUIStatusBar::create();
+		mGUI->getPanel()->addElement(mStatusBar);
 
 		updateAreas();
 
@@ -36,6 +39,7 @@ namespace BansheeEngine
 	{
 		mDockManager->closeAll();
 		GUIElement::destroy(mDockManager);
+		GUIElement::destroy(mStatusBar);
 		bs_delete(mMenuBar);
 	}
 
@@ -54,8 +58,13 @@ namespace BansheeEngine
 		UINT32 menuBarHeight = 15;
 		mMenuBar->setArea(1, 1, widgetWidth, menuBarHeight);
 
-		UINT32 dockHeight = (UINT32)std::max(0, (INT32)widgetHeight - (INT32)menuBarHeight);
+		UINT32 statusBarHeight = 20;
+		UINT32 dockHeight = (UINT32)std::max(0, (INT32)widgetHeight - (INT32)(menuBarHeight + statusBarHeight));
 		mDockManager->setArea(1, menuBarHeight + 1, widgetWidth, dockHeight);
+
+		mStatusBar->setPosition(1, 1 + menuBarHeight + dockHeight);
+		mStatusBar->setWidth(widgetWidth);
+		mStatusBar->setHeight(statusBarHeight);
 	}
 
 	void MainEditorWindow::update()

+ 11 - 11
BansheeEngine/Include/BsGUIButtonBase.h

@@ -57,12 +57,12 @@ namespace BansheeEngine
 		/**
 		 * @copydoc	GUIElement::_getOptimalSize
 		 */
-		virtual Vector2I _getOptimalSize() const;
+		virtual Vector2I _getOptimalSize() const override;
 
 		/**
 		 * @copydoc GUIElement::_getRenderElementDepthRange
 		 */
-		virtual UINT32 _getRenderElementDepthRange() const;
+		virtual UINT32 _getRenderElementDepthRange() const override;
 
 		/**
 		 * @brief	Triggered when button is clicked.
@@ -90,43 +90,43 @@ namespace BansheeEngine
 		/**
 		 * @copydoc GUIElement::getNumRenderElements
 		 */
-		virtual UINT32 _getNumRenderElements() const;
+		virtual UINT32 _getNumRenderElements() const override;
 
 		/**
 		 * @copydoc GUIElement::getMaterial
 		 */
-		virtual const GUIMaterialInfo& _getMaterial(UINT32 renderElementIdx) const;
+		virtual const GUIMaterialInfo& _getMaterial(UINT32 renderElementIdx) const override;
 
 		/**
 		 * @copydoc GUIElement::getNumQuads
 		 */
-		virtual UINT32 _getNumQuads(UINT32 renderElementIdx) const;
+		virtual UINT32 _getNumQuads(UINT32 renderElementIdx) const override;
 
 		/**
 		 * @copydoc GUIElement::fillBuffer
 		 */
 		virtual void _fillBuffer(UINT8* vertices, UINT8* uv, UINT32* indices, UINT32 startingQuad, 
-			UINT32 maxNumQuads, UINT32 vertexStride, UINT32 indexStride, UINT32 renderElementIdx) const;
+			UINT32 maxNumQuads, UINT32 vertexStride, UINT32 indexStride, UINT32 renderElementIdx) const override;
 
 		/**
 		 * @copydoc GUIElement::updateRenderElementsInternal
 		 */
-		virtual void updateRenderElementsInternal();
+		virtual void updateRenderElementsInternal() override;
 
 		/**
 		 * @copydoc GUIElement::updateBounds
 		 */
-		virtual void updateClippedBounds();
+		virtual void updateClippedBounds() override;
 
 		/**
 		 * @copydoc GUIElement::mouseEvent
 		 */
-		virtual bool _mouseEvent(const GUIMouseEvent& ev);
+		virtual bool _mouseEvent(const GUIMouseEvent& ev) override;
 
 		/**
 		 * @copydoc GUIElement::_getRenderElementDepth
 		 */
-		virtual UINT32 _getRenderElementDepth(UINT32 renderElementIdx) const;
+		virtual UINT32 _getRenderElementDepth(UINT32 renderElementIdx) const override;
 
 		/**
 		 * @brief	Gets the text sprite descriptor used for creating/updating the internal text sprite.
@@ -139,7 +139,7 @@ namespace BansheeEngine
 		void setState(GUIButtonState state);
 
 		/**
-		 * @brief	Retrieves interal button state.
+		 * @brief	Retrieves internal button state.
 		 */
 		GUIButtonState getState() const { return mActiveState; }
 

+ 2 - 2
BansheeEngine/Include/BsGUILayout.h

@@ -72,12 +72,12 @@ namespace BansheeEngine
 		/**
 		 * @copydoc	GUIElementBase::_getOptimalSize
 		 */
-		Vector2I _getOptimalSize() const { return mSizeRange.optimal; }
+		Vector2I _getOptimalSize() const override { return mSizeRange.optimal; }
 
 		/**
 		 * @copydoc	GUIElementBase::_getPadding
 		 */
-		const RectOffset& _getPadding() const;
+		const RectOffset& _getPadding() const override;
 
 		/**
 		 * @copydoc	GUIElementBase::_getType

+ 5 - 5
BansheeEngine/Include/BsGUILayoutX.h

@@ -19,23 +19,23 @@ namespace BansheeEngine
 		/**
 		 * @brief	Calculate optimal sizes of all child layout elements.
 		 */
-		void _updateOptimalLayoutSizes();
+		void _updateOptimalLayoutSizes() override;
 
 		/**
 		 * @copydoc	GUIElementBase::_calculateLayoutSizeRange
 		 */
-		virtual LayoutSizeRange _calculateLayoutSizeRange() const;
+		virtual LayoutSizeRange _calculateLayoutSizeRange() const override;
 
 		/**
 		 * @copydoc	GUILayout::_getElementAreas
 		 */
 		void _getElementAreas(const Rect2I& layoutArea, Rect2I* elementAreas, UINT32 numElements,
-			const Vector<LayoutSizeRange>& sizeRanges, const LayoutSizeRange& mySizeRange) const;
+			const Vector<LayoutSizeRange>& sizeRanges, const LayoutSizeRange& mySizeRange) const override;
 
 		/**
 		 * @copydoc	GUILayout::_calcActualSize
 		 */
-		virtual Vector2I _calcActualSize(INT32 x, INT32 y, Rect2I* elementAreas, UINT32 numElements) const;
+		virtual Vector2I _calcActualSize(INT32 x, INT32 y, Rect2I* elementAreas, UINT32 numElements) const override;
 
 		/**
 		 * @brief	Creates a new horizontal layout.
@@ -53,6 +53,6 @@ namespace BansheeEngine
 		/**
 		 * @copydoc	GUIElementBase::_updateLayoutInternal
 		 */
-		void _updateLayoutInternal(const GUILayoutData& data);
+		void _updateLayoutInternal(const GUILayoutData& data) override;
 	};
 }

+ 1 - 1
BansheeEngine/Include/BsGUILayoutY.h

@@ -53,6 +53,6 @@ namespace BansheeEngine
 		/**
 		 * @copydoc	GUIElementBase::_updateLayoutInternal
 		 */
-		void _updateLayoutInternal(const GUILayoutData& data);
+		void _updateLayoutInternal(const GUILayoutData& data) override;
 	};
 }

+ 5 - 5
BansheeEngine/Include/BsGUIPanel.h

@@ -64,6 +64,11 @@ namespace BansheeEngine
 		 */
 		virtual Vector2I _calcActualSize(INT32 x, INT32 y, Rect2I* elementAreas, UINT32 numElements) const override;
 
+		/**
+		 * @copydoc	GUIElementBase::_updateLayoutInternal
+		 */
+		void _updateLayoutInternal(const GUILayoutData& data) override;
+
 		/**
 		 * @brief	Changes values that control at which depth is GUI panel and its children rendered.
 		 *
@@ -120,11 +125,6 @@ namespace BansheeEngine
 		static GUIPanel* create(INT16 depth, UINT16 depthRangeMin, UINT16 depthRangeMax, const GUIOptions& options);
 
 	protected:
-		/**
-		 * @copydoc	GUIElementBase::_updateLayoutInternal
-		 */
-		void _updateLayoutInternal(const GUILayoutData& data) override;
-
 		INT16 mDepthOffset;
 		UINT16 mDepthRangeMin;
 		UINT16 mDepthRangeMax;

+ 24 - 2
BansheeEngine/Source/BsGUIButtonBase.cpp

@@ -128,10 +128,32 @@ namespace BansheeEngine
 
 		if(mContentImageSprite != nullptr)
 		{
+			Rect2I contentBounds = getCachedContentBounds();
+
+			UINT32 contentWidth = mContent.getImage()->getWidth();
+			UINT32 contentHeight = mContent.getImage()->getHeight();
+
+			UINT32 contentMaxWidth = std::min((UINT32)contentBounds.width, contentWidth);
+			UINT32 contentMaxHeight = std::min((UINT32)contentBounds.height, contentHeight);
+
+			float horzRatio = contentMaxWidth / (float)contentWidth;
+			float vertRatio = contentMaxHeight / (float)contentHeight;
+
+			if (horzRatio < vertRatio)
+			{
+				contentWidth = Math::roundToInt(contentWidth * horzRatio);
+				contentHeight = Math::roundToInt(contentHeight * horzRatio);
+			}
+			else
+			{
+				contentWidth = Math::roundToInt(contentWidth * vertRatio);
+				contentHeight = Math::roundToInt(contentHeight * vertRatio);
+			}
+
 			IMAGE_SPRITE_DESC contentImgDesc;
 			contentImgDesc.texture = mContent.getImage().getInternalPtr();
-			contentImgDesc.width = std::min(mImageDesc.width, mContent.getImage()->getWidth());
-			contentImgDesc.height = std::min(mImageDesc.height, mContent.getImage()->getHeight());
+			contentImgDesc.width = contentWidth;
+			contentImgDesc.height = contentHeight;
 			contentImgDesc.color = mColor;
 
 			mContentImageSprite->update(contentImgDesc, (UINT64)_getParentWidget());

+ 2 - 2
BansheeFreeImgImporter/Source/BsFreeImgImporter.cpp

@@ -22,11 +22,11 @@ namespace BansheeEngine
 		const char* typeName = FreeImage_GetFormatFromFIF(fif);
 		if (typeName)
 		{
-			gDebug().log("FreeImage error: '" + String(message) + "' when loading format " + typeName, "AssetImport");
+			gDebug().logError("FreeImage error: '" + String(message) + "' when loading format " + typeName);
 		}
 		else
 		{
-			gDebug().log("FreeImage error: '" + String(message) + "'", "AssetImport");
+			gDebug().logError("FreeImage error: '" + String(message) + "'");
 		}
 	}
 

+ 9 - 1
BansheeUtility/Include/BsDebug.h

@@ -7,6 +7,14 @@ namespace BansheeEngine
 {
 	class Log;
 
+	/**
+	 * @brief	Available types of channels that debug messages can be logged to.
+	 */
+	enum class DebugChannel
+	{
+		Debug, Info, Warning, Error
+	};
+
 	/**
 	 * @brief	Utility class providing various debug functionality. Thread safe.
 	 */
@@ -36,7 +44,7 @@ namespace BansheeEngine
 		/**
 		 * @brief	Adds a log entry in the specified channel. You may specify custom channels as needed.
 		 */
-		void log(const String& msg, const String& channel);
+		void log(const String& msg, UINT32 channel);
 
 		/**
 		 * @brief	Retrieves the Log used by the Debug instance.

+ 1 - 0
BansheeUtility/Include/BsFwdDeclUtil.h

@@ -61,6 +61,7 @@ namespace BansheeEngine
 	struct SerializedObject;
 	struct SerializedInstance;
 	class FrameAlloc;
+	class LogEntry;
 	// Reflection
 	class IReflectable;
 	class RTTITypeBase;

+ 5 - 5
BansheeUtility/Include/BsLog.h

@@ -12,14 +12,14 @@ namespace BansheeEngine
 	class BS_UTILITY_EXPORT LogEntry
 	{
 	public:
-		LogEntry(const String& msg, const String& channel);
+		LogEntry(const String& msg, UINT32 channel);
 
-		const String& getChannel(void) { return mChannel; }
-		const String& getMessage(void) { return mMsg; }
+		UINT32 getChannel() const { return mChannel; }
+		const String& getMessage() const { return mMsg; }
 
 	private:
 		String mMsg;
-		String mChannel;
+		UINT32 mChannel;
 	};
 
 	/**
@@ -40,7 +40,7 @@ namespace BansheeEngine
 		 * @param	message	The message describing the log entry.
 		 * @param	channel Channel in which to store the log entry.
 		 */
-		void logMsg(const String& message, const String& channel);
+		void logMsg(const String& message, UINT32 channel);
 
 		/**
 		 * @brief	Removes all log entries. 

+ 5 - 5
BansheeUtility/Source/BsDebug.cpp

@@ -28,29 +28,29 @@ namespace BansheeEngine
 {
 	void Debug::logDebug(const String& msg)
 	{
-		mLog.logMsg(msg, "GlobalDebug");
+		mLog.logMsg(msg, (UINT32)DebugChannel::Debug);
 		logToIDEConsole(msg);
 	}
 
 	void Debug::logInfo(const String& msg)
 	{
-		mLog.logMsg(msg, "GlobalInfo");
+		mLog.logMsg(msg, (UINT32)DebugChannel::Info);
 		logToIDEConsole(msg);
 	}
 
 	void Debug::logWarning(const String& msg)
 	{
-		mLog.logMsg(msg, "GlobalWarning");
+		mLog.logMsg(msg, (UINT32)DebugChannel::Warning);
 		logToIDEConsole(msg);
 	}
 
 	void Debug::logError(const String& msg)
 	{
-		mLog.logMsg(msg, "GlobalError");
+		mLog.logMsg(msg, (UINT32)DebugChannel::Error);
 		logToIDEConsole(msg);
 	}
 
-	void Debug::log(const String& msg, const String& channel)
+	void Debug::log(const String& msg, UINT32 channel)
 	{
 		mLog.logMsg(msg, channel);
 		logToIDEConsole(msg);

+ 4 - 4
BansheeUtility/Source/BsLog.cpp

@@ -3,8 +3,8 @@
 
 namespace BansheeEngine
 {
-	LogEntry::LogEntry(const String& msg, const String& level)
-		:mMsg(msg), mChannel(level)
+	LogEntry::LogEntry(const String& msg, UINT32 channel)
+		:mMsg(msg), mChannel(channel)
 	{ }
 
 	Log::Log()
@@ -19,11 +19,11 @@ namespace BansheeEngine
 			bs_delete<PoolAlloc>(*iter);
 	}
 
-	void Log::logMsg(const String& message, const String& level)
+	void Log::logMsg(const String& message, UINT32 channel)
 	{
 		BS_LOCK_RECURSIVE_MUTEX(mMutex);
 
-		LogEntry* newEntry = bs_new<LogEntry, PoolAlloc>(message, level);
+		LogEntry* newEntry = bs_new<LogEntry>(message, channel);
 		mEntries.push_back(newEntry);
 
 		doOnEntryAdded(*newEntry);

+ 3 - 3
SBansheeEngine/Source/BsScriptDebug.cpp

@@ -19,16 +19,16 @@ namespace BansheeEngine
 
 	void ScriptDebug::internal_log(MonoString* message)
 	{
-		gDebug().log(MonoUtil::monoToString(message), "ScriptInfo");
+		gDebug().logInfo(MonoUtil::monoToString(message));
 	}
 
 	void ScriptDebug::internal_logWarning(MonoString* message)
 	{
-		gDebug().log(MonoUtil::monoToString(message), "ScriptWarning");
+		gDebug().logWarning(MonoUtil::monoToString(message));
 	}
 
 	void ScriptDebug::internal_logError(MonoString* message)
 	{
-		gDebug().log(MonoUtil::monoToString(message), "ScriptError");
+		gDebug().logError(MonoUtil::monoToString(message));
 	}
 }

+ 5 - 12
TODO.txt

@@ -57,6 +57,8 @@ Code quality improvements:
 ----------------------------------------------------------------------
 Polish stage 1
 
+Test GUITextureField
+Test GUIStatusBar
 Test inspector selection, selecting a resource and adding/removing component updates
 Showing the inspector causes a considerable slowdown (maybe stuff gets refreshed too often?)
 Crash when showing the inspector (invalid index in Layout.InsertElement)
@@ -67,7 +69,6 @@ Crash on shutdown in mono_gchandle_free
 Material/Shader has no color type so I cannot know when to display normal vector and when color in inspector
 
 First screenshot work:
-- Inspector change contents on selection (and make sure the selected object/component looks okay)
 - Additional menu bar items: 
  - File: Exit, Save Project, New Project, Open Project, Save Scene As
  - Edit: Undo/Redo, Cut/Copy/Paste/Duplicate/Delete(need to make sure it works in Hierarchy, with shortcuts), Frame Selected, Preferences, Play/Pause/Step
@@ -76,21 +77,18 @@ First screenshot work:
    - Possibly create helper objects: Cube, Sphere, Plane, Quad, Capsule, Cylinder
  - Component (also add to inspector context): Camera, Renderable, Point/Spot/Directional light, all other components from scripts
  - Help - About, API Reference (link to site)
-- Status bar with last console message
+- Camera & Renderable inspector
+- (Optionally) New UI look (tabs, component/array containers, better buttons)
 - (Optionally) Console window
 
 -----------
 
 SceneTreeView
  - Hook up ping effect so it triggers when I select a resource or sceneobject
+   - Add Selection::ping method to both C++ and C# and an Event that triggers when its called
  - See if it needs other enhancements (rename, delete all work properly? etc.)
  - Add copy/cut/paste/duplicate (with context menu)
 
-Finish up inspector
- - Do I handle the case of updating the inspector when component is added or removed?
- - Hook it up to Selection changes so it shows inspector for current component/resource
- - GUI TextureField similar to ResourceField but it displays the texture it has assigned
-
 Need a way to add scene objects and components (and remove them)
  - Components adding should be only done by drag and dropping scripts to inspector (undoable)
  - COmponent removal should be done by context menu in inspector (undoable)
@@ -104,11 +102,6 @@ Drag to select in scene view
 
 Replace "minimize" button in tabbed title bar with maximize and make sure it works
 
-Will need a status bar:
- - Displays last error message
- - Opens up console on click
- - Indicator when compiling
-
 Make sure to persist EditorSettings
 
 Later: