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
3 // found in the LICENSE file.
7 * @extends {WebInspector.App}
9 WebInspector.ScreencastApp = function()
11 WebInspector.App.call(this);
13 var lastScreencastState = WebInspector.settings.createSetting("lastScreencastState", "left");
14 this._currentScreencastState = WebInspector.settings.createSetting("currentScreencastState", "disabled");
15 this._toggleScreencastButton = new WebInspector.StatusBarStatesSettingButton(
16 "screencast-status-bar-item",
17 ["disabled", "left", "top"],
18 [WebInspector.UIString("Disable screencast."), WebInspector.UIString("Switch to portrait screencast."), WebInspector.UIString("Switch to landscape screencast.")],
19 this._currentScreencastState.get(),
20 this._currentScreencastState,
22 this._onStatusBarButtonStateChanged.bind(this));
25 WebInspector.ScreencastApp.prototype = {
26 createRootView: function()
28 var rootView = new WebInspector.RootView();
30 this._rootSplitView = new WebInspector.SplitView(false, true, "InspectorView.screencastSplitViewState", 300, 300);
31 this._rootSplitView.show(rootView.element);
32 this._rootSplitView.hideMain();
34 WebInspector.inspectorView.show(this._rootSplitView.sidebarElement());
35 rootView.attachToBody();
39 * @param {!WebInspector.Target} mainTarget
41 presentUI: function(mainTarget)
43 if (mainTarget.hasCapability(WebInspector.Target.Capabilities.CanScreencast)) {
44 this._screencastView = new WebInspector.ScreencastView(mainTarget);
45 this._screencastView.show(this._rootSplitView.mainElement());
46 this._screencastView.initialize();
47 this._onStatusBarButtonStateChanged(this._currentScreencastState.get());
49 this._onStatusBarButtonStateChanged("disabled");
50 this._toggleScreencastButton.setEnabled(false);
52 WebInspector.App.prototype.presentUI.call(this, mainTarget);
56 * @param {string} state
58 _onStatusBarButtonStateChanged: function(state)
60 if (!this._rootSplitView)
62 if (state === "disabled") {
63 this._rootSplitView.toggleResizer(this._rootSplitView.resizerElement(), false);
64 this._rootSplitView.toggleResizer(WebInspector.inspectorView.topResizerElement(), false);
65 this._rootSplitView.hideMain();
69 this._rootSplitView.setVertical(state === "left");
70 this._rootSplitView.setSecondIsSidebar(true);
71 this._rootSplitView.toggleResizer(this._rootSplitView.resizerElement(), true);
72 this._rootSplitView.toggleResizer(WebInspector.inspectorView.topResizerElement(), state === "top");
73 this._rootSplitView.showBoth();
76 __proto__: WebInspector.App.prototype
81 * @implements {WebInspector.StatusBarItem.Provider}
83 WebInspector.ScreencastApp.StatusBarButtonProvider = function()
87 WebInspector.ScreencastApp.StatusBarButtonProvider.prototype = {
89 * @return {?WebInspector.StatusBarItem}
93 if (!(WebInspector.app instanceof WebInspector.ScreencastApp))
95 return /** @type {!WebInspector.ScreencastApp} */ (WebInspector.app)._toggleScreencastButton;