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

Scroll bar handle size is now saved in percentage so that is properly resizes when the scrollbar size changes

BearishSun преди 9 години
родител
ревизия
546d1ebef0
променени са 57 файла, в които са добавени 66 реда и са изтрити 33 реда
  1. BIN
      Data/Editor/GUISkin.asset
  2. BIN
      Data/Editor/Icons/Sprites/sprite_AnimationClipIcon.psd16.asset
  3. BIN
      Data/Editor/Icons/Sprites/sprite_AnimationClipIcon.psd32.asset
  4. BIN
      Data/Editor/Icons/Sprites/sprite_AnimationClipIcon.psd48.asset
  5. BIN
      Data/Editor/Icons/Sprites/sprite_AudioClipIcon.psd16.asset
  6. BIN
      Data/Editor/Icons/Sprites/sprite_AudioClipIcon.psd32.asset
  7. BIN
      Data/Editor/Icons/Sprites/sprite_AudioClipIcon.psd48.asset
  8. BIN
      Data/Editor/Icons/Sprites/sprite_CSharpIcon.psd16.asset
  9. BIN
      Data/Editor/Icons/Sprites/sprite_CSharpIcon.psd32.asset
  10. BIN
      Data/Editor/Icons/Sprites/sprite_CSharpIcon.psd48.asset
  11. BIN
      Data/Editor/Icons/Sprites/sprite_FolderIcon.psd16.asset
  12. BIN
      Data/Editor/Icons/Sprites/sprite_FolderIcon.psd32.asset
  13. BIN
      Data/Editor/Icons/Sprites/sprite_FolderIcon.psd48.asset
  14. BIN
      Data/Editor/Icons/Sprites/sprite_FontIcon.psd16.asset
  15. BIN
      Data/Editor/Icons/Sprites/sprite_FontIcon.psd32.asset
  16. BIN
      Data/Editor/Icons/Sprites/sprite_FontIcon.psd48.asset
  17. BIN
      Data/Editor/Icons/Sprites/sprite_GUISkinIcon.psd16.asset
  18. BIN
      Data/Editor/Icons/Sprites/sprite_GUISkinIcon.psd32.asset
  19. BIN
      Data/Editor/Icons/Sprites/sprite_GUISkinIcon.psd48.asset
  20. BIN
      Data/Editor/Icons/Sprites/sprite_MaterialIcon.psd16.asset
  21. BIN
      Data/Editor/Icons/Sprites/sprite_MaterialIcon.psd32.asset
  22. BIN
      Data/Editor/Icons/Sprites/sprite_MaterialIcon.psd48.asset
  23. BIN
      Data/Editor/Icons/Sprites/sprite_MeshIcon.psd16.asset
  24. BIN
      Data/Editor/Icons/Sprites/sprite_MeshIcon.psd32.asset
  25. BIN
      Data/Editor/Icons/Sprites/sprite_MeshIcon.psd48.asset
  26. BIN
      Data/Editor/Icons/Sprites/sprite_PhysicsMaterialIcon.psd16.asset
  27. BIN
      Data/Editor/Icons/Sprites/sprite_PhysicsMaterialIcon.psd32.asset
  28. BIN
      Data/Editor/Icons/Sprites/sprite_PhysicsMaterialIcon.psd48.asset
  29. BIN
      Data/Editor/Icons/Sprites/sprite_PhysicsMeshIcon.psd16.asset
  30. BIN
      Data/Editor/Icons/Sprites/sprite_PhysicsMeshIcon.psd32.asset
  31. BIN
      Data/Editor/Icons/Sprites/sprite_PhysicsMeshIcon.psd48.asset
  32. BIN
      Data/Editor/Icons/Sprites/sprite_PrefabIcon.psd16.asset
  33. BIN
      Data/Editor/Icons/Sprites/sprite_PrefabIcon.psd32.asset
  34. BIN
      Data/Editor/Icons/Sprites/sprite_PrefabIcon.psd48.asset
  35. BIN
      Data/Editor/Icons/Sprites/sprite_ShaderIcon.psd16.asset
  36. BIN
      Data/Editor/Icons/Sprites/sprite_ShaderIcon.psd32.asset
  37. BIN
      Data/Editor/Icons/Sprites/sprite_ShaderIcon.psd48.asset
  38. BIN
      Data/Editor/Icons/Sprites/sprite_ShaderIncludeIcon.psd16.asset
  39. BIN
      Data/Editor/Icons/Sprites/sprite_ShaderIncludeIcon.psd32.asset
  40. BIN
      Data/Editor/Icons/Sprites/sprite_ShaderIncludeIcon.psd48.asset
  41. BIN
      Data/Editor/Icons/Sprites/sprite_SpriteIcon.psd16.asset
  42. BIN
      Data/Editor/Icons/Sprites/sprite_SpriteIcon.psd32.asset
  43. BIN
      Data/Editor/Icons/Sprites/sprite_SpriteIcon.psd48.asset
  44. BIN
      Data/Editor/Icons/Sprites/sprite_TextIcon.psd16.asset
  45. BIN
      Data/Editor/Icons/Sprites/sprite_TextIcon.psd32.asset
  46. BIN
      Data/Editor/Icons/Sprites/sprite_TextIcon.psd48.asset
  47. BIN
      Data/Editor/Icons/Sprites/sprite_TextureIcon.psd16.asset
  48. BIN
      Data/Editor/Icons/Sprites/sprite_TextureIcon.psd32.asset
  49. BIN
      Data/Editor/Icons/Sprites/sprite_TextureIcon.psd48.asset
  50. BIN
      Data/Editor/ResourceManifest.asset
  51. BIN
      Data/Editor/Timestamp.asset
  52. BIN
      Data/Editor/arial.ttf.asset
  53. BIN
      Data/Editor/arialAA.ttf.asset
  54. 4 4
      Source/BansheeEditor/Source/BsBuiltinEditorResources.cpp
  55. 1 1
      Source/BansheeEngine/Include/BsGUIScrollBar.h
  56. 8 2
      Source/BansheeEngine/Include/BsGUISliderHandle.h
  57. 53 26
      Source/BansheeEngine/Source/BsGUISliderHandle.cpp

BIN
Data/Editor/GUISkin.asset


BIN
Data/Editor/Icons/Sprites/sprite_AnimationClipIcon.psd16.asset


BIN
Data/Editor/Icons/Sprites/sprite_AnimationClipIcon.psd32.asset


BIN
Data/Editor/Icons/Sprites/sprite_AnimationClipIcon.psd48.asset


BIN
Data/Editor/Icons/Sprites/sprite_AudioClipIcon.psd16.asset


BIN
Data/Editor/Icons/Sprites/sprite_AudioClipIcon.psd32.asset


BIN
Data/Editor/Icons/Sprites/sprite_AudioClipIcon.psd48.asset


BIN
Data/Editor/Icons/Sprites/sprite_CSharpIcon.psd16.asset


BIN
Data/Editor/Icons/Sprites/sprite_CSharpIcon.psd32.asset


BIN
Data/Editor/Icons/Sprites/sprite_CSharpIcon.psd48.asset


BIN
Data/Editor/Icons/Sprites/sprite_FolderIcon.psd16.asset


BIN
Data/Editor/Icons/Sprites/sprite_FolderIcon.psd32.asset


BIN
Data/Editor/Icons/Sprites/sprite_FolderIcon.psd48.asset


BIN
Data/Editor/Icons/Sprites/sprite_FontIcon.psd16.asset


BIN
Data/Editor/Icons/Sprites/sprite_FontIcon.psd32.asset


BIN
Data/Editor/Icons/Sprites/sprite_FontIcon.psd48.asset


BIN
Data/Editor/Icons/Sprites/sprite_GUISkinIcon.psd16.asset


BIN
Data/Editor/Icons/Sprites/sprite_GUISkinIcon.psd32.asset


BIN
Data/Editor/Icons/Sprites/sprite_GUISkinIcon.psd48.asset


BIN
Data/Editor/Icons/Sprites/sprite_MaterialIcon.psd16.asset


BIN
Data/Editor/Icons/Sprites/sprite_MaterialIcon.psd32.asset


