summaryrefslogtreecommitdiff
path: root/src/gui/widgets
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2012-12-27 01:22:21 +0300
committerAndrei Karas <akaras@inbox.ru>2012-12-27 23:15:05 +0300
commit2babe1d6491f5231b0e97349ccb198b92bb90ba9 (patch)
tree3db30d7bff509ec233ba91ee14f55ea95ebb159c /src/gui/widgets
parent81d317cf80f4c333396c708bbefca16be2362c8c (diff)
downloadmanaplus-2babe1d6491f5231b0e97349ccb198b92bb90ba9.tar.gz
manaplus-2babe1d6491f5231b0e97349ccb198b92bb90ba9.tar.bz2
manaplus-2babe1d6491f5231b0e97349ccb198b92bb90ba9.tar.xz
manaplus-2babe1d6491f5231b0e97349ccb198b92bb90ba9.zip
Improve draw speed in listboxes.
Diffstat (limited to 'src/gui/widgets')
-rw-r--r--src/gui/widgets/avatarlistbox.cpp10
-rw-r--r--src/gui/widgets/extendedlistbox.cpp11
-rw-r--r--src/gui/widgets/listbox.cpp7
-rw-r--r--src/gui/widgets/shoplistbox.cpp7
4 files changed, 17 insertions, 18 deletions
diff --git a/src/gui/widgets/avatarlistbox.cpp b/src/gui/widgets/avatarlistbox.cpp
index 5a5027982..d9fe65dfe 100644
--- a/src/gui/widgets/avatarlistbox.cpp
+++ b/src/gui/widgets/avatarlistbox.cpp
@@ -105,13 +105,11 @@ void AvatarListBox::draw(gcn::Graphics *gcnGraphics)
Graphics *const graphics = static_cast<Graphics *const>(gcnGraphics);
mHighlightColor.a = static_cast<int>(mAlpha * 255.0f);
-// graphics->setColor(mHighlightColor);
- graphics->setFont(getFont());
+ gcn::Font *const font = getFont();
+ graphics->setFont(font);
const int fontHeight = getFont()->getHeight();
-
const gcn::Widget *const parent = mParent;
-
const std::string name = player_node->getName();
// Draw the list elements
@@ -271,9 +269,9 @@ void AvatarListBox::draw(gcn::Graphics *gcnGraphics)
// Draw Name
if (a->getType() == MapItem::SEPARATOR)
- graphics->drawText(text, mPadding, y + mPadding);
+ font->drawString(graphics, text, mPadding, y + mPadding);
else
- graphics->drawText(text, 15 + mPadding, y + mPadding);
+ font->drawString(graphics, text, 15 + mPadding, y + mPadding);
if (a->getDisplayBold())
graphics->setFont(getFont());
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 *const>(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);
}
diff --git a/src/gui/widgets/listbox.cpp b/src/gui/widgets/listbox.cpp
index 87ecc9460..dbd54f3f3 100644
--- a/src/gui/widgets/listbox.cpp
+++ b/src/gui/widgets/listbox.cpp
@@ -92,7 +92,8 @@ void ListBox::draw(gcn::Graphics *graphics)
mHighlightColor.a = static_cast<int>(mAlpha * 255.0f);
graphics->setColor(mHighlightColor);
- graphics->setFont(getFont());
+ gcn::Font *const font = getFont();
+ graphics->setFont(font);
const int height = getRowHeight();
@@ -107,7 +108,7 @@ void ListBox::draw(gcn::Graphics *graphics)
if (sel >= 0)
{
graphics->setColor(mForegroundSelectedColor);
- graphics->drawText(mListModel->getElementAt(sel),
+ font->drawString(graphics, mListModel->getElementAt(sel),
mPadding, sel * height + mPadding);
}
// Draw the list elements
@@ -117,7 +118,7 @@ void ListBox::draw(gcn::Graphics *graphics)
{
if (i != sel)
{
- graphics->drawText(mListModel->getElementAt(i),
+ font->drawString(graphics, mListModel->getElementAt(i),
mPadding, y + mPadding);
}
}
diff --git a/src/gui/widgets/shoplistbox.cpp b/src/gui/widgets/shoplistbox.cpp
index 1dd58532e..11f350165 100644
--- a/src/gui/widgets/shoplistbox.cpp
+++ b/src/gui/widgets/shoplistbox.cpp
@@ -95,10 +95,9 @@ void ShopListBox::draw(gcn::Graphics *gcnGraphics)
mAlpha = Client::getGuiAlpha();
const int alpha = static_cast<int>(mAlpha * 255.0f);
-
Graphics *graphics = static_cast<Graphics*>(gcnGraphics);
-
- graphics->setFont(getFont());
+ gcn::Font *const font = getFont();
+ graphics->setFont(font);
// Draw the list elements
for (int i = 0, y = 0;
@@ -159,7 +158,7 @@ void ShopListBox::draw(gcn::Graphics *gcnGraphics)
graphics->setColor(mForegroundSelectedColor);
else
graphics->setColor(mForegroundColor);
- graphics->drawText(mListModel->getElementAt(i),
+ font->drawString(graphics, mListModel->getElementAt(i),
ITEM_ICON_SIZE + mPadding,
y + (ITEM_ICON_SIZE - getFont()->getHeight()) / 2 + mPadding);
}