From fa59cd8c7e31afce5b5233e844084f881a411446 Mon Sep 17 00:00:00 2001 From: dec05eba Date: Sat, 30 Nov 2019 23:42:28 +0100 Subject: Change size of body item rows depending on how many lines the text has --- include/Body.hpp | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'include') 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 replies; + int num_lines; }; using BodyItems = std::vector>; -- cgit v1.2.3