BIN
Data/Editor/Icons/Sprites/sprite_MaterialIcon.psd48.asset


BIN
Data/Editor/Icons/Sprites/sprite_MeshIcon.psd16.asset


BIN
Data/Editor/Icons/Sprites/sprite_MeshIcon.psd32.asset


BIN
Data/Editor/Icons/Sprites/sprite_MeshIcon.psd48.asset


BIN
Data/Editor/Icons/Sprites/sprite_PhysicsMaterialIcon.psd16.asset


BIN
Data/Editor/Icons/Sprites/sprite_PhysicsMaterialIcon.psd32.asset


BIN
Data/Editor/Icons/Sprites/sprite_PhysicsMaterialIcon.psd48.asset


BIN
Data/Editor/Icons/Sprites/sprite_PhysicsMeshIcon.psd16.asset


BIN
Data/Editor/Icons/Sprites/sprite_PhysicsMeshIcon.psd32.asset


BIN
Data/Editor/Icons/Sprites/sprite_PhysicsMeshIcon.psd48.asset


BIN
Data/Editor/Icons/Sprites/sprite_PrefabIcon.psd16.asset


BIN
Data/Editor/Icons/Sprites/sprite_PrefabIcon.psd32.asset


BIN
Data/Editor/Icons/Sprites/sprite_PrefabIcon.psd48.asset


BIN
Data/Editor/Icons/Sprites/sprite_ShaderIcon.psd16.asset


BIN
Data/Editor/Icons/Sprites/sprite_ShaderIcon.psd32.asset


BIN
Data/Editor/Icons/Sprites/sprite_ShaderIcon.psd48.asset


BIN
Data/Editor/Icons/Sprites/sprite_ShaderIncludeIcon.psd16.asset


BIN
Data/Editor/Icons/Sprites/sprite_ShaderIncludeIcon.psd32.asset


BIN
Data/Editor/Icons/Sprites/sprite_ShaderIncludeIcon.psd48.asset


BIN
Data/Editor/Icons/Sprites/sprite_SpriteIcon.psd16.asset


BIN
Data/Editor/Icons/Sprites/sprite_SpriteIcon.psd32.asset


BIN
Data/Editor/Icons/Sprites/sprite_SpriteIcon.psd48.asset


BIN
Data/Editor/Icons/Sprites/sprite_TextIcon.psd16.asset


BIN
Data/Editor/Icons/Sprites/sprite_TextIcon.psd32.asset


BIN
Data/Editor/Icons/Sprites/sprite_TextIcon.psd48.asset


BIN
Data/Editor/Icons/Sprites/sprite_TextureIcon.psd16.asset


BIN
Data/Editor/Icons/Sprites/sprite_TextureIcon.psd32.asset


BIN
Data/Editor/Icons/Sprites/sprite_TextureIcon.psd48.asset


BIN
Data/Editor/ResourceManifest.asset


BIN
Data/Editor/Timestamp.asset


BIN
Data/Editor/arial.ttf.asset


BIN
Data/Editor/arialAA.ttf.asset


+ 4 - 4
Source/BansheeEditor/Source/BsBuiltinEditorResources.cpp

@@ -849,7 +849,7 @@ namespace BansheeEngine
 		scrollBarHorzBtnStyle.active.texture = getGUITexture(ScrollBarHandleHorzActiveTex);
 		scrollBarHorzBtnStyle.fixedHeight = true;
 		scrollBarHorzBtnStyle.fixedWidth = false;
-		scrollBarHorzBtnStyle.width = 10;
+		scrollBarHorzBtnStyle.minWidth = 10;
 		scrollBarHorzBtnStyle.height = 13;
 		scrollBarHorzBtnStyle.border.left = 4;
 		scrollBarHorzBtnStyle.border.right = 4;
@@ -864,7 +864,7 @@ namespace BansheeEngine
 		scrollBarVertBtnStyle.fixedHeight = false;
 		scrollBarVertBtnStyle.fixedWidth = true;
 		scrollBarVertBtnStyle.width = 13;
-		scrollBarVertBtnStyle.height = 10;
+		scrollBarVertBtnStyle.minHeight = 10;
 		scrollBarVertBtnStyle.border.top = 4;
 		scrollBarVertBtnStyle.border.bottom = 4;
 
