Updated film strip. Added it back to settings.

master
Håvar Aambø Fosstveit 2019-06-06 11:28:36 +02:00
parent 4b3219f614
commit c46bcb7bdc
3 changed files with 97 additions and 39 deletions

View File

@ -53,6 +53,8 @@ const styles = (theme) =>
viewContainer : viewContainer :
{ {
position : 'relative', position : 'relative',
width : '100%',
height : '100%',
'&.webcam' : '&.webcam' :
{ {
order : 2 order : 2
@ -164,9 +166,10 @@ const Peer = (props) =>
const smallScreen = useMediaQuery(theme.breakpoints.down('sm')); const smallScreen = useMediaQuery(theme.breakpoints.down('sm'));
const spacingStyle = const rootStyle =
{ {
'margin' : spacing 'margin' : spacing,
...style
}; };
return ( return (
@ -199,9 +202,9 @@ const Peer = (props) =>
setHover(false); setHover(false);
}, 2000); }, 2000);
}} }}
style={spacingStyle} style={rootStyle}
> >
<div className={classnames(classes.viewContainer)} style={style}> <div className={classnames(classes.viewContainer)}>
{ !videoVisible ? { !videoVisible ?
<div className={classes.videoInfo}> <div className={classes.videoInfo}>
<p>this video is paused</p> <p>this video is paused</p>
@ -319,16 +322,17 @@ const Peer = (props) =>
setHover(false); setHover(false);
}, 2000); }, 2000);
}} }}
style={rootStyle}
> >
{ !screenVisible ? { !screenVisible ?
<div className={classes.videoInfo} style={style}> <div className={classes.videoInfo}>
<p>this video is paused</p> <p>this video is paused</p>
</div> </div>
:null :null
} }
{ screenVisible ? { screenVisible ?
<div className={classnames(classes.viewContainer)} style={style}> <div className={classnames(classes.viewContainer)}>
<div <div
className={classnames(classes.controls, screenHover ? 'hover' : null)} className={classnames(classes.controls, screenHover ? 'hover' : null)}
onMouseOver={() => setScreenHover(true)} onMouseOver={() => setScreenHover(true)}

View File

@ -4,7 +4,8 @@ import { connect } from 'react-redux';
import { withStyles } from '@material-ui/core/styles'; import { withStyles } from '@material-ui/core/styles';
import classnames from 'classnames'; import classnames from 'classnames';
import { import {
spotlightsLengthSelector spotlightsLengthSelector,
videoBoxesSelector
} from '../Selectors'; } from '../Selectors';
import { withRoomContext } from '../../RoomContext'; import { withRoomContext } from '../../RoomContext';
import Me from '../Containers/Me'; import Me from '../Containers/Me';
@ -60,6 +61,8 @@ class Filmstrip extends React.PureComponent
this.resizeTimeout = null; this.resizeTimeout = null;
this.activePeerContainer = React.createRef(); this.activePeerContainer = React.createRef();
this.filmStripContainer = React.createRef();
} }
state = { state = {
@ -102,31 +105,53 @@ class Filmstrip extends React.PureComponent
updateDimensions = () => updateDimensions = () =>
{ {
const container = this.activePeerContainer.current; const newState = {};
if (container) const speaker = this.activePeerContainer.current;
if (speaker)
{ {
let width = (container.clientWidth - 100); let speakerWidth = (speaker.clientWidth - 100);
let height = (width / 4) * 3; let speakerHeight = (speakerWidth / 4) * 3;
if (this.isSharingCamera(this.getActivePeerId())) if (this.isSharingCamera(this.getActivePeerId()))
{ {
width /= 2; speakerWidth /= 2;
height = (width / 4) * 3; speakerHeight = (speakerWidth / 4) * 3;
} }
if (height > (container.clientHeight - 60)) if (speakerHeight > (speaker.clientHeight - 60))
{ {
height = (container.clientHeight - 60); speakerHeight = (speaker.clientHeight - 60);
width = (height / 3) * 4; speakerWidth = (speakerHeight / 3) * 4;
}
newState.speakerWidth = speakerWidth;
newState.speakerHeight = speakerHeight;
}
const filmStrip = this.filmStripContainer.current;
if (filmStrip)
{
let filmStripHeight = filmStrip.clientHeight - 10;
let filmStripWidth = (filmStripHeight / 3) * 4;
if (filmStripWidth * this.props.boxes > (filmStrip.clientWidth - 50))
{
filmStripWidth = (filmStrip.clientWidth - 50) / this.props.boxes;
filmStripHeight = (filmStripWidth / 4) * 3;
}
newState.filmStripWidth = filmStripWidth;
newState.filmStripHeight = filmStripHeight;
} }
this.setState({ this.setState({
width, ...newState
height
}); });
}
}; };
componentDidMount() componentDidMount()
@ -190,14 +215,14 @@ class Filmstrip extends React.PureComponent
const speakerStyle = const speakerStyle =
{ {
width : this.state.width, width : this.state.speakerWidth,
height : this.state.height height : this.state.speakerHeight
}; };
const peerStyle = const peerStyle =
{ {
'width' : '24vmin', width : this.state.filmStripWidth,
'height' : '18vmin' height : this.state.filmStripHeight
}; };
return ( return (
@ -213,7 +238,7 @@ class Filmstrip extends React.PureComponent
} }
</div> </div>
<div className={classes.filmStrip}> <div className={classes.filmStrip} ref={this.filmStripContainer}>
<Grid container justify='center' spacing={0}> <Grid container justify='center' spacing={0}>
<Grid item> <Grid item>
<div <div
@ -258,7 +283,7 @@ class Filmstrip extends React.PureComponent
})} })}
</Grid> </Grid>
</div> </div>
<div className={classes.hiddenPeers}>
{ spotlightsLength<Object.keys(peers).length ? { spotlightsLength<Object.keys(peers).length ?
<HiddenPeers <HiddenPeers
hiddenPeersCount={Object.keys(peers).length-spotlightsLength} hiddenPeersCount={Object.keys(peers).length-spotlightsLength}
@ -266,7 +291,6 @@ class Filmstrip extends React.PureComponent
:null :null
} }
</div> </div>
</div>
); );
} }
} }
@ -281,6 +305,7 @@ Filmstrip.propTypes = {
selectedPeerId : PropTypes.string, selectedPeerId : PropTypes.string,
spotlightsLength : PropTypes.number, spotlightsLength : PropTypes.number,
spotlights : PropTypes.array.isRequired, spotlights : PropTypes.array.isRequired,
boxes : PropTypes.number,
classes : PropTypes.object.isRequired classes : PropTypes.object.isRequired
}; };
@ -293,7 +318,8 @@ const mapStateToProps = (state) =>
consumers : state.consumers, consumers : state.consumers,
myId : state.me.id, myId : state.me.id,
spotlights : state.room.spotlights, spotlights : state.room.spotlights,
spotlightsLength : spotlightsLengthSelector(state) spotlightsLength : spotlightsLengthSelector(state),
boxes : videoBoxesSelector(state),
}; };
}; };

View File

@ -51,13 +51,13 @@ const styles = (theme) =>
} }
}); });
/* const modes = [ { const modes = [ {
value : 'democratic', value : 'democratic',
label : 'Democratic view' label : 'Democratic view'
}, { }, {
value : 'filmstrip', value : 'filmstrip',
label : 'Filmstrip view' label : 'Filmstrip view'
} ]; */ } ];
const resolutions = [ { const resolutions = [ {
value : 'low', value : 'low',
@ -87,6 +87,7 @@ const Settings = ({
settings, settings,
onToggleAdvancedMode, onToggleAdvancedMode,
handleCloseSettings, handleCloseSettings,
handleChangeMode,
classes classes
}) => }) =>
{ {
@ -203,6 +204,33 @@ const Settings = ({
</FormHelperText> </FormHelperText>
</FormControl> </FormControl>
</form> </form>
<form className={classes.setting} autoComplete='off'>
<FormControl className={classes.formControl}>
<Select
value={room.mode || ''}
onChange={(event) =>
{
if (event.target.value)
handleChangeMode(event.target.value);
}}
name='Room layout'
autoWidth
className={classes.selectEmpty}
>
{ modes.map((mode, index) =>
{
return (
<MenuItem key={index} value={mode.value}>
{mode.label}
</MenuItem>
);
})}
</Select>
<FormHelperText>
Select room layout
</FormHelperText>
</FormControl>
</form>
<FormControlLabel <FormControlLabel
className={classes.setting} className={classes.setting}
control={<Checkbox checked={settings.advancedMode} onChange={onToggleAdvancedMode} value='advancedMode' />} control={<Checkbox checked={settings.advancedMode} onChange={onToggleAdvancedMode} value='advancedMode' />}
@ -241,7 +269,7 @@ const mapStateToProps = (state) =>
const mapDispatchToProps = { const mapDispatchToProps = {
onToggleAdvancedMode : stateActions.toggleAdvancedMode, onToggleAdvancedMode : stateActions.toggleAdvancedMode,
handleChangeMode : stateActions.setDisplayMode, handleChangeMode : stateActions.setDisplayMode,
handleCloseSettings : stateActions.setSettingsOpen handleCloseSettings : stateActions.setSettingsOpen,
}; };
export default withRoomContext(connect( export default withRoomContext(connect(