aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--README.md3
-rw-r--r--src/ImageViewer.cpp10
-rw-r--r--src/QuickMedia.cpp121
3 files changed, 41 insertions, 93 deletions
diff --git a/README.md b/README.md
index fc5ba12..700db5c 100644
--- a/README.md
+++ b/README.md
@@ -34,6 +34,7 @@ Press `Ctrl + C` to begin writing a post to a thread (image boards).\
Press `1 to 9` or `Numpad 1 to 9` to select google captcha image when posting a comment on 4chan.\
Press `P` to preview the attached item of the selected row in full screen view. Only works for image boards when browsing a thread.\
Press `I` to switch between single image and scroll image view mode when reading manga.\
+Press `Middle mouse button` to "autoscroll" in scrolling image view mode.\
Press `Tab` to autocomplete a search when autocomplete is available (currently only available for youtube).\
Press `Ctrl + V` to paste the content of your clipboard into the search bar.
## Video controls
@@ -57,7 +58,7 @@ See project.conf \[dependencies].
`youtube-dl` needs to be installed to play videos from youtube.\
`notify-send` needs to be installed to show notifications (on Linux and other systems that uses d-bus notification system).\
`torsocks` needs to be installed when using the `--tor` option.\
-`automedia` needs to be installed when tracking manga with `Ctrl + T`.
+[automedia](https://git.dec05eba.com/AutoMedia/) needs to be installed when tracking manga with `Ctrl + T`.
# TODO
If a search returns no results, then "No results found for ..." should be shown and navigation should go back to searching with suggestions.\
Give user the option to start where they left off or from the start or from the start.\
diff --git a/src/ImageViewer.cpp b/src/ImageViewer.cpp
index 9777611..8ce9b30 100644
--- a/src/ImageViewer.cpp
+++ b/src/ImageViewer.cpp
@@ -117,6 +117,10 @@ namespace QuickMedia {
return true;
}
+ static double sign(double value) {
+ return value >= 0.0 ? 1.0 : -1.0;
+ }
+
ImageViewerAction ImageViewer::draw(sf::RenderWindow &window) {
const double frame_delta = frame_timer.restart().asSeconds();
const double scroll_speed_key_input = 450.0;
@@ -177,7 +181,11 @@ namespace QuickMedia {
if(middle_mouse_scrolling) {
double distance_to_start_y = (double)sf::Mouse::getPosition(window).y - autoscroll_start_y;
- scroll_speed = -distance_to_start_y * scroll_speed_autoscroll * frame_delta;
+ double dist_abs = std::abs(distance_to_start_y);
+ dist_abs -= 20.0;
+ if(dist_abs < 0.0)
+ dist_abs = 0.0;
+ scroll_speed = -(dist_abs * sign(distance_to_start_y)) * scroll_speed_autoscroll * frame_delta;
const double max_speed = 100.0;
if(scroll_speed > max_speed)
scroll_speed = max_speed;
diff --git a/src/QuickMedia.cpp b/src/QuickMedia.cpp
index 99d713e..eefc45a 100644
--- a/src/QuickMedia.cpp
+++ b/src/QuickMedia.cpp
@@ -30,6 +30,8 @@
static const sf::Color back_color(30, 32, 34);
static const int DOUBLE_CLICK_TIME = 500;
static const std::string fourchan_google_captcha_api_key = "6Ldp2bsSAAAAAAJ5uyx_lx34lJeEpTLVkP5k04qc";
+static const float tab_text_size = 18.0f;
+static const float tab_height = tab_text_size + 10.0f;
// Prevent writing to broken pipe from exiting the program
static void sigpipe_handler(int unused) {
@@ -469,6 +471,25 @@ namespace QuickMedia {
fill_history_items_from_json(load_video_history_json(plugin), history_items);
}
+ static void get_body_dimensions(const sf::Vector2f &window_size, SearchBar *search_bar, sf::Vector2f &body_pos, sf::Vector2f &body_size, bool has_tabs = false) {
+ float body_padding_horizontal = 25.0f;
+ float body_padding_vertical = 25.0f;
+ float body_width = window_size.x - body_padding_horizontal * 2.0f;
+ if(body_width <= 480.0f) {
+ body_width = window_size.x;
+ body_padding_horizontal = 0.0f;
+ body_padding_vertical = 10.0f;
+ }
+
+ float tab_h = tab_height;
+ if(!has_tabs)
+ tab_h = 0.0f;
+
+ float search_bottom = search_bar->getBottomWithoutShadow();
+ body_pos = sf::Vector2f(body_padding_horizontal, search_bottom + body_padding_vertical + tab_h);
+ body_size = sf::Vector2f(body_width, window_size.y - search_bottom - body_padding_vertical - tab_h);
+ }
+
void Program::search_suggestion_page() {
std::string update_search_text;
bool search_running = false;
@@ -479,16 +500,14 @@ namespace QuickMedia {
Body history_body(this, font, bold_font);
std::unique_ptr<Body> recommended_body;
- const float tab_text_size = 18.0f;
- const float tab_height = tab_text_size + 10.0f;
sf::Text all_tab_text("All", font, tab_text_size);
sf::Text history_tab_text("History", font, tab_text_size);
sf::Text recommended_tab_text("Recommended", font, tab_text_size);
- //if(current_plugin->name == "youtube") {
+ // if(current_plugin->name == "youtube") {
// recommended_body = std::make_unique<Body>(this, font, bold_font);
// recommended_body->draw_thumbnails = true;
- //}
+ // }
struct Tab {
Body *body;
@@ -636,18 +655,7 @@ namespace QuickMedia {
if(redraw) {
redraw = false;
search_bar->onWindowResize(window_size);
-
- float body_padding_horizontal = 50.0f;
- float body_padding_vertical = tab_spacer_height + tab_height + 50.0f;
- float body_width = window_size.x - body_padding_horizontal * 2.0f;
- if(body_width < 400) {
- body_width = window_size.x;
- body_padding_horizontal = 0.0f;
- }
-
- float search_bottom = search_bar->getBottomWithoutShadow();
- body_pos = sf::Vector2f(body_padding_horizontal, search_bottom + body_padding_vertical);
- body_size = sf::Vector2f(body_width, window_size.y - search_bottom - body_padding_vertical);
+ get_body_dimensions(window_size, search_bar.get(), body_pos, body_size, true);
}
search_bar->update();
@@ -762,18 +770,7 @@ namespace QuickMedia {
if(redraw) {
redraw = false;
search_bar->onWindowResize(window_size);
-
- float body_padding_horizontal = 50.0f;
- float body_padding_vertical = 50.0f;
- float body_width = window_size.x - body_padding_horizontal * 2.0f;
- if(body_width < 400) {
- body_width = window_size.x;
- body_padding_horizontal = 0.0f;
- }
-
- float search_bottom = search_bar->getBottom();
- body_pos = sf::Vector2f(body_padding_horizontal, search_bottom + body_padding_vertical);
- body_size = sf::Vector2f(body_width, window_size.y - search_bottom - body_padding_vertical);
+ get_body_dimensions(window_size, search_bar.get(), body_pos, body_size);
}
search_bar->update();
@@ -1161,18 +1158,7 @@ namespace QuickMedia {
if(redraw) {
redraw = false;
search_bar->onWindowResize(window_size);
-
- float body_padding_horizontal = 50.0f;
- float body_padding_vertical = 50.0f;
- float body_width = window_size.x - body_padding_horizontal * 2.0f;
- if(body_width < 400) {
- body_width = window_size.x;
- body_padding_horizontal = 0.0f;
- }
-
- float search_bottom = search_bar->getBottom();
- body_pos = sf::Vector2f(body_padding_horizontal, search_bottom + body_padding_vertical);
- body_size = sf::Vector2f(body_width, window_size.y - search_bottom - body_padding_vertical);
+ get_body_dimensions(window_size, search_bar.get(), body_pos, body_size);
}
search_bar->update();
@@ -1594,18 +1580,7 @@ namespace QuickMedia {
if(redraw) {
redraw = false;
search_bar->onWindowResize(window_size);
-
- float body_padding_horizontal = 50.0f;
- float body_padding_vertical = 50.0f;
- float body_width = window_size.x - body_padding_horizontal * 2.0f;
- if(body_width < 400) {
- body_width = window_size.x;
- body_padding_horizontal = 0.0f;
- }
-
- float search_bottom = search_bar->getBottom();
- body_pos = sf::Vector2f(body_padding_horizontal, search_bottom + body_padding_vertical);
- body_size = sf::Vector2f(body_width, window_size.y - search_bottom - body_padding_vertical);
+ get_body_dimensions(window_size, search_bar.get(), body_pos, body_size);
}
search_bar->update();
@@ -1650,22 +1625,10 @@ namespace QuickMedia {
redraw = true;
}
- // TODO: This code is duplicated in many places. Handle it in one place.
if(redraw) {
redraw = false;
search_bar->onWindowResize(window_size);
-
- float body_padding_horizontal = 50.0f;
- float body_padding_vertical = 50.0f;
- float body_width = window_size.x - body_padding_horizontal * 2.0f;
- if(body_width < 400) {
- body_width = window_size.x;
- body_padding_horizontal = 0.0f;
- }
-
- float search_bottom = search_bar->getBottom();
- body_pos = sf::Vector2f(body_padding_horizontal, search_bottom + body_padding_vertical);
- body_size = sf::Vector2f(body_width, window_size.y - search_bottom - body_padding_vertical);
+ get_body_dimensions(window_size, search_bar.get(), body_pos, body_size);
}
search_bar->update();
@@ -1715,22 +1678,10 @@ namespace QuickMedia {
redraw = true;
}
- // TODO: This code is duplicated in many places. Handle it in one place.
if(redraw) {
redraw = false;
search_bar->onWindowResize(window_size);
-
- float body_padding_horizontal = 50.0f;
- float body_padding_vertical = 50.0f;
- float body_width = window_size.x - body_padding_horizontal * 2.0f;
- if(body_width < 400) {
- body_width = window_size.x;
- body_padding_horizontal = 0.0f;
- }
-
- float search_bottom = search_bar->getBottom();
- body_pos = sf::Vector2f(body_padding_horizontal, search_bottom + body_padding_vertical);
- body_size = sf::Vector2f(body_width, window_size.y - search_bottom - body_padding_vertical);
+ get_body_dimensions(window_size, search_bar.get(), body_pos, body_size);
}
search_bar->update();
@@ -2070,22 +2021,10 @@ namespace QuickMedia {
}
}
- // TODO: This code is duplicated in many places. Handle it in one place.
if(redraw) {
redraw = false;
search_bar->onWindowResize(window_size);
-
- float body_padding_horizontal = 50.0f;
- float body_padding_vertical = 50.0f;
- float body_width = window_size.x - body_padding_horizontal * 2.0f;
- if(body_width < 400) {
- body_width = window_size.x;
- body_padding_horizontal = 0.0f;
- }
-
- float search_bottom = search_bar->getBottom();
- body_pos = sf::Vector2f(body_padding_horizontal, search_bottom + body_padding_vertical);
- body_size = sf::Vector2f(body_width, window_size.y - search_bottom - body_padding_vertical);
+ get_body_dimensions(window_size, search_bar.get(), body_pos, body_size);
}
//search_bar->update();