@@ -907,7 +907,7 @@ namespace BansheeEngine
 		scrollBarHorzResizeableBtnStyle.active.texture = getGUITexture(ScrollBarResizeableHandleHorzActiveTex);
 		scrollBarHorzResizeableBtnStyle.fixedHeight = true;
 		scrollBarHorzResizeableBtnStyle.fixedWidth = false;
-		scrollBarHorzResizeableBtnStyle.width = 15;
+		scrollBarHorzResizeableBtnStyle.minWidth = 15;
 		scrollBarHorzResizeableBtnStyle.height = 13;
 		scrollBarHorzResizeableBtnStyle.border.left = 7;
 		scrollBarHorzResizeableBtnStyle.border.right = 7;
@@ -922,7 +922,7 @@ namespace BansheeEngine
 		scrollBarVertResizeableBtnStyle.fixedHeight = false;
 		scrollBarVertResizeableBtnStyle.fixedWidth = true;
 		scrollBarVertResizeableBtnStyle.width = 13;
-		scrollBarVertResizeableBtnStyle.height = 15;
+		scrollBarVertResizeableBtnStyle.minHeight = 15;
 		scrollBarVertResizeableBtnStyle.border.top = 7;
 		scrollBarVertResizeableBtnStyle.border.bottom = 7;
 

+ 1 - 1
Source/BansheeEngine/Include/BsGUIScrollBar.h

@@ -115,7 +115,7 @@ namespace BansheeEngine
 		/** @copydoc	GUIElement::_getRenderElementDepthRange */
 		UINT32 _getRenderElementDepthRange() const override;
 
-		/** @copydoc GUIElementContainer::styleUpdated */
+		/** @copydoc GUIElement::styleUpdated */
 		void styleUpdated() override;
 
 		/**

+ 8 - 2
Source/BansheeEngine/Include/BsGUISliderHandle.h

@@ -157,17 +157,23 @@ namespace BansheeEngine
 		/**	Sets the position of the slider handle, in pixels. Relative to this object. */
 		void setHandlePosPx(INT32 pos);
 
+		/** Returns the size of the handle button, in pixels. */
+		UINT32 getHandleSize() const;
+
 		/**	Gets the currently active texture, depending on handle state. */
 		const HSpriteTexture& getActiveTexture() const;
 
-		static const UINT32 MIN_HANDLE_SIZE;
+		/** @copydoc GUIElement::styleUpdated */
+		void styleUpdated() override;
+
 		static const UINT32 RESIZE_HANDLE_SIZE;
 
 		ImageSprite* mImageSprite;
-		UINT32 mHandleSize;
 
 		GUISliderHandleFlags mFlags;
+		UINT32 mMinHandleSize;
 		float mPctHandlePos;
+		float mPctHandleSize;
 		float mStep;
 		INT32 mDragStartPos;
 		DragState mDragState;

+ 53 - 26
Source/BansheeEngine/Source/BsGUISliderHandle.cpp

@@ -10,7 +10,6 @@
 
 namespace BansheeEngine
 {
-	const UINT32 GUISliderHandle::MIN_HANDLE_SIZE = 15;
 	const UINT32 GUISliderHandle::RESIZE_HANDLE_SIZE = 7;
 
 	const String& GUISliderHandle::getGUITypeName()
@@ -20,11 +19,14 @@ namespace BansheeEngine
 	}
 
 	GUISliderHandle::GUISliderHandle(GUISliderHandleFlags flags, const String& styleName, const GUIDimensions& dimensions)
-		: GUIElement(styleName, dimensions), mHandleSize(0), mFlags(flags), mPctHandlePos(0.0f), mStep(0.0f)
-		, mDragStartPos(0), mDragState(DragState::Normal), mMouseOverHandle(false), mHandleDragged(false)
+		: GUIElement(styleName, dimensions), mFlags(flags), mMinHandleSize(0), mPctHandlePos(0.0f), mPctHandleSize(0.0f)
+		, mStep(0.0f), mDragStartPos(0), mDragState(DragState::Normal), mMouseOverHandle(false), mHandleDragged(false)
 		, mState(State::Normal)
 	{
 		mImageSprite = bs_new<ImageSprite>();
+
+		// Calling virtual method is okay in this case
+		styleUpdated();
 	}
 
 	GUISliderHandle::~GUISliderHandle()
@@ -46,9 +48,7 @@ namespace BansheeEngine
 
 	void GUISliderHandle::_setHandleSize(float pct)
 	{
-		pct = Math::clamp01(pct);
-
-		mHandleSize = std::max(MIN_HANDLE_SIZE, (UINT32)(getMaxSize() * pct));
+		mPctHandleSize = Math::clamp01(pct);
 	}
 
 	void GUISliderHandle::_setHandlePos(float pct)
@@ -80,7 +80,7 @@ namespace BansheeEngine
 
 	UINT32 GUISliderHandle::getScrollableSize() const
 	{
-		return getMaxSize() - mHandleSize;
+		return getMaxSize() - getHandleSize();
 	}
 
 	UINT32 GUISliderHandle::_getNumRenderElements() const
@@ -110,21 +110,28 @@ namespace BansheeEngine
 		if(SpriteTexture::checkIsLoaded(activeTex))
 			desc.texture = activeTex.getInternalPtr();
 
+		UINT32 handleSize = getHandleSize();
 		if (mFlags.isSet(GUISliderHandleFlag::Horizontal))
 		{
-			if (mHandleSize == 0 && desc.texture != nullptr)
-				mHandleSize = desc.texture->getWidth();
+			if (handleSize == 0 && desc.texture != nullptr)
+			{
+				handleSize = desc.texture->getWidth();
+				mPctHandleSize = handleSize / (float)getMaxSize();
+			}
 
-			desc.width = mHandleSize;
+			desc.width = handleSize;
 			desc.height = mLayoutData.area.height;
 		}
 		else
 		{
-			if (mHandleSize == 0 && desc.texture != nullptr)
-				mHandleSize = desc.texture->getHeight();
+			if (handleSize == 0 && desc.texture != nullptr)
+			{
+				handleSize = desc.texture->getHeight();
+				mPctHandleSize = handleSize / (float)getMaxSize();
+			}
 
 			desc.width = mLayoutData.area.width;
-			desc.height = mHandleSize;
+			desc.height = handleSize;
 		}
 
 		desc.borderLeft = _getStyle()->border.left;
