aboutsummaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
Diffstat (limited to 'include')
-rw-r--r--include/Body.hpp8
-rw-r--r--include/Entry.hpp7
-rw-r--r--include/QuickMedia.hpp1
-rw-r--r--include/RoundedRectangle.hpp27
-rw-r--r--include/SearchBar.hpp8
-rw-r--r--include/Tabs.hpp7
6 files changed, 44 insertions, 14 deletions
diff --git a/include/Body.hpp b/include/Body.hpp
index 98baa6d..58e1414 100644
--- a/include/Body.hpp
+++ b/include/Body.hpp
@@ -2,10 +2,10 @@
#include "Text.hpp"
#include "AsyncImageLoader.hpp"
+#include "RoundedRectangle.hpp"
#include <SFML/Graphics/Text.hpp>
#include <SFML/Graphics/RectangleShape.hpp>
#include <SFML/Graphics/Sprite.hpp>
-#include "../external/RoundedRectangleShape.hpp"
#include <json/value.h>
#include <thread>
#include <future>
@@ -179,7 +179,7 @@ namespace QuickMedia {
class Body {
public:
- Body(Program *program, sf::Texture &loading_icon_texture);
+ Body(Program *program, sf::Texture &loading_icon_texture, sf::Shader *rounded_rectangle_shader);
~Body();
// Select previous page, ignoring invisible items. Returns true if the item was changed. This can be used to check if the top was hit when wrap_around is set to false
@@ -279,7 +279,6 @@ namespace QuickMedia {
// TODO: Use a loading gif or something similar instead, to properly indicate the image is loading. Which could also have text that says "failed to load image" when image loading failed.
sf::RectangleShape image_fallback;
sf::RectangleShape item_separator;
- sf::RoundedRectangleShape item_background;
sf::Sprite image;
sf::Sprite loading_icon;
int num_visible_items;
@@ -313,6 +312,7 @@ namespace QuickMedia {
float selected_scrolled = 0.0f;
bool loaded_textures_changed = false;
std::shared_ptr<BodyItem> clicked_body_item = nullptr;
- //float scroll_y = 0.0f;
+ RoundedRectangle item_background;
+ RoundedRectangle reaction_background;
};
} \ No newline at end of file
diff --git a/include/Entry.hpp b/include/Entry.hpp
index 10210f8..02d0a59 100644
--- a/include/Entry.hpp
+++ b/include/Entry.hpp
@@ -1,7 +1,7 @@
#pragma once
#include "Text.hpp"
-#include "../external/RoundedRectangleShape.hpp"
+#include "RoundedRectangle.hpp"
#include <SFML/Graphics/Text.hpp>
#include <functional>
@@ -9,6 +9,7 @@ namespace sf {
class Font;
class Event;
class RenderWindow;
+ class Shader;
}
namespace QuickMedia {
@@ -17,7 +18,7 @@ namespace QuickMedia {
class Entry {
public:
- Entry(const std::string &placeholder_text);
+ Entry(const std::string &placeholder_text, sf::Shader *rounded_rectangle_shader);
void process_event(sf::Event &event);
void draw(sf::RenderWindow &window);
@@ -35,7 +36,7 @@ namespace QuickMedia {
private:
Text text;
float width;
- sf::RoundedRectangleShape background;
+ RoundedRectangle background;
sf::Text placeholder;
bool mouse_left_inside;
};
diff --git a/include/QuickMedia.hpp b/include/QuickMedia.hpp
index e61c2ff..ec788bf 100644
--- a/include/QuickMedia.hpp
+++ b/include/QuickMedia.hpp
@@ -173,6 +173,7 @@ namespace QuickMedia {
int exit_code = 0;
std::string resources_root;
sf::Shader circle_mask_shader;
+ sf::Shader rounded_rectangle_shader;
bool no_video = false;
bool force_no_video = false;
bool use_system_mpv_config = false;
diff --git a/include/RoundedRectangle.hpp b/include/RoundedRectangle.hpp
new file mode 100644
index 0000000..f72a083
--- /dev/null
+++ b/include/RoundedRectangle.hpp
@@ -0,0 +1,27 @@
+#pragma once
+
+#include <SFML/System/Vector2.hpp>
+#include <SFML/Graphics/Vertex.hpp>
+
+namespace sf {
+ class RenderWindow;
+ class Shader;
+}
+
+namespace QuickMedia {
+ class RoundedRectangle {
+ public:
+ RoundedRectangle(sf::Vector2f size, float radius, sf::Color color, sf::Shader *rounded_rectangle_shader);
+ void set_position(sf::Vector2f pos);
+ void set_size(sf::Vector2f size);
+ sf::Vector2f get_position() const;
+ sf::Vector2f get_size() const;
+ void draw(sf::RenderWindow &window);
+ private:
+ float radius;
+ sf::Vector2f pos;
+ sf::Vector2f size;
+ sf::Vertex vertices[4];
+ sf::Shader *rounded_rectangle_shader;
+ };
+} \ No newline at end of file
diff --git a/include/SearchBar.hpp b/include/SearchBar.hpp
index b2cdf4d..76ad24b 100644
--- a/include/SearchBar.hpp
+++ b/include/SearchBar.hpp
@@ -1,16 +1,17 @@
#pragma once
+#include "RoundedRectangle.hpp"
#include <SFML/Graphics/Text.hpp>
#include <SFML/Graphics/RectangleShape.hpp>
#include <SFML/Graphics/Sprite.hpp>
#include <SFML/System/Clock.hpp>
-#include "../external/RoundedRectangleShape.hpp"
#include <functional>
namespace sf {
class Font;
class RenderWindow;
class Event;
+ class Shader;
}
namespace QuickMedia {
@@ -21,7 +22,7 @@ namespace QuickMedia {
class SearchBar {
public:
- SearchBar(sf::Texture *plugin_logo, const std::string &placeholder, bool input_masked = false);
+ SearchBar(sf::Texture *plugin_logo, sf::Shader *rounded_rectangle_shader, const std::string &placeholder, bool input_masked = false);
void draw(sf::RenderWindow &window, bool draw_shadow = true);
void on_event(sf::Event &event);
void update();
@@ -32,7 +33,6 @@ namespace QuickMedia {
void set_to_autocomplete();
void set_autocomplete_text(const std::string &text);
void set_vertical_position(float vertical_pos);
- void set_background_color(sf::Color color);
float getBottom() const;
float getBottomWithoutShadow() const;
@@ -53,7 +53,7 @@ namespace QuickMedia {
private:
sf::Text text;
sf::Text autocomplete_text;
- sf::RoundedRectangleShape background;
+ RoundedRectangle background;
sf::RectangleShape background_shadow;
sf::RectangleShape shade;
sf::RectangleShape caret;
diff --git a/include/Tabs.hpp b/include/Tabs.hpp
index d5aa5b6..d899a61 100644
--- a/include/Tabs.hpp
+++ b/include/Tabs.hpp
@@ -1,6 +1,6 @@
#pragma once
-#include "../external/RoundedRectangleShape.hpp"
+#include "RoundedRectangle.hpp"
#include <SFML/Graphics/RectangleShape.hpp>
#include <SFML/Graphics/Text.hpp>
#include <vector>
@@ -9,12 +9,13 @@
namespace sf {
class Event;
class RenderWindow;
+ class Shader;
}
namespace QuickMedia {
class Tabs {
public:
- Tabs(sf::Color shade_color = sf::Color(33, 37, 44));
+ Tabs(sf::Shader *rounded_rectangle_shader, sf::Color shade_color = sf::Color(33, 37, 44));
static float get_height();
static float get_shade_height();
@@ -34,7 +35,7 @@ namespace QuickMedia {
float tab_index_to_x_offset(int index);
private:
std::vector<sf::Text> tab_texts;
- sf::RoundedRectangleShape background;
+ RoundedRectangle background;
sf::RectangleShape shade;
int selected_tab = 0;
float scroll = 0.0f;