Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tweak behaviour of NanoWidget as subwidget of another NanoWidget #75

Closed

Conversation

pdesaulniers
Copy link
Contributor

@pdesaulniers pdesaulniers commented Sep 29, 2018

This would fix the weird behavior I've described in #68.

I really don't know if this is a proper fix, but it works with Wolf Shaper and the rectangles example I've shown in the issue.

It makes the subwidgets pass through this OpenGL code, which sets the correct viewport:

else if (needsScaling)
{
// limit viewport to widget bounds
glViewport(absolutePos.getX(),
static_cast<int>(height - self->getHeight()) - absolutePos.getY(),
static_cast<GLsizei>(self->getWidth()),
static_cast<GLsizei>(self->getHeight()));
}

So, calling rect(0, 0, getWidth(), getHeight()); should draw a rectangle equal to the widget's viewport.

Also, in onNanoDisplay(), you can freely use NanoVG's translate(), reset(), etc. It doesn't seem to affect the OpenGL viewport.

@falkTX
Copy link
Contributor

falkTX commented Sep 29, 2018

I rather not do this until I am 100% sure it is the right thing.
Sorry it is taking long.

@pdesaulniers
Copy link
Contributor Author

No worries, take your time. I'm not sure this is OK either.

@pdesaulniers
Copy link
Contributor Author

pdesaulniers commented Dec 9, 2018

I don't understand why skipDisplay is needed. Why not draw all widgets directly, without special treatment for subwidgets?

In pseudocode:

for each widget in window:
    if widget is visible:
        setup the glViewport
        call widget->onDisplay()

onDisplay would just draw the widget itself, not the subwidgets.

@pdesaulniers
Copy link
Contributor Author

The pugl-upstream-v2 branch appears to fix my original issue. Closing this PR, as the code is probably not relevant anymore.

@pdesaulniers pdesaulniers deleted the tweak_nanovg_subwidgets branch May 16, 2021 12:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants