Formatting fixes.
This commit is contained in:
@@ -21,15 +21,16 @@ package appeng.client.gui.widgets;
|
|||||||
import java.time.Duration;
|
import java.time.Duration;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This class can be used to implement repeating events such as holding down a button to fire
|
* This class can be used to implement repeating events such as holding down a
|
||||||
* an event repeatedly while the button is still being held, or repeatedly scrolling down
|
* button to fire an event repeatedly while the button is still being held, or
|
||||||
* a page, while the mouse is held down on the scrollbar.
|
* repeatedly scrolling down a page, while the mouse is held down on the
|
||||||
|
* scrollbar.
|
||||||
*/
|
*/
|
||||||
public class EventRepeater {
|
public class EventRepeater {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* -1 if no repeat event is scheduled.
|
* -1 if no repeat event is scheduled. Otherwise contains the
|
||||||
* Otherwise contains the {@link System#nanoTime()} at which the next event should occur.
|
* {@link System#nanoTime()} at which the next event should occur.
|
||||||
*/
|
*/
|
||||||
private long nextEventTime = -1;
|
private long nextEventTime = -1;
|
||||||
|
|
||||||
@@ -49,7 +50,8 @@ public class EventRepeater {
|
|||||||
return; // No event scheduled
|
return; // No event scheduled
|
||||||
}
|
}
|
||||||
|
|
||||||
// Use nanoTime here because it is monotonically increasing, while System.currentTimeMillis is not
|
// Use nanoTime here because it is monotonically increasing, while
|
||||||
|
// System.currentTimeMillis is not
|
||||||
long nanoTime = System.nanoTime();
|
long nanoTime = System.nanoTime();
|
||||||
if (nanoTime < this.nextEventTime) {
|
if (nanoTime < this.nextEventTime) {
|
||||||
return; // Event time not reached
|
return; // Event time not reached
|
||||||
@@ -63,10 +65,11 @@ public class EventRepeater {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Schedule the given callback to be called after a given initial delay, and then
|
* Schedule the given callback to be called after a given initial delay, and
|
||||||
* after the given interval repeatedly.
|
* then after the given interval repeatedly.
|
||||||
*
|
*
|
||||||
* <p>Replaces any previously queued callback.
|
* <p>
|
||||||
|
* Replaces any previously queued callback.
|
||||||
*/
|
*/
|
||||||
public void repeat(EventCallback callback) {
|
public void repeat(EventCallback callback) {
|
||||||
long time = System.nanoTime();
|
long time = System.nanoTime();
|
||||||
|
|||||||
@@ -18,13 +18,15 @@
|
|||||||
|
|
||||||
package appeng.client.gui.widgets;
|
package appeng.client.gui.widgets;
|
||||||
|
|
||||||
import appeng.client.gui.AEBaseScreen;
|
import java.time.Duration;
|
||||||
|
|
||||||
import com.mojang.blaze3d.matrix.MatrixStack;
|
import com.mojang.blaze3d.matrix.MatrixStack;
|
||||||
|
|
||||||
import net.minecraft.client.gui.AbstractGui;
|
import net.minecraft.client.gui.AbstractGui;
|
||||||
import net.minecraft.client.renderer.Rectangle2d;
|
import net.minecraft.client.renderer.Rectangle2d;
|
||||||
import net.minecraft.util.ResourceLocation;
|
import net.minecraft.util.ResourceLocation;
|
||||||
|
|
||||||
import java.time.Duration;
|
import appeng.client.gui.AEBaseScreen;
|
||||||
|
|
||||||
public class Scrollbar extends AbstractGui implements IScrollSource {
|
public class Scrollbar extends AbstractGui implements IScrollSource {
|
||||||
|
|
||||||
@@ -86,10 +88,7 @@ public class Scrollbar extends AbstractGui implements IScrollSource {
|
|||||||
*/
|
*/
|
||||||
private boolean dragging;
|
private boolean dragging;
|
||||||
|
|
||||||
private final EventRepeater eventRepeater = new EventRepeater(
|
private final EventRepeater eventRepeater = new EventRepeater(Duration.ofMillis(250), Duration.ofMillis(150));
|
||||||
Duration.ofMillis(250),
|
|
||||||
Duration.ofMillis(150)
|
|
||||||
);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Draws the handle of the scrollbar.
|
* Draws the handle of the scrollbar.
|
||||||
@@ -101,7 +100,8 @@ public class Scrollbar extends AbstractGui implements IScrollSource {
|
|||||||
setBlitOffset(g.getBlitOffset());
|
setBlitOffset(g.getBlitOffset());
|
||||||
|
|
||||||
// Draw the track (nice for debugging)
|
// Draw the track (nice for debugging)
|
||||||
// fill(matrices, displayX, displayY, this.displayX + width, this.displayY + height, 0xffff0000);
|
// fill(matrices, displayX, displayY, this.displayX + width, this.displayY +
|
||||||
|
// height, 0xffff0000);
|
||||||
|
|
||||||
g.bindTexture(TEXTURE);
|
g.bindTexture(TEXTURE);
|
||||||
|
|
||||||
@@ -248,8 +248,9 @@ public class Scrollbar extends AbstractGui implements IScrollSource {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Ticks the scrollbar for the purposes of input-repeats (since mouse-downs are not repeat-triggered),
|
* Ticks the scrollbar for the purposes of input-repeats (since mouse-downs are
|
||||||
* used to repeatedly page-up or page-down when the mouse is held in the area above or below the scrollbar handle.
|
* not repeat-triggered), used to repeatedly page-up or page-down when the mouse
|
||||||
|
* is held in the area above or below the scrollbar handle.
|
||||||
*/
|
*/
|
||||||
public void tick() {
|
public void tick() {
|
||||||
this.eventRepeater.tick();
|
this.eventRepeater.tick();
|
||||||
|
|||||||
Reference in New Issue
Block a user