Search in sources :

Example 11 with ReadablePoint

use of de.johni0702.minecraft.gui.utils.lwjgl.ReadablePoint in project jGui by ReplayMod.

the class AbstractGuiHorizontalScrollbar method mouseRelease.

@Override
public boolean mouseRelease(ReadablePoint position, int button) {
    if (dragging) {
        Point pos = new Point(position);
        if (getContainer() != null) {
            getContainer().convertFor(this, pos);
        }
        updateValue(pos);
        dragging = false;
        startDragging = null;
        return true;
    } else {
        return false;
    }
}
Also used : Point(de.johni0702.minecraft.gui.utils.lwjgl.Point) ReadablePoint(de.johni0702.minecraft.gui.utils.lwjgl.ReadablePoint)

Example 12 with ReadablePoint

use of de.johni0702.minecraft.gui.utils.lwjgl.ReadablePoint in project jGui by ReplayMod.

the class AbstractGuiHorizontalScrollbar method mouseDrag.

@Override
public boolean mouseDrag(ReadablePoint position, int button, long timeSinceLastCall) {
    if (dragging) {
        Point pos = new Point(position);
        if (getContainer() != null) {
            getContainer().convertFor(this, pos);
        }
        updateValue(pos);
    }
    return dragging;
}
Also used : Point(de.johni0702.minecraft.gui.utils.lwjgl.Point) ReadablePoint(de.johni0702.minecraft.gui.utils.lwjgl.ReadablePoint)

Example 13 with ReadablePoint

use of de.johni0702.minecraft.gui.utils.lwjgl.ReadablePoint in project jGui by ReplayMod.

the class AbstractGuiSlider method mouseRelease.

@Override
public boolean mouseRelease(ReadablePoint position, int button) {
    if (dragging) {
        dragging = false;
        Point pos = new Point(position);
        if (getContainer() != null) {
            getContainer().convertFor(this, pos);
        }
        updateValue(pos);
        return true;
    } else {
        return false;
    }
}
Also used : Point(de.johni0702.minecraft.gui.utils.lwjgl.Point) ReadablePoint(de.johni0702.minecraft.gui.utils.lwjgl.ReadablePoint)

Example 14 with ReadablePoint

use of de.johni0702.minecraft.gui.utils.lwjgl.ReadablePoint in project jGui by ReplayMod.

the class AbstractGuiSlider method updateValue.

protected void updateValue(ReadablePoint position) {
    if (getLastSize() == null) {
        return;
    }
    int width = getLastSize().getWidth() - 8;
    int pos = Math.max(0, Math.min(width, position.getX() - 4));
    setValue(steps * pos / width);
}
Also used : Point(de.johni0702.minecraft.gui.utils.lwjgl.Point) ReadablePoint(de.johni0702.minecraft.gui.utils.lwjgl.ReadablePoint)

Example 15 with ReadablePoint

use of de.johni0702.minecraft.gui.utils.lwjgl.ReadablePoint in project jGui by ReplayMod.

the class AbstractGuiSlider method mouseClick.

@Override
public boolean mouseClick(ReadablePoint position, int button) {
    Point pos = new Point(position);
    if (getContainer() != null) {
        getContainer().convertFor(this, pos);
    }
    if (isMouseHovering(pos) && isEnabled()) {
        updateValue(pos);
        dragging = true;
        return true;
    }
    return false;
}
Also used : Point(de.johni0702.minecraft.gui.utils.lwjgl.Point) ReadablePoint(de.johni0702.minecraft.gui.utils.lwjgl.ReadablePoint)

Aggregations

ReadablePoint (de.johni0702.minecraft.gui.utils.lwjgl.ReadablePoint)28 Point (de.johni0702.minecraft.gui.utils.lwjgl.Point)23 ReadableDimension (de.johni0702.minecraft.gui.utils.lwjgl.ReadableDimension)12 GuiElement (de.johni0702.minecraft.gui.element.GuiElement)8 Dimension (de.johni0702.minecraft.gui.utils.lwjgl.Dimension)8 Pair (org.apache.commons.lang3.tuple.Pair)6 OffsetGuiRenderer (de.johni0702.minecraft.gui.OffsetGuiRenderer)5 LinkedHashMap (java.util.LinkedHashMap)4 Map (java.util.Map)4 TextRenderer (net.minecraft.client.font.TextRenderer)4 CrashException (net.minecraft.util.crash.CrashException)4 CrashReport (net.minecraft.util.crash.CrashReport)4 CrashReportSection (net.minecraft.util.crash.CrashReportSection)4 WritablePoint (de.johni0702.minecraft.gui.utils.lwjgl.WritablePoint)3 AbstractComposedGuiElement (de.johni0702.minecraft.gui.element.AbstractComposedGuiElement)2 ComposedGuiElement (de.johni0702.minecraft.gui.element.ComposedGuiElement)2 Focusable (de.johni0702.minecraft.gui.function.Focusable)2 RenderInfo (de.johni0702.minecraft.gui.RenderInfo)1