Просмотр исходного кода

GUISlider and GUIProgressBar working
Fixed issue with GUI element depth

Marko Pintera 11 лет назад
Родитель
Сommit
74e5650965

+ 5 - 0
BansheeEditor/Include/BsBuiltinEditorResources.h

@@ -306,6 +306,11 @@ namespace BansheeEngine
 		static const WString TreeViewElementHighlight;
 		static const WString TreeViewElementSepHighlight;
 
+		static const WString ColorPickerSliderHandleTex;
+
+		static const WString ProgressBarFillTex;
+		static const WString ProgressBarBgTex;
+
 		static const WString ShaderDockOverlayVSFile;
 		static const WString ShaderDockOverlayPSFile;
 		static const WString SceneGridVSFile;

+ 61 - 1
BansheeEditor/Source/BsBuiltinEditorResources.cpp

@@ -20,6 +20,8 @@
 #include "BsGUIVector4Field.h"
 #include "BsGUIComponentFoldout.h"
 #include "BsGUIFoldout.h"
+#include "BsGUIProgressBar.h"
+#include "BsGUISlider.h"
 
 #include "BsFont.h"
 #include "BsFontImportOptions.h"
@@ -175,6 +177,11 @@ namespace BansheeEngine
 	const WString BuiltinEditorResources::TreeViewElementHighlight = L"TreeViewElementHighlight.psd";
 	const WString BuiltinEditorResources::TreeViewElementSepHighlight = L"TreeViewElementSepHighlight.psd";
 
+	const WString BuiltinEditorResources::ColorPickerSliderHandleTex = L"ColorPickerSliderHandle.psd";
+
+	const WString BuiltinEditorResources::ProgressBarFillTex = L"ProgressBarFill.psd";
+	const WString BuiltinEditorResources::ProgressBarBgTex = L"ProgressBarBg.psd";
+
 	/************************************************************************/
 	/* 									SHADERS                      		*/
 	/************************************************************************/
@@ -1043,6 +1050,58 @@ namespace BansheeEngine
 		foldoutStyle.subStyles[GUIFoldout::getFoldoutButtonStyleType()] = GUIFoldout::getFoldoutButtonStyleType();
 
 		mSkin.setStyle(GUIFoldout::getGUITypeName(), foldoutStyle);
+
+		/************************************************************************/
+		/* 								PROGRESS BAR                      		*/
+		/************************************************************************/
+		GUIElementStyle progressBarBgStyle;
+		progressBarBgStyle.fixedHeight = true;
+		progressBarBgStyle.height = 18;
+		progressBarBgStyle.normal.texture = getGUITexture(ProgressBarBgTex);
+
+		mSkin.setStyle(GUIProgressBar::getBackgroundStyleType(), progressBarBgStyle);
+
+		GUIElementStyle progressBarFillStyle;
+		progressBarFillStyle.fixedHeight = true;
+		progressBarFillStyle.height = 12;
+		progressBarFillStyle.normal.texture = getGUITexture(ProgressBarFillTex);
+
+		mSkin.setStyle(GUIProgressBar::getBarStyleType(), progressBarFillStyle);
+
+		GUIElementStyle progressBarStyle;
+		progressBarStyle.fixedHeight = true;
+		progressBarStyle.height = 18;
+		progressBarStyle.minWidth = 100;
+		progressBarStyle.margins.top = 3;
+		progressBarStyle.margins.bottom = 3;
+
+		progressBarStyle.subStyles[GUIProgressBar::getBarStyleType()] = GUIProgressBar::getBarStyleType();
+		progressBarStyle.subStyles[GUIProgressBar::getBackgroundStyleType()] = GUIProgressBar::getBackgroundStyleType();
+
+		mSkin.setStyle(GUIProgressBar::getGUITypeName(), progressBarStyle);
+
+		/************************************************************************/
+		/* 							COLOR PICKER SLIDER                      	*/
+		/************************************************************************/
+
+		GUIElementStyle colorPickerSliderHandleStyle;
+		colorPickerSliderHandleStyle.fixedHeight = true;
+		colorPickerSliderHandleStyle.fixedWidth = true;
+		colorPickerSliderHandleStyle.height = 32;
+		colorPickerSliderHandleStyle.width = 10;
+		colorPickerSliderHandleStyle.normal.texture = getGUITexture(ColorPickerSliderHandleTex);
+		colorPickerSliderHandleStyle.hover.texture = colorPickerSliderHandleStyle.normal.texture;
+		colorPickerSliderHandleStyle.active.texture = colorPickerSliderHandleStyle.normal.texture;
+
+		mSkin.setStyle(GUISlider::getHandleStyleType(), colorPickerSliderHandleStyle);
+
+		GUIElementStyle colorPickerSliderStyle;
+		colorPickerSliderHandleStyle.fixedHeight = true;
+		colorPickerSliderHandleStyle.height = 32;
+		colorPickerSliderHandleStyle.minWidth = 50;
+		colorPickerSliderStyle.subStyles[GUISlider::getHandleStyleType()] = GUISlider::getHandleStyleType();
+
+		mSkin.setStyle("ColorPickerSlider", colorPickerSliderStyle);
 	}
 
 	void BuiltinEditorResources::preprocess()
@@ -1066,7 +1125,8 @@ namespace BansheeEngine
 			DropDownBoxEntryExpHoverTex, DropDownSeparatorTex, DropDownBoxBtnUpArrowTex, DropDownBoxBtnDownArrowTex,
 			ScrollBarBgTex, MenuBarBgTex, MenuBarBtnNormalTex, MenuBarBtnHoverTex, MenuBarBansheeLogoTex, DockSliderNormalTex,
 			TreeViewExpandButtonOffNormal, TreeViewExpandButtonOffHover, TreeViewExpandButtonOnNormal, TreeViewExpandButtonOnHover,
-			TreeViewSelectionBackground, TreeViewEditBox, TreeViewElementHighlight, TreeViewElementSepHighlight };
+			TreeViewSelectionBackground, TreeViewEditBox, TreeViewElementHighlight, TreeViewElementSepHighlight, ProgressBarBgTex,
+			ProgressBarFillTex, ColorPickerSliderHandleTex };
 
 		static const GpuProgramImportData GPU_PROGRAM_IMPORT_DATA[] = 
 		{

+ 4 - 4
BansheeEditor/Source/BsGUITabbedTitleBar.cpp

@@ -41,10 +41,6 @@ namespace BansheeEngine
 		if(mTabBtnStyle == StringUtil::BLANK)
 			mTabBtnStyle = "TabbedBarBtn";
 
-		mBackgroundImage = GUITexture::create(mBackgroundStyle);
-		mBackgroundImage->_setElementDepth(2);
-		_registerChildElement(mBackgroundImage);
-
 		mMinBtn = GUIButton::create(HString(L""), mMinimizeBtnStyle);
 		mMinBtn->_setElementDepth(1);
 		_registerChildElement(mMinBtn);
@@ -53,6 +49,10 @@ namespace BansheeEngine
 		mCloseBtn->_setElementDepth(1);
 		_registerChildElement(mCloseBtn);
 
+		mBackgroundImage = GUITexture::create(mBackgroundStyle);
+		mBackgroundImage->_setElementDepth(mMinBtn->_getRenderElementDepthRange() + 1);
+		_registerChildElement(mBackgroundImage);
+
 		mCloseBtn->onClick.connect(std::bind(&GUITabbedTitleBar::tabClosed, this));
 
 		mTabToggleGroup = GUIToggle::createToggleGroup();

+ 3 - 3
BansheeEditor/Source/BsGUITreeView.cpp

@@ -123,8 +123,8 @@ namespace BansheeEngine
 		mDragHighlight->disableRecursively();
 		mDragSepHighlight->disableRecursively();
 
-		mDragHighlight->_setElementDepth(1);
-		mDragSepHighlight->_setElementDepth(1);
+		mDragHighlight->_setElementDepth(2);
+		mDragSepHighlight->_setElementDepth(2);
 
 		_registerChildElement(mBackgroundImage);
 		_registerChildElement(mNameEditBox);
@@ -500,7 +500,7 @@ namespace BansheeEngine
 		if(iterFind == mSelectedElements.end())
 		{
 			GUITexture* background = GUITexture::create(mSelectionBackgroundStyle);
-			background->_setElementDepth(1);
+			background->_setElementDepth(2);
 			_registerChildElement(background);
 
 			element->mIsSelected = true;

+ 8 - 0
BansheeEditor/Source/DbgEditorWidget2.cpp

@@ -17,6 +17,8 @@
 #include "BsGUIButton.h"
 #include "BsGUIComponentFoldout.h"
 #include "BsGUISpace.h"
+#include "BsGUISlider.h"
+#include "BsGUIProgressBar.h"
 #include "BsHString.h"
 
 #include "BsCoreThread.h"
@@ -63,6 +65,10 @@ namespace BansheeEngine
 		GUIButton* button = GUIButton::create(HString(L"Testing"), GUIOptions(GUIOption::fixedWidth(100)));
 		button->onClick.connect(&toggleFullscreen);
 
+		GUISlider* slider = GUISliderHorz::create(GUIOptions(GUIOption::fixedWidth(200)), "ColorPickerSlider");
+		GUIProgressBar* progressBar = GUIProgressBar::create(GUIOptions(GUIOption::fixedWidth(200)));
+		progressBar->setPercent(0.33f);
+
 		layout.addElement(intField);
 		layout.addElement(floatField);
 		layout.addElement(textField);
@@ -73,6 +79,8 @@ namespace BansheeEngine
 		layout.addElement(colorField);
 		layout.addElement(foldout);
 		layout.addElement(button);
+		layout.addElement(slider);
+		layout.addElement(progressBar);
 
 		layout.addFlexibleSpace();
 	}

+ 5 - 0
BansheeEngine/Include/BsGUIButtonBase.h

@@ -54,6 +54,11 @@ namespace BansheeEngine
 		 */
 		virtual Vector2I _getOptimalSize() const;
 
+		/**
+		 * @copydoc GUIElement::_getRenderElementDepthRange
+		 */
+		virtual UINT32 _getRenderElementDepthRange() const;
+
 		/**
 		 * @brief	Triggered when button is clicked.
 		 */

+ 10 - 1
BansheeEngine/Include/BsGUIElement.h

@@ -169,7 +169,7 @@ namespace BansheeEngine
 		 */
 		void _setAreaDepth(UINT16 depth);
 
-/**
+		/**
 		 * @brief	Set element part of element depth. Less significant than both
 		 *			widget and area depth.
 		 *
@@ -257,6 +257,15 @@ namespace BansheeEngine
 		 */
 		virtual UINT32 _getRenderElementDepth(UINT32 renderElementIdx) const { return _getDepth(); }
 
+		/**
+		 * @brief	Returns the range of depths that the child elements can be rendered it.
+		 *
+		 * @note	e.g. if you are rendering a button with an image and a text you will want the text
+		 *			to be rendered in front of the image at a different depth, which means the depth
+		 *			range is 2 (0 for text, 1 for background image).
+		 */
+		virtual UINT32 _getRenderElementDepthRange() const { return 1; }
+
 		/**
 		 * @brief	Gets internal element style representing the exact type of GUI element
 		 *			in this object.

+ 5 - 0
BansheeEngine/Include/BsGUIInputBox.h

@@ -180,6 +180,11 @@ namespace BansheeEngine
 		 */
 		virtual UINT32 _getRenderElementDepth(UINT32 renderElementIdx) const;
 
+		/**
+		 * @copydoc	GUIElement::_getRenderElementDepthRange
+		 */
+		virtual UINT32 _getRenderElementDepthRange() const;
+
 		/**
 		 * @copydoc	GUIElement::_hasCustomCursor
 		 */

+ 5 - 0
BansheeEngine/Include/BsGUIProgressBar.h

@@ -75,6 +75,11 @@ namespace BansheeEngine
 		virtual void _updateLayoutInternal(INT32 x, INT32 y, UINT32 width, UINT32 height,
 			Rect2I clipRect, UINT8 widgetDepth, UINT16 areaDepth);
 
+		/**
+		 * @copydoc	GUIElementContainer::styleUpdated
+		 */
+		void styleUpdated();
+
 	private:
 		GUITexture* mBar;
 		GUITexture* mBackground;

+ 5 - 0
BansheeEngine/Include/BsGUIScrollBar.h

@@ -104,6 +104,11 @@ namespace BansheeEngine
 		 * @copydoc GUIElement::_getRenderElementDepth
 		 */
 		virtual UINT32 _getRenderElementDepth(UINT32 renderElementIdx) const;
+
+		/**
+		 * @copydoc	GUIElement::_getRenderElementDepthRange
+		 */
+		virtual UINT32 _getRenderElementDepthRange() const;
 	private:
 		/**
 		 * @brief	Triggered whenever the scroll handle moves. Provided value represents the new 

+ 5 - 0
BansheeEngine/Include/BsGUISlider.h

@@ -50,6 +50,11 @@ namespace BansheeEngine
 		virtual void _updateLayoutInternal(INT32 x, INT32 y, UINT32 width, UINT32 height,
 			Rect2I clipRect, UINT8 widgetDepth, UINT16 areaDepth);
 
+		/**
+		 * @copydoc	GUIElementContainer::styleUpdated
+		 */
+		void styleUpdated();
+
 		/**
 		 * @brief	Triggered when the slider handles moves.
 		 */

+ 10 - 4
BansheeEngine/Include/BsGUISliderHandle.h

@@ -31,23 +31,29 @@ namespace BansheeEngine
 		 * @brief	Creates a new handle.
 		 *
 		 * @param	horizontal		Should the handle be movable vertically or horizontally.
+		 * @param	jumpOnClick		If true clicking on a specific position on the slider will cause
+		 *							the slider handle to jump to that position. Otherwise the slider
+		 *							will just slightly move towards that direction.
 		 * @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 GUISliderHandle* create(bool horizontal, const String& styleName = StringUtil::BLANK);
+		static GUISliderHandle* create(bool horizontal, bool jumpOnClick, const String& styleName = StringUtil::BLANK);
 
 		/**
 		 * @brief	Creates a new handle.
 		 *
 		 * @param	horizontal		Should the handle be movable vertically or horizontally.
+		 * @param	jumpOnClick		If true clicking on a specific position on the slider will cause
+		 *							the slider handle to jump to that position. Otherwise the slider
+		 *							will just slightly move towards that direction.
 		 * @param	layoutOptions	Options that allows you to control how is the element positioned in
 		 *							GUI layout. 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 GUISliderHandle* create(bool horizontal, const GUIOptions& layoutOptions, 
+		static GUISliderHandle* create(bool horizontal, bool jumpOnClick, const GUIOptions& layoutOptions,
 			const String& styleName = StringUtil::BLANK);
 
 		/**
@@ -117,7 +123,7 @@ namespace BansheeEngine
 		 */
 		virtual void updateClippedBounds();
 	private:
-		GUISliderHandle(bool horizontal, const String& styleName, const GUILayoutOptions& layoutOptions);
+		GUISliderHandle(bool horizontal, bool jumpOnClick, const String& styleName, const GUILayoutOptions& layoutOptions);
 
 		/**
 		 * @copydoc	GUIElement::mouseEvent
@@ -139,11 +145,11 @@ namespace BansheeEngine
 		UINT32 mHandleSize;
 
 		bool mHorizontal; // Otherwise its vertical
+		bool mJumpOnClick;
 		float mHandlePos;
 		INT32 mDragStartPos;
 		bool mMouseOverHandle;
 		bool mHandleDragged;
 		State mState;
-
 	};
 }

+ 5 - 0
BansheeEngine/Source/BsGUIButtonBase.cpp

@@ -168,6 +168,11 @@ namespace BansheeEngine
 			return _getDepth() + 1;
 	}
 
+	UINT32 GUIButtonBase::_getRenderElementDepthRange() const
+	{
+		return 2;
+	}
+
 	void GUIButtonBase::fillBuffer(UINT8* vertices, UINT8* uv, UINT32* indices, UINT32 startingQuad, UINT32 maxNumQuads, 
 		UINT32 vertexStride, UINT32 indexStride, UINT32 renderElementIdx) const
 	{

+ 5 - 0
BansheeEngine/Source/BsGUIInputBox.cpp

@@ -355,6 +355,11 @@ namespace BansheeEngine
 			return _getDepth() + 2;
 	}
 
+	UINT32 GUIInputBox::_getRenderElementDepthRange() const
+	{
+		return 4;
+	}
+
 	bool GUIInputBox::_hasCustomCursor(const Vector2I position, CursorType& type) const
 	{
 		if(_isInBounds(position))

+ 7 - 2
BansheeEngine/Source/BsGUIProgressBar.cpp

@@ -15,7 +15,7 @@ namespace BansheeEngine
 		mBar = GUITexture::create(getSubStyleName(getBarStyleType()));
 		mBackground = GUITexture::create(getSubStyleName(getBackgroundStyleType()));
 
-		mBackground->_setElementDepth(1);
+		mBackground->_setElementDepth(mBar->_getRenderElementDepthRange());
 
 		_registerChildElement(mBar);
 		_registerChildElement(mBackground);
@@ -59,7 +59,6 @@ namespace BansheeEngine
 
 		const GUIElementStyle* style = _getStyle();
 		
-
 		Vector2I barOffset(x + style->margins.left, y + style->margins.top);
 		Rect2I barClipRect(clipRect.x - barOffset.x, clipRect.y - barOffset.y, clipRect.width, clipRect.height);
 
@@ -74,6 +73,12 @@ namespace BansheeEngine
 		mBar->_setClipRect(barClipRect);
 	}
 
+	void GUIProgressBar::styleUpdated()
+	{
+		mBar->setStyle(getSubStyleName(getBarStyleType()));
+		mBackground->setStyle(getSubStyleName(getBackgroundStyleType()));
+	}
+
 	void GUIProgressBar::setPercent(float pct)
 	{
 		mPercent = pct;

+ 7 - 2
BansheeEngine/Source/BsGUIScrollBar.cpp

@@ -29,7 +29,7 @@ namespace BansheeEngine
 			mUpBtn = GUIButton::create(HString(L""), "ScrollLeftBtn");
 			mDownBtn = GUIButton::create(HString(L""), "ScrollRightBtn");
 
-			mHandleBtn = GUISliderHandle::create(mHorizontal, 
+			mHandleBtn = GUISliderHandle::create(mHorizontal, false,
 				GUIOptions(GUIOption::flexibleWidth(), GUIOption::fixedHeight(6)), "ScrollBarHorzBtn");
 		}
 		else
@@ -39,7 +39,7 @@ namespace BansheeEngine
 			mUpBtn = GUIButton::create(HString(L""), "ScrollUpBtn");
 			mDownBtn = GUIButton::create(HString(L""), "ScrollDownBtn");
 
-			mHandleBtn = GUISliderHandle::create(mHorizontal, 
+			mHandleBtn = GUISliderHandle::create(mHorizontal, false,
 				GUIOptions(GUIOption::fixedWidth(6), GUIOption::flexibleHeight()), "ScrollBarVertBtn");
 		}
 
@@ -111,6 +111,11 @@ namespace BansheeEngine
 		return _getDepth() + 2; // + 2 depth because child buttons use +1
 	}
 
+	UINT32 GUIScrollBar::_getRenderElementDepthRange() const
+	{
+		return 3;
+	}
+
 	void GUIScrollBar::fillBuffer(UINT8* vertices, UINT8* uv, UINT32* indices, UINT32 startingQuad, UINT32 maxNumQuads, 
 		UINT32 vertexStride, UINT32 indexStride, UINT32 renderElementIdx) const
 	{

+ 8 - 2
BansheeEngine/Source/BsGUISlider.cpp

@@ -13,10 +13,10 @@ namespace BansheeEngine
 	GUISlider::GUISlider(bool horizontal, const String& styleName, const GUILayoutOptions& layoutOptions)
 		:GUIElementContainer(layoutOptions, styleName)
 	{
-		mSliderHandle = GUISliderHandle::create(horizontal, getSubStyleName(getHandleStyleType()));
+		mSliderHandle = GUISliderHandle::create(horizontal, true, getSubStyleName(getHandleStyleType()));
 		mBackground = GUITexture::create(getSubStyleName(getBackgroundStyleType()));
 
-		mBackground->_setElementDepth(1);
+		mBackground->_setElementDepth(mSliderHandle->_getRenderElementDepthRange());
 
 		_registerChildElement(mSliderHandle);
 		_registerChildElement(mBackground);
@@ -73,6 +73,12 @@ namespace BansheeEngine
 		mSliderHandle->_setClipRect(elemClipRect);
 	}
 
+	void GUISlider::styleUpdated()
+	{
+		mBackground->setStyle(getSubStyleName(getBackgroundStyleType()));
+		mSliderHandle->setStyle(getSubStyleName(getHandleStyleType()));
+	}
+
 	void GUISlider::setPercent(float pct)
 	{
 		mSliderHandle->setHandlePos(pct);

+ 43 - 26
BansheeEngine/Source/BsGUISliderHandle.cpp

@@ -17,9 +17,9 @@ namespace BansheeEngine
 		return name;
 	}
 
-	GUISliderHandle::GUISliderHandle(bool horizontal, const String& styleName, const GUILayoutOptions& layoutOptions)
+	GUISliderHandle::GUISliderHandle(bool horizontal, bool jumpOnClick, const String& styleName, const GUILayoutOptions& layoutOptions)
 		:GUIElement(styleName, layoutOptions), mHorizontal(horizontal), mHandleSize(0), mMouseOverHandle(false), mHandlePos(0), mDragStartPos(0),
-		mHandleDragged(false), mState(State::Normal)
+		mHandleDragged(false), mState(State::Normal), mJumpOnClick(jumpOnClick)
 	{
 		mImageSprite = bs_new<ImageSprite, PoolAlloc>();
 	}
@@ -29,14 +29,16 @@ namespace BansheeEngine
 		bs_delete<PoolAlloc>(mImageSprite);
 	}
 
-	GUISliderHandle* GUISliderHandle::create(bool horizontal, const String& styleName)
+	GUISliderHandle* GUISliderHandle::create(bool horizontal, bool jumpOnClick, const String& styleName)
 	{
-		return new (bs_alloc<GUISliderHandle, PoolAlloc>()) GUISliderHandle(horizontal, getStyleName<GUISliderHandle>(styleName), GUILayoutOptions::create());
+		return new (bs_alloc<GUISliderHandle, PoolAlloc>()) GUISliderHandle(horizontal, jumpOnClick, 
+			getStyleName<GUISliderHandle>(styleName), GUILayoutOptions::create());
 	}
 
-	GUISliderHandle* GUISliderHandle::create(bool horizontal, const GUIOptions& layoutOptions, const String& styleName)
+	GUISliderHandle* GUISliderHandle::create(bool horizontal, bool jumpOnClick, const GUIOptions& layoutOptions, const String& styleName)
 	{
-		return new (bs_alloc<GUISliderHandle, PoolAlloc>()) GUISliderHandle(horizontal, getStyleName<GUISliderHandle>(styleName), GUILayoutOptions::create(layoutOptions));
+		return new (bs_alloc<GUISliderHandle, PoolAlloc>()) GUISliderHandle(horizontal, jumpOnClick, 
+			getStyleName<GUISliderHandle>(styleName), GUILayoutOptions::create(layoutOptions));
 	}
 
 	void GUISliderHandle::setHandleSize(UINT32 size)
@@ -182,11 +184,22 @@ namespace BansheeEngine
 			}
 		}
 
-		if(ev.getType() == GUIMouseEventType::MouseDown && mMouseOverHandle)
+		if(ev.getType() == GUIMouseEventType::MouseDown && (mMouseOverHandle || mJumpOnClick))
 		{
 			mState = State::Active;
 			markContentAsDirty();
 
+			if (mJumpOnClick)
+			{
+				if (mHorizontal)
+					mHandlePos = (float)(ev.getPosition().x - (INT32)mOffset.x - mHandleSize * 0.5f);
+				else
+					mHandlePos = (float)(ev.getPosition().y - (INT32)mOffset.y - mHandleSize * 0.5f);
+
+				float maxScrollAmount = (float)getMaxSize() - mHandleSize;
+				mHandlePos = Math::clamp(mHandlePos, 0.0f, maxScrollAmount);
+			}
+
 			if(mHorizontal)
 			{
 				INT32 left = (INT32)mOffset.x + Math::floorToInt(mHandlePos);
@@ -244,31 +257,35 @@ namespace BansheeEngine
 				mState = State::Hover;
 			else
 				mState = State::Normal;
-
+			
 			// If we clicked above or below the scroll handle, scroll by one page
-			INT32 handleOffset = 0;
-			if(mHorizontal)
+			if (!mJumpOnClick)
 			{
-				INT32 handleLeft = (INT32)mOffset.x + Math::floorToInt(mHandlePos);
-				INT32 handleRight = handleLeft + mHandleSize;
+				INT32 handleOffset = 0;
+				if (mHorizontal)
+				{
+					INT32 handleLeft = (INT32)mOffset.x + Math::floorToInt(mHandlePos);
+					INT32 handleRight = handleLeft + mHandleSize;
 
-				if(ev.getPosition().x < handleLeft)
-					handleOffset -= mHandleSize;
-				else if(ev.getPosition().x > handleRight)
-					handleOffset += mHandleSize;
-			}
-			else
-			{
-				INT32 handleTop = (INT32)mOffset.y + Math::floorToInt(mHandlePos);
-				INT32 handleBottom = handleTop + mHandleSize;
+					if (ev.getPosition().x < handleLeft)
+						handleOffset -= mHandleSize;
+					else if (ev.getPosition().x > handleRight)
+						handleOffset += mHandleSize;
+				}
+				else
+				{
+					INT32 handleTop = (INT32)mOffset.y + Math::floorToInt(mHandlePos);
+					INT32 handleBottom = handleTop + mHandleSize;
+
+					if (ev.getPosition().y < handleTop)
+						handleOffset -= mHandleSize;
+					else if (ev.getPosition().y > handleBottom)
+						handleOffset += mHandleSize;
+				}
 
-				if(ev.getPosition().y < handleTop)
-					handleOffset -= mHandleSize;
-				else if(ev.getPosition().y > handleBottom)
-					handleOffset += mHandleSize;
+				mHandlePos += handleOffset;
 			}
 
-			mHandlePos += handleOffset;
 			float maxScrollAmount = (float)getMaxSize() - mHandleSize;
 			mHandlePos = Math::clamp(mHandlePos, 0.0f, maxScrollAmount);