| 121 | } |
| 122 | |
| 123 | void 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 | |
| 148 | void Button::HandleStateChange( State old_state ) { |
| 149 | AllocateChild(); |
nothing calls this directly
no test coverage detected