@@ -279,7 +279,6 @@ public: | |||||
return fContext; | return fContext; | ||||
} | } | ||||
protected: | |||||
/** | /** | ||||
Begin drawing a new frame. | Begin drawing a new frame. | ||||
@param withAlha Controls if drawing the shapes to the render target should be done using straight or pre-multiplied alpha. | @param withAlha Controls if drawing the shapes to the render target should be done using straight or pre-multiplied alpha. | ||||
@@ -695,6 +694,13 @@ protected: | |||||
*/ | */ | ||||
void textAlign(Align align); | void textAlign(Align align); | ||||
/** | |||||
Sets the text align of current text style. | |||||
Overloaded function for convenience. | |||||
@see Align | |||||
*/ | |||||
void textAlign(int align); | |||||
/** | /** | ||||
Sets the font face based on specified id of current text style. | Sets the font face based on specified id of current text style. | ||||
*/ | */ | ||||
@@ -296,6 +296,12 @@ protected: | |||||
*/ | */ | ||||
virtual void onResize(const ResizeEvent&); | virtual void onResize(const ResizeEvent&); | ||||
/** | |||||
Wherever the Y position is inverted. | |||||
(starts at the bottom) | |||||
*/ | |||||
bool fInvertedY; | |||||
private: | private: | ||||
Window& fParent; | Window& fParent; | ||||
bool fVisible; | bool fVisible; | ||||
@@ -529,6 +529,11 @@ void NanoVG::textAlign(NanoVG::Align align) | |||||
nvgTextAlign(fContext, align); | nvgTextAlign(fContext, align); | ||||
} | } | ||||
void NanoVG::textAlign(int align) | |||||
{ | |||||
nvgTextAlign(fContext, align); | |||||
} | |||||
void NanoVG::fontFaceId(FontId font) | void NanoVG::fontFaceId(FontId font) | ||||
{ | { | ||||
nvgFontFaceId(fContext, font); | nvgFontFaceId(fContext, font); | ||||
@@ -23,7 +23,8 @@ START_NAMESPACE_DGL | |||||
// Widget | // Widget | ||||
Widget::Widget(Window& parent) | Widget::Widget(Window& parent) | ||||
: fParent(parent), | |||||
: fInvertedY(false), | |||||
fParent(parent), | |||||
fVisible(true) | fVisible(true) | ||||
{ | { | ||||
fParent._addWidget(this); | fParent._addWidget(this); | ||||
@@ -575,8 +575,23 @@ struct Window::PrivateData { | |||||
if (widget->isVisible()) | if (widget->isVisible()) | ||||
{ | { | ||||
glViewport(widget->getAbsoluteX(), -widget->getAbsoluteY(), fView->width, fView->height); | |||||
const int ypos = widget->fInvertedY ? fView->height - widget->getHeight() - widget->getAbsoluteY() : 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(); | widget->onDisplay(); | ||||
// pop | |||||
glPopMatrix(); | |||||
} | } | ||||
} | } | ||||