From a16cfdc4f6cd14d576760c100a817c08f45be394 Mon Sep 17 00:00:00 2001 From: dec05eba Date: Mon, 28 Sep 2020 01:54:57 +0200 Subject: Matrix: add red line at bottom of chat if we are not at the bottom --- include/Body.hpp | 2 ++ src/Body.cpp | 10 ++++++++-- src/QuickMedia.cpp | 11 +++++++++++ 3 files changed, 21 insertions(+), 2 deletions(-) diff --git a/include/Body.hpp b/include/Body.hpp index 4887582..35b3f30 100644 --- a/include/Body.hpp +++ b/include/Body.hpp @@ -124,6 +124,7 @@ namespace QuickMedia { void set_page_scroll(float scroll) { page_scroll = scroll; } float get_page_scroll() const { return page_scroll; } + bool is_last_item_fully_visible() const { return last_item_fully_visible; } sf::Font *font; sf::Font *bold_font; @@ -168,5 +169,6 @@ namespace QuickMedia { sf::Sprite image; std::future load_thumbnail_future; int num_visible_items; + bool last_item_fully_visible; }; } \ No newline at end of file diff --git a/src/Body.cpp b/src/Body.cpp index c52f8ad..7af2b49 100644 --- a/src/Body.cpp +++ b/src/Body.cpp @@ -75,7 +75,8 @@ namespace QuickMedia { prev_selected_item(0), page_scroll(0.0f), item_background(sf::Vector2f(1.0f, 1.0f), 10.0f, 10), - num_visible_items(0) + num_visible_items(0), + last_item_fully_visible(true) { progress_text.setFillColor(sf::Color::White); replies_text.setFillColor(sf::Color(129, 162, 190)); @@ -394,6 +395,7 @@ namespace QuickMedia { image_fallback.setSize(thumbnail_fallback_size); item_background_shadow.setFillColor(line_seperator_color); num_visible_items = 0; + last_item_fully_visible = true; if(loading_thumbnail && load_thumbnail_future.valid() && load_thumbnail_future.wait_for(std::chrono::seconds(0)) == std::future_status::ready) { load_thumbnail_future.get(); @@ -517,10 +519,14 @@ namespace QuickMedia { if(!item->visible) continue; + float item_height = get_item_height(item.get()); + + if(after_pos.y + item_height > start_y + size.y) + last_item_fully_visible = false; + if(after_pos.y >= start_y + size.y) break; - float item_height = get_item_height(item.get()); draw_item(window, item.get(), after_pos, size, item_height, i, content_progress); after_pos.y += item_height + spacing_y; ++num_visible_items; diff --git a/src/QuickMedia.cpp b/src/QuickMedia.cpp index 994d14c..a0d8508 100644 --- a/src/QuickMedia.cpp +++ b/src/QuickMedia.cpp @@ -3410,6 +3410,9 @@ namespace QuickMedia { sf::Vertex gradient_points[4]; double gradient_inc = 0; + sf::RectangleShape more_messages_below_rect; + more_messages_below_rect.setFillColor(sf::Color(128, 50, 50)); + sf::Clock start_typing_timer; const double typing_timeout_seconds = 3.0; bool typing = false; @@ -3558,6 +3561,7 @@ namespace QuickMedia { if(matrix->post_file(current_room_id, selected_files[0]) != PluginResult::OK) show_notification("QuickMedia", "Failed to upload image to room", Urgency::CRITICAL); } + redraw = true; break; } case Page::CHAT_LOGIN: { @@ -3622,6 +3626,9 @@ namespace QuickMedia { body_pos = sf::Vector2f(body_padding_horizontal, body_padding_vertical + tab_shade_height); body_size = sf::Vector2f(body_width, window_size.y - input_bottom - body_padding_vertical - tab_shade_height); //get_body_dimensions(window_size, &chat_input, body_pos, body_size, true); + + more_messages_below_rect.setSize(sf::Vector2f(window_size.x, gradient_height)); + more_messages_below_rect.setPosition(0.0f, std::floor(window_size.y - chat_input.getBottomWithoutShadow() - gradient_height)); } if(!sync_running && sync_timer.getElapsedTime().asMilliseconds() >= sync_min_time_ms) { @@ -3728,6 +3735,10 @@ namespace QuickMedia { window.draw(gradient_points, 4, sf::Quads); // Note: sf::Quads doesn't work with egl } + if(tabs[selected_tab].type == ChatTabType::MESSAGES && !tabs[selected_tab].body->is_last_item_fully_visible()) { + window.draw(more_messages_below_rect); + } + window.display(); } -- cgit v1.2.3