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 EconomyGraph::drawHistoryLineGraph( Painter& painter, Rect2D mg ){ // see oldgui/screen.cpp do_history_linegraph Vector2 a; Vector2 b; Color red, yellow, blue, brown, grey; red.parse( "red"); yellow.parse( "yellow" ); blue.parse( "blue" ); brown.parse( "brown" ); grey.parse("#A9A9A9FF"); painter.setClipRectangle( mg ); painter.setFillColor( grey ); painter.fillRectangle( mg ); int mgX = (int) mg.p1.x; int mgY = (int) mg.p1.y; int mgW = (int) mg.getWidth(); int mgH = (int) mg.getHeight(); float scale = (float) mgH / 64; //MONTHGRAPH_H ; b.y = mgY + mgH; for( int i = mgW - 1; i >= 0; i-- ){ painter.setLineColor( yellow ); a.x = mgX + mgW - i; a.y = mgY + mgH - scale * monthgraph_nojobs[i]; b.x = mgX + mgW - i; painter.drawLine( a, b ); painter.setLineColor( red ); a.y = mgY + mgH - scale * monthgraph_starve[i]; painter.drawLine( a, b ); } for( int i = mgW - 1; i > 0; i-- ){ painter.setLineColor( brown ); a.x = mgX + mgW - i; a.y = mgY + mgH - scale * monthgraph_pop[ i ]; b.x = mgX + mgW - i-1; b.y = mgY + mgH - scale * monthgraph_pop[ i-1 ]; painter.drawLine( a, b ); a.y = mgY + mgH - scale * monthgraph_ppool[ i ]; b.y = mgY + mgH - scale * monthgraph_ppool[ i-1 ]; painter.setLineColor( blue ); painter.drawLine( a, b ); } painter.clearClipRectangle(); }
void EconomyGraph::drawFPSGraph( Painter& painter, Rect2D fpsRect ){ Color grey, blue; blue.parse( "blue" ); grey.parse("#A9A9A9FF"); int mgX = (int) fpsRect.p1.x; int mgY = (int) fpsRect.p1.y; int mgW = (int) fpsRect.getWidth(); int mgH = (int) fpsRect.getHeight(); painter.setFillColor( grey ); painter.fillRectangle( fpsRect ); painter.setClipRectangle( fpsRect ); Vector2 a; Vector2 b; painter.setLineColor( blue ); float scale = (float) mgH / 64; //MONTHGRAPH_H ; b.y = mgY + mgH; for( int i = mgW - 1; i >= 0; i-- ){ a.x = mgX + mgW - i; a.y = mgY + mgH - scale * fps[i]; b.x = mgX + mgW - i; painter.drawLine( a, b ); } painter.clearClipRectangle(); }
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); }
void CustomStyle::draw(Painter &p,CheckBox*,Style::Element, const WidgetState &st, const Rect &r, const Style::Extra &) const { const int s = std::min(std::min(r.w,r.h),24); const Size sz = Size(s,s); p.translate(r.x,r.y); p.setBlendMode( Tempest::alphaBlend ); p.setColor(prime[Dark]); int x = 0, y = (r.h-sz.h)/2; p.drawLine(x, y,x+sz.w-1, y); p.drawLine(x,y+sz.h-1,x+sz.w-1,y+sz.h-1); p.drawLine( x, y, x,y+sz.h-1); p.drawLine(x+sz.w-1,y,x+sz.w-1,y+sz.h ); if( st.checked==WidgetState::Checked ) { int d = st.pressed ? 2 : 4; if( st.pressed ) { p.drawLine(x+d, y+d, x+sz.w-d, y+sz.h-d); p.drawLine(x+sz.w-d, y+d, x+d, y+sz.h-d); } else { p.drawLine(x, y, x+sz.w, y+sz.h); p.drawLine(x+sz.w, y, x, y+sz.h); } } else if( st.checked==WidgetState::PartiallyChecked ) { int d = st.pressed ? 2 : 4; p.drawLine(x+d, y+d, x+sz.w-d, y+d); p.drawLine(x+d, y+sz.h+d, x+sz.w-d, y+sz.h+d); p.drawLine(x+d, y+d, x+d, y+sz.h-d); p.drawLine(x+sz.w+d, y+d, x+sz.w+d, y+sz.h-d); } p.translate(-r.x,-r.y); }
void EconomyGraph::drawSustBarGraph( Painter& painter, Rect2D mg ){ // see oldgui/screen.cpp do_sust_barchart Color grey,yellow,orange,black,green,blue,red; grey.parse( "#A9A9A9FF" ); yellow.parse( "yellow" ); orange.parse( "orange" ); black.parse( "black" ); green.parse( "green" ); blue.parse( "blue" ); red.parse( "red" ); painter.setFillColor( grey ); painter.fillRectangle( mg ); int mgX = (int) mg.p1.x; int mgY = (int) mg.p1.y; int mgW = (int) mg.getWidth(); int mgH = (int) mg.getHeight(); Vector2 a, b, p; #define SUST_BAR_H 5 #define SUST_BAR_GAP_Y 5 /* draw the starting line */ a.x = mgX + 38; a.y = mgY; b.x = mgX + 38; b.y = mgY + mgH; p.x = mgX; p.y = mgY; painter.setLineColor( yellow ); painter.drawLine( a, b); Rect2D bar; bar.p1.x = mgX + 36; bar.p1.y = mgY + SUST_BAR_GAP_Y; bar.setHeight( SUST_BAR_H ); int maxBarLen = mgW - 40; int newLen; int len; /* ore coal */ newLen = maxBarLen * sust_dig_ore_coal_count / SUST_ORE_COAL_YEARS_NEEDED; len = 3 + ( ( newLen > maxBarLen ) ? maxBarLen : newLen ); bar.setWidth( len ); painter.setFillColor( orange ); painter.fillRectangle( bar ); painter.drawTexture( labelTextureMIN, p ); /* import export */ p.y += SUST_BAR_H + SUST_BAR_GAP_Y ; newLen = maxBarLen * sust_port_count / SUST_PORT_YEARS_NEEDED; len = 3 + ( ( newLen > maxBarLen ) ? maxBarLen : newLen ); bar.setWidth( len ); painter.setFillColor( black ); bar.move( Vector2( 0, SUST_BAR_H + SUST_BAR_GAP_Y ) ); painter.fillRectangle( bar ); painter.drawTexture( labelTexturePRT, p ); /* money */ p.y += SUST_BAR_H + SUST_BAR_GAP_Y ; newLen = maxBarLen * sust_old_money_count / SUST_MONEY_YEARS_NEEDED; len = 3 + ( ( newLen > maxBarLen ) ? maxBarLen : newLen ); bar.setWidth( len ); painter.setFillColor( green ); bar.move( Vector2( 0, SUST_BAR_H + SUST_BAR_GAP_Y ) ); painter.fillRectangle( bar ); painter.drawTexture( labelTextureMNY, p ); /* population */ p.y += SUST_BAR_H + SUST_BAR_GAP_Y ; newLen = maxBarLen * sust_old_population_count / SUST_POP_YEARS_NEEDED; len = 3 + ( ( newLen > maxBarLen ) ? maxBarLen : newLen ); bar.setWidth( len ); painter.setFillColor( blue ); bar.move( Vector2( 0, SUST_BAR_H + SUST_BAR_GAP_Y ) ); painter.fillRectangle( bar ); painter.drawTexture( labelTexturePOP, p ); /* tech */ p.y += SUST_BAR_H + SUST_BAR_GAP_Y ; newLen = maxBarLen * sust_old_tech_count / SUST_TECH_YEARS_NEEDED; len = 3 + ( ( newLen > maxBarLen ) ? maxBarLen : newLen ); bar.setWidth( len ); painter.setFillColor( yellow ); bar.move( Vector2( 0, SUST_BAR_H + SUST_BAR_GAP_Y ) ); painter.fillRectangle( bar ); painter.drawTexture( labelTextureTEC, p ); /* fire */ p.y += SUST_BAR_H + SUST_BAR_GAP_Y ; newLen = maxBarLen * sust_fire_count / SUST_FIRE_YEARS_NEEDED; len = 3 + ( ( newLen > maxBarLen ) ? maxBarLen : newLen ); bar.setWidth( len ); painter.setFillColor( red ); bar.move( Vector2( 0, SUST_BAR_H + SUST_BAR_GAP_Y ) ); painter.fillRectangle( bar ); painter.drawTexture( labelTextureFIR, p ); }