package speiger.src.coreengine.rendering.guiOld.components.list;

import java.util.Map;
import java.util.UUID;

import speiger.src.coreengine.math.color.ColorUtils;
import speiger.src.coreengine.rendering.guiOld.GuiBase;
import speiger.src.coreengine.rendering.guiOld.GuiComponent;
import speiger.src.coreengine.rendering.guiOld.base.IButtonComponent;
import speiger.src.coreengine.rendering.guiOld.components.CheckBoxComponent;
import speiger.src.coreengine.rendering.guiOld.components.TextComponent;
import speiger.src.coreengine.rendering.guiOld.helper.Align;

public class ExampleEntry implements IListEntry, IButtonComponent
{
	TextComponent text = new TextComponent().limit(false).align(Align.LEFT_TOP, Align.LEFT_TOP);
	CheckBoxComponent checkBox = new CheckBoxComponent(ColorUtils.ORANGE);
	
	public ExampleEntry(String s)
	{
		text.setText(s);
	}
	
	@Override
	public float getWidth()
	{
		return text.getBox().getMinX() + text.getMetadata().getMaxWidth();
	}
	
	@Override
	public void init(GuiComponent comp, GuiBase owner)
	{
		text.setOwner(owner);
		checkBox.setOwner(owner);
		checkBox.bounds(owner.getFont().height(), owner.getFont().height());
		text.set(owner.getFont().height(), 0F);
	}
	
	@Override
	public void updateState(GuiComponent comp, float scale)
	{
		text.setScale(scale);
		checkBox.setScale(scale);
		text.set(checkBox.getBox().getWidth(), 0F);
	}
	
	@Override
	public void onClosed()
	{
	}
	
	@Override
	public void onFixedUpdate()
	{
		
	}
	
	@Override
	public void onRender(GuiComponent comp, boolean enabled, int mouseX, int mouseY, float particalTicks)
	{
		checkBox.render(mouseX, mouseY, particalTicks);
		text.render(mouseX, mouseY, particalTicks);
	}

	@Override
	public void collectTooltips(GuiComponent comp, int mouseX, int mouseY, float particalTicks, Map<UUID, GuiComponent> collector)
	{
		
	}
	
	@Override
	public boolean isComponentColliding(int mouseX, int mouseY)
	{
		return checkBox.isComponentColliding(mouseX, mouseY);
	}

	@Override
	public boolean onClick(int button, int mouseX, int mouseY)
	{
		return checkBox.onClick(button, mouseX, mouseY);
	}

	@Override
	public boolean onDrag(int mouseX, int mouseY)
	{
		return checkBox.onDrag(mouseX, mouseY);
	}

	@Override
	public void onRelease(int button, int mouseX, int mouseY)
	{
		checkBox.onRelease(button, mouseX, mouseY);
	}
	
	
}