@@ -180,6 +187,8 @@ namespace BansheeEngine
 
 	bool GUISliderHandle::_mouseEvent(const GUIMouseEvent& ev)
 	{
+		UINT32 handleSize = getHandleSize();
+
 		if(ev.getType() == GUIMouseEventType::MouseMove)
 		{
 			if (!_isDisabled())
@@ -224,9 +233,9 @@ namespace BansheeEngine
 					float handlePosPx = 0.0f;
 
 					if (mFlags.isSet(GUISliderHandleFlag::Horizontal))
-						handlePosPx = (float)(ev.getPosition().x - (INT32)mLayoutData.area.x - mHandleSize * 0.5f);
+						handlePosPx = (float)(ev.getPosition().x - (INT32)mLayoutData.area.x - handleSize * 0.5f);
 					else
-						handlePosPx = (float)(ev.getPosition().y - (INT32)mLayoutData.area.y - mHandleSize * 0.5f);
+						handlePosPx = (float)(ev.getPosition().y - (INT32)mLayoutData.area.y - handleSize * 0.5f);
 
 					setHandlePosPx((INT32)handlePosPx);
 					onHandleMovedOrResized(mPctHandlePos, _getHandleSizePct());
@@ -239,7 +248,7 @@ namespace BansheeEngine
 
 					if(isResizeable)
 					{
-						INT32 right = left + mHandleSize;
+						INT32 right = left + handleSize;
 
 						INT32 clickPos = ev.getPosition().x;
 						if(clickPos >= left && clickPos < (left + (INT32)RESIZE_HANDLE_SIZE))
@@ -260,7 +269,7 @@ namespace BansheeEngine
 
 					if(isResizeable)
 					{
-						INT32 bottom = top + mHandleSize;
+						INT32 bottom = top + handleSize;
 
 						INT32 clickPos = ev.getPosition().y;
 						if (clickPos >= top && clickPos < (top + (INT32)RESIZE_HANDLE_SIZE))
@@ -301,7 +310,7 @@ namespace BansheeEngine
 				{
 					if(mDragState == DragState::LeftResize)
 					{
-						INT32 right = getHandlePosPx() + mHandleSize;
+						INT32 right = getHandlePosPx() + handleSize;
 						INT32 newHandleSize = right - handlePosPx;
 
 						_setHandleSize(newHandleSize / (float)getMaxSize());
@@ -359,13 +368,13 @@ namespace BansheeEngine
 						if (mStep > 0.0f)
 							stepSizePx = (UINT32)(mStep * getMaxSize());
 						else
-							stepSizePx = mHandleSize;
+							stepSizePx = handleSize;
 
 						INT32 handleOffset = 0;
 						if (mFlags.isSet(GUISliderHandleFlag::Horizontal))
 						{
 							INT32 handleLeft = (INT32)mLayoutData.area.x + handlePosPx;
-							INT32 handleRight = handleLeft + mHandleSize;
+							INT32 handleRight = handleLeft + handleSize;
 
 							if (ev.getPosition().x < handleLeft)
 								handleOffset -= stepSizePx;
@@ -375,7 +384,7 @@ namespace BansheeEngine
 						else
 						{
 							INT32 handleTop = (INT32)mLayoutData.area.y + handlePosPx;
-							INT32 handleBottom = handleTop + mHandleSize;
+							INT32 handleBottom = handleTop + handleSize;
 
 							if (ev.getPosition().y < handleTop)
 								handleOffset -= stepSizePx;
@@ -417,10 +426,11 @@ namespace BansheeEngine
 
 	bool GUISliderHandle::isOnHandle(const Vector2I& pos) const
 	{
+		UINT32 handleSize = getHandleSize();
 		if(mFlags.isSet(GUISliderHandleFlag::Horizontal))
 		{
 			INT32 left = (INT32)mLayoutData.area.x + getHandlePosPx();
-			INT32 right = left + mHandleSize;
+			INT32 right = left + handleSize;
 
 			if(pos.x >= left && pos.x < right)
 				return true;
@@ -428,7 +438,7 @@ namespace BansheeEngine
 		else
 		{
 			INT32 top = (INT32)mLayoutData.area.y + getHandlePosPx();
-			INT32 bottom = top + mHandleSize;
+			INT32 bottom = top + handleSize;
 
 			if(pos.y >= top && pos.y < bottom)
 				return true;
@@ -439,18 +449,35 @@ namespace BansheeEngine
 
 	INT32 GUISliderHandle::getHandlePosPx() const
 	{
-		UINT32 maxScrollAmount = getMaxSize() - mHandleSize;
+		UINT32 maxScrollAmount = getMaxSize() - getHandleSize();
 		return Math::floorToInt(mPctHandlePos * maxScrollAmount);
 	}
 
+	UINT32 GUISliderHandle::getHandleSize() const
+	{
+		return std::max(mMinHandleSize, (UINT32)(getMaxSize() * mPctHandleSize));
+	}
+
 	float GUISliderHandle::_getHandleSizePct() const
 	{
-		return Math::clamp01(mHandleSize / (float)getMaxSize());
+		return mPctHandleSize;
+	}
+
+	void GUISliderHandle::styleUpdated()
+	{
+		const GUIElementStyle* style = _getStyle();
+		if (style != nullptr)
+		{
+			if (mFlags.isSet(GUISliderHandleFlag::Horizontal))
+				mMinHandleSize = style->fixedWidth ? style->width : style->minWidth;
+			else
+				mMinHandleSize = style->fixedHeight ? style->height : style->minHeight;
+		}
 	}
 
 	void GUISliderHandle::setHandlePosPx(INT32 pos)
 	{
-		float maxScrollAmount = (float)getMaxSize() - mHandleSize;
+		float maxScrollAmount = (float)getMaxSize() - getHandleSize();
 		_setHandlePos(pos / maxScrollAmount);
 	}