void Widget::AllocateSize( const sf::FloatRect& rect ) const { sf::FloatRect oldallocation( m_allocation ); // Make sure allocation is pixel-aligned. m_allocation.Left = std::floor( rect.Left + .5f ); m_allocation.Top = std::floor( rect.Top + .5f ); m_allocation.Width = std::floor( rect.Width + .5f ); m_allocation.Height = std::floor( rect.Height + .5f ); if( oldallocation.Top == m_allocation.Top && oldallocation.Left == m_allocation.Left && oldallocation.Width == m_allocation.Width && oldallocation.Height == m_allocation.Height ) { // Nothing even changed. Save the hierarchy the trouble. return; } HandleAbsolutePositionChange(); HandleSizeAllocate( oldallocation ); OnSizeAllocate(); Invalidate(); }
void Widget::SetAllocation( const sf::FloatRect& rect ) { sf::FloatRect oldallocation( m_allocation ); // Make sure allocation is pixel-aligned. m_allocation.left = std::floor( rect.left + .5f ); m_allocation.top = std::floor( rect.top + .5f ); m_allocation.width = std::floor( rect.width + .5f ); m_allocation.height = std::floor( rect.height + .5f ); if( oldallocation.top == m_allocation.top && oldallocation.left == m_allocation.left && oldallocation.width == m_allocation.width && oldallocation.height == m_allocation.height ) { // Nothing even changed. Save the hierarchy the trouble. return; } if( ( oldallocation.top != m_allocation.top ) || ( oldallocation.left != m_allocation.left ) ) { HandlePositionChange(); HandleAbsolutePositionChange(); } if( ( oldallocation.width != m_allocation.width ) || ( oldallocation.height != m_allocation.height ) ) { HandleSizeChange(); Invalidate(); GetSignals().Emit( OnSizeAllocate ); } }
void Widget::SetPosition( const sf::Vector2f& position ) const { sf::FloatRect oldallocation( GetAllocation() ); // Make sure allocation is pixel-aligned. m_allocation.Left = std::floor( position.x + .5f ); m_allocation.Top = std::floor( position.y + .5f ); if( oldallocation.Top == m_allocation.Top && oldallocation.Left == m_allocation.Left ) { // Nothing even changed. Save the hierarchy the trouble. return; } HandleAbsolutePositionChange(); HandleSizeAllocate( oldallocation ); if( m_drawable ) { m_drawable->SetPosition( GetAbsolutePosition() ); } OnSizeAllocate(); }