OLD | NEW |
---|---|
1 // Copyright (c) 2014 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2014 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.ElementsSidebarPane} | 7 * @extends {WebInspector.ElementsSidebarPane} |
8 */ | 8 */ |
9 WebInspector.AnimationsSidebarPane = function(stylesPane) | 9 WebInspector.AnimationsSidebarPane = function(stylesPane) |
10 { | 10 { |
11 WebInspector.ElementsSidebarPane.call(this, WebInspector.UIString("Animation s")); | 11 WebInspector.ElementsSidebarPane.call(this, WebInspector.UIString("Animation s")); |
12 this._stylesPane = stylesPane; | 12 this._stylesPane = stylesPane; |
13 | 13 |
14 this.headerElement = createElementWithClass("div", "animationsSettings"); | 14 this.headerElement = createElementWithClass("div", "animationsHeader"); |
15 this._globalControls = new WebInspector.AnimationsSidebarPane.GlobalAnimatio nControls(); | |
16 this.headerElement.appendChild(this._globalControls.element); | |
15 this._showSubtreeSetting = WebInspector.settings.createSetting("showSubtreeA nimations", true); | 17 this._showSubtreeSetting = WebInspector.settings.createSetting("showSubtreeA nimations", true); |
18 this._showSubtreeSetting.addChangeListener(this._showSubtreeSettingChanged.b ind(this)); | |
16 this.headerElement.appendChild(WebInspector.AnimationsSidebarPane._showSubtr eeAnimationsCheckbox(this._showSubtreeSetting)); | 19 this.headerElement.appendChild(WebInspector.AnimationsSidebarPane._showSubtr eeAnimationsCheckbox(this._showSubtreeSetting)); |
17 this._showSubtreeSetting.addChangeListener(this._showSubtreeSettingChanged.b ind(this)); | 20 |
18 this._emptyElement = createElement("div"); | 21 this._emptyElement = createElement("div"); |
19 this._emptyElement.className = "info"; | 22 this._emptyElement.className = "info"; |
20 this._emptyElement.textContent = WebInspector.UIString("No Animations"); | 23 this._emptyElement.textContent = WebInspector.UIString("No Animations"); |
21 this.animationsElement = createElement("div"); | 24 this.animationsElement = createElement("div"); |
22 this.animationsElement.appendChild(this._emptyElement); | 25 this.animationsElement.appendChild(this._emptyElement); |
23 | 26 |
24 this._animationSections = []; | 27 this._animationSections = []; |
25 | 28 |
26 this.bodyElement.appendChild(this.headerElement); | 29 this.bodyElement.appendChild(this.headerElement); |
27 this.bodyElement.appendChild(this.animationsElement); | 30 this.bodyElement.appendChild(this.animationsElement); |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
70 var player = animationPlayers[i]; | 73 var player = animationPlayers[i]; |
71 this._animationSections[i] = new WebInspector.AnimationSection(t his, this._stylesPane, player); | 74 this._animationSections[i] = new WebInspector.AnimationSection(t his, this._stylesPane, player); |
72 if (animationPlayers.length < 5) | 75 if (animationPlayers.length < 5) |
73 this._animationSections[i].expand(true); | 76 this._animationSections[i].expand(true); |
74 this.animationsElement.appendChild(this._animationSections[i].el ement); | 77 this.animationsElement.appendChild(this._animationSections[i].el ement); |
75 } | 78 } |
76 finishCallback(); | 79 finishCallback(); |
77 } | 80 } |
78 | 81 |
79 if (!this.node()) { | 82 if (!this.node()) { |
83 this._globalControls.reset(); | |
80 finishCallback(); | 84 finishCallback(); |
81 return; | 85 return; |
82 } | 86 } |
83 | 87 |
84 if (!this._forceUpdate && this._selectedNode === this.node()) { | 88 if (!this._forceUpdate && this._selectedNode === this.node()) { |
85 for (var i = 0; i < this._animationSections.length; ++i) | 89 for (var i = 0; i < this._animationSections.length; ++i) |
86 this._animationSections[i].updateCurrentTime(); | 90 this._animationSections[i].updateCurrentTime(); |
87 finishCallback(); | 91 finishCallback(); |
88 return; | 92 return; |
89 } | 93 } |
(...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
303 var keyframes = this.player.source().keyframesRule().keyframes(); | 307 var keyframes = this.player.source().keyframesRule().keyframes(); |
304 for (var j = 0; j < keyframes.length; j++) { | 308 for (var j = 0; j < keyframes.length; j++) { |
305 var inlineStyle = { selectorText: keyframes[j].offset(), style: keyframes[j].style(), isAttribute: true }; | 309 var inlineStyle = { selectorText: keyframes[j].offset(), style: keyframes[j].style(), isAttribute: true }; |
306 var styleSection = new WebInspector.StylePropertiesSection(this. _stylesPane, inlineStyle, true, false); | 310 var styleSection = new WebInspector.StylePropertiesSection(this. _stylesPane, inlineStyle, true, false); |
307 styleSection.expanded = true; | 311 styleSection.expanded = true; |
308 this._keyframesElement.appendChild(styleSection.element); | 312 this._keyframesElement.appendChild(styleSection.element); |
309 } | 313 } |
310 } | 314 } |
311 } | 315 } |
312 } | 316 } |
317 | |
318 WebInspector.AnimationsSidebarPane._globalPlaybackRates = [0.1, 0.25, 0.5, 1.0, 2.0]; | |
319 | |
320 /** | |
321 * @constructor | |
322 * @extends {WebInspector.StatusBar} | |
323 */ | |
324 WebInspector.AnimationsSidebarPane.GlobalAnimationControls = function() | |
325 { | |
326 WebInspector.StatusBar.call(this); | |
327 this.element.classList.add("global-animations-toolbar"); | |
328 | |
329 this._pauseButton = new WebInspector.StatusBarButton("", "animation-pause"); | |
330 this._pauseButton.addEventListener("click", this._pauseHandler.bind(this), t his); | |
331 this.appendStatusBarItem(this._pauseButton); | |
332 this._playbackRateButtons = []; | |
333 WebInspector.AnimationsSidebarPane._globalPlaybackRates.forEach(this._create PlaybackRateButton.bind(this)); | |
334 this.reset(); | |
335 } | |
336 | |
337 WebInspector.AnimationsSidebarPane.GlobalAnimationControls.prototype = { | |
338 /** | |
339 * @param {number} playbackRate | |
340 */ | |
341 _createPlaybackRateButton: function(playbackRate) | |
342 { | |
343 var button = new WebInspector.StatusBarTextButton(WebInspector.UIString( "Set all animations playback rate to " + playbackRate + "x"), "playback-rate-but ton", playbackRate + "x"); | |
344 button.playbackRate = playbackRate; | |
345 button.addEventListener("click", this._playbackRateHandler.bind(this, bu tton), this); | |
346 this._playbackRateButtons.push(button); | |
347 this.appendStatusBarItem(button); | |
348 }, | |
349 | |
350 reset: function() | |
351 { | |
352 this._paused = false; | |
353 this._playbackRate = 1.0; | |
354 this._updateControls(); | |
355 }, | |
356 | |
357 _updateControls: function() | |
358 { | |
359 this._updatePauseButton(); | |
360 for (var i = 0; i < this._playbackRateButtons.length; i++) | |
361 this._playbackRateButtons[i].setToggled(this._playbackRateButtons[i] .playbackRate === this._playbackRate); | |
362 }, | |
363 | |
364 _updatePauseButton: function() | |
365 { | |
366 this._pauseButton.setToggled(this._paused); | |
367 this._pauseButton.setTitle(this._paused ? WebInspector.UIString("Resume all animations") : WebInspector.UIString("Pause all animations")); | |
368 }, | |
369 | |
370 _pauseHandler: function() | |
371 { | |
372 this._paused = !this._paused; | |
373 PageAgent.setAnimationsPlaybackRate(this._paused ? 0 : this._playbackRat e); | |
374 this._updatePauseButton(); | |
vsevik
2014/11/17 06:03:16
You should also update toggled state of the last t
samli
2014/11/17 06:15:54
From a UI perspective, pause/play & playback rate
| |
375 }, | |
376 | |
377 _playbackRateHandler: function(button) | |
vsevik
2014/11/17 06:03:16
You could actually bind playbackRate directly.
vsevik
2014/11/17 06:03:16
Please annotate
samli
2014/11/17 06:15:54
Done.
samli
2014/11/17 06:15:54
Done.
| |
378 { | |
379 this._playbackRate = button.playbackRate; | |
380 this._updateControls(); | |
381 PageAgent.setAnimationsPlaybackRate(button.playbackRate); | |
382 }, | |
383 | |
384 __proto__: WebInspector.StatusBar.prototype | |
385 } | |
OLD | NEW |