Skip to content

Commit

Permalink
added various features for hypertree to qtree behavior
Browse files Browse the repository at this point in the history
  • Loading branch information
stevewirts committed May 1, 2015
1 parent 42bd4f5 commit d0830d2
Show file tree
Hide file tree
Showing 9 changed files with 139 additions and 57 deletions.
97 changes: 69 additions & 28 deletions fin-hypergrid.dev.html
Original file line number Diff line number Diff line change
Expand Up @@ -21914,7 +21914,6 @@
var cellProvider = this.getGrid().getCellProvider();
var viewWidth = this.getBounds().width() - 200; // look in fin-hypergrid and initializtion of fin-canvas
var viewHeight = behavior.getFixedRowsHeight();
var fixedColumnCount = behavior.getFixedColumnCount();

for (var c = 0; c < numColumns; c++) {
var width = this.getColumnWidth(c + scrollLeft);
Expand All @@ -21930,10 +21929,6 @@
//reset this for this pass..
this.renderedColumnMinWidths[c + scrollLeft] = 0;

if (c < fixedColumnCount) {
this.renderedFixedColumnMinWidths[c] = 0;
}

for (var r = 0; r < numRows; r++) {

var height = this.getFixedRowHeight(r);
Expand All @@ -21948,9 +21943,6 @@

//lets capture the col preferred widths for col autosizing
this.renderedColumnMinWidths[c + scrollLeft] = Math.max(cell.config.minWidth || 0, this.renderedColumnMinWidths[c + scrollLeft]);
if (c < fixedColumnCount) {
this.renderedFixedColumnMinWidths[c] = Math.max(cell.config.minWidth || 0, this.renderedFixedColumnMinWidths[c]);
}

if (behavior.highlightCellOnHover(isColumnHovered, isRowHovered)) {
ctx.beginPath();
Expand Down Expand Up @@ -22176,6 +22168,8 @@
ctx.fillStyle = bgColor;
ctx.fillRect(x, y, x + width, viewHeight - y);

this.renderedFixedColumnMinWidths[c] = 0;

for (; r < numRows; r++) {
var height = this.getFixedRowHeight(r);
if (y > viewHeight || numRows <= r) {
Expand All @@ -22194,9 +22188,13 @@

cell.paint(ctx, x, y, width, height);

var minWidth = cell.config ? cell.config.minWidth : 0;
this.renderedFixedColumnMinWidths[c] = Math.max(minWidth || 0, this.renderedFixedColumnMinWidths[c]);

y = y + height;
}


x = x + width;
}
},
Expand Down Expand Up @@ -23241,6 +23239,12 @@
var isFixed = gridCell.x < grid.getFixedColumnCount();
return isFixed;
},

isTopLeft: function(grid, event) {
var isTopLeft = this.isFixedRow(grid, event) && this.isFixedColumn(grid, event);
return isTopLeft;
},

setCursor: function(grid) {
if (this.next) {
this.next.setCursor(grid);
Expand Down Expand Up @@ -23611,19 +23615,20 @@
gc.closePath();
}
}

var iconWidth = 0;
if (leftIcon) {
iyoffset = Math.round((height - leftIcon.height) / 2);
ixoffset = Math.round((halignOffset - leftIcon.width) / 2);
gc.drawImage(leftIcon, x + ixoffset, y + iyoffset);
this.config.minWidth = this.config.minWidth + leftIcon.width + 6;
iconWidth = Math.max(leftIcon.width);
}
if (rightIcon) {
iyoffset = Math.round((height - rightIcon.height) / 2);
ixoffset = Math.round((halignOffset - rightIcon.width) / 2);
gc.drawImage(rightIcon, x + width - ixoffset - rightIcon.width, y + iyoffset);
this.config.minWidth = this.config.minWidth + rightIcon.width + 6;
iconWidth = Math.max(rightIcon.width);
}
this.config.minWidth = this.config.minWidth + 2 * (iconWidth + 2);
},

//emersons paint function for a slider button. currently the user cannot interact with it
Expand Down Expand Up @@ -27080,8 +27085,9 @@

['up-rectangle', 'iVBORw0KGgoAAAANSUhEUgAAAAkAAAAECAYAAABcDxXOAAAABGdBTUEAALGPC/xhBQAAAAlwSFlzAAAOwgAADsIBFShKgAAAABp0RVh0U29mdHdhcmUAUGFpbnQuTkVUIHYzLjUuMTFH80I3AAAAHklEQVQYV2PAAv5DaZwApACGsQJkBVgVYlMAxQwMABOrD/GvP+EWAAAAAElFTkSuQmCC'],
['down-rectangle', 'iVBORw0KGgoAAAANSUhEUgAAAAkAAAAECAYAAABcDxXOAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAAadEVYdFNvZnR3YXJlAFBhaW50Lk5FVCB2My41LjExR/NCNwAAABpJREFUGFdjgIL/eDAKIKgABggqgAE0BQwMAPTlD/Fpi0JfAAAAAElFTkS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Ars4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAAYdEVYdFNvZnR3YXJlAHBhaW50Lm5ldCA0LjAuNWWFMmUAAAA+SURBVBhXhYvRCgAgCAOtqP//4+WWhtBDB1duqBUQ/2W5LLtSMFyW020skuecwOGj6QzfkuExt1LlcqICgG3S7z/SL/jVpgAAAABJRU5ErkJggg==']
];
Expand Down Expand Up @@ -30416,6 +30422,12 @@
A: 'D',
};

var imageMap = {
u: 'up-rectangle',
d: 'down-rectangle',
'': 'rectangle-spacer'
};

Polymer('fin-hypergrid-behavior-qtree',{ /* jslint ignore:line */
ready: function() {
this.block = {
Expand All @@ -30440,6 +30452,22 @@
this.msgCounter = Date.now();
this.msgResponsesActions = {};

var cursorChanger = function(grid, event) {
if (this.isTopLeft(grid, event)) {
this.cursor = 'pointer';
} else {
this.cursor = null;
}
if (this.next) {
this.next.handleMouseMove(grid, event);
}
};
var self = this;
setTimeout(function() {
self.featureChain.handleMouseMove = cursorChanger;
cursorChanger.bind(self.featureChain);
}, 500);

},
getFixedRowCount: function() {
return 2;
Expand Down Expand Up @@ -30521,7 +30549,8 @@
// return clone;
// }
//var hValue = this.block.Z[0].g_[0];
var clone = [this.getImage('up-rectangle'), 'Hierarchy', this.getSortIndicator(hierarchyColumn)];
var image = this.getClickIndicator(hierarchyColumn);
var clone = [image, 'Hierarchy', this.getSortIndicator(hierarchyColumn)];
//clone[0] = clone[0] + ' ' + sortIndicator;
return clone;
},
Expand All @@ -30531,7 +30560,7 @@
getValue: function(x, y) {
var col = this.getColumnId(x);
var normalized = Math.floor(y - this.scrollPositionY);
if (this.block && col) {
if (this.block && (typeof col === 'string')) {
var val = this.block.Z[1][col][normalized];
if (val || val === 0) {
return val;
Expand Down Expand Up @@ -30598,8 +30627,9 @@
},

getClickIndicator: function(colId) {
noop(colId);
return this.getImage('down-rectangle');
var direction = this.block.C[colId];
var image = this.getImage(imageMap[direction]);
return image;
},

getSortIndicator: function(colId) {
Expand Down Expand Up @@ -30726,13 +30756,18 @@
var colId = hierarchyColumn;
var colWidth = this.getFixedColumnWidth(0);
var mousePoint = mouse.mousePoint.x;
var direction = this.block.C[hierarchyColumn];
if (mousePoint < (colWidth / 2)) {
var colClick = {
id: this.getNextMessageId(),
fn: 'col',
col: colId
};
this.sendMessage(colClick);
if (direction) {
var colClick = {
id: this.getNextMessageId(),
fn: 'col',
col: colId
};
this.sendMessage(colClick);
} else {
return;
}
} else {
this._toggleSort(colId);
}
Expand All @@ -30754,15 +30789,18 @@

fixedRowClicked: function(grid, mouse) {
var colId = this.getColumnId(mouse.gridCell.x);
var direction = this.block.C[colId];
var colWidth = this.getColumnWidth(mouse.gridCell.x);
var mousePoint = mouse.mousePoint.x;
if (mousePoint < (colWidth / 2)) {
var colClick = {
id: this.getNextMessageId(),
fn: 'col',
col: colId
};
this.sendMessage(colClick);
if (direction) {
var colClick = {
id: this.getNextMessageId(),
fn: 'col',
col: colId
};
this.sendMessage(colClick);
}
} else {
this.toggleSort(mouse.gridCell.x);
}
Expand Down Expand Up @@ -30790,6 +30828,9 @@
},

openEditor: function(div) {
if (!this.block.W) {
return false;
}
var self = this;
var container = document.createElement('div');

Expand Down
2 changes: 1 addition & 1 deletion fin-hypergrid.min.html

Large diffs are not rendered by default.

Binary file added images/rectangle-spacer.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified images/sortable.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 2 additions & 1 deletion polymer/js/behaviors/fin-hypergrid-behavior-base.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,9 @@

['up-rectangle', 'iVBORw0KGgoAAAANSUhEUgAAAAkAAAAECAYAAABcDxXOAAAABGdBTUEAALGPC/xhBQAAAAlwSFlzAAAOwgAADsIBFShKgAAAABp0RVh0U29mdHdhcmUAUGFpbnQuTkVUIHYzLjUuMTFH80I3AAAAHklEQVQYV2PAAv5DaZwApACGsQJkBVgVYlMAxQwMABOrD/GvP+EWAAAAAElFTkSuQmCC'],
['down-rectangle', 'iVBORw0KGgoAAAANSUhEUgAAAAkAAAAECAYAAABcDxXOAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAAadEVYdFNvZnR3YXJlAFBhaW50Lk5FVCB2My41LjExR/NCNwAAABpJREFUGFdjgIL/eDAKIKgABggqgAE0BQwMAPTlD/Fpi0JfAAAAAElFTkSuQmCC'],
['rectangle-spacer', 'iVBORw0KGgoAAAANSUhEUgAAAAkAAAAECAYAAABcDxXOAAAABGdBTUEAALGPC/xhBQAAAAlwSFlzAAAOwQAADsEBuJFr7QAAABh0RVh0U29mdHdhcmUAcGFpbnQubmV0IDQuMC41ZYUyZQAAAA1JREFUGFdjGHSAgQEAAJQAAY8LvLEAAAAASUVORK5CYII='],

['sortable', 'iVBORw0KGgoAAAANSUhEUgAAAAcAAAAKCAYAAAB4zEQNAAAABGdBTUEAALGPC/xhBQAAAAlwSFlzAAAOwQAADsEBuJFr7QAAABh0RVh0U29mdHdhcmUAcGFpbnQubmV0IDQuMC41ZYUyZQAAAC5JREFUKFNjQAP/oTQGAEnAMApAlkBRgE0ChikA2IyDYTDAKQEDOCVgAEmCgQEA4DEf4Wk8bewAAAAASUVORK5CYII='],
['sortable', 'iVBORw0KGgoAAAANSUhEUgAAAA4AAAAKCAYAAACE2W/HAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAAYdEVYdFNvZnR3YXJlAHBhaW50Lm5ldCA0LjAuNWWFMmUAAAAxSURBVChTY8AD/kNpkgBIEwwTDZA1Ea0ZmyYYHmQAmxNhmCAgSxMMkKUJBvBoYmAAAJCXH+FU1T8+AAAAAElFTkSuQmCC'],
['up-arrow', 'iVBORw0KGgoAAAANSUhEUgAAAAUAAAAKCAYAAAB8OZQwAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAAYdEVYdFNvZnR3YXJlAHBhaW50Lm5ldCA0LjAuNWWFMmUAAAA9SURBVBhXbYvRCgAgCAOtqP//Y9tElw8NDrcDzd0DBCd7iSL3E0IvGOpf2fKXeZUFKDcYFMwBlDNWS76bXUM5P9In5AzyAAAAAElFTkSuQmCC'],
['down-arrow', 'iVBORw0KGgoAAAANSUhEUgAAAAUAAAAKCAYAAAB8OZQwAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAAYdEVYdFNvZnR3YXJlAHBhaW50Lm5ldCA0LjAuNWWFMmUAAAA+SURBVBhXhYvRCgAgCAOtqP//4+WWhtBDB1duqBUQ/2W5LLtSMFyW020skuecwOGj6QzfkuExt1LlcqICgG3S7z/SL/jVpgAAAABJRU5ErkJggg==']
];
Expand Down
67 changes: 51 additions & 16 deletions polymer/js/behaviors/fin-hypergrid-behavior-qtree.js
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,12 @@
A: 'D',
};

var imageMap = {
u: 'up-rectangle',
d: 'down-rectangle',
'': 'rectangle-spacer'
};

Polymer({ /* jslint ignore:line */
ready: function() {
this.block = {
Expand All @@ -163,6 +169,22 @@
this.msgCounter = Date.now();
this.msgResponsesActions = {};

var cursorChanger = function(grid, event) {
if (this.isTopLeft(grid, event)) {
this.cursor = 'pointer';
} else {
this.cursor = null;
}
if (this.next) {
this.next.handleMouseMove(grid, event);
}
};
var self = this;
setTimeout(function() {
self.featureChain.handleMouseMove = cursorChanger;
cursorChanger.bind(self.featureChain);
}, 500);

},
getFixedRowCount: function() {
return 2;
Expand Down Expand Up @@ -244,7 +266,8 @@
// return clone;
// }
//var hValue = this.block.Z[0].g_[0];
var clone = [this.getImage('up-rectangle'), 'Hierarchy', this.getSortIndicator(hierarchyColumn)];
var image = this.getClickIndicator(hierarchyColumn);
var clone = [image, 'Hierarchy', this.getSortIndicator(hierarchyColumn)];
//clone[0] = clone[0] + ' ' + sortIndicator;
return clone;
},
Expand All @@ -254,7 +277,7 @@
getValue: function(x, y) {
var col = this.getColumnId(x);
var normalized = Math.floor(y - this.scrollPositionY);
if (this.block && col) {
if (this.block && (typeof col === 'string')) {
var val = this.block.Z[1][col][normalized];
if (val || val === 0) {
return val;
Expand Down Expand Up @@ -321,8 +344,9 @@
},

getClickIndicator: function(colId) {
noop(colId);
return this.getImage('down-rectangle');
var direction = this.block.C[colId];
var image = this.getImage(imageMap[direction]);
return image;
},

getSortIndicator: function(colId) {
Expand Down Expand Up @@ -449,13 +473,18 @@
var colId = hierarchyColumn;
var colWidth = this.getFixedColumnWidth(0);
var mousePoint = mouse.mousePoint.x;
var direction = this.block.C[hierarchyColumn];
if (mousePoint < (colWidth / 2)) {
var colClick = {
id: this.getNextMessageId(),
fn: 'col',
col: colId
};
this.sendMessage(colClick);
if (direction) {
var colClick = {
id: this.getNextMessageId(),
fn: 'col',
col: colId
};
this.sendMessage(colClick);
} else {
return;
}
} else {
this._toggleSort(colId);
}
Expand All @@ -477,15 +506,18 @@

fixedRowClicked: function(grid, mouse) {
var colId = this.getColumnId(mouse.gridCell.x);
var direction = this.block.C[colId];
var colWidth = this.getColumnWidth(mouse.gridCell.x);
var mousePoint = mouse.mousePoint.x;
if (mousePoint < (colWidth / 2)) {
var colClick = {
id: this.getNextMessageId(),
fn: 'col',
col: colId
};
this.sendMessage(colClick);
if (direction) {
var colClick = {
id: this.getNextMessageId(),
fn: 'col',
col: colId
};
this.sendMessage(colClick);
}
} else {
this.toggleSort(mouse.gridCell.x);
}
Expand Down Expand Up @@ -513,6 +545,9 @@
},

openEditor: function(div) {
if (!this.block.W) {
return false;
}
var self = this;
var container = document.createElement('div');

Expand Down
6 changes: 6 additions & 0 deletions polymer/js/features/fin-hypergrid-feature-base.js
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,12 @@
var isFixed = gridCell.x < grid.getFixedColumnCount();
return isFixed;
},

isTopLeft: function(grid, event) {
var isTopLeft = this.isFixedRow(grid, event) && this.isFixedColumn(grid, event);
return isTopLeft;
},

setCursor: function(grid) {
if (this.next) {
this.next.setCursor(grid);
Expand Down
Loading

0 comments on commit d0830d2

Please sign in to comment.