aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authordec05eba <dec05eba@protonmail.com>2021-03-22 13:21:29 +0100
committerdec05eba <dec05eba@protonmail.com>2021-03-22 13:21:29 +0100
commita59acdce5e21a65dd06d8d1d17359bd3159f518c (patch)
treef15b6e34715ee1c891d195b9e0db48b740c17f40 /src
parent795bb9eb3e46c4f9edece953b69b4a66cde34e24 (diff)
Matrix: do not open url when posting a message with an url
Diffstat (limited to 'src')
-rw-r--r--src/QuickMedia.cpp14
-rw-r--r--src/Text.cpp29
2 files changed, 20 insertions, 23 deletions
diff --git a/src/QuickMedia.cpp b/src/QuickMedia.cpp
index e18aa9a..85c3241 100644
--- a/src/QuickMedia.cpp
+++ b/src/QuickMedia.cpp
@@ -3650,10 +3650,14 @@ namespace QuickMedia {
tabs[MESSAGES_TAB_INDEX].body->select_last_item();
}
};
+
+ bool frame_skip_text_entry = false;
- chat_input.on_submit_callback = [this, &tabs, &me, &chat_input, &selected_tab, &current_room, &new_page, &chat_state, &pending_sent_replies, &currently_operating_on_item, &post_task_queue, &process_reactions, &find_body_item_by_event_id](std::string text) mutable {
+ chat_input.on_submit_callback = [this, &frame_skip_text_entry, &tabs, &me, &chat_input, &selected_tab, &current_room, &new_page, &chat_state, &pending_sent_replies, &currently_operating_on_item, &post_task_queue, &process_reactions, &find_body_item_by_event_id](std::string text) mutable {
if(!current_room)
return false;
+
+ frame_skip_text_entry = true;
if(selected_tab == MESSAGES_TAB_INDEX) {
if(text.empty())
@@ -3702,7 +3706,7 @@ namespace QuickMedia {
message->type = MessageType::TEXT;
message->timestamp = time(NULL) * 1000;
- const sf::Color provisional_message_color(171, 175, 180);
+ const sf::Color provisional_message_color(255, 255, 255, 180);
int num_items = tabs[MESSAGES_TAB_INDEX].body->items.size();
bool scroll_to_end = num_items == 0;
@@ -4305,7 +4309,6 @@ namespace QuickMedia {
}
float tab_shade_height = 0.0f;
- bool frame_skip_text_entry = false;
room_tabs[room_selected_tab].body->body_item_select_callback = [&move_room](BodyItem *body_item) {
move_room = true;
@@ -4439,7 +4442,7 @@ namespace QuickMedia {
goto chat_page_end;
}
- if((selected_tab == MESSAGES_TAB_INDEX || selected_tab == PINNED_TAB_INDEX) && event.key.code == sf::Keyboard::Enter) {
+ if((selected_tab == MESSAGES_TAB_INDEX || selected_tab == PINNED_TAB_INDEX) && event.key.code == sf::Keyboard::Enter && !frame_skip_text_entry) {
BodyItem *selected = tabs[selected_tab].body->get_selected();
if(selected) {
if(!display_url_or_image(selected))
@@ -5054,17 +5057,14 @@ namespace QuickMedia {
exit(exit_code);
auto rooms_body = create_body();
- rooms_body->thumbnail_mask_shader = &circle_mask_shader;
auto matrix_rooms_page_search_bar = create_search_bar("Search...", SEARCH_DELAY_FILTER);
auto matrix_rooms_page = std::make_unique<MatrixRoomsPage>(this, rooms_body.get(), "All rooms", nullptr, matrix_rooms_page_search_bar.get());
auto rooms_tags_body = create_body();
- rooms_tags_body->thumbnail_mask_shader = &circle_mask_shader;
auto matrix_rooms_tage_page_search_bar = create_search_bar("Search...", SEARCH_DELAY_FILTER);
auto matrix_rooms_tag_page = std::make_unique<MatrixRoomTagsPage>(this, rooms_tags_body.get(), matrix_rooms_tage_page_search_bar.get());
auto invites_body = create_body();
- invites_body->thumbnail_mask_shader = &circle_mask_shader;
auto matrix_invites_page_search_bar = create_search_bar("Search...", SEARCH_DELAY_FILTER);
auto matrix_invites_page = std::make_unique<MatrixInvitesPage>(this, matrix, invites_body.get(), matrix_invites_page_search_bar.get());
diff --git a/src/Text.cpp b/src/Text.cpp
index ee6bd55..171bd70 100644
--- a/src/Text.cpp
+++ b/src/Text.cpp
@@ -13,7 +13,6 @@
namespace QuickMedia
{
static const float TAB_WIDTH = 4.0f;
- static const sf::Color URL_COLOR(15, 192, 252);
static const float WORD_WRAP_MIN_SIZE = 80.0f;
size_t StringViewUtf32::find(const StringViewUtf32 &other, size_t offset) const {
@@ -34,7 +33,6 @@ namespace QuickMedia
characterSize(_characterSize),
maxWidth(_maxWidth),
color(sf::Color::White),
- urlColor(URL_COLOR),
dirty(true),
dirtyText(false),
dirtyCaret(false),
@@ -359,6 +357,7 @@ namespace QuickMedia
} else if(textElement.text_type == TextElement::TextType::EMOJI) {
vertices_index = 2;
textElement.position = glyphPos;
+ sf::Color emoji_color(255, 255, 255, color.a);
for(size_t i = 0; i < textElement.text.size; ++i)
{
sf::Uint32 codePoint = textElement.text[i];
@@ -376,12 +375,12 @@ namespace QuickMedia
sf::Vector2f textureBottomLeft(emoji_rec.x, emoji_rec.y + emoji_rec.height);
sf::Vector2f textureBottomRight(emoji_rec.x + emoji_rec.width, emoji_rec.y + emoji_rec.height);
- vertices[vertices_index].append({ vertexTopRight, sf::Color::White, textureTopRight });
- vertices[vertices_index].append({ vertexTopLeft, sf::Color::White, textureTopLeft });
- vertices[vertices_index].append({ vertexBottomLeft, sf::Color::White, textureBottomLeft });
- vertices[vertices_index].append({ vertexBottomLeft, sf::Color::White, textureBottomLeft });
- vertices[vertices_index].append({ vertexBottomRight, sf::Color::White, textureBottomRight });
- vertices[vertices_index].append({ vertexTopRight, sf::Color::White, textureTopRight });
+ vertices[vertices_index].append({ vertexTopRight, emoji_color, textureTopRight });
+ vertices[vertices_index].append({ vertexTopLeft, emoji_color, textureTopLeft });
+ vertices[vertices_index].append({ vertexBottomLeft, emoji_color, textureBottomLeft });
+ vertices[vertices_index].append({ vertexBottomLeft, emoji_color, textureBottomLeft });
+ vertices[vertices_index].append({ vertexBottomRight, emoji_color, textureBottomRight });
+ vertices[vertices_index].append({ vertexTopRight, emoji_color, textureTopRight });
glyphPos.x += std::floor(emoji_rec.width * get_ui_scale()) + characterSpacing;
vertices_linear.push_back({vertices_index, vertexStart, 0, codePoint});
@@ -474,14 +473,12 @@ namespace QuickMedia
sf::Vector2f textureBottomLeft(glyph.textureRect.left, glyph.textureRect.top + glyph.textureRect.height);
sf::Vector2f textureBottomRight(glyph.textureRect.left + glyph.textureRect.width, glyph.textureRect.top + glyph.textureRect.height);
- sf::Color fontColor = (textElement.type == TextElement::Type::TEXT ? color : urlColor);
-
- vertices[vertices_index].append({ vertexTopRight, fontColor, textureTopRight });
- vertices[vertices_index].append({ vertexTopLeft, fontColor, textureTopLeft });
- vertices[vertices_index].append({ vertexBottomLeft, fontColor, textureBottomLeft });
- vertices[vertices_index].append({ vertexBottomLeft, fontColor, textureBottomLeft });
- vertices[vertices_index].append({ vertexBottomRight, fontColor, textureBottomRight });
- vertices[vertices_index].append({ vertexTopRight, fontColor, textureTopRight });
+ vertices[vertices_index].append({ vertexTopRight, color, textureTopRight });
+ vertices[vertices_index].append({ vertexTopLeft, color, textureTopLeft });
+ vertices[vertices_index].append({ vertexBottomLeft, color, textureBottomLeft });
+ vertices[vertices_index].append({ vertexBottomLeft, color, textureBottomLeft });
+ vertices[vertices_index].append({ vertexBottomRight, color, textureBottomRight });
+ vertices[vertices_index].append({ vertexTopRight, color, textureTopRight });
glyphPos.x += glyph.advance + characterSpacing;
vertices_linear.push_back({vertices_index, vertexStart, 0, codePoint});