Bladeren bron

better approach for scrollbar

Laserlicht 11 maanden geleden
bovenliggende
commit
0ab4b66026

BIN
Mods/vcmi/Data/stackWindow/bonus-effects-noscroll.png


BIN
Mods/vcmi/Data/stackWindow/bonus-effects.png


+ 4 - 7
client/widgets/ObjectLists.cpp

@@ -116,12 +116,12 @@ void CListBox::updatePositions()
 		(elem)->moveTo(itemPos);
 		itemPos += itemOffset;
 	}
-	if (isActive())
+	if(slider)
 	{
-		redraw();
-		if (slider)
-			slider->scrollTo((int)first);
+		slider->scrollTo((int)first);
+		moveChildForeground(slider.get());
 	}
+	redraw();
 }
 
 void CListBox::reset()
@@ -185,9 +185,6 @@ void CListBox::scrollTo(size_t which)
 	//scroll down
 	else if (first + items.size() <= which && which < totalSize)
 		moveToPos(which - items.size() + 1);
-		
-	if(slider)
-		slider->scrollTo(which);
 }
 
 void CListBox::moveToPos(size_t which)

+ 3 - 3
client/windows/CCreatureWindow.cpp

@@ -240,8 +240,8 @@ CStackWindow::ActiveSpellsSection::ActiveSpellsSection(CStackWindow * owner, int
 	}
 }
 
-CStackWindow::BonusLineSection::BonusLineSection(CStackWindow * owner, size_t lineIndex, bool noScroll)
-	: CWindowSection(owner, ImagePath::builtin(noScroll ? "stackWindow/bonus-effects-noscroll" : "stackWindow/bonus-effects"), 0)
+CStackWindow::BonusLineSection::BonusLineSection(CStackWindow * owner, size_t lineIndex)
+	: CWindowSection(owner, ImagePath::builtin("stackWindow/bonus-effects"), 0)
 {
 	OBJECT_CONSTRUCTION;
 
@@ -324,7 +324,7 @@ CStackWindow::BonusesSection::BonusesSection(CStackWindow * owner, int yOffset,
 
 	auto onCreate = [=](size_t index) -> std::shared_ptr<CIntObject>
 	{
-		return std::make_shared<BonusLineSection>(owner, index, totalSize <= 3);
+		return std::make_shared<BonusLineSection>(owner, index);
 	};
 
 	lines = std::make_shared<CListBox>(onCreate, Point(0, 0), Point(0, itemHeight), visibleSize, totalSize, 0, totalSize > 3 ? 1 : 0, Rect(pos.w - 15, 0, pos.h, pos.h));

+ 1 - 1
client/windows/CCreatureWindow.h

@@ -89,7 +89,7 @@ class CStackWindow : public CWindowObject
 		std::array<std::shared_ptr<GraphicalPrimitiveCanvas>, 2> frame;
 		std::array<std::vector<std::shared_ptr<CLabel>>, 2> bonusSource;
 	public:
-		BonusLineSection(CStackWindow * owner, size_t lineIndex, bool noScroll);
+		BonusLineSection(CStackWindow * owner, size_t lineIndex);
 	};
 
 	class BonusesSection : public CWindowSection