MCPcopy Create free account
hub / github.com/TankOs/SFGUI / CalculateRequisition

Method CalculateRequisition

src/SFGUI/CheckButton.cpp:27–42  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

25}
26
27sf::Vector2f CheckButton::CalculateRequisition() {
28 const std::string& font_name( Context::Get().GetEngine().GetProperty<std::string>( "FontName", shared_from_this() ) );
29 unsigned int font_size( Context::Get().GetEngine().GetProperty<unsigned int>( "FontSize", shared_from_this() ) );
30 const sf::Font& font( *Context::Get().GetEngine().GetResourceManager().GetFont( font_name ) );
31 float spacing( Context::Get().GetEngine().GetProperty<float>( "Spacing", shared_from_this() ) );
32 float box_size( Context::Get().GetEngine().GetProperty<float>( "BoxSize", shared_from_this() ) );
33 sf::Vector2f requisition( box_size, box_size );
34
35 if( GetLabel().getSize() > 0 ) {
36 auto metrics = Context::Get().GetEngine().GetTextStringMetrics( GetLabel(), font, font_size );
37 requisition.x += metrics.x + spacing;
38 requisition.y = std::max( requisition.y, Context::Get().GetEngine().GetFontLineHeight( font, font_size ) );
39 }
40
41 return requisition;
42}
43
44void CheckButton::HandleSizeChange() {
45 float spacing( Context::Get().GetEngine().GetProperty<float>( "Spacing", shared_from_this() ) );

Callers

nothing calls this directly

Calls 2

GetTextStringMetricsMethod · 0.80
GetFontLineHeightMethod · 0.80

Tested by

no test coverage detected