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 +++++++++++++++------------------ 1 file changed, 15 insertions(+), 18 deletions(-) (limited to 'src/Body.cpp') 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) { -- cgit v1.2.3