aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--TODO5
-rw-r--r--include/Body.hpp6
-rw-r--r--src/Body.cpp29
-rw-r--r--src/plugins/Matrix.cpp8
4 files changed, 38 insertions, 10 deletions
diff --git a/TODO b/TODO
index 8c0708c..578a5a8 100644
--- a/TODO
+++ b/TODO
@@ -18,7 +18,6 @@ Add navigation to nyaa.si submitter torrents.
Create a large texture and add downloaded images to it. This will save memory usage because sfml has to use power of two textures (and so does opengl internally) for textures, so if you have multiple textures they will use more memory than one large texture with the same texture data.
Use fallback cjk font for regular sf::Text as well (search, tabs, chapter name when viewing a page, path in file-manager, etc).
Fix some japanese fonts not rendering (half width alphanumeric?).
-Resize text vertex arrays to 0 when not visible on screen to reduce memory usage. Text already does this but its done incorrectly (copied from dchat codebase). (Is this really necessary?).
Extract thumbnail from images that are being downloaded, while its downloading and show that while the full image is downloading (upscaled, or with blurhash).
Add setting to disable sending typing events to the server (matrix).
Support emoji (mainly for matrix), by readding Text code from dchat. Also do the same but for inline images, text editing and url colors and clicking (also clicking on inline images).
@@ -37,7 +36,6 @@ Use https://github.com/simdjson/simdjson as a json library in other parts than m
Sanitize check: do not allow pasting more than 2gb of text.
Add search bar for matrix rooms.
Only add related videos to recommendations if its the first time we watch the video. This is to prevent rewatching a video multiple times from messing up recommendations.
-Fix incorrect body visible rows count (draws incorrect number of items and incorrect counted, also messed up pg(up/down)).
Implement mentions in matrix with an autofill list, like on element. Also do the same with / commands.
Add option to disable autosearch and search when pressing enter instead or something? this would be needed for mobile phones where typing is slow.
Sleep when idle, to reduce cpu usage from 1-2% to 0%, important for mobile devices. Also render view to a rendertexture and render that instead of redrawing every time every time.
@@ -50,7 +48,6 @@ Support peertube (works with mpv, but need to implement search and related video
Scroll to bottom when receiving a new message even if the selected message is not the last one. It should instead scroll if the last message is visible on the screen.
Also add a tab for common directories and recently accessed files/directories (the directories would be the directory of used files).
Provide a way to go to the first unread message in matrix and also show a marker in the body (maybe a red line?) where the first unread message is.
-Allow scrolling body item. A body item can be long and we wont be able to read all of it otherwise (such as a message on matrix). Pressing up/down should scroll such a large body item rather than moving to another one.
Cleanup keybindings. Some require ctrl, some dont.
Add room topic beside room name in matrix (in messages tab).
Move rooms in matrix to previous page instead, then messages can be beside users, pinned messages, settings, etc and they would all be connected to that one room, then beside rooms tab there would be a global settings tab.
@@ -106,7 +103,6 @@ Scroll body when adding new items and the selected item fits after the scroll (n
Implement our own encryption for matrix. This is also needed to make forwarded message work. Pantalaimon ignores them!
Modify matrix sync to download and parse json but not handle it, and then add a function to handle the json. This would allow us to remove all the mutex code if we would call that new method from the main thread (similar to chromium multithreading).
Room list in matrix ignores edited messages, which it should for unread messages but it should show the edited message if the edited message is the last message in the room.
-For messages that mention us we only want a notification for the last edited version to show as a notification.
Fetch replies/pinned message using multiple threads.
Show in room tags list when there is a message in any of the rooms in the tag.
Cancel video download when pressing escape or closing window (important in matrix).
@@ -123,7 +119,6 @@ Add a notifications tab to show messages that mention us in all rooms (and then
Disable message input in matrix when muted.
Preview rooms?
Instantly show messages posted by me until we receive our message from the server (use post response which includes event id).
-Test if glScissor doesn't break loading of embedded body item.
Handle matrix token being invalidated while running.
Update upload limit if its updated on the server (can it be updated while the server is running?).
Editing a reply removes reply formatting (both in body and formatted_body). Element also does this when you edit a reply twice. This breaks element mobile that is unable to display replied-to messages without correct formatting (doesn't fetch the replied-to message).
diff --git a/include/Body.hpp b/include/Body.hpp
index 294295b..1fa32bb 100644
--- a/include/Body.hpp
+++ b/include/Body.hpp
@@ -145,10 +145,10 @@ namespace QuickMedia {
// Select next page, ignoring invisible items. Returns true if the item was changed. This can be used to check if the bottom was hit when wrap_around is set to false
bool select_next_page();
- // Select previous item, ignoring invisible items. Returns true if the item was changed. This can be used to check if the top was hit when wrap_around is set to false
+ // Select previous item, ignoring invisible items. Returns true if the item was changed or if the item scrolled. This can be used to check if the top was hit when wrap_around is set to false
bool select_previous_item();
- // Select next item, ignoring invisible items. Returns true if the item was changed. This can be used to check if the bottom was hit when wrap_around is set to false
+ // Select next item, ignoring invisible items. Returns true if the item was changed or if the item scrolled. This can be used to check if the bottom was hit when wrap_around is set to false
bool select_next_item();
void set_selected_item(int item, bool reset_prev_selected_item = true);
@@ -236,5 +236,7 @@ namespace QuickMedia {
int last_fully_visible_item;
sf::Clock draw_timer;
double elapsed_time_sec = 0.0;
+ bool selected_line_top_visible = true;
+ bool selected_line_bottom_visible = true;
};
} \ No newline at end of file
diff --git a/src/Body.cpp b/src/Body.cpp
index 06907c8..f224d06 100644
--- a/src/Body.cpp
+++ b/src/Body.cpp
@@ -132,6 +132,11 @@ namespace QuickMedia {
if(items.empty())
return false;
+ if(!selected_line_top_visible) {
+ page_scroll += 32.0f;
+ return true;
+ }
+
int new_selected_item = selected_item;
int num_items = (int)items.size();
@@ -160,6 +165,11 @@ namespace QuickMedia {
if(items.empty())
return false;
+ if(!selected_line_bottom_visible) {
+ page_scroll -= 32.0f;
+ return true;
+ }
+
int new_selected_item = selected_item;
int num_items = (int)items.size();
@@ -328,6 +338,8 @@ namespace QuickMedia {
num_visible_items = 0;
last_item_fully_visible = true;
last_fully_visible_item = -1;
+ selected_line_top_visible = true;
+ selected_line_bottom_visible = true;
int num_items = items.size();
if(num_items == 0 || size.y <= 0.0f) {
@@ -381,9 +393,22 @@ namespace QuickMedia {
}
float selected_item_height = get_item_height(items[selected_item].get(), size.x) + spacing_y;
- if(page_scroll > size.y - selected_item_height) {
+ bool selected_item_fits_on_screen = selected_item_height <= size.y;
+ selected_line_top_visible = pos.y - start_y + page_scroll >= 0.0f;
+ selected_line_bottom_visible = pos.y - start_y + page_scroll + selected_item_height <= size.y;
+
+ if(pos.y - start_y + page_scroll >= size.y)
+ page_scroll -= 32.0f;
+ else if(pos.y - start_y + page_scroll + selected_item_height <= 0.0f)
+ page_scroll += 32.0f;
+
+ selected_line_top_visible |= selected_item_fits_on_screen;
+ selected_line_bottom_visible |= selected_item_fits_on_screen;
+ if(page_scroll > size.y - selected_item_height && selected_item_fits_on_screen) {
+ //fprintf(stderr, "top!\n");
page_scroll = size.y - selected_item_height;
- } else if(page_scroll < 0.0f) {
+ } else if(page_scroll < 0.0f && selected_line_top_visible && selected_item_fits_on_screen) {
+ //fprintf(stderr, "bottom!\n");
page_scroll = 0.0f;
}
diff --git a/src/plugins/Matrix.cpp b/src/plugins/Matrix.cpp
index a90bb30..d6034de 100644
--- a/src/plugins/Matrix.cpp
+++ b/src/plugins/Matrix.cpp
@@ -496,7 +496,7 @@ namespace QuickMedia {
for(auto &message : messages) {
if(message->mentions_me) {
// TODO: What if the message or username begins with "-"? also make the notification image be the avatar of the user
- if(!is_window_focused || room != current_room || is_initial_sync || page_type == MatrixPageType::ROOM_LIST)
+ if((!is_window_focused || room != current_room || is_initial_sync || page_type == MatrixPageType::ROOM_LIST) && message->related_event_type != RelatedEventType::EDIT && message->related_event_type != RelatedEventType::REDACTION)
show_notification("QuickMedia matrix - " + matrix->message_get_author_displayname(message.get()) + " (" + room->get_name() + ")", message->body);
}
}
@@ -534,6 +534,7 @@ namespace QuickMedia {
void MatrixRoomsPage::update() {
{
std::lock_guard<std::mutex> lock(mutex);
+ int prev_selected_item = body->get_selected_item();
if(clear_data_on_update) {
clear_data_on_update = false;
body->clear_items();
@@ -555,6 +556,7 @@ namespace QuickMedia {
}
pending_remove_body_items.clear();
+ body->set_selected_item(prev_selected_item, false);
body->clamp_selection();
body->append_items(std::move(room_body_items));
}
@@ -645,6 +647,7 @@ namespace QuickMedia {
void MatrixRoomTagsPage::update() {
{
std::lock_guard<std::recursive_mutex> lock(mutex);
+ int prev_selected_item = body->get_selected_item();
if(clear_data_on_update) {
clear_data_on_update = false;
body->clear_items();
@@ -696,6 +699,7 @@ namespace QuickMedia {
}
}
add_room_body_items_by_tags.clear();
+ body->set_selected_item(prev_selected_item, false);
}
matrix_delegate->update(MatrixPageType::ROOM_LIST);
if(filter_on_update) {
@@ -794,6 +798,7 @@ namespace QuickMedia {
void MatrixInvitesPage::update() {
std::lock_guard<std::mutex> lock(mutex);
+ int prev_selected_item = body->get_selected_item();
if(clear_data_on_update) {
clear_data_on_update = false;
body->clear_items();
@@ -806,6 +811,7 @@ namespace QuickMedia {
remove_body_item_by_url(body->items, room_id);
}
pending_remove_body_items.clear();
+ body->set_selected_item(prev_selected_item, false);
body->clamp_selection();
// TODO: Insert in reverse order (to show the latest invite at the top?)