From 07eebc494c3655a81ba45522603a9406825a3d0f Mon Sep 17 00:00:00 2001 From: dec05eba Date: Wed, 23 Sep 2020 20:28:42 +0200 Subject: Make tabs rounded, readd color to nyaa.si trusted/remake --- src/Body.cpp | 23 +++++++------------- src/QuickMedia.cpp | 59 ++++++++++++++++++++++---------------------------- src/SearchBar.cpp | 2 +- src/plugins/NyaaSi.cpp | 4 ++-- 4 files changed, 37 insertions(+), 51 deletions(-) (limited to 'src') diff --git a/src/Body.cpp b/src/Body.cpp index 238ea8c..b8bfbff 100644 --- a/src/Body.cpp +++ b/src/Body.cpp @@ -15,7 +15,7 @@ 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(sf::Color::Transparent) { + BodyItem::BodyItem(std::string _title): visible(true), dirty(false), dirty_description(false), thumbnail_is_local(false), title_color(sf::Color::White) { set_title(std::move(_title)); } @@ -340,7 +340,8 @@ namespace QuickMedia { sf::Sprite image; sf::RoundedRectangleShape item_background(sf::Vector2f(1.0f, 1.0f), 10.0f, 10); - item_background.setFillColor(front_color); + //item_background.setFillColor(front_color); + item_background.setFillColor(sf::Color(32, 37, 43)); //item_background.setOutlineThickness(1.0f); //item_background.setOutlineColor(sf::Color(13, 15, 17)); sf::RectangleShape item_background_shadow; @@ -362,6 +363,7 @@ namespace QuickMedia { body_item->title_text->setString(body_item->get_title()); else body_item->title_text = std::make_unique(body_item->get_title(), font, 16, size.x - 50 - image_padding_x * 2.0f); + body_item->title_text->setFillColor(body_item->title_color); body_item->title_text->updateGeometry(); } @@ -458,19 +460,9 @@ namespace QuickMedia { } } - sf::Vector2f item_pos = pos; - if(i == selected_item) { - //selected_border.setPosition(pos); - //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(32, 37, 43)); - } else { - item_background.setFillColor(item->background_color); - } - - item_pos.x = std::floor(item_pos.x); - item_pos.y = std::floor(item_pos.y); + sf::Vector2f item_pos; + 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))); @@ -526,6 +518,7 @@ namespace QuickMedia { //title_text.setPosition(std::floor(item_pos.x + text_offset_x), std::floor(item_pos.y + padding_y)); //window.draw(title_text); if(!item->get_title().empty()) { + item->title_text->setFillColor(item->title_color); item->title_text->setPosition(std::floor(item_pos.x + text_offset_x), std::floor(item_pos.y + padding_y - 4.0f)); item->title_text->setMaxWidth(size.x - text_offset_x - image_padding_x * 2.0f); item->title_text->draw(window); diff --git a/src/QuickMedia.cpp b/src/QuickMedia.cpp index ce5a414..b78ea10 100644 --- a/src/QuickMedia.cpp +++ b/src/QuickMedia.cpp @@ -35,12 +35,11 @@ #include 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(55, 60, 68); -static const sf::Color tab_unselected_color(32, 36, 42); +static const float tab_margin_x = 10.0f; // Prevent writing to broken pipe from exiting the program static void sigpipe_handler(int) { @@ -1043,13 +1042,14 @@ namespace QuickMedia { bool redraw = true; sf::Event event; - sf::RectangleShape tab_spacing_rect(sf::Vector2f(0.0f, 0.0f)); - tab_spacing_rect.setFillColor(tab_unselected_color); const float tab_spacer_height = 0.0f; sf::RectangleShape tab_drop_shadow; tab_drop_shadow.setFillColor(sf::Color(23, 25, 27)); + sf::RoundedRectangleShape tab_background(sf::Vector2f(1.0f, 1.0f), 10.0f, 10); + tab_background.setFillColor(tab_selected_color); + //sf::Clock tt; //int fps = 0; while (current_page == Page::SEARCH_SUGGESTION) { @@ -1154,12 +1154,8 @@ namespace QuickMedia { window.clear(back_color); { - //tab_spacing_rect.setPosition(0.0f, search_bar->getBottomWithoutShadow()); - //tab_spacing_rect.setSize(sf::Vector2f(window_size.x, tab_spacer_height)); - //window.draw(tab_spacing_rect); - const float width_per_tab = window_size.x / tabs.size(); - sf::RectangleShape tab_background(sf::Vector2f(std::floor(width_per_tab), tab_height)); + tab_background.setSize(sf::Vector2f(std::floor(width_per_tab - tab_margin_x * 2.0f), tab_height)); float tab_vertical_offset = search_bar->getBottomWithoutShadow(); if(tabs[selected_tab].body) { @@ -1175,12 +1171,9 @@ namespace QuickMedia { int i = 0; for(Tab &tab : tabs) { if(i == selected_tab) { - tab_background.setFillColor(tab_selected_color); - } else { - tab_background.setFillColor(tab_unselected_color); + tab_background.setPosition(std::floor(i * width_per_tab + tab_margin_x), tab_spacer_height + std::floor(tab_vertical_offset)); + window.draw(tab_background); } - tab_background.setPosition(std::floor(i * width_per_tab), tab_spacer_height + std::floor(tab_vertical_offset)); - window.draw(tab_background); const float center = (i * width_per_tab) + (width_per_tab * 0.5f); tab.text->setPosition(std::floor(center - tab.text->getLocalBounds().width * 0.5f), tab_y); window.draw(*tab.text); @@ -1825,6 +1818,9 @@ namespace QuickMedia { sf::RectangleShape tab_drop_shadow; tab_drop_shadow.setFillColor(sf::Color(23, 25, 27)); + sf::RoundedRectangleShape tab_background(sf::Vector2f(1.0f, 1.0f), 10.0f, 10); + tab_background.setFillColor(tab_selected_color); + while (current_page == Page::EPISODE_LIST) { while (window.pollEvent(event)) { base_event_handler(event, Page::SEARCH_SUGGESTION, false, true); @@ -1875,7 +1871,7 @@ namespace QuickMedia { window.clear(back_color); const float width_per_tab = window_size.x / tabs.size(); - sf::RectangleShape tab_background(sf::Vector2f(std::floor(width_per_tab), tab_height)); + tab_background.setSize(sf::Vector2f(std::floor(width_per_tab - tab_margin_x * 2.0f), tab_height)); float tab_vertical_offset = search_bar->getBottomWithoutShadow(); if(tabs[selected_tab].type == EpisodeListTabType::CHAPTERS) @@ -1895,13 +1891,10 @@ namespace QuickMedia { tab.body->clamp_selection(); } - if(i == selected_tab) - tab_background.setFillColor(tab_selected_color); - else - tab_background.setFillColor(tab_unselected_color); - - tab_background.setPosition(std::floor(i * width_per_tab), tab_spacer_height + std::floor(tab_vertical_offset)); - window.draw(tab_background); + if(i == selected_tab) { + tab_background.setPosition(std::floor(i * width_per_tab + tab_margin_x), tab_spacer_height + std::floor(tab_vertical_offset)); + window.draw(tab_background); + } const float center = (i * width_per_tab) + (width_per_tab * 0.5f); tab.text.setPosition(std::floor(center - tab.text.getLocalBounds().width * 0.5f), tab_y); window.draw(tab.text); @@ -3159,7 +3152,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.body->line_seperator_color = sf::Color::Transparent; messages_tab.text = sf::Text("Messages", font, tab_text_size); tabs.push_back(std::move(messages_tab)); @@ -3167,7 +3160,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.body->line_seperator_color = sf::Color::Transparent; rooms_tab.text = sf::Text("Rooms", font, tab_text_size); tabs.push_back(std::move(rooms_tab)); @@ -3306,6 +3299,9 @@ namespace QuickMedia { sf::RectangleShape tab_drop_shadow; tab_drop_shadow.setFillColor(sf::Color(23, 25, 27)); + sf::RoundedRectangleShape tab_background(sf::Vector2f(1.0f, 1.0f), 10.0f, 10); + tab_background.setFillColor(tab_selected_color); + while (current_page == Page::CHAT) { while (window.pollEvent(event)) { base_event_handler(event, Page::EXIT, false, false, false); @@ -3415,21 +3411,18 @@ namespace QuickMedia { window.clear(back_color); const float width_per_tab = window_size.x / tabs.size(); - sf::RectangleShape tab_background(sf::Vector2f(std::floor(width_per_tab), tab_height)); + tab_background.setSize(sf::Vector2f(std::floor(width_per_tab - tab_margin_x * 2.0f), tab_height)); - float tab_vertical_offset = 0.0f; + float tab_vertical_offset = 10.0f; tabs[selected_tab].body->draw(window, body_pos, body_size); const float tab_y = tab_spacer_height + std::floor(tab_vertical_offset + tab_height * 0.5f - (tab_text_size + 5.0f) * 0.5f); int i = 0; for(ChatTab &tab : tabs) { - if(i == selected_tab) - tab_background.setFillColor(tab_selected_color); - else - tab_background.setFillColor(tab_unselected_color); - - tab_background.setPosition(std::floor(i * width_per_tab), tab_spacer_height + std::floor(tab_vertical_offset)); - window.draw(tab_background); + if(i == selected_tab) { + tab_background.setPosition(std::floor(i * width_per_tab + tab_margin_x), tab_spacer_height + std::floor(tab_vertical_offset)); + window.draw(tab_background); + } const float center = (i * width_per_tab) + (width_per_tab * 0.5f); tab.text.setPosition(std::floor(center - tab.text.getLocalBounds().width * 0.5f), tab_y); window.draw(tab.text); diff --git a/src/SearchBar.cpp b/src/SearchBar.cpp index b04a9a1..5abd970 100644 --- a/src/SearchBar.cpp +++ b/src/SearchBar.cpp @@ -9,7 +9,7 @@ const sf::Color text_placeholder_color(255, 255, 255, 100); 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_HORIZONTAL = 25.0f; const float padding_vertical = 20.0f; namespace QuickMedia { diff --git a/src/plugins/NyaaSi.cpp b/src/plugins/NyaaSi.cpp index 862d3d4..1dbd4f3 100644 --- a/src/plugins/NyaaSi.cpp +++ b/src/plugins/NyaaSi.cpp @@ -125,9 +125,9 @@ namespace QuickMedia { body_item->thumbnail_url = "https://nyaa.si/static/img/icons/nyaa/" + category_id + ".png"; body_item->set_description("Published: " + pub_date + "\nSeeders: " + seeders + "\nLeechers: " + leechers + "\nDownloads: " + downloads + "\nSize: " + size + "\nComments: " + comments); if(trusted == "Yes") - body_item->background_color = sf::Color(43, 95, 47); + body_item->title_color = sf::Color(43, 200, 47); else if(remake == "Yes") - body_item->background_color = sf::Color(93, 45, 47); + body_item->title_color = sf::Color(200, 45, 47); result_items.push_back(std::move(body_item)); index = item_end + 7; -- cgit v1.2.3