void CheckboxStyle::draw() { // todo Widget *w = getWidget(); iuiGetRenderer()->drawRect(Rect(w->getPosition(), w->getSize()), getBGColor()); iuiGetRenderer()->drawOutlineRect(Rect(w->getPosition(), w->getSize()), getBorderColor()); }
void EditboxStyle::draw() { Editbox *w = static_cast<Editbox*>(getWidget()); Rect rect(Position(), w->getSize()); TextPosition tpos(rect, getTextHAlign(), getTextVAlign(), getTextHSpacing(), getTextVSpacing()); Color bg = getBGColor(); if(w->isFocused()) { bg += vec4(0.4f, 0.4f, 0.4f, 0.0f); } else if(w->isHovered()) { bg += vec4(0.2f, 0.2f, 0.2f, 0.0f); } iuiGetRenderer()->drawRect(rect, bg); iuiGetRenderer()->drawOutlineRect(rect, getBorderColor()); iuiGetRenderer()->drawFont(tpos, getFontColor(), w->getText().c_str(), w->getText().size()); if(w->isFocused() && ist::GetTick()%1000<500) { vec2 tsize = iuiGetRenderer()->computeTextSize(w->getText().c_str(), w->getCursorPos()); Line l(Position(tsize.x, 0.0f), Position(tsize.x, tsize.y)); iuiGetRenderer()->drawLine(l, getBorderColor()); } }
void Rainbow::draw() const { if(isVisible()) { HPEN pen = CreatePen (PS_SOLID, 2, decodeColor(getBorderColor())); SelectObject (dc, pen); MoveToEx(dc, x+r, y, NULL); ArcTo(dc, x-R, y-R, x+R, y+R, x+R, y, x-R, y); MoveToEx(dc, x+r, y, NULL); ArcTo(dc, x-r, y-r, x+r, y+r, x+r, y, x-r, y); LineTo(dc, x-R, y); } }
void ToggleButtonStyle::draw() { ToggleButton *w = static_cast<ToggleButton*>(getWidget()); Rect rect(Position(), w->getSize()); TextPosition tpos(rect, getTextHAlign(), getTextVAlign(), getTextHSpacing(), getTextVSpacing()); Color bg = getBGColor(); if(w->isPressing() || w->isPressed()) { bg += vec4(0.4f, 0.4f, 0.4f, 0.0f); } else if(w->isHovered()) { bg += vec4(0.2f, 0.2f, 0.2f, 0.0f); } iuiGetRenderer()->drawRect(rect, bg); iuiGetRenderer()->drawOutlineRect(rect, getBorderColor()); iuiGetRenderer()->drawFont(tpos, getFontColor(), w->getText().c_str(), w->getText().size()); }
void Container::draw(SDL_Renderer * renderer) { if(isVisible()) { if(renderTarget == nullptr) { renderTarget = SDL_CreateTexture(renderer,SDL_PIXELFORMAT_UNKNOWN,SDL_TEXTUREACCESS_TARGET,getWidth(),getHeight()); SDL_SetTextureBlendMode(renderTarget,SDL_BLENDMODE_BLEND); } SDL_Texture * callerTexture = SDL_GetRenderTarget(renderer); SDL_SetRenderTarget(renderer,renderTarget); SDL_SetRenderDrawColor(renderer,bgColor.r,bgColor.g,bgColor.b,bgColor.a); SDL_RenderClear(renderer); for(it = widgets.begin();it != widgets.end();++it) { (*it)->draw(renderer); } SDL_SetRenderTarget(renderer,callerTexture); SDL_RenderCopy(renderer,renderTarget,NULL,&getArea()); if(borderVisible) { SDL_Color bc = getBorderColor(); SDL_SetRenderDrawColor(renderer,bc.r,bc.g,bc.b,bc.a); SDL_RenderDrawRect(renderer,&area); } callerTexture = NULL; } }
void ScenRectangle::toXml(ostream &out) { //Dati obbligatori out<<" <Rect x=\""<<p.x<<"\" y=\""<<p.y<<"\" width=\""<<width<<"\" height=\""<<height<<"\""; //Nome (dato Opzionale) if(getName()!="") out<<" name=\""<<getName()<<"\""; //Angolo di rotazione (dato Opzionale) if(rotAngle!=0) out<<" rotation=\""<<rotAngle<<"\""; //Colore riempimento (Dato opzionale) Color fillCol=getFillColor(); if((fillCol.getRi()!=128)|| (fillCol.getGi()!=128)|| (fillCol.getBi()!=128)) { out<<" fill=\""<<fillCol.getRi()<<"," <<fillCol.getGi()<<"," <<fillCol.getBi()<<"\""; } //Colore bordo (Dato opzionale) Color borderCol=getBorderColor(); if((borderCol.getRi()!=255)|| (borderCol.getGi()!=0)|| (borderCol.getBi()!=0)) { out<<" border=\""<<borderCol.getRi()<<"," <<borderCol.getGi()<<"," <<borderCol.getBi()<<"\""; } out<<" attenuation=\""<<getAttenuation()<<"\"/>\n"; }//Fine toXml
bool GUIProgressBar::gatherGeometry(GeometryGather& gather) { if (shouldProcessGather(gather)) { auto fullMaterialName = getMaterialRoot() + material_; gather.changePriority(getRenderPriority()); gather.changeTransformation(getWorldTransform()); if (material_.length()) { auto overrideParameters = getMaterialOverrideParameters(fullMaterialName); gather.changeMaterial(fullMaterialName, overrideParameters); gather.addRectangle(getWidth() * fraction_, getHeight()); } else queueWindow(gather, getWidth() * fraction_, getHeight(), getBorderSize(), getFillColor(), getBorderColor()); auto fullBackgroundMaterialName = getMaterialRoot() + backgroundMaterial_; gather.changeTransformation(localToWorld(Vec3(getWidth() * fraction_, 0.0f)), getWorldOrientation()); if (backgroundMaterial_.length()) { auto overrideParameters = getMaterialOverrideParameters(fullBackgroundMaterialName); gather.changeMaterial(fullBackgroundMaterialName, overrideParameters); gather.addRectangle(getWidth() * (1.0f - fraction_), getHeight()); } else { queueWindow(gather, getWidth() * (1.0f - fraction_), getHeight(), getBorderSize(), getFillColor(), getBorderColor()); } } return true; }
void EditboxMultilineStyle::draw() { Widget *w = getWidget(); iuiGetRenderer()->drawRect(Rect(w->getPosition(), w->getSize()), getBGColor()); iuiGetRenderer()->drawOutlineRect(Rect(w->getPosition(), w->getSize()), getBorderColor()); }
/*! Draw the statistics lines. */ void SimpleStatisticsForeground::draw(DrawEnv *pEnv, Viewport *pPort) { if(getActive() == false) return; if(_face == 0) initText(getFamily(), getSize()); if ((getCollector() == NULL) || (!getCollector()->getNumOfElems() && !getMFElementIDs()->size())) return; // nothing to do Real32 pw = Real32(pPort->getPixelWidth ()); Real32 ph = Real32(pPort->getPixelHeight()); if(pw < 1 || ph < 1) return; glPushAttrib(GL_LIGHTING_BIT | GL_POLYGON_BIT | GL_DEPTH_BUFFER_BIT | GL_COLOR_BUFFER_BIT); glPolygonMode(GL_FRONT_AND_BACK, GL_FILL); glDisable(GL_DEPTH_TEST); glDisable(GL_COLOR_MATERIAL); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glEnable(GL_BLEND); glMatrixMode(GL_MODELVIEW); glPushMatrix(); glLoadIdentity(); glMatrixMode(GL_PROJECTION); glPushMatrix(); glLoadIdentity(); // Set viewport. We want to map one unit to one pixel on the // screen. Some sources in the internet say that we should // add an offset of -0.375 to prevent rounding errors. Don't // know if that is true, but it seems to work. glOrtho(0 - 0.375, pw - 0.375, 0 - 0.375, ph - 0.375, 0, 1); // retrieve text std::vector < std::string > stat; StatCollector *col = this->getCollector(); StatElem *el; if(getMFElementIDs()->size() != 0) { for(UInt32 i = 0; i < getMFElementIDs()->size(); ++i) { Int32 id(getElementIDs(i)); el = ((id >= 0) ? col->getElem(id) : 0); stat.resize(stat.size() + 1); std::vector < std::string >::iterator str = stat.end() - 1; const char *format = NULL; if(i < getMFFormats()->size() && getFormats(i).length()) { format = getFormats(i).c_str(); } if (el) el->putToString(*str, format); else *str = format; } } else // fallback, show all elements { for(UInt32 i = 0; i < col->getNumOfElems(); ++i) { el = col->getElem(i, false); if(el) { std::string desc(el->getDesc()->getName()), eltext; el->putToString(eltext); desc = desc + " : " + eltext; stat.resize(stat.size() + 1); std::vector < std::string >::iterator str = stat.end() - 1; *str = desc; } } } TextLayoutParam layoutParam; layoutParam.spacing = 1.1f; layoutParam.majorAlignment = TextLayoutParam::ALIGN_BEGIN; layoutParam.minorAlignment = TextLayoutParam::ALIGN_BEGIN; TextLayoutResult layoutResult; _face->layout(stat, layoutParam, layoutResult); Real32 scale = 1 / _face->getScale(); Real32 size = _face->getParam().size; Real32 textWidth = layoutResult.textBounds.x() * scale + size + getTextMargin().x() * 2.0f; Real32 textHeight = layoutResult.textBounds.y() * scale + size + getTextMargin().y() * 2.0f; // Let's do some simple form of layout management Real32 orthoX = 0, orthoY = ph; switch ( getHorizontalAlign() ) { case Right: orthoX = pw - textWidth; break; case Middle: orthoX = (pw - textWidth) * 0.5; break; case Left: default: break; } switch ( getVerticalAlign() ) { case Bottom: orthoY = textHeight; break; case Center: orthoY = (ph - textHeight) * 0.5 + textHeight; break; case Top: default: break; } glTranslatef(orthoX, orthoY, 0.0); // draw background glColor4fv(static_cast<const GLfloat *>(getBgColor().getValuesRGBA())); glBegin(GL_QUADS); glVertex2f(0, -textHeight); glVertex2f(textWidth, -textHeight); glVertex2f(textWidth, 0); glVertex2f(0, 0); glEnd(); // draw border if(getBorderColor().alpha() >= 0.0f) { glColor4fv( static_cast<const GLfloat *>(getBorderColor().getValuesRGBA())); glBegin(GL_LINE_LOOP); glVertex2f(getBorderOffset().x(), -textHeight + 1 + getBorderOffset().y()); glVertex2f(textWidth - 1 - getBorderOffset().x(), -textHeight + 1 + getBorderOffset().y()); glVertex2f(textWidth - 1 - getBorderOffset().x(), -1 - getBorderOffset().y()); glVertex2f(getBorderOffset().x(), -1 - getBorderOffset().y()); glEnd(); } glTranslatef( 0.5 * size + getTextMargin().x(), -0.5 * size - getTextMargin().y(), 0.0); _texchunk ->activate(pEnv); _texenvchunk->activate(pEnv); // draw text shadow glColor4fv(static_cast<const GLfloat *>(getShadowColor().getValuesRGBA())); glPushMatrix(); glTranslatef(getShadowOffset().x(), getShadowOffset().y(), 0); glScalef(scale, scale, 1); _face->drawCharacters(layoutResult); // draw text glColor4fv(static_cast<const GLfloat *>(getColor().getValuesRGBA())); glPopMatrix(); glScalef(scale, scale, 1); _face->drawCharacters(layoutResult); _texchunk ->deactivate(pEnv); _texenvchunk->deactivate(pEnv); glMatrixMode(GL_PROJECTION); glPopMatrix(); glMatrixMode(GL_MODELVIEW); glPopMatrix(); glPopAttrib(); }