aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordec05eba <dec05eba@protonmail.com>2020-10-19 08:16:42 +0200
committerdec05eba <dec05eba@protonmail.com>2020-10-19 08:16:42 +0200
commit386d16a95a1306decabf6e9764309caf0d2818e3 (patch)
treebf8ba2f2a3462957e6ebcae873a42892a1f104b5
parent0b6f4abda7eb9696ada9c6cf0da54499fe1a0e53 (diff)
Fix body stuttering
-rw-r--r--TODO1
-rw-r--r--include/Body.hpp4
-rw-r--r--src/Body.cpp11
-rw-r--r--src/QuickMedia.cpp6
4 files changed, 10 insertions, 12 deletions
diff --git a/TODO b/TODO
index bc3e4de..80051fc 100644
--- a/TODO
+++ b/TODO
@@ -25,7 +25,6 @@ Resize text vertex arrays to 0 when not visible on screen to reduce memory usage
Speed up thumbnail creating (image resizing).
Extract thumbnail from images that are being downloaded, while its downloading and show that while the full image is downloading (upscaled, or with blurhash).
Use one special thread to load cached files. Right now if there are multiple images on the screen and 1 needs to download while the others are cached, then the cached images wont load until that 1 image has downloaded.
-Scrolling past page causes the page to jump up and down very fast because the new thumbnail is loaded. Fix this somehow. In youtube this can be fixed by setting the thumbnail image fallback size to the same size and thumbnail images, but that doesn't work for matrix with different image sizes!
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).
Also take code from dchat to support gifs (inline in text).
diff --git a/include/Body.hpp b/include/Body.hpp
index 1e21093..9c7c1c1 100644
--- a/include/Body.hpp
+++ b/include/Body.hpp
@@ -210,7 +210,7 @@ namespace QuickMedia {
bool wrap_around;
// Set to {0, 0} to disable resizing
sf::Vector2i thumbnail_resize_target_size;
- sf::Color line_seperator_color;
+ sf::Color line_separator_color;
BodyItemRenderCallback body_item_render_callback;
sf::Shader *thumbnail_mask_shader;
private:
@@ -226,7 +226,7 @@ namespace QuickMedia {
float page_scroll;
// TODO: Use a loading gif or something similar instead, to properly indicate the image is loading. Which could also have text that says "failed to load image" when image loading failed.
sf::RectangleShape image_fallback;
- sf::RectangleShape item_background_shadow;
+ sf::RectangleShape item_separator;
sf::RoundedRectangleShape item_background;
sf::Sprite image;
int num_visible_items;
diff --git a/src/Body.cpp b/src/Body.cpp
index e60a691..a779c09 100644
--- a/src/Body.cpp
+++ b/src/Body.cpp
@@ -43,7 +43,7 @@ namespace QuickMedia {
embedded_item_load_text("", *font, 14),
draw_thumbnails(false),
wrap_around(false),
- line_seperator_color(sf::Color(32, 37, 43, 255)),
+ line_separator_color(sf::Color(32, 37, 43, 255)),
body_item_render_callback(nullptr),
thumbnail_mask_shader(nullptr),
program(program),
@@ -279,7 +279,7 @@ namespace QuickMedia {
//item_background.setFillColor(front_color);
//item_background.setOutlineThickness(1.0f);
//item_background.setOutlineColor(sf::Color(13, 15, 17));
- item_background_shadow.setFillColor(line_seperator_color);
+ item_separator.setFillColor(line_separator_color);
num_visible_items = 0;
last_item_fully_visible = true;
last_fully_visible_item = -1;
@@ -333,6 +333,7 @@ namespace QuickMedia {
prev_selected_item = selected_item;
}
+ update_dirty_state(items[selected_item].get(), size);
float selected_item_height = get_item_height(items[selected_item].get()) + spacing_y;
if(page_scroll > size.y - selected_item_height) {
page_scroll = size.y - selected_item_height;
@@ -547,9 +548,9 @@ namespace QuickMedia {
item_pos.x = std::floor(pos.x);
item_pos.y = std::floor(pos.y);
- item_background_shadow.setSize(sf::Vector2f(std::max(0.0f, size.x - 20.0f), 1.0f));
- item_background_shadow.setPosition(item_pos + sf::Vector2f(10.0f, std::floor(item_height + spacing_y * 0.5f)));
- window.draw(item_background_shadow);
+ item_separator.setSize(sf::Vector2f(std::max(0.0f, size.x - 20.0f), 1.0f));
+ item_separator.setPosition(item_pos + sf::Vector2f(10.0f, std::floor(item_height + spacing_y * 0.5f)));
+ window.draw(item_separator);
if(item_index == selected_item) {
item_background.setPosition(item_pos);
diff --git a/src/QuickMedia.cpp b/src/QuickMedia.cpp
index dc7e6f3..6e4ee51 100644
--- a/src/QuickMedia.cpp
+++ b/src/QuickMedia.cpp
@@ -2946,7 +2946,7 @@ namespace QuickMedia {
messages_tab.body->thumbnail_resize_target_size.x = 600;
messages_tab.body->thumbnail_resize_target_size.y = 337;
messages_tab.body->thumbnail_mask_shader = &circle_mask_shader;
- //messages_tab.body->line_seperator_color = sf::Color::Transparent;
+ //messages_tab.body->line_separator_color = sf::Color::Transparent;
messages_tab.text = sf::Text("Messages", *font, tab_text_size);
tabs.push_back(std::move(messages_tab));
@@ -2954,7 +2954,7 @@ namespace QuickMedia {
rooms_tab.type = ChatTabType::ROOMS;
rooms_tab.body = std::make_unique<Body>(this, font.get(), bold_font.get(), cjk_font.get());
rooms_tab.body->draw_thumbnails = true;
- //rooms_tab.body->line_seperator_color = sf::Color::Transparent;
+ //rooms_tab.body->line_separator_color = sf::Color::Transparent;
rooms_tab.body->thumbnail_mask_shader = &circle_mask_shader;
rooms_tab.text = sf::Text("Rooms", *font, tab_text_size);
tabs.push_back(std::move(rooms_tab));
@@ -3475,8 +3475,6 @@ namespace QuickMedia {
tabs[selected_tab].body->select_next_page();
} else if(event.key.code == sf::Keyboard::End) {
tabs[selected_tab].body->select_last_item();
- } else if(event.key.code == sf::Keyboard::Escape) {
- current_page = PageType::EXIT;
} else if((event.key.code == sf::Keyboard::Left || event.key.code == sf::Keyboard::H) && synced) {
tabs[selected_tab].body->clear_cache();
selected_tab = std::max(0, selected_tab - 1);