| 197 | } |
| 198 | |
| 199 | void ScrolledWindow::RecalculateContentAllocation() const { |
| 200 | float scrollbar_spacing( Context::Get().GetEngine().GetProperty<float>( "ScrollbarSpacing", shared_from_this() ) ); |
| 201 | float border_width( Context::Get().GetEngine().GetProperty<float>( "BorderWidth", shared_from_this() ) ); |
| 202 | |
| 203 | m_content_allocation = GetAllocation(); |
| 204 | |
| 205 | m_content_allocation.position.x = border_width; |
| 206 | m_content_allocation.position.y = border_width; |
| 207 | m_content_allocation.size.x -= 2.f * border_width; |
| 208 | m_content_allocation.size.y -= 2.f * border_width; |
| 209 | |
| 210 | if( IsVerticalScrollbarVisible() ) { |
| 211 | m_content_allocation.size.x -= ( m_vertical_scrollbar->GetRequisition().x + scrollbar_spacing ); |
| 212 | |
| 213 | if( ( m_placement == Placement::TOP_RIGHT ) || ( m_placement == Placement::BOTTOM_RIGHT ) ) { // Content placed at Right |
| 214 | m_content_allocation.position.x += ( m_vertical_scrollbar->GetRequisition().x + scrollbar_spacing ); |
| 215 | } |
| 216 | } |
| 217 | |
| 218 | if( IsHorizontalScrollbarVisible() ) { |
| 219 | m_content_allocation.size.y -= ( m_horizontal_scrollbar->GetRequisition().y + scrollbar_spacing ); |
| 220 | |
| 221 | if( ( m_placement == Placement::BOTTOM_RIGHT ) || ( m_placement == Placement::BOTTOM_LEFT ) ) { // Content placed at Bottom |
| 222 | m_content_allocation.position.y += ( m_horizontal_scrollbar->GetRequisition().y + scrollbar_spacing ); |
| 223 | } |
| 224 | } |
| 225 | |
| 226 | if( ( m_placement == Placement::TOP_LEFT ) || ( m_placement == Placement::TOP_RIGHT ) ) { // Content placed at Top |
| 227 | m_horizontal_scrollbar->SetAllocation( |
| 228 | sf::FloatRect( |
| 229 | { m_content_allocation.position.x - border_width, m_content_allocation.size.y + 2.f * border_width + scrollbar_spacing }, |
| 230 | { m_content_allocation.size.x + 2.f * border_width, m_horizontal_scrollbar->GetRequisition().y } |
| 231 | ) |
| 232 | ); |
| 233 | } |
| 234 | else { // Content placed at Bottom |
| 235 | m_horizontal_scrollbar->SetAllocation( |
| 236 | sf::FloatRect( |
| 237 | { m_content_allocation.position.x - border_width, 0.f }, |
| 238 | { m_content_allocation.size.x + 2.f * border_width, m_horizontal_scrollbar->GetRequisition().y } |
| 239 | ) |
| 240 | ); |
| 241 | } |
| 242 | |
| 243 | if( ( m_placement == Placement::TOP_LEFT ) || ( m_placement == Placement::BOTTOM_LEFT ) ) { // Content placed at Left |
| 244 | m_vertical_scrollbar->SetAllocation( |
| 245 | sf::FloatRect( |
| 246 | { m_content_allocation.size.x + 2.f * border_width + scrollbar_spacing, m_content_allocation.position.y - border_width }, |
| 247 | { m_vertical_scrollbar->GetRequisition().x, m_content_allocation.size.y + 2.f * border_width } |
| 248 | ) |
| 249 | ); |
| 250 | } |
| 251 | else { // Content placed at Right |
| 252 | m_vertical_scrollbar->SetAllocation( |
| 253 | sf::FloatRect( |
| 254 | { 0.f, m_content_allocation.position.y - border_width }, |
| 255 | { m_vertical_scrollbar->GetRequisition().x, m_content_allocation.size.y + 2.f * border_width } |
| 256 | ) |
nothing calls this directly
no test coverage detected