Select multiple tools haha this sucks

It's not even bad in a fun way, because the tools share state and basically one wins, for the most part.

You can combine airbrush and brush which is nice... altho you have to select airbrush second for it to be continuous over time.

If you select select as the last thing you can use it with other tools, and then with Ctrl+I to invert, you can do something like this: https://i.imgur.com/DXbc2GT.png
main
Isaiah Odhner 2019-09-20 01:36:39 -04:00
parent 35c2af0143
commit cc01ea1496
3 changed files with 14 additions and 4 deletions

View File

@ -32,11 +32,11 @@ function $ToolBox(tools, is_extras){
backgroundPosition: bx + "px " + -by + "px",
});
$b.on("click", function(){
$b.on("click", function(e){
if(selected_tool === tool && tool.deselect){
select_tool(previous_tool);
}else{
select_tool(tool);
select_tool(tool, e.shiftKey);
}
});
@ -61,7 +61,9 @@ function $ToolBox(tools, is_extras){
var $c = $Component(is_extras ? "Extra Tools" : "Tools", "tall", $tools.add($tool_options));
$c.update_selected_tool = function(){
$buttons.removeClass("selected");
selected_tool.$button.addClass("selected");
selected_tools.forEach((selected_tool)=> {
selected_tool.$button.addClass("selected");
});
$tool_options.children().detach();
$tool_options.append(selected_tool.$options);
$tool_options.children().trigger("update");

View File

@ -27,6 +27,7 @@ var stroke_color_k = 0;
var fill_color_k = 0;
var selected_tool = tools[6];
var selected_tools = [selected_tool];
var previous_tool = selected_tool;
var colors = {
foreground: "",
@ -428,6 +429,7 @@ function e2c(e){
}
function tool_go(event_name){
selected_tools.forEach((selected_tool)=> {
ctx.lineWidth = stroke_size;
@ -480,6 +482,7 @@ function tool_go(event_name){
selected_tool.paint(ctx, pointer.x, pointer.y);
}
}
});
}
function canvas_pointer_move(e){
ctrl = e.ctrlKey;

View File

@ -774,11 +774,16 @@ function get_tool_by_name(name){
}
}
function select_tool(tool){
function select_tool(tool, add){
if(!selected_tool.deselect){
previous_tool = selected_tool;
}
selected_tool = tool;
if (add) {
selected_tools.push(tool);
} else {
selected_tools = [tool];
}
deselect();
if(selected_tool.activate){