simplify button selection and allow picking a ternary color before one has been selected

main
Isaiah Odhner 2014-03-03 23:06:08 -05:00
parent 508d2ce9b2
commit 7f35934e65
1 changed files with 9 additions and 11 deletions

20
app.js
View File

@ -719,11 +719,13 @@ app.open = function(){
ctx.fillStyle = fill_color = ctx.fillStyle = fill_color =
ctx.strokeStyle = stroke_color = ctx.strokeStyle = stroke_color =
colors[ colors[
fill_color_i = (ctrl && colors[2]) ? 2 :
stroke_color_i = (reverse ? 1 : 0)
(ctrl && colors[2]) ? 2 :
(reverse ? 1 : 0)
]; ];
fill_color_i =
stroke_color_i =
ctrl ? 2 : (reverse ? 1 : 0)
} }
if(selected_tool[event_name]){ if(selected_tool[event_name]){
@ -871,19 +873,15 @@ app.open = function(){
$buttons.removeClass("selected"); $buttons.removeClass("selected");
if(selected_tool === tool && tool.deselect){ if(selected_tool === tool && tool.deselect){
$.each(tools, function(j, _tool){ selected_tool = previous_tool;
if(_tool === previous_tool){
selected_tool = previous_tool;
previous_tool.$button.addClass("selected");
}
});
}else{ }else{
if(!tool.deselect){ if(!tool.deselect){
previous_tool = tool; previous_tool = tool;
} }
selected_tool = tool; selected_tool = tool;
$b.addClass("selected");
} }
selected_tool.$button.addClass("selected");
}); });
}); });
$buttons = $tools.find(".jspaint-tool"); $buttons = $tools.find(".jspaint-tool");