Browse Source

Do not scroll lists in lobby if another item is hovered

Ivan Savenko 10 months ago
parent
commit
367aa94227

+ 10 - 0
client/globalLobby/GlobalLobbyWidget.cpp

@@ -28,6 +28,7 @@
 #include "../widgets/Images.h"
 #include "../widgets/MiscWidgets.h"
 #include "../widgets/ObjectLists.h"
+#include "../widgets/Slider.h"
 #include "../widgets/TextControls.h"
 
 #include "../../lib/CConfigHandler.h"
@@ -126,6 +127,15 @@ std::shared_ptr<CIntObject> GlobalLobbyWidget::buildItemList(const JsonNode & co
 
 	auto result = std::make_shared<CListBox>(callback, position, itemOffset, visibleAmount, totalAmount, initialPos, sliderMode, Rect(sliderPosition, sliderSize));
 
+	if (result->getSlider())
+	{
+		Point scrollBoundsDimensions(sliderPosition.x + result->getSlider()->pos.w, result->getSlider()->pos.h);
+		Point scrollBoundsOffset = -sliderPosition;
+
+		result->getSlider()->setScrollBounds(Rect(scrollBoundsOffset, scrollBoundsDimensions));
+		result->getSlider()->setPanningStep(itemOffset.length());
+	}
+
 	result->setRedrawParent(true);
 	return result;
 }

+ 5 - 0
client/widgets/ObjectLists.cpp

@@ -168,6 +168,11 @@ std::shared_ptr<CIntObject> CListBox::getItem(size_t which)
 	return std::shared_ptr<CIntObject>();
 }
 
+std::shared_ptr<CSlider> CListBox::getSlider()
+{
+	return slider;
+}
+
 size_t CListBox::getIndexOf(std::shared_ptr<CIntObject> item)
 {
 	size_t i=first;

+ 2 - 0
client/widgets/ObjectLists.h

@@ -91,6 +91,8 @@ public:
 	//return item with index which or null if not present
 	std::shared_ptr<CIntObject> getItem(size_t which);
 
+	std::shared_ptr<CSlider> getSlider();
+
 	//return currently active items
 	const std::list<std::shared_ptr<CIntObject>> & getItems();