-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathVariableRaidioButton.pde
More file actions
80 lines (74 loc) · 1.59 KB
/
VariableRaidioButton.pde
File metadata and controls
80 lines (74 loc) · 1.59 KB
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
class VariableRadioButton
{
String name;
int x = TEXT_MARGIN_FROM_BOX;
int y;
int width = BUTTON_WIDTH;
int height = BUTTON_HEIGHT;
color outerColor = BOX_COLOR_2;
color innerColor = RAIL_COLOR;
PFont font = createFont("Raleway-Light.ttf", 15);
boolean selected = false;
int margin = TEXT_MARGIN_FROM_BOX;
int dataType;
VariableRadioButton(String nameIn, int yIn, int dataType)
{
this.name = nameIn;
this.y = yIn;
this.dataType = dataType;
}
void draw()
{
fill(WHITE);
textFont(font);
text(name,(x - margin + MARGIN_BT_SCREENEDGE_AND_TEXT) , (y + TEXT_POSITION_TOP_OF_BOX));
stroke(colors.getSelectedScheme().getBoxColor2());
fill(RAIL_COLOR);
rect(x, y, width, height);
if(selected == true)
{
noStroke();
fill(WHITE);
ellipse((x + (width/2)), (y +(height/2)), SELECTION_CIRCLE_RADIUS, SELECTION_CIRCLE_RADIUS);
}
}
//Sets a button to be selected
void select()
{
this.selected = true;
}
//Checks to see if a new selection has been made.
boolean selectionMade()
{
if(mousePressed &&
mouseX >= x &&
mouseX <= (x + width) &&
mouseY >= y &&
mouseY <= (y + height))
{
return true;
}
else
{
return false;
}
}
// Gets Datatype
int getDataType()
{
return this.dataType;
}
//Deselects a button
void deselect()
{
this.selected = false;
}
//Returns the selection status of the current button.
boolean isSelected()
{
return selected;
}
void setX(int xIn){
x = xIn;
}
}