aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordec05eba <dec05eba@protonmail.com>2019-08-10 06:44:16 +0200
committerdec05eba <dec05eba@protonmail.com>2019-08-10 06:44:19 +0200
commitfe475d755534d3c97ac1030429a97477710d74e6 (patch)
treeccdfb533eb91565131dcb0f99f8dbcf94580f70c
parent8032c13df9eafd1539112dc6f72eb9e1a695ad31 (diff)
Change design, add logos
-rw-r--r--images/manganelo_logo.pngbin0 -> 17702 bytes
-rw-r--r--images/pornhub_logo.pngbin0 -> 11121 bytes
-rw-r--r--images/yt_logo_rgb_dark_large.pngbin0 -> 7438 bytes
-rw-r--r--images/yt_logo_rgb_dark_small.pngbin0 -> 6975 bytes
-rw-r--r--include/QuickMedia.hpp1
-rw-r--r--include/SearchBar.hpp6
-rw-r--r--src/Body.cpp6
-rw-r--r--src/QuickMedia.cpp25
-rw-r--r--src/SearchBar.cpp52
9 files changed, 69 insertions, 21 deletions
diff --git a/images/manganelo_logo.png b/images/manganelo_logo.png
new file mode 100644
index 0000000..4b8e707
--- /dev/null
+++ b/images/manganelo_logo.png
Binary files differ
diff --git a/images/pornhub_logo.png b/images/pornhub_logo.png
new file mode 100644
index 0000000..0ae5a76
--- /dev/null
+++ b/images/pornhub_logo.png
Binary files differ
diff --git a/images/yt_logo_rgb_dark_large.png b/images/yt_logo_rgb_dark_large.png
new file mode 100644
index 0000000..64d91a3
--- /dev/null
+++ b/images/yt_logo_rgb_dark_large.png
Binary files differ
diff --git a/images/yt_logo_rgb_dark_small.png b/images/yt_logo_rgb_dark_small.png
new file mode 100644
index 0000000..d480e1f
--- /dev/null
+++ b/images/yt_logo_rgb_dark_small.png
Binary files differ
diff --git a/include/QuickMedia.hpp b/include/QuickMedia.hpp
index 90ceddd..5010025 100644
--- a/include/QuickMedia.hpp
+++ b/include/QuickMedia.hpp
@@ -33,6 +33,7 @@ namespace QuickMedia {
sf::Font font;
Body *body;
Plugin *current_plugin;
+ sf::Texture plugin_logo;
std::unique_ptr<SearchBar> search_bar;
Page current_page;
// TODO: Combine these
diff --git a/include/SearchBar.hpp b/include/SearchBar.hpp
index 0ddcac9..8ac8766 100644
--- a/include/SearchBar.hpp
+++ b/include/SearchBar.hpp
@@ -4,6 +4,7 @@
#include <SFML/Graphics/Font.hpp>
#include <SFML/Graphics/Text.hpp>
#include <SFML/Graphics/RectangleShape.hpp>
+#include <SFML/Graphics/Sprite.hpp>
#include <functional>
namespace QuickMedia {
@@ -13,7 +14,7 @@ namespace QuickMedia {
class SearchBar {
public:
- SearchBar(sf::Font &font);
+ SearchBar(sf::Font &font, sf::Texture &plugin_logo);
void draw(sf::RenderWindow &window);
void update();
void onWindowResize(const sf::Vector2f &window_size);
@@ -29,8 +30,11 @@ namespace QuickMedia {
sf::Text text;
sf::RectangleShape background;
sf::RectangleShape background_shadow;
+ sf::RectangleShape shade;
+ sf::Sprite plugin_logo_sprite;
bool show_placeholder;
bool updated_search;
+ bool draw_logo;
sf::Clock time_since_search_update;
};
} \ No newline at end of file
diff --git a/src/Body.cpp b/src/Body.cpp
index 1165399..c87844c 100644
--- a/src/Body.cpp
+++ b/src/Body.cpp
@@ -129,10 +129,10 @@ namespace QuickMedia {
//item_background.setOutlineThickness(1.0f);
//item_background.setOutlineColor(sf::Color(13, 15, 17));
sf::RectangleShape item_background_shadow;
- item_background_shadow.setFillColor(sf::Color(13, 15, 17));
+ item_background_shadow.setFillColor(sf::Color(23, 25, 27));
sf::RectangleShape selected_border;
- selected_border.setFillColor(sf::Color::Red);
+ selected_border.setFillColor(sf::Color(0, 85, 119));
const float selected_border_width = 5.0f;
int num_items = items.size();
@@ -189,7 +189,7 @@ namespace QuickMedia {
selected_border.setSize(sf::Vector2f(selected_border_width, row_height));
window.draw(selected_border);
item_pos.x += selected_border_width;
- item_background.setFillColor(sf::Color(63, 65, 67));
+ item_background.setFillColor(sf::Color(0, 85, 119));
} else {
item_background.setFillColor(front_color);
}
diff --git a/src/QuickMedia.cpp b/src/QuickMedia.cpp
index e80fde6..dab1eae 100644
--- a/src/QuickMedia.cpp
+++ b/src/QuickMedia.cpp
@@ -20,7 +20,7 @@
#include <signal.h>
const sf::Color front_color(43, 45, 47);
-const sf::Color back_color(33, 35, 37);
+const sf::Color back_color(30, 32, 34);
const int DOUBLE_CLICK_TIME = 500;
// Prevent writing to broken pipe from exiting the program
@@ -43,7 +43,6 @@ namespace QuickMedia {
abort();
}
body = new Body(font);
- search_bar = std::make_unique<SearchBar>(font);
struct sigaction action;
action.sa_handler = sigpipe_handler;
@@ -82,17 +81,31 @@ namespace QuickMedia {
return -1;
}
- if(strcmp(argv[1], "manganelo") == 0)
+ std::string plugin_logo_path;
+ if(strcmp(argv[1], "manganelo") == 0) {
current_plugin = new Manganelo();
- else if(strcmp(argv[1], "youtube") == 0)
+ plugin_logo_path = "../../../images/manganelo_logo.png";
+ } else if(strcmp(argv[1], "youtube") == 0) {
current_plugin = new Youtube();
- else if(strcmp(argv[1], "pornhub") == 0)
+ plugin_logo_path = "../../../images/yt_logo_rgb_dark_small.png";
+ } else if(strcmp(argv[1], "pornhub") == 0) {
current_plugin = new Pornhub();
- else {
+ plugin_logo_path = "../../../images/pornhub_logo.png";
+ } else {
usage();
return -1;
}
+ if(!plugin_logo_path.empty()) {
+ if(!plugin_logo.loadFromFile(plugin_logo_path)) {
+ fprintf(stderr, "Failed to load plugin logo, path: %s\n", plugin_logo_path.c_str());
+ return -2;
+ }
+ plugin_logo.generateMipmap();
+ plugin_logo.setSmooth(true);
+ }
+
+ search_bar = std::make_unique<SearchBar>(font, plugin_logo);
search_bar->text_autosearch_delay = current_plugin->get_search_delay();
while(window.isOpen()) {
diff --git a/src/SearchBar.cpp b/src/SearchBar.cpp
index ae229b5..e792480 100644
--- a/src/SearchBar.cpp
+++ b/src/SearchBar.cpp
@@ -1,35 +1,42 @@
#include "../include/SearchBar.hpp"
+#include "../include/Scale.hpp"
#include <cmath>
const sf::Color text_placeholder_color(255, 255, 255, 100);
const sf::Color front_color(43, 45, 47);
const float background_margin_horizontal = 8.0f;
const float background_margin_vertical = 4.0f;
-const float padding_horizontal = 10.0f;
-const float padding_vertical = 10.0f;
+const float PADDING_HORIZONTAL = 50.0f;
+const float padding_vertical = 20.0f;
namespace QuickMedia {
- SearchBar::SearchBar(sf::Font &font) :
+ SearchBar::SearchBar(sf::Font &font, sf::Texture &plugin_logo) :
onTextUpdateCallback(nullptr),
onTextSubmitCallback(nullptr),
text_autosearch_delay(0),
text("Search...", font, 18),
show_placeholder(true),
- updated_search(false)
+ updated_search(false),
+ draw_logo(false)
{
text.setFillColor(text_placeholder_color);
background.setFillColor(front_color);
- background.setPosition(padding_horizontal, padding_vertical);
- background_shadow.setFillColor(sf::Color(13, 15, 17));
- background_shadow.setPosition(background.getPosition() + sf::Vector2f(5.0f, 5.0f));
- //background.setOutlineThickness(2.0f);
+ 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));
+ //background.setOutlineThickness(1.0f);
//background.setOutlineColor(sf::Color(13, 15, 17));
+ if(plugin_logo.getNativeHandle() != 0)
+ plugin_logo_sprite.setTexture(plugin_logo, true);
}
void SearchBar::draw(sf::RenderWindow &window) {
window.draw(background_shadow);
+ window.draw(shade);
window.draw(background);
window.draw(text);
+ if(draw_logo)
+ window.draw(plugin_logo_sprite);
}
void SearchBar::update() {
@@ -45,11 +52,34 @@ namespace QuickMedia {
}
void SearchBar::onWindowResize(const sf::Vector2f &window_size) {
+ draw_logo = plugin_logo_sprite.getTexture() != nullptr;
+ float padding_horizontal = PADDING_HORIZONTAL;
+ if(window_size.x - padding_horizontal * 2.0f < 400.0f) {
+ padding_horizontal = 0.0f;
+ draw_logo = false;
+ }
+
float font_height = text.getCharacterSize() + 8.0f;
float rect_height = std::floor(font_height + background_margin_vertical * 2.0f);
- background.setSize(sf::Vector2f(std::floor(window_size.x - padding_horizontal * 2.0f), rect_height));
- background_shadow.setSize(background.getSize());
- text.setPosition(std::floor(padding_horizontal + background_margin_horizontal), std::floor(padding_vertical + background_margin_vertical));
+
+ float offset_x = padding_horizontal;
+ if(draw_logo) {
+ auto texture_size = plugin_logo_sprite.getTexture()->getSize();
+ sf::Vector2f texture_size_f(texture_size.x, texture_size.y);
+ sf::Vector2f new_size = wrap_to_size(texture_size_f, sf::Vector2f(200.0f, rect_height));
+ plugin_logo_sprite.setScale(get_ratio(texture_size_f, new_size));
+ plugin_logo_sprite.setPosition(25.0f, padding_vertical);
+ offset_x = 25.0f + new_size.x + 25.0f;
+ }
+ const float width = std::floor(window_size.x - offset_x - padding_horizontal);
+
+ background.setSize(sf::Vector2f(width, rect_height));
+ shade.setSize(sf::Vector2f(window_size.x, padding_vertical + rect_height + padding_vertical));
+ background_shadow.setSize(sf::Vector2f(window_size.x, 5.0f));
+
+ background.setPosition(offset_x, padding_vertical);
+ background_shadow.setPosition(0.0f, std::floor(shade.getSize().y));
+ text.setPosition(std::floor(offset_x + background_margin_horizontal), std::floor(padding_vertical + background_margin_vertical));
}
void SearchBar::onTextEntered(sf::Uint32 codepoint) {