diff options
author | dec05eba <dec05eba@protonmail.com> | 2021-05-18 23:12:05 +0200 |
---|---|---|
committer | dec05eba <dec05eba@protonmail.com> | 2021-05-18 23:12:05 +0200 |
commit | 9cbba813ff41549467af38a9f0ce3eb28d4c157b (patch) | |
tree | 14c76bc7965a06139e5e0903f3eec5a7f3d828b8 | |
parent | c57703dd93cd31c3bc09e1803279d266b098f353 (diff) |
Fix replying/edit mention
-rw-r--r-- | src/QuickMedia.cpp | 40 |
1 files changed, 28 insertions, 12 deletions
diff --git a/src/QuickMedia.cpp b/src/QuickMedia.cpp index 28bd72f..297a780 100644 --- a/src/QuickMedia.cpp +++ b/src/QuickMedia.cpp @@ -4347,6 +4347,7 @@ namespace QuickMedia { filter_updated = false; filter.clear(); users_tab_body->filter_search_fuzzy(""); + users_tab_body->clear_cache(); } void handle_event(const sf::Event &event) { @@ -4356,23 +4357,23 @@ namespace QuickMedia { if(event.text.unicode > 32) { filter += event.text.unicode; filter_updated = true; - } else if(event.text.unicode == 8) { // 8 = backspace - if(filter.getSize() == 0) { - hide(); - } else { - filter.erase(filter.getSize() - 1, 1); - filter_updated = true; - } } else if(event.text.unicode == ' ' || event.text.unicode == '\t') { hide(); } } else if(event.type == sf::Event::KeyPressed) { - if(event.key.code == sf::Keyboard::Up) { + if(event.key.code == sf::Keyboard::Up || (event.key.control && event.key.code == sf::Keyboard::K)) { users_tab_body->select_previous_item(); - } else if(event.key.code == sf::Keyboard::Down) { + } else if(event.key.code == sf::Keyboard::Down || (event.key.control && event.key.code == sf::Keyboard::J)) { users_tab_body->select_next_item(); } else if(event.key.code == sf::Keyboard::Enter && event.key.shift) { hide(); + } else if(event.key.code == sf::Keyboard::Backspace) { + if(filter.getSize() == 0) { + hide(); + } else { + filter.erase(filter.getSize() - 1, 1); + filter_updated = true; + } } } } @@ -4393,6 +4394,7 @@ namespace QuickMedia { Mention mention; mention.users_tab_body = tabs[USERS_TAB_INDEX].body.get(); + const float user_mention_body_height = std::floor(300.0f * get_ui_scale()); bool frame_skip_text_entry = false; @@ -5638,8 +5640,7 @@ namespace QuickMedia { url_selection_body.draw(window, body_pos, body_size); } else { tabs[selected_tab].body->draw(window, body_pos, body_size); - if(selected_tab == MESSAGES_TAB_INDEX && mention.visible) { - const float user_mention_body_height = std::floor(300.0f * get_ui_scale()); + if(selected_tab == MESSAGES_TAB_INDEX && mention.visible && chat_state == ChatState::TYPING_MESSAGE) { sf::RectangleShape user_mention_background(sf::Vector2f(body_size.x + body_padding_vertical*2.0f, user_mention_body_height)); user_mention_background.setPosition(sf::Vector2f(body_pos.x - body_padding_vertical, body_pos.y + body_size.y - user_mention_body_height)); user_mention_background.setFillColor(sf::Color(33, 37, 44)); @@ -5722,7 +5723,11 @@ namespace QuickMedia { if(item_height < 0.0f) item_height = 0.0f; - sf::RectangleShape overlay(sf::Vector2f(window_size.x, window_size.y - chat_input_height_full)); + float extra_user_mention_height = 0.0f; + if(mention.visible) + extra_user_mention_height = user_mention_body_height; + + sf::RectangleShape overlay(sf::Vector2f(window_size.x, window_size.y - chat_input_height_full - extra_user_mention_height)); overlay.setFillColor(sf::Color(0, 0, 0, 240)); window.draw(overlay); @@ -5733,6 +5738,17 @@ namespace QuickMedia { item_background.setPosition(sf::Vector2f(0.0f, window_size.y - (body_item_size.y + chat_input_height_full + replying_to_text_height + margin))); item_background.setFillColor(back_color); window.draw(item_background); + + if(mention.visible) { + sf::RectangleShape user_mention_background(sf::Vector2f(window_size.x, user_mention_body_height)); + user_mention_background.setPosition(sf::Vector2f(0.0f, item_background.getPosition().y - user_mention_body_height)); + user_mention_background.setFillColor(sf::Color(33, 37, 44)); + + window.draw(user_mention_background); + tabs[USERS_TAB_INDEX].body->draw(window, + sf::Vector2f(body_pos.x, item_background.getPosition().y - user_mention_body_height + body_padding_vertical), + sf::Vector2f(body_size.x, user_mention_body_height - body_padding_vertical)); + } replying_to_text.setPosition(body_item_pos.x, body_item_pos.y - replying_to_text_height); window.draw(replying_to_text); |