DEADSOFTWARE

Fix codestyle
[cavedroid.git] / core / src / ru / deadsoftware / cavedroid / menu / objects / Button.java
1 package ru.deadsoftware.cavedroid.menu.objects;
3 import com.badlogic.gdx.math.Rectangle;
5 public class Button {
7 public static final int WIDTH = 200;
8 public static final int HEIGHT = 20;
10 public static final int
11 DISABLED = 0,
12 NORMAL = 1,
13 SELECTED = 2;
14 private final Rectangle rect;
15 private final String label;
16 private ButtonEventListener listener;
17 private int type;
19 /**
20 * @param label Label to be shown on button
21 * @param type Type of button where 0 - disabled, 1 - normal, 2 - selected.
22 * You should use these constants
23 * {@link #DISABLED} {@link #NORMAL} {@link #SELECTED}
24 */
25 public Button(String label, int x, int y, int type, ButtonEventListener listener) {
26 this.label = label;
27 rect = new Rectangle(x, y, WIDTH, HEIGHT);
28 this.type = type;
29 this.listener = listener;
30 }
32 public Rectangle getRect() {
33 return rect;
34 }
36 public String getLabel() {
37 return label;
38 }
40 public float getX() {
41 return rect.x;
42 }
44 public float getY() {
45 return rect.y;
46 }
48 public float getWidth() {
49 return rect.width;
50 }
52 public float getHeight() {
53 return rect.height;
54 }
56 public int getType() {
57 return type;
58 }
60 public void setType(int type) {
61 this.type = type;
62 }
64 public void draw(ButtonRenderer drawer) {
65 drawer.draw(this);
66 }
68 public void clicked() {
69 listener.buttonClicked();
70 }
72 }