package speiger.src.coreengine.rendering.guiOld.helper.constrains;

public class ParentConstrain extends Constrain
{
	float padding;
	boolean inverted;
	
	public ParentConstrain()
	{
		this(0F);
	}
	
	public ParentConstrain(float padding)
	{
		this.padding = padding;
	}
	
	public ParentConstrain invert()
	{
		inverted = true;
		return this;
	}
	
	@Override
	public void apply()
	{
		if(inverted)
		{
			set(target.isPosition() ? get(target.toWidth()) - padding : padding * 2);
			return;
		}
		set(target.isPosition() ? padding : get(target) - (padding * 2));
	}
}
