From e3682e2cdcb59c36792f6f9c39569e0af01088f0 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Mon, 25 May 2015 01:58:52 +0300 Subject: Dont set global color variables before drawing text. This allow not set actual OpenGL color on each call because it useless for drawing text. --- src/gui/widgets/listbox.cpp | 28 ++++++++++++++++++---------- 1 file changed, 18 insertions(+), 10 deletions(-) (limited to 'src/gui/widgets/listbox.cpp') diff --git a/src/gui/widgets/listbox.cpp b/src/gui/widgets/listbox.cpp index 63595cfb3..d4b6f7a76 100644 --- a/src/gui/widgets/listbox.cpp +++ b/src/gui/widgets/listbox.cpp @@ -175,15 +175,15 @@ void ListBox::draw(Graphics *graphics) rowHeight * mSelected + mPadding, mDimension.width - 2 * mPadding, rowHeight)); - graphics->setColorAll(mForegroundSelectedColor, - mForegroundSelectedColor2); const std::string str = mListModel->getElementAt(mSelected); - font->drawString(graphics, str, + font->drawString(graphics, + mForegroundSelectedColor, + mForegroundSelectedColor2, + str, (width - font->getWidth(str)) / 2, mSelected * rowHeight + mPadding + mItemPadding); } // Draw the list elements - graphics->setColorAll(mForegroundColor, mForegroundColor2); const int sz = mListModel->getNumberOfElements(); for (int i = 0, y = mPadding + mItemPadding; i < sz; ++i, y += rowHeight) @@ -191,7 +191,10 @@ void ListBox::draw(Graphics *graphics) if (i != mSelected) { const std::string str = mListModel->getElementAt(i); - font->drawString(graphics, str, + font->drawString(graphics, + mForegroundColor, + mForegroundColor2, + str, (width - font->getWidth(str)) / 2, y); } } @@ -205,14 +208,15 @@ void ListBox::draw(Graphics *graphics) rowHeight * mSelected + mPadding, mDimension.width - 2 * mPadding, rowHeight)); - graphics->setColorAll(mForegroundSelectedColor, - mForegroundSelectedColor2); const std::string str = mListModel->getElementAt(mSelected); - font->drawString(graphics, str, mPadding, + font->drawString(graphics, + mForegroundSelectedColor, + mForegroundSelectedColor2, + str, + mPadding, mSelected * rowHeight + mPadding + mItemPadding); } // Draw the list elements - graphics->setColorAll(mForegroundColor, mForegroundColor2); const int sz = mListModel->getNumberOfElements(); for (int i = 0, y = mPadding + mItemPadding; i < sz; ++i, y += rowHeight) @@ -220,7 +224,11 @@ void ListBox::draw(Graphics *graphics) if (i != mSelected) { const std::string str = mListModel->getElementAt(i); - font->drawString(graphics, str, mPadding, y); + font->drawString(graphics, + mForegroundColor, + mForegroundColor2, + str, + mPadding, y); } } } -- cgit v1.2.3-70-g09d2