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

Method HandleSizeChange

src/SFGUI/Frame.cpp:55–76  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

53}
54
55void Frame::HandleSizeChange() {
56 auto child = GetChild();
57 if( !child ) {
58 return;
59 }
60
61 float padding( Context::Get().GetEngine().GetProperty<float>( "Padding", shared_from_this() ) );
62 float border_width( Context::Get().GetEngine().GetProperty<float>( "BorderWidth", shared_from_this() ) );
63 const std::string& font_name( Context::Get().GetEngine().GetProperty<std::string>( "FontName", shared_from_this() ) );
64 unsigned int font_size( Context::Get().GetEngine().GetProperty<unsigned int>( "FontSize", shared_from_this() ) );
65 const sf::Font& font( *Context::Get().GetEngine().GetResourceManager().GetFont( font_name ) );
66 float line_height( Context::Get().GetEngine().GetFontLineHeight( font, font_size ) );
67
68 sf::FloatRect allocation( GetAllocation() );
69
70 allocation.position.x = padding + 2 * border_width;
71 allocation.position.y = line_height + padding + 2 * border_width;
72 allocation.size.x -= 2 * padding + 4 * border_width;
73 allocation.size.y -= line_height + 2 * padding + 4 * border_width;
74
75 child->SetAllocation( allocation );
76}
77
78}

Callers

nothing calls this directly

Calls 2

GetFontLineHeightMethod · 0.80
SetAllocationMethod · 0.80

Tested by

no test coverage detected