void wins_update_border (void) { switch (slctd_win) { case CAL: border_color (win[CAL].p); border_nocolor (win[APP].p); border_nocolor (win[TOD].p); break; case APP: border_color (win[APP].p); border_nocolor (win[CAL].p); border_nocolor (win[TOD].p); break; case TOD: border_color (win[TOD].p); border_nocolor (win[APP].p); border_nocolor (win[CAL].p); break; default: EXIT (_("no window selected")); /* NOTREACHED */ } }
static float round_rect_color(const veci2& p, const rect& rc, int corner_radius) { const int x00 = rc.x; const int x01 = rc.x + corner_radius; const int x10 = rc.x + rc.w - corner_radius - 1; const int x11 = rc.x + rc.w - 1; const int y00 = rc.y; const int y01 = rc.y + corner_radius; const int y10 = rc.y + rc.h - corner_radius - 1; const int y11 = rc.y + rc.h - 1; const int x = p.x; const int y = p.y; if (x < x00 || x > x11 || y < y00 || y > y11) return 0; else if (x < x01 && y < y01) return border_color(p, veci2(x01, y01), corner_radius); else if (x < x01 && y > y10) return border_color(p, veci2(x01, y10), corner_radius); else if (x > x10 && y < y01) return border_color(p, veci2(x10, y01), corner_radius); else if (x > x10 && y > y10) return border_color(p, veci2(x10, y10), corner_radius); else return 1; }
TEST(PaddingEffectTest, WhiteBorderColor) { float data[2 * 2] = { 1.0f, 0.5f, 0.8f, 0.3f, }; float expected_data[4 * 4] = { 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 0.5f, 1.0f, 1.0f, 0.8f, 0.3f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, }; float out_data[4 * 4]; EffectChainTester tester(NULL, 4, 4); ImageFormat format; format.color_space = COLORSPACE_sRGB; format.gamma_curve = GAMMA_LINEAR; FlatInput *input = new FlatInput(format, FORMAT_GRAYSCALE, GL_FLOAT, 2, 2); input->set_pixel_data(data); tester.get_chain()->add_input(input); Effect *effect = tester.get_chain()->add_effect(new PaddingEffect()); CHECK(effect->set_int("width", 4)); CHECK(effect->set_int("height", 4)); CHECK(effect->set_float("left", 1.0f)); CHECK(effect->set_float("top", 1.0f)); RGBATuple border_color(1.0f, 1.0f, 1.0f, 1.0f); CHECK(effect->set_vec4("border_color", (float *)&border_color)); tester.run(out_data, GL_RED, COLORSPACE_sRGB, GAMMA_LINEAR, OUTPUT_ALPHA_FORMAT_PREMULTIPLIED); expect_equal(expected_data, out_data, 4, 4); }
TEST(PaddingEffectTest, BorderColorIsInLinearGamma) { float data[4 * 1] = { 0.2f, 0.4f, 0.6f, 0.8f, }; float expected_data[4 * 2] = { 0.5005, 0.7051, 0.8677, 0.7998, // Pixel from data[]. 0.5005, 0.7051, 0.8677, 0.7998, // Pixel from the border color. }; float out_data[4 * 2]; EffectChainTester tester(NULL, 1, 2); ImageFormat format; format.color_space = COLORSPACE_sRGB; format.gamma_curve = GAMMA_LINEAR; FlatInput *input = new FlatInput(format, FORMAT_RGBA_PREMULTIPLIED_ALPHA, GL_FLOAT, 1, 1); input->set_pixel_data(data); tester.get_chain()->add_input(input); Effect *effect = tester.get_chain()->add_effect(new PaddingEffect()); CHECK(effect->set_int("width", 1)); CHECK(effect->set_int("height", 2)); CHECK(effect->set_float("left", 0.0f)); CHECK(effect->set_float("top", 0.0f)); RGBATuple border_color(0.2f, 0.4f, 0.6f, 0.8f); // Same as the pixel in data[]. CHECK(effect->set_vec4("border_color", (float *)&border_color)); tester.run(out_data, GL_RGBA, COLORSPACE_REC_601_625, GAMMA_REC_601, OUTPUT_ALPHA_FORMAT_POSTMULTIPLIED); expect_equal(expected_data, out_data, 4, 2); }
TEST(PaddingEffectTest, AlphaIsCorrectEvenWithNonLinearInputsAndOutputs) { float data[2 * 1] = { 1.0f, 0.8f, }; float expected_data[4 * 4] = { 1.0f, 1.0f, 1.0f, 0.5f, 1.0f, 1.0f, 1.0f, 1.0f, 0.8f, 0.8f, 0.8f, 1.0f, 1.0f, 1.0f, 1.0f, 0.5f, }; float out_data[4 * 4]; EffectChainTester tester(NULL, 1, 4); ImageFormat format; format.color_space = COLORSPACE_REC_601_625; format.gamma_curve = GAMMA_REC_709; FlatInput *input = new FlatInput(format, FORMAT_GRAYSCALE, GL_FLOAT, 1, 2); input->set_pixel_data(data); tester.get_chain()->add_input(input); Effect *effect = tester.get_chain()->add_effect(new PaddingEffect()); CHECK(effect->set_int("width", 1)); CHECK(effect->set_int("height", 4)); CHECK(effect->set_float("left", 0.0f)); CHECK(effect->set_float("top", 1.0f)); RGBATuple border_color(1.0f, 1.0f, 1.0f, 0.5f); CHECK(effect->set_vec4("border_color", (float *)&border_color)); tester.run(out_data, GL_RGBA, COLORSPACE_REC_601_625, GAMMA_REC_709, OUTPUT_ALPHA_FORMAT_POSTMULTIPLIED); expect_equal(expected_data, out_data, 4, 4); }
void OverlayScrollBar::paintEvent(QPaintEvent *event) { qreal dp_ratio = 1.0; QSize pm_size(packet_map_width_, geometry().height()); #if QT_VERSION >= QT_VERSION_CHECK(5, 1, 0) dp_ratio = devicePixelRatio(); pm_size *= dp_ratio; #endif QPainter painter(this); painter.fillRect(event->rect(), palette().base()); if (!packet_map_img_.isNull()) { QImage packet_map(pm_size, QImage::Format_ARGB32_Premultiplied); packet_map.fill(Qt::transparent); // Draw the image supplied by the packet list. QPainter pm_painter(&packet_map); pm_painter.setPen(Qt::NoPen); QRect near_dest(0, 0, pm_size.width(), pm_size.height()); pm_painter.drawImage(near_dest, packet_map_img_.scaled(near_dest.size(), Qt::IgnoreAspectRatio, Qt::SmoothTransformation)); // Selected packet indicator if (selected_pos_ >= 0 && selected_pos_ < packet_map_img_.height()) { pm_painter.save(); int no_pos = near_dest.height() * selected_pos_ / packet_map_img_.height(); pm_painter.setBrush(palette().highlight().color()); pm_painter.drawRect(0, no_pos, pm_size.width(), dp_ratio); pm_painter.restore(); } // Borders pm_painter.save(); QColor border_color(ColorUtils::alphaBlend(palette().text(), palette().window(), 0.25)); pm_painter.setPen(border_color); pm_painter.drawLine(near_dest.topLeft(), near_dest.bottomLeft()); pm_painter.drawLine(near_dest.topRight(), near_dest.bottomRight()); pm_painter.drawLine(near_dest.bottomLeft(), near_dest.bottomRight()); pm_painter.restore(); // Draw the map. #if QT_VERSION >= QT_VERSION_CHECK(5, 1, 0) packet_map.setDevicePixelRatio(dp_ratio); #endif painter.drawImage(0, 0, packet_map); } }
RenderQueue* BREW::CreateScaleDrawable( SharedPtr<const Scale> scale ) const { sf::Color trough_color( GetProperty<sf::Color>( "TroughColor", scale ) ); sf::Color slider_color( GetProperty<sf::Color>( "SliderColor", scale ) ); sf::Color border_color( GetProperty<sf::Color>( "BorderColor", scale ) ); int border_color_shift( GetProperty<int>( "BorderColorShift", scale ) ); float trough_thickness( GetProperty<float>( "TroughWidth", scale ) ); float border_width( GetProperty<float>( "BorderWidth", scale ) ); RenderQueue* queue( new RenderQueue ); Scale::Orientation orientation = scale->GetOrientation(); sf::FloatRect slider_rect = scale->GetSliderRect(); if( orientation == Scale::HORIZONTAL ) { // Trough queue->Add( Renderer::Get().CreateRect( sf::FloatRect( slider_rect.width / 2.f, ( scale->GetAllocation().height - trough_thickness ) / 2.f, scale->GetAllocation().width - slider_rect.width, trough_thickness ), trough_color ) ); } else { // Trough queue->Add( Renderer::Get().CreateRect( sf::FloatRect( ( scale->GetAllocation().width - trough_thickness ) / 2.f, slider_rect.height / 2.f, trough_thickness, scale->GetAllocation().height - slider_rect.height ), trough_color ) ); } // Slider queue->Add( CreateSlider( slider_rect, slider_color, border_width, border_color, border_color_shift ) ); return queue; }
RenderQueue* BREW::CreateToggleButtonDrawable( SharedPtr<const ToggleButton> button ) const { sf::Color border_color( GetProperty<sf::Color>( "BorderColor", button ) ); int border_color_shift( GetProperty<int>( "BorderColorShift", button ) ); sf::Color background_color( GetProperty<sf::Color>( "BackgroundColor", button ) ); sf::Color color( GetProperty<sf::Color>( "Color", button ) ); float border_width( GetProperty<float>( "BorderWidth", button ) ); const std::string& font_name( GetProperty<std::string>( "FontName", button ) ); unsigned int font_size( GetProperty<unsigned int>( "FontSize", button ) ); const sf::Font& font( *GetResourceManager().GetFont( font_name ) ); if( ( button->GetState() == Button::ACTIVE ) || button->IsActive() ) { border_color_shift = -border_color_shift; } RenderQueue* queue( new RenderQueue ); // Pane. queue->Add( Renderer::Get().CreatePane( sf::Vector2f( 0.f, 0.f ), sf::Vector2f( button->GetAllocation().width, button->GetAllocation().height ), border_width, background_color, border_color, border_color_shift ) ); // Label. if( button->GetLabel().getSize() > 0 ) { sf::Vector2f metrics = GetTextMetrics( button->GetLabel(), font, font_size ); metrics.y = GetFontLineHeight( font, font_size ); sf::Text text( button->GetLabel(), font, font_size ); float offset = ( ( button->GetState() == Button::ACTIVE ) || button->IsActive() ) ? border_width : 0.f; text.setPosition( button->GetAllocation().width / 2.f - metrics.x / 2.f + offset, button->GetAllocation().height / 2.f - metrics.y / 2.f + offset ); text.setColor( color ); queue->Add( Renderer::Get().CreateText( text ) ); } return queue; }
void GameSession::draw_background (DrawingContext& gc) { Rect rect = playfield->get_rect(); if (rect != Rect(Vector2i(0,0), Size(Display::get_width(), Display::get_height()))) { // Draw a black border around the playfield when the playfield is smaller then the screen Color border_color(0, 0, 0); // top gc.draw_fillrect(Rect(0, 0, Display::get_width(), rect.top), border_color); // bottom gc.draw_fillrect(Rect(0, rect.bottom, Display::get_width(), Display::get_height()), border_color); // left gc.draw_fillrect(Rect(0, rect.top, rect.left, rect.bottom), border_color); // right gc.draw_fillrect(Rect(rect.right, rect.top, Display::get_width(), rect.bottom), border_color); } }
void WorldmapComponent::draw (DrawingContext& gc) { Worldmap* worldmap = worldmap_screen->get_worldmap(); Rect cliprect = worldmap_screen->get_trans_rect(); scene_context->set_rect(cliprect); scene_context->clear(); scene_context->push_modelview(); worldmap->draw(scene_context->color()); gc.draw(new SceneContextDrawingRequest(scene_context.get(), Vector2i(0,0), -1000)); scene_context->pop_modelview(); // Draw border if (cliprect != Rect(Vector2i(0,0), Size(Display::get_width(), Display::get_height()))) { Color border_color(0, 0, 0); // top gc.draw_fillrect(Rect(0, 0, Display::get_width(), cliprect.top), border_color); // bottom gc.draw_fillrect(Rect(0, cliprect.bottom, Display::get_width(), Display::get_height()), border_color); // left gc.draw_fillrect(Rect(0, cliprect.top, cliprect.left, cliprect.bottom), border_color); // right gc.draw_fillrect(Rect(cliprect.right, cliprect.top, Display::get_width(), cliprect.bottom), border_color); } }
RenderQueue* BREW::CreateProgressBarDrawable( SharedPtr<const ProgressBar> progress_bar ) const { sf::Color border_color( GetProperty<sf::Color>( "BorderColor", progress_bar ) ); sf::Color bar_border_color( GetProperty<sf::Color>( "BarBorderColor", progress_bar ) ); sf::Color background_color( GetProperty<sf::Color>( "BackgroundColor", progress_bar ) ); sf::Color progress_color( GetProperty<sf::Color>( "BarColor", progress_bar ) ); int border_color_shift( GetProperty<int>( "BorderColorShift", progress_bar ) ); int bar_border_color_shift( GetProperty<int>( "BarBorderColorShift", progress_bar ) ); float border_width( GetProperty<float>( "BorderWidth", progress_bar ) ); float bar_border_width( GetProperty<float>( "BarBorderWidth", progress_bar ) ); RenderQueue* queue( new RenderQueue ); // Pane. queue->Add( Renderer::Get().CreatePane( sf::Vector2f( 0.f, 0.f ), sf::Vector2f( progress_bar->GetAllocation().width, progress_bar->GetAllocation().height ), border_width, background_color, border_color, -border_color_shift ) ); if( progress_bar->GetFraction() > 0.f ) { sf::FloatRect bar_rect; if( progress_bar->GetOrientation() == ProgressBar::HORIZONTAL ) { float frac_width( std::max( 2.f * bar_border_width, progress_bar->GetAllocation().width * progress_bar->GetFraction() ) ); bar_rect = sf::FloatRect( border_width, border_width, std::max( 0.f, frac_width - 2.f * border_width ), std::max( 0.f, progress_bar->GetAllocation().height - 2.f * border_width ) ); } else { float frac_height( std::max( 2.f * bar_border_width, progress_bar->GetAllocation().height * progress_bar->GetFraction() ) ); bar_rect = sf::FloatRect( border_width, std::max( 0.f, progress_bar->GetAllocation().height - frac_height + border_width ), std::max( 0.f, progress_bar->GetAllocation().width - 2.f * border_width ), std::max( 0.f, frac_height - 2.f * border_width ) ); } // Bar Pane. queue->Add( Renderer::Get().CreatePane( sf::Vector2f( bar_rect.left, bar_rect.top ), sf::Vector2f( bar_rect.width, bar_rect.height ), bar_border_width, progress_color, bar_border_color, bar_border_color_shift ) ); } return queue; }
RenderQueue* BREW::CreateWindowDrawable( SharedPtr<const Window> window ) const { RenderQueue* queue( new RenderQueue ); sf::Color background_color( GetProperty<sf::Color>( "BackgroundColor", window ) ); sf::Color border_color( GetProperty<sf::Color>( "BorderColor", window ) ); sf::Color title_background_color( GetProperty<sf::Color>( "TitleBackgroundColor", window ) ); sf::Color title_text_color( GetProperty<sf::Color>( "Color", window ) ); int border_color_shift( GetProperty<int>( "BorderColorShift", window ) ); float border_width( GetProperty<float>( "BorderWidth", window ) ); float title_padding( GetProperty<float>( "TitlePadding", window ) ); float shadow_distance( GetProperty<float>( "ShadowDistance", window ) ); float handle_size( GetProperty<float>( "HandleSize", window ) ); sf::Uint8 shadow_alpha( GetProperty<sf::Uint8>( "ShadowAlpha", window ) ); unsigned int title_font_size( GetProperty<unsigned int>( "FontSize", window ) ); const sf::Font& title_font( *GetResourceManager().GetFont( GetProperty<std::string>( "FontName", window ) ) ); float title_size( GetFontLineHeight( title_font, title_font_size ) + 2 * title_padding ); if( window->HasStyle( Window::SHADOW ) ) { // Shadow. sf::Color shadow_color( 0, 0, 0, shadow_alpha ); sf::FloatRect shadow_rect( shadow_distance, shadow_distance, window->GetAllocation().width, window->GetAllocation().height ); queue->Add( Renderer::Get().CreateRect( shadow_rect, shadow_color ) ); } if( window->HasStyle( Window::BACKGROUND ) ) { // Pane. queue->Add( Renderer::Get().CreatePane( sf::Vector2f( 0.f, 0.f ), sf::Vector2f( window->GetAllocation().width, window->GetAllocation().height ), border_width, background_color, border_color, border_color_shift ) ); } if( window->HasStyle( Window::RESIZE ) ) { queue->Add( Renderer::Get().CreateTriangle( sf::Vector2f( window->GetAllocation().width, window->GetAllocation().height - handle_size ), sf::Vector2f( window->GetAllocation().width - handle_size, window->GetAllocation().height ), sf::Vector2f( window->GetAllocation().width, window->GetAllocation().height ), title_background_color ) ); } if( !window->HasStyle( Window::TITLEBAR ) ) { title_size = 0; } if( title_size > 0 ) { queue->Add( Renderer::Get().CreateRect( sf::FloatRect( border_width + .1f, border_width + .1f, window->GetAllocation().width - 2 * border_width, title_size ), title_background_color ) ); // Find out visible text, count in "...". float avail_width( window->GetAllocation().width - 2.f * border_width - 2.f * title_padding ); sf::Text title_text( window->GetTitle(), title_font, title_font_size ); if( title_text.getLocalBounds().width > avail_width ) { sf::Text dots( "...", title_font, title_font_size ); const sf::String& title_string( window->GetTitle() ); sf::String visible_title; avail_width = window->GetAllocation().width - 2.f * border_width - 2.f * title_padding - dots.getLocalBounds().width; for( std::size_t ch_index = 0; ch_index < title_string.getSize(); ++ch_index ) { avail_width -= static_cast<float>( title_font.getGlyph( title_string[ch_index], title_font_size, false ).advance ); if( avail_width < 0.f ) { visible_title += "..."; break; } visible_title += title_string[ch_index]; } title_text.setString( visible_title ); } // Calculate title text position. sf::Vector2f title_position( border_width + title_padding, border_width + title_size / 2.f - static_cast<float>( title_font_size ) / 2.f ); title_text.setPosition( title_position ); title_text.setColor( title_text_color ); queue->Add( Renderer::Get().CreateText( title_text ) ); } return queue; }
BOOL CColorEditSampleDlg::OnInitDialog() { CDialog::OnInitDialog(); CDC *dc = __super::GetDC(); // icon HICON icon = AfxGetApp()->LoadIcon(IDR_MAINFRAME); SetIcon(icon, TRUE); SetIcon(icon, FALSE); // edit LOGFONT font; { CString font_name = _T("Tahoma"); LONG font_size = 14; _tcsncpy_s(font.lfFaceName, font_name, LF_FACESIZE); { static const int kPhysicalPx = 72; int logicalPx = dc->GetDeviceCaps(LOGPIXELSY); font.lfHeight = font_size * 10 * (-1) * logicalPx / kPhysicalPx; } font.lfWidth = 0; font.lfEscapement = 0; font.lfOrientation = 0; font.lfWeight = FW_NORMAL; font.lfItalic = FALSE; font.lfUnderline = FALSE; font.lfStrikeOut = FALSE; font.lfCharSet = DEFAULT_CHARSET; font.lfOutPrecision = OUT_DEFAULT_PRECIS; font.lfClipPrecision = CLIP_DEFAULT_PRECIS; font.lfPitchAndFamily = DEFAULT_PITCH | FF_DONTCARE; font.lfQuality = DEFAULT_QUALITY; } CSize edit_size(320, 100); COLORREF text_color(RGB(0, 0, 128)); COLORREF placeholder_color(RGB(128, 0, 0)); COLORREF bg_color(RGB(64, 128, 128)); COLORREF border_color(RGB(139, 87, 66)); COLORREF focus_text_color(RGB(0, 64, 255)); COLORREF focus_placeholder_color(RGB(255, 64, 0)); COLORREF focus_bg_color(RGB(128, 255, 255)); COLORREF focus_border_color(RGB(139, 69, 0)); UINT border_width = 10; LONG left_margin = 10; LONG right_margin = 10; CPoint id_pos(50, 50); id_edit_.CreateEdit(100, this, id_pos, edit_size, false, _T(""), _T("Id or email"), &font, text_color, placeholder_color, bg_color, border_color, focus_text_color, focus_placeholder_color, focus_bg_color, focus_border_color, border_width, left_margin, right_margin); CPoint pw_pos(50, 160); pw_edit_.CreateEdit(101, this, pw_pos, edit_size, true, _T(""), _T("Password"), &font, text_color, placeholder_color, bg_color, border_color, focus_text_color, focus_placeholder_color, focus_bg_color, focus_border_color, border_width, left_margin, right_margin); // __super::ReleaseDC(dc); return TRUE; }
RenderQueue* BREW::CreateFrameDrawable( SharedPtr<const Frame> frame ) const { sf::Color border_color( GetProperty<sf::Color>( "BorderColor", frame ) ); sf::Color color( GetProperty<sf::Color>( "Color", frame ) ); sf::Color background_color( GetProperty<sf::Color>( "BackgroundColor", frame ) ); float border_width( GetProperty<float>( "BorderWidth", frame ) ); const std::string& font_name( GetProperty<std::string>( "FontName", frame ) ); unsigned int font_size( GetProperty<unsigned int>( "FontSize", frame ) ); const sf::Font& font( *GetResourceManager().GetFont( font_name ) ); float label_padding( GetProperty<float>( "LabelPadding", frame ) ); float line_height = GetLineHeight( font, font_size ); RenderQueue* queue( new RenderQueue ); // Right queue->Add( Renderer::Get().CreateLine( sf::Vector2f( frame->GetAllocation().width - border_width, line_height / 2.f ), sf::Vector2f( frame->GetAllocation().width - border_width, frame->GetAllocation().height - border_width ), border_color, border_width ) ); // Bottom queue->Add( Renderer::Get().CreateLine( sf::Vector2f( frame->GetAllocation().width, frame->GetAllocation().height - border_width ), sf::Vector2f( 0.f, frame->GetAllocation().height - border_width ), border_color, border_width ) ); // Left queue->Add( Renderer::Get().CreateLine( sf::Vector2f( 0.f, frame->GetAllocation().height - border_width ), sf::Vector2f( 0.f, line_height / 2.f ), border_color, border_width ) ); float label_start_x = line_height; float label_end_x = line_height; float alignment = frame->GetAlignment().x; if( frame->GetLabel().getSize() > 0 ) { sf::Vector2f metrics = GetTextMetrics( frame->GetLabel(), font, font_size ); metrics.x += ( 2 * label_padding ); label_start_x += ( alignment * ( frame->GetAllocation().width - 2 * line_height - metrics.x ) ); label_end_x += ( metrics.x + alignment * ( frame->GetAllocation().width - 2 * line_height - metrics.x ) ); sf::Text text( frame->GetLabel(), font, font_size ); text.setPosition( label_start_x + label_padding, .0f ); text.setColor( color ); queue->Add( Renderer::Get().CreateText( text, background_color ) ); } // Top Left queue->Add( Renderer::Get().CreateLine( sf::Vector2f( 0.f, line_height / 2.f ), sf::Vector2f( label_start_x, line_height / 2.f ), border_color, border_width ) ); // Top Right queue->Add( Renderer::Get().CreateLine( sf::Vector2f( label_end_x, line_height / 2.f ), sf::Vector2f( frame->GetAllocation().width - border_width, line_height / 2.f ), border_color, border_width ) ); return queue; }
RenderQueue* BREW::CreateSpinButtonDrawable( SharedPtr<const SpinButton> spinbutton ) const { sf::Color border_color( GetProperty<sf::Color>( "BorderColor", spinbutton ) ); sf::Color background_color( GetProperty<sf::Color>( "BackgroundColor", spinbutton ) ); sf::Color text_color( GetProperty<sf::Color>( "Color", spinbutton ) ); sf::Color cursor_color( GetProperty<sf::Color>( "Color", spinbutton ) ); float text_padding( GetProperty<float>( "Padding", spinbutton ) ); float cursor_thickness( GetProperty<float>( "Thickness", spinbutton ) ); float border_width( GetProperty<float>( "BorderWidth", spinbutton ) ); int border_color_shift( GetProperty<int>( "BorderColorShift", spinbutton ) ); const sf::Font& font( *GetResourceManager().GetFont( GetProperty<std::string>( "FontName", spinbutton ) ) ); const unsigned int& font_size( GetProperty<unsigned int>( "FontSize", spinbutton ) ); float stepper_aspect_ratio( GetProperty<float>( "StepperAspectRatio", spinbutton ) ); sf::Color stepper_color( GetProperty<sf::Color>( "StepperBackgroundColor", spinbutton ) ); sf::Color stepper_border_color( GetProperty<sf::Color>( "BorderColor", spinbutton ) ); sf::Color stepper_arrow_color( GetProperty<sf::Color>( "StepperArrowColor", spinbutton ) ); RenderQueue* queue( new RenderQueue ); // Pane. queue->Add( Renderer::Get().CreatePane( sf::Vector2f( 0.f, 0.f ), sf::Vector2f( spinbutton->GetAllocation().width, spinbutton->GetAllocation().height ), border_width, background_color, border_color, -border_color_shift ) ); float button_width = ( spinbutton->GetAllocation().height / 2.f ) * stepper_aspect_ratio; // Up Stepper. queue->Add( Renderer::Get().CreatePane( sf::Vector2f( spinbutton->GetAllocation().width - button_width - border_width, border_width ), sf::Vector2f( button_width, spinbutton->GetAllocation().height / 2.f - border_width ), border_width, stepper_color, stepper_border_color, spinbutton->IsIncreaseStepperPressed() ? -border_color_shift : border_color_shift ) ); // Up Stepper Triangle. queue->Add( Renderer::Get().CreateTriangle( sf::Vector2f( spinbutton->GetAllocation().width - button_width / 2.f - border_width, ( spinbutton->IsIncreaseStepperPressed() ? 1.f : 0.f ) + border_width + spinbutton->GetAllocation().height / 6.f ), sf::Vector2f( spinbutton->GetAllocation().width - button_width / 4.f * 3.f - border_width, ( spinbutton->IsIncreaseStepperPressed() ? 1.f : 0.f ) + border_width + spinbutton->GetAllocation().height / 3.f ), sf::Vector2f( spinbutton->GetAllocation().width - button_width / 4.f - border_width, ( spinbutton->IsIncreaseStepperPressed() ? 1.f : 0.f ) + border_width + spinbutton->GetAllocation().height / 3.f ), stepper_arrow_color ) ); // Down Stepper. queue->Add( Renderer::Get().CreatePane( sf::Vector2f( spinbutton->GetAllocation().width - button_width - border_width, spinbutton->GetAllocation().height / 2.f ), sf::Vector2f( button_width, spinbutton->GetAllocation().height / 2.f - border_width ), border_width, stepper_color, stepper_border_color, spinbutton->IsDecreaseStepperPressed() ? -border_color_shift : border_color_shift ) ); // Down Stepper Triangle. queue->Add( Renderer::Get().CreateTriangle( sf::Vector2f( spinbutton->GetAllocation().width - button_width / 2.f - border_width, ( spinbutton->IsDecreaseStepperPressed() ? 1.f : 0.f ) + spinbutton->GetAllocation().height - border_width - spinbutton->GetAllocation().height / 6.f ), sf::Vector2f( spinbutton->GetAllocation().width - button_width / 4.f - border_width, ( spinbutton->IsDecreaseStepperPressed() ? 1.f : 0.f ) + spinbutton->GetAllocation().height - border_width - spinbutton->GetAllocation().height / 3.f ), sf::Vector2f( spinbutton->GetAllocation().width - button_width / 4.f * 3.f - border_width, ( spinbutton->IsDecreaseStepperPressed() ? 1.f : 0.f ) + spinbutton->GetAllocation().height - border_width - spinbutton->GetAllocation().height / 3.f ), stepper_arrow_color ) ); float line_height = GetFontLineHeight( font, font_size ); sf::Text vis_label( spinbutton->GetVisibleText(), font, font_size ); vis_label.setColor( text_color ); vis_label.setPosition( text_padding, spinbutton->GetAllocation().height / 2.f - line_height / 2.f ); queue->Add( Renderer::Get().CreateText( vis_label ) ); // Draw cursor if spinbutton is active and cursor is visible. if( spinbutton->HasFocus() && spinbutton->IsCursorVisible() ) { sf::String cursor_string( spinbutton->GetVisibleText() ); if( spinbutton->GetCursorPosition() - spinbutton->GetVisibleOffset() < cursor_string.getSize() ) { cursor_string.erase( spinbutton->GetCursorPosition() - spinbutton->GetVisibleOffset(), cursor_string.getSize() ); } // Get metrics. sf::Vector2f metrics( GetTextMetrics( cursor_string, font, font_size ) ); queue->Add( Renderer::Get().CreateRect( sf::FloatRect( metrics.x + text_padding, spinbutton->GetAllocation().height / 2.f - line_height / 2.f, cursor_thickness, line_height ), cursor_color ) ); } return queue; }