Layer shortcuts

This commit is contained in:
Devine Lu Linvega 2018-01-20 11:50:38 +13:00
parent e34146ba87
commit 27d2e90965
5 changed files with 17 additions and 14 deletions

View File

@ -168,6 +168,12 @@ function Cursor(rune)
ronin.commander.update();
}
this.select_layer = function(layer)
{
this.target = layer;
ronin.commander.update();
}
function make_offset(a,b)
{
return {x:a.x-b.x,y:a.y-b.y};

View File

@ -82,16 +82,6 @@ function Keyboard()
ronin.io.methods.save.run();
}
if(e.key == "x"){
e.preventDefault();
ronin.cursor.swap_colors();
}
if(e.key == "z"){
e.preventDefault();
ronin.cursor.swap_layer();
}
ronin.hint.update(e);
}
}

View File

@ -12,9 +12,6 @@ function Layer(name)
this.update = function(zoom = {scale:1,offset:{x:0,y:0}})
{
console.log(`Updated ${this.name}`);
// this.el.style.width = (ronin.frame.width)+"px";
// this.el.style.height = (ronin.frame.height)+"px";
}
this.context = function()

View File

@ -55,6 +55,11 @@ function Frame()
ronin.frame.el.style.height = `${ronin.frame.height * ronin.frame.zoom.scale}px`;
ronin.frame.zoom.offset.x = ronin.frame.zoom.scale == 1 ? 0 : ((-ronin.cursor.pos.x * ronin.frame.zoom.scale) + (ronin.frame.width/2));
ronin.frame.zoom.offset.y = ronin.frame.zoom.scale == 1 ? 0 : ((-ronin.cursor.pos.y * ronin.frame.zoom.scale) + (ronin.frame.height/2));
// Normalize
if(ronin.frame.zoom.offset.x > 0){ ronin.frame.zoom.offset.x = 0; }
if(ronin.frame.zoom.offset.y > 0){ ronin.frame.zoom.offset.y = 0; }
ronin.frame.el.style.top = `${ronin.frame.zoom.offset.y}px`;
ronin.frame.el.style.left = `${ronin.frame.zoom.offset.x}px`;
});

View File

@ -76,10 +76,15 @@ function Ronin()
this.controller.add("default","File","Open",() => { ronin.open(); },"CmdOrCtrl+O");
this.controller.add("default","File","Save",() => { ronin.save(); },"CmdOrCtrl+S");
this.controller.add("default","Layers","Above Layer",() => { ronin.cursor.select_layer(ronin.layers.above); },"c");
this.controller.add("default","Layers","Below Layer",() => { ronin.cursor.select_layer(ronin.layers.below); },"z");
this.controller.add("default","Layers","Toggle Layer",() => { ronin.cursor.swap_layer(); },"x");
this.controller.add("default","Brush","Inc Size",() => { ronin.brush.mod_size(1); },"]");
this.controller.add("default","Brush","Dec Size",() => { ronin.brush.mod_size(-1); },"[");
this.controller.add("default","Brush","Toggle Color",() => { ronin.cursor.swap_colors(); },"x");
this.controller.add("default","View","Reset Zoom",() => { ronin.frame.methods.zoom.run(1); },"1");
this.controller.add("default","View","Zoom Reset",() => { ronin.frame.methods.zoom.run(1); },"1");
this.controller.add("default","View","Zoom 2x",() => { ronin.frame.methods.zoom.run(2); },"2");
this.controller.add("default","View","Zoom 4x",() => { ronin.frame.methods.zoom.run(4); },"3");