aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/me/shedaniel/gui/Drawable.java
blob: 76d49e0496ede6b896da3e550a9e09a05d69f1c1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
package me.shedaniel.gui;

import me.shedaniel.api.IDrawable;
import me.shedaniel.gui.widget.Control;

import java.awt.*;

/**
 * Created by James on 7/28/2018.
 */
public abstract class Drawable implements IDrawable {
    protected Rectangle rect;
    
    public Drawable(int x, int y, int width, int height) {
        rect = new Rectangle(x, y, width, height);
    }
    
    public Drawable(Rectangle rect) {
        this.rect = rect;
    }
    
    public abstract void draw();
    
    public boolean isHighlighted() {
        Point mousePoint = REIRenderHelper.getMouseLoc();
        if (rect.contains(mousePoint.x, mousePoint.y)) {
            if (this instanceof Control)
                REIRenderHelper.reiGui.setLastHovered((Control) this);
            return true;
        }
        return false;
    }
}