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

Method packHorizontal

src/eepp/ui/uilinearlayout.cpp:285–411  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

283}
284
285void UILinearLayout::packHorizontal() {
286 if ( mPacking )
287 return;
288 mPacking = true;
289 bool sizeChanged = false;
290 Sizef size( getPixelsSize() );
291
292 if ( getLayoutWidthPolicy() == SizePolicy::MatchParent ) {
293 Float w = getMatchParentWidth();
294
295 if ( (int)w != (int)getPixelsSize().getWidth() ) {
296 sizeChanged = true;
297 size.setWidth( w );
298 }
299 }
300
301 if ( getLayoutHeightPolicy() == SizePolicy::MatchParent && 0 == getLayoutWeight() ) {
302 Float h = getMatchParentHeight();
303
304 if ( (int)h != (int)getPixelsSize().getHeight() ) {
305 sizeChanged = true;
306 size.setHeight( h );
307 }
308 }
309
310 if ( sizeChanged )
311 setInternalPixelsSize( size );
312
313 applyHeightPolicyOnChildren();
314
315 Float curX = mPaddingPx.Left;
316 Float maxY = 0;
317 Sizei freeSize = getTotalUsedSize();
318
319 Node* child = mChild;
320
321 while ( NULL != child ) {
322 if ( child->isWidget() && child->isVisible() ) {
323 UIWidget* widget = static_cast<UIWidget*>( child );
324 Rectf margin = widget->getLayoutPixelsMargin();
325
326 curX += eeceil( margin.Left );
327
328 Vector2f pos( curX, mPaddingPx.Top );
329
330 if ( widget->getLayoutWeight() != 0 ) {
331 Float totSize =
332 ( getLayoutWidthPolicy() == SizePolicy::MatchParent ||
333 getLayoutWidthPolicy() == SizePolicy::Fixed )
334 ? getPixelsSize().getWidth() - mPaddingPx.Left - mPaddingPx.Right
335 : getParent()->getPixelsSize().getWidth() - mLayoutMarginPx.Right -
336 mLayoutMarginPx.Left - mPaddingPx.Left - mPaddingPx.Right;
337 Float newSize = eemax(
338 eeceil( totSize - freeSize.getWidth() ) * widget->getLayoutWeight(), 0.f );
339
340 widget->setPixelsSize( newSize, widget->getPixelsSize().getHeight() );
341 }
342

Callers

nothing calls this directly

Calls 15

getParentFunction · 0.85
eemaxFunction · 0.85
getVerticalAlignFunction · 0.85
isWidgetMethod · 0.80
getLayoutWeightMethod · 0.80
getLayoutGravityMethod · 0.80
setPixelsPositionMethod · 0.80
getNextNodeMethod · 0.80
isUINodeMethod · 0.80
ownsChildPositionMethod · 0.80
getWidthMethod · 0.45
setWidthMethod · 0.45

Tested by

no test coverage detected