Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(56)

Side by Side Diff: Source/devtools/front_end/elements/AnimationControlPane.js

Issue 1149373004: Devtools: Extensible toolbar in SSP (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Fix test Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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.StylesSidebarPane.BaseToolbarPaneWidget}
7 */ 8 */
8 WebInspector.AnimationControlPane = function() 9 WebInspector.AnimationControlPane = function(toolbarItem)
9 { 10 {
11 WebInspector.StylesSidebarPane.BaseToolbarPaneWidget.call(this, toolbarItem) ;
10 this._animationsPaused = false; 12 this._animationsPaused = false;
11 this._animationsPlaybackRate = 1; 13 this._animationsPlaybackRate = 1;
12 14
13 this.element = createElementWithClass("div", "styles-animations-controls-pan e"); 15 this.element.className = "styles-animations-controls-pane";
14 this.element.createChild("div").createTextChild("Animations"); 16 this.element.createChild("div").createTextChild("Animations");
15 var container = this.element.createChild("div", "animations-controls"); 17 var container = this.element.createChild("div", "animations-controls");
16 18
17 var toolbar = new WebInspector.Toolbar(); 19 var toolbar = new WebInspector.Toolbar();
18 this._animationsPauseButton = new WebInspector.ToolbarButton("", "pause-tool bar-item"); 20 this._animationsPauseButton = new WebInspector.ToolbarButton("", "pause-tool bar-item");
19 toolbar.appendToolbarItem(this._animationsPauseButton); 21 toolbar.appendToolbarItem(this._animationsPauseButton);
20 this._animationsPauseButton.addEventListener("click", this._pauseButtonHandl er.bind(this)); 22 this._animationsPauseButton.addEventListener("click", this._pauseButtonHandl er.bind(this));
21 container.appendChild(toolbar.element); 23 container.appendChild(toolbar.element);
22 24
23 this._animationsPlaybackSlider = container.createChild("input"); 25 this._animationsPlaybackSlider = container.createChild("input");
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
67 { 69 {
68 this._animationsPlaybackSlider.value = WebInspector.AnimationTimelin e.GlobalPlaybackRates.indexOf(playbackRate); 70 this._animationsPlaybackSlider.value = WebInspector.AnimationTimelin e.GlobalPlaybackRates.indexOf(playbackRate);
69 this._animationsPlaybackLabel.textContent = playbackRate + "x"; 71 this._animationsPlaybackLabel.textContent = playbackRate + "x";
70 } 72 }
71 73
72 if (this._target) 74 if (this._target)
73 this._target.animationAgent().getPlaybackRate(setPlaybackRate.bind(t his)); 75 this._target.animationAgent().getPlaybackRate(setPlaybackRate.bind(t his));
74 }, 76 },
75 77
76 /** 78 /**
79 * @override
77 * @param {?WebInspector.DOMNode} node 80 * @param {?WebInspector.DOMNode} node
78 */ 81 */
79 setNode: function(node) 82 onNodeChanged: function(node)
80 { 83 {
81 if (!node) 84 if (!node) {
85 this.detach();
82 return; 86 return;
87 }
83 88
84 if (this._target) 89 if (this._target)
85 this._target.resourceTreeModel.removeEventListener(WebInspector.Reso urceTreeModel.EventTypes.MainFrameNavigated, this._updateAnimationsPlaybackRate, this); 90 this._target.resourceTreeModel.removeEventListener(WebInspector.Reso urceTreeModel.EventTypes.MainFrameNavigated, this._updateAnimationsPlaybackRate, this);
86 91
87 this._target = node.target(); 92 this._target = node.target();
88 this._target.resourceTreeModel.addEventListener(WebInspector.ResourceTre eModel.EventTypes.MainFrameNavigated, this._updateAnimationsPlaybackRate, this); 93 this._target.resourceTreeModel.addEventListener(WebInspector.ResourceTre eModel.EventTypes.MainFrameNavigated, this._updateAnimationsPlaybackRate, this);
89 this._updateAnimationsPlaybackRate(); 94 this._updateAnimationsPlaybackRate();
95 },
96
97 __proto__: WebInspector.StylesSidebarPane.BaseToolbarPaneWidget.prototype
98 }
99
100 /**
101 * @constructor
102 * @implements {WebInspector.ToolbarItem.Provider}
103 */
104 WebInspector.AnimationControlPane.ButtonProvider = function()
105 {
106 this._button = new WebInspector.ToolbarButton(WebInspector.UIString("Animati ons Controls"), "animation-toolbar-item");
107 this._button.addEventListener("click", this._clicked, this);
108 WebInspector.context.addFlavorChangeListener(WebInspector.DOMNode, this._nod eChanged, this);
109 this._nodeChanged();
110 }
111
112 WebInspector.AnimationControlPane.ButtonProvider.prototype = {
113 _animationTimelineModeClick: function()
114 {
115 if (!this._animationTimeline)
116 this._animationTimeline = new WebInspector.AnimationTimeline();
117 this._button.setToggled(!this._animationTimeline.isShowing());
118 var elementsPanel = WebInspector.ElementsPanel.instance();
119 elementsPanel.setWidgetBelowDOM(!this._animationTimeline.isShowing() ? t his._animationTimeline : null);
120 },
121
122 _animationControlPaneModeClick: function()
123 {
124 if (!this._animationsControlPane)
125 this._animationsControlPane = new WebInspector.AnimationControlPane( this.item());
126 var stylesSidebarPane = WebInspector.ElementsPanel.instance().sidebarPan es.styles;
127 stylesSidebarPane.showToolbarPane(!this._animationsControlPane.isShowing () ? this._animationsControlPane : null);
128 },
129
130 _clicked: function()
131 {
132 if (Runtime.experiments.isEnabled("animationInspection"))
133 this._animationTimelineModeClick();
134 else
135 this._animationControlPaneModeClick();
136 },
137
138 _nodeChanged: function()
139 {
140 this._button.setEnabled(!!WebInspector.context.flavor(WebInspector.DOMNo de));
141 },
142
143 /**
144 * @override
145 * @return {!WebInspector.ToolbarItem}
146 */
147 item: function()
148 {
149 return this._button;
90 } 150 }
91
92 } 151 }
OLDNEW
« no previous file with comments | « Source/devtools/devtools.gypi ('k') | Source/devtools/front_end/elements/ElementStatePaneWidget.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698