]> git.lizzy.rs Git - BoundingBoxOutlineReloaded.git/blob - src/main/java/com/irtimaled/bbor/client/gui/BoundingBoxTypeButton.java
d44f0586852793442903bf077e70ac5f8dddb07e
[BoundingBoxOutlineReloaded.git] / src / main / java / com / irtimaled / bbor / client / gui / BoundingBoxTypeButton.java
1 package com.irtimaled.bbor.client.gui;
2
3 import com.irtimaled.bbor.common.BoundingBoxType;
4
5 import java.awt.*;
6
7 public class BoundingBoxTypeButton extends BoolSettingButton {
8     private final Color color;
9
10     BoundingBoxTypeButton(int id, int x, int y, int width, String label, BoundingBoxType type) {
11         super(id, x, y, width, label, type.shouldRenderSetting);
12         color = type.getColor();
13     }
14
15     public BoundingBoxTypeButton(int id, int x, int y, int width, String label, BoundingBoxType type, boolean enabled) {
16         this(id, x, y, width, label, type);
17         this.enabled = enabled;
18     }
19
20     @Override
21     protected void renderBackground() {
22         if (!enabled) return;
23
24         int left = x + 1;
25         int top = y + 1;
26         int right = left + width - 2;
27         int bottom = top + height - 2;
28
29         // top & left
30         drawRectangle(left, top, right, top + 1, color);
31         drawRectangle(left, top, left + 1, bottom, color);
32
33         Color darker = color.darker();
34         // bottom left & top right
35         drawRectangle(left, bottom - 2, left + 1, bottom, darker);
36         drawRectangle(right - 1, top, right, top + 1, darker);
37
38         Color darkest = darker.darker();
39         // bottom & right
40         drawRectangle(left + 1, bottom - 2, right, bottom, darkest);
41         drawRectangle(right - 1, top + 1, right, bottom, darkest);
42     }
43
44     private void drawRectangle(int left, int top, int right, int bottom, Color color) {
45         drawRect(left, top, right, bottom, color.getRGB());
46     }
47 }