diff options
author | Andrei Karas <akaras@inbox.ru> | 2013-03-24 14:32:36 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2013-03-24 14:32:36 +0300 |
commit | 0c3d18a076b2ac999f47500a76f5ebf3b1a722ed (patch) | |
tree | 4f474688d3937f84cbd490af265a6fa918b0ec52 /src | |
parent | e0b255453f189f80aab146574bdcb873771801c6 (diff) | |
download | mv-0c3d18a076b2ac999f47500a76f5ebf3b1a722ed.tar.gz mv-0c3d18a076b2ac999f47500a76f5ebf3b1a722ed.tar.bz2 mv-0c3d18a076b2ac999f47500a76f5ebf3b1a722ed.tar.xz mv-0c3d18a076b2ac999f47500a76f5ebf3b1a722ed.zip |
improve textmanager class.
Diffstat (limited to 'src')
-rw-r--r-- | src/textmanager.cpp | 15 | ||||
-rw-r--r-- | src/textmanager.h | 4 |
2 files changed, 10 insertions, 9 deletions
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<Text *> TextList; /**< The container type */ TextList mTextList; /**< The container */ |