MCPcopy Create free account
hub / github.com/bumptop/BumpTop / reLayout

Method reLayout

trunk/win/Source/BT_OverlayComponent.cpp:864–945  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

862}
863
864void OverlayLayout::reLayout()
865{
866 // ensure components exist
867 if (_components.empty())
868 return;
869
870 // get this layout's bounds
871 Vec3 dims = getSize();
872
873 // get the max children bounds
874 Vec3 maxDims;
875 Bounds maxBounds;
876 for (int i = 0; i < _components.size(); ++i)
877 {
878 OverlayComponent * c = _components[i];
879 maxBounds.combine(c->getBounds());
880 }
881 maxBounds.getDimensions(maxDims);
882
883 if (!getStyle().isFloating())
884 {
885 // reset the children to 0,0
886 for (int i = 0; i < _components.size(); ++i)
887 {
888 OverlayComponent * c = _components[i];
889 c->setPosition(Vec3(0.0f));
890 }
891 }
892 else
893 {
894 Vec3 pos = getStyle().getOffset();
895 if (pos.magnitudeSquared() > 0.0f)
896 {
897 Vec3 absPos;
898 absPos.x = abs(pos.x);
899 absPos.y = abs(pos.y);
900
901 // determine the position based on the absolute or percentage offset
902 // x percentage check
903 bool isXPercentage = (0.0f <= absPos.x && absPos.x <= 1.0f);
904 if (isXPercentage)
905 {
906 if (pos.x < 0.0f)
907 pos.x = dims.x * (1.0f - absPos.x);
908 else
909 pos.x = dims.x * absPos.x;
910 }
911 // y percentage check
912 bool isYPercentage = (0.0f <= absPos.y && absPos.y <= 1.0f);
913 if (isYPercentage)
914 {
915 if (pos.y < 0.0f)
916 pos.y = dims.y * (1.0f - absPos.y);
917 else
918 pos.y = dims.y * absPos.y;
919 }
920
921 // position them according to the absolute positions (if such exist)

Callers 3

setSizeMethod · 0.45

Calls 15

getBoundsMethod · 0.80
getDimensionsMethod · 0.80
getPaddingMethod · 0.80
isAlignedOnEdgeMethod · 0.80
getSpacingMethod · 0.80
absFunction · 0.50
itemsFunction · 0.50
emptyMethod · 0.45
sizeMethod · 0.45
combineMethod · 0.45
isFloatingMethod · 0.45
setPositionMethod · 0.45

Tested by

no test coverage detected