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

Method SetAllocation

src/SFGUI/Widget.cpp:125–156  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

123}
124
125void Widget::SetAllocation( const sf::FloatRect& rect ) {
126 sf::FloatRect oldallocation( m_allocation );
127
128 // Make sure allocation is pixel-aligned.
129 m_allocation.position.x = std::floor( rect.position.x + .5f );
130 m_allocation.position.y = std::floor( rect.position.y + .5f );
131 m_allocation.size.x = std::floor( rect.size.x + .5f );
132 m_allocation.size.y = std::floor( rect.size.y + .5f );
133
134 if(
135 oldallocation.position.y == m_allocation.position.y &&
136 oldallocation.position.x == m_allocation.position.x &&
137 oldallocation.size.x == m_allocation.size.x &&
138 oldallocation.size.y == m_allocation.size.y
139 ) {
140 // Nothing even changed. Save the hierarchy the trouble.
141 return;
142 }
143
144 if( ( oldallocation.position.y != m_allocation.position.y ) || ( oldallocation.position.x != m_allocation.position.x ) ) {
145 HandlePositionChange();
146 HandleAbsolutePositionChange();
147 }
148
149 if( ( oldallocation.size.x != m_allocation.size.x ) || ( oldallocation.size.y != m_allocation.size.y ) ) {
150 HandleSizeChange();
151
152 Invalidate();
153
154 GetSignals().Emit( OnSizeAllocate );
155 }
156}
157
158void Widget::RequestResize() {
159 m_requisition = CalculateRequisition();

Callers 15

RecalculateSizeMethod · 0.80
AllocateChildMethod · 0.80
AddWithViewportMethod · 0.80
HandleSizeChangeMethod · 0.80
AllocateChildrenMethod · 0.80
AllocateChildrenMethod · 0.80
UpdateChildMethod · 0.80
MoveMethod · 0.80
HandleAddMethod · 0.80
InvalidateImplMethod · 0.80
HandleSizeChangeMethod · 0.80

Calls 1

EmitMethod · 0.80

Tested by

no test coverage detected