diff options
author | Andrei Karas <akaras@inbox.ru> | 2012-11-21 21:13:31 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2012-12-01 22:58:18 +0300 |
commit | 04916c1b451e4400a496ae210b3faa10154c65ac (patch) | |
tree | fe7414434dcb6bcc1405b0d608d82348bc3ca466 /src/gui/widgets | |
parent | d48e360ea40536e9f3e7fb4ce381b7fdc2ee5954 (diff) | |
download | plus-04916c1b451e4400a496ae210b3faa10154c65ac.tar.gz plus-04916c1b451e4400a496ae210b3faa10154c65ac.tar.bz2 plus-04916c1b451e4400a496ae210b3faa10154c65ac.tar.xz plus-04916c1b451e4400a496ae210b3faa10154c65ac.zip |
Add batch drawing for any images.
Add this drawing to Button.
Diffstat (limited to 'src/gui/widgets')
-rw-r--r-- | src/gui/widgets/button.cpp | 65 | ||||
-rw-r--r-- | src/gui/widgets/button.h | 4 | ||||
-rw-r--r-- | src/gui/widgets/widget2.h | 1 |
3 files changed, 44 insertions, 26 deletions
diff --git a/src/gui/widgets/button.cpp b/src/gui/widgets/button.cpp index 5a12893a6..5de5f01b5 100644 --- a/src/gui/widgets/button.cpp +++ b/src/gui/widgets/button.cpp @@ -65,7 +65,7 @@ Button::Button(const Widget2 *const widget) : gcn::WidgetListener(), mDescription(""), mClickCount(0), mTag(0), - mVertexes(new GraphicsVertexes()), + mVertexes2(new ImageCollection()), mRedraw(true), mMode(0), mXOffset(0), @@ -90,7 +90,7 @@ Button::Button(const Widget2 *const widget, mDescription(""), mClickCount(0), mTag(0), - mVertexes(new GraphicsVertexes()), + mVertexes2(new ImageCollection()), mRedraw(true), mMode(0), mXOffset(0), @@ -121,7 +121,7 @@ Button::Button(const Widget2 *const widget, mDescription(""), mClickCount(0), mTag(0), - mVertexes(new GraphicsVertexes()), + mVertexes2(new ImageCollection()), mRedraw(true), mMode(0), mXOffset(0), @@ -152,7 +152,7 @@ Button::Button(const Widget2 *const widget, const std::string &imageName, mDescription(""), mClickCount(0), mTag(0), - mVertexes(new GraphicsVertexes()), + mVertexes2(new ImageCollection()), mRedraw(true), mMode(0), mXOffset(0), @@ -210,8 +210,8 @@ Button::~Button() for (int mode = 0; mode < BUTTON_COUNT; mode ++) theme->unload(button[mode]); } - delete mVertexes; - mVertexes = nullptr; + delete mVertexes2; + mVertexes2 = nullptr; if (mImageSet) { mImageSet->decRef(); @@ -326,18 +326,6 @@ void Button::draw(gcn::Graphics *graphics) } } - if (recalc) - { - mRedraw = false; - mMode = mode; - g2->calcWindow(mVertexes, 0, 0, getWidth(), getHeight(), - skin->getBorder()); - } - - g2->drawImageRect2(mVertexes, skin->getBorder()); - -// g2->drawImageRect(0, 0, getWidth(), getHeight(), button[mode]); - const int padding = skin->getPadding(); const int spacing = skin->getOption("spacing"); @@ -401,18 +389,47 @@ void Button::draw(gcn::Graphics *graphics) graphics->setFont(getFont()); - if (isPressed()) + if (openGLMode != 2) { - if (mImages) - g2->drawImage(mImages[mode], imageX + 1, imageY + 1); - g2->drawText(getCaption(), textX + 1, textY + 1, getAlignment()); + if (recalc) + { + mRedraw = false; + mMode = mode; + mVertexes2->clear(); + g2->calcWindow(mVertexes2, 0, 0, getWidth(), getHeight(), + skin->getBorder()); + + if (mImages) + { + if (isPressed()) + { + g2->calcTile(mVertexes2, mImages[mode], + imageX + 1, imageY + 1); + } + else + { + g2->calcTile(mVertexes2, mImages[mode], imageX, imageY); + } + } + } + g2->drawTile(mVertexes2); } else { + g2->drawImageRect(0, 0, getWidth(), getHeight(), skin->getBorder()); if (mImages) - g2->drawImage(mImages[mode], imageX, imageY); - g2->drawText(getCaption(), textX, textY, getAlignment()); + { + if (isPressed()) + g2->drawImage(mImages[mode], imageX + 1, imageY + 1); + else + g2->drawImage(mImages[mode], imageX, imageY); + } } + + if (isPressed()) + g2->drawText(getCaption(), textX + 1, textY + 1, getAlignment()); + else + g2->drawText(getCaption(), textX, textY, getAlignment()); BLOCK_END("Button::draw") } diff --git a/src/gui/widgets/button.h b/src/gui/widgets/button.h index 25fa0da02..3e84eeafe 100644 --- a/src/gui/widgets/button.h +++ b/src/gui/widgets/button.h @@ -31,8 +31,8 @@ #include "localconsts.h" -class GraphicsVertexes; class Image; +class ImageCollection; class ImageSet; class ImageRect; class Skin; @@ -147,7 +147,7 @@ class Button final : public gcn::Button, std::string mDescription; unsigned mClickCount; int mTag; - GraphicsVertexes *mVertexes; + ImageCollection *mVertexes2; bool mRedraw; int mMode; int mXOffset; diff --git a/src/gui/widgets/widget2.h b/src/gui/widgets/widget2.h index 3b4060899..f2eb9bbb1 100644 --- a/src/gui/widgets/widget2.h +++ b/src/gui/widgets/widget2.h @@ -84,4 +84,5 @@ class Widget2 int mPaletteOffset; }; +extern int openGLMode; #endif |