aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/ImageViewer.hpp3
-rw-r--r--src/ImageViewer.cpp34
-rw-r--r--src/QuickMedia.cpp3
3 files changed, 32 insertions, 8 deletions
diff --git a/include/ImageViewer.hpp b/include/ImageViewer.hpp
index 68eaa05..18faa9c 100644
--- a/include/ImageViewer.hpp
+++ b/include/ImageViewer.hpp
@@ -73,5 +73,8 @@ namespace QuickMedia {
bool has_default_cursor;
bool has_size_vertical_cursor;
+
+ bool up_pressed = false;
+ bool down_pressed = false;
};
} \ No newline at end of file
diff --git a/src/ImageViewer.cpp b/src/ImageViewer.cpp
index 0773f80..d2b1a95 100644
--- a/src/ImageViewer.cpp
+++ b/src/ImageViewer.cpp
@@ -133,7 +133,7 @@ namespace QuickMedia {
ImageViewerAction ImageViewer::draw(sf::RenderWindow &window) {
const double frame_delta = frame_timer.restart().asSeconds();
- const double scroll_speed_key_input = 450.0;
+ const double scroll_speed_key_input = 50.0;
const double scroll_speed_mouse_wheel = 600.0;
const double scroll_speed_autoscroll = 10.0;
const double scroll_deaccel = 0.96;
@@ -162,17 +162,24 @@ namespace QuickMedia {
} else if(event.type == sf::Event::GainedFocus) {
//redraw = true;
} else if(event.type == sf::Event::KeyPressed) {
- if(event.key.code == sf::Keyboard::Up) {
- scroll_speed += scroll_speed_key_input * frame_delta;
- } else if(event.key.code == sf::Keyboard::Down) {
- scroll_speed -= scroll_speed_key_input * frame_delta;
- } else if(event.key.code == sf::Keyboard::Escape) {
+ if(event.key.code == sf::Keyboard::Up)
+ up_pressed = true;
+ if(event.key.code == sf::Keyboard::Down)
+ down_pressed = true;
+
+ if(event.key.code == sf::Keyboard::Escape) {
if(has_default_cursor)
window.setMouseCursor(default_cursor);
return ImageViewerAction::RETURN;
- } else if(event.key.code == sf::Keyboard::I) {
- return ImageViewerAction::SWITCH_TO_SINGLE_IMAGE_MODE;
}
+
+ if(event.key.code == sf::Keyboard::I)
+ return ImageViewerAction::SWITCH_TO_SINGLE_IMAGE_MODE;
+ } else if(event.type == sf::Event::KeyReleased) {
+ if(event.key.code == sf::Keyboard::Up)
+ up_pressed = false;
+ if(event.key.code == sf::Keyboard::Down)
+ down_pressed = false;
} else if(event.type == sf::Event::MouseWheelScrolled && event.mouseWheelScroll.wheel == sf::Mouse::VerticalWheel) {
scroll_speed += scroll_speed_mouse_wheel * event.mouseWheelScroll.delta * frame_delta;
} else if(event.type == sf::Event::MouseButtonPressed && event.mouseButton.button == sf::Mouse::Button::Middle) {
@@ -189,6 +196,11 @@ namespace QuickMedia {
}
}
+ if(up_pressed)
+ scroll_speed += scroll_speed_key_input * frame_delta;
+ if(down_pressed)
+ scroll_speed -= scroll_speed_key_input * frame_delta;
+
if(middle_mouse_scrolling) {
double distance_to_start_y = (double)sf::Mouse::getPosition(window).y - autoscroll_start_y;
double dist_abs = std::abs(distance_to_start_y);
@@ -203,6 +215,12 @@ namespace QuickMedia {
scroll_speed = -max_speed;
scroll += scroll_speed;
} else {
+ const double max_speed = 100.0;
+ if(scroll_speed > max_speed)
+ scroll_speed = max_speed;
+ if(scroll_speed < -max_speed)
+ scroll_speed = -max_speed;
+
scroll_speed *= scroll_deaccel;
if(std::abs(scroll_speed) < 0.01) {
scroll_speed = 0.0;
diff --git a/src/QuickMedia.cpp b/src/QuickMedia.cpp
index 85c6695..a7fca2d 100644
--- a/src/QuickMedia.cpp
+++ b/src/QuickMedia.cpp
@@ -251,8 +251,10 @@ namespace QuickMedia {
}
case Page::IMAGES_CONTINUOUS: {
body->draw_thumbnails = false;
+ window.setKeyRepeatEnabled(false);
image_continuous_page();
body->filter_search_fuzzy("");
+ window.setKeyRepeatEnabled(true);
break;
}
case Page::CONTENT_LIST: {
@@ -872,6 +874,7 @@ namespace QuickMedia {
const int max_fallbacks = 3;
/* itags from: https://gist.github.com/sidneys/7095afe4da4ae58694d128b1034e01e2 */
/* 1080p, 720p, 360p */
+ /* TODO: Use invidious api instead (/api/v1/videos/<video_id>, formatStreams) https://github.com/iv-org/invidious/wiki/API */
const char *fallback_itags[max_fallbacks] = { "37", "22", "18" };
Page previous_page = pop_page_stack();