Formatting fixes.

This commit is contained in:
Sebastian Hartte
2020-09-13 22:18:38 +02:00
parent 4ba97ec899
commit d87ff9d1e7
2 changed files with 22 additions and 18 deletions
@@ -21,15 +21,16 @@ package appeng.client.gui.widgets;
import java.time.Duration;
/**
* This class can be used to implement repeating events such as holding down a button to fire
* an event repeatedly while the button is still being held, or repeatedly scrolling down
* a page, while the mouse is held down on the scrollbar.
* This class can be used to implement repeating events such as holding down a
* button to fire an event repeatedly while the button is still being held, or
* repeatedly scrolling down a page, while the mouse is held down on the
* scrollbar.
*/
public class EventRepeater {
/**
* -1 if no repeat event is scheduled.
* Otherwise contains the {@link System#nanoTime()} at which the next event should occur.
* -1 if no repeat event is scheduled. Otherwise contains the
* {@link System#nanoTime()} at which the next event should occur.
*/
private long nextEventTime = -1;
@@ -49,7 +50,8 @@ public class EventRepeater {
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();
if (nanoTime < this.nextEventTime) {
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
* after the given interval repeatedly.
* Schedule the given callback to be called after a given initial delay, and
* then after the given interval repeatedly.
*
* <p>Replaces any previously queued callback.
* <p>
* Replaces any previously queued callback.
*/
public void repeat(EventCallback callback) {
long time = System.nanoTime();
@@ -18,13 +18,15 @@
package appeng.client.gui.widgets;
import appeng.client.gui.AEBaseScreen;
import java.time.Duration;
import com.mojang.blaze3d.matrix.MatrixStack;
import net.minecraft.client.gui.AbstractGui;
import net.minecraft.client.renderer.Rectangle2d;
import net.minecraft.util.ResourceLocation;
import java.time.Duration;
import appeng.client.gui.AEBaseScreen;
public class Scrollbar extends AbstractGui implements IScrollSource {
@@ -86,10 +88,7 @@ public class Scrollbar extends AbstractGui implements IScrollSource {
*/
private boolean dragging;
private final EventRepeater eventRepeater = new EventRepeater(
Duration.ofMillis(250),
Duration.ofMillis(150)
);
private final EventRepeater eventRepeater = new EventRepeater(Duration.ofMillis(250), Duration.ofMillis(150));
/**
* Draws the handle of the scrollbar.
@@ -101,7 +100,8 @@ public class Scrollbar extends AbstractGui implements IScrollSource {
setBlitOffset(g.getBlitOffset());
// 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);
@@ -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),
* used to repeatedly page-up or page-down when the mouse is held in the area above or below the scrollbar handle.
* Ticks the scrollbar for the purposes of input-repeats (since mouse-downs are
* 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() {
this.eventRepeater.tick();