MCPcopy Create free account
hub / github.com/SpartanJ/eepp / updateLayout

Method updateLayout

src/eepp/ui/tablelayouter.cpp:280–531  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

278}
279
280void TableLayouter::updateLayout() {
281 if ( !mContainer->isVisible() )
282 return;
283
284 if ( mPacking )
285 return;
286 mPacking = true;
287
288 setMatchParentIfNeededVerticalGrowth();
289
290 const StyleSheetProperty* prop = nullptr;
291 UIWidget* widget = mContainer->asType<UIWidget>();
292 if ( widget->getLayoutWidthPolicy() == SizePolicy::Fixed && widget->getUIStyle() &&
293 ( prop = widget->getUIStyle()->getProperty( PropertyId::Width ) ) ) {
294 widget->asType<UINode>()->setInternalPixelsSize(
295 { widget->lengthFromValue( *prop ), widget->getPixelsSize().getHeight() } );
296 }
297
298 computeIntrinsicWidths();
299
300 if ( mRows.empty() ) {
301 mPacking = false;
302 return;
303 }
304
305 size_t maxCols = mColMinWidths.size();
306 mColWidths.assign( maxCols, 0.f );
307 Float paddingH = mContainer->getPixelsPadding().Left + mContainer->getPixelsPadding().Right;
308 Float containerWidth = mContainer->getPixelsSize().getWidth();
309 Float availableWidth = sanitizeFloat(
310 std::max( 0.f, containerWidth - paddingH - ( maxCols + 1 ) * mCellspacing ) );
311
312 if ( availableWidth <= 0.f || maxCols == 0 ) {
313 mPacking = false;
314 return;
315 }
316
317 Float totalMin = 0.f;
318 Float totalMax = 0.f;
319 for ( size_t i = 0; i < maxCols; ++i ) {
320 totalMin += sanitizeFloat( mColMinWidths[i] );
321 totalMax += sanitizeFloat( mColMaxWidths[i] );
322 }
323
324 Float tableUsedWidth = availableWidth;
325
326 // Assign column widths
327 if ( mTableLayout == TableLayout::Fixed ) {
328 Float sumOfSpecifiedWidths = 0.f;
329 size_t unspecifiedCount = 0;
330 for ( size_t i = 0; i < maxCols; ++i ) {
331 if ( mColSpecifiedWidths[i] > 0.f ) {
332 sumOfSpecifiedWidths += mColSpecifiedWidths[i];
333 mColWidths[i] = mColSpecifiedWidths[i];
334 } else {
335 unspecifiedCount++;
336 }
337 }

Callers

nothing calls this directly

Calls 15

sanitizeFloatFunction · 0.85
getUIStyleMethod · 0.80
lengthFromValueMethod · 0.80
assignMethod · 0.80
setLayoutWidthPolicyMethod · 0.80
setLayoutHeightPolicyMethod · 0.80
getColspanMethod · 0.80
setPixelsPositionMethod · 0.80
computeIntrinsicWidthsFunction · 0.50

Tested by

no test coverage detected