aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--README.md6
-rw-r--r--include/ImageViewer.hpp5
-rw-r--r--src/ImageViewer.cpp23
3 files changed, 16 insertions, 18 deletions
diff --git a/README.md b/README.md
index 00d4d2e..b7bf1e6 100644
--- a/README.md
+++ b/README.md
@@ -1,7 +1,7 @@
# QuickMedia
A rofi inspired native client for web services.
-Currently supported web services: `youtube`, `peertube`, `lbry`, `soundcloud`, `nyaa.si`, `manganelo`, `manganelos`, `mangatown`, `mangakatana`, `mangadex`, `readm`, `onimanga`, `4chan`, `matrix`, `saucenao`, `hotexamples`, `anilist` and _others_.
-QuickMedia also supports reading local manga (add "local_manga_directory" config to ~/.config/quickmedia/config.json).
+Currently supported web services: `youtube`, `peertube`, `lbry`, `soundcloud`, `nyaa.si`, `manganelo`, `manganelos`, `mangatown`, `mangakatana`, `mangadex`, `readm`, `onimanga`, `4chan`, `matrix`, `saucenao`, `hotexamples`, `anilist` and _others_.\
+QuickMedia also supports reading local manga (add "local_manga_directory" config to `~/.config/quickmedia/config.json`, see the [config](#config) section).
## Usage
```
usage: quickmedia [plugin] [--dir <directory>] [-e <window>] [youtube-url]
@@ -158,7 +158,7 @@ Type text and then wait and QuickMedia will automatically search.\
`/me [text]`: Send a message of type "m.emote".\
`/react [text]`: React to the selected message (also works if you are replying to a message).\
`/id`: Show the room id.
-## Config
+## <a id="config"></a>Config
Config is loaded from `~/.config/quickmedia/config.json` if it exists. See [example-config.json](https://git.dec05eba.com/QuickMedia/plain/example-config.json) for an example config. All fields in the config file are optional.\
If `use_system_mpv_config` is set to `true` then your systems mpv config in `~/.config/mpv/mpv.conf` and plugins will be used. If you have a mpv plugin installed that uses `input-ipc-server` (such as `mpv-discord`) then it will break quickmedia integration with mpv (especially key inputs such as ctrl+r).
## Theme
diff --git a/include/ImageViewer.hpp b/include/ImageViewer.hpp
index 182a6a2..c1fb6ad 100644
--- a/include/ImageViewer.hpp
+++ b/include/ImageViewer.hpp
@@ -61,7 +61,6 @@ namespace QuickMedia {
int current_page;
int num_pages;
- int page_center;
std::string content_title;
std::string chapter_title;
@@ -69,8 +68,8 @@ namespace QuickMedia {
double scroll = 0.0;
double scroll_speed = 0.0;
- double min_page_center_dist;
- int page_closest_to_center;
+ double min_page_top_dist;
+ int page_closest_to_top;
int focused_page;
int prev_focused_page = -1;
diff --git a/src/ImageViewer.cpp b/src/ImageViewer.cpp
index f568402..2b40c1f 100644
--- a/src/ImageViewer.cpp
+++ b/src/ImageViewer.cpp
@@ -99,10 +99,10 @@ namespace QuickMedia {
if(!scrolling)
render_pos.y = std::floor(render_pos.y);
- double center_dist = std::abs(window_size.y * 0.5 - (render_pos.y + image_size.y * 0.5));
- if(center_dist < min_page_center_dist) {
- min_page_center_dist = center_dist;
- page_closest_to_center = page;
+ double top_dist = std::abs(0.0 - render_pos.y);
+ if(top_dist < min_page_top_dist) {
+ min_page_top_dist = top_dist;
+ page_closest_to_top = page;
}
if(page_image_data) {
@@ -298,8 +298,8 @@ namespace QuickMedia {
}
}
- min_page_center_dist = 9999999.0;
- page_closest_to_center = -1;
+ min_page_top_dist = 9999999.0;
+ page_closest_to_top = -1;
bool loaded_textures_changed = false;
int page_i = 0;
@@ -340,19 +340,18 @@ namespace QuickMedia {
const double first_image_height = get_page_size(0).y;
const double last_image_height = get_page_size((int)image_data.size() - 1).y;
- // TODO: Limit bottom scroll if page_offset is smaller than window height
+ // TODO: Do not allow scrolling if all images height (page_offset) is smaller than window height
- const double top_scroll = std::max(0.0, -first_image_height * 0.5 + window_size.y * 0.5);
- const double bottom_scroll = std::min(window_size.y, window_size.y + last_image_height * 0.5 - window_size.y * 0.5);
+ const double top_scroll = std::max(0.0, -first_image_height + window_size.y);
+ const double bottom_scroll = std::min(window_size.y, window_size.y + last_image_height - window_size.y);
if(scroll > top_scroll) {
scroll = top_scroll;
} else if(scroll + page_offset < bottom_scroll && page_offset > window_size.y) {
scroll = -page_offset + bottom_scroll;
}
- if(page_closest_to_center != -1) {
- focused_page = page_closest_to_center;
- }
+ if(page_closest_to_top != -1)
+ focused_page = page_closest_to_top;
if(focused_page != prev_focused_page) {
prev_focused_page = focused_page;