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

Method AllocateChild

src/SFGUI/Button.cpp:123–146  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

121}
122
123void Button::AllocateChild() {
124 auto child = GetChild();
125
126 if( !child ) {
127 return;
128 }
129
130 float padding( Context::Get().GetEngine().GetProperty<float>( "Padding", shared_from_this() ) );
131 float border_width( Context::Get().GetEngine().GetProperty<float>( "BorderWidth", shared_from_this() ) );
132
133 sf::FloatRect allocation( GetAllocation() );
134
135 allocation.position.x = padding + border_width;
136 allocation.position.y = padding + border_width;
137 allocation.size.x = child->GetRequisition().x;
138 allocation.size.y -= border_width * 2.f + padding * 2.f;
139
140 if( GetState() == State::ACTIVE ) {
141 allocation.position.x += border_width;
142 allocation.position.y += border_width;
143 }
144
145 child->SetAllocation( allocation );
146}
147
148void Button::HandleStateChange( State old_state ) {
149 AllocateChild();

Callers

nothing calls this directly

Calls 1

SetAllocationMethod · 0.80

Tested by

no test coverage detected