-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathbutton.js
More file actions
47 lines (38 loc) · 1.25 KB
/
button.js
File metadata and controls
47 lines (38 loc) · 1.25 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
//set namespace
goog.provide('dr.Button');
//include lime.Button
goog.require('lime.GlossyButton');
// Constructor
dr.Button = function(lbl) {
lime.GlossyButton.call(this,lbl);
this.borderWidth = 4;
this.setColor('#000');
};
goog.inherits(dr.Button,lime.GlossyButton);
dr.Button.prototype.makeState_ = function() {
var state = new lime.RoundedRect().setFill('#fff').setRadius(10);
state.inner = new lime.RoundedRect().setRadius(10);
state.label = new lime.Label().setAlign('center').
setFontFamily('"Trebuchet MS"').setFontColor('#eef').setFontSize(28);
state.appendChild(state.inner);
state.inner.appendChild(state.label);
return state;
};
/**
* @inheritDoc
*/
dr.Button.prototype.setColor = function(clr) {
clr = lime.fill.parse(clr);
goog.array.forEach([this.upstate, this.downstate], function(s) {
var c = s == this.downstate ? clr.clone().addBrightness(.1) : clr;
//s.setFill(c);
var c2 = c.clone().addBrightness(.3);
var grad = new lime.fill.LinearGradient().setDirection(0, 0, 0, 1);
grad.addColorStop(0, c2);
grad.addColorStop(.45, c);
grad.addColorStop(.55, c);
grad.addColorStop(1, c2);
s.inner.setFill(grad);
},this);
return this;
};