| 27 | } |
| 28 | |
| 29 | sf::Vector2f Frame::CalculateRequisition() { |
| 30 | float padding( Context::Get().GetEngine().GetProperty<float>( "Padding", shared_from_this() ) ); |
| 31 | const std::string& font_name( Context::Get().GetEngine().GetProperty<std::string>( "FontName", shared_from_this() ) ); |
| 32 | unsigned int font_size( Context::Get().GetEngine().GetProperty<unsigned int>( "FontSize", shared_from_this() ) ); |
| 33 | const sf::Font& font( *Context::Get().GetEngine().GetResourceManager().GetFont( font_name ) ); |
| 34 | float label_padding( Context::Get().GetEngine().GetProperty<float>( "LabelPadding", shared_from_this() ) ); |
| 35 | float border_width( Context::Get().GetEngine().GetProperty<float>( "BorderWidth", shared_from_this() ) ); |
| 36 | |
| 37 | sf::Vector2f requisition( Context::Get().GetEngine().GetTextStringMetrics( m_label, font, font_size ) ); |
| 38 | requisition.x += 2.f * label_padding + 4.f * border_width + 2.f * padding; |
| 39 | requisition.y = Context::Get().GetEngine().GetFontLineHeight( font, font_size ) + 4.f * border_width; |
| 40 | |
| 41 | auto child = GetChild(); |
| 42 | if( child ) { |
| 43 | requisition.x = std::max( 4.f * border_width + 2.f * padding + child->GetRequisition().x, requisition.x ); |
| 44 | requisition.y += 2.f * padding + child->GetRequisition().y; |
| 45 | } |
| 46 | |
| 47 | return requisition; |
| 48 | } |
| 49 | |
| 50 | const std::string& Frame::GetName() const { |
| 51 | static const std::string name( "Frame" ); |
nothing calls this directly
no test coverage detected