Skip to content
This repository has been archived by the owner on Nov 7, 2022. It is now read-only.

Commit

Permalink
Change scrollbar callback #4 #9 #16
Browse files Browse the repository at this point in the history
  • Loading branch information
boomboompower committed Mar 26, 2020
1 parent c9e3039 commit 1ca75a4
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,7 @@ protected void onGuiInitExtra() {

ModernScroller modernScroller = new ModernScroller(this.width - 15, 5, 10, this.height - 10).disableTranslatable();

modernScroller.insertScrollCallback((val) -> this.yTranslation = (int) ((float) val) * 100);
modernScroller.insertScrollCallback((val) -> this.yTranslation = val * 10);

registerElement(modernScroller);
registerElement(skinSettings);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ public abstract class ModernGui extends UILock implements UISkeleton {

private List<InteractiveDrawable> selectedDrawables = Lists.newArrayList();

protected int yTranslation = 0;
protected float yTranslation = 0;

@Override
public final void initGui() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,12 @@ public void render(int mouseX, int mouseY, float yTranslation) {
// Run our callbacks
this.currentProgress = (this.lastYLoc / tallest);

if (this.lastTrackedProgress != this.currentProgress) {
this.callbacks.forEach((c) -> c.run(this.currentProgress));

this.lastTrackedProgress = this.currentProgress;
}

ModernGui.drawRect(this.x + 2, (int) this.lastYLoc - 3, this.x + this.width - 1, (int) this.lastYLoc + 3, transparentBlue.getRGB());
}

Expand All @@ -131,12 +137,6 @@ public void onLeftClick(int mouseX, int mouseY, float yTranslation) {
@Override
public void onMouseReleased(int mouseX, int mouseY, float yTranslation) {
this.dragging = false;

if (this.lastTrackedProgress != this.currentProgress) {
this.callbacks.forEach((c) -> c.run(this.currentProgress));
}

this.lastTrackedProgress = this.currentProgress;
}

@Override
Expand Down

0 comments on commit 1ca75a4

Please sign in to comment.