mirror of
https://github.com/geode-sdk/geode.git
synced 2024-11-27 01:45:35 -05:00
Keep scroll value when refreshing the list
This commit is contained in:
parent
d40f4672c4
commit
b3d444a0f3
3 changed files with 15 additions and 4 deletions
|
@ -444,13 +444,18 @@ void ModListLayer::createSearchControl() {
|
|||
this->addChild(m_searchInput);
|
||||
}
|
||||
|
||||
void ModListLayer::reloadList(std::optional<ModListQuery> const& query) {
|
||||
void ModListLayer::reloadList(bool keepScroll, std::optional<ModListQuery> const& query) {
|
||||
auto winSize = CCDirector::sharedDirector()->getWinSize();
|
||||
|
||||
if (query) {
|
||||
m_query = query.value();
|
||||
}
|
||||
|
||||
float scroll = 0.0f;
|
||||
if (keepScroll && m_list) {
|
||||
scroll = m_list->m_listView->m_tableView->m_contentLayer->getPositionY();
|
||||
}
|
||||
|
||||
// set search query
|
||||
m_query.keywords =
|
||||
m_searchInput &&
|
||||
|
@ -489,6 +494,12 @@ void ModListLayer::reloadList(std::optional<ModListQuery> const& query) {
|
|||
m_listLabel->setVisible(false);
|
||||
}
|
||||
|
||||
if (keepScroll) {
|
||||
list->m_tableView->m_contentLayer->setPosition(
|
||||
{ 0.0f, scroll }
|
||||
);
|
||||
}
|
||||
|
||||
// update index if needed
|
||||
if (g_tab == ModListType::Download && !Index::get()->hasTriedToUpdate()) {
|
||||
m_listLabel->setVisible(true);
|
||||
|
@ -686,7 +697,7 @@ void ModListLayer::keyDown(enumKeyCodes key) {
|
|||
}
|
||||
|
||||
void ModListLayer::textChanged(CCTextInputNode* input) {
|
||||
this->reloadList();
|
||||
this->reloadList(false);
|
||||
}
|
||||
|
||||
// Constructors etc.
|
||||
|
|
|
@ -94,5 +94,5 @@ public:
|
|||
ModListDisplay getDisplay() const;
|
||||
ModListQuery& getQuery();
|
||||
|
||||
void reloadList(std::optional<ModListQuery> const& query = std::nullopt);
|
||||
void reloadList(bool keepScroll = true, std::optional<ModListQuery> const& query = std::nullopt);
|
||||
};
|
||||
|
|
|
@ -175,7 +175,7 @@ void SearchFilterPopup::onPlatformToggle(CCObject* sender) {
|
|||
|
||||
void SearchFilterPopup::onClose(CCObject* sender) {
|
||||
Popup::onClose(sender);
|
||||
m_modLayer->reloadList();
|
||||
m_modLayer->reloadList(false);
|
||||
}
|
||||
|
||||
SearchFilterPopup* SearchFilterPopup::create(ModListLayer* layer, ModListType type) {
|
||||
|
|
Loading…
Reference in a new issue