private static void LayoutAfterHeightChanged(GLControl parent, GLControlChildren glControlChildren) { foreach (var control in glControlChildren) { GUIAnchorStyles anchor = control.Anchor; if ((anchor & bottomTopAnchor) == bottomTopAnchor) { control.Height = parent.height - control.bottom - control.top; } else if ((anchor & bottomAnchor) == bottomAnchor) { control.top = parent.height - control.bottom - control.height; } else if ((anchor & topAnchor) == topAnchor) { control.bottom = parent.height - control.top - control.height; control.absBottom = parent.absBottom + control.bottom; } else // if ((anchor & noneAnchor) == noneAnchor) { int diff = parent.height - control.top - control.height - control.bottom; int halfDiff = diff / 2; int OtherHalfDiff = diff - halfDiff; control.bottom += halfDiff; control.absBottom = parent.absBottom + control.bottom; control.top += OtherHalfDiff; } } }
private static void LayoutAfterWidthChanged(GLControl parent, GLControlChildren glControlChildren) { foreach (var control in glControlChildren) { if (control.parent != parent) { throw new Exception("Parent info not matching!"); } GUIAnchorStyles anchor = control.Anchor; if ((anchor & leftRightAnchor) == leftRightAnchor) { control.Width = parent.width - control.left - control.right; } else if ((anchor & leftAnchor) == leftAnchor) { control.right = parent.width - control.left - control.width; } else if ((anchor & rightAnchor) == rightAnchor) { control.left = parent.width - control.right - control.width; control.absLeft = parent.absLeft + control.left; } else // if ((anchor & noneAnchor) == noneAnchor) { int diff = parent.width - control.left - control.width - control.right; int halfDiff = diff / 2; int OtherHalfDiff = diff - halfDiff; control.left += halfDiff; control.absLeft = parent.absLeft + control.left; control.right += OtherHalfDiff; } } }