1 | "use strict";
|
2 | var __extends = (this && this.__extends) || (function () {
|
3 | var extendStatics = Object.setPrototypeOf ||
|
4 | ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
5 | function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
|
6 | return function (d, b) {
|
7 | extendStatics(d, b);
|
8 | function __() { this.constructor = d; }
|
9 | d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
10 | };
|
11 | })();
|
12 | Object.defineProperty(exports, "__esModule", { value: true });
|
13 | var Graphic_1 = require("./../Graphic");
|
14 | var Tool_1 = require("./../Tool");
|
15 |
|
16 |
|
17 |
|
18 | var Button = (function (_super) {
|
19 | __extends(Button, _super);
|
20 |
|
21 | function Button() {
|
22 | var _this = _super.call(this) || this;
|
23 | _this.setProps({
|
24 | sizeAuto: false,
|
25 | labelCentered: true
|
26 | });
|
27 | return _this;
|
28 | }
|
29 | Button.prototype.initialize = function (props) {
|
30 | _super.prototype.initialize.call(this, props);
|
31 | if (!this.props.width && !this.props.height) {
|
32 | this.props.sizeAuto = true;
|
33 | }
|
34 | this.shape("shape", {
|
35 | width: this.props.width,
|
36 | height: this.props.height,
|
37 | stroke: Tool_1.Color.cyan400,
|
38 | strokeThickness: 2,
|
39 | fill: Tool_1.Color.black,
|
40 | fillAlpha: 0.5,
|
41 | radius: 5
|
42 | }, {
|
43 | hover: {
|
44 | fill: Tool_1.Color.cyan900,
|
45 | fillAlpha: 1
|
46 | },
|
47 | disabled: {
|
48 | fill: Tool_1.Color.grey900,
|
49 | fillAlpha: 0.7,
|
50 | stroke: Tool_1.Color.grey400
|
51 | }
|
52 | }).text("label", {
|
53 | fill: Tool_1.Color.white,
|
54 | dropShadow: true,
|
55 | dropShadowColor: Tool_1.Color.black,
|
56 | dropShadowAngle: 80,
|
57 | dropShadowBlur: 30,
|
58 | dropShadowDistance: 1
|
59 | }, {
|
60 | disabled: {
|
61 | fill: Tool_1.Color.grey400
|
62 | }
|
63 | });
|
64 | this.graphics.label.item.signals.propChange.bind(["width", "height"], this.updateLabelPosition.bind(this));
|
65 | };
|
66 |
|
67 | Button.prototype.onSizeChange = function () {
|
68 | _super.prototype.onSizeChange.call(this);
|
69 | this.updateLabelPosition();
|
70 | };
|
71 | |
72 |
|
73 |
|
74 | Button.prototype.updateLabelPosition = function () {
|
75 | var _this = this;
|
76 | if (this.props.labelCentered) {
|
77 | this.text("label", function (label) {
|
78 | return {
|
79 | x: (_this.props.width / 2) - (label.props.width / 2),
|
80 | y: (_this.props.height / 2) - (label.props.height / 2)
|
81 | };
|
82 | });
|
83 | }
|
84 | };
|
85 | return Button;
|
86 | }(Graphic_1.Graphic));
|
87 | exports.Button = Button;
|