diff --git a/core/src/ru/deadsoftware/cavedroid/menu/objects/Button.java b/core/src/ru/deadsoftware/cavedroid/menu/objects/Button.java
index f0da583f5c0e9c0127402e8eb067778b77211337..bc78f21250e4084b0e0c63ab3c770e6903eb9a8e 100644 (file)
public class Button {
- private Rectangle rect;
- private String label;
+ public static final int WIDTH = 200;
+ public static final int HEIGHT = 20;
+
+ public static final int
+ DISABLED = 0,
+ NORMAL = 1,
+ SELECTED = 2;
+ private final Rectangle rect;
+ private final String label;
+ private ButtonEventListener listener;
private int type;
- public Button(String label, float x, float y, float width, float heigth, int type) {
+ /**
+ * @param label Label to be shown on button
+ * @param type Type of button where 0 - disabled, 1 - normal, 2 - selected.
+ * You should use these constants
+ * {@link #DISABLED} {@link #NORMAL} {@link #SELECTED}
+ */
+ public Button(String label, int x, int y, int type, ButtonEventListener listener) {
this.label = label;
- rect = new Rectangle(x, y, width, heigth);
+ rect = new Rectangle(x, y, WIDTH, HEIGHT);
this.type = type;
- }
-
- public Button(String label, float x, float y, float width, float heigth) {
- this(label, x, y, width, heigth, 1);
- }
-
- public Button(String label, float x, float y, int type) {
- this(label, x, y, 200, 20, type);
- }
-
- public Button(String label, float x, float y) {
- this(label, x, y, 200, 20, 1);
+ this.listener = listener;
}
public Rectangle getRect() {
this.type = type;
}
+ public void draw(ButtonRenderer drawer) {
+ drawer.draw(this);
+ }
+
+ public void clicked() {
+ listener.buttonClicked();
+ }
+
}