summaryrefslogtreecommitdiff
path: root/src/gui
diff options
context:
space:
mode:
Diffstat (limited to 'src/gui')
-rw-r--r--src/gui/widgets/button.cpp64
-rw-r--r--src/gui/widgets/button.h13
-rw-r--r--src/gui/widgets/popup.cpp39
-rw-r--r--src/gui/widgets/popup.h11
-rw-r--r--src/gui/widgets/progressbar.cpp68
-rw-r--r--src/gui/widgets/progressbar.h19
-rw-r--r--src/gui/widgets/scrollarea.cpp56
-rw-r--r--src/gui/widgets/scrollarea.h7
-rw-r--r--src/gui/widgets/tab.cpp34
-rw-r--r--src/gui/widgets/tab.h11
-rw-r--r--src/gui/widgets/window.cpp28
-rw-r--r--src/gui/widgets/window.h5
12 files changed, 334 insertions, 21 deletions
diff --git a/src/gui/widgets/button.cpp b/src/gui/widgets/button.cpp
index 89e270595..a8e8b656d 100644
--- a/src/gui/widgets/button.cpp
+++ b/src/gui/widgets/button.cpp
@@ -25,6 +25,7 @@
#include "client.h"
#include "configuration.h"
#include "graphics.h"
+#include "graphicsvertexes.h"
#include "log.h"
#include "gui/palette.h"
@@ -67,7 +68,12 @@ static ButtonData const data[BUTTON_COUNT] =
ImageRect Button::button[BUTTON_COUNT];
Button::Button():
- mDescription(""), mClickCount(0)
+ mDescription(""), mClickCount(0),
+ mVertexes(new GraphicsVertexes()),
+ mRedraw(true),
+ mMode(0),
+ mXOffset(0),
+ mYOffset(0)
{
init();
}
@@ -75,7 +81,9 @@ Button::Button():
Button::Button(const std::string &caption, const std::string &actionEventId,
gcn::ActionListener *listener):
gcn::Button(caption),
- mDescription(""), mClickCount(0)
+ mDescription(""), mClickCount(0),
+ mVertexes(new GraphicsVertexes()),
+ mRedraw(true)
{
init();
setActionEventId(actionEventId);
@@ -88,6 +96,8 @@ void Button::init()
{
setFrameSize(0);
+ addWidgetListener(this);
+
if (mInstances == 0)
{
// Load the skin
@@ -175,8 +185,44 @@ void Button::draw(gcn::Graphics *graphics)
updateAlpha();
- static_cast<Graphics*>(graphics)->
- drawImageRect(0, 0, getWidth(), getHeight(), button[mode]);
+
+ bool recalc = false;
+ if (mRedraw)
+ {
+ recalc = true;
+ }
+ else
+ {
+ // because we dont know where parent windows was moved,
+ // need recalc vertexes
+ gcn::ClipRectangle &rect = static_cast<Graphics*>(
+ graphics)->getTopClip();
+ if (rect.xOffset != mXOffset || rect.yOffset != mYOffset)
+ {
+ recalc = true;
+ mXOffset = rect.xOffset;
+ mYOffset = rect.yOffset;
+ }
+ else if (mMode != mode)
+ {
+ recalc = true;
+ mMode = mode;
+ }
+ }
+
+ if (recalc)
+ {
+ mRedraw = false;
+ mMode = mode;
+ static_cast<Graphics*>(graphics)->calcWindow(mVertexes, 0, 0,
+ getWidth(), getHeight(), button[mode]);
+ }
+
+ static_cast<Graphics*>(graphics)->drawImageRect2(
+ mVertexes, button[mode]);
+
+// static_cast<Graphics*>(graphics)->
+// drawImageRect(0, 0, getWidth(), getHeight(), button[mode]);
if (mode == BUTTON_DISABLED)
graphics->setColor(Theme::getThemeColor(Theme::BUTTON_DISABLED));
@@ -226,3 +272,13 @@ void Button::mouseReleased(gcn::MouseEvent& mouseEvent)
mouseEvent.consume();
}
}
+
+void Button::widgetResized(const gcn::Event &event _UNUSED_)
+{
+ mRedraw = true;
+}
+
+void Button::widgetMoved(const gcn::Event &event _UNUSED_)
+{
+ mRedraw = true;
+}
diff --git a/src/gui/widgets/button.h b/src/gui/widgets/button.h
index e7446cd26..8c43b6ddd 100644
--- a/src/gui/widgets/button.h
+++ b/src/gui/widgets/button.h
@@ -25,7 +25,9 @@
#include <guichan/widgets/button.hpp>
#include <guichan/mouseevent.hpp>
+#include <guichan/widgetlistener.hpp>
+class GraphicsVertexes;
class ImageRect;
/**
@@ -33,7 +35,7 @@ class ImageRect;
*
* \ingroup GUI
*/
-class Button : public gcn::Button
+class Button : public gcn::Button, public gcn::WidgetListener
{
public:
/**
@@ -80,6 +82,10 @@ class Button : public gcn::Button
int getTag()
{ return mTag; }
+ void widgetResized(const gcn::Event &event);
+
+ void widgetMoved(const gcn::Event &event);
+
private:
void init();
@@ -90,6 +96,11 @@ class Button : public gcn::Button
std::string mDescription;
unsigned mClickCount;
int mTag;
+ GraphicsVertexes *mVertexes;
+ bool mRedraw;
+ int mMode;
+ int mXOffset;
+ int mYOffset;
};
#endif
diff --git a/src/gui/widgets/popup.cpp b/src/gui/widgets/popup.cpp
index 3d9c3b449..7519d1583 100644
--- a/src/gui/widgets/popup.cpp
+++ b/src/gui/widgets/popup.cpp
@@ -25,12 +25,14 @@
#include "configuration.h"
#include "graphics.h"
+#include "graphicsvertexes.h"
#include "log.h"
#include "gui/theme.h"
#include "gui/viewport.h"
#include "gui/widgets/windowcontainer.h"
+#include "gui/widgets/window.h"
#include "resources/image.h"
@@ -41,13 +43,17 @@ Popup::Popup(const std::string &name, const std::string &skin):
mMinWidth(100),
mMinHeight(40),
mMaxWidth(graphics->getWidth()),
- mMaxHeight(graphics->getHeight())
+ mMaxHeight(graphics->getHeight()),
+ mVertexes(new GraphicsVertexes()),
+ mRedraw(true)
{
logger->log("Popup::Popup(\"%s\")", name.c_str());
if (!windowContainer)
throw GCN_EXCEPTION("Popup::Popup(): no windowContainer set");
+ addWidgetListener(this);
+
setPadding(3);
// Loads the skin
@@ -64,6 +70,9 @@ Popup::~Popup()
{
logger->log("Popup::~Popup(\"%s\")", mPopupName.c_str());
+ delete mVertexes;
+ mVertexes = 0;
+
if (mSkin)
mSkin->instances--;
}
@@ -77,7 +86,16 @@ void Popup::draw(gcn::Graphics *graphics)
{
Graphics *g = static_cast<Graphics*>(graphics);
- g->drawImageRect(0, 0, getWidth(), getHeight(), mSkin->getBorder());
+ if (mRedraw)
+ {
+ mRedraw = false;
+ g->calcWindow(mVertexes, 0, 0, getWidth(),
+ getHeight(), mSkin->getBorder());
+ }
+
+ g->drawImageRect2(mVertexes, mSkin->getBorder());
+
+// g->drawImageRect(0, 0, getWidth(), getHeight(), mSkin->getBorder());
drawChildren(graphics);
}
@@ -103,6 +121,7 @@ void Popup::setContentSize(int width, int height)
height = getMaxHeight();
setSize(width, height);
+ mRedraw = true;
}
void Popup::setLocationRelativeTo(gcn::Widget *widget)
@@ -118,6 +137,7 @@ void Popup::setLocationRelativeTo(gcn::Widget *widget)
setPosition(getX() + (wx + (widget->getWidth() - getWidth()) / 2 - x),
getY() + (wy + (widget->getHeight() - getHeight()) / 2 - y));
+ mRedraw = true;
}
void Popup::setMinWidth(int width)
@@ -161,15 +181,28 @@ void Popup::position(int x, int y)
setPosition(posX, posY);
setVisible(true);
requestMoveToTop();
+ mRedraw = true;
}
void Popup::mouseMoved(gcn::MouseEvent &event _UNUSED_)
{
if (viewport)
viewport->hideBeingPopup();
+ mRedraw = true;
}
void Popup::hide()
{
setVisible(false);
-} \ No newline at end of file
+ mRedraw = true;
+}
+
+void Popup::widgetResized(const gcn::Event &event _UNUSED_)
+{
+ mRedraw = true;
+}
+
+void Popup::widgetMoved(const gcn::Event &event _UNUSED_)
+{
+ mRedraw = true;
+}
diff --git a/src/gui/widgets/popup.h b/src/gui/widgets/popup.h
index 302e55656..963477fbb 100644
--- a/src/gui/widgets/popup.h
+++ b/src/gui/widgets/popup.h
@@ -30,6 +30,7 @@
#include "gui/widgets/container.h"
#include <guichan/mouselistener.hpp>
+#include <guichan/widgetlistener.hpp>
#ifdef __GNUC__
#define _UNUSED_ __attribute__ ((unused))
@@ -37,6 +38,7 @@
#define _UNUSED_
#endif
+class GraphicsVertexes;
class Skin;
class WindowContainer;
@@ -52,7 +54,8 @@ class WindowContainer;
*
* \ingroup GUI
*/
-class Popup : public Container, public gcn::MouseListener
+class Popup : public Container, public gcn::MouseListener,
+ public gcn::WidgetListener
{
public:
/**
@@ -161,6 +164,10 @@ class Popup : public Container, public gcn::MouseListener
void hide();
+ void widgetResized(const gcn::Event &event);
+
+ void widgetMoved(const gcn::Event &event);
+
private:
std::string mPopupName; /**< Name of the popup */
int mMinWidth; /**< Minimum popup width */
@@ -170,6 +177,8 @@ class Popup : public Container, public gcn::MouseListener
int mPadding; /**< Holds the padding of the popup. */
Skin *mSkin; /**< Skin in use by this popup */
+ GraphicsVertexes *mVertexes;
+ bool mRedraw;
};
#endif
diff --git a/src/gui/widgets/progressbar.cpp b/src/gui/widgets/progressbar.cpp
index c612ed36a..0916d9976 100644
--- a/src/gui/widgets/progressbar.cpp
+++ b/src/gui/widgets/progressbar.cpp
@@ -25,6 +25,7 @@
#include "client.h"
#include "configuration.h"
#include "graphics.h"
+#include "graphicsvertexes.h"
#include "textrenderer.h"
#include "gui/gui.h"
@@ -47,7 +48,9 @@ ProgressBar::ProgressBar(float progress,
gcn::Widget(),
mSmoothProgress(true),
mProgressPalette(color),
- mSmoothColorChange(true)
+ mSmoothColorChange(true),
+ mVertexes(new GraphicsVertexes()),
+ mRedraw(true)
{
// The progress value is directly set at load time:
if (progress > 1.0f || progress < 0.0f)
@@ -59,6 +62,8 @@ ProgressBar::ProgressBar(float progress,
mColor = Theme::getProgressColor(color >= 0 ? color : 0, mProgress);
mColorToGo = mColor;
+ addWidgetListener(this);
+
setSize(width, height);
if (mInstances == 0)
@@ -98,6 +103,8 @@ ProgressBar::~ProgressBar()
if (mInstances == 0)
for_each(mBorder.grid, mBorder.grid + 9, dtor<Image*>());
+ delete mVertexes;
+ mVertexes = 0;
}
void ProgressBar::logic()
@@ -157,7 +164,7 @@ void ProgressBar::draw(gcn::Graphics *graphics)
rect.y = 0;
render(static_cast<Graphics*>(graphics), rect, mColor,
- mProgress, mText);
+ mProgress, mText, mVertexes, &mRedraw);
}
void ProgressBar::setProgress(float progress)
@@ -191,6 +198,53 @@ void ProgressBar::setColor(const gcn::Color &color)
void ProgressBar::render(Graphics *graphics, const gcn::Rectangle &area,
const gcn::Color &color, float progress,
+ const std::string &text, GraphicsVertexes *vert,
+ bool *redraw)
+{
+ gcn::Font *oldFont = graphics->getFont();
+ gcn::Color oldColor = graphics->getColor();
+
+ if (*redraw)
+ {
+ *redraw = false;
+ static_cast<Graphics*>(graphics)->calcWindow(vert,
+ area.x, area.y, area.width, area.height, mBorder);
+ }
+
+ static_cast<Graphics*>(graphics)->drawImageRect2(vert, mBorder);
+
+// graphics->drawImageRect(area.x, area.y, area.width, area.height, mBorder);
+// graphics->drawImageRect(area, mBorder);
+
+ // The bar
+ if (progress > 0)
+ {
+ graphics->setColor(color);
+ graphics->fillRectangle(gcn::Rectangle(static_cast<int>(area.x + 4),
+ static_cast<int>(area.y + 4),
+ static_cast<int>(static_cast<float>(progress)
+ * static_cast<float>(area.width - 8)),
+ static_cast<int>(area.height - 8)));
+ }
+
+ // The label
+ if (!text.empty())
+ {
+ const int textX = area.x + area.width / 2;
+ const int textY = area.y + (area.height - boldFont->getHeight()) / 2;
+
+ TextRenderer::renderText(graphics, text, textX, textY,
+ gcn::Graphics::CENTER,
+ Theme::getThemeColor(Theme::PROGRESS_BAR),
+ gui->getFont(), true, false);
+ }
+
+ graphics->setFont(oldFont);
+ graphics->setColor(oldColor);
+}
+
+void ProgressBar::render(Graphics *graphics, const gcn::Rectangle &area,
+ const gcn::Color &color, float progress,
const std::string &text)
{
gcn::Font *oldFont = graphics->getFont();
@@ -224,3 +278,13 @@ void ProgressBar::render(Graphics *graphics, const gcn::Rectangle &area,
graphics->setFont(oldFont);
graphics->setColor(oldColor);
}
+
+void ProgressBar::widgetResized(const gcn::Event &event _UNUSED_)
+{
+ mRedraw = true;
+}
+
+void ProgressBar::widgetMoved(const gcn::Event &event _UNUSED_)
+{
+ mRedraw = true;
+}
diff --git a/src/gui/widgets/progressbar.h b/src/gui/widgets/progressbar.h
index ba10f3027..52a26ddac 100644
--- a/src/gui/widgets/progressbar.h
+++ b/src/gui/widgets/progressbar.h
@@ -27,7 +27,10 @@
#include <string>
+#include <guichan/widgetlistener.hpp>
+
class Graphics;
+class GraphicsVertexes;
class ImageRect;
/**
@@ -35,7 +38,7 @@ class ImageRect;
*
* \ingroup GUI
*/
-class ProgressBar : public gcn::Widget
+class ProgressBar : public gcn::Widget, public gcn::WidgetListener
{
public:
/**
@@ -117,8 +120,20 @@ class ProgressBar : public gcn::Widget
*/
static void render(Graphics *graphics, const gcn::Rectangle &area,
const gcn::Color &color, float progress,
+ const std::string &text,
+ GraphicsVertexes *vert, bool *redraw);
+
+ /**
+ * Renders a progressbar with the given properties.
+ */
+ static void render(Graphics *graphics, const gcn::Rectangle &area,
+ const gcn::Color &color, float progress,
const std::string &text = "");
+ void widgetResized(const gcn::Event &event);
+
+ void widgetMoved(const gcn::Event &event);
+
private:
float mProgress, mProgressToGo;
bool mSmoothProgress;
@@ -129,6 +144,8 @@ class ProgressBar : public gcn::Widget
bool mSmoothColorChange;
std::string mText;
+ GraphicsVertexes *mVertexes;
+ bool mRedraw;
static ImageRect mBorder;
static int mInstances;
diff --git a/src/gui/widgets/scrollarea.cpp b/src/gui/widgets/scrollarea.cpp
index b11213239..2cc745ccd 100644
--- a/src/gui/widgets/scrollarea.cpp
+++ b/src/gui/widgets/scrollarea.cpp
@@ -25,6 +25,7 @@
#include "client.h"
#include "configuration.h"
#include "graphics.h"
+#include "graphicsvertexes.h"
#include "log.h"
#include "gui/theme.h"
@@ -45,7 +46,11 @@ ScrollArea::ScrollArea():
mX(0),
mY(0),
mHasMouse(false),
- mOpaque(true)
+ mOpaque(true),
+ mVertexes(new GraphicsVertexes()),
+ mRedraw(true),
+ mXOffset(0),
+ mYOffset(0)
{
addWidgetListener(this);
init();
@@ -56,8 +61,13 @@ ScrollArea::ScrollArea(gcn::Widget *widget):
mX(0),
mY(0),
mHasMouse(false),
- mOpaque(true)
+ mOpaque(true),
+ mVertexes(new GraphicsVertexes()),
+ mRedraw(true),
+ mXOffset(0),
+ mYOffset(0)
{
+ addWidgetListener(this);
init();
}
@@ -91,6 +101,8 @@ ScrollArea::~ScrollArea()
if (buttons[RIGHT][1])
buttons[RIGHT][1]->decRef();
}
+ delete mVertexes;
+ mVertexes = 0;
}
void ScrollArea::init()
@@ -286,6 +298,7 @@ void ScrollArea::draw(gcn::Graphics *graphics)
drawHMarker(graphics);
}
+
if (mHBarVisible && mVBarVisible)
{
graphics->setColor(getBaseColor());
@@ -300,6 +313,7 @@ void ScrollArea::draw(gcn::Graphics *graphics)
drawChildren(graphics);
}
+//void ScrollArea::drawFrame(gcn::Graphics *graphics _UNUSED_)
void ScrollArea::drawFrame(gcn::Graphics *graphics)
{
if (mOpaque)
@@ -308,8 +322,38 @@ void ScrollArea::drawFrame(gcn::Graphics *graphics)
const int w = getWidth() + bs * 2;
const int h = getHeight() + bs * 2;
+ bool recalc = false;
+ if (mRedraw)
+ {
+ recalc = true;
+ }
+ else
+ {
+ // because we dont know where parent windows was moved,
+ // need recalc vertexes
+ gcn::ClipRectangle &rect = static_cast<Graphics*>(
+ graphics)->getTopClip();
+ if (rect.xOffset != mXOffset || rect.yOffset != mYOffset)
+ {
+ recalc = true;
+ mXOffset = rect.xOffset;
+ mYOffset = rect.yOffset;
+ }
+ }
+
+ if (recalc)
+ {
+ mRedraw = false;
+ static_cast<Graphics*>(graphics)->calcWindow(
+ mVertexes, 0, 0, w, h, background);
+ }
+
+
static_cast<Graphics*>(graphics)->
- drawImageRect(0, 0, w, h, background);
+ drawImageRect2(mVertexes, background);
+
+// static_cast<Graphics*>(graphics)->
+// drawImageRect(0, 0, w, h, background);
}
}
@@ -441,6 +485,12 @@ void ScrollArea::mouseExited(gcn::MouseEvent& event _UNUSED_)
void ScrollArea::widgetResized(const gcn::Event &event _UNUSED_)
{
+ mRedraw = true;
getContent()->setSize(getWidth() - 2 * getFrameSize(),
getHeight() - 2 * getFrameSize());
}
+
+void ScrollArea::widgetMoved(const gcn::Event& event _UNUSED_)
+{
+ mRedraw = true;
+}
diff --git a/src/gui/widgets/scrollarea.h b/src/gui/widgets/scrollarea.h
index 49d5e7f28..e613170fa 100644
--- a/src/gui/widgets/scrollarea.h
+++ b/src/gui/widgets/scrollarea.h
@@ -32,6 +32,7 @@
#define _UNUSED_
#endif
+class GraphicsVertexes;
class Image;
class ImageRect;
@@ -113,6 +114,8 @@ class ScrollArea : public gcn::ScrollArea, public gcn::WidgetListener
void widgetResized(const gcn::Event &event);
+ void widgetMoved(const gcn::Event &event);
+
protected:
enum BUTTON_DIR
{
@@ -147,6 +150,10 @@ class ScrollArea : public gcn::ScrollArea, public gcn::WidgetListener
int mX, mY;
bool mHasMouse;
bool mOpaque;
+ GraphicsVertexes *mVertexes;
+ bool mRedraw;
+ int mXOffset;
+ int mYOffset;
};
#endif
diff --git a/src/gui/widgets/tab.cpp b/src/gui/widgets/tab.cpp
index 6a2b05cd4..78165dc18 100644
--- a/src/gui/widgets/tab.cpp
+++ b/src/gui/widgets/tab.cpp
@@ -25,6 +25,7 @@
#include "client.h"
#include "configuration.h"
#include "graphics.h"
+#include "graphicsvertexes.h"
#include "log.h"
#include "gui/palette.h"
@@ -68,7 +69,10 @@ static TabData const data[TAB_COUNT] =
ImageRect Tab::tabImg[TAB_COUNT];
Tab::Tab() : gcn::Tab(),
- mTabColor(&Theme::getThemeColor(Theme::TAB))
+ mTabColor(&Theme::getThemeColor(Theme::TAB)),
+ mVertexes(new GraphicsVertexes()),
+ mRedraw(true),
+ mMode(0)
{
init();
}
@@ -82,6 +86,8 @@ Tab::~Tab()
for (int mode = 0; mode < TAB_COUNT; mode++)
for_each(tabImg[mode].grid, tabImg[mode].grid + 9, dtor<Image*>());
}
+ delete mVertexes;
+ mVertexes = 0;
}
void Tab::init()
@@ -90,6 +96,8 @@ void Tab::init()
setFrameSize(0);
mFlash = 0;
+ addWidgetListener(this);
+
if (mInstances == 0)
{
// Load the skin
@@ -179,8 +187,18 @@ void Tab::draw(gcn::Graphics *graphics)
updateAlpha();
// draw tab
- static_cast<Graphics*>(graphics)->
- drawImageRect(0, 0, getWidth(), getHeight(), tabImg[mode]);
+ if (mRedraw || mode != mMode)
+ {
+ mMode = mode;
+ mRedraw = false;
+ static_cast<Graphics*>(graphics)->calcWindow(mVertexes, 0, 0, getWidth(),
+ getHeight(), tabImg[mode]);
+ }
+
+ static_cast<Graphics*>(graphics)->drawImageRect2(mVertexes, tabImg[mode]);
+
+// static_cast<Graphics*>(graphics)->
+// drawImageRect(0, 0, getWidth(), getHeight(), tabImg[mode]);
// draw label
drawChildren(graphics);
@@ -195,3 +213,13 @@ void Tab::setFlash(int flash)
{
mFlash = flash;
}
+
+void Tab::widgetResized(const gcn::Event &event _UNUSED_)
+{
+ mRedraw = true;
+}
+
+void Tab::widgetMoved(const gcn::Event &event _UNUSED_)
+{
+ mRedraw = true;
+}
diff --git a/src/gui/widgets/tab.h b/src/gui/widgets/tab.h
index 637234c89..f9f1fa4da 100644
--- a/src/gui/widgets/tab.h
+++ b/src/gui/widgets/tab.h
@@ -24,7 +24,9 @@
#define TAB_H
#include <guichan/widgets/tab.hpp>
+#include <guichan/widgetlistener.hpp>
+class GraphicsVertexes;
class ImageRect;
class TabbedArea;
@@ -32,7 +34,7 @@ class TabbedArea;
* A tab, the same as the Guichan tab in 0.8, but extended to allow
* transparency.
*/
-class Tab : public gcn::Tab
+class Tab : public gcn::Tab, public gcn::WidgetListener
{
public:
Tab();
@@ -61,6 +63,10 @@ class Tab : public gcn::Tab
int getFlash()
{ return mFlash; }
+ void widgetResized(const gcn::Event &event);
+
+ void widgetMoved(const gcn::Event &event);
+
protected:
friend class TabbedArea;
virtual void setCurrent()
@@ -76,6 +82,9 @@ class Tab : public gcn::Tab
const gcn::Color *mTabColor;
int mFlash;
+ GraphicsVertexes *mVertexes;
+ bool mRedraw;
+ int mMode;
};
#endif
diff --git a/src/gui/widgets/window.cpp b/src/gui/widgets/window.cpp
index 1037296b6..8c33b4787 100644
--- a/src/gui/widgets/window.cpp
+++ b/src/gui/widgets/window.cpp
@@ -24,6 +24,7 @@
#include "client.h"
#include "configuration.h"
+#include "graphicsvertexes.h"
#include "log.h"
#include "gui/gui.h"
@@ -60,7 +61,9 @@ Window::Window(const std::string &caption, bool modal, Window *parent,
mMinWinWidth(100),
mMinWinHeight(40),
mMaxWinWidth(graphics->getWidth()),
- mMaxWinHeight(graphics->getHeight())
+ mMaxWinHeight(graphics->getHeight()),
+ mVertexes(new GraphicsVertexes()),
+ mRedraw(true)
{
logger->log("Window::Window(\"%s\")", caption.c_str());
@@ -106,6 +109,8 @@ Window::~Window()
// need mWidgets.clean ?
removeWidgetListener(this);
+ delete mVertexes;
+ mVertexes = 0;
instances--;
@@ -125,7 +130,19 @@ void Window::draw(gcn::Graphics *graphics)
Graphics *g = static_cast<Graphics*>(graphics);
- g->drawImageRect(0, 0, getWidth(), getHeight(), mSkin->getBorder());
+ if (mRedraw)
+ {
+ mRedraw = false;
+ g->calcWindow(mVertexes, 0, 0, getWidth(),
+ getHeight(), mSkin->getBorder());
+ }
+
+ g->drawImageRect2(mVertexes, mSkin->getBorder());
+
+/*
+ g->drawImageRect(0, 0, getWidth(),
+ getHeight(), mSkin->getBorder());
+*/
// Draw title
if (mShowTitle)
@@ -303,12 +320,19 @@ void Window::widgetResized(const gcn::Event &event _UNUSED_)
getHeight() - mGrip->getHeight() - area.y);
}
+
if (mLayout)
{
int w = area.width;
int h = area.height;
mLayout->reflow(w, h);
}
+ mRedraw = true;
+}
+
+void Window::widgetMoved(const gcn::Event& event _UNUSED_)
+{
+ mRedraw = true;
}
void Window::widgetHidden(const gcn::Event &event _UNUSED_)
diff --git a/src/gui/widgets/window.h b/src/gui/widgets/window.h
index 4125f1986..6f856fc62 100644
--- a/src/gui/widgets/window.h
+++ b/src/gui/widgets/window.h
@@ -37,6 +37,7 @@
#endif
class ContainerPlacer;
+class GraphicsVertexes;
class Layout;
class LayoutCell;
class ResizeGrip;
@@ -114,6 +115,8 @@ class Window : public gcn::Window, gcn::WidgetListener
*/
void widgetResized(const gcn::Event &event);
+ virtual void widgetMoved(const gcn::Event& event);
+
/**
* Called whenever the widget is hidden.
*/
@@ -437,6 +440,8 @@ class Window : public gcn::Window, gcn::WidgetListener
* where two borders are moved at the same time.
*/
static const int resizeBorderWidth = 10;
+ GraphicsVertexes *mVertexes;
+ bool mRedraw;
};
#endif