From 0c3d18a076b2ac999f47500a76f5ebf3b1a722ed Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Sun, 24 Mar 2013 14:32:36 +0300 Subject: improve textmanager class. --- src/textmanager.cpp | 15 ++++++++------- src/textmanager.h | 4 ++-- 2 files changed, 10 insertions(+), 9 deletions(-) (limited to 'src') diff --git a/src/textmanager.cpp b/src/textmanager.cpp index 29081769d..04e60d587 100644 --- a/src/textmanager.cpp +++ b/src/textmanager.cpp @@ -39,7 +39,7 @@ void TextManager::addText(Text *const text) mTextList.push_back(text); } -void TextManager::moveText(Text *const text, const int x, const int y) +void TextManager::moveText(Text *const text, const int x, const int y) const { text->mX = x; text->mY = y; @@ -72,7 +72,7 @@ void TextManager::draw(Graphics *const graphics, } void TextManager::place(const Text *const textObj, const Text *const omit, - const int &x A_UNUSED, int &y, const int h) + const int &x A_UNUSED, int &y, const int h) const { const int xLeft = textObj->mX; const int xRight1 = xLeft + textObj->mWidth; @@ -88,12 +88,13 @@ void TextManager::place(const Text *const textObj, const Text *const omit, for (TextList::const_iterator ptr = mTextList.begin(), pEnd = mTextList.end(); ptr != pEnd && cnt < nBeings; ++ptr, cnt ++) { - if (*ptr != omit && - (*ptr)->mX + 1 <= xRight1 && - (*ptr)->mX + (*ptr)->mWidth > xLeft) + const Text *const text = *ptr; + + if (text != omit && text->mX + 1 <= xRight1 + && text->mX + text->mWidth > xLeft) { - int from = (*ptr)->mY - occupiedTop; - int to = from + (*ptr)->mHeight - 1; + int from = text->mY - occupiedTop; + int to = from + text->mHeight - 1; if (to < 0 || from >= TEST) // out of range considered continue; if (from < 0) diff --git a/src/textmanager.h b/src/textmanager.h index e926a9ca8..e3c9988fe 100644 --- a/src/textmanager.h +++ b/src/textmanager.h @@ -52,7 +52,7 @@ class TextManager final /** * Move the text around the screen */ - void moveText(Text *const text, const int x, const int y); + void moveText(Text *const text, const int x, const int y) const; /** * Remove the text from the manager @@ -70,7 +70,7 @@ class TextManager final * Position the text so as to avoid conflict */ void place(const Text *const textObj, const Text *const omit, - const int &x, int &y, const int h); + const int &x, int &y, const int h) const; typedef std::list TextList; /**< The container type */ TextList mTextList; /**< The container */ -- cgit v1.2.3-70-g09d2