Skip to content
Newer
Older
100644 49 lines (40 sloc) 914 Bytes
bdb75d0 @camillol View system improvements
authored Nov 19, 2011
1 class Checkbox extends Button {
9f07ede @camillol added checkbox and beginning of data model
authored Nov 19, 2011
2 boolean checked = false;
3
4 final static int INSET = 3;
5
bdb75d0 @camillol View system improvements
authored Nov 20, 2011
6 Checkbox(float x_, float y_, float w_, float h_)
9f07ede @camillol added checkbox and beginning of data model
authored Nov 19, 2011
7 {
bdb75d0 @camillol View system improvements
authored Nov 20, 2011
8 super(x_,y_,w_,h_,"");
9f07ede @camillol added checkbox and beginning of data model
authored Nov 19, 2011
9 }
10
bdb75d0 @camillol View system improvements
authored Nov 20, 2011
11 void drawContent(float lx, float ly)
9f07ede @camillol added checkbox and beginning of data model
authored Nov 19, 2011
12 {
13 strokeWeight(1);
14 stroke(fgColor);
15 noFill();
16 rect(0, 0, w, h);
17
18 if (checked) {
19 fill(fgColor);
20 rect(INSET, INSET, w-INSET*2, h-INSET*2);
21 }
22 }
23
24 boolean contentClicked(float lx, float ly)
25 {
26 checked = !checked;
bdb75d0 @camillol View system improvements
authored Nov 20, 2011
27 super.contentClicked(lx,ly);
9f07ede @camillol added checkbox and beginning of data model
authored Nov 19, 2011
28 return true;
29 }
30 }
31
40c3388 @camillol top artists view
authored Nov 19, 2011
32 class GlyphCheckbox extends Checkbox {
33 String glyph;
34 GlyphCheckbox(float x_, float y_, float w_, float h_, String glyph)
35 {
36 super(x_,y_,w_,h_);
37 this.glyph = glyph;
38 }
39
40 void drawContent(float lx, float ly) {
41 super.drawContent(lx, ly);
42 if (checked) fill(0);
43 else fill(fgColor);
44 textAlign(CENTER, CENTER);
45 text(glyph, 0, 0, w, h);
46 }
47 }
48
Something went wrong with that request. Please try again.