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

Method CalculateRequisition

src/SFGUI/Box.cpp:102–139  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

100}
101
102sf::Vector2f Box::CalculateRequisition() {
103 sf::Vector2f requisition( 0.f, 0.f );
104 unsigned int num_visible( 0 );
105
106 for( const auto& child : m_box_children ) {
107 if( !IsChildInteresting( child.widget ) ) {
108 continue;
109 }
110
111 ++num_visible;
112
113 sf::Vector2f child_requisition( child.widget->GetRequisition() );
114
115 if( m_orientation == Orientation::HORIZONTAL ) {
116 requisition.x += child_requisition.x;
117 requisition.y = std::max( requisition.y, child_requisition.y );
118 }
119 else {
120 requisition.x = std::max( requisition.x, child_requisition.x );
121 requisition.y += child_requisition.y;
122 }
123 }
124
125 if( num_visible > 1 ) {
126 if( m_orientation == Orientation::HORIZONTAL ) {
127 requisition.x += static_cast<float>( num_visible - 1 ) * GetSpacing();
128 }
129 else {
130 requisition.y += static_cast<float>( num_visible - 1 ) * GetSpacing();
131 }
132 }
133
134 float gap( Context::Get().GetEngine().GetProperty<float>( "Gap", shared_from_this() ) );
135 requisition.x += 2 * gap;
136 requisition.y += 2 * gap;
137
138 return requisition;
139}
140
141void Box::HandleSizeChange() {
142 AllocateChildren();

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected