added getWidth() and getHeight() methods to Label

This commit is contained in:
Eric Rowell
2013-03-17 17:56:39 -07:00
parent b37f50ba69
commit e0e390f760
2 changed files with 11 additions and 5 deletions

View File

@@ -37,13 +37,18 @@
Kinetic.Group.call(this, config); Kinetic.Group.call(this, config);
this.setText(new Kinetic.Text(config.text)); this.setText(new Kinetic.Text(config.text));
this.setRect(new Kinetic.Plugins.LabelRect(config.rect)); this.setRect(new Kinetic.Plugins.LabelRect(config.rect));
this.getRect().text = this.getText();
this.innerGroup.add(this.getRect()); this.innerGroup.add(this.getRect());
this.innerGroup.add(this.getText()); this.innerGroup.add(this.getText());
this.add(this.innerGroup); this.add(this.innerGroup);
this._setGroupOffset(); this._setGroupOffset();
}, },
getWidth: function() {
return this.getText().getWidth();
},
getHeight: function() {
return this.getText().getHeight();
},
_setGroupOffset: function() { _setGroupOffset: function() {
var text = this.getText(), var text = this.getText(),
width = text.getWidth(), width = text.getWidth(),
@@ -97,9 +102,10 @@
this._setDrawFuncs(); this._setDrawFuncs();
}, },
drawFunc: function(canvas) { drawFunc: function(canvas) {
var context = canvas.getContext(), var label = this.getParent().getParent(),
width = this.text.getWidth(), context = canvas.getContext(),
height = this.text.getHeight(), width = label.getWidth(),
height = label.getHeight(),
pointerDirection = this.getPointerDirection(), pointerDirection = this.getPointerDirection(),
pointerWidth = this.getPointerWidth(), pointerWidth = this.getPointerWidth(),
pointerHeight = this.getPointerHeight(), pointerHeight = this.getPointerHeight(),

View File

@@ -1,5 +1,5 @@
Test.Modules.LABEL = { Test.Modules.LABEL = {
'add label': function(containerId) { '*add label': function(containerId) {
var stage = new Kinetic.Stage({ var stage = new Kinetic.Stage({
container: containerId, container: containerId,
width: 578, width: 578,