|
|
@ -1,5 +1,6 @@ |
|
|
|
import File; |
|
|
|
import GUI; |
|
|
|
import * as Keys from GUI.Keys; |
|
|
|
import Scoria; |
|
|
|
import * as Zoom from Toolbar.Zoom; |
|
|
|
import * as Async from UnitJS.Async; |
|
|
@ -11,20 +12,13 @@ GUI.wcThreshold.addEventListener('change', refresh); |
|
|
|
GUI.loadScoria.addEventListener('click', importScoria); |
|
|
|
GUI.saveScoria.addEventListener('click', exportScoria); |
|
|
|
|
|
|
|
GUI.fitWidth.addEventListener('click', function() { |
|
|
|
Zoom.setScalingMode({fitWidth: true}); |
|
|
|
refresh(); |
|
|
|
}); |
|
|
|
|
|
|
|
GUI.zoomAmount.addEventListener('change', function() { |
|
|
|
Zoom.setScalingMode({zoom: GUI.zoomAmount.value}); |
|
|
|
refresh(); |
|
|
|
}); |
|
|
|
|
|
|
|
GUI.fitHeight.addEventListener('click', function() { |
|
|
|
Zoom.setScalingMode({fitHeight: true}); |
|
|
|
refresh(); |
|
|
|
}); |
|
|
|
GUI.fitWidth.addEventListener('click', scale({fitWidth: true})); |
|
|
|
GUI.zoomAmount.addEventListener('change', scale({zoom: GUI.zoomAmount.value})); |
|
|
|
GUI.fitHeight.addEventListener('click', scale({fitHeight: true})); |
|
|
|
Keys.bind('w', scale({fitWidth: true})); |
|
|
|
Keys.bind('h', scale({fitHeight: true})); |
|
|
|
Keys.bind('+', scale(function(x) {return Math.min(GUI.zoomAmount.max, x + 10);})); |
|
|
|
Keys.bind('-', scale(function(x) {return Math.max(GUI.zoomAmount.min, x - 10);})); |
|
|
|
|
|
|
|
return { |
|
|
|
open: open |
|
|
@ -49,6 +43,16 @@ function refresh() { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
function scale(o) { |
|
|
|
return function() { |
|
|
|
if(typeof o == 'function') { |
|
|
|
o.zoom = GUI.zoomAmount.value = o(1*GUI.zoomAmount.value); |
|
|
|
} |
|
|
|
Zoom.setScalingMode(o); |
|
|
|
refresh(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
function importScoria() { |
|
|
|
Async.run( |
|
|
|
Async.bind( |
|
|
|