use of de.johni0702.minecraft.gui.utils.lwjgl.ReadablePoint in project jGui by ReplayMod.
the class AbstractGuiVerticalList method isOnBackground.
private boolean isOnBackground(ReadablePoint point) {
int width = lastRenderSize.getWidth();
int listPanelWidth = listPanel.calcMinSize().getWidth();
return point.getX() < width / 2 - listPanelWidth / 2 || width / 2 + listPanelWidth / 2 + (drawSlider ? 6 : 0) < point.getX();
}
use of de.johni0702.minecraft.gui.utils.lwjgl.ReadablePoint in project jGui by ReplayMod.
the class AbstractGuiVerticalList method mouseDrag.
@Override
public boolean mouseDrag(ReadablePoint position, int button, long timeSinceLastCall) {
position = convert(position);
if (lastMousePos != null) {
int dPixel = lastMousePos.getY() - position.getY();
if (draggingSlider) {
int contentHeight = listPanel.calcMinSize().getHeight();
int renderHeight = lastRenderSize.getHeight();
scrollY(dPixel * (contentHeight + renderHeight) / renderHeight);
} else {
scrollY(-dPixel);
}
lastMousePos = position;
// Returning false on purpose, see #mouseClick
}
return false;
}
use of de.johni0702.minecraft.gui.utils.lwjgl.ReadablePoint in project jGui by ReplayMod.
the class AbstractGuiTextField method mouseClick.
@Override
public boolean mouseClick(ReadablePoint position, int button) {
if (getContainer() != null) {
getContainer().convertFor(this, (Point) (position = new Point(position)));
}
boolean hovering = isMouseHovering(position);
if (hovering && isFocused() && button == 0) {
updateCurrentOffset();
int mouseX = position.getX() - BORDER;
TextRenderer fontRenderer = MCVer.getFontRenderer();
String text = this.text.substring(currentOffset);
int textX = fontRenderer.trimToWidth(text, mouseX).length() + currentOffset;
setCursorPosition(textX);
return true;
}
setFocused(hovering);
// Do not yet return true to allow focusables later in the event chain to be notified of the focus change
return false;
}
use of de.johni0702.minecraft.gui.utils.lwjgl.ReadablePoint in project jGui by ReplayMod.
the class AbstractGuiTexturedButton method setTexturePosV.
@Override
public T setTexturePosV(final ReadablePoint pos) {
this.textureNormal = pos;
this.textureHover = new ReadablePoint() {
@Override
public int getX() {
return pos.getX();
}
@Override
public int getY() {
return pos.getY() + textureSize.getHeight();
}
@Override
public void getLocation(WritablePoint dest) {
dest.setLocation(getX(), getY());
}
};
return getThis();
}
use of de.johni0702.minecraft.gui.utils.lwjgl.ReadablePoint in project jGui by ReplayMod.
the class AbstractGuiTexturedButton method draw.
@Override
public void draw(GuiRenderer renderer, ReadableDimension size, RenderInfo renderInfo) {
super.draw(renderer, size, renderInfo);
renderer.bindTexture(texture);
ReadablePoint texture = textureNormal;
if (!isEnabled()) {
texture = textureDisabled;
} else if (isMouseHovering(new Point(renderInfo.mouseX, renderInfo.mouseY))) {
texture = textureHover;
}
if (texture == null) {
// Button is disabled but we have no texture for that
// #if MC>=11700
// $$ // TODO anything reasonable we can do here? do we even care?
// #else
color4f(0.5f, 0.5f, 0.5f, 1);
// #endif
texture = textureNormal;
}
enableBlend();
blendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, 1, 0);
blendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
renderer.drawTexturedRect(0, 0, texture.getX(), texture.getY(), size.getWidth(), size.getHeight(), textureSize.getWidth(), textureSize.getHeight(), textureTotalSize.getWidth(), textureTotalSize.getHeight());
}
Aggregations