From 144a3ddfb55fbf17cec4baaa73542664d68a3b05 Mon Sep 17 00:00:00 2001 From: Loic Guegan Date: Sat, 31 Dec 2022 11:47:56 +0100 Subject: Debug comments$ --- src/components/MoveTable.cpp | 29 ++++++++++++++--------------- 1 file changed, 14 insertions(+), 15 deletions(-) (limited to 'src/components/MoveTable.cpp') diff --git a/src/components/MoveTable.cpp b/src/components/MoveTable.cpp index c3cbcbf..7e51c9f 100644 --- a/src/components/MoveTable.cpp +++ b/src/components/MoveTable.cpp @@ -209,16 +209,13 @@ std::uint32_t MoveTable::DrawComment(CGEHalfMove *m, std::uint32_t line, ((indent + 1) / 2 * status->MarginBarWidth), status->MoveHeight * line); } - // Print comment - line++; - + line++; // Goto the right line /// ----- Compute comment bounding box values int nchar=m->comment.size(); - int nline=ceil((double)nchar/(double)status->CharPerLine); - std::uint16_t nrow=ceil((nline*status->TextCharHeight)/status->MoveHeight); - std::cout << nrow <CharPerLine*status->TextCharWidth; + int nline=ceil((double)nchar/(double)status->CommentCharPerLine); + std::uint16_t nrow=ceil(((nline*status->CommentCharHeight)+2*status->CommentPadding)/status->MoveHeight); + int width=status->CommentCharPerLine*status->CommentCharWidth+2*status->CommentPadding; int height=nrow*status->MoveHeight; // Draw comment background @@ -244,19 +241,21 @@ std::uint32_t MoveTable::DrawComment(CGEHalfMove *m, std::uint32_t line, status->Events.push_back({Event::Type::CommentSelected, m}); } // Now draw each lines of the comment: - Element l; + Element l; // One line l.prop = Property::Comment|Property::Text; - l.x=e.x; - l.y=e.y; - std::cout <<"x=" << l.x << " y="<comment.substr(i*status->CharPerLine,status->CharPerLine); + l.text=m->comment.substr(i*status->CommentCharPerLine,status->CommentCharPerLine); + // Remove leading space: + if(l.text.size()>2 && l.text[0]==' '){ + l.text=l.text.substr(1,l.text.size()); + } elements.push_back(l); - l.y+=status->TextCharHeight; + l.y+=status->CommentCharHeight; } // Do not forget to add marging before comment if indented: if (indent > 0) { -- cgit v1.2.3