little tool for building Wardley maps
on.mouse_press = function(x,y, mouse_button)
	if Cursor_node then
		Cursor_node.show_cursor = nil
		Cursor_node = nil
	end
	local sx, sy = sx(x), sy(y)
	local node = on_node(sx,sy)
	if node then
		-- position cursor in node
		Cursor_node = node
		edit.mouse_press(node.editor, x,y, mouse_button)
		return
	end
	node = on_move_bar(sx,sy)
	if node then
		Move_node = node
		Move = {sx=sx-Move_node.x, sy=sy-Move_node.y}
		return
	end
	node = on_resize(sx,sy)
	if node then
		Resize_node = node
		Resize = {sx=sx-Resize_node.width}
		return
	end
	node = on_border(sx,sy)
	if node then
		local edge = on_edge(sx,sy)
		if edge == nil then
			Edge = {source=node, s={sx=sx, sy=sy}, e={sx=sx, sy=sy}}
		else
			detach_edge(edge)
			Global_next_save = Current_time + 3
			A()
		end
		return
	end
	-- default
	Pan = {sx=sx,sy=sy}
end