Bri Prebilic Cole

GUI -- Updated Equalize Master glyph. SVG practice progress - better algorithm f…

…or changing button position. Various other small edits.

Change-Id: I4d04a31b3cf5b329b2227c6ccf494de0b5603455
...@@ -42,6 +42,7 @@ ...@@ -42,6 +42,7 @@
42 .button { 42 .button {
43 fill: #369; 43 fill: #369;
44 /* TODO: figure out why svg filters are not working */ 44 /* TODO: figure out why svg filters are not working */
45 + /* is it because there is an invisible rectangle behind it? */
45 /*filter: url(#innerbevel);*/ 46 /*filter: url(#innerbevel);*/
46 } 47 }
47 svg text { 48 svg text {
......
...@@ -29,7 +29,7 @@ ...@@ -29,7 +29,7 @@
29 btnHeight = 50, 29 btnHeight = 50,
30 hoverZone = 60, 30 hoverZone = 60,
31 sectorDivisions = 3, 31 sectorDivisions = 3,
32 - pageMargin = 20; 32 + pageMargin = 10;
33 33
34 // svg elements 34 // svg elements
35 var svg, g; 35 var svg, g;
...@@ -37,48 +37,16 @@ ...@@ -37,48 +37,16 @@
37 // other variables 37 // other variables
38 var winWidth, winHeight, 38 var winWidth, winHeight,
39 sectorWidth, sectorHeight, 39 sectorWidth, sectorHeight,
40 - currSector = 4, 40 + currSector = 4, // always starts in the middle
41 mouse; 41 mouse;
42 42
43 // ==================================================== 43 // ====================================================
44 44
45 - // helper functions
46 function centeredOnWindow(axis, dim) { 45 function centeredOnWindow(axis, dim) {
47 return (axis / 2) - (dim / 2); 46 return (axis / 2) - (dim / 2);
48 } 47 }
49 48
50 - // ====================================================
51 -
52 - function center(elem) {
53 - $log.debug(winWidth / 2);
54 - $log.debug(winHeight / 2);
55 - $log.debug((winWidth / 2) - ((elem.node().getBBox().width) / 2));
56 - $log.debug((winHeight / 2) - ((elem.node().getBBox().height) / 2));
57 - return {
58 - x: (winWidth / 2) - ((elem.node().getBBox().width) / 2),
59 - y: (winHeight / 2) - ((elem.node().getBBox().height) / 2)
60 - }
61 - }
62 -
63 function showSectors() { 49 function showSectors() {
64 - svg.append('line')
65 - .attr({
66 - x1: winWidth / 2,
67 - x2: winWidth / 2,
68 - y1: 0,
69 - y2: winHeight,
70 - stroke: 'purple',
71 - 'stroke-width': '3px'
72 - });
73 - svg.append('line')
74 - .attr({
75 - x1: 0,
76 - x2: winWidth,
77 - y1: winHeight / 2,
78 - y2: winHeight / 2,
79 - stroke: 'purple',
80 - 'stroke-width': '3px'
81 - });
82 for (var i = 1; i < 5; i++) { 50 for (var i = 1; i < 5; i++) {
83 var j; 51 var j;
84 if (i < 3) { 52 if (i < 3) {
...@@ -122,37 +90,34 @@ ...@@ -122,37 +90,34 @@
122 } 90 }
123 91
124 function selectSector() { 92 function selectSector() {
125 - var sector, row, col; 93 + var sector, row, col,
94 + currSectorCol = currSector % sectorDivisions;
126 95
127 do { 96 do {
128 sector = Math.floor((Math.random() * 9)); 97 sector = Math.floor((Math.random() * 9));
129 - } while (sector === currSector); 98 + col = sector % sectorDivisions;
130 - $log.debug('sector after loop: ' + sector); 99 + } while (col === currSectorCol);
131 - $log.debug('currSector after loop: ' + currSector);
132 currSector = sector; 100 currSector = sector;
133 - $log.debug('currSector after assignment: ' + currSector);
134 row = Math.floor(sector / sectorDivisions); 101 row = Math.floor(sector / sectorDivisions);
135 - col = sector % sectorDivisions;
136 -
137 - $log.debug('row: ' + row);
138 - $log.debug('col: ' + col);
139 102
103 + // active area is the coordinates of the sector, plus or minus a margin
140 return { 104 return {
141 - xmin: sectorWidth * col, 105 + xmin: (sectorWidth * col) + pageMargin,
142 - xmax: (sectorWidth * col) + sectorWidth, 106 + xmax: ((sectorWidth * col) + sectorWidth) - pageMargin,
143 - ymin: sectorHeight * row, 107 + ymin: (sectorHeight * row) + pageMargin,
144 - ymax: (sectorHeight * row) + sectorHeight 108 + ymax: ((sectorHeight * row) + sectorHeight) - pageMargin
145 } 109 }
146 } 110 }
147 111
148 function selectXY(sectorCoords) { 112 function selectXY(sectorCoords) {
149 var x, y, x1, y1; 113 var x, y, x1, y1;
114 +
150 do { 115 do {
151 x = (Math.random() * sectorCoords.xmax) + sectorCoords.xmin; 116 x = (Math.random() * sectorCoords.xmax) + sectorCoords.xmin;
152 y = (Math.random() * sectorCoords.ymax) + sectorCoords.ymin; 117 y = (Math.random() * sectorCoords.ymax) + sectorCoords.ymin;
153 x1 = x + btnWidth; 118 x1 = x + btnWidth;
154 y1 = y + btnHeight; 119 y1 = y + btnHeight;
155 - } while (x1 >= winWidth - pageMargin || y1 >= winHeight - pageMargin); 120 + } while (x1 > sectorCoords.xmax || y1 > sectorCoords.ymax);
156 121
157 return { 122 return {
158 x: x, 123 x: x,
...@@ -167,9 +132,8 @@ ...@@ -167,9 +132,8 @@
167 function moveButton() { 132 function moveButton() {
168 var sec = selectSector(), 133 var sec = selectSector(),
169 pos = selectXY(sec); 134 pos = selectXY(sec);
170 - $log.debug(pos.x, pos.y);
171 g.transition() 135 g.transition()
172 - .duration(400) 136 + .duration(300)
173 .ease('cubic-out') 137 .ease('cubic-out')
174 .each('start', removeMouseListener) 138 .each('start', removeMouseListener)
175 .attr('transform', gTranslate(pos.x, pos.y)) 139 .attr('transform', gTranslate(pos.x, pos.y))
...@@ -186,13 +150,9 @@ ...@@ -186,13 +150,9 @@
186 fs = _fs_; 150 fs = _fs_;
187 return { 151 return {
188 restrict: 'E', 152 restrict: 'E',
189 - link: function (scope, elem, attrs) { 153 + link: function (scope, elem) {
190 winWidth = fs.windowSize().width; 154 winWidth = fs.windowSize().width;
191 winHeight = fs.windowSize().height; 155 winHeight = fs.windowSize().height;
192 - // getting rid of pageMargin to see if the math is easier
193 - // could put the padding somewhere else as in where it's ok to move the button
194 - //sectorWidth = (winWidth / sectorDivisions) - pageMargin;
195 - //sectorHeight = (winHeight / sectorDivisions) - pageMargin;
196 sectorWidth = winWidth / sectorDivisions; 156 sectorWidth = winWidth / sectorDivisions;
197 sectorHeight = winHeight / sectorDivisions; 157 sectorHeight = winHeight / sectorDivisions;
198 158
...@@ -203,7 +163,7 @@ ...@@ -203,7 +163,7 @@
203 height: winHeight + 'px' 163 height: winHeight + 'px'
204 }); 164 });
205 165
206 - showSectors(); 166 + //showSectors();
207 g = svg.append('g'); 167 g = svg.append('g');
208 168
209 var button = g.append('rect') 169 var button = g.append('rect')
...@@ -228,12 +188,10 @@ ...@@ -228,12 +188,10 @@
228 height: btnHeight + hoverZone + 'px', 188 height: btnHeight + hoverZone + 'px',
229 x: -(hoverZone / 2), 189 x: -(hoverZone / 2),
230 y: -(hoverZone / 2) 190 y: -(hoverZone / 2)
231 - }), 191 + });
232 - centeredG = center(g);
233 g.attr('transform', 192 g.attr('transform',
234 - gTranslate(centeredG.x, centeredG.y)); 193 + gTranslate(centeredOnWindow(winWidth, btnWidth),
235 - //gTranslate(centeredOnWindow(winWidth, btnWidth), 194 + centeredOnWindow(winHeight, btnHeight)));
236 - // centeredOnWindow(winHeight, btnHeight)));
237 195
238 addMouseListener(); 196 addMouseListener();
239 } 197 }
......
...@@ -267,13 +267,16 @@ ...@@ -267,13 +267,16 @@
267 "61.4,90.2,61.4,93.7z M93.8,61.8c-3.5,0-6.4-2.9-6.4-6.4c0-3.5," + 267 "61.4,90.2,61.4,93.7z M93.8,61.8c-3.5,0-6.4-2.9-6.4-6.4c0-3.5," +
268 "2.9-6.4,6.4-6.4s6.4,2.9,6.4,6.4C100.1,58.9,97.3,61.8,93.8,61.8z", 268 "2.9-6.4,6.4-6.4s6.4,2.9,6.4,6.4C100.1,58.9,97.3,61.8,93.8,61.8z",
269 269
270 - eqMaster: "M94.6,80.1c0,5.7-4.6,10.3-10.3,10.3S74,85.8,74,80.1" + 270 + eqMaster: "M100.1,46.9l-10.8-25h0.2c0.5,0,0.8-0.5,0.8-1.1v-3.2" +
271 - "c0-3.8,2-7,5-8.8L64.4,37.5H45.8L31.1,71.3c2.9,1.8,4.9,5.1,4.9," + 271 + "c0-0.6-0.4-1.1-0.8-1.1H59.2v-5.1c0-0.5-0.8-1-1.7-1h-5.1c-0.9,0" +
272 - "8.8c0,5.7-4.6,10.3-10.3,10.3s-10.3-4.6-10.3-10.3S20,69.8,25.7," + 272 + "-1.7,0.4-1.7,1v5.1l-30.2,0c-0.5,0-0.8,0.5-0.8,1.1v3.2c0,0.6," +
273 - "69.8c0.7,0,1.5,0.1,2.2,0.2L42,37.5H26.7c-0.6,0-1-0.4-1-0.8V20.4" + 273 + "0.4,1.1,0.8,1.1h0.1l-10.8,25C9,47.3,8.4,48,8.4,48.8v1.6l0,0h0" +
274 - "c0-0.5,0.5-0.8,1-0.8h56.6c0.6,0,1,0.4,1,0.8v16.2c0,0.5-0.5,0.8" + 274 + "v6.4c0,1.3,1.4,2.3,3.2,2.3h21.7c1.8,0,3.2-1,3.2-2.3v-8c0-0.9" +
275 - "-1,0.8H68.2L82.3,70c0.6-0.1,1.3-0.2,2-0.2C90,69.8,94.6,74.4," + 275 + "-0.7-1.6-1.7-2L22.9,21.9h27.9v59.6l-29,15.9c0,1.2,1.8,2.2,4.1," +
276 - "94.6,80.1z" 276 + "2.2h58.3c2.3,0,4.1-1,4.1-2.2l-29-15.9V21.9h27.8L75.2,46.8c-1," +
277 + "0.4-1.7,1.1-1.7,2v8c0,1.3,1.4,2.3,3.2,2.3h21.7c1.8,0,3.2-1,3.2" +
278 + "-2.3v-8C101.6,48,101,47.3,100.1,46.9z M22,23.7l10.8,22.8H12.1" +
279 + "L22,23.7z M97.9,46.5H77.2L88,23.7L97.9,46.5z"
277 }, 280 },
278 281
279 badgeViewBox = '0 0 10 10', 282 badgeViewBox = '0 0 10 10',
......
...@@ -95,7 +95,7 @@ ...@@ -95,7 +95,7 @@
95 toolbar.addToggle('demo-toggle', 'chain', false, togFn, 'another tooltip'); 95 toolbar.addToggle('demo-toggle', 'chain', false, togFn, 'another tooltip');
96 toolbar.addSeparator(); 96 toolbar.addSeparator();
97 toolbar.addRadioSet('demo-radio', rset); 97 toolbar.addRadioSet('demo-radio', rset);
98 - toolbar.show(); 98 + toolbar.hide();
99 99
100 checkFn(); 100 checkFn();
101 101
......
...@@ -53,7 +53,7 @@ describe('factory: fw/svg/glyph.js', function() { ...@@ -53,7 +53,7 @@ describe('factory: fw/svg/glyph.js', function() {
53 intentTraffic: 'M14.7,71.5h', 53 intentTraffic: 'M14.7,71.5h',
54 allTraffic: 'M15.7,64.5h-7v', 54 allTraffic: 'M15.7,64.5h-7v',
55 flows: 'M93.8,46.1c', 55 flows: 'M93.8,46.1c',
56 - eqMaster: 'M94.6,80.1c0,5.7', 56 + eqMaster: 'M100.1,46.9l',
57 57
58 // badges 58 // badges
59 uiAttached: 'M2,2.5a.5,.5', 59 uiAttached: 'M2,2.5a.5,.5',
......
...@@ -55,12 +55,24 @@ describe('factory: fw/widget/tooltip.js', function () { ...@@ -55,12 +55,24 @@ describe('factory: fw/widget/tooltip.js', function () {
55 }); 55 });
56 56
57 // testing mouse events is tough 57 // testing mouse events is tough
58 - 58 + // showTooltip needs a d3 event, which currently has no test backend
59 + // .each is a workaround, which provides this, d, and i
59 xit('should show a tooltip', function () { 60 xit('should show a tooltip', function () {
60 var btn = d3.select('body').append('div').attr('id', 'foo'); 61 var btn = d3.select('body').append('div').attr('id', 'foo');
61 - // each is used to trigger a "mouse" event, providing this, d, and i
62 btn.each(function () { 62 btn.each(function () {
63 tts.showTooltip(this, 'yay a tooltip'); 63 tts.showTooltip(this, 'yay a tooltip');
64 }); 64 });
65 + // tests here
66 + });
67 +
68 + // can't cancel a tooltip until we show one
69 + // because currElemId isn't set otherwise
70 + xit('should cancel an existing tooltip', function () {
71 + var btn = d3.select('body').append('div').attr('id', 'foo');
72 + btn.each(function () {
73 + tts.cancelTooltip(this);
74 + });
75 + expect(d3Elem.text()).toBe('');
76 + expect(d3Elem.style('display')).toBe('none');
65 }); 77 });
66 }); 78 });
......