aboutsummaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authordec05eba <dec05eba@protonmail.com>2022-11-07 01:01:28 +0100
committerdec05eba <dec05eba@protonmail.com>2022-11-07 14:24:32 +0100
commitede1a8476acd54941c20b809455ba62b30302a4e (patch)
tree82160da56025e47484c23e8496f1d59b8ddc084f /include
parent8025d1075db0779bde635148f6e38303eb29d6c8 (diff)
Add option to limit number of lines of text drawn in Text class
Diffstat (limited to 'include')
-rw-r--r--include/BodyItem.hpp17
-rw-r--r--include/Text.hpp7
2 files changed, 21 insertions, 3 deletions
diff --git a/include/BodyItem.hpp b/include/BodyItem.hpp
index b7dc48a..647d344 100644
--- a/include/BodyItem.hpp
+++ b/include/BodyItem.hpp
@@ -104,6 +104,14 @@ namespace QuickMedia {
force_title_color = new_force_color;
}
+ // Set to 0 to disable max lines
+ void set_title_max_lines(int max_lines) {
+ if(max_lines == title_max_lines)
+ return;
+ title_max_lines = max_lines;
+ dirty = true;
+ }
+
void set_description_color(mgl::Color new_color, bool new_force_color = false) {
if(new_color == description_color && new_force_color == force_description_color)
return;
@@ -112,6 +120,13 @@ namespace QuickMedia {
force_description_color = new_force_color;
}
+ void set_description_max_lines(int max_lines) {
+ if(max_lines == description_max_lines)
+ return;
+ description_max_lines = max_lines;
+ dirty_description = true;
+ }
+
void set_author_color(mgl::Color new_color, bool new_force_color = false) {
if(new_color == author_color && new_force_color == force_description_color)
return;
@@ -153,6 +168,8 @@ namespace QuickMedia {
// TODO: Use a list of strings instead, not all plugins need all of these fields
std::string url;
std::string thumbnail_url;
+ int title_max_lines = 0;
+ int description_max_lines = 0;
bool visible; // TODO: Make private and when set by user, set a |visible_force| variable to true or false which makes the item invisible even after filtering
bool dirty;
bool dirty_description;
diff --git a/include/Text.hpp b/include/Text.hpp
index 73dd565..601f1a2 100644
--- a/include/Text.hpp
+++ b/include/Text.hpp
@@ -100,6 +100,8 @@ namespace QuickMedia
// text_flags is bit-or of FormattedTextFlag
static std::string formatted_text(const std::string &text, mgl::Color color, uint8_t text_flags);
void insert_text_at_caret_position(const std::string &str);
+ // Set to 0 to disable max lines
+ void set_max_lines(int max_lines);
static std::string to_printable_string(const std::string &str);
@@ -186,7 +188,7 @@ namespace QuickMedia
float maxWidth;
mgl::vec2f position;
mgl::Color color;
- bool force_color;
+ bool force_color = false;
bool dirty;
bool dirtyText;
bool dirtyCaret;
@@ -202,10 +204,9 @@ namespace QuickMedia
int caretIndex;
float caret_offset_x;
mgl::vec2f caretPosition;
- mgl::vec2u renderTarget_size;
+ int max_lines = 0;
std::vector<VertexRef> vertices_linear; // TODO: Use textElements instead
-
std::vector<Range> url_ranges;
};
}