summaryrefslogtreecommitdiff
path: root/js/ui/selection.js
diff options
context:
space:
mode:
authorJules Laplace <jules@okfoc.us>2015-03-24 18:16:36 -0400
committerJules Laplace <jules@okfoc.us>2015-03-24 18:16:36 -0400
commit8410a217e2a02257bd3a9d05e26c51cc8ae33086 (patch)
treed7d5d5e536153234b8641ece8b3ee46cc193f879 /js/ui/selection.js
parent5f5127573a185e8070ecff31c2b69e8911843b7e (diff)
no tabs
Diffstat (limited to 'js/ui/selection.js')
-rw-r--r--js/ui/selection.js62
1 files changed, 31 insertions, 31 deletions
diff --git a/js/ui/selection.js b/js/ui/selection.js
index cbd15bf..f818d04 100644
--- a/js/ui/selection.js
+++ b/js/ui/selection.js
@@ -2,16 +2,16 @@ var selection = (function(){
var creating = false, moving = false, copying = false
- var selection_canvas = new Matrix (1, 1, function(x,y){
- var lex = new Lex (x,y)
- lex.build()
- return lex
- })
-
- var selector_el = document.createElement("div")
- selector_el.className = "selector_el"
- selection_canvas.append(selector_el)
- document.body.appendChild(selector_el)
+ var selection_canvas = new Matrix (1, 1, function(x,y){
+ var lex = new Lex (x,y)
+ lex.build()
+ return lex
+ })
+
+ var selector_el = document.createElement("div")
+ selector_el.className = "selector_el"
+ selection_canvas.append(selector_el)
+ document.body.appendChild(selector_el)
// in selection mode..
// - we start by clicking the canvas. this positions the selection, and copies
@@ -28,7 +28,7 @@ var selection = (function(){
var d = [0, 0]
function reset () {
- a[0] = a[1] = b[0] = b[1] = 0
+ a[0] = a[1] = b[0] = b[1] = 0
}
function left (a,b) { return min(a[0],b[0]) }
function top (a,b) { return min(a[1],b[1]) }
@@ -39,8 +39,8 @@ var selection = (function(){
function mag_x (a,b) { return a[0]-b[0] }
function mag_y (a,b) { return a[1]-b[1] }
function orient (a,b) {
- var l = left(a,b), m = top(a,b), n = right(a,b), o = bottom(a,b)
- a[0] = l ; a[1] = m ; b[0] = n ; b[1] = o
+ var l = left(a,b), m = top(a,b), n = right(a,b), o = bottom(a,b)
+ a[0] = l ; a[1] = m ; b[0] = n ; b[1] = o
}
function contains (a,b,point) {
@@ -70,9 +70,9 @@ var selection = (function(){
a[1] = point[1]
b[0] = point[0]
b[1] = point[1]
- reposition(a,b)
+ reposition(a,b)
selector_el.classList.add("creating")
- } else {
+ } else {
copying = false
moving = true
creating = false
@@ -82,7 +82,7 @@ var selection = (function(){
d[1] = point[1]
}
show()
- selector_el.classList.remove("dragging")
+ selector_el.classList.remove("dragging")
}
function move (e, lex, point){
if (creating) {
@@ -101,26 +101,26 @@ var selection = (function(){
}
}
function up (e) {
- if (creating) {
- orient(a,b)
- selection_canvas.resize(width(a,b), height(a,b))
- blit.copy_from( canvas, selection_canvas, a[0], a[1] )
- selection_canvas.build()
+ if (creating) {
+ orient(a,b)
+ selection_canvas.resize(width(a,b), height(a,b))
+ blit.copy_from( canvas, selection_canvas, a[0], a[1] )
+ selection_canvas.build()
selector_el.classList.remove("creating")
- }
- if (moving) {
+ }
+ if (moving) {
var dx = - clamp( mag_x(c,d), b[0] - canvas.w + 1, a[0] )
var dy = - clamp( mag_y(c,d), b[1] - canvas.h + 1, a[1] )
a[0] += dx
a[1] += dy
b[0] += dx
b[1] += dy
- blit.copy_to( canvas, selection_canvas, a[0], a[1] )
- }
- if (copying) {
- }
- creating = moving = copying = false
- selector_el.classList.remove("dragging")
+ blit.copy_to( canvas, selection_canvas, a[0], a[1] )
+ }
+ if (copying) {
+ }
+ creating = moving = copying = false
+ selector_el.classList.remove("dragging")
}
function show () {
@@ -128,7 +128,7 @@ var selection = (function(){
controls.grid.show()
}
function hide () {
- reset()
+ reset()
selector_el.style.top = "-9999px"
selector_el.style.left = "-9999px"
selector_el.style.width = "0px"
@@ -143,6 +143,6 @@ var selection = (function(){
selection.canvas = selection_canvas
selection.show = show
selection.hide = hide
- return selection
+ return selection
})()