diff options
author | dec05eba <dec05eba@protonmail.com> | 2021-10-02 05:02:34 +0200 |
---|---|---|
committer | dec05eba <dec05eba@protonmail.com> | 2021-10-02 05:02:34 +0200 |
commit | 522c6ea14cd2c1569ce5ff24c0241edba1835308 (patch) | |
tree | 9cd9e496f185f46d0dde7f3fa6058241f0713afb /src | |
parent | ca49eef152db41ac30df2fd6a1b4631f81491b6b (diff) |
Revert tab style
Diffstat (limited to 'src')
-rw-r--r-- | src/Body.cpp | 24 | ||||
-rw-r--r-- | src/QuickMedia.cpp | 24 | ||||
-rw-r--r-- | src/SearchBar.cpp | 2 | ||||
-rw-r--r-- | src/Tabs.cpp | 10 | ||||
-rw-r--r-- | src/Utils.cpp | 2 |
5 files changed, 31 insertions, 31 deletions
diff --git a/src/Body.cpp b/src/Body.cpp index dffb3c9..1669e52 100644 --- a/src/Body.cpp +++ b/src/Body.cpp @@ -582,8 +582,8 @@ namespace QuickMedia { if(!show_drop_shadow) return; - const sf::Color color = get_theme().background_color; - const float height = 20.0f; + const sf::Color color(0, 0, 0, 50); + const float height = 5.0f; sf::Vertex gradient_points[4]; gradient_points[0] = sf::Vertex(body_pos + sf::Vector2f(0.0f, 0.0f), color); @@ -792,7 +792,7 @@ namespace QuickMedia { double scrollbar_offset_y = body_total_height == 0.0 ? 0.0 : (std::abs(page_scroll) / body_total_height); RoundedRectangle scrollbar( - vec2f_round(5.0f * get_config().scale, scrollbar_max_height * scrolling_bar_height_ratio), + vec2f_floor(5.0f * get_config().scale, scrollbar_max_height * scrolling_bar_height_ratio), std::floor(3.0f * get_config().scale), get_theme().selected_color, rounded_rectangle_shader); @@ -1458,7 +1458,7 @@ namespace QuickMedia { const float timestamp_text_y = std::floor(item_pos.y + padding_y - text_offset_y); if(item->author_text && !merge_with_previous) { - item->author_text->setPosition(vec2f_round(item_pos.x + text_offset_x, item_pos.y + padding_y - text_offset_y)); + item->author_text->setPosition(vec2f_floor(item_pos.x + text_offset_x, item_pos.y + padding_y - text_offset_y)); item->author_text->draw(window); sf::Vector2f replies_text_pos = item->author_text->getPosition() + sf::Vector2f(0.0f, 5.0f); @@ -1482,7 +1482,7 @@ namespace QuickMedia { 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(embedded_item_border_width, std::floor(embedded_item_height))); border_left.setFillColor(get_theme().embedded_item_border_color); - border_left.setPosition(vec2f_round(item_pos.x + text_offset_x, item_pos.y + body_spacing[body_theme].embedded_item_padding_y + 2.0f)); + border_left.setPosition(vec2f_floor(item_pos.x + text_offset_x, item_pos.y + body_spacing[body_theme].embedded_item_padding_y + 2.0f)); window.draw(border_left); if(item->embedded_item) { @@ -1491,21 +1491,21 @@ namespace QuickMedia { draw_item(window, item->embedded_item, embedded_item_pos, embedded_item_size, false, true); } else { embedded_item_load_text.setString(embedded_item_status_to_string(item->embedded_item_status)); - embedded_item_load_text.setPosition(vec2f_round(item_pos.x + text_offset_x + embedded_item_border_width + body_spacing[body_theme].padding_x, item_pos.y + embedded_item_height * 0.5f - (body_spacing[body_theme].embedded_item_font_size + 5.0f) * 0.5f + 6.0f)); + embedded_item_load_text.setPosition(vec2f_floor(item_pos.x + text_offset_x + embedded_item_border_width + body_spacing[body_theme].padding_x, item_pos.y + embedded_item_height * 0.5f - (body_spacing[body_theme].embedded_item_font_size + 5.0f) * 0.5f + 6.0f)); window.draw(embedded_item_load_text); } item_pos.y += embedded_item_height + 4.0f; } if(item->title_text) { - item->title_text->setPosition(vec2f_round(item_pos.x + text_offset_x, item_pos.y + padding_y - text_offset_y)); + item->title_text->setPosition(vec2f_floor(item_pos.x + text_offset_x, item_pos.y + padding_y - text_offset_y)); item->title_text->draw(window); item_pos.y += item->title_text->getHeight() - 2.0f + std::floor(3.0f * get_config().scale); } if(item->description_text) { float height_offset = 0.0f; - item->description_text->setPosition(vec2f_round(item_pos.x + text_offset_x, item_pos.y + padding_y - text_offset_y + height_offset)); + item->description_text->setPosition(vec2f_floor(item_pos.x + text_offset_x, item_pos.y + padding_y - text_offset_y + height_offset)); item->description_text->draw(window); item_pos.y += item->description_text->getHeight() - 2.0f; } @@ -1519,8 +1519,8 @@ namespace QuickMedia { auto &reaction = item->reactions[i]; reaction.text->updateGeometry(); reaction_max_height = std::max(reaction_max_height, reaction.text->getHeight()); - reaction.text->setPosition(vec2f_round(item_pos.x + text_offset_x + reaction_offset_x + body_spacing[body_theme].reaction_background_padding_x, item_pos.y + padding_y - 4.0f + body_spacing[body_theme].reaction_background_padding_y)); - reaction_background.set_position(vec2f_round(item_pos.x + text_offset_x + reaction_offset_x, item_pos.y + padding_y)); + reaction.text->setPosition(vec2f_floor(item_pos.x + text_offset_x + reaction_offset_x + body_spacing[body_theme].reaction_background_padding_x, item_pos.y + padding_y - 4.0f + body_spacing[body_theme].reaction_background_padding_y)); + reaction_background.set_position(vec2f_floor(item_pos.x + text_offset_x + reaction_offset_x, item_pos.y + padding_y)); reaction_background.set_size(sf::Vector2f(reaction.text->getWidth() + body_spacing[body_theme].reaction_background_padding_x * 2.0f, reaction.text->getHeight() + body_spacing[body_theme].reaction_background_padding_y * 2.0f)); reaction_background.draw(window); reaction_offset_x += reaction.text->getWidth() + body_spacing[body_theme].reaction_background_padding_x * 2.0f + body_spacing[body_theme].reaction_spacing_x; @@ -1535,7 +1535,7 @@ namespace QuickMedia { } if(item_index == selected_item && item->timestamp_text) { - item->timestamp_text->setPosition(vec2f_round(item_pos.x + size.x - item->timestamp_text->getLocalBounds().width - body_spacing[body_theme].padding_x, timestamp_text_y + 8.0f)); + item->timestamp_text->setPosition(vec2f_floor(item_pos.x + size.x - item->timestamp_text->getLocalBounds().width - body_spacing[body_theme].padding_x, timestamp_text_y + 8.0f)); window.draw(*item->timestamp_text); } @@ -1551,7 +1551,7 @@ namespace QuickMedia { if(current_json.isNumeric() && total_json.isNumeric()) { progress_text.setString(std::string("Page: ") + std::to_string(current_json.asInt()) + "/" + std::to_string(total_json.asInt())); auto bounds = progress_text.getLocalBounds(); - progress_text.setPosition(vec2f_round(item_pos.x + size.x - bounds.width - body_spacing[body_theme].padding_x, timestamp_text_y + text_offset_y)); + progress_text.setPosition(vec2f_floor(item_pos.x + size.x - bounds.width - body_spacing[body_theme].padding_x, timestamp_text_y + text_offset_y)); window.draw(progress_text); } } diff --git a/src/QuickMedia.cpp b/src/QuickMedia.cpp index cdf20f8..e63a5f2 100644 --- a/src/QuickMedia.cpp +++ b/src/QuickMedia.cpp @@ -3669,7 +3669,7 @@ namespace QuickMedia { redraw = false; if(error) { auto bounds = error_message.getLocalBounds(); - error_message.setPosition(vec2f_round(content_size.x * 0.5f - bounds.width * 0.5f, content_size.y * 0.5f - bounds.height)); + error_message.setPosition(vec2f_floor(content_size.x * 0.5f - bounds.width * 0.5f, content_size.y * 0.5f - bounds.height)); } else { sf::Vector2f image_scale; if(fit_image_to_window) @@ -3681,7 +3681,7 @@ namespace QuickMedia { auto image_size = texture_size_f; image_size.x *= image_scale.x; image_size.y *= image_scale.y; - image.setPosition(vec2f_round(content_size.x * 0.5f - image_size.x * 0.5f, content_size.y * 0.5f - image_size.y * 0.5f)); + image.setPosition(vec2f_floor(content_size.x * 0.5f - image_size.x * 0.5f, content_size.y * 0.5f - image_size.y * 0.5f)); } window.clear(get_theme().background_color); @@ -3697,7 +3697,7 @@ namespace QuickMedia { window.draw(chapter_text_background); auto text_bounds = chapter_text.getLocalBounds(); - chapter_text.setPosition(vec2f_round(window_size.x * 0.5f - text_bounds.width * 0.5f, window_size.y - bottom_panel_height * 0.5f - font_height * 0.5f)); + chapter_text.setPosition(vec2f_floor(window_size.x * 0.5f - text_bounds.width * 0.5f, window_size.y - bottom_panel_height * 0.5f - font_height * 0.5f)); window.draw(chapter_text); window.display(); @@ -4349,7 +4349,7 @@ namespace QuickMedia { redraw = false; comment_input.set_max_width(window_size.x - (logo_padding_x + logo_size.x + chat_input_padding_x + logo_padding_x)); - comment_input.set_position(vec2f_round(logo_padding_x + logo_size.x + chat_input_padding_x, chat_input_padding_y)); + comment_input.set_position(vec2f_floor(logo_padding_x + logo_size.x + chat_input_padding_x, chat_input_padding_y)); const float body_width = window_size.x; @@ -4390,7 +4390,7 @@ namespace QuickMedia { auto captcha_image_size = captcha_texture_size_f; captcha_image_size.x *= image_scale.x; captcha_image_size.y *= image_scale.y; - captcha_sprite.setPosition(vec2f_round(content_size.x * 0.5f - captcha_image_size.x * 0.5f, content_size.y * 0.5f - captcha_image_size.y * 0.5f)); + captcha_sprite.setPosition(vec2f_floor(content_size.x * 0.5f - captcha_image_size.x * 0.5f, content_size.y * 0.5f - captcha_image_size.y * 0.5f)); image_height = (int)captcha_image_size.y; if(has_captcha_bg && captcha_bg_texture.getNativeHandle() != 0) { @@ -4405,7 +4405,7 @@ namespace QuickMedia { image_size.x *= image_scale.x; image_size.y *= image_scale.y; const float width_diff = image_size.x - captcha_image_size.x; - captcha_bg_sprite.setPosition(vec2f_round(captcha_sprite.getPosition().x + width_diff*1.0f - captcha_slide*(width_diff + width_diff*2.0f), captcha_sprite.getPosition().y)); + captcha_bg_sprite.setPosition(vec2f_floor(captcha_sprite.getPosition().x + width_diff*1.0f - captcha_slide*(width_diff + width_diff*2.0f), captcha_sprite.getPosition().y)); window.draw(captcha_bg_sprite); image_height = std::max(image_height, (int)image_size.y); @@ -4427,7 +4427,7 @@ namespace QuickMedia { captcha_slide_bg.set_position(sf::Vector2f(captcha_sprite.getPosition().x, captcha_sprite.getPosition().y + image_height + 10.0f)); const sf::Vector2f captcha_slide_fg_size = captcha_slide_bg.get_size() - sf::Vector2f(captcha_slide_padding_x * 2.0f, captcha_slide_padding_y * 2.0f); - captcha_slide_fg.set_size(vec2f_round(captcha_slide_fg_size.x * captcha_slide, captcha_slide_fg_size.y)); + captcha_slide_fg.set_size(vec2f_floor(captcha_slide_fg_size.x * captcha_slide, captcha_slide_fg_size.y)); captcha_slide_fg.set_position(captcha_slide_bg.get_position() + sf::Vector2f(captcha_slide_padding_x, captcha_slide_padding_y)); if(has_captcha_bg) { @@ -4458,7 +4458,7 @@ namespace QuickMedia { auto image_size = texture_size_f; image_size.x *= image_scale.x; image_size.y *= image_scale.y; - attached_image_sprite.setPosition(vec2f_round(content_size.x * 0.5f - image_size.x * 0.5f, content_size.y * 0.5f - image_size.y * 0.5f)); + attached_image_sprite.setPosition(vec2f_floor(content_size.x * 0.5f - image_size.x * 0.5f, content_size.y * 0.5f - image_size.y * 0.5f)); window.draw(attached_image_sprite); } } else { @@ -4467,7 +4467,7 @@ namespace QuickMedia { auto content_size = window_size; auto rect_size = clamp_to_size(rect.getSize(), content_size); rect.setSize(rect_size); - rect.setPosition(vec2f_round(content_size.x * 0.5f - rect_size.x * 0.5f, content_size.y * 0.5f - rect_size.y * 0.5f)); + rect.setPosition(vec2f_floor(content_size.x * 0.5f - rect_size.x * 0.5f, content_size.y * 0.5f - rect_size.y * 0.5f)); window.draw(rect); load_sprite.setPosition(window_size.x * 0.5f, window_size.y * 0.5f); @@ -6550,7 +6550,7 @@ namespace QuickMedia { this->body_pos = sf::Vector2f(0.0f, tab_shade_height); if(window_size.x > 900.0f * get_config().scale * get_config().font_scale && show_room_side_panel) { - this->body_size = vec2f_round(300.0f * get_config().scale * get_config().font_scale, window_size.y - tab_shade_height); + this->body_size = vec2f_floor(300.0f * get_config().scale * get_config().font_scale, window_size.y - tab_shade_height); draw_room_list = true; } else { this->body_size = sf::Vector2f(0.0f, 0.0f); @@ -6564,7 +6564,7 @@ namespace QuickMedia { chat_input_shade.setPosition(body_pos.x, window_size.y - chat_input_shade.getSize().y); chat_input.set_max_width(window_size.x - (logo_padding_x + logo_size.x + chat_input_padding_x + logo_padding_x + body_pos.x)); - chat_input.set_position(vec2f_round(body_pos.x + logo_padding_x + logo_size.x + chat_input_padding_x, window_size.y - chat_height - chat_input_padding_y)); + chat_input.set_position(vec2f_floor(body_pos.x + logo_padding_x + logo_size.x + chat_input_padding_x, window_size.y - chat_height - chat_input_padding_y)); more_messages_below_rect.setSize(sf::Vector2f(chat_input_shade.getSize().x, gradient_height)); more_messages_below_rect.setPosition(chat_input_shade.getPosition().x, std::floor(window_size.y - chat_input_height_full - gradient_height)); @@ -7315,7 +7315,7 @@ namespace QuickMedia { redraw = false; loading_bar_background.set_size(sf::Vector2f(window_size.x - padding_x * 2.0f, loading_bar_height)); loading_bar_background.set_position(window_size * 0.5f - loading_bar_background.get_size() * 0.5f + sf::Vector2f(0.0f, download_speed_text.getLocalBounds().height * 0.5f)); - loading_bar_background.set_position(vec2f_round(loading_bar_background.get_position().x, loading_bar_background.get_position().y)); + loading_bar_background.set_position(vec2f_floor(loading_bar_background.get_position().x, loading_bar_background.get_position().y)); loading_bar.set_position(loading_bar_background.get_position() + sf::Vector2f(loading_bar_padding_x, loading_bar_padding_y)); filename_text.setPosition( loading_bar_background.get_position() + sf::Vector2f(0.0f, -(filename_text.getLocalBounds().height + spacing_y))); diff --git a/src/SearchBar.cpp b/src/SearchBar.cpp index 0a86bba..2a6b089 100644 --- a/src/SearchBar.cpp +++ b/src/SearchBar.cpp @@ -166,7 +166,7 @@ namespace QuickMedia { background.set_size(sf::Vector2f(width, rect_height)); shade.setSize(sf::Vector2f(size.x, padding_top + rect_height + padding_bottom)); - caret.setSize(vec2f_round(2.0f * get_config().scale, text.getCharacterSize() + std::floor(2.0f * get_config().scale))); + caret.setSize(vec2f_floor(2.0f * get_config().scale, text.getCharacterSize() + std::floor(2.0f * get_config().scale))); background.set_position(sf::Vector2f(pos.x + offset_x, pos.y + padding_top)); shade.setPosition(pos); diff --git a/src/Tabs.cpp b/src/Tabs.cpp index d22f959..866589b 100644 --- a/src/Tabs.cpp +++ b/src/Tabs.cpp @@ -1,9 +1,9 @@ #include "../include/Tabs.hpp" #include "../include/Body.hpp" #include "../include/ResourceLoader.hpp" +#include "../include/Utils.hpp" #include "../include/Config.hpp" #include "../include/Theme.hpp" -#include "../include/Utils.hpp" #include <SFML/Window/Event.hpp> #include <SFML/Graphics/RenderWindow.hpp> #include <cmath> @@ -24,7 +24,7 @@ namespace QuickMedia { return tab_height + std::floor(10.0f * get_config().scale); } - Tabs::Tabs(sf::Shader *rounded_rectangle_shader, sf::Color shade_color) : background(sf::Vector2f(1.0f, 1.0f), 10.0f, get_theme().background_color, rounded_rectangle_shader), shade_color(shade_color) { + Tabs::Tabs(sf::Shader *rounded_rectangle_shader, sf::Color shade_color) : background(sf::Vector2f(1.0f, 1.0f), 10.0f, get_theme().selected_color, rounded_rectangle_shader), shade_color(shade_color) { shade.setFillColor(shade_color); } @@ -101,7 +101,7 @@ namespace QuickMedia { width_per_tab = std::floor(width / num_visible_tabs); const float tab_text_y = std::floor(pos.y + tab_height*0.5f - (tab_text_size + 5.0f*get_config().scale)*0.5f); tab_background_width = std::floor(width_per_tab - tab_margin_x*2.0f); - background.set_size(sf::Vector2f(tab_background_width, get_shade_height() + std::floor(10.0f * get_config().scale))); + background.set_size(sf::Vector2f(tab_background_width, tab_height)); if(shade_color != sf::Color::Transparent) { shade.setSize(sf::Vector2f(width, get_shade_height())); @@ -173,7 +173,7 @@ namespace QuickMedia { window.draw(gradient_points, 4, sf::Quads); - sf::RectangleShape line(vec2f_round(10.0f * get_config().scale, 2.0f * get_config().scale)); + sf::RectangleShape line(vec2f_floor(10.0f * get_config().scale, 2.0f * get_config().scale)); line.setFillColor(get_theme().arrow_color); line.setOrigin(line.getSize().x * 0.5f, line.getSize().y * 0.5f); @@ -200,7 +200,7 @@ namespace QuickMedia { window.draw(gradient_points, 4, sf::Quads); - sf::RectangleShape line(vec2f_round(10.0f * get_config().scale, 2.0f * get_config().scale)); + sf::RectangleShape line(vec2f_floor(10.0f * get_config().scale, 2.0f * get_config().scale)); line.setFillColor(get_theme().arrow_color); line.setOrigin(line.getSize().x * 0.5f, line.getSize().y * 0.5f); diff --git a/src/Utils.cpp b/src/Utils.cpp index 3d87140..3e9fe7d 100644 --- a/src/Utils.cpp +++ b/src/Utils.cpp @@ -78,7 +78,7 @@ namespace QuickMedia { return time_str; } - sf::Vector2f vec2f_round(float x, float y) { + sf::Vector2f vec2f_floor(float x, float y) { return sf::Vector2f(int(x), int(y)); } } |