From 5b8c2237147336fd44b9deaa24e933abd797f8a3 Mon Sep 17 00:00:00 2001 From: dec05eba Date: Wed, 23 Sep 2020 06:36:04 +0200 Subject: Testing redesign --- src/Body.cpp | 33 +++++++++++++++------------------ src/QuickMedia.cpp | 11 +++++++---- src/SearchBar.cpp | 22 ++++++++++++++-------- 3 files changed, 36 insertions(+), 30 deletions(-) (limited to 'src') diff --git a/src/Body.cpp b/src/Body.cpp index d650d20..238ea8c 100644 --- a/src/Body.cpp +++ b/src/Body.cpp @@ -4,17 +4,18 @@ #include "../include/base64_url.hpp" #include "../include/ImageUtils.hpp" #include "../plugins/Plugin.hpp" +#include "../external/RoundedRectangleShape.hpp" #include #include #include #include #include -const sf::Color front_color(43, 45, 47); +const sf::Color front_color(32, 36, 42); const sf::Color back_color(33, 35, 37); namespace QuickMedia { - BodyItem::BodyItem(std::string _title): visible(true), dirty(false), dirty_description(false), thumbnail_is_local(false), background_color(front_color) { + BodyItem::BodyItem(std::string _title): visible(true), dirty(false), dirty_description(false), thumbnail_is_local(false), background_color(sf::Color::Transparent) { set_title(std::move(_title)); } @@ -49,6 +50,7 @@ namespace QuickMedia { replies_text("", *font, 14), draw_thumbnails(false), wrap_around(false), + line_seperator_color(sf::Color(32, 37, 43, 255)), program(program), loading_thumbnail(false), selected_item(0) @@ -257,7 +259,7 @@ namespace QuickMedia { Path thumbnail_path = get_cache_dir().join("thumbnails").join(base64_url::encode(url)); std::string texture_data; - if(file_get_content(thumbnail_path, texture_data) == 0) { + if(thumbnail_resize_target_size.x != 0 && thumbnail_resize_target_size.y != 0 && file_get_content(thumbnail_path, texture_data) == 0) { fprintf(stderr, "Loaded %s from thumbnail cache\n", url.c_str()); result->loadFromMemory(texture_data.data(), texture_data.size()); loading_thumbnail = false; @@ -337,15 +339,12 @@ namespace QuickMedia { sf::Sprite image; - sf::RectangleShape item_background; + sf::RoundedRectangleShape item_background(sf::Vector2f(1.0f, 1.0f), 10.0f, 10); item_background.setFillColor(front_color); //item_background.setOutlineThickness(1.0f); //item_background.setOutlineColor(sf::Color(13, 15, 17)); sf::RectangleShape item_background_shadow; - item_background_shadow.setFillColor(sf::Color(23, 25, 27)); - - sf::RectangleShape selected_border; - selected_border.setFillColor(sf::Color(0, 85, 119)); + item_background_shadow.setFillColor(line_seperator_color); int num_items = items.size(); if(num_items == 0) @@ -465,7 +464,7 @@ namespace QuickMedia { //selected_border.setSize(sf::Vector2f(selected_border_width, item_height)); //window.draw(selected_border); //item_pos.x += selected_border_width; - item_background.setFillColor(sf::Color(0, 85, 119)); + item_background.setFillColor(sf::Color(32, 37, 43)); } else { item_background.setFillColor(item->background_color); } @@ -473,17 +472,15 @@ namespace QuickMedia { item_pos.x = std::floor(item_pos.x); item_pos.y = std::floor(item_pos.y); - item_background_shadow.setPosition(item_pos + sf::Vector2f(size.x, 0.0f) + sf::Vector2f(0.0, 5.0f)); - item_background_shadow.setSize(sf::Vector2f(5.0f, item_height)); - window.draw(item_background_shadow); - - item_background_shadow.setPosition(item_pos + sf::Vector2f(0.0f, item_height) + sf::Vector2f(5.0, 0.0f)); - item_background_shadow.setSize(sf::Vector2f(size.x - 5.0f, 5.0f)); + 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_background.setPosition(item_pos); - item_background.setSize(sf::Vector2f(size.x, item_height)); - window.draw(item_background); + if(i == selected_item) { + item_background.setPosition(item_pos); + item_background.setSize(sf::Vector2f(size.x, item_height)); + window.draw(item_background); + } float text_offset_x = padding_x; if(draw_thumbnails) { diff --git a/src/QuickMedia.cpp b/src/QuickMedia.cpp index a2fd42b..ce5a414 100644 --- a/src/QuickMedia.cpp +++ b/src/QuickMedia.cpp @@ -34,13 +34,13 @@ #include #include -static const sf::Color back_color(34, 34, 34); +static const sf::Color back_color(21, 25, 30); static const int DOUBLE_CLICK_TIME = 500; static const std::string fourchan_google_captcha_api_key = "6Ldp2bsSAAAAAAJ5uyx_lx34lJeEpTLVkP5k04qc"; static const float tab_text_size = 18.0f; static const float tab_height = tab_text_size + 10.0f; -static const sf::Color tab_selected_color(0, 85, 119); -static const sf::Color tab_unselected_color(43, 45, 47); +static const sf::Color tab_selected_color(55, 60, 68); +static const sf::Color tab_unselected_color(32, 36, 42); // Prevent writing to broken pipe from exiting the program static void sigpipe_handler(int) { @@ -2681,7 +2681,7 @@ namespace QuickMedia { } sf::RectangleShape captcha_selection_rect; captcha_selection_rect.setOutlineThickness(5.0f); - captcha_selection_rect.setOutlineColor(sf::Color(0, 85, 119)); + captcha_selection_rect.setOutlineColor(sf::Color(55, 60, 68)); // TODO: Draw only the outline instead of a transparent rectangle captcha_selection_rect.setFillColor(sf::Color::Transparent); @@ -3159,6 +3159,7 @@ namespace QuickMedia { messages_tab.type = ChatTabType::MESSAGES; messages_tab.body = std::make_unique(this, &font, &bold_font); messages_tab.body->draw_thumbnails = true; + messages_tab.body->line_seperator_color = sf::Color::Transparent; messages_tab.text = sf::Text("Messages", font, tab_text_size); tabs.push_back(std::move(messages_tab)); @@ -3166,6 +3167,7 @@ namespace QuickMedia { rooms_tab.type = ChatTabType::ROOMS; rooms_tab.body = std::make_unique(this, &font, &bold_font); rooms_tab.body->draw_thumbnails = true; + rooms_tab.body->line_seperator_color = sf::Color::Transparent; rooms_tab.text = sf::Text("Rooms", font, tab_text_size); tabs.push_back(std::move(rooms_tab)); @@ -3212,6 +3214,7 @@ namespace QuickMedia { } SearchBar chat_input(font, &plugin_logo, "Send a message..."); + chat_input.set_background_color(sf::Color::Transparent); // TODO: Filer for rooms and settings chat_input.onTextUpdateCallback = nullptr; diff --git a/src/SearchBar.cpp b/src/SearchBar.cpp index f790de8..b04a9a1 100644 --- a/src/SearchBar.cpp +++ b/src/SearchBar.cpp @@ -6,8 +6,8 @@ #include const sf::Color text_placeholder_color(255, 255, 255, 100); -const sf::Color front_color(34, 34, 34); -const float background_margin_horizontal = 8.0f; +const sf::Color front_color(55, 60, 68); +const float background_margin_horizontal = 15.0f; const float background_margin_vertical = 4.0f; const float PADDING_HORIZONTAL = 50.0f; const float padding_vertical = 20.0f; @@ -23,6 +23,7 @@ namespace QuickMedia { caret_visible(true), text(placeholder, font, 18), autocomplete_text("", font, 18), + background(sf::Vector2f(1.0f, 1.0f), 10.0f, 10), placeholder_str(placeholder), show_placeholder(true), updated_search(false), @@ -35,9 +36,10 @@ namespace QuickMedia { text.setFillColor(text_placeholder_color); autocomplete_text.setFillColor(text_placeholder_color); background.setFillColor(front_color); + //background.setCornersRadius(5); background_shadow.setFillColor(sf::Color(23, 25, 27)); //background_shadow.setPosition(background.getPosition() + sf::Vector2f(5.0f, 5.0f)); - shade.setFillColor(sf::Color(0, 85, 119)); + shade.setFillColor(sf::Color(55, 60, 68)); //background.setOutlineThickness(1.0f); //background.setOutlineColor(sf::Color(13, 15, 17)); if(plugin_logo && plugin_logo->getNativeHandle() != 0) @@ -52,7 +54,7 @@ namespace QuickMedia { } if(draw_shadow) window.draw(background_shadow); - window.draw(shade); + //window.draw(shade); window.draw(background); // TODO: Render starting from the character after text length window.draw(autocomplete_text); @@ -61,13 +63,13 @@ namespace QuickMedia { sf::Text masked_text(std::move(masked_str), *text.getFont(), text.getCharacterSize()); masked_text.setPosition(text.getPosition()); window.draw(masked_text); - caret.setPosition(masked_text.findCharacterPos(masked_text.getString().getSize())); + caret.setPosition(masked_text.findCharacterPos(masked_text.getString().getSize()) + sf::Vector2f(0.0f, 2.0f)); } else { window.draw(text); if(show_placeholder || text.getString().isEmpty()) - caret.setPosition(text.getPosition() - sf::Vector2f(2.0f, 0.0f)); + caret.setPosition(text.getPosition() - sf::Vector2f(2.0f, 0.0f) + sf::Vector2f(0.0f, 2.0f)); else - caret.setPosition(text.findCharacterPos(text.getString().getSize())); + caret.setPosition(text.findCharacterPos(text.getString().getSize()) + sf::Vector2f(0.0f, 2.0f)); } if(caret_visible) @@ -124,7 +126,7 @@ namespace QuickMedia { background.setSize(sf::Vector2f(width, rect_height)); shade.setSize(sf::Vector2f(window_size.x, padding_vertical + rect_height + padding_vertical)); - caret.setSize(sf::Vector2f(2.0f, text.getCharacterSize() + 8.0f)); + caret.setSize(sf::Vector2f(2.0f, text.getCharacterSize() + 2.0f)); background_shadow.setSize(sf::Vector2f(window_size.x, 5.0f)); background.setPosition(offset_x, padding_vertical + vertical_pos); @@ -242,6 +244,10 @@ namespace QuickMedia { } } + void SearchBar::set_background_color(sf::Color color) { + background.setFillColor(color); + } + void SearchBar::clear_autocomplete_if_text_not_substring() { const sf::String &text_str = text.getString(); const sf::String &autocomplete_str = autocomplete_text.getString(); -- cgit v1.2.3