aboutsummaryrefslogtreecommitdiff
path: root/include/Body.hpp
diff options
context:
space:
mode:
authordec05eba <dec05eba@protonmail.com>2021-06-02 17:42:30 +0200
committerdec05eba <dec05eba@protonmail.com>2021-06-02 17:43:47 +0200
commitcc3a65bde2e480b2b07b74eeef20d9081d7f730f (patch)
tree1bb5b85ab764592093e8042458ec9f4be0cf904a /include/Body.hpp
parent1b6812348e75de21c8f398a7dc944cc427064cc4 (diff)
Add modern theme
Join matrix room by their name instead of id if there is a name. This allows you to join rooms where the homeserver that created the room is no longer participating in the room.
Diffstat (limited to 'include/Body.hpp')
-rw-r--r--include/Body.hpp28
1 files changed, 20 insertions, 8 deletions
diff --git a/include/Body.hpp b/include/Body.hpp
index 388d825..4846b59 100644
--- a/include/Body.hpp
+++ b/include/Body.hpp
@@ -30,7 +30,13 @@ namespace QuickMedia {
enum class ThumbnailMaskType {
NONE,
- CIRCLE
+ CIRCLE,
+ ROUNDED_RECTANGLE
+ };
+
+ enum BodyTheme : int {
+ BODY_THEME_MINIMAL,
+ BODY_THEME_MODERN_SPACIOUS
};
// TODO: Remove and create an Userdata class instead to replace the void* userdata in BodyItem
@@ -183,7 +189,7 @@ namespace QuickMedia {
class Body {
public:
- Body(Program *program, sf::Texture &loading_icon_texture, sf::Shader *rounded_rectangle_shader);
+ Body(BodyTheme body_theme, sf::Texture &loading_icon_texture, sf::Shader *rounded_rectangle_shader, sf::Shader *rounded_rectangle_mask_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
@@ -231,7 +237,6 @@ namespace QuickMedia {
void draw_item(sf::RenderWindow &window, BodyItem *item, sf::Vector2f pos, sf::Vector2f size, bool include_embedded_item = true, bool is_embedded = false);
float get_item_height(BodyItem *item, float width, bool load_texture = true, bool include_embedded_item = true, bool merge_with_previous = false, int item_index = -1);
- float get_spacing_y() const;
// TODO: Highlight the part of the text that matches the search.
void filter_search_fuzzy(const std::string &text);
@@ -254,14 +259,10 @@ namespace QuickMedia {
void apply_search_filter_for_item(BodyItem *body_item);
- sf::Text progress_text;
- sf::Text replies_text;
- sf::Text embedded_item_load_text;
BodyItems items;
bool draw_thumbnails;
// Set to {0, 0} to disable resizing
sf::Vector2i thumbnail_max_size;
- sf::Color line_separator_color;
BodyItemRenderCallback body_item_render_callback;
BodyItemMergeHandler body_item_merge_handler;
std::function<void(BodyItem*)> body_item_select_callback;
@@ -269,10 +270,12 @@ namespace QuickMedia {
AttachSide attach_side = AttachSide::TOP;
bool title_mark_urls = false;
bool swiping_enabled = false;
+ bool show_drop_shadow = true;
std::function<void()> on_top_reached = nullptr;
std::function<void()> on_bottom_reached = nullptr;
private:
+ void draw_drop_shadow(sf::RenderWindow &window);
void filter_search_fuzzy_item(const std::string &text, BodyItem *body_item);
void handle_item_render(BodyItem *item, const sf::Vector2f pos, const sf::Vector2f size, const float item_height, int item_index);
void draw_item(sf::RenderWindow &window, BodyItem *item, const sf::Vector2f &pos, const sf::Vector2f &size, const float item_height, const int item_index, const Json::Value &content_progress, bool include_embedded_item = true, bool merge_with_previous = false);
@@ -302,7 +305,8 @@ namespace QuickMedia {
BOTTOM
};
- Program *program;
+ BodyTheme body_theme;
+
int selected_item;
int prev_selected_item;
double page_scroll = 0.0;
@@ -312,6 +316,11 @@ namespace QuickMedia {
//sf::RectangleShape item_separator;
sf::Sprite image;
sf::Sprite loading_icon;
+
+ sf::Text progress_text;
+ sf::Text replies_text;
+ sf::Text embedded_item_load_text;
+
int num_visible_items;
bool top_cut_off;
bool bottom_cut_off;
@@ -345,12 +354,15 @@ namespace QuickMedia {
RoundedRectangle item_background;
RoundedRectangle reaction_background;
bool render_selected_item_bg = true;
+ float item_background_prev_pos_y = 0.0f;
float item_background_target_pos_y = 0.0f;
+ float item_background_prev_height = 0.0f;
float item_background_target_height = 0.0f;
TargetSetState target_y_set = TargetSetState::NOT_SET;
// TODO: Instead of using this, add functions for modifying |items| and apply the filter on those new items
DirtyState items_dirty = DirtyState::FALSE;
std::string current_filter;
bool using_filter = false;
+ sf::Shader *rounded_rectangle_mask_shader;
};
} \ No newline at end of file