diff options
| author | timb <opuscule@gmail.com> | 2015-07-22 00:25:07 -0700 |
|---|---|---|
| committer | timb <opuscule@gmail.com> | 2015-07-22 00:25:07 -0700 |
| commit | a76225dc7f8ec707fc2dc563a796c65620b1c5a4 (patch) | |
| tree | 313932c110e782565224b9ae6be53f39a6325677 /js/matrix.js | |
| parent | 1a009fd877364f5c6616a381d39e33902201a298 (diff) | |
finally hook up undo
Diffstat (limited to 'js/matrix.js')
| -rw-r--r-- | js/matrix.js | 23 |
1 files changed, 22 insertions, 1 deletions
diff --git a/js/matrix.js b/js/matrix.js index 5c56bd4..6994327 100644 --- a/js/matrix.js +++ b/js/matrix.js @@ -4,6 +4,8 @@ function Matrix (w,h,f){ this.w = w this.h = h this.f = f + this.focus_x = 0 + this.focus_y = 0 this.initialize() } Matrix.prototype.initialize = function(f){ @@ -23,6 +25,7 @@ Matrix.prototype.rebuild = function (){ this.append() this.bind() this.generate && this.generate() + this.focus_clamp() check_if_lost_focus() } Matrix.prototype.clone = function () { @@ -70,6 +73,24 @@ Matrix.prototype.forEach = function(f){ }) }) } +Matrix.prototype.focus_clamp = function(){ + this.focus_x = clamp(this.focus_x, 0, this.w - 1) + this.focus_y = clamp(this.focus_y, 0, this.h - 1) +} +Matrix.prototype.focus_add = function(x, y){ + this.focus(this.focus_x + x, this.focus_y + y) +} +Matrix.prototype.focus = function(x, y){ + if (x === undefined) x = this.focus_x + if (y === undefined) y = this.focus_y + x = mod(x, this.w) + y = mod(y, this.h) + this.focus_x = x + this.focus_y = y + + //focused_input = this + this.aa[y][x].focus() +} Matrix.prototype.focusLex = function(y,x){ if (x < 0) { y -= 1 @@ -181,7 +202,7 @@ Matrix.prototype.resize = function(w,h){ this.w = w this.h = h this.bind && this.bind() - + this.focus_clamp() if (this.rapper && this.rapper.parentNode != document.body) { this.resize_rapper() } |
