Skip to content

Commit 57fb6bc

Browse files
committed
Merge branch 'hotfix/v0.3.2'
2 parents d552cf7 + 9daee94 commit 57fb6bc

File tree

10 files changed

+172
-80
lines changed

10 files changed

+172
-80
lines changed

‎dist/aframe-gui.js‎

Lines changed: 43 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,7 @@ AFRAME.registerComponent('gui-button', {
158158
schema: {
159159
on: { default: 'click' },
160160
toggle: { type: 'boolean', default: false },
161+
toggleState: { type: 'boolean', default: false },
161162
text: { type: 'string', default: 'text' },
162163
fontSize: { type: 'string', default: '150px' },
163164
fontFamily: { type: 'string', default: 'Arial' },
@@ -166,6 +167,7 @@ AFRAME.registerComponent('gui-button', {
166167
backgroundColor: { type: 'string', default: key_grey },
167168
hoverColor: { type: 'string', default: key_grey_dark },
168169
activeColor: { type: 'string', default: key_orange }
170+
169171
},
170172
init: function init() {
171173

@@ -178,7 +180,6 @@ AFRAME.registerComponent('gui-button', {
178180
var multiplier = 512; // POT conversion
179181
var canvasWidth = guiItem.width * multiplier;
180182
var canvasHeight = guiItem.height * multiplier;
181-
var toggleState = this.toggleState = data.toggle;
182183

183184
var canvasContainer = document.createElement('div');
184185
canvasContainer.setAttribute('class', 'visuallyhidden');
@@ -220,25 +221,30 @@ AFRAME.registerComponent('gui-button', {
220221

221222
el.addEventListener('mouseenter', function () {
222223
buttonEntity.removeAttribute('animation__leave');
223-
buttonEntity.setAttribute('animation__enter', 'property: material.color; from: ' + data.backgroundColor + '; to:' + data.hoverColor + '; dur:200;');
224+
if (!data.toggle) {
225+
buttonEntity.setAttribute('animation__enter', 'property: material.color; from: ' + data.backgroundColor + '; to:' + data.hoverColor + '; dur:200;');
226+
}
224227
});
225228
el.addEventListener('mouseleave', function () {
226229
if (!data.toggle) {
227230
buttonEntity.removeAttribute('animation__click');
231+
buttonEntity.setAttribute('animation__leave', 'property: material.color; from: ' + data.hoverColor + '; to:' + data.backgroundColor + '; dur:200; easing: easeOutQuad;');
228232
}
229233
buttonEntity.removeAttribute('animation__enter');
230-
buttonEntity.setAttribute('animation__leave', 'property: material.color; from: ' + data.hoverColor + '; to:' + data.backgroundColor + '; dur:200; easing: easeOutQuad;');
231234
});
232235
el.addEventListener(data.on, function () {
233236
if (!data.toggle) {
234237
// if not toggling flashing active state
235238
buttonEntity.setAttribute('animation__click', 'property: material.color; from: ' + data.activeColor + '; to:' + data.backgroundColor + '; dur:400; easing: easeOutQuad;');
236239
} else {
237-
buttonEntity.setAttribute('material', 'color', data.activeColor);
240+
var guiButton = el.components['gui-button'];
241+
// console.log("about to toggle, current state: " + guiButton.data.toggleState);
242+
guiButton.setActiveState(!guiButton.data.toggleState);
243+
// buttonEntity.setAttribute('material', 'color', data.activeColor);
238244
}
239245

240246
var clickActionFunctionName = guiInteractable.clickAction;
241-
console.log("in button, clickActionFunctionName: " + clickActionFunctionName);
247+
// console.log("in button, clickActionFunctionName: "+clickActionFunctionName);
242248
// find object
243249
var clickActionFunction = window[clickActionFunctionName];
244250
//console.log("clickActionFunction: "+clickActionFunction);
@@ -251,14 +257,18 @@ AFRAME.registerComponent('gui-button', {
251257
},
252258
play: function play() {},
253259
update: function update(oldData) {
254-
console.log("In button update, toggle: " + this.toggleState);
260+
// console.log("In button update, toggle: "+this.data.toggleState);
255261
},
256262
setActiveState: function setActiveState(activeState) {
257-
console.log("in setActiveState function");
258-
this.data.toggle = this.toggleState = activeState;
263+
// console.log("in setActiveState function, new state: " + activeState);
264+
this.data.toggleState = activeState;
259265
if (!activeState) {
266+
console.log('not active, about to set background color');
260267
this.buttonEntity.setAttribute('material', 'color', this.data.backgroundColor);
261-
} else {}
268+
} else {
269+
console.log('active, about to set active color');
270+
this.buttonEntity.setAttribute('material', 'color', this.data.activeColor);
271+
}
262272
},
263273
setText: function setText(newText) {
264274
drawText(this.ctx, this.canvas, newText, this.data.fontSize, this.data.fontFamily, this.data.fontColor, 1, 'center', 'middle');
@@ -505,6 +515,18 @@ AFRAME.registerComponent('gui-circle-timer', {
505515
this.timerRing.setAttribute('theta-length', elapsed); // this has to increase 0 to 360 when running the count_down
506516
//text doesn't update
507517
drawText(this.ctx, this.canvas, left, data.fontSize, data.fontFamily, data.fontColor, 1, 'center', 'middle');
518+
if (this.countDownLabel) {
519+
el.removeChild(this.countDownLabel);
520+
}
521+
var guiItem = el.getAttribute("gui-item");
522+
var canvas = this.canvas;
523+
var countDownLabel = document.createElement("a-entity");
524+
countDownLabel.setAttribute('geometry', 'primitive: plane; width: ' + guiItem.height / 1.5 + '; height: ' + guiItem.height / 1.5 + ';');
525+
countDownLabel.setAttribute('material', 'shader: flat; src: #' + canvas.id + '; transparent: true; opacity: 1; side:front;');
526+
countDownLabel.setAttribute('position', '0 0 0.022');
527+
el.appendChild(countDownLabel);
528+
this.countDownLabel = countDownLabel;
529+
508530
if (left == 1) {
509531
console.log('fire callback on the last second');
510532
}
@@ -1720,7 +1742,9 @@ AFRAME.registerComponent('gui-label', {
17201742
var canvasHeight = guiItem.height * multiplier;
17211743

17221744
var canvasContainer = document.createElement('div');
1745+
this.canvasContainer = canvasContainer;
17231746
canvasContainer.setAttribute('class', 'visuallyhidden');
1747+
canvasContainer.id = getUniqueId('canvasContainer');
17241748
document.body.appendChild(canvasContainer);
17251749

17261750
var canvas = document.createElement("canvas");
@@ -1738,11 +1762,15 @@ AFRAME.registerComponent('gui-label', {
17381762

17391763
this.oldText = data.text;
17401764

1741-
drawText(ctx, canvas, data.text, guiItem.fontSize + ' ' + data.fontFamily, data.fontColor, 1);
1765+
// drawText(ctx, canvas, data.text, guiItem.fontSize+' ' + data.fontFamily, data.fontColor, 1);
17421766

17431767
drawText(ctx, canvas, data.text, data.fontSize, data.fontFamily, data.fontColor, 1, 'center', 'middle');
17441768

1769+
if (this.textEntity) {
1770+
el.removeChild(this.textEntity);
1771+
}
17451772
var textEntity = document.createElement("a-entity");
1773+
this.textEntity = textEntity;
17461774
textEntity.setAttribute('geometry', 'primitive: plane; width: ' + guiItem.width / 1.05 + '; height: ' + guiItem.height / 1.05 + ';');
17471775
textEntity.setAttribute('material', 'shader: flat; src: #' + canvas.id + '; transparent: true; opacity: 1; side:front;');
17481776
textEntity.setAttribute('position', '0 0 0.001');
@@ -1760,7 +1788,10 @@ AFRAME.registerComponent('gui-label', {
17601788
},
17611789
tick: function tick() {
17621790
if (this.data.text !== this.oldText) {
1763-
drawText(this.ctx, this.canvas, this.data.text, '100px ' + this.data.fontFamily, this.data.fontColor, 1);
1791+
// console.log('text was changed, about to draw text: ' + this.data.text);
1792+
this.oldText = this.data.text;
1793+
// drawText(this.ctx, this.canvas, this.data.text, '100px ' + this.data.fontFamily, this.data.fontColor, 1);
1794+
drawText(this.ctx, this.canvas, this.data.text, this.data.fontSize, this.data.fontFamily, this.data.fontColor, 1, 'center', 'middle');
17641795
}
17651796
}
17661797
});
@@ -1774,10 +1805,10 @@ AFRAME.registerPrimitive('a-gui-label', {
17741805
'width': 'gui-item.width',
17751806
'height': 'gui-item.height',
17761807
'margin': 'gui-item.margin',
1777-
'font-size': 'gui-item.fontSize',
17781808
'on': 'gui-button.on',
17791809
'value': 'gui-label.text',
17801810
'label-for': 'gui-label.labelFor',
1811+
'font-size': 'gui-label.fontSize',
17811812
'font-color': 'gui-label.fontColor',
17821813
'font-family': 'gui-label.fontFamily',
17831814
'background-color': 'gui-label.backgroundColor'

‎dist/aframe-gui.min.js‎

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎examples/all_components.html‎

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,14 @@
33
<head>
44
<meta charset="utf-8">
55
<title>A-Frame GUI All Components</title>
6-
<script src="https://aframe.io/releases/0.9.0/aframe.min.js"></script>
6+
<script src="https://aframe.io/releases/0.9.1/aframe.min.js"></script>
77
<style type="text/css">
88
@font-face{
99
font-family:"Ionicons";
1010

1111
src:url("assets/fonts/ionicons.eot?v=2.0.1");
1212
src:url("assets/fonts/ionicons.eot?v=2.0.1#iefix") format("embedded-opentype"),url("assets/fonts/ionicons.ttf?v=2.0.1") format("truetype"),url("assets/fonts/ionicons.woff?v=2.0.1") format("woff"),url("assets/fonts/ionicons.svg?v=2.0.1#Ionicons") format("svg");
13-
13+
1414
font-weight:normal;
1515
font-style:normal
1616
}
@@ -38,12 +38,12 @@
3838
<a-asset-item id="iconfont" src="assets/fonts/ionicons.ttf"></a-asset-item>
3939
</a-assets>
4040

41-
<a-gui-flex-container
42-
flex-direction="column" justify-content="center" align-items="normal" component-padding="0.1"
41+
<a-gui-flex-container
42+
flex-direction="column" justify-content="center" align-items="normal" component-padding="0.1"
4343
opacity="0.7" width="3.5" height="4.5"
4444
position="-2 2.5 -6" rotation="0 0 0"
4545
>
46-
<a-gui-button
46+
<a-gui-button
4747
width="2.5" height="0.75"
4848
onclick="testButtonAction" key-code="32"
4949
value="test button"
@@ -83,32 +83,32 @@
8383

8484
</a-gui-flex-container>
8585

86-
<a-gui-flex-container
86+
<a-gui-flex-container
8787
flex-direction="column" justify-content="center" align-items="normal" component-padding="0.1" opacity="0.7" width="3.5" height="4.5"
8888
position="2 2.5 -6" rotation="0 0 0"
8989
>
90-
<a-gui-label
90+
<a-gui-label
9191
width="2.5" height="0.75"
9292
value="label text"
9393
margin="0 0 0.05 0"
9494
>
9595
</a-gui-label>
9696

97-
<a-gui-radio
97+
<a-gui-radio
9898
width="2.5" height="0.75"
9999
onclick="testToggleAction"
100100
value="label radio"
101101
margin="0 0 0.05 0"
102102
>
103103
</a-gui-radio>
104104

105-
<a-gui-progressbar
105+
<a-gui-progressbar
106106
width="2.5" height="0.25"
107107
margin="0 0 0.05 0"
108108
>
109109
</a-gui-progressbar>
110110

111-
<a-gui-circle-timer
111+
<a-gui-circle-timer
112112
id="timer"
113113
height="0.75"
114114
count-down="60"
@@ -117,15 +117,15 @@
117117
>
118118
</a-gui-circle-timer>
119119

120-
<a-gui-slider
120+
<a-gui-slider
121121
width="2.5" height="0.75"
122122
onclick="testSliderAction"
123123
percent="0.29"
124124
margin="0 0 0.05 0"
125125
>
126126
</a-gui-slider>
127127

128-
<a-gui-input
128+
<a-gui-input
129129
width="2.5" height="0.75"
130130
onclick="testInputAction"
131131
value="Hello Wor_"
@@ -174,19 +174,19 @@
174174
window.testButtonAction = function () {
175175
console.log("clicked GUI");
176176
}
177-
177+
178178
window.testToggleAction = function () {
179179
console.log("clicked GUI");
180180
}
181-
181+
182182
window.testSliderAction = function () {
183183
console.log("clicked GUI");
184184
}
185-
185+
186186
window.testInputAction = function () {
187187
console.log("clicked GUI");
188188
}
189189
</script>
190190

191191
</body>
192-
</html>
192+
</html>

‎examples/all_components_smallfontsize.html‎

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
src:url("assets/fonts/ionicons.eot?v=2.0.1");
1212
src:url("assets/fonts/ionicons.eot?v=2.0.1#iefix") format("embedded-opentype"),url("assets/fonts/ionicons.ttf?v=2.0.1") format("truetype"),url("assets/fonts/ionicons.woff?v=2.0.1") format("woff"),url("assets/fonts/ionicons.svg?v=2.0.1#Ionicons") format("svg");
13-
13+
1414
font-weight:normal;
1515
font-style:normal
1616
}
@@ -98,7 +98,7 @@
9898
width="2.5" height="0.75"
9999
value="label text smaller font"
100100
font-family="Arial"
101-
font-size="80px"
101+
font-size="50px"
102102
margin="0 0 0.05 0"
103103
>
104104
</a-gui-label>
@@ -120,7 +120,7 @@
120120
>
121121
</a-gui-progressbar>
122122

123-
<a-gui-circle-timer
123+
<a-gui-circle-timer
124124
id="timer"
125125
height="0.75"
126126
count-down="60"
@@ -188,19 +188,19 @@
188188
window.testButtonAction = function () {
189189
console.log("clicked GUI");
190190
}
191-
191+
192192
window.testToggleAction = function () {
193193
console.log("clicked GUI");
194194
}
195-
195+
196196
window.testSliderAction = function () {
197197
console.log("clicked GUI");
198198
}
199-
199+
200200
window.testInputAction = function () {
201201
console.log("clicked GUI");
202202
}
203203
</script>
204204

205205
</body>
206-
</html>
206+
</html>

0 commit comments

Comments
 (0)