]> git.lizzy.rs Git - BoundingBoxOutlineReloaded.git/blob - src/main/java/com/irtimaled/bbor/client/gui/BoolButton.java
Change button ON state highlighting to make it more obvious in 1.15+
[BoundingBoxOutlineReloaded.git] / src / main / java / com / irtimaled / bbor / client / gui / BoolButton.java
1 package com.irtimaled.bbor.client.gui;
2
3 import java.awt.*;
4
5 public abstract class BoolButton extends AbstractButton {
6     private static final Color OVERLAY_COLOR = new Color(0, 255, 0, 48);
7
8     private boolean value;
9
10     BoolButton(int width, String label, boolean enabled) {
11         super(0, 0, width, label, enabled);
12     }
13
14     BoolButton(int width, String label) {
15         super(0, 0, width, label);
16     }
17
18     @Override
19     protected int getState() {
20         return enabled ? super.getState() : 0;
21     }
22
23     protected boolean getValue() {
24         return this.value;
25     }
26
27     protected void setValue(boolean value) {
28         this.value = value;
29     }
30
31     @Override
32     protected void renderBackground(int mouseX, int mouseY) {
33         int left = this.x + 1;
34         int top = this.y + 1;
35         int right = left + this.width - 2;
36         int bottom = top + this.height - 2;
37         if (this.getValue()) {
38             drawRectangle(left, top, right, bottom, OVERLAY_COLOR);
39         }
40     }
41 }