This one's a frame-changer, guys!

This isn't how mspaint handles these edge cases at all. It just disables
any actions while you're drawing. Maybe I should do that.
main
Isaiah Odhner 2014-06-09 18:46:32 -04:00
parent 76aee3df6a
commit 9eb2c96936
2 changed files with 26 additions and 7 deletions

13
TODO.md
View File

@ -26,15 +26,14 @@
Also, it should gracefully push the dimension displays off the edge instead of covering up the text with usually blank space
* BUG: cropping doesn't update the canvas handles
* It's not supposed to show the canavas handles when there is a selection. It used to hide them but now it doesn't.
* Handle some edge cases
* Undoing/redoing should stop brush drawing
* Undoing/redoing should destroy the selection
* Switching frames in the future should also do the above.
* `this_one_is_a_frame_changer_guys();`
* `invert` is also a frame-changer
* `file_new` (`reset`) is a frame-changer
* `this_ones_a_frame_changer();` (undo, redo, reset, file_open, ... switching between frames of an animation)
* That's not how mspaint handles these edge cases. It disables actions while you're drawing. Maybe I should do that. (It does allow actions when you have a selection, and handles this like I tried to)
* The window can be smaller than the minimum window area of mspaint
* Subwindows should go away at some point. There should only be one of most of them.
* Subwindows should go away at some point. Also, there should only be one of most of them at a time.
* Set up minification?

View File

@ -5,6 +5,8 @@ function reset_colors(){
}
function reset(){
this_ones_a_frame_changer();
undos = [];
redos = [];
reset_colors();
@ -28,6 +30,8 @@ function update_title(){
function open_from_Image(img, new_file_name){
are_you_sure(function(){
this_ones_a_frame_changer();
undos = [];
redos = [];
reset_colors();
@ -262,6 +266,7 @@ function undoable(callback, action){
}
function undo(){
if(undos.length<1) return false;
this_ones_a_frame_changer();
var c = document.createElement("canvas");
c.width = canvas.width;
@ -282,6 +287,7 @@ function undo(){
}
function redo(){
if(redos.length<1) return false;
this_ones_a_frame_changer();
var c = document.createElement("canvas");
c.width = canvas.width;
@ -304,6 +310,10 @@ function cancel(){
if(!selected_tool.passive) undo();
$G.triggerHandler("mouseup", "cancel");
}
function this_ones_a_frame_changer(){
deselect();
$G.triggerHandler("mouseup", "cancel");
}
function deselect(){
if(selection){
selection.draw();
@ -325,6 +335,8 @@ function select_all(){
function invert(){
undoable(0, function(){
this_ones_a_frame_changer();
var id = ctx.getImageData(0, 0, canvas.width, canvas.height);
for(var i=0; i<id.data.length; i+=4){
id.data[i+0] = 255 - id.data[i+0];
@ -339,3 +351,11 @@ function view_bitmap(){
canvas.requestFullscreen && canvas.requestFullscreen();
canvas.webkitRequestFullscreen && canvas.webkitRequestFullscreen();
}
function show_message(title, text){
var $win = new $Window();
$win.title(title).$content.text(text);
$win.$Button("Okay", function(){});
return $win;
}