| OLD | NEW |
| 1 // Copyright (c) 2015 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 /** | 5 /** |
| 6 * @constructor | 6 * @constructor |
| 7 * @extends {WebInspector.VBox} | 7 * @extends {WebInspector.VBox} |
| 8 */ | 8 */ |
| 9 WebInspector.SensorsView = function() | 9 WebInspector.SensorsView = function() |
| 10 { | 10 { |
| (...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 123 this._geolocationSetting.set(this._geolocation.toSetting()); | 123 this._geolocationSetting.set(this._geolocation.toSetting()); |
| 124 this._geolocation.apply(); | 124 this._geolocation.apply(); |
| 125 } else { | 125 } else { |
| 126 this._geolocation.clear(); | 126 this._geolocation.clear(); |
| 127 } | 127 } |
| 128 }, | 128 }, |
| 129 | 129 |
| 130 _createDeviceOrientationSection: function() | 130 _createDeviceOrientationSection: function() |
| 131 { | 131 { |
| 132 var orientationGroup = this.contentElement.createChild("section", "senso
rs-group"); | 132 var orientationGroup = this.contentElement.createChild("section", "senso
rs-group"); |
| 133 orientationGroup.createChild("div", "sensors-group-title").textContent =
WebInspector.UIString("Accelerometer"); | 133 orientationGroup.createChild("div", "sensors-group-title").textContent =
WebInspector.UIString("Orientation"); |
| 134 var orientationContent = orientationGroup.createChild("div", "orientatio
n-content"); | 134 var orientationContent = orientationGroup.createChild("div", "orientatio
n-content"); |
| 135 var fields = orientationContent.createChild("div", "orientation-fields")
; | 135 var fields = orientationContent.createChild("div", "orientation-fields")
; |
| 136 | 136 |
| 137 const accelerometerOffOption = {title: WebInspector.UIString("Off"), ori
entation: WebInspector.SensorsView.NonPresetOptions.NoOverride}; | 137 const orientationOffOption = {title: WebInspector.UIString("Off"), orien
tation: WebInspector.SensorsView.NonPresetOptions.NoOverride}; |
| 138 const customOrientationOption = {title: WebInspector.UIString("Custom or
ientation..."), orientation: WebInspector.SensorsView.NonPresetOptions.Custom}; | 138 const customOrientationOption = {title: WebInspector.UIString("Custom or
ientation..."), orientation: WebInspector.SensorsView.NonPresetOptions.Custom}; |
| 139 this._orientationSelectElement = this.contentElement.createChild("select
", "chrome-select"); | 139 this._orientationSelectElement = this.contentElement.createChild("select
", "chrome-select"); |
| 140 this._orientationSelectElement.appendChild(new Option(accelerometerOffOp
tion.title, accelerometerOffOption.orientation)); | 140 this._orientationSelectElement.appendChild(new Option(orientationOffOpti
on.title, orientationOffOption.orientation)); |
| 141 this._orientationSelectElement.appendChild(new Option(customOrientationO
ption.title, customOrientationOption.orientation)); | 141 this._orientationSelectElement.appendChild(new Option(customOrientationO
ption.title, customOrientationOption.orientation)); |
| 142 | 142 |
| 143 var orientationGroups = WebInspector.SensorsView.PresetOrientations; | 143 var orientationGroups = WebInspector.SensorsView.PresetOrientations; |
| 144 for (var i = 0; i < orientationGroups.length; ++i) { | 144 for (var i = 0; i < orientationGroups.length; ++i) { |
| 145 var groupElement = this._orientationSelectElement.createChild("optgr
oup"); | 145 var groupElement = this._orientationSelectElement.createChild("optgr
oup"); |
| 146 groupElement.label = orientationGroups[i].title; | 146 groupElement.label = orientationGroups[i].title; |
| 147 var group = orientationGroups[i].value; | 147 var group = orientationGroups[i].value; |
| 148 for (var j = 0; j < group.length; ++j) | 148 for (var j = 0; j < group.length; ++j) |
| 149 groupElement.appendChild(new Option(group[j].title, group[j].ori
entation)); | 149 groupElement.appendChild(new Option(group[j].title, group[j].ori
entation)); |
| 150 } | 150 } |
| 151 this._orientationSelectElement.selectedIndex = 0; | 151 this._orientationSelectElement.selectedIndex = 0; |
| 152 fields.appendChild(this._orientationSelectElement); | 152 fields.appendChild(this._orientationSelectElement); |
| 153 this._orientationSelectElement.addEventListener("change", this._orientat
ionSelectChanged.bind(this)); | 153 this._orientationSelectElement.addEventListener("change", this._orientat
ionSelectChanged.bind(this)); |
| 154 | 154 |
| 155 this._deviceOrientationFieldset = this._createDeviceOrientationOverrideE
lement(this._deviceOrientation); | 155 this._deviceOrientationFieldset = this._createDeviceOrientationOverrideE
lement(this._deviceOrientation); |
| 156 | 156 |
| 157 this._stageElement = orientationContent.createChild("div", "acceleromete
r-stage"); | 157 this._stageElement = orientationContent.createChild("div", "orientation-
stage"); |
| 158 this._stageElement.title = WebInspector.UIString("Shift+drag to rotate a
round the y-axis"); | 158 this._stageElement.title = WebInspector.UIString("Shift+drag horizontall
y to rotate around the y-axis"); |
| 159 this._boxElement = this._stageElement.createChild("section", "accelerome
ter-box accelerometer-element"); | 159 this._boxElement = this._stageElement.createChild("section", "orientatio
n-box orientation-element"); |
| 160 | 160 |
| 161 this._boxElement.createChild("section", "accelerometer-front acceleromet
er-element"); | 161 this._boxElement.createChild("section", "orientation-front orientation-e
lement"); |
| 162 this._boxElement.createChild("section", "accelerometer-top accelerometer
-element"); | 162 this._boxElement.createChild("section", "orientation-top orientation-ele
ment"); |
| 163 this._boxElement.createChild("section", "accelerometer-back acceleromete
r-element"); | 163 this._boxElement.createChild("section", "orientation-back orientation-el
ement"); |
| 164 this._boxElement.createChild("section", "accelerometer-left acceleromete
r-element"); | 164 this._boxElement.createChild("section", "orientation-left orientation-el
ement"); |
| 165 this._boxElement.createChild("section", "accelerometer-right acceleromet
er-element"); | 165 this._boxElement.createChild("section", "orientation-right orientation-e
lement"); |
| 166 this._boxElement.createChild("section", "accelerometer-bottom accelerome
ter-element"); | 166 this._boxElement.createChild("section", "orientation-bottom orientation-
element"); |
| 167 | 167 |
| 168 WebInspector.installDragHandle(this._stageElement, this._onBoxDragStart.
bind(this), this._onBoxDrag.bind(this), null, "-webkit-grabbing", "-webkit-grab"
); | 168 WebInspector.installDragHandle(this._stageElement, this._onBoxDragStart.
bind(this), this._onBoxDrag.bind(this), null, "-webkit-grabbing", "-webkit-grab"
); |
| 169 | 169 |
| 170 fields.appendChild(this._deviceOrientationFieldset); | 170 fields.appendChild(this._deviceOrientationFieldset); |
| 171 this._enableOrientationFields(true); | 171 this._enableOrientationFields(true); |
| 172 this._setBoxOrientation(this._deviceOrientation); | 172 this._setBoxOrientation(this._deviceOrientation); |
| 173 }, | 173 }, |
| 174 | 174 |
| 175 /** | 175 /** |
| 176 * @param {?boolean} disable | 176 * @param {?boolean} disable |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 271 }, | 271 }, |
| 272 | 272 |
| 273 /** | 273 /** |
| 274 * @param {!Element} parentElement | 274 * @param {!Element} parentElement |
| 275 * @param {!Element} input | 275 * @param {!Element} input |
| 276 * @param {string} label | 276 * @param {string} label |
| 277 * @return {function(string)} | 277 * @return {function(string)} |
| 278 */ | 278 */ |
| 279 _createAxisInput: function(parentElement, input, label) | 279 _createAxisInput: function(parentElement, input, label) |
| 280 { | 280 { |
| 281 var div = parentElement.createChild("div", "accelerometer-axis-input-con
tainer"); | 281 var div = parentElement.createChild("div", "orientation-axis-input-conta
iner"); |
| 282 div.appendChild(input); | 282 div.appendChild(input); |
| 283 div.createTextChild(label); | 283 div.createTextChild(label); |
| 284 input.type = "number"; | 284 input.type = "number"; |
| 285 return WebInspector.bindInput(input, this._applyDeviceOrientationUserInp
ut.bind(this), WebInspector.DeviceOrientation.validator, true); | 285 return WebInspector.bindInput(input, this._applyDeviceOrientationUserInp
ut.bind(this), WebInspector.DeviceOrientation.validator, true); |
| 286 }, | 286 }, |
| 287 | 287 |
| 288 /** | 288 /** |
| 289 * @param {!WebInspector.DeviceOrientation} deviceOrientation | 289 * @param {!WebInspector.DeviceOrientation} deviceOrientation |
| 290 * @return {!Element} | 290 * @return {!Element} |
| 291 */ | 291 */ |
| 292 _createDeviceOrientationOverrideElement: function(deviceOrientation) | 292 _createDeviceOrientationOverrideElement: function(deviceOrientation) |
| 293 { | 293 { |
| 294 var fieldsetElement = createElement("fieldset"); | 294 var fieldsetElement = createElement("fieldset"); |
| 295 fieldsetElement.classList.add("device-orientation-override-section"); | 295 fieldsetElement.classList.add("device-orientation-override-section"); |
| 296 var cellElement = fieldsetElement.createChild("td", "accelerometer-input
s-cell"); | 296 var cellElement = fieldsetElement.createChild("td", "orientation-inputs-
cell"); |
| 297 | 297 |
| 298 this._alphaElement = createElement("input"); | 298 this._alphaElement = createElement("input"); |
| 299 this._alphaSetter = this._createAxisInput(cellElement, this._alphaElemen
t, WebInspector.UIString("\u03B1 (alpha)")); | 299 this._alphaSetter = this._createAxisInput(cellElement, this._alphaElemen
t, WebInspector.UIString("\u03B1 (alpha)")); |
| 300 this._alphaSetter(String(deviceOrientation.alpha)); | 300 this._alphaSetter(String(deviceOrientation.alpha)); |
| 301 | 301 |
| 302 this._betaElement = createElement("input"); | 302 this._betaElement = createElement("input"); |
| 303 this._betaSetter = this._createAxisInput(cellElement, this._betaElement,
WebInspector.UIString("\u03B2 (beta)")); | 303 this._betaSetter = this._createAxisInput(cellElement, this._betaElement,
WebInspector.UIString("\u03B2 (beta)")); |
| 304 this._betaSetter(String(deviceOrientation.beta)); | 304 this._betaSetter(String(deviceOrientation.beta)); |
| 305 | 305 |
| 306 this._gammaElement = createElement("input"); | 306 this._gammaElement = createElement("input"); |
| 307 this._gammaSetter = this._createAxisInput(cellElement, this._gammaElemen
t, WebInspector.UIString("\u03B3 (gamma)")); | 307 this._gammaSetter = this._createAxisInput(cellElement, this._gammaElemen
t, WebInspector.UIString("\u03B3 (gamma)")); |
| 308 this._gammaSetter(String(deviceOrientation.gamma)); | 308 this._gammaSetter(String(deviceOrientation.gamma)); |
| 309 | 309 |
| 310 cellElement.appendChild(createTextButton(WebInspector.UIString("Reset"),
this._resetDeviceOrientation.bind(this), "accelerometer-reset-button")); | 310 cellElement.appendChild(createTextButton(WebInspector.UIString("Reset"),
this._resetDeviceOrientation.bind(this), "orientation-reset-button")); |
| 311 return fieldsetElement; | 311 return fieldsetElement; |
| 312 }, | 312 }, |
| 313 | 313 |
| 314 /** | 314 /** |
| 315 * @param {!WebInspector.DeviceOrientation} deviceOrientation | 315 * @param {!WebInspector.DeviceOrientation} deviceOrientation |
| 316 */ | 316 */ |
| 317 _setBoxOrientation: function(deviceOrientation) | 317 _setBoxOrientation: function(deviceOrientation) |
| 318 { | 318 { |
| 319 var matrix = this._viewportPreviewMatrix(true); | 319 var matrix = this._viewportPreviewMatrix(true); |
| 320 this._boxMatrix = matrix.rotate(-deviceOrientation.beta, deviceOrientati
on.gamma, -deviceOrientation.alpha); | 320 this._boxMatrix = matrix.rotate(-deviceOrientation.beta, deviceOrientati
on.gamma, -deviceOrientation.alpha); |
| (...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 511 * @return {boolean} | 511 * @return {boolean} |
| 512 */ | 512 */ |
| 513 handleAction: function(context, actionId) | 513 handleAction: function(context, actionId) |
| 514 { | 514 { |
| 515 WebInspector.inspectorView.showViewInDrawer("sensors"); | 515 WebInspector.inspectorView.showViewInDrawer("sensors"); |
| 516 return true; | 516 return true; |
| 517 } | 517 } |
| 518 } | 518 } |
| 519 | 519 |
| 520 WebInspector.SensorsView.ShiftDragOrientationSpeed = 16; | 520 WebInspector.SensorsView.ShiftDragOrientationSpeed = 16; |
| OLD | NEW |