1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-03-17 20:58:07 +02:00

better approach for scrollbar

This commit is contained in:
Laserlicht 2024-11-02 15:16:38 +01:00
parent 9009dffebd
commit 0ab4b66026
5 changed files with 8 additions and 11 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 35 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 29 KiB

After

Width:  |  Height:  |  Size: 35 KiB

View File

@ -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)

View File

@ -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));

View File

@ -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