11import React from "react" ;
22
3- import { BREAKPOINTS , basicButtonStyle , customIconStyle , undisplay } from "../cssStyles" ;
3+ import { BREAKPOINTS , basicButtonStyle , customIconStyle , selectFieldStyle , undisplay } from "../cssStyles" ;
44
55import { IconType } from "react-icons" ;
66import { LuScissors , LuChevronLeft , LuChevronRight , LuTrash , LuMoveHorizontal } from "react-icons/lu" ;
@@ -15,6 +15,8 @@ import {
1515 mergeAll ,
1616 mergeLeft ,
1717 mergeRight ,
18+ selectDisplayDuration ,
19+ selectDurationInSeconds ,
1820 selectIsCurrentSegmentAlive ,
1921 selectTimelineZoom ,
2022 setTimelineZoom ,
@@ -30,6 +32,7 @@ import { ThemedTooltip } from "./Tooltip";
3032import { Slider } from "@mui/material" ;
3133import { useHotkeys } from "react-hotkeys-hook" ;
3234import { ProtoButton } from "@opencast/appkit" ;
35+ import Select , { components } from "react-select" ;
3336
3437/**
3538 * Defines the different actions a user can perform while in cutting mode
@@ -179,6 +182,7 @@ const CuttingActions: React.FC = () => {
179182 hotkeyNameOut : rewriteKeys ( KEYMAP . cutting . zoomOut ) ,
180183 } ) }
181184 />
185+ < ZoomDropdown />
182186 { /* <CuttingActionsButton Icon={faQuestion} actionName="Reset changes" action={null}
183187 tooltip="Not implemented"
184188 ariaLabelText="Reset changes. Not implemented"
@@ -365,4 +369,75 @@ const ZoomSlider : React.FC<ZoomSliderInterface> = ({
365369 ) ;
366370} ;
367371
372+ const ZoomDropdown : React . FC = ( ) => {
373+ const theme = useTheme ( ) ;
374+ const dispatch = useAppDispatch ( ) ;
375+ const seconds = useAppSelector ( selectDisplayDuration ) ;
376+ const durationInSeconds = useAppSelector ( selectDurationInSeconds ) ;
377+
378+ const options = [
379+ {
380+ label : "All" ,
381+ value : "0" ,
382+ } ,
383+ ] ;
384+ if ( durationInSeconds > 60 ) {
385+ options . push ( {
386+ label : "10 s" ,
387+ value : "1" ,
388+ } ) ;
389+ }
390+ if ( durationInSeconds > 60 * 10 ) {
391+ options . push ( {
392+ label : "1 m" ,
393+ value : ( 1 - ( 60 / durationInSeconds ) ) . toString ( ) ,
394+ } ) ;
395+ }
396+ if ( durationInSeconds > 300 * 5 ) {
397+ options . push ( {
398+ label : "5 m" ,
399+ value : ( 1 - ( 300 / durationInSeconds ) ) . toString ( ) ,
400+ } ) ;
401+ }
402+
403+ const renderTime = ( seconds : number ) => {
404+ const minutes = seconds / 60 ;
405+ const hours = seconds / 3600 ;
406+
407+ if ( hours >= 1 ) {
408+ return Math . round ( hours ) + " h" ;
409+ }
410+ if ( minutes >= 1 ) {
411+ return Math . round ( minutes ) + " m" ;
412+ }
413+
414+ return Math . round ( seconds ) + " s" ;
415+ } ;
416+
417+ // @ts -expect-error No proper type for children available
418+ const Control = ( { children, ...props } ) => (
419+ // @ts -expect-error And therefore this complains as well
420+ < components . Control { ...props } >
421+ < div style = { { paddingLeft : "5px" , paddingRight : "5px" } } >
422+ ~{ renderTime ( seconds ) }
423+ </ div >
424+ { children [ 1 ] }
425+ </ components . Control >
426+ ) ;
427+
428+ return (
429+ < Select
430+ name = "Zoom Dropdown"
431+ styles = { selectFieldStyle ( theme ) }
432+ options = { options }
433+ onChange = { option => {
434+ if ( option ) {
435+ dispatch ( setTimelineZoom ( parseFloat ( option . value ) ) ) ;
436+ }
437+ } }
438+ components = { { Control } }
439+ />
440+ ) ;
441+ } ;
442+
368443export default CuttingActions ;
0 commit comments