diff options
Diffstat (limited to 'src/Body.cpp')
-rw-r--r-- | src/Body.cpp | 37 |
1 files changed, 18 insertions, 19 deletions
diff --git a/src/Body.cpp b/src/Body.cpp index ba99c62..c841f98 100644 --- a/src/Body.cpp +++ b/src/Body.cpp @@ -4,6 +4,7 @@ #include "../include/ResourceLoader.hpp" #include "../include/AsyncImageLoader.hpp" #include "../include/Utils.hpp" +#include "../include/Theme.hpp" #include "../include/StringUtils.hpp" #include "../plugins/Plugin.hpp" #include <SFML/Graphics/CircleShape.hpp> @@ -99,9 +100,9 @@ namespace QuickMedia { thumbnail_is_local(false), userdata(nullptr), timestamp(0), - title_color(sf::Color::White), - author_color(sf::Color::White), - description_color(sf::Color::White) + title_color(get_current_theme().text_color), + author_color(get_current_theme().text_color), + description_color(get_current_theme().text_color) { if(!_title.empty()) set_title(std::move(_title)); @@ -176,16 +177,16 @@ namespace QuickMedia { num_visible_items(0), top_cut_off(false), bottom_cut_off(false), - item_background(sf::Vector2f(1.0f, 1.0f), 10.0f, sf::Color(55, 60, 68), rounded_rectangle_shader), - reaction_background(sf::Vector2f(1.0f, 1.0f), 10.0f, sf::Color(33, 37, 44), rounded_rectangle_shader), + item_background(sf::Vector2f(1.0f, 1.0f), 10.0f, get_current_theme().selected_color, rounded_rectangle_shader), + reaction_background(sf::Vector2f(1.0f, 1.0f), 10.0f, get_current_theme().shade_color, rounded_rectangle_shader), rounded_rectangle_mask_shader(rounded_rectangle_mask_shader) { assert(rounded_rectangle_shader); assert(rounded_rectangle_mask_shader); init_body_themes(); embedded_item_load_text = sf::Text("", *FontLoader::get_font(FontLoader::FontType::LATIN), body_spacing[body_theme].embedded_item_font_size); - progress_text.setFillColor(sf::Color::White); - replies_text.setFillColor(sf::Color(129, 162, 190)); + progress_text.setFillColor(get_current_theme().text_color); + replies_text.setFillColor(get_current_theme().replies_text_color); thumbnail_max_size.x = 250; thumbnail_max_size.y = 141; sf::Vector2f loading_icon_size(loading_icon.getTexture()->getSize().x, loading_icon.getTexture()->getSize().y); @@ -866,7 +867,7 @@ namespace QuickMedia { body_item->timestamp_text = std::make_unique<sf::Text>(time_str, *FontLoader::get_font(FontLoader::FontType::LATIN), std::floor(10 * get_ui_scale())); } - body_item->timestamp_text->setFillColor(sf::Color(185, 190, 198, 100)); + body_item->timestamp_text->setFillColor(get_current_theme().timestamp_text_color); } } } @@ -967,7 +968,7 @@ namespace QuickMedia { if(prev_num_visible_items > 0 && render_selected_item_bg && body_theme == BODY_THEME_MINIMAL) { item_background.set_position(sf::Vector2f(pos.x, item_background_prev_pos.y)); item_background.set_size(item_background_prev_size); - item_background.set_color(sf::Color(55, 60, 68)); + item_background.set_color(get_current_theme().selected_color); item_background.set_band(sf::Vector2f(0.0f, 0.0f), sf::Vector2f(0.0f, 0.0f)); item_background.draw(window); } @@ -1176,9 +1177,9 @@ namespace QuickMedia { item_background.set_position(pos + pos_offset); item_background.set_size(sf::Vector2f(card_width, item_height)); - item_background.set_color(sf::Color(28, 32, 39)); + item_background.set_color(get_current_theme().card_item_background_color); item_background.set_band(item_background_prev_pos - (pos + pos_offset), item_background_prev_size); - item_background.set_band_color(sf::Color(55, 60, 68)); + item_background.set_band_color(get_current_theme().selected_color); item_background.draw(window); { @@ -1248,7 +1249,7 @@ namespace QuickMedia { const float gradient_height = 5.0f; if(text_offset_y >= text_height - gradient_height && std::abs(item_height - card_height) < 1) { const sf::Vector2f card_bottom(text_pos.x, text_height); - const sf::Color color = item_index == selected_item ? sf::Color(55, 60, 68) : sf::Color(28, 32, 39); + const sf::Color color = item_index == selected_item ? get_current_theme().selected_color : get_current_theme().card_item_background_color; sf::Vertex gradient_points[4]; gradient_points[0] = sf::Vertex(card_bottom + sf::Vector2f(0.0f, -gradient_height), sf::Color(color.r, color.g, color.b, 0)); @@ -1320,9 +1321,9 @@ namespace QuickMedia { if(item_index != -1 && body_theme == BODY_THEME_MODERN_SPACIOUS) { item_background.set_size(sf::Vector2f(size.x, item_height)); item_background.set_position(item_pos); - item_background.set_color(sf::Color(33, 37, 44)); + item_background.set_color(get_current_theme().shade_color); item_background.set_band(item_background_prev_pos - pos, item_background_prev_size); - item_background.set_band_color(sf::Color(55, 60, 68)); + item_background.set_band_color(get_current_theme().selected_color); item_background.draw(window); } @@ -1356,18 +1357,17 @@ namespace QuickMedia { } else if(!item->thumbnail_url.empty()) { sf::Vector2f content_size = to_vec2f(thumbnail_size); - sf::Color fallback_color(52, 58, 70); if(thumbnail_mask_shader && item->thumbnail_mask_type == ThumbnailMaskType::CIRCLE) { // TODO: Use the mask shader instead, but a vertex shader is also needed for that to pass the vertex coordinates since // shapes dont have texture coordinates. // TODO: Cache circle shape sf::CircleShape circle_shape(content_size.x * 0.5f); - circle_shape.setFillColor(fallback_color); + circle_shape.setFillColor(get_current_theme().image_loading_background_color); circle_shape.setPosition(item_pos + sf::Vector2f(body_spacing[body_theme].image_padding_x, padding_y)); window.draw(circle_shape); } else { image_fallback.setSize(content_size); - image_fallback.setFillColor(fallback_color); + image_fallback.setFillColor(get_current_theme().image_loading_background_color); image_fallback.setPosition(item_pos + sf::Vector2f(body_spacing[body_theme].image_padding_x, padding_y)); window.draw(image_fallback); } @@ -1384,7 +1384,6 @@ namespace QuickMedia { text_offset_x += body_spacing[body_theme].image_padding_x + thumbnail_size.x; } - const float text_max_width = size.x - text_offset_x - body_spacing[body_theme].image_padding_x; const float text_offset_y = std::floor(6.0f * get_ui_scale()); const float timestamp_text_y = std::floor(item_pos.y + padding_y - text_offset_y); @@ -1413,7 +1412,7 @@ namespace QuickMedia { const float embedded_item_width = std::floor(size.x - text_offset_x - border_width - body_spacing[body_theme].padding_x); float embedded_item_height = item->embedded_item ? get_item_height(item->embedded_item.get(), embedded_item_width, true, false) : ((body_spacing[body_theme].embedded_item_font_size + 5.0f) + body_spacing[body_theme].embedded_item_padding_y * 2.0f); sf::RectangleShape border_left(sf::Vector2f(border_width, std::floor(embedded_item_height))); - border_left.setFillColor(sf::Color::White); + border_left.setFillColor(get_current_theme().embedded_item_border_color); border_left.setPosition(std::floor(item_pos.x + text_offset_x), std::floor(item_pos.y + body_spacing[body_theme].embedded_item_padding_y + 2.0f)); window.draw(border_left); |