s.state.focusedButton); } setFocusedButton(focusedButton) { const { buttonIds } = this.state; focusedButton = focusedButton && buttonIds.includes(focusedButton) ? focusedButton : buttonIds[0]; if (this.state.focusedButton !== focusedButton) { this.setState({ focusedButton, }); } } setCurrentToolId(currentToolId) { this.setState({ currentToolId }, () => { // Also set the currently focused button to this tool. this.setFocusedButton(currentToolId); }); } setCanRender() { this.setState({ canRender: true }, this.updateButtonIds); } highlightTool(highlightedTool) { const { highlightedTools } = this.state; highlightedTools.add(highlightedTool); this.setState({ highlightedTools }); } unhighlightTool(id) { const { highlightedTools } = this.state; if (highlightedTools.has(id)) { highlightedTools.delete(id); this.setState({ highlightedTools }); } } setDockOptionsEnabled(areDockOptionsEnabled) { this.setState({ areDockOptionsEnabled }); } setHostTypes(hostTypes) { this.setState({ hostTypes }); } setCurrentHostType(currentHostType) { this.setState({ currentHostType }); } setCanCloseToolbox(canCloseToolbox) { this.setState({ canCloseToolbox }, this.updateButtonIds); } setIsSplitConsoleActive(isSplitConsoleActive) { this.setState({ isSplitConsoleActive }); } /** * @param {bool | undefined} disableAutohide */ setDisableAutohide(disableAutohide) { this.setState({ disableAutohide }); } /** * @param {bool | undefined} alwaysOnTop */ setAlwaysOnTop(alwaysOnTop) { this.setState({ alwaysOnTop }); } /** * @param {bool} focusedState */ setFocusedState(focusedState) { // We only care about the focused state when the toolbox is always on top if (this.state.alwaysOnTop) { this.setState({ focusedState }); } } /** * @param {"bidi" | "accented" | "none" | undefined} pseudoLocale */ setPseudoLocale(pseudoLocale) { this.setState({ pseudoLocale }); } setPanelDefinitions(panelDefinitions) { this.setState({ panelDefinitions }, this.updateButtonIds); } get panelDefinitions() { return this.state.panelDefinitions; } setToolboxButtons(toolboxButtons) { // Listen for updates of the checked attribute. this.state.toolboxButtons.forEach(button => { button.off("updatechecked", this.state.checkedButtonsUpdated); }); toolboxButtons.forEach(button => { button.on("updatechecked", this.state.checkedButtonsUpdated); }); const visibleToolboxButtonCount = toolboxButtons.filter( button => button.isVisible ).length; this.setState( { toolboxButtons, visibleToolboxButtonCount }, this.updateButtonIds ); } setDebugTargetData(data) { this.setState({ debugTargetData: data }); } render() { return ToolboxToolbar(Object.assign({}, this.props, this.state)); } } module.exports = ToolboxController; PK