ISSUE-053 - Placed Chyrons on video feed.

Adjusted the method that placement is determined. It didn't make much sense to define Placement in state, so I've moved it to the central theme object instead.
I also took the time to support +10 laps and minutes with a special xScale setting for the TimingTowerRows.
This commit is contained in:
Kyle Geib committed 2022-03-17 08:56:55 -04:00
1 parent b7d1b23dff
commit 58da0e4895
13 files changed
+74 -23

No files matched your search

@@ -71,7 +71,6 @@ export function ChyronsDirectorControls() {
}
const newChyrons: BGChyrons = {
openState: 0,
placement: { top: "0", right: "0", bottom: "0", left: "0" },
mode: chyronMode,
subMode: chyronSubMode,
driver: {
+9 -3
View File
@@ -1,7 +1,10 @@
import { MockupBlock } from "../../Common/MockupBlock.styled";
import { PadBox } from "@bedrock-layout/padbox";
import VideoFeed from "../VideoFeed/VideoFeed";
import { MockupBlock } from "../../Common/MockupBlock.styled";
import { LayoutGrid, LayoutGridItem } from "../../Common/LayoutGrid.styled";
import { TimingTowerPrototypeControls } from "../../Workspaces/PrototypingControls/TimingTowerPrototype";
import { ChyronsDirectorControls } from "../BroadcastDirectorUI/Chyrons";
type LayoutProps = {
headerHeight?: number,
@@ -17,7 +20,7 @@ export function Layout({ headerHeight }: LayoutProps) {
>Timing Board UI</MockupBlock>
</LayoutGridItem>
<LayoutGridItem column={2} row={1} columnSpan={5} rowSpan={7} >
<LayoutGridItem column={2} row={1} columnSpan={5} rowSpan={8} >
<VideoFeed />
</LayoutGridItem>
@@ -33,8 +36,11 @@ export function Layout({ headerHeight }: LayoutProps) {
>Race Director UI</MockupBlock>
</LayoutGridItem>
<LayoutGridItem column={2} row={8} columnSpan={5} rowSpan={3}>
<LayoutGridItem column={2} row={9} columnSpan={5} rowSpan={2}>
<PadBox padding="lg">
<TimingTowerPrototypeControls />
<ChyronsDirectorControls />
</PadBox>
</LayoutGridItem>
</LayoutGrid>
);
@@ -3,10 +3,12 @@ import useMeasure from "react-use-measure";
import { calculateFitSize, calculateScale } from "../../../utils/styling";
import { theme } from "../../../shared/theme";
import { VideoFeedFrame, BackgroundImageDiv, DimensionsSpan, BroadcastLayout } from "./styles";
import { VideoFeedFrame, BackgroundImageDiv, DimensionsSpan, BroadcastLayout, Logo } from "./styles";
import { TimingBoard } from "../../BroadcastGraphics/TimingBoard";
import { ChyronContainer } from "../../BroadcastGraphics/Chyrons/Container";
import bg from "../../../public/images/misc/bg-standin.jpg";
import f1Logo from "../../../public/images/logos/f1-logo-white.svg";
export default function VideoFeed() {
const [frameRef, {
@@ -17,6 +19,8 @@ export default function VideoFeed() {
const {
dimensionsWidthPx: broadcastWidth,
dimensionsHeightPx: broadcastHeight,
logoHeightPx,
placement,
} = theme.broadcast;
const [layoutWidth, layoutHeight] = calculateFitSize(frameWidth, frameHeight,
@@ -27,11 +31,15 @@ export default function VideoFeed() {
return (
<VideoFeedFrame centered ref={frameRef}>
<DimensionsSpan>
{Math.floor(frameWidth)} x {Math.floor(frameHeight)}px
Frame: {Math.floor(frameWidth)} x {Math.floor(frameHeight)}px
<br />
Scaled: {Math.floor(layoutWidth)} x {Math.floor(layoutHeight)}px ({(layoutScale * 100).toFixed(1)}%)
</DimensionsSpan>
<BackgroundImageDiv src={bg} />
<BroadcastLayout width={broadcastWidth} height={broadcastHeight} scale={layoutScale} >
<TimingBoard />
<TimingBoard placement={placement.timingBoard} />
<ChyronContainer placement={placement.chyrons} />
<Logo height={logoHeightPx} placement={placement.logo} src={f1Logo} />
</BroadcastLayout>
</VideoFeedFrame>
);
+12 -1
View File
@@ -1,6 +1,7 @@
import styled, { css } from "styled-components/macro";
import { Fraction, Px } from "../../../types/style";
import { Fraction, Placement, Px } from "../../../types/style";
import { placementStyleRules } from "../../../utils/styling";
type VideoFeedFrameProps = {
centered?: boolean,
@@ -61,3 +62,13 @@ export const DimensionsSpan = styled.span`
color: ${p => p.theme.colors.textWhite};
font-family: ${p => p.theme.fonts.f1Regular};
`;
type LogoProps = {
placement: Placement,
height: Px,
};
export const Logo = styled.img<LogoProps>`
position: absolute;
${({ placement }) => placementStyleRules(placement)}
height: ${({ height }) => height}px;
`;
@@ -2,14 +2,16 @@ import { useSelector } from "react-redux";
import { broadcastGraphicsSelector } from "../../../../features/broadcast/graphics/broadcastGraphicsSelector";
import { workspaceSelector } from "../../../../features/workspace/workspaceSelector";
import { Placement } from "../../../../types/style";
import { ChyronDriver } from "../Driver";
import { DoubleChyronContainer } from "./styles";
import { ChyronPlacement, DoubleChyronContainer } from "./styles";
type ChyronContainerProps = {
debug?: boolean,
placement?: Placement,
};
export function ChyronContainer({ debug = false }: ChyronContainerProps) {
export function ChyronContainer({ debug = false, placement = {} }: ChyronContainerProps) {
const { chyrons } = useSelector(broadcastGraphicsSelector);
const { debugDurationMultiplier } = useSelector(workspaceSelector);
@@ -23,8 +25,10 @@ export function ChyronContainer({ debug = false }: ChyronContainerProps) {
debugDurationMultiplier={debug ? debugDurationMultiplier : 1}
/>
);
if (chyrons.subMode === "medium" && chyrons.driver.secondary) {
return (
<ChyronPlacement placement={placement}>
{chyrons.subMode === "medium" && chyrons.driver.secondary ? (
<DoubleChyronContainer>
{primary}
<ChyronDriver
@@ -34,8 +38,7 @@ export function ChyronContainer({ debug = false }: ChyronContainerProps) {
debugDurationMultiplier={debug ? debugDurationMultiplier : 1}
/>
</DoubleChyronContainer>
) : primary}
</ChyronPlacement>
);
} else {
return primary;
}
}
@@ -1,7 +1,19 @@
import styled from "styled-components/macro";
import { Placement } from "../../../../types/style";
import { placementStyleRules } from "../../../../utils/styling";
export const DoubleChyronContainer = styled.div`
display: flex;
justify-content: space-between;
width: 1196px;
`;
type ChyronPlacementProps = {
placement: Placement,
};
export const ChyronPlacement = styled.div<ChyronPlacementProps>`
position: absolute;
${({ placement }) => placementStyleRules(placement)}
`;
@@ -1,21 +1,21 @@
import { useSelector } from "react-redux";
import { workspaceSelector } from "../../../features/workspace/workspaceSelector";
import { Placement } from "../../../types/style";
import { TimingBoardLayout } from "./styles";
import { TimingTower } from "./TimingTower";
import { StatusIndicator } from "./StatusIndicator";
import { broadcastGraphicsSelector } from "../../../features/broadcast/graphics/broadcastGraphicsSelector";
type TimingBoardProps = {
debug?: boolean,
placement?: Placement,
};
export function TimingBoard({ debug = false }: TimingBoardProps) {
export function TimingBoard({ debug = false, placement = {} }: TimingBoardProps) {
const { debugDurationMultiplier } = useSelector(workspaceSelector);
const { timingBoard } = useSelector(broadcastGraphicsSelector);
return (
<TimingBoardLayout placement={timingBoard.placement}>
<TimingBoardLayout placement={placement}>
<StatusIndicator
debugDurationMultiplier={debug ? debugDurationMultiplier : 1}
/>
@@ -153,6 +153,13 @@ export function TimingTowerRow({
xScale = rightHalfContent.includes(":") ? 0.75 : 0.9;
yScale = rightHalfContent.includes("+") ? 1.1 : 1.0;
if (rightHalfContent.includes("LAPS") && rightHalfContent.length > 7) {
xScale = 0.85; // Extreme edge case where +10 laps or more behind.
}
if (rightHalfContent.length > 9) {
xScale = 0.7; // Extreme edge case where +10 minutes or more behind.
}
}
return (
@@ -221,6 +221,7 @@ export const TimeDiff = styled.span<TimeDiffProps>`
color: ${p => p.theme.colors.textWhite};
font-family: ${p => p.theme.fonts.f1Regular};
font-size: 20px;
white-space: nowrap;
text-align: end;
@@ -7,7 +7,7 @@ type TimingBoardLayoutProps = {
placement: Placement,
};
export const TimingBoardLayout = styled.div<TimingBoardLayoutProps>`
position: relative;
position: absolute;
${({ placement }) => placementStyleRules(placement)}
display: flex;
@@ -13,13 +13,12 @@ import {
const initialState: RootState["broadcastGraphics"] = {
chyrons: null,
timingBoard: {
placement: { top: "54px", left: "96px" },
openState: 1,
statusIndicator: {
mode: BGStatusIndicatorModes.LapNarrow,
},
timingTower: {
open: 1,
openState: 1,
displayMode: BGTimingTowerDisplayMode.LeftAndRight,
splitsMode: BGTimingTowerSplitsMode.Leader,
focusedCars: [],
+6
View File
@@ -105,6 +105,12 @@ export const theme = {
broadcast: {
dimensionsWidthPx: 1920,
dimensionsHeightPx: 1080,
logoHeightPx: 40,
placement: {
chyrons: { bottom: "52px", left: "378px" },
timingBoard: { top: "54px", left: "96px" },
logo: { left: "86px", bottom: "52px" },
},
},
};
+1 -2
View File
@@ -254,7 +254,6 @@ export interface BroadcastDirector {
// Broadcast Graphics
export interface BGBaseState {
placement: Placement;
openState: OpenState;
}
/**
@@ -287,7 +286,7 @@ export enum BGStatusIndicatorModes {
// Timing Tower
export interface BGTimingTower {
open: OpenState;
openState: OpenState;
displayMode: BGTimingTowerDisplayMode;
splitsMode: BGTimingTowerSplitsMode,
focusedCars: Car[],