Added Base Classes for interactable List/TreeEntries
This commit is contained in:
parent
3bc7dcdf44
commit
9c947c4898
|
@ -41,6 +41,7 @@ public class WindowComponent extends PanelComponent implements IButtonComponent,
|
||||||
public static final int DEFAULT_FLAGS = WINDOW_FLAGS | FLAG_RESIZEABLE | FLAG_MOVEABLE;
|
public static final int DEFAULT_FLAGS = WINDOW_FLAGS | FLAG_RESIZEABLE | FLAG_MOVEABLE;
|
||||||
public static final int FIXED_SIZE_WINDOW = WINDOW_FLAGS | FLAG_MOVEABLE;
|
public static final int FIXED_SIZE_WINDOW = WINDOW_FLAGS | FLAG_MOVEABLE;
|
||||||
public static final int FIXED_SIZE_POPUP = WINDOW_FLAG_CLOSEABLE | FLAG_MOVEABLE;
|
public static final int FIXED_SIZE_POPUP = WINDOW_FLAG_CLOSEABLE | FLAG_MOVEABLE;
|
||||||
|
public static final int DYNAMIC_POPUP = FIXED_SIZE_POPUP | FLAG_RESIZEABLE;
|
||||||
public static final int UNCLOSEABLE_WINDOW = WINDOW_FLAG_MINIMIZEABLE | FLAG_RESIZEABLE | FLAG_MOVEABLE;
|
public static final int UNCLOSEABLE_WINDOW = WINDOW_FLAG_MINIMIZEABLE | FLAG_RESIZEABLE | FLAG_MOVEABLE;
|
||||||
public static final int SUB_WINDOW = WINDOW_FLAG_MINIMIZEABLE | FLAG_RESIZEABLE | FLAG_RESIZE_INVERT;
|
public static final int SUB_WINDOW = WINDOW_FLAG_MINIMIZEABLE | FLAG_RESIZEABLE | FLAG_RESIZE_INVERT;
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,88 @@
|
||||||
|
package speiger.src.coreengine.rendering.gui.components.list;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
|
import speiger.src.coreengine.rendering.gui.GuiComponent;
|
||||||
|
import speiger.src.coreengine.rendering.gui.base.IButtonComponent;
|
||||||
|
|
||||||
|
public class BaseClickableListEntry extends BaseListEntry implements IButtonComponent
|
||||||
|
{
|
||||||
|
@Override
|
||||||
|
public boolean isComponentColliding(int mouseX, int mouseY)
|
||||||
|
{
|
||||||
|
for(int i = 0,m=components.size();i<m;i++)
|
||||||
|
{
|
||||||
|
GuiComponent comp = components.get(i);
|
||||||
|
if(comp instanceof IButtonComponent && ((IButtonComponent)comp).isComponentColliding(mouseX, mouseY)) return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onClick(int button, int mouseX, int mouseY)
|
||||||
|
{
|
||||||
|
for(int i = 0,m=components.size();i<m;i++)
|
||||||
|
{
|
||||||
|
GuiComponent comp = components.get(i);
|
||||||
|
if(!(comp instanceof IButtonComponent)) continue;
|
||||||
|
IButtonComponent btn = (IButtonComponent)comp;
|
||||||
|
if(btn.isComponentColliding(mouseX, mouseY) && btn.onClick(button, mouseX, mouseY)) return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onDrag(int mouseX, int mouseY)
|
||||||
|
{
|
||||||
|
for(int i = 0,m=components.size();i<m;i++)
|
||||||
|
{
|
||||||
|
GuiComponent comp = components.get(i);
|
||||||
|
if(comp instanceof IButtonComponent && ((IButtonComponent)comp).onDrag(mouseX, mouseY)) return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onRelease(int button, int mouseX, int mouseY)
|
||||||
|
{
|
||||||
|
for(int i = 0,m=components.size();i<m;i++)
|
||||||
|
{
|
||||||
|
GuiComponent comp = components.get(i);
|
||||||
|
if(comp instanceof IButtonComponent)
|
||||||
|
{
|
||||||
|
IButtonComponent btn = (IButtonComponent)comp;
|
||||||
|
if(btn.isComponentColliding(mouseX, mouseY))
|
||||||
|
{
|
||||||
|
btn.onRelease(button, mouseX, mouseY);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
btn.onFocusLost();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onScroll(int scroll, int mouseX, int mouseY)
|
||||||
|
{
|
||||||
|
for(int i = 0,m=components.size();i<m;i++)
|
||||||
|
{
|
||||||
|
GuiComponent comp = components.get(i);
|
||||||
|
if(!(comp instanceof IButtonComponent)) continue;
|
||||||
|
IButtonComponent btn = (IButtonComponent)comp;
|
||||||
|
if(btn.isComponentColliding(mouseX, mouseY) && btn.onScroll(scroll, mouseX, mouseY)) return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void collectTooltips(GuiComponent comp, int mouseX, int mouseY, float particalTicks, Map<UUID, GuiComponent> collector)
|
||||||
|
{
|
||||||
|
for(int i = 0,m=components.size();i<m;i++)
|
||||||
|
{
|
||||||
|
GuiComponent subComb = components.get(i);
|
||||||
|
if(!(subComb instanceof IButtonComponent)) continue;
|
||||||
|
subComb.collectTooltips(mouseX, mouseY, particalTicks, collector);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,11 +1,13 @@
|
||||||
package speiger.src.coreengine.rendering.gui.components.tree;
|
package speiger.src.coreengine.rendering.gui.components.tree;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
import speiger.src.coreengine.rendering.gui.GuiComponent;
|
import speiger.src.coreengine.rendering.gui.GuiComponent;
|
||||||
import speiger.src.coreengine.rendering.gui.base.IButtonComponent;
|
import speiger.src.coreengine.rendering.gui.base.IButtonComponent;
|
||||||
|
|
||||||
public class BaseClickableTreeEntry extends BaseTreeEntry implements IButtonComponent
|
public class BaseClickableTreeEntry extends BaseTreeEntry implements IButtonComponent
|
||||||
{
|
{
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isComponentColliding(int mouseX, int mouseY)
|
public boolean isComponentColliding(int mouseX, int mouseY)
|
||||||
{
|
{
|
||||||
|
@ -73,4 +75,14 @@ public class BaseClickableTreeEntry extends BaseTreeEntry implements IButtonComp
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void collectTooltips(GuiComponent comp, int mouseX, int mouseY, float particalTicks, Map<UUID, GuiComponent> collector)
|
||||||
|
{
|
||||||
|
for(int i = 0,m=components.size();i<m;i++)
|
||||||
|
{
|
||||||
|
GuiComponent subComb = components.get(i);
|
||||||
|
if(!(subComb instanceof IButtonComponent)) continue;
|
||||||
|
subComb.collectTooltips(mouseX, mouseY, particalTicks, collector);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue