commit ed6fdffbb0f6a86e2dfc60a4ac9616de89cd53ac
parent e0a6cf3f22550e2c7d40a97b60a688771de93ce8
Author: falkTX <falktx@gmail.com>
Date: Sun, 25 May 2014 03:39:07 +0100
Final fix for local widget/window drawing coordinates
Diffstat:
3 files changed, 30 insertions(+), 15 deletions(-)
diff --git a/dgl/ImageAboutWindow.hpp b/dgl/ImageAboutWindow.hpp
@@ -38,6 +38,7 @@ protected:
void onDisplay() override;
bool onKeyboard(const KeyboardEvent&) override;
bool onMouse(const MouseEvent&) override;
+ void onReshape(int width, int height) override;
private:
Image fImgBackground;
diff --git a/dgl/src/ImageAboutWindow.cpp b/dgl/src/ImageAboutWindow.cpp
@@ -76,6 +76,12 @@ bool ImageAboutWindow::onMouse(const MouseEvent& ev)
return false;
}
+void ImageAboutWindow::onReshape(int width, int height)
+{
+ Widget::setSize(width, height);
+ Window::onReshape(width, height);
+}
+
// -----------------------------------------------------------------------
END_NAMESPACE_DGL
diff --git a/dgl/src/Window.cpp b/dgl/src/Window.cpp
@@ -575,24 +575,32 @@ struct Window::PrivateData {
if (widget->isVisible())
{
- const int ypos = widget->fInvertedY ? fView->height - widget->getHeight() - widget->getAbsoluteY() : widget->getAbsoluteY();
- //const int ypos = fView->height - widget->getHeight() - widget->getAbsoluteY();
-
// reset color
glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
- // limit viewport to widget bounds
- glViewport(widget->getAbsoluteX(), ypos, widget->getWidth(), widget->getHeight());
-
- // need scale contents to match viewport
- glPushMatrix();
- glScalef(float(fView->width)/float(widget->getWidth()), float(fView->height)/float(widget->getHeight()), 1.0f);
-
- // display widget
- widget->onDisplay();
-
- // pop
- glPopMatrix();
+ if (widget->fArea == Rectangle<int>(0, 0, fView->width, fView->height))
+ {
+ // full viewport size
+ glViewport(0, 0, fView->width, fView->height);
+
+ // display widget
+ widget->onDisplay();
+ }
+ else
+ {
+ // limit viewport to widget bounds
+ glViewport(widget->getAbsoluteX(), fView->height - widget->getHeight() - widget->getAbsoluteY(), widget->getWidth(), widget->getHeight());
+
+ // scale contents to match viewport size
+ glPushMatrix();
+ glScalef(float(fView->width)/float(widget->getWidth()), float(fView->height)/float(widget->getHeight()), 1.0f);
+
+ // display widget
+ widget->onDisplay();
+
+ // done
+ glPopMatrix();
+ }
}
}