OLD | NEW |
---|---|
1 <!-- | 1 <!-- |
2 Copyright (C) 2012 Google Inc. All rights reserved. | 2 Copyright (C) 2012 Google Inc. All rights reserved. |
3 | 3 |
4 Redistribution and use in source and binary forms, with or without | 4 Redistribution and use in source and binary forms, with or without |
5 modification, are permitted provided that the following conditions | 5 modification, are permitted provided that the following conditions |
6 are met: | 6 are met: |
7 | 7 |
8 1. Redistributions of source code must retain the above copyright | 8 1. Redistributions of source code must retain the above copyright |
9 notice, this list of conditions and the following disclaimer. | 9 notice, this list of conditions and the following disclaimer. |
10 2. Redistributions in binary form must reproduce the above copyright | 10 2. Redistributions in binary form must reproduce the above copyright |
(...skipping 429 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
440 window.canvasHeight = viewportSize.height; | 440 window.canvasHeight = viewportSize.height; |
441 | 441 |
442 window._controlsVisible = false; | 442 window._controlsVisible = false; |
443 document.querySelector(".controls-line").style.visibility = "hidden"; | 443 document.querySelector(".controls-line").style.visibility = "hidden"; |
444 document.getElementById("element-title").style.visibility = "hidden"; | 444 document.getElementById("element-title").style.visibility = "hidden"; |
445 document.getElementById("tooltip-container").classList.add("hidden"); | 445 document.getElementById("tooltip-container").classList.add("hidden"); |
446 var editor = document.getElementById("editor"); | 446 var editor = document.getElementById("editor"); |
447 editor.style.visibility = "hidden"; | 447 editor.style.visibility = "hidden"; |
448 editor.textContent = ""; | 448 editor.textContent = ""; |
449 document.body.classList.remove("dimmed"); | 449 document.body.classList.remove("dimmed"); |
450 document.removeEventListener("mousemove", onGlobalMouseMove); | 450 document.removeEventListener("mousedown", consumeEvent); |
451 document.removeEventListener("mousemove", onLayoutEditorMouseMove); | |
452 document.removeEventListener("mouseup", consumeEvent); | |
453 document.removeEventListener("click", onLayoutEditorClick); | |
454 document.removeEventListener("keydown", onLayoutEditorKeyDown); | |
455 | |
451 delete window.hoverableAreas; | 456 delete window.hoverableAreas; |
452 delete window.anchorsByType; | 457 delete window.anchorsByType; |
453 window._gridPainted = false; | 458 window._gridPainted = false; |
454 } | 459 } |
455 | 460 |
456 function _drawElementTitle(elementInfo, bounds) | 461 function _drawElementTitle(elementInfo, bounds) |
457 { | 462 { |
458 document.getElementById("tag-name").textContent = elementInfo.tagName; | 463 document.getElementById("tag-name").textContent = elementInfo.tagName; |
459 document.getElementById("node-id").textContent = elementInfo.idValue ? "#" + elementInfo.idValue : ""; | 464 document.getElementById("node-id").textContent = elementInfo.idValue ? "#" + elementInfo.idValue : ""; |
460 var className = elementInfo.className; | 465 var className = elementInfo.className; |
(...skipping 342 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
803 anchorsByType.set(anchorInfo.type, []); | 808 anchorsByType.set(anchorInfo.type, []); |
804 anchorsByType.get(anchorInfo.type).push(anchorInfo); | 809 anchorsByType.get(anchorInfo.type).push(anchorInfo); |
805 editorElement.appendChild(createAnchor(anchorInfo)); | 810 editorElement.appendChild(createAnchor(anchorInfo)); |
806 if (anchorInfo.propertyName === window.draggedPropertyName) | 811 if (anchorInfo.propertyName === window.draggedPropertyName) |
807 selectedAnchorInfo = anchorInfo; | 812 selectedAnchorInfo = anchorInfo; |
808 } | 813 } |
809 | 814 |
810 if (selectedAnchorInfo) | 815 if (selectedAnchorInfo) |
811 showLabels(selectedAnchorInfo.type, selectedAnchorInfo.propertyName); | 816 showLabels(selectedAnchorInfo.type, selectedAnchorInfo.propertyName); |
812 | 817 |
813 document.addEventListener("mousemove", onGlobalMouseMove); | 818 document.addEventListener("mousedown", consumeEvent); |
819 document.addEventListener("mousemove", onLayoutEditorMouseMove); | |
820 document.addEventListener("mouseup", consumeEvent); | |
821 document.addEventListener("click", onLayoutEditorClick); | |
822 document.addEventListener("keydown", onLayoutEditorKeyDown); | |
814 } | 823 } |
815 | 824 |
816 function createAnchor(anchorInfo) | 825 function createAnchor(anchorInfo) |
817 { | 826 { |
818 var handleWidth = 5; | 827 var handleWidth = 5; |
819 context.save(); | 828 context.save(); |
820 context.shadowColor = "rgba(0, 0, 0, 0.34)"; | 829 context.shadowColor = "rgba(0, 0, 0, 0.34)"; |
821 context.shadowBlur = 2; | 830 context.shadowBlur = 2; |
822 context.fillStyle = anchorColorForProperty(anchorInfo); | 831 context.fillStyle = anchorColorForProperty(anchorInfo); |
823 context.beginPath(); | 832 context.beginPath(); |
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1013 // TODO: find a better color | 1022 // TODO: find a better color |
1014 if (!anchorInfo.propertyValue.mutable) | 1023 if (!anchorInfo.propertyValue.mutable) |
1015 return "rgb(159, 188, 191)"; | 1024 return "rgb(159, 188, 191)"; |
1016 | 1025 |
1017 var propertyName = anchorInfo.propertyName; | 1026 var propertyName = anchorInfo.propertyName; |
1018 if (propertyName.startsWith("margin")) | 1027 if (propertyName.startsWith("margin")) |
1019 return "rgb(246, 167, 35)"; | 1028 return "rgb(246, 167, 35)"; |
1020 return "rgb(107, 213, 0)"; | 1029 return "rgb(107, 213, 0)"; |
1021 } | 1030 } |
1022 | 1031 |
1023 function onGlobalMouseMove(event) | 1032 function onLayoutEditorMouseMove(event) |
1024 { | 1033 { |
1034 event.preventDefault(); | |
1025 if (!window.hoverableAreas) | 1035 if (!window.hoverableAreas) |
1026 return; | 1036 return; |
1027 var types = ["padding", "margin"]; | 1037 var types = ["padding", "margin"]; |
1028 for (var type of types) { | 1038 for (var type of types) { |
1029 var path = hoverableAreas.get(type); | 1039 var path = hoverableAreas.get(type); |
1030 if (path && context.isPointInPath(path, deviceScaleFactor * event.x, dev iceScaleFactor * event.y)) { | 1040 if (path && context.isPointInPath(path, deviceScaleFactor * event.x, dev iceScaleFactor * event.y)) { |
1031 showLabels(type); | 1041 showLabels(type); |
1032 break; | 1042 break; |
1033 } | 1043 } |
1034 } | 1044 } |
1035 } | 1045 } |
1036 | 1046 |
1047 function onLayoutEditorClick(event) | |
1048 { | |
1049 event.preventDefault(); | |
1050 InspectorOverlayHost.clearSelection(true); | |
1051 } | |
1052 | |
1053 function onLayoutEditorKeyDown(event) | |
1054 { | |
1055 // clear selection on ESC | |
dgozman
2015/08/28 23:44:11
nit: Clear selection on Esc.
sergeyv
2015/09/02 00:40:58
Done.
| |
1056 if (event.keyIdentifier === "U+001B") { | |
1057 event.preventDefault(); | |
1058 InspectorOverlayHost.clearSelection(false); | |
1059 } | |
1060 } | |
1061 | |
1062 function consumeEvent(event) | |
1063 { | |
1064 event.preventDefault(); | |
1065 } | |
1066 | |
1037 function resetLabelCanvas() | 1067 function resetLabelCanvas() |
1038 { | 1068 { |
1039 delete window.labelCanvasState; | 1069 delete window.labelCanvasState; |
1040 resetCanvas(labelsCanvas); | 1070 resetCanvas(labelsCanvas); |
1041 } | 1071 } |
1042 | 1072 |
1043 window.addEventListener("DOMContentLoaded", onLoaded); | 1073 window.addEventListener("DOMContentLoaded", onLoaded); |
1044 document.addEventListener("keydown", onDocumentKeyDown); | 1074 document.addEventListener("keydown", onDocumentKeyDown); |
1045 | 1075 |
1046 </script> | 1076 </script> |
(...skipping 13 matching lines...) Expand all Loading... | |
1060 </div> | 1090 </div> |
1061 <div id="tooltip-container" class="hidden"> | 1091 <div id="tooltip-container" class="hidden"> |
1062 <div id="element-tooltip"> | 1092 <div id="element-tooltip"> |
1063 <div id="element-description" class="monospace"><span id="material-tag-nam e"></span><span id="material-node-id"></span><span id="material-class-name"></sp an></div> | 1093 <div id="element-description" class="monospace"><span id="material-tag-nam e"></span><span id="material-node-id"></span><span id="material-class-name"></sp an></div> |
1064 <div id="dimensions"><span id="material-node-width"></span>×<span id= "material-node-height"></span></div> | 1094 <div id="dimensions"><span id="material-node-width"></span>×<span id= "material-node-height"></span></div> |
1065 </div> | 1095 </div> |
1066 <div id="element-tooltip-arrow"></div> | 1096 <div id="element-tooltip-arrow"></div> |
1067 <div id="editor" class="fill"></div> | 1097 <div id="editor" class="fill"></div> |
1068 <div id="log"></div> | 1098 <div id="log"></div> |
1069 </html> | 1099 </html> |
OLD | NEW |