OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 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.App} | 7 * @extends {WebInspector.App} |
8 */ | 8 */ |
9 WebInspector.ScreencastApp = function() | 9 WebInspector.ScreencastApp = function() |
10 { | 10 { |
11 WebInspector.App.call(this); | 11 WebInspector.App.call(this); |
12 | 12 |
13 this._currentScreencastState = WebInspector.settings.createSetting("currentS
creencastState", ""); | 13 var currentScreencastState = WebInspector.settings.createSetting("currentScr
eencastState", ""); |
14 this._lastScreencastState = WebInspector.settings.createSetting("lastScreenc
astState", ""); | 14 var lastScreencastState = WebInspector.settings.createSetting("lastScreencas
tState", ""); |
15 this._toggleScreencastButton = new WebInspector.StatusBarStatesSettingButton
( | 15 this._toggleScreencastButton = new WebInspector.StatusBarStatesSettingButton
( |
16 "screencast-status-bar-item", | 16 "screencast-status-bar-item", |
17 ["disabled", "left", "top"], | 17 ["disabled", "left", "top"], |
18 [WebInspector.UIString("Disable screencast."), WebInspector.UIString("Sw
itch to portrait screencast."), WebInspector.UIString("Switch to landscape scree
ncast.")], | 18 [WebInspector.UIString("Disable screencast."), WebInspector.UIString("Sw
itch to portrait screencast."), WebInspector.UIString("Switch to landscape scree
ncast.")], |
19 this._currentScreencastState, | 19 currentScreencastState.get(), |
20 this._lastScreencastState, | 20 currentScreencastState, |
| 21 lastScreencastState, |
21 this._onStatusBarButtonStateChanged.bind(this)); | 22 this._onStatusBarButtonStateChanged.bind(this)); |
22 }; | 23 }; |
23 | 24 |
24 WebInspector.ScreencastApp.prototype = { | 25 WebInspector.ScreencastApp.prototype = { |
25 createGlobalStatusBarItems: function() | |
26 { | |
27 this.appendInspectStatusBarItem(); | |
28 this.appendSettingsStatusBarItem(); | |
29 WebInspector.inspectorView.appendToRightToolbar(this._toggleScreencastBu
tton.element); | |
30 }, | |
31 | |
32 createRootView: function() | 26 createRootView: function() |
33 { | 27 { |
34 var rootView = new WebInspector.RootView(); | 28 var rootView = new WebInspector.RootView(); |
35 | 29 |
36 this._rootSplitView = new WebInspector.SplitView(false, true, "Inspector
View.screencastSplitViewState", 300, 300); | 30 this._rootSplitView = new WebInspector.SplitView(false, true, "Inspector
View.screencastSplitViewState", 300, 300); |
37 this._rootSplitView.show(rootView.element); | 31 this._rootSplitView.show(rootView.element); |
38 | 32 |
39 WebInspector.inspectorView.show(this._rootSplitView.sidebarElement()); | 33 WebInspector.inspectorView.show(this._rootSplitView.sidebarElement()); |
40 var target = /** @type {!WebInspector.Target} */ (WebInspector.targetMan
ager.activeTarget()); | 34 var target = /** @type {!WebInspector.Target} */ (WebInspector.targetMan
ager.activeTarget()); |
41 this._screencastView = new WebInspector.ScreencastView(target); | 35 this._screencastView = new WebInspector.ScreencastView(target); |
42 this._screencastView.show(this._rootSplitView.mainElement()); | 36 this._screencastView.show(this._rootSplitView.mainElement()); |
43 | 37 |
44 this._onStatusBarButtonStateChanged("disabled"); | 38 this._onStatusBarButtonStateChanged("disabled"); |
45 rootView.attachToBody(); | 39 rootView.attachToBody(); |
46 }, | 40 }, |
47 | 41 |
48 presentUI: function() | 42 presentUI: function() |
49 { | 43 { |
50 WebInspector.App.prototype.presentUI.call(this); | 44 WebInspector.App.prototype.presentUI.call(this); |
51 this._screencastView.initialize(); | 45 this._screencastView.initialize(); |
52 this._toggleScreencastButton.toggleInitialState(); | |
53 }, | 46 }, |
54 | 47 |
55 /** | 48 /** |
56 * @param {string} state | 49 * @param {string} state |
57 */ | 50 */ |
58 _onStatusBarButtonStateChanged: function(state) | 51 _onStatusBarButtonStateChanged: function(state) |
59 { | 52 { |
60 if (state === "disabled") { | 53 if (state === "disabled") { |
61 this._rootSplitView.toggleResizer(this._rootSplitView.resizerElement
(), false); | 54 this._rootSplitView.toggleResizer(this._rootSplitView.resizerElement
(), false); |
62 this._rootSplitView.toggleResizer(WebInspector.inspectorView.topResi
zerElement(), false); | 55 this._rootSplitView.toggleResizer(WebInspector.inspectorView.topResi
zerElement(), false); |
63 this._rootSplitView.hideMain(); | 56 this._rootSplitView.hideMain(); |
64 return; | 57 return; |
65 } | 58 } |
66 | 59 |
67 this._rootSplitView.setVertical(state === "left"); | 60 this._rootSplitView.setVertical(state === "left"); |
68 this._rootSplitView.setSecondIsSidebar(true); | 61 this._rootSplitView.setSecondIsSidebar(true); |
69 this._rootSplitView.toggleResizer(this._rootSplitView.resizerElement(),
true); | 62 this._rootSplitView.toggleResizer(this._rootSplitView.resizerElement(),
true); |
70 this._rootSplitView.toggleResizer(WebInspector.inspectorView.topResizerE
lement(), state === "top"); | 63 this._rootSplitView.toggleResizer(WebInspector.inspectorView.topResizerE
lement(), state === "top"); |
71 this._rootSplitView.showBoth(); | 64 this._rootSplitView.showBoth(); |
72 }, | 65 }, |
73 | 66 |
74 __proto__: WebInspector.App.prototype | 67 __proto__: WebInspector.App.prototype |
75 }; | 68 }; |
| 69 |
| 70 /** |
| 71 * @constructor |
| 72 * @implements {WebInspector.StatusBarButton.Provider} |
| 73 */ |
| 74 WebInspector.ScreencastApp.StatusBarButtonProvider = function() |
| 75 { |
| 76 } |
| 77 |
| 78 WebInspector.ScreencastApp.StatusBarButtonProvider.prototype = { |
| 79 /** |
| 80 * @return {?WebInspector.StatusBarButton} |
| 81 */ |
| 82 button: function() |
| 83 { |
| 84 if (!(WebInspector.app instanceof WebInspector.ScreencastApp)) |
| 85 return null; |
| 86 return /** @type {!WebInspector.ScreencastApp} */ (WebInspector.app)._to
ggleScreencastButton; |
| 87 } |
| 88 } |
OLD | NEW |