protected void TryChangeSizeOf(IPanelGroupElement element, PanelDirection direction, float deltaSize) { if (element.IsNull() || deltaSize <= MIN_SIZE_TOLERANCE || element.GetSurroundingElement(direction).IsNull()) { return; } resizePropsIndex = 0; IPanelGroupElement surroundingElement = element.GetSurroundingElement(direction); element = surroundingElement.GetSurroundingElement(direction.Opposite()); AddResizeProperty(element); float deltaMovement = TryChangeSizeOfInternal(surroundingElement, direction, deltaSize); if (resizePropsIndex > 1) { ResizeElementHelper(0, direction, deltaMovement); for (int i = 0; i < resizePropsIndex; i++) { ElementDirtyProperties properties = resizeProperties[i]; Vector2 position = properties.element.Position + new Vector2(properties.posX, properties.posY); Vector2 size = properties.element.Size + new Vector2(properties.sizeX, properties.sizeY); UpdateBoundsOf(properties.element, position, size); } } }
private void ResizeElementHelper(int resizePropsIndex, PanelDirection direction, float deltaSize) { ElementDirtyProperties properties = resizeProperties[resizePropsIndex]; if (direction == PanelDirection.Left) { properties.posX -= deltaSize; properties.sizeX += deltaSize; } else if (direction == PanelDirection.Top) { properties.sizeY += deltaSize; } else if (direction == PanelDirection.Right) { properties.sizeX += deltaSize; } else { properties.posY -= deltaSize; properties.sizeY += deltaSize; } }