Skip to content

Commit

Permalink
window focus; pixel editor saving; ~
Browse files Browse the repository at this point in the history
  • Loading branch information
1j01 committed Sep 29, 2013
1 parent 74a95f9 commit 7cf4ed1
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 7 deletions.
2 changes: 2 additions & 0 deletions am.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ ArtManager = function(aa, gui){
new PixelEditor(gui, aa.images[iname], function(img){
aa.images[iname]=img;
am.update();
}, function(img, shiftKey){
window.open(img.src);
});
};
})(i);
Expand Down
9 changes: 7 additions & 2 deletions gui.css
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,14 @@
color: white;
opacity: 0.8;
outline: 1px solid rgba(255,255,255,0.4);
no-outline-offset: 4px;
no-box-shadow: 0 0 1px 4px rgba(0,0,0,0.5);
-no-outline-offset: 4px;
-no-box-shadow: 0 0 1px 4px rgba(0,0,0,0.5);
padding: 4px;
border-radius: 4px;
box-shadow: 0 0 3pt 2pt rgba(255,0,0,0.4);
}
.modal.active {
box-shadow: 0 0 3pt 2pt red;
}
.modal:hover, .modal.dragging {
opacity: 1;
Expand Down
15 changes: 11 additions & 4 deletions gui.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,17 @@ function Modal(_gui){
var windowMouseMove=function(e){m.position(e.clientX-m.ox,e.clientY-m.oy);};
var bringToFront=function(e){
m.$m.style.zIndex=++gui.z;
if(gui.active)gui.active.isActive=false;
if(gui.active){
gui.active.isActive=false
gui.active.$m.classList.remove("active");
}
gui.active=m.onactivate?m.onactivate():m;
gui.active.$m.classList.add("active");
gui.active.isActive=true;
}; bringToFront();
};
bringToFront();
m.focus = bringToFront;

var prevent=function(e){
e.preventDefault();
};
Expand All @@ -60,13 +67,13 @@ function Modal(_gui){
var tbMouseDown=function(e){
if(e.button!==0)return;
e.preventDefault();
m.$m.className=(m.className+" modal dragging").trim();
m.$m.className=(m.className+" modal dragging"+(m.isActive?" active":"")).trim();
m.ox=e.clientX-m.$m.offsetLeft;
m.oy=e.clientY-m.$m.offsetTop;
addEventListener('mousemove', windowMouseMove, true);
};
var mouseUp=function(e){
m.$m.className=(m.className+" modal").trim();
m.$m.className=(m.className+" modal"+(m.isActive?" active":"")).trim();
m.ox=0;
m.oy=0;
removeEventListener('mousemove', windowMouseMove, true);
Expand Down
6 changes: 5 additions & 1 deletion pe.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

/// It's a pixel editor.
// #disposable
PixelEditor = function(gui, img, update){
PixelEditor = function(gui, img, update, save){
var pe = this;
somePixelEditor = pe;

Expand Down Expand Up @@ -373,6 +373,9 @@ PixelEditor = function(gui, img, update){
pe.undoable();
console.log(e.clipboard,e);
break;
case "S"://save (+shift=save as)
e.ctrlKey && save(pe.img, e.shiftKey);
break;
}
//if(String.fromCharCode(e.keyCode).toUpperCase()==="A"){
// return false;
Expand Down Expand Up @@ -551,6 +554,7 @@ PixelEditor = function(gui, img, update){
}
return true;
};
pe.m.focus();
};

/*
Expand Down

0 comments on commit 7cf4ed1

Please sign in to comment.