aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authordec05eba <dec05eba@protonmail.com>2020-09-26 07:02:50 +0200
committerdec05eba <dec05eba@protonmail.com>2020-09-26 07:53:37 +0200
commit511716ea4e7c9034fbc38f208db5041107f76ee7 (patch)
tree2ca1bd5c35f8038ba17e634c7f5d7e36422b9b71 /src
parent22aa3cb4f4722e9f73f5a4c8bba82e304e5a9205 (diff)
Fix page scroll when navigating 4chan replies
Diffstat (limited to 'src')
-rw-r--r--src/QuickMedia.cpp13
1 files changed, 9 insertions, 4 deletions
diff --git a/src/QuickMedia.cpp b/src/QuickMedia.cpp
index 74ee75e..2e1eac3 100644
--- a/src/QuickMedia.cpp
+++ b/src/QuickMedia.cpp
@@ -2824,6 +2824,7 @@ namespace QuickMedia {
sf::Event event;
std::stack<int> comment_navigation_stack;
+ std::stack<int> comment_page_scroll_stack;
while (current_page == Page::IMAGE_BOARD_THREAD) {
while (window.pollEvent(event)) {
@@ -2898,17 +2899,19 @@ namespace QuickMedia {
body->items[reply_index]->visible = true;
}
comment_navigation_stack.push(body->get_selected_item());
+ comment_page_scroll_stack.push(body->get_page_scroll());
+ body->clamp_selection();
} else if(event.key.code == sf::Keyboard::BackSpace && !comment_navigation_stack.empty()) {
- size_t previous_selected = 0;
- if(!comment_navigation_stack.empty()) {
- previous_selected = comment_navigation_stack.top();
- }
+ size_t previous_selected = comment_navigation_stack.top();
+ float previous_page_scroll = comment_page_scroll_stack.top();
comment_navigation_stack.pop();
+ comment_page_scroll_stack.pop();
if(comment_navigation_stack.empty()) {
for(auto &body_item : body->items) {
body_item->visible = true;
}
body->set_selected_item(previous_selected);
+ body->clamp_selection();
} else {
for(auto &body_item : body->items) {
body_item->visible = false;
@@ -2919,7 +2922,9 @@ namespace QuickMedia {
for(size_t reply_index : selected_item->replies) {
body->items[reply_index]->visible = true;
}
+ body->clamp_selection();
}
+ body->set_page_scroll(previous_page_scroll);
} else if(event.key.code == sf::Keyboard::C && event.key.control && selected_item) {
navigation_stage = NavigationStage::REPLYING;
} else if(event.key.code == sf::Keyboard::R && selected_item) {