1

Adding button element

This commit is contained in:
Alex Yatskov 2015-06-29 11:35:50 +09:00
parent df7ba8f128
commit 7d3ea8e5dd

View File

@ -88,6 +88,7 @@
var _height = 500; var _height = 500;
var _padding = 10; var _padding = 10;
var _panelSize = 20; var _panelSize = 20;
var _buttonSize = 20;
var _tickSize = 5; var _tickSize = 5;
var _width = 120; var _width = 120;
@ -110,7 +111,7 @@
_densitySize, _densitySize,
0, 0,
_width - (_bracketSize + _densitySize), _width - (_bracketSize + _densitySize),
_height - _panelSize _height - (_panelSize + _buttonSize)
).attr({ ).attr({
cursor: 'crosshair', cursor: 'crosshair',
stroke: _borderColor, stroke: _borderColor,
@ -122,7 +123,7 @@
0, 0,
0, 0,
_densitySize, _densitySize,
_height - _panelSize _height - (_panelSize + _buttonSize)
).attr({ ).attr({
stroke: _borderColor stroke: _borderColor
}); });
@ -130,7 +131,7 @@
// panel // panel
_elements.panel = _canvas.rect( _elements.panel = _canvas.rect(
0, 0,
_height - _panelSize, _height - (_panelSize + _buttonSize),
_width - _bracketSize, _width - _bracketSize,
_panelSize _panelSize
).attr({ ).attr({
@ -140,7 +141,7 @@
// label // label
_elements.label = _canvas.text( _elements.label = _canvas.text(
(_width - _bracketSize) / 2, (_width - _bracketSize) / 2,
_height - _panelSize / 2, _height - (_panelSize / 2 + _buttonSize),
_name _name
).attr({ ).attr({
'dominant-baseline': 'middle', 'dominant-baseline': 'middle',
@ -152,10 +153,9 @@
_width - _bracketSize, _width - _bracketSize,
0, 0,
_bracketSize, _bracketSize,
_height - _panelSize _height - (_panelSize + _buttonSize)
).attr({ ).attr({
fill: _bracketColorBg, fill: _bracketColorBg
cursor: 'ns-resize'
}).click(bracketClick); }).click(bracketClick);
// indiciator // indiciator
@ -164,6 +164,9 @@
// bracket // bracket
updateBracket(_data.bracket); updateBracket(_data.bracket);
// mode
updateMode();
// tick // tick
if (_range.contains(0.0)) { if (_range.contains(0.0)) {
var origin = valueToIndicator(0.0); var origin = valueToIndicator(0.0);
@ -187,7 +190,8 @@
_elements.bracketMax, _elements.bracketMax,
_elements.panel, _elements.panel,
_elements.tick, _elements.tick,
_elements.label _elements.label,
_elements.button
); );
_elements.group.transform( _elements.group.transform(
@ -253,7 +257,6 @@
fill: _bracketColorBg, fill: _bracketColorBg,
strokeWidth: 1, strokeWidth: 1,
stroke: _bracketColorFg, stroke: _bracketColorFg,
cursor: 'ns-resize',
'stroke-dasharray': '5, 1' 'stroke-dasharray': '5, 1'
}).click(bracketClick); }).click(bracketClick);
} }
@ -293,6 +296,23 @@
} }
} }
function updateMode() {
if (_.has(_elements, 'button')) {
}
else {
_elements.button = _canvas.text(
(_width - _bracketSize) / 2,
_height - _buttonSize / 2,
''
).attr({
'dominant-baseline': 'middle',
'text-anchor': 'middle'
});
}
}
function updateDensity() { function updateDensity() {
var fill = _fillColorBg; var fill = _fillColorBg;
if (_data.hints.length > 0) { if (_data.hints.length > 0) {