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 { |
11 WebInspector.VBox.call(this, true); | 11 WebInspector.VBox.call(this, true); |
12 this.registerRequiredCSS("emulation/sensors.css"); | 12 this.registerRequiredCSS("emulation/sensors.css"); |
13 this.contentElement.classList.add("sensors-view"); | 13 this.contentElement.classList.add("sensors-view"); |
14 | 14 |
15 this._geolocationSetting = WebInspector.settings.createSetting("emulation.ge
olocationOverride", ""); | 15 this._geolocationSetting = WebInspector.settings.createSetting("emulation.ge
olocationOverride", ""); |
16 this._geolocation = WebInspector.Geolocation.parseSetting(this._geolocationS
etting.get()); | 16 this._geolocation = WebInspector.Geolocation.parseSetting(this._geolocationS
etting.get()); |
17 this._geolocationEnabled = false; | 17 this._geolocationEnabled = false; |
18 this._appendGeolocationOverrideControl(); | 18 this._appendGeolocationOverrideControl(); |
19 | 19 |
20 this._deviceOrientationSetting = WebInspector.settings.createSetting("emulat
ion.deviceOrientationOverride", ""); | 20 this._deviceOrientationSetting = WebInspector.settings.createSetting("emulat
ion.deviceOrientationOverride", ""); |
21 this._deviceOrientation = WebInspector.DeviceOrientation.parseSetting(this._
deviceOrientationSetting.get()); | 21 this._deviceOrientation = WebInspector.DeviceOrientation.parseSetting(this._
deviceOrientationSetting.get()); |
22 this._deviceOrientationEnabled = false; | 22 this._deviceOrientationEnabled = false; |
23 this._appendDeviceOrientationOverrideControl(); | 23 this._appendDeviceOrientationOverrideControl(); |
| 24 |
| 25 this._appendTouchControl(); |
24 } | 26 } |
25 | 27 |
26 WebInspector.SensorsView.prototype = { | 28 WebInspector.SensorsView.prototype = { |
27 _appendGeolocationOverrideControl: function() | 29 _appendGeolocationOverrideControl: function() |
28 { | 30 { |
29 var checkboxLabel = createCheckboxLabel(WebInspector.UIString("Emulate g
eolocation coordinates")); | 31 var checkboxLabel = createCheckboxLabel(WebInspector.UIString("Emulate g
eolocation coordinates")); |
30 this._geolocationOverrideCheckbox = checkboxLabel.checkboxElement; | 32 this._geolocationOverrideCheckbox = checkboxLabel.checkboxElement; |
31 this._geolocationOverrideCheckbox.addEventListener("click", this._geoloc
ationOverrideCheckboxClicked.bind(this)); | 33 this._geolocationOverrideCheckbox.addEventListener("click", this._geoloc
ationOverrideCheckboxClicked.bind(this)); |
32 this.contentElement.appendChild(checkboxLabel); | 34 this.contentElement.appendChild(checkboxLabel); |
33 this._geolocationFieldset = this._createGeolocationOverrideElement(this.
_geolocation); | 35 this._geolocationFieldset = this._createGeolocationOverrideElement(this.
_geolocation); |
(...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
290 var radius = Math.max(rect.width, rect.height) / 2; | 292 var radius = Math.max(rect.width, rect.height) / 2; |
291 var sphereX = (x - rect.left - rect.width / 2) / radius; | 293 var sphereX = (x - rect.left - rect.width / 2) / radius; |
292 var sphereY = (y - rect.top - rect.height / 2) / radius; | 294 var sphereY = (y - rect.top - rect.height / 2) / radius; |
293 var sqrSum = sphereX * sphereX + sphereY * sphereY; | 295 var sqrSum = sphereX * sphereX + sphereY * sphereY; |
294 if (sqrSum > 0.5) | 296 if (sqrSum > 0.5) |
295 return new WebInspector.Geometry.Vector(sphereX, sphereY, 0.5 / Math
.sqrt(sqrSum)); | 297 return new WebInspector.Geometry.Vector(sphereX, sphereY, 0.5 / Math
.sqrt(sqrSum)); |
296 | 298 |
297 return new WebInspector.Geometry.Vector(sphereX, sphereY, Math.sqrt(1 -
sqrSum)); | 299 return new WebInspector.Geometry.Vector(sphereX, sphereY, Math.sqrt(1 -
sqrSum)); |
298 }, | 300 }, |
299 | 301 |
| 302 _appendTouchControl: function() |
| 303 { |
| 304 var label = this.contentElement.createChild("label", "touch-label"); |
| 305 label.createChild("span", "").textContent = WebInspector.UIString("Touch
"); |
| 306 var select = label.createChild("select", "chrome-select"); |
| 307 select.appendChild(new Option(WebInspector.UIString("Device-based"), "au
to")); |
| 308 select.appendChild(new Option(WebInspector.UIString("Force enabled"), "e
nabled")); |
| 309 select.addEventListener("change", applyTouch, false); |
| 310 |
| 311 function applyTouch() |
| 312 { |
| 313 WebInspector.MultitargetTouchModel.instance().setCustomTouchEnabled(
select.value === "enabled"); |
| 314 } |
| 315 }, |
| 316 |
300 __proto__ : WebInspector.VBox.prototype | 317 __proto__ : WebInspector.VBox.prototype |
301 } | 318 } |
302 | 319 |
303 /** @enum {string} */ | 320 /** @enum {string} */ |
304 WebInspector.SensorsView.DeviceOrientationModificationSource = { | 321 WebInspector.SensorsView.DeviceOrientationModificationSource = { |
305 UserInput: "userInput", | 322 UserInput: "userInput", |
306 UserDrag: "userDrag", | 323 UserDrag: "userDrag", |
307 ResetButton: "resetButton" | 324 ResetButton: "resetButton" |
308 } | 325 } |
309 | 326 |
(...skipping 21 matching lines...) Expand all Loading... |
331 * @param {!WebInspector.Context} context | 348 * @param {!WebInspector.Context} context |
332 * @param {string} actionId | 349 * @param {string} actionId |
333 * @return {boolean} | 350 * @return {boolean} |
334 */ | 351 */ |
335 handleAction: function(context, actionId) | 352 handleAction: function(context, actionId) |
336 { | 353 { |
337 WebInspector.inspectorView.showViewInDrawer("sensors"); | 354 WebInspector.inspectorView.showViewInDrawer("sensors"); |
338 return true; | 355 return true; |
339 } | 356 } |
340 } | 357 } |
OLD | NEW |