summaryrefslogtreecommitdiff
path: root/src/gui/widgets
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2015-05-25 17:12:20 +0300
committerAndrei Karas <akaras@inbox.ru>2015-05-25 17:12:20 +0300
commit2cfbdedad7488301cb72c0ba05a450bdca7f7435 (patch)
treea56257c0a9e696cf9bc1163b51319e44790c7e2c /src/gui/widgets
parentf99569872f391ee0090348bf58d4a2a43c549eda (diff)
downloadplus-2cfbdedad7488301cb72c0ba05a450bdca7f7435.tar.gz
plus-2cfbdedad7488301cb72c0ba05a450bdca7f7435.tar.bz2
plus-2cfbdedad7488301cb72c0ba05a450bdca7f7435.tar.xz
plus-2cfbdedad7488301cb72c0ba05a450bdca7f7435.zip
Add safeDraw method into emotepage.
Diffstat (limited to 'src/gui/widgets')
-rw-r--r--src/gui/widgets/emotepage.cpp77
-rw-r--r--src/gui/widgets/emotepage.h2
2 files changed, 46 insertions, 33 deletions
diff --git a/src/gui/widgets/emotepage.cpp b/src/gui/widgets/emotepage.cpp
index d167f8bd9..7d9506546 100644
--- a/src/gui/widgets/emotepage.cpp
+++ b/src/gui/widgets/emotepage.cpp
@@ -65,47 +65,25 @@ void EmotePage::draw(Graphics *graphics)
{
BLOCK_START("EmotePage::draw")
- if (!mEmotes)
- return;
+ if (mRedraw)
+ {
+ if (!mEmotes)
+ return;
- const std::vector<Image*> &images = mEmotes->getImages();
+ const std::vector<Image*> &images = mEmotes->getImages();
- const unsigned int width = mDimension.width;
- unsigned int x = 0;
- unsigned int y = 0;
+ const unsigned int width = mDimension.width;
+ unsigned int x = 0;
+ unsigned int y = 0;
- if (isBatchDrawRenders(openGLMode))
- {
- if (mRedraw)
- {
- mRedraw = false;
- mVertexes->clear();
- FOR_EACH (std::vector<Image*>::const_iterator, it, images)
- {
- const Image *const image = *it;
- if (image)
- {
- graphics->calcTileCollection(mVertexes, image, x, y);
- x += emoteWidth;
- if (x + emoteWidth > width)
- {
- x = 0;
- y += emoteHeight;
- }
- }
- }
- graphics->finalize(mVertexes);
- }
- graphics->drawTileCollection(mVertexes);
- }
- else
- {
+ mRedraw = false;
+ mVertexes->clear();
FOR_EACH (std::vector<Image*>::const_iterator, it, images)
{
const Image *const image = *it;
if (image)
{
- graphics->drawImage(image, x, y);
+ graphics->calcTileCollection(mVertexes, image, x, y);
x += emoteWidth;
if (x + emoteWidth > width)
{
@@ -114,11 +92,44 @@ void EmotePage::draw(Graphics *graphics)
}
}
}
+ graphics->finalize(mVertexes);
}
+ graphics->drawTileCollection(mVertexes);
BLOCK_END("EmotePage::draw")
}
+void EmotePage::safeDraw(Graphics *graphics)
+{
+ BLOCK_START("EmotePage::safeDraw")
+
+ if (!mEmotes)
+ return;
+
+ const std::vector<Image*> &images = mEmotes->getImages();
+
+ const unsigned int width = mDimension.width;
+ unsigned int x = 0;
+ unsigned int y = 0;
+
+ FOR_EACH (std::vector<Image*>::const_iterator, it, images)
+ {
+ const Image *const image = *it;
+ if (image)
+ {
+ graphics->drawImage(image, x, y);
+ x += emoteWidth;
+ if (x + emoteWidth > width)
+ {
+ x = 0;
+ y += emoteHeight;
+ }
+ }
+ }
+
+ BLOCK_END("EmotePage::safeDraw")
+}
+
void EmotePage::mousePressed(MouseEvent &event)
{
mSelectedIndex = getIndexFromGrid(event.getX(), event.getY());
diff --git a/src/gui/widgets/emotepage.h b/src/gui/widgets/emotepage.h
index a10526532..24d166750 100644
--- a/src/gui/widgets/emotepage.h
+++ b/src/gui/widgets/emotepage.h
@@ -41,6 +41,8 @@ class EmotePage final : public Widget,
void draw(Graphics *graphics) override final;
+ void safeDraw(Graphics *graphics) override final;
+
void mousePressed(MouseEvent &event) override final;
int getIndexFromGrid(const int x, const int y) const;