summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2015-05-25 22:07:05 +0300
committerAndrei Karas <akaras@inbox.ru>2015-05-25 22:07:05 +0300
commit2b681b167c1d307f550a8dc7b56a94d13886827e (patch)
tree8ab235ab55893ce4c97a34babd83d71750082de9 /src
parent1f4410ab9ac4064ff0cfb0fd31b4e942bee82277 (diff)
downloadplus-2b681b167c1d307f550a8dc7b56a94d13886827e.tar.gz
plus-2b681b167c1d307f550a8dc7b56a94d13886827e.tar.bz2
plus-2b681b167c1d307f550a8dc7b56a94d13886827e.tar.xz
plus-2b681b167c1d307f550a8dc7b56a94d13886827e.zip
Add method safeDrawFrame for safe OpenGL renderer.
Diffstat (limited to 'src')
-rw-r--r--src/gui/widgets/basiccontainer.cpp2
-rw-r--r--src/gui/widgets/dropdown.cpp11
-rw-r--r--src/gui/widgets/dropdown.h2
-rw-r--r--src/gui/widgets/playerbox.cpp17
-rw-r--r--src/gui/widgets/playerbox.h2
-rw-r--r--src/gui/widgets/scrollarea.cpp38
-rw-r--r--src/gui/widgets/scrollarea.h2
-rw-r--r--src/gui/widgets/textfield.cpp12
-rw-r--r--src/gui/widgets/textfield.h2
-rw-r--r--src/gui/widgets/widget.h3
10 files changed, 75 insertions, 16 deletions
diff --git a/src/gui/widgets/basiccontainer.cpp b/src/gui/widgets/basiccontainer.cpp
index cd1dac0a2..96dfffef7 100644
--- a/src/gui/widgets/basiccontainer.cpp
+++ b/src/gui/widgets/basiccontainer.cpp
@@ -357,7 +357,7 @@ void BasicContainer::safeDrawChildren(Graphics* graphics)
rec.height += frame2;
graphics->pushClipArea(rec);
BLOCK_START("BasicContainer::drawChildren 1")
- widget->drawFrame(graphics);
+ widget->safeDrawFrame(graphics);
BLOCK_END("BasicContainer::drawChildren 1")
graphics->popClipArea();
}
diff --git a/src/gui/widgets/dropdown.cpp b/src/gui/widgets/dropdown.cpp
index ddd409c3a..a16381c2a 100644
--- a/src/gui/widgets/dropdown.cpp
+++ b/src/gui/widgets/dropdown.cpp
@@ -305,6 +305,17 @@ void DropDown::drawFrame(Graphics *graphics)
BLOCK_END("DropDown::drawFrame")
}
+void DropDown::safeDrawFrame(Graphics *graphics)
+{
+ BLOCK_START("DropDown::drawFrame")
+ const int bs2 = getFrameSize();
+ const Rect &rect = mDimension;
+ graphics->drawImageRect(0, 0,
+ rect.width + bs2, rect.height + bs2,
+ skinRect);
+ BLOCK_END("DropDown::drawFrame")
+}
+
void DropDown::drawButton(Graphics *graphics)
{
const int height = mDroppedDown ? mFoldedUpHeight : mDimension.height;
diff --git a/src/gui/widgets/dropdown.h b/src/gui/widgets/dropdown.h
index 5f12cca31..aea2752d0 100644
--- a/src/gui/widgets/dropdown.h
+++ b/src/gui/widgets/dropdown.h
@@ -85,6 +85,8 @@ class DropDown final : public ActionListener,
void drawFrame(Graphics *graphics) override final;
+ void safeDrawFrame(Graphics *graphics) override final;
+
// Inherited from KeyListener
void keyPressed(KeyEvent& event) override final;
diff --git a/src/gui/widgets/playerbox.cpp b/src/gui/widgets/playerbox.cpp
index 09ebe610d..e69d3e35b 100644
--- a/src/gui/widgets/playerbox.cpp
+++ b/src/gui/widgets/playerbox.cpp
@@ -160,6 +160,23 @@ void PlayerBox::drawFrame(Graphics *graphics)
BLOCK_END("PlayerBox::drawFrame")
}
+void PlayerBox::safeDrawFrame(Graphics *graphics)
+{
+ BLOCK_START("PlayerBox::drawFrame")
+ if (mDrawBackground)
+ {
+ const int bs = mFrameSize * 2;
+ const int w = mDimension.width + bs;
+ const int h = mDimension.height + bs;
+
+ if (!mSelected)
+ graphics->drawImageRect(0, 0, w, h, mBackground);
+ else
+ graphics->drawImageRect(0, 0, w, h, mSelectedBackground);
+ }
+ BLOCK_END("PlayerBox::drawFrame")
+}
+
void PlayerBox::mouseReleased(MouseEvent& event)
{
if (event.getButton() == MouseButton::LEFT)
diff --git a/src/gui/widgets/playerbox.h b/src/gui/widgets/playerbox.h
index f428fcbfa..b331b7a1b 100644
--- a/src/gui/widgets/playerbox.h
+++ b/src/gui/widgets/playerbox.h
@@ -85,6 +85,8 @@ class PlayerBox final : public Widget,
*/
void drawFrame(Graphics *graphics) override final;
+ void safeDrawFrame(Graphics *graphics) override final;
+
Being *getBeing() A_WARN_UNUSED
{ return mBeing; }
diff --git a/src/gui/widgets/scrollarea.cpp b/src/gui/widgets/scrollarea.cpp
index 481e4365d..1eb5417e8 100644
--- a/src/gui/widgets/scrollarea.cpp
+++ b/src/gui/widgets/scrollarea.cpp
@@ -436,25 +436,33 @@ void ScrollArea::drawFrame(Graphics *graphics)
updateCalcFlag(graphics);
- if (isBatchDrawRenders(openGLMode))
+ if (mRedraw)
{
- if (mRedraw)
- {
- mVertexes2->clear();
- graphics->calcWindow(mVertexes2,
- 0, 0,
- w, h,
- background);
- graphics->finalize(mVertexes2);
- }
- graphics->drawTileCollection(mVertexes2);
- }
- else
- {
- graphics->drawImageRect(0, 0,
+ mVertexes2->clear();
+ graphics->calcWindow(mVertexes2,
+ 0, 0,
w, h,
background);
+ graphics->finalize(mVertexes2);
}
+ graphics->drawTileCollection(mVertexes2);
+ }
+ BLOCK_END("ScrollArea::drawFrame")
+}
+
+void ScrollArea::safeDrawFrame(Graphics *graphics)
+{
+ BLOCK_START("ScrollArea::drawFrame")
+ if (mOpaque)
+ {
+ const int bs = mFrameSize * 2;
+ const int w = mDimension.width + bs;
+ const int h = mDimension.height + bs;
+
+ updateCalcFlag(graphics);
+ graphics->drawImageRect(0, 0,
+ w, h,
+ background);
}
BLOCK_END("ScrollArea::drawFrame")
}
diff --git a/src/gui/widgets/scrollarea.h b/src/gui/widgets/scrollarea.h
index d0e3bca92..d166f235c 100644
--- a/src/gui/widgets/scrollarea.h
+++ b/src/gui/widgets/scrollarea.h
@@ -146,6 +146,8 @@ class ScrollArea final : public BasicContainer,
*/
void drawFrame(Graphics *graphics) override final;
+ void safeDrawFrame(Graphics *graphics) override final;
+
/**
* Sets whether the widget should draw its background or not.
*/
diff --git a/src/gui/widgets/textfield.cpp b/src/gui/widgets/textfield.cpp
index 49d3fd412..ce1aacd9e 100644
--- a/src/gui/widgets/textfield.cpp
+++ b/src/gui/widgets/textfield.cpp
@@ -223,6 +223,18 @@ void TextField::drawFrame(Graphics *graphics)
BLOCK_END("TextField::drawFrame")
}
+void TextField::safeDrawFrame(Graphics *graphics)
+{
+ BLOCK_START("TextField::drawFrame")
+ const int bs = 2 * mFrameSize;
+ graphics->drawImageRect(0,
+ 0,
+ mDimension.width + bs,
+ mDimension.height + bs,
+ skin);
+ BLOCK_END("TextField::drawFrame")
+}
+
void TextField::setNumeric(const bool numeric)
{
mNumeric = numeric;
diff --git a/src/gui/widgets/textfield.h b/src/gui/widgets/textfield.h
index 2b5f4196f..3a5db3c3c 100644
--- a/src/gui/widgets/textfield.h
+++ b/src/gui/widgets/textfield.h
@@ -117,6 +117,8 @@ class TextField notfinal : public Widget,
*/
void drawFrame(Graphics *graphics) override final;
+ void safeDrawFrame(Graphics *graphics) override final;
+
/**
* Determine whether the field should be numeric or not
*/
diff --git a/src/gui/widgets/widget.h b/src/gui/widgets/widget.h
index 723811e66..7c3134302 100644
--- a/src/gui/widgets/widget.h
+++ b/src/gui/widgets/widget.h
@@ -147,6 +147,9 @@ class Widget notfinal : public Widget2
virtual void drawFrame(Graphics* graphics A_UNUSED)
{ }
+ virtual void safeDrawFrame(Graphics* graphics A_UNUSED)
+ { }
+
/**
* Sets the size of the widget's frame. The frame is not considered a part of
* the widget, it only allows a frame to be drawn around the widget, thus a frame