diff options
| author | Unknown <shekwancheung0528@gmail.com> | 2019-07-01 20:06:43 +0800 |
|---|---|---|
| committer | Unknown <shekwancheung0528@gmail.com> | 2019-07-01 20:06:43 +0800 |
| commit | ef588c0ace2c668f61deb5b14b3299fd243f2ff6 (patch) | |
| tree | 3c7a8287f73365125d0b46391d302b7298a39750 /src/main/java/me/shedaniel/rei/gui/widget/WidgetWithBounds.java | |
| parent | f6e7c6ac2d593e0592015232c7788386a4e1a1a6 (diff) | |
| download | RoughlyEnoughItems-ef588c0ace2c668f61deb5b14b3299fd243f2ff6.tar.gz RoughlyEnoughItems-ef588c0ace2c668f61deb5b14b3299fd243f2ff6.tar.bz2 RoughlyEnoughItems-ef588c0ace2c668f61deb5b14b3299fd243f2ff6.zip | |
Refractor HighlightableWidget
Diffstat (limited to 'src/main/java/me/shedaniel/rei/gui/widget/WidgetWithBounds.java')
| -rw-r--r-- | src/main/java/me/shedaniel/rei/gui/widget/WidgetWithBounds.java | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/src/main/java/me/shedaniel/rei/gui/widget/WidgetWithBounds.java b/src/main/java/me/shedaniel/rei/gui/widget/WidgetWithBounds.java new file mode 100644 index 000000000..c1ed9fbbd --- /dev/null +++ b/src/main/java/me/shedaniel/rei/gui/widget/WidgetWithBounds.java @@ -0,0 +1,31 @@ +/* + * Roughly Enough Items by Danielshe. + * Licensed under the MIT License. + */ + +package me.shedaniel.rei.gui.widget; + +import java.awt.*; + +public abstract class WidgetWithBounds extends Widget { + + abstract public Shape getBounds(); + + public final boolean containsMouse(int mouseX, int mouseY) { + return containsMouse((double) mouseX, (double) mouseY); + } + + public final boolean containsMouse(Point point) { + return containsMouse(point.x, point.y); + } + + public boolean containsMouse(double mouseX, double mouseY) { + return getBounds().contains(mouseX, mouseY); + } + + @Override + public boolean isMouseOver(double double_1, double double_2) { + return containsMouse(double_1, double_2); + } + +} |
