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

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

import speiger.src.coreengine.math.misc.ColorObject;
import speiger.src.coreengine.rendering.gui.GuiBase;
import speiger.src.coreengine.rendering.gui.GuiComponent;
import speiger.src.coreengine.rendering.gui.base.IButtonComponent;
import speiger.src.coreengine.rendering.gui.components.CheckBoxComponent;
import speiger.src.coreengine.rendering.gui.components.TextComponent;
import speiger.src.coreengine.rendering.gui.helper.Align;

public class ExampleEntry implements IListEntry, IButtonComponent
{
	TextComponent text = new TextComponent().setLimitedBounds(false).setAlignment(Align.LEFT_TOP, Align.LEFT_TOP);
	CheckBoxComponent checkBox = new CheckBoxComponent(ColorObject.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.setComponentBounds(owner.getFont().getFontHeight(), owner.getFont().getFontHeight());
		text.setComponentPosition(owner.getFont().getFontHeight(), 0F);
	}
	
	@Override
	public void updateState(GuiComponent comp, float scale)
	{
		text.setScale(scale);
		checkBox.setScale(scale);
		text.setComponentPosition(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.onRender(mouseX, mouseY, particalTicks);
		text.onRender(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);
	}
	
	
}
