Browse Source

Final fix for local widget/window drawing coordinates

gh-pages
falkTX 9 years ago
parent
commit
ed6fdffbb0
3 changed files with 30 additions and 15 deletions
  1. +1
    -0
      dgl/ImageAboutWindow.hpp
  2. +6
    -0
      dgl/src/ImageAboutWindow.cpp
  3. +23
    -15
      dgl/src/Window.cpp

+ 1
- 0
dgl/ImageAboutWindow.hpp View File

@@ -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;


+ 6
- 0
dgl/src/ImageAboutWindow.cpp View File

@@ -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

+ 23
- 15
dgl/src/Window.cpp View File

@@ -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();
}
}
}



Loading…
Cancel
Save