-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathGUI_button.pde
More file actions
166 lines (131 loc) · 4.03 KB
/
Copy pathGUI_button.pde
File metadata and controls
166 lines (131 loc) · 4.03 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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
/////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////// /////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////
class button {
button_point bp1;
button_point bp2;
int positionX;
int positionY;
int sizeX;
int sizeY;
String text;
int url;
boolean pressed;
boolean loaderneeded;
boolean transneeded = true;
public button(int x, int y) {
sizeX = 200;
sizeY = 30;
positionX = x;
positionY = y;
text = "button";
text = text.toUpperCase();
bp1 = new button_point(1, positionX-sizeX/2, positionY-sizeY/2);
bp2 = new button_point(2, positionX+sizeX/2, positionY+sizeY/2);
bp1.setSpeed(sizeX/12);
bp2.setSpeed(sizeX/12);
}
public button(String txt, int x, int y, int sx, int sy) {
sizeX = sx;
sizeY = sy;
positionX = x;
positionY = y;
text = txt;
text = text.toUpperCase();
bp1 = new button_point(1, positionX-sizeX/2, positionY-sizeY/2);
bp2 = new button_point(2, positionX+sizeX/2, positionY+sizeY/2);
}
public button(String txt, int x, int y) {
sizeX = 200;
sizeY = 30;
positionX = x;
positionY = y;
text = txt;
text = text.toUpperCase();
bp1 = new button_point(1, positionX-sizeX/2, positionY-sizeY/2);
bp2 = new button_point(2, positionX+sizeX/2, positionY+sizeY/2);
}
void setURL(int a) {
url = a;
}
void setPosition(int x, int y) {
positionX = x;
positionY = y;
bp1.setPosition(x-sizeX/2, y-sizeY/2);
bp2.setPosition(x+sizeX/2, y+sizeY/2);
}
void display() {
fill(0, 255, 255, transL);
stroke(0, 255, 255, transLO);
strokeWeight(5);
point(positionX-sizeX/2, positionY-sizeY/2);
point(positionX+sizeX/2, positionY+sizeY/2);
strokeWeight(1);
stroke(0, 255, 255, transLO-105);
line(positionX-sizeX/2, positionY-sizeY/2, positionX+sizeX/2, positionY-sizeY/2);
line(positionX-sizeX/2, positionY+sizeY/2, positionX+sizeX/2, positionY+sizeY/2);
if (mouseOver()) {
bp1.movement = 1;
bp2.movement = 2;
if (bp2.positionX == bp1.defPosX) {
fill(0, 255, 255, 10);
rectMode(CENTER);
rect(positionX, positionY, sizeX, sizeY);
}
} else {
if (bp1.positionX == bp1.defPosX) {
bp1.movement = 0;
} else {
bp1.movement = 2;
}
if (bp2.positionX == bp2.defPosX) {
bp2.movement = 0;
} else {
bp2.movement = 1;
}
}
bp1.display();
bp2.display();
if (mousePressed && mouseOver()) {
if (bp2.positionX == bp1.defPosX) {
fill(0, 255, 255, 30);
rectMode(CENTER);
rect(positionX, positionY, sizeX, sizeY);
//actualLayout = url;
}
if (transneeded) {
transitioning = true;
}
pressed = true;
}
fill(0, 255, 255);
textAlign(CENTER);
textSize(15);
text(text, positionX, positionY+6);
textSize(10);
if (pressed) {
pressed = wATrans_IfTrans(url, loaderneeded);
}
}
void setLoaderNeedeability(boolean a) {
loaderneeded = a;
}
void setTransitionNeedeability(boolean a) {
transneeded = a;
}
void setText(String tx) {
text = tx;
}
boolean mouseOver() {
return (
mouseX > positionX-sizeX/2 &&
mouseX < positionX+sizeX/2 &&
mouseY > positionY-sizeY/2 &&
mouseY < positionY+sizeY/2
);
}
}