parent
cc01ea1496
commit
da7689d785
|
@ -33,10 +33,14 @@ function $ToolBox(tools, is_extras){
|
||||||
});
|
});
|
||||||
|
|
||||||
$b.on("click", function(e){
|
$b.on("click", function(e){
|
||||||
|
if (e.shiftKey) {
|
||||||
|
select_tool(tool, true);
|
||||||
|
return;
|
||||||
|
}
|
||||||
if(selected_tool === tool && tool.deselect){
|
if(selected_tool === tool && tool.deselect){
|
||||||
select_tool(previous_tool);
|
select_tool(previous_tool);
|
||||||
}else{
|
}else{
|
||||||
select_tool(tool, e.shiftKey);
|
select_tool(tool);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -555,6 +555,8 @@ $canvas.on("pointerdown", function(e){
|
||||||
pointer_start = pointer_previous = pointer = e2c(e);
|
pointer_start = pointer_previous = pointer = e2c(e);
|
||||||
|
|
||||||
var pointerdown_action = function(){
|
var pointerdown_action = function(){
|
||||||
|
selected_tools.forEach((selected_tool)=> {
|
||||||
|
|
||||||
if(selected_tool.paint || selected_tool.pointerdown){
|
if(selected_tool.paint || selected_tool.pointerdown){
|
||||||
tool_go("pointerdown");
|
tool_go("pointerdown");
|
||||||
}
|
}
|
||||||
|
@ -571,14 +573,17 @@ $canvas.on("pointerdown", function(e){
|
||||||
pointer = e2c(e);
|
pointer = e2c(e);
|
||||||
selected_tool.pointerup && selected_tool.pointerup(ctx, pointer.x, pointer.y);
|
selected_tool.pointerup && selected_tool.pointerup(ctx, pointer.x, pointer.y);
|
||||||
}
|
}
|
||||||
|
if (selected_tools.length === 0) {
|
||||||
if(selected_tool.deselect){
|
if(selected_tool.deselect){
|
||||||
select_tool(previous_tool);
|
select_tool(previous_tool);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
$G.off("pointermove", canvas_pointer_move);
|
$G.off("pointermove", canvas_pointer_move);
|
||||||
if(iid){
|
if(iid){
|
||||||
clearInterval(iid);
|
clearInterval(iid);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
if((typeof selected_tool.passive === "function") ? selected_tool.passive() : selected_tool.passive){
|
if((typeof selected_tool.passive === "function") ? selected_tool.passive() : selected_tool.passive){
|
||||||
|
|
|
@ -774,20 +774,32 @@ function get_tool_by_name(name){
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function select_tool(tool, add){
|
function select_tool(tool, toggle){
|
||||||
if(!selected_tool.deselect){
|
if(!selected_tool.deselect){
|
||||||
previous_tool = selected_tool;
|
previous_tool = selected_tool;
|
||||||
}
|
}
|
||||||
selected_tool = tool;
|
if (toggle) {
|
||||||
if (add) {
|
var index = selected_tools.indexOf(tool);
|
||||||
selected_tools.push(tool);
|
if (index === -1) {
|
||||||
|
selected_tools.push(tool);
|
||||||
|
} else {
|
||||||
|
selected_tools.splice(index, 1);
|
||||||
|
}
|
||||||
|
if (selected_tools.length > 0) {
|
||||||
|
selected_tool = selected_tools[selected_tools.length - 1];
|
||||||
|
} else {
|
||||||
|
selected_tool = tools[6];
|
||||||
|
selected_tools = [selected_tool];
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
|
selected_tool = tool;
|
||||||
selected_tools = [tool];
|
selected_tools = [tool];
|
||||||
}
|
}
|
||||||
|
|
||||||
deselect();
|
deselect();
|
||||||
if(selected_tool.activate){
|
|
||||||
selected_tool.activate();
|
if(tool.preload){
|
||||||
|
tool.preload();
|
||||||
}
|
}
|
||||||
|
|
||||||
$toolbox.update_selected_tool();
|
$toolbox.update_selected_tool();
|
||||||
|
|
|
@ -367,7 +367,7 @@ tools = [{
|
||||||
description: "Inserts text into the picture.",
|
description: "Inserts text into the picture.",
|
||||||
cursor: ["precise", [16, 16], "crosshair"],
|
cursor: ["precise", [16, 16], "crosshair"],
|
||||||
passive: true,
|
passive: true,
|
||||||
activate: function(){
|
preload: function(){
|
||||||
setTimeout(FontDetective.preload, 10);
|
setTimeout(FontDetective.preload, 10);
|
||||||
},
|
},
|
||||||
drag_start_x: 0,
|
drag_start_x: 0,
|
||||||
|
|
Loading…
Reference in New Issue