void StGLMenu::stglResize() { // Since all children should be StGLMenuItem implementing delayed resize, // just postpone resize until items will be actually rendered. //StGLWidget::stglResize(); for(StGLWidget* aChild = getChildren()->getStart(); aChild != NULL; aChild = aChild->getNext()) { ((StGLMenuItem* )aChild)->changeRectPx(); } StGLContext& aCtx = getContext(); StArray<StGLVec2> aVertices(4); getRectGl(aVertices); myVertexBuf.init(aCtx, aVertices); if(myToDrawBounds) { StRectI_t aRectBnd = getRectPxAbsolute(); aRectBnd.left() -= 1; aRectBnd.right() += 1; aRectBnd.top() -= 1; aRectBnd.bottom() += 1; myRoot->getRectGl(aRectBnd, aVertices); myVertexBndBuf.init(aCtx, aVertices); } myIsResized = false; }
bool StGLWidget::isPointIn(const StPointD_t& thePointZo) const { const StRectD_t aRectGl = getRectGl(); StPointD_t aPointGl = getPointGl(thePointZo); return aPointGl.x() > aRectGl.left() && aPointGl.x() < aRectGl.right() && aPointGl.y() > aRectGl.bottom() && aPointGl.y() < aRectGl.top(); }
void StGLRootWidget::getRectGl(const StRectI_t& theRectPx, StArray<StGLVec2>& theVertices, const size_t theFromId) const { StRectD_t aRectGl = getRectGl(theRectPx); theVertices[theFromId + 0] = StGLVec2(GLfloat(aRectGl.right()), GLfloat(aRectGl.top())); theVertices[theFromId + 1] = StGLVec2(GLfloat(aRectGl.right()), GLfloat(aRectGl.bottom())); theVertices[theFromId + 2] = StGLVec2(GLfloat(aRectGl.left()), GLfloat(aRectGl.top())); theVertices[theFromId + 3] = StGLVec2(GLfloat(aRectGl.left()), GLfloat(aRectGl.bottom())); }
StPointD_t StGLWidget::getPointIn(const StPointD_t& thePointZo) const { const StRectD_t aRectGl = getRectGl(); StPointD_t aPointGl = getPointGl(thePointZo); return StPointD_t((aPointGl.x() - aRectGl.left()) / (aRectGl.right() - aRectGl.left()), (aRectGl.top() - aPointGl.y()) / (aRectGl.top() - aRectGl.bottom())); }