aboutsummaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authordec05eba <dec05eba@protonmail.com>2021-05-11 14:24:52 +0200
committerdec05eba <dec05eba@protonmail.com>2021-05-11 14:24:52 +0200
commite308d77b06405b91885cf6f97c0dc2a1b70679ef (patch)
tree7fb0ed73c20354f3e0ff49ebb199e33ebc3427f7 /include
parent6b90f55f4dc14b9d39fa0dbf6b82b3c12ccc29d9 (diff)
Improve file saving gui
Diffstat (limited to 'include')
-rw-r--r--include/Entry.hpp3
-rw-r--r--include/QuickMedia.hpp2
-rw-r--r--include/RoundedRectangle.hpp5
-rw-r--r--include/SearchBar.hpp3
-rw-r--r--include/Text.hpp2
-rw-r--r--include/gui/Button.hpp40
6 files changed, 53 insertions, 2 deletions
diff --git a/include/Entry.hpp b/include/Entry.hpp
index 02d0a59..581dc14 100644
--- a/include/Entry.hpp
+++ b/include/Entry.hpp
@@ -22,6 +22,7 @@ namespace QuickMedia {
void process_event(sf::Event &event);
void draw(sf::RenderWindow &window);
+ void set_single_line(bool single_line);
void set_editable(bool editable);
void set_text(std::string text);
void set_position(const sf::Vector2f &pos);
@@ -29,7 +30,9 @@ namespace QuickMedia {
void move_caret_to_end();
void append_text(std::string str);
+ bool is_editable() const;
float get_height();
+ const sf::String& get_text() const;
OnEntrySubmit on_submit_callback;
bool draw_background;
diff --git a/include/QuickMedia.hpp b/include/QuickMedia.hpp
index 01baf76..0ef5273 100644
--- a/include/QuickMedia.hpp
+++ b/include/QuickMedia.hpp
@@ -120,6 +120,8 @@ namespace QuickMedia {
bool chat_page(MatrixChatPage *matrix_chat_page, RoomData *current_room, std::vector<Tab> &room_tabs, int room_selected_tab);
void after_matrix_login_page();
void download_page(const char *url, bool download_use_youtube_dl);
+ // Returns the full path where the file should be saved, or an empty string if the operation was cancelled
+ std::string file_save_page(const std::string &filename);
enum class LoadImageResult {
OK,
diff --git a/include/RoundedRectangle.hpp b/include/RoundedRectangle.hpp
index f72a083..96e57fd 100644
--- a/include/RoundedRectangle.hpp
+++ b/include/RoundedRectangle.hpp
@@ -4,7 +4,7 @@
#include <SFML/Graphics/Vertex.hpp>
namespace sf {
- class RenderWindow;
+ class RenderTarget;
class Shader;
}
@@ -14,9 +14,10 @@ namespace QuickMedia {
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);
+ void set_color(sf::Color color);
sf::Vector2f get_position() const;
sf::Vector2f get_size() const;
- void draw(sf::RenderWindow &window);
+ void draw(sf::RenderTarget &target);
private:
float radius;
sf::Vector2f pos;
diff --git a/include/SearchBar.hpp b/include/SearchBar.hpp
index cad897f..4fc19e9 100644
--- a/include/SearchBar.hpp
+++ b/include/SearchBar.hpp
@@ -33,7 +33,9 @@ namespace QuickMedia {
void set_to_autocomplete();
void set_autocomplete_text(const std::string &text);
void set_position(sf::Vector2f pos);
+ void set_editable(bool editable);
+ bool is_editable() const;
float getBottom() const;
float getBottomWithoutShadow() const;
@@ -74,5 +76,6 @@ namespace QuickMedia {
sf::Vector2f pos;
sf::Clock time_since_search_update;
sf::Vector2f prev_size;
+ bool editable = true;
};
} \ No newline at end of file
diff --git a/include/Text.hpp b/include/Text.hpp
index 53105f5..cef6dd5 100644
--- a/include/Text.hpp
+++ b/include/Text.hpp
@@ -104,6 +104,8 @@ namespace QuickMedia
bool draw(sf::RenderTarget &target);
void updateGeometry(bool update_even_if_not_dirty = false);
+
+ bool single_line_edit = false;
private:
enum class CaretMoveDirection : u8
{
diff --git a/include/gui/Button.hpp b/include/gui/Button.hpp
new file mode 100644
index 0000000..ba6997b
--- /dev/null
+++ b/include/gui/Button.hpp
@@ -0,0 +1,40 @@
+#pragma once
+
+#include "../RoundedRectangle.hpp"
+#include <string>
+#include <SFML/Graphics/Text.hpp>
+
+namespace sf {
+ class Event;
+ class Font;
+ class RenderTarget;
+ class Shader;
+}
+
+namespace QuickMedia {
+ enum ButtonEvent {
+ BUTTON_EVENT_NONE = 0,
+ BUTTON_EVENT_CLICKED = 1
+ };
+
+ class Button {
+ public:
+ Button(const std::string &label, sf::Font *font, unsigned int character_size, float width, sf::Shader *rounded_rectangle_shader, float scale = 1.0f);
+
+ ButtonEvent on_event(sf::Event &event);
+ void draw(sf::RenderTarget &target);
+
+ void set_background_color(sf::Color color);
+ void set_position(sf::Vector2f pos);
+
+ sf::Vector2f get_position() const;
+ float get_width() const;
+ float get_height() const;
+ private:
+ sf::Text label;
+ RoundedRectangle background;
+ sf::Color background_color;
+ float scale;
+ bool clicked_inside = false;
+ };
+} \ No newline at end of file