1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-12-22 00:27:58 +02:00

fix scrolling in creature window

This commit is contained in:
Laserlicht
2025-12-06 00:22:22 +01:00
parent 0373691f3a
commit d25dc3d25e
3 changed files with 9 additions and 9 deletions

View File

@@ -121,8 +121,9 @@ void CListBox::updatePositions()
slider->scrollTo((int)first); slider->scrollTo((int)first);
moveChildForeground(slider.get()); moveChildForeground(slider.get());
} }
parent->setRedrawParent(true); redraw();
parent->redraw(); if(onScroll)
onScroll();
} }
void CListBox::reset() void CListBox::reset()

View File

@@ -108,6 +108,8 @@ public:
virtual void moveToPrev(); virtual void moveToPrev();
size_t getPos(); size_t getPos();
std::function<void()> onScroll;
}; };
class CListBoxWithCallback : public CListBox class CListBoxWithCallback : public CListBox

View File

@@ -346,6 +346,7 @@ CStackWindow::BonusesSection::BonusesSection(CStackWindow * owner, int yOffset,
}; };
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)); 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));
lines->onScroll = [owner](){ owner->redraw(); };
} }
CStackWindow::ButtonsSection::ButtonsSection(CStackWindow * owner, int yOffset) CStackWindow::ButtonsSection::ButtonsSection(CStackWindow * owner, int yOffset)
@@ -537,7 +538,7 @@ CStackWindow::CommanderMainSection::CommanderMainSection(CStackWindow * owner, i
}; };
abilities = std::make_shared<CListBox>(onCreate, Point(38, 3+pos.h), Point(63, 0), 6, abilitiesCount); abilities = std::make_shared<CListBox>(onCreate, Point(38, 3+pos.h), Point(63, 0), 6, abilitiesCount);
abilities->setRedrawParent(true); abilities->onScroll = [owner](){ owner->redraw(); };
leftBtn = std::make_shared<CButton>(Point(10, pos.h + 6), AnimationPath::builtin("hsbtns3.def"), CButton::tooltip(), [this](){ abilities->moveToPrev(); }, EShortcut::MOVE_LEFT); leftBtn = std::make_shared<CButton>(Point(10, pos.h + 6), AnimationPath::builtin("hsbtns3.def"), CButton::tooltip(), [this](){ abilities->moveToPrev(); }, EShortcut::MOVE_LEFT);
rightBtn = std::make_shared<CButton>(Point(411, pos.h + 6), AnimationPath::builtin("hsbtns5.def"), CButton::tooltip(), [this](){ abilities->moveToNext(); }, EShortcut::MOVE_RIGHT); rightBtn = std::make_shared<CButton>(Point(411, pos.h + 6), AnimationPath::builtin("hsbtns5.def"), CButton::tooltip(), [this](){ abilities->moveToNext(); }, EShortcut::MOVE_RIGHT);
@@ -973,17 +974,13 @@ void CStackWindow::initSections()
auto obj = switchTab(index); auto obj = switchTab(index);
if(obj) if(obj)
{ obj->enable();
obj->activate();
obj->recActions |= (UPDATE | SHOWALL);
}
return obj; return obj;
}; };
auto deactivateObj = [=](std::shared_ptr<CIntObject> obj) auto deactivateObj = [=](std::shared_ptr<CIntObject> obj)
{ {
obj->deactivate(); obj->disable();
obj->recActions &= ~(UPDATE | SHOWALL);
}; };
commanderMainSection = std::make_shared<CommanderMainSection>(this, 0); commanderMainSection = std::make_shared<CommanderMainSection>(this, 0);