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

Method UpdateChild

src/SFGUI/Alignment.cpp:46–73  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

44}
45
46void Alignment::UpdateChild() {
47 auto child = GetChild();
48
49 if( !child ) {
50 return;
51 }
52
53 sf::FloatRect allocation( GetAllocation() );
54
55 sf::Vector2f spare_space( allocation.size );
56 spare_space -= child->GetRequisition();
57 spare_space.x *= 1.f - GetScale().x;
58 spare_space.y *= 1.f - GetScale().y;
59
60 if( ( spare_space.x < 0 ) || ( spare_space.y < 0 ) ) {
61#if defined( SFGUI_DEBUG )
62 std::cerr << "SFGUI warning: Alignment got a smaller allocation than it requested.\n";
63 return;
64#endif
65 }
66
67 allocation.position.x = spare_space.x * GetAlignment().x;
68 allocation.position.y = spare_space.y * GetAlignment().y;
69 allocation.size.x -= spare_space.x;
70 allocation.size.y -= spare_space.y;
71
72 child->SetAllocation( allocation );
73}
74
75}

Callers

nothing calls this directly

Calls 1

SetAllocationMethod · 0.80

Tested by

no test coverage detected