2019-06-28 17:18:47 +00:00
|
|
|
// @flow
|
|
|
|
|
2021-02-18 15:52:47 +00:00
|
|
|
import { openDialog } from '../../base/dialog';
|
2019-06-28 17:18:47 +00:00
|
|
|
import { translate } from '../../base/i18n';
|
2022-11-08 10:24:32 +00:00
|
|
|
import { IconImage } from '../../base/icons';
|
2019-06-28 17:18:47 +00:00
|
|
|
import { connect } from '../../base/redux';
|
2021-02-25 12:21:03 +00:00
|
|
|
import { AbstractButton } from '../../base/toolbox/components';
|
2020-07-24 12:14:33 +00:00
|
|
|
import type { AbstractButtonProps } from '../../base/toolbox/components';
|
2021-08-20 08:53:11 +00:00
|
|
|
import { checkBlurSupport } from '../functions';
|
2021-02-18 15:52:47 +00:00
|
|
|
|
|
|
|
import { VirtualBackgroundDialog } from './index';
|
2019-06-28 17:18:47 +00:00
|
|
|
|
|
|
|
/**
|
2021-02-18 15:52:47 +00:00
|
|
|
* The type of the React {@code Component} props of {@link VideoBackgroundButton}.
|
2019-06-28 17:18:47 +00:00
|
|
|
*/
|
|
|
|
type Props = AbstractButtonProps & {
|
|
|
|
|
|
|
|
/**
|
|
|
|
* True if the video background is blurred or false if it is not.
|
|
|
|
*/
|
2021-02-18 15:52:47 +00:00
|
|
|
_isBackgroundEnabled: boolean,
|
2019-06-28 17:18:47 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* The redux {@code dispatch} function.
|
|
|
|
*/
|
|
|
|
dispatch: Function
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
2021-02-18 15:52:47 +00:00
|
|
|
* An abstract implementation of a button that toggles the video background dialog.
|
2019-06-28 17:18:47 +00:00
|
|
|
*/
|
2021-02-18 15:52:47 +00:00
|
|
|
class VideoBackgroundButton extends AbstractButton<Props, *> {
|
|
|
|
accessibilityLabel = 'toolbar.accessibilityLabel.selectBackground';
|
2022-11-08 10:24:32 +00:00
|
|
|
icon = IconImage;
|
2021-02-18 15:52:47 +00:00
|
|
|
label = 'toolbar.selectBackground';
|
|
|
|
tooltip = 'toolbar.selectBackground';
|
2019-06-28 17:18:47 +00:00
|
|
|
|
|
|
|
/**
|
2021-02-18 15:52:47 +00:00
|
|
|
* Handles clicking / pressing the button, and toggles the virtual background dialog
|
2019-06-28 17:18:47 +00:00
|
|
|
* state accordingly.
|
|
|
|
*
|
|
|
|
* @protected
|
|
|
|
* @returns {void}
|
|
|
|
*/
|
|
|
|
_handleClick() {
|
2022-01-04 11:21:00 +00:00
|
|
|
const { dispatch } = this.props;
|
2019-06-28 17:18:47 +00:00
|
|
|
|
2021-02-18 15:52:47 +00:00
|
|
|
dispatch(openDialog(VirtualBackgroundDialog));
|
2019-06-28 17:18:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2021-02-18 15:52:47 +00:00
|
|
|
* Returns {@code boolean} value indicating if the background effect is
|
2019-06-28 17:18:47 +00:00
|
|
|
* enabled or not.
|
|
|
|
*
|
|
|
|
* @protected
|
|
|
|
* @returns {boolean}
|
|
|
|
*/
|
|
|
|
_isToggled() {
|
2021-02-18 15:52:47 +00:00
|
|
|
return this.props._isBackgroundEnabled;
|
2019-06-28 17:18:47 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Maps (parts of) the redux state to the associated props for the
|
2021-02-18 15:52:47 +00:00
|
|
|
* {@code VideoBackgroundButton} component.
|
2019-06-28 17:18:47 +00:00
|
|
|
*
|
|
|
|
* @param {Object} state - The Redux state.
|
|
|
|
* @private
|
|
|
|
* @returns {{
|
2021-02-18 15:52:47 +00:00
|
|
|
* _isBackgroundEnabled: boolean
|
2019-06-28 17:18:47 +00:00
|
|
|
* }}
|
|
|
|
*/
|
|
|
|
function _mapStateToProps(state): Object {
|
2021-02-26 15:03:51 +00:00
|
|
|
|
2019-06-28 17:18:47 +00:00
|
|
|
return {
|
2021-08-20 08:53:11 +00:00
|
|
|
_isBackgroundEnabled: Boolean(state['features/virtual-background'].backgroundEffectEnabled),
|
|
|
|
visible: checkBlurSupport()
|
2019-06-28 17:18:47 +00:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2021-02-18 15:52:47 +00:00
|
|
|
export default translate(connect(_mapStateToProps)(VideoBackgroundButton));
|