void CustomStyle::draw(Painter &p, const std::u16string &text, Style::TextElement elt, const WidgetState& st, const Rect &r, const Style::Extra &extra) const { const Margin& m = extra.margin; p.setFont (font); p.translate(r.x,r.y); const Sprite& icon = iconSprite(extra.icon,st,r); int dX=0; if( !icon.size().isEmpty() && elt!=TE_CheckboxTitle ){ p.setColor(Color(1.f)); p.setTexture( icon ); if( text.empty() ) { p.drawRect( (r.w-icon.w())/2, (r.h-icon.h())/2, icon.w(), icon.h() ); } else { p.drawRect( m.left, (r.h-icon.h())/2, icon.w(), icon.h() ); } } switch( elt ){ case TE_LabelTitle: case TE_CheckboxTitle: p.setColor(Color(0,0,0,1)); break; default: p.setColor(extra.fontColor); } const Size txtSz=extra.font.textSize(text); p.drawText( m.left+dX+(r.w-dX-m.xMargin()-txtSz.w)/2, (r.h-txtSz.h)/2, r.w-m.xMargin(), txtSz.h, text, AlignBottom ); p.translate(-r.x,-r.y); }
void CustomStyle::draw(Painter& p, Button*, Element /*e*/, const WidgetState &st, const Rect &r, const Extra&) const { p.setBlendMode( Tempest::alphaBlend ); p.translate(r.x,r.y); const Button::Type buttonType=st.button; const bool drawBackFrame = (buttonType!=Button::T_ToolButton || st.highlighted) && buttonType!=Button::T_FlatButton; if( drawBackFrame ) { auto c = p.color(); if( st.pressed ) p.setColor(second[Dark]); else if( st.highlighted ) p.setColor(second[Dark]); else p.setColor(second[Normal]); p.drawRect(0,0,r.w,r.h); p.setColor(c); } if( drawBackFrame ) { p.setColor(border); p.unsetTexture(); p.drawLine(0,0, r.w-1,0 ); p.drawLine(0,r.h-1,r.w-1,r.h-1); p.drawLine(0, 0, 0,r.h-1); p.drawLine(r.w-1, 0,r.w-1,r.h ); } p.translate(r.x,r.y); }
void CustomStyle::draw(Painter &p, Panel*, Style::Element, const WidgetState&,const Rect& r,const Style::Extra&) const { p.translate(r.x,r.y); p.setBlendMode( Tempest::alphaBlend ); p.setColor(Color(1.0)); p.drawRect(0,0,r.w,r.h); p.setColor(border); p.unsetTexture(); p.drawLine(0,0, r.w-1,0 ); p.drawLine(0,r.h-1,r.w-1,r.h-1); p.drawLine(0, 0, 0,r.h-1); p.drawLine(r.w-1, 0,r.w-1,r.h ); p.translate(-r.x,-r.y); }