OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2014 Google Inc. All rights reserved. | 2 * Copyright (C) 2014 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 are | 5 * modification, are permitted provided that the following conditions are |
6 * met: | 6 * met: |
7 * | 7 * |
8 * * Redistributions of source code must retain the above copyright | 8 * * 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 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
(...skipping 577 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
588 if (product < 0) | 588 if (product < 0) |
589 return undefined; | 589 return undefined; |
590 } | 590 } |
591 return t; | 591 return t; |
592 }, | 592 }, |
593 | 593 |
594 /** | 594 /** |
595 * @param {?Event} event | 595 * @param {?Event} event |
596 * @return {?WebInspector.Layers3DView.ActiveObject} | 596 * @return {?WebInspector.Layers3DView.ActiveObject} |
597 */ | 597 */ |
598 _layerFromEventPoint: function(event) | 598 _activeObjectFromEventPoint: function(event) |
599 { | 599 { |
600 if (!this._layerTree) | 600 if (!this._layerTree) |
601 return null; | 601 return null; |
602 var closestIntersectionPoint = Infinity; | 602 var closestIntersectionPoint = Infinity; |
603 var closestLayer = null; | 603 var closestLayer = null; |
604 var projectionMatrix = new WebKitCSSMatrix().scale(1, -1, -1).translate(
-1, -1, 0).multiply(this._calculateProjectionMatrix()); | 604 var projectionMatrix = new WebKitCSSMatrix().scale(1, -1, -1).translate(
-1, -1, 0).multiply(this._calculateProjectionMatrix()); |
605 var x0 = (event.clientX - this._canvasElement.totalOffsetLeft()) * windo
w.devicePixelRatio; | 605 var x0 = (event.clientX - this._canvasElement.totalOffsetLeft()) * windo
w.devicePixelRatio; |
606 var y0 = -(event.clientY - this._canvasElement.totalOffsetTop()) * windo
w.devicePixelRatio; | 606 var y0 = -(event.clientY - this._canvasElement.totalOffsetTop()) * windo
w.devicePixelRatio; |
607 | 607 |
608 /** | 608 /** |
(...skipping 22 matching lines...) Expand all Loading... |
631 | 631 |
632 this._layerTree.forEachLayer(checkIntersection.bind(this)); | 632 this._layerTree.forEachLayer(checkIntersection.bind(this)); |
633 return closestLayer; | 633 return closestLayer; |
634 }, | 634 }, |
635 | 635 |
636 /** | 636 /** |
637 * @param {?Event} event | 637 * @param {?Event} event |
638 */ | 638 */ |
639 _onContextMenu: function(event) | 639 _onContextMenu: function(event) |
640 { | 640 { |
641 var layer = this._layerFromEventPoint(event).layer; | 641 var activeObject = this._activeObjectFromEventPoint(event); |
642 var node = layer ? layer.nodeForSelfOrAncestor() : null; | 642 var node = activeObject && activeObject.layer && activeObject.layer.node
ForSelfOrAncestor(); |
643 var contextMenu = new WebInspector.ContextMenu(event); | 643 var contextMenu = new WebInspector.ContextMenu(event); |
644 contextMenu.appendItem("Reset view", this._transformController._resetAnd
Notify.bind(this._transformController), false); | 644 contextMenu.appendItem("Reset view", this._transformController._resetAnd
Notify.bind(this._transformController), false); |
645 if (node) | 645 if (node) |
646 contextMenu.appendApplicableItems(node); | 646 contextMenu.appendApplicableItems(node); |
647 contextMenu.show(); | 647 contextMenu.show(); |
648 }, | 648 }, |
649 | 649 |
650 /** | 650 /** |
651 * @param {?Event} event | 651 * @param {?Event} event |
652 */ | 652 */ |
653 _onMouseMove: function(event) | 653 _onMouseMove: function(event) |
654 { | 654 { |
655 if (event.which) | 655 if (event.which) |
656 return; | 656 return; |
657 this.dispatchEventToListeners(WebInspector.Layers3DView.Events.ObjectHov
ered, this._layerFromEventPoint(event)); | 657 this.dispatchEventToListeners(WebInspector.Layers3DView.Events.ObjectHov
ered, this._activeObjectFromEventPoint(event)); |
658 }, | 658 }, |
659 | 659 |
660 /** | 660 /** |
661 * @param {?Event} event | 661 * @param {?Event} event |
662 */ | 662 */ |
663 _onMouseDown: function(event) | 663 _onMouseDown: function(event) |
664 { | 664 { |
665 this._mouseDownX = event.clientX; | 665 this._mouseDownX = event.clientX; |
666 this._mouseDownY = event.clientY; | 666 this._mouseDownY = event.clientY; |
667 }, | 667 }, |
668 | 668 |
669 /** | 669 /** |
670 * @param {?Event} event | 670 * @param {?Event} event |
671 */ | 671 */ |
672 _onMouseUp: function(event) | 672 _onMouseUp: function(event) |
673 { | 673 { |
674 const maxDistanceInPixels = 6; | 674 const maxDistanceInPixels = 6; |
675 if (this._mouseDownX && Math.abs(event.clientX - this._mouseDownX) < max
DistanceInPixels && Math.abs(event.clientY - this._mouseDownY) < maxDistanceInPi
xels) | 675 if (this._mouseDownX && Math.abs(event.clientX - this._mouseDownX) < max
DistanceInPixels && Math.abs(event.clientY - this._mouseDownY) < maxDistanceInPi
xels) |
676 this.dispatchEventToListeners(WebInspector.Layers3DView.Events.Objec
tSelected, this._layerFromEventPoint(event)); | 676 this.dispatchEventToListeners(WebInspector.Layers3DView.Events.Objec
tSelected, this._activeObjectFromEventPoint(event)); |
677 delete this._mouseDownX; | 677 delete this._mouseDownX; |
678 delete this._mouseDownY; | 678 delete this._mouseDownY; |
679 }, | 679 }, |
680 | 680 |
681 /** | 681 /** |
682 * @param {?Event} event | 682 * @param {?Event} event |
683 */ | 683 */ |
684 _onDoubleClick: function(event) | 684 _onDoubleClick: function(event) |
685 { | 685 { |
686 var object = this._layerFromEventPoint(event); | 686 var object = this._activeObjectFromEventPoint(event); |
687 if (object && object.layer) | 687 if (object && object.layer) |
688 this.dispatchEventToListeners(WebInspector.Layers3DView.Events.Layer
SnapshotRequested, object.layer); | 688 this.dispatchEventToListeners(WebInspector.Layers3DView.Events.Layer
SnapshotRequested, object.layer); |
689 event.stopPropagation(); | 689 event.stopPropagation(); |
690 }, | 690 }, |
691 | 691 |
692 __proto__: WebInspector.VBox.prototype | 692 __proto__: WebInspector.VBox.prototype |
693 } | 693 } |
OLD | NEW |