diff options
author | dec05eba <dec05eba@protonmail.com> | 2019-11-30 23:42:28 +0100 |
---|---|---|
committer | dec05eba <dec05eba@protonmail.com> | 2019-11-30 23:42:28 +0100 |
commit | fa59cd8c7e31afce5b5233e844084f881a411446 (patch) | |
tree | 3432b673dcedd585631a3548f144d57527905669 /include | |
parent | e67b9899feb72027b246e3b63ce5aa0ccae2dd16 (diff) |
Change size of body item rows depending on how many lines the text has
Diffstat (limited to 'include')
-rw-r--r-- | include/Body.hpp | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/include/Body.hpp b/include/Body.hpp index 32e19dc..d10b482 100644 --- a/include/Body.hpp +++ b/include/Body.hpp @@ -12,8 +12,18 @@ namespace QuickMedia { class BodyItem { public: - BodyItem(const std::string &_title): title(_title), visible(true) { + BodyItem(std::string _title): visible(true), num_lines(0) { + set_title(std::move(_title)); + } + void set_title(std::string new_title) { + title = std::move(new_title); + // TODO: Optimize this + num_lines = 0; + for(char c : title) { + if(c == '\n') + ++num_lines; + } } std::string title; @@ -22,6 +32,7 @@ namespace QuickMedia { bool visible; // Used by image boards for example. The elements are indices to other body items std::vector<size_t> replies; + int num_lines; }; using BodyItems = std::vector<std::unique_ptr<BodyItem>>; |