Selaa lähdekoodia

Int/Float fields now properly trigger on changed events when their values are changed by mouse drag

Marko Pintera 10 vuotta sitten
vanhempi
sitoutus
c2015dd039

+ 1 - 0
BansheeEditor/Include/BsGUIFloatField.h

@@ -35,6 +35,7 @@ namespace BansheeEngine
 		void styleUpdated() override;
 		void styleUpdated() override;
 
 
 		void valueChanged(const WString& newValue);
 		void valueChanged(const WString& newValue);
+		void valueChanged(float newValue);
 		void focusGained();
 		void focusGained();
 		void focusLost();
 		void focusLost();
 
 

+ 1 - 0
BansheeEditor/Include/BsGUIIntField.h

@@ -36,6 +36,7 @@ namespace BansheeEngine
 		void styleUpdated() override;
 		void styleUpdated() override;
 
 
 		void valueChanged(const WString& newValue);
 		void valueChanged(const WString& newValue);
+		void valueChanged(INT32 newValue);
 		void focusGained();
 		void focusGained();
 		void focusLost();
 		void focusLost();
 
 

+ 11 - 5
BansheeEditor/Source/BsGUIFloatField.cpp

@@ -26,7 +26,7 @@ namespace BansheeEngine
 		mInputBox = GUIInputBox::create(false, GUIOptions(GUIOption::flexibleWidth()), getSubStyleName(getInputStyleType()));
 		mInputBox = GUIInputBox::create(false, GUIOptions(GUIOption::flexibleWidth()), getSubStyleName(getInputStyleType()));
 		mInputBox->setFilter(&GUIFloatField::floatFilter);
 		mInputBox->setFilter(&GUIFloatField::floatFilter);
 
 
-		mInputBox->onValueChanged.connect(std::bind(&GUIFloatField::valueChanged, this, _1));
+		mInputBox->onValueChanged.connect(std::bind((void(GUIFloatField::*)(const WString&))&GUIFloatField::valueChanged, this, _1));
 		mInputBox->onFocusGained.connect(std::bind(&GUIFloatField::focusGained, this));
 		mInputBox->onFocusGained.connect(std::bind(&GUIFloatField::focusGained, this));
 		mInputBox->onFocusLost.connect(std::bind(&GUIFloatField::focusLost, this));
 		mInputBox->onFocusLost.connect(std::bind(&GUIFloatField::focusLost, this));
 
 
@@ -105,8 +105,11 @@ namespace BansheeEngine
 
 
 				mLastDragPos = event.getPosition().x + jumpAmount;
 				mLastDragPos = event.getPosition().x + jumpAmount;
 
 
-				if(oldValue != newValue)
+				if (oldValue != newValue)
+				{
 					setValue(newValue);
 					setValue(newValue);
+					valueChanged(newValue);
+				}
 			}
 			}
 
 
 			return true;
 			return true;
@@ -168,12 +171,15 @@ namespace BansheeEngine
 
 
 	void GUIFloatField::valueChanged(const WString& newValue)
 	void GUIFloatField::valueChanged(const WString& newValue)
 	{
 	{
-		float newFloatValue = parseFloat(newValue);
+		valueChanged(parseFloat(newValue));
+	}
 
 
-		CmdInputFieldValueChange<GUIFloatField, float>::execute(this, newFloatValue);
+	void GUIFloatField::valueChanged(float newValue)
+	{
+		CmdInputFieldValueChange<GUIFloatField, float>::execute(this, newValue);
 
 
 		if (!onValueChanged.empty())
 		if (!onValueChanged.empty())
-			onValueChanged(newFloatValue);
+			onValueChanged(newValue);
 	}
 	}
 
 
 	void GUIFloatField::focusGained()
 	void GUIFloatField::focusGained()

+ 12 - 6
BansheeEditor/Source/BsGUIIntField.cpp

@@ -28,7 +28,7 @@ namespace BansheeEngine
 		mInputBox = GUIInputBox::create(false, GUIOptions(GUIOption::flexibleWidth()), getSubStyleName(getInputStyleType()));
 		mInputBox = GUIInputBox::create(false, GUIOptions(GUIOption::flexibleWidth()), getSubStyleName(getInputStyleType()));
 		mInputBox->setFilter(&GUIIntField::intFilter);
 		mInputBox->setFilter(&GUIIntField::intFilter);
 
 
-		mInputBox->onValueChanged.connect(std::bind(&GUIIntField::valueChanged, this, _1));
+		mInputBox->onValueChanged.connect(std::bind((void(GUIIntField::*)(const WString&))&GUIIntField::valueChanged, this, _1));
 		mInputBox->onFocusGained.connect(std::bind(&GUIIntField::focusGained, this));
 		mInputBox->onFocusGained.connect(std::bind(&GUIIntField::focusGained, this));
 		mInputBox->onFocusLost.connect(std::bind(&GUIIntField::focusLost, this));
 		mInputBox->onFocusLost.connect(std::bind(&GUIIntField::focusLost, this));
 
 
@@ -124,8 +124,11 @@ namespace BansheeEngine
 
 
 				mLastDragPos += (newValue - oldValue) * DRAG_SPEED + jumpAmount;
 				mLastDragPos += (newValue - oldValue) * DRAG_SPEED + jumpAmount;
 
 
-				if(oldValue != newValue)
+				if (oldValue != newValue)
+				{
 					setValue(newValue);
 					setValue(newValue);
+					valueChanged(newValue);
+				}
 			}
 			}
 
 
 			return true;
 			return true;
@@ -193,12 +196,15 @@ namespace BansheeEngine
 
 
 	void GUIIntField::valueChanged(const WString& newValue)
 	void GUIIntField::valueChanged(const WString& newValue)
 	{
 	{
-		INT32 newIntValue = parseInt(newValue);
+		valueChanged(parseInt(newValue));
+	}
 
 
-		CmdInputFieldValueChange<GUIIntField, INT32>::execute(this, newIntValue);
+	void GUIIntField::valueChanged(INT32 newValue)
+	{
+		CmdInputFieldValueChange<GUIIntField, INT32>::execute(this, newValue);
 
 
-		if(!onValueChanged.empty())
-			onValueChanged(newIntValue);
+		if (!onValueChanged.empty())
+			onValueChanged(newValue);
 	}
 	}
 
 
 	void GUIIntField::focusGained()
 	void GUIIntField::focusGained()

+ 1 - 2
TODO.txt

@@ -56,8 +56,7 @@ Code quality improvements:
 ----------------------------------------------------------------------
 ----------------------------------------------------------------------
 Polish stage 1
 Polish stage 1
 
 
-Int/Float field mouse scrolling doesn't work unless clicked on a specific spot
- - Additionally the scroll value doesn't seem to persist when it comes to the inspector window
+Float field scroll value doesn't seem to persist when it comes to the inspector window
 Fix DX11 (and possibly DX9) rendering
 Fix DX11 (and possibly DX9) rendering
 After undocking ProjectWindow the auto-scroll seems to be stuck in up position
 After undocking ProjectWindow the auto-scroll seems to be stuck in up position
 Decent looking default layout
 Decent looking default layout