Search in sources :

Example 11 with Point

use of de.johni0702.minecraft.gui.utils.lwjgl.Point 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 12 with Point

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

the class AbstractGuiHorizontalScrollbar method draw.

@Override
public void draw(GuiRenderer renderer, ReadableDimension size, RenderInfo renderInfo) {
    super.draw(renderer, size, renderInfo);
    int width = size.getWidth();
    int height = size.getHeight();
    renderer.bindTexture(TEXTURE);
    // Draw background
    // We have to increase the border size as there is one pixel row which is part of the border while drawing
    // but isn't during position calculations due to shadows
    Utils.drawDynamicRect(renderer, width, height, TEXTURE_BG_X, TEXTURE_BG_Y, TEXTURE_BG_WIDTH, TEXTURE_BG_HEIGHT, BORDER_TOP + 1, BORDER_BOTTOM, BORDER_LEFT + 1, BORDER_RIGHT);
    // Draw slider
    int bodyWidth = size.getWidth() - BORDER_LEFT - BORDER_RIGHT;
    int barOffset = (int) (bodyWidth * offset) + BORDER_LEFT;
    int barWidth = (int) (bodyWidth * zoom);
    Utils.drawDynamicRect(new OffsetGuiRenderer(renderer, new Point(barOffset, BORDER_TOP), size), barWidth, height - (BORDER_TOP + 1) - BORDER_BOTTOM, TEXTURE_FG_X, TEXTURE_FG_Y, TEXTURE_FG_WIDTH, TEXTURE_FG_HEIGHT, 2, 1, 1, 1);
}
Also used : OffsetGuiRenderer(de.johni0702.minecraft.gui.OffsetGuiRenderer) Point(de.johni0702.minecraft.gui.utils.lwjgl.Point) ReadablePoint(de.johni0702.minecraft.gui.utils.lwjgl.ReadablePoint) Point(de.johni0702.minecraft.gui.utils.lwjgl.Point) ReadablePoint(de.johni0702.minecraft.gui.utils.lwjgl.ReadablePoint)

Example 13 with Point

use of de.johni0702.minecraft.gui.utils.lwjgl.Point 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 Point

use of de.johni0702.minecraft.gui.utils.lwjgl.Point 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)

Example 15 with Point

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

the class AbstractGuiColorPicker method draw.

@Override
public void draw(GuiRenderer renderer, ReadableDimension size, RenderInfo renderInfo) {
    super.draw(renderer, size, renderInfo);
    if (renderInfo.layer == 0) {
        int width = size.getWidth();
        int height = size.getHeight();
        // Draw outline
        renderer.drawRect(0, 0, width, height, OUTLINE_COLOR);
        // Draw color
        renderer.drawRect(1, 1, width - 2, height - 2, color);
    } else if (renderInfo.layer == 1) {
        ReadablePoint offsetPoint = new Point(0, size.getHeight());
        ReadableDimension offsetSize = new Dimension(PICKER_SIZE, PICKER_SIZE);
        OffsetGuiRenderer offsetRenderer = new OffsetGuiRenderer(renderer, offsetPoint, offsetSize);
        offsetRenderer.startUsing();
        try {
            picker.draw(offsetRenderer, offsetSize, renderInfo);
        } finally {
            offsetRenderer.stopUsing();
        }
    }
}
Also used : ReadableDimension(de.johni0702.minecraft.gui.utils.lwjgl.ReadableDimension) OffsetGuiRenderer(de.johni0702.minecraft.gui.OffsetGuiRenderer) Point(de.johni0702.minecraft.gui.utils.lwjgl.Point) ReadablePoint(de.johni0702.minecraft.gui.utils.lwjgl.ReadablePoint) Dimension(de.johni0702.minecraft.gui.utils.lwjgl.Dimension) ReadableDimension(de.johni0702.minecraft.gui.utils.lwjgl.ReadableDimension) ReadablePoint(de.johni0702.minecraft.gui.utils.lwjgl.ReadablePoint) Point(de.johni0702.minecraft.gui.utils.lwjgl.Point) ReadablePoint(de.johni0702.minecraft.gui.utils.lwjgl.ReadablePoint)

Aggregations

Point (de.johni0702.minecraft.gui.utils.lwjgl.Point)25 ReadablePoint (de.johni0702.minecraft.gui.utils.lwjgl.ReadablePoint)25 ReadableDimension (de.johni0702.minecraft.gui.utils.lwjgl.ReadableDimension)11 Dimension (de.johni0702.minecraft.gui.utils.lwjgl.Dimension)8 GuiElement (de.johni0702.minecraft.gui.element.GuiElement)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 Pair (org.apache.commons.lang3.tuple.Pair)4 CrashException (net.minecraft.util.crash.CrashException)2 CrashReport (net.minecraft.util.crash.CrashReport)2 CrashReportSection (net.minecraft.util.crash.CrashReportSection)2 RenderInfo (de.johni0702.minecraft.gui.RenderInfo)1 WritablePoint (de.johni0702.minecraft.gui.utils.lwjgl.WritablePoint)1 Window (net.minecraft.client.util.Window)1