Skip to content

Commit

Permalink
Merge branch '1.20' into 1.20.2
Browse files Browse the repository at this point in the history
# Conflicts:
#	build.gradle
#	gradle/wrapper/gradle-wrapper.properties
#	src/main/java/com/minelittlepony/common/client/gui/element/Button.java
  • Loading branch information
Sollace committed Apr 6, 2024
2 parents d2bab0e + a9b2836 commit 8c09e8a
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 11 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ buildscript {
}
}
plugins {
id 'fabric-loom' version '1.3-SNAPSHOT'
id 'fabric-loom' version '1.5-SNAPSHOT'
id 'maven-publish'
id 'com.modrinth.minotaur' version '2.+'
id 'org.ajoberstar.reckon' version '0.13.0'
Expand Down
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.1-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.3-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
Original file line number Diff line number Diff line change
Expand Up @@ -157,11 +157,11 @@ public void mouseMoved(double mouseX, double mouseY) {
}

public int getMouseYOffset() {
return -margin.top - getScrollY() - getContentPadding().top;
return -getBounds().top - getScrollY() - getContentPadding().top;
}

public int getMouseXOffset() {
return -margin.left - getScrollX() - getContentPadding().left;
return -getBounds().left - getScrollX() - getContentPadding().left;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,10 @@
import com.minelittlepony.common.client.gui.scrollable.ScrollbarScrubber;

import net.minecraft.client.gui.Drawable;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.gui.DrawContext;
import net.minecraft.client.gui.Element;
import net.minecraft.client.util.Window;
import net.minecraft.sound.SoundEvents;

/**
Expand Down Expand Up @@ -153,11 +155,13 @@ public boolean mouseClicked(double mouseX, double mouseY, int button) {
}

private double calculateInternalYPosition(double mouseY) {
return mouseY + rootView.getScrollY() + rootView.getContentPadding().top;
double yOffset = -rootView.getScrollY() - rootView.getContentPadding().top;
return mouseY - yOffset;
}

private double calculateInternalXPosition(double mouseX) {
return mouseX + rootView.getScrollX() + rootView.getContentPadding().left;
double xOffset = -rootView.getScrollX() - rootView.getContentPadding().left;
return mouseX - xOffset;
}

@Override
Expand All @@ -167,11 +171,15 @@ public boolean mouseDragged(double mouseX, double mouseY, int button, double dif

double mousePosition = orientation.pick(mouseX, mouseY);

Window window = MinecraftClient.getInstance().getWindow();
double motionRatio = orientation.pick(window.getWidth(), window.getHeight()) / (double)orientation.pick(bounds.width, bounds.height);
double change = motionRatio * (prevMousePosition - mousePosition);

if (dragging) {
scrubber.scrollBy(-(int)(prevMousePosition - mousePosition), false);
scrubber.scrollBy(-(int)change, false);
} else if (touching) {
scrubber.scrollBy((int)(mousePosition - prevMousePosition) / 16, true);
scrubber.setMomentum((int)(mousePosition - prevMousePosition));
scrubber.scrollBy(-(int)change * 16, true);
scrubber.setMomentum(-(int)change);
}

prevMousePosition = mousePosition;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,11 +63,10 @@ public void scrollTo(int position, boolean animate) {
if (!animate) {
currentPosition = targetPosition;
}
setMomentum(0);
}

public void setMomentum(int momentum) {
this.momentum = momentum;
this.momentum += momentum;
}

public void reposition(Bounds containerBounds, Bounds contentBounds) {
Expand Down

0 comments on commit 8c09e8a

Please sign in to comment.