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 192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1016 // TODO: find a better color | 1025 // TODO: find a better color |
1017 if (!anchorInfo.propertyValue.mutable) | 1026 if (!anchorInfo.propertyValue.mutable) |
1018 return "rgb(159, 188, 191)"; | 1027 return "rgb(159, 188, 191)"; |
1019 | 1028 |
1020 var propertyName = anchorInfo.propertyName; | 1029 var propertyName = anchorInfo.propertyName; |
1021 if (propertyName.startsWith("margin")) | 1030 if (propertyName.startsWith("margin")) |
1022 return "rgb(246, 167, 35)"; | 1031 return "rgb(246, 167, 35)"; |
1023 return "rgb(107, 213, 0)"; | 1032 return "rgb(107, 213, 0)"; |
1024 } | 1033 } |
1025 | 1034 |
1026 function onGlobalMouseMove(event) | 1035 function onLayoutEditorMouseMove(event) |
1027 { | 1036 { |
1037 event.preventDefault(); | |
1028 if (!window.hoverableAreas) | 1038 if (!window.hoverableAreas) |
1029 return; | 1039 return; |
1030 var types = ["padding", "margin"]; | 1040 var types = ["padding", "margin"]; |
1031 for (var type of types) { | 1041 for (var type of types) { |
1032 var path = hoverableAreas.get(type); | 1042 var path = hoverableAreas.get(type); |
1033 if (path && context.isPointInPath(path, deviceScaleFactor * event.x, dev iceScaleFactor * event.y)) { | 1043 if (path && context.isPointInPath(path, deviceScaleFactor * event.x, dev iceScaleFactor * event.y)) { |
1034 event.preventDefault(); | |
1035 showLabels(type); | 1044 showLabels(type); |
1036 return; | 1045 return; |
1037 } | 1046 } |
1038 } | 1047 } |
1039 resetLabelCanvas(); | 1048 resetLabelCanvas(); |
1040 } | 1049 } |
1041 | 1050 |
1051 function onLayoutEditorClick(event) | |
1052 { | |
1053 event.preventDefault(); | |
1054 InspectorOverlayHost.clearSelection(true); | |
1055 } | |
1056 | |
1057 function onLayoutEditorKeyDown(event) | |
1058 { | |
1059 if (event.keyIdentifier === "U+001B") { | |
pfeldman
2015/08/24 23:18:13
Add comment with the key name.
sergeyv
2015/08/25 17:58:02
Done.
| |
1060 event.preventDefault(); | |
1061 InspectorOverlayHost.clearSelection(false); | |
1062 } | |
1063 } | |
1064 | |
1065 function consumeEvent(event) | |
1066 { | |
1067 event.preventDefault(); | |
1068 } | |
1069 | |
1042 function resetLabelCanvas() | 1070 function resetLabelCanvas() |
1043 { | 1071 { |
1044 delete window.labelCanvasState; | 1072 delete window.labelCanvasState; |
1045 resetCanvas(labelsCanvas); | 1073 resetCanvas(labelsCanvas); |
1046 if (!window.draggedPropertyName && document.body.style.cursor) | 1074 if (!window.draggedPropertyName && document.body.style.cursor) |
1047 document.body.style.cursor = ""; | 1075 document.body.style.cursor = ""; |
1048 } | 1076 } |
1049 | 1077 |
1050 function scalarProduct(v1, v2) | 1078 function scalarProduct(v1, v2) |
1051 { | 1079 { |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1089 </div> | 1117 </div> |
1090 <div id="tooltip-container" class="hidden"> | 1118 <div id="tooltip-container" class="hidden"> |
1091 <div id="element-tooltip"> | 1119 <div id="element-tooltip"> |
1092 <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> | 1120 <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="dimensions"><span id="material-node-width"></span>×<span id= "material-node-height"></span></div> | 1121 <div id="dimensions"><span id="material-node-width"></span>×<span id= "material-node-height"></span></div> |
1094 </div> | 1122 </div> |
1095 <div id="element-tooltip-arrow"></div> | 1123 <div id="element-tooltip-arrow"></div> |
1096 <div id="editor" class="fill"></div> | 1124 <div id="editor" class="fill"></div> |
1097 <div id="log"></div> | 1125 <div id="log"></div> |
1098 </html> | 1126 </html> |
OLD | NEW |