From 2babe1d6491f5231b0e97349ccb198b92bb90ba9 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Thu, 27 Dec 2012 01:22:21 +0300 Subject: Improve draw speed in listboxes. --- src/gui/widgets/extendedlistbox.cpp | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'src/gui/widgets/extendedlistbox.cpp') diff --git a/src/gui/widgets/extendedlistbox.cpp b/src/gui/widgets/extendedlistbox.cpp index bad1472ac..af1480f86 100644 --- a/src/gui/widgets/extendedlistbox.cpp +++ b/src/gui/widgets/extendedlistbox.cpp @@ -60,7 +60,8 @@ void ExtendedListBox::draw(gcn::Graphics *graphics) Graphics *const g = static_cast(graphics); updateAlpha(); - graphics->setFont(getFont()); + gcn::Font *const font = getFont(); + graphics->setFont(font); const int height = getRowHeight(); int textPos = (height - getFont()->getHeight()) / 2 + mPadding; @@ -87,14 +88,14 @@ void ExtendedListBox::draw(gcn::Graphics *graphics) const Image *const image = model->getImageAt(i); if (!image) { - graphics->drawText(mListModel->getElementAt(i), + font->drawString(graphics, mListModel->getElementAt(i), mPadding, y + textPos); } else { g->drawImage(image, mImagePadding, y + (height - image->getHeight()) / 2 + mPadding); - graphics->drawText(mListModel->getElementAt(i), + font->drawString(graphics, mListModel->getElementAt(i), image->getWidth() + mImagePadding + mSpacing, y + textPos); } } @@ -104,13 +105,13 @@ void ExtendedListBox::draw(gcn::Graphics *graphics) const Image *const image = model->getImageAt(mSelected); if (!image) { - graphics->drawText(mListModel->getElementAt(mSelected), + font->drawString(graphics, mListModel->getElementAt(mSelected), mPadding, mSelected * height + textPos); } else { graphics->setColor(mForegroundSelectedColor); - graphics->drawText(mListModel->getElementAt(mSelected), + font->drawString(graphics, mListModel->getElementAt(mSelected), image->getWidth() + mImagePadding + mSpacing, mSelected * height + textPos); } -- cgit v1.2.3-60-g2f50