diff --git a/web_editor/assets/add.svg b/web_editor/assets/add.svg new file mode 100644 index 0000000..7a4b6b8 --- /dev/null +++ b/web_editor/assets/add.svg @@ -0,0 +1,5 @@ + + + + + diff --git a/web_editor/assets/pedestrian.svg b/web_editor/assets/pedestrian.svg new file mode 100644 index 0000000..3d608c5 --- /dev/null +++ b/web_editor/assets/pedestrian.svg @@ -0,0 +1,3 @@ + + + diff --git a/web_editor/index.html b/web_editor/index.html index b8327cb..71cf799 100644 --- a/web_editor/index.html +++ b/web_editor/index.html @@ -28,6 +28,9 @@ + diff --git a/web_editor/js/cards.js b/web_editor/js/cards.js index 94d3b6d..f416aad 100644 --- a/web_editor/js/cards.js +++ b/web_editor/js/cards.js @@ -11,7 +11,8 @@ export function makeLaneCard(lane, idx, app) { } node.appendChild(wrapInCenterDiv(width(lane))); - var finalRow = document.createElement("div"); + var editRow = document.createElement("div"); + editRow.align = "center"; var left = iconObj("left"); if (idx != 0) { @@ -23,15 +24,14 @@ export function makeLaneCard(lane, idx, app) { } else { left.disabled = true; } - finalRow.appendChild(left); - finalRow.align = "center"; + editRow.appendChild(left); var trash = iconObj("delete"); trash.onclick = () => { app.road.lanes.splice(idx, 1); app.render(); }; - finalRow.appendChild(trash); + editRow.appendChild(trash); var right = iconObj("right"); if (idx != app.road.lanes.length - 1) { @@ -43,9 +43,23 @@ export function makeLaneCard(lane, idx, app) { } else { right.disabled = true; } - finalRow.appendChild(right); + editRow.appendChild(right); - node.append(finalRow); + node.append(editRow); + + if (idx != app.road.lanes.length - 1) { + var add = iconObj("add"); + add.className = "insert-lane"; + add.onclick = () => { + app.road.lanes.splice(idx + 1, 0, { + type: "travel", + direction: "backward", + designated: "motor_vehicle", + }); + app.render(); + }; + node.append(add); + } return node; } @@ -60,6 +74,9 @@ function typeIcon(lane) { if (lane.type == "travel" && lane.designated == "motor_vehicle") { return icon("car"); } + if (lane.type == "travel" && lane.designated == "foot") { + return icon("pedestrian"); + } if (lane.type == "parking" && lane.designated == "motor_vehicle") { return icon("parking"); } @@ -71,10 +88,20 @@ function typeIcon(lane) { function directionIcon(lane) { if (lane.direction == "forward") { - return icon("forwards"); + var obj = iconObj("forwards"); + obj.onclick = () => { + lane.direction = "backward"; + app.render(); + }; + return obj; } if (lane.direction == "backward") { - return icon("backwards"); + var obj = iconObj("backwards"); + obj.onclick = () => { + lane.direction = "forward"; + app.render(); + }; + return obj; } if (lane.direction == "both") { return icon("both_ways"); diff --git a/web_editor/js/main.js b/web_editor/js/main.js index 356ac09..b0f5f14 100644 --- a/web_editor/js/main.js +++ b/web_editor/js/main.js @@ -127,5 +127,12 @@ export class LaneEditor { }); this.render(); }; + document.getElementById("new-sidewalk").onclick = () => { + this.road.lanes.push({ + type: "travel", + designated: "foot", + }); + this.render(); + }; } } diff --git a/web_editor/main.css b/web_editor/main.css index 53a3ad5..791a662 100644 --- a/web_editor/main.css +++ b/web_editor/main.css @@ -6,6 +6,8 @@ .card { outline: solid; padding: 15px; + /* So child elements can use position=absolute */ + position: relative; } .card button { @@ -33,6 +35,13 @@ width: 50px; } +.insert-lane { + position: absolute; + right: -15px; + bottom: 0px; + z-index: 1; +} + table, td { border: 1px solid black;