2017-10-13 19:31:05 +00:00
|
|
|
// @flow
|
2017-10-02 23:08:07 +00:00
|
|
|
|
2018-05-22 22:41:53 +00:00
|
|
|
import {
|
2018-11-27 20:22:25 +00:00
|
|
|
getParticipantCountWithFake,
|
2018-05-22 22:41:53 +00:00
|
|
|
getPinnedParticipant
|
|
|
|
} from '../base/participants';
|
2018-06-14 09:14:32 +00:00
|
|
|
import { toState } from '../base/redux';
|
2017-08-29 15:08:16 +00:00
|
|
|
|
2020-01-24 16:28:47 +00:00
|
|
|
import { TILE_ASPECT_RATIO } from './constants';
|
|
|
|
|
2017-10-13 19:31:05 +00:00
|
|
|
declare var interfaceConfig: Object;
|
2017-08-29 15:08:16 +00:00
|
|
|
|
2018-06-14 09:14:32 +00:00
|
|
|
/**
|
|
|
|
* Returns true if the filmstrip on mobile is visible, false otherwise.
|
|
|
|
*
|
|
|
|
* NOTE: Filmstrip on web behaves differently to mobile, much simpler, but so
|
|
|
|
* function lies here only for the sake of consistency and to avoid flow errors
|
|
|
|
* on import.
|
|
|
|
*
|
|
|
|
* @param {Object | Function} stateful - The Object or Function that can be
|
|
|
|
* resolved to a Redux state object with the toState function.
|
|
|
|
* @returns {boolean}
|
|
|
|
*/
|
|
|
|
export function isFilmstripVisible(stateful: Object | Function) {
|
|
|
|
return toState(stateful)['features/filmstrip'].visible;
|
|
|
|
}
|
|
|
|
|
2017-08-29 15:08:16 +00:00
|
|
|
/**
|
2017-10-13 19:31:05 +00:00
|
|
|
* Determines whether the remote video thumbnails should be displayed/visible in
|
|
|
|
* the filmstrip.
|
2017-08-29 15:08:16 +00:00
|
|
|
*
|
|
|
|
* @param {Object} state - The full redux state.
|
2017-10-13 19:31:05 +00:00
|
|
|
* @returns {boolean} - If remote video thumbnails should be displayed/visible
|
|
|
|
* in the filmstrip, then {@code true}; otherwise, {@code false}.
|
2017-08-29 15:08:16 +00:00
|
|
|
*/
|
2017-10-02 23:08:07 +00:00
|
|
|
export function shouldRemoteVideosBeVisible(state: Object) {
|
2018-06-26 22:56:22 +00:00
|
|
|
if (state['features/invite'].calleeInfoVisible) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2018-11-27 20:22:25 +00:00
|
|
|
// Include fake participants to derive how many thumbnails are dispalyed,
|
|
|
|
// as it is assumed all participants, including fake, will be displayed
|
|
|
|
// in the filmstrip.
|
|
|
|
const participantCount = getParticipantCountWithFake(state);
|
2017-10-13 19:31:05 +00:00
|
|
|
let pinnedParticipant;
|
2017-08-29 15:08:16 +00:00
|
|
|
|
2017-10-13 19:31:05 +00:00
|
|
|
return Boolean(
|
|
|
|
participantCount > 2
|
2017-08-29 15:08:16 +00:00
|
|
|
|
2017-10-13 19:31:05 +00:00
|
|
|
// Always show the filmstrip when there is another participant to
|
|
|
|
// show and the filmstrip is hovered, or local video is pinned, or
|
|
|
|
// the toolbar is displayed.
|
|
|
|
|| (participantCount > 1
|
|
|
|
&& (state['features/filmstrip'].hovered
|
|
|
|
|| state['features/toolbox'].visible
|
2018-05-22 22:41:53 +00:00
|
|
|
|| ((pinnedParticipant = getPinnedParticipant(state))
|
2017-10-13 19:31:05 +00:00
|
|
|
&& pinnedParticipant.local)))
|
2017-08-29 15:08:16 +00:00
|
|
|
|
2017-10-13 19:31:05 +00:00
|
|
|
|| (typeof interfaceConfig === 'object'
|
|
|
|
&& interfaceConfig.filmStripOnly)
|
2017-08-29 15:08:16 +00:00
|
|
|
|
2017-10-13 19:31:05 +00:00
|
|
|
|| state['features/base/config'].disable1On1Mode);
|
2017-08-29 15:08:16 +00:00
|
|
|
}
|
2020-01-24 16:28:47 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Calculates the size for thumbnails when in horizontal view layout.
|
|
|
|
*
|
|
|
|
* @param {number} clientHeight - The height of the app window.
|
|
|
|
* @returns {{local: {height, width}, remote: {height, width}}}
|
|
|
|
*/
|
|
|
|
export function calculateThumbnailSizeForHorizontalView(clientHeight: number = 0) {
|
|
|
|
const topBottomMargin = 15;
|
|
|
|
const availableHeight = Math.min(clientHeight, (interfaceConfig.FILM_STRIP_MAX_HEIGHT || 120) + topBottomMargin);
|
|
|
|
const height = availableHeight - topBottomMargin;
|
|
|
|
|
|
|
|
return {
|
|
|
|
local: {
|
|
|
|
height,
|
|
|
|
width: Math.floor(interfaceConfig.LOCAL_THUMBNAIL_RATIO * height)
|
|
|
|
},
|
|
|
|
remote: {
|
|
|
|
height,
|
|
|
|
width: Math.floor(interfaceConfig.REMOTE_THUMBNAIL_RATIO * height)
|
|
|
|
}
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Calculates the size for thumbnails when in tile view layout.
|
|
|
|
*
|
|
|
|
* @param {Object} dimensions - The desired dimensions of the tile view grid.
|
|
|
|
* @returns {{height, width}}
|
|
|
|
*/
|
|
|
|
export function calculateThumbnailSizeForTileView({
|
|
|
|
columns,
|
|
|
|
visibleRows,
|
|
|
|
clientWidth,
|
|
|
|
clientHeight
|
|
|
|
}: Object) {
|
|
|
|
// The distance from the top and bottom of the screen, as set by CSS, to
|
|
|
|
// avoid overlapping UI elements.
|
|
|
|
const topBottomPadding = 200;
|
|
|
|
|
|
|
|
// Minimum space to keep between the sides of the tiles and the sides
|
|
|
|
// of the window.
|
|
|
|
const sideMargins = 30 * 2;
|
2020-04-01 22:20:43 +00:00
|
|
|
|
|
|
|
const verticalMargins = visibleRows * 10;
|
2020-01-24 16:28:47 +00:00
|
|
|
const viewWidth = clientWidth - sideMargins;
|
2020-04-01 22:20:43 +00:00
|
|
|
const viewHeight = clientHeight - topBottomPadding - verticalMargins;
|
2020-01-24 16:28:47 +00:00
|
|
|
const initialWidth = viewWidth / columns;
|
|
|
|
const aspectRatioHeight = initialWidth / TILE_ASPECT_RATIO;
|
|
|
|
const height = Math.floor(Math.min(aspectRatioHeight, viewHeight / visibleRows));
|
|
|
|
const width = Math.floor(TILE_ASPECT_RATIO * height);
|
|
|
|
|
|
|
|
return {
|
|
|
|
height,
|
|
|
|
width
|
|
|
|
};
|
|
|
|
}
|
2020-02-10 15:27:43 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns the width of the visible area (doesn't include the left margin/padding) of the the vertical filmstrip.
|
|
|
|
*
|
|
|
|
* @returns {number} - The width of the vertical filmstrip.
|
|
|
|
*/
|
|
|
|
export function getVerticalFilmstripVisibleAreaWidth() {
|
|
|
|
// Adding 11px for the 2px right margin, 2px borders on the left and right and 5px right padding.
|
|
|
|
// Also adding 7px for the scrollbar. Note that we are not counting the left margins and paddings because this
|
|
|
|
// function is used for calculating the available space and they are invisible.
|
|
|
|
// TODO: Check if we can remove the left margins and paddings from the CSS.
|
|
|
|
// FIXME: This function is used to calculate the size of the large video, etherpad or shared video. Once everything
|
|
|
|
// is reactified this calculation will need to move to the corresponding components.
|
|
|
|
const filmstripMaxWidth = (interfaceConfig.FILM_STRIP_MAX_HEIGHT || 120) + 18;
|
|
|
|
|
|
|
|
return Math.min(filmstripMaxWidth, window.innerWidth);
|
|
|
|
}
|