1
1
import { useMemo , useRef , useState } from 'react' ;
2
2
3
- import { KebabHorizontal } from '@osrd-project/ui-icons' ;
3
+ import { Slider } from '@osrd-project/ui-core' ;
4
+ import { KebabHorizontal , Iterations } from '@osrd-project/ui-icons' ;
4
5
import Manchette , { type WaypointMenuData } from '@osrd-project/ui-manchette' ;
5
- import { useManchettesWithSpaceTimeChart } from '@osrd-project/ui-manchette-with-spacetimechart' ;
6
+ import {
7
+ useManchettesWithSpaceTimeChart ,
8
+ timeScaleToZoomValue ,
9
+ DEFAULT_ZOOM_MS_PER_PX ,
10
+ } from '@osrd-project/ui-manchette-with-spacetimechart' ;
6
11
import {
7
12
ConflictLayer ,
8
13
PathLayer ,
@@ -63,6 +68,7 @@ const ManchetteWithSpaceTimeChartWrapper = ({
63
68
} : ManchetteWithSpaceTimeChartProps ) => {
64
69
const manchetteWithSpaceTimeCharWrappertRef = useRef < HTMLDivElement > ( null ) ;
65
70
const manchetteWithSpaceTimeChartRef = useRef < HTMLDivElement > ( null ) ;
71
+ const spaceTimeChartRef = useRef < HTMLDivElement > ( null ) ;
66
72
67
73
const [ waypointsPanelIsOpen , setWaypointsPanelIsOpen ] = useState ( false ) ;
68
74
@@ -159,13 +165,15 @@ const ManchetteWithSpaceTimeChartWrapper = ({
159
165
} ) ) ;
160
166
} , [ waypointsPanelData , operationalPoints ] ) ;
161
167
162
- const { manchetteProps, spaceTimeChartProps, handleScroll } = useManchettesWithSpaceTimeChart (
163
- manchetteWaypoints ,
164
- cutProjectedTrains ,
165
- manchetteWithSpaceTimeChartRef ,
166
- selectedTrainScheduleId ,
167
- height
168
- ) ;
168
+ const { manchetteProps, spaceTimeChartProps, handleScroll, handleXZoom, xZoom } =
169
+ useManchettesWithSpaceTimeChart (
170
+ manchetteWaypoints ,
171
+ cutProjectedTrains ,
172
+ manchetteWithSpaceTimeChartRef ,
173
+ selectedTrainScheduleId ,
174
+ height ,
175
+ spaceTimeChartRef
176
+ ) ;
169
177
170
178
const [ showSettingsPanel , setShowSettingsPanel ] = useState ( false ) ;
171
179
const [ settings , setSettings ] = useState ( {
@@ -251,6 +259,7 @@ const ManchetteWithSpaceTimeChartWrapper = ({
251
259
>
252
260
< Manchette { ...manchettePropsWithWaypointMenu } height = { height - BOTTOM_TOOLBAR_HEIGHT } />
253
261
< div
262
+ ref = { spaceTimeChartRef }
254
263
className = "space-time-chart-container"
255
264
style = { {
256
265
bottom : 0 ,
@@ -260,7 +269,18 @@ const ManchetteWithSpaceTimeChartWrapper = ({
260
269
} }
261
270
>
262
271
< div className = "toolbar" >
263
- < button type = "button" onClick = { ( ) => setShowSettingsPanel ( true ) } >
272
+ < button
273
+ type = "button"
274
+ className = "reset-button"
275
+ onClick = { ( ) => handleXZoom ( timeScaleToZoomValue ( DEFAULT_ZOOM_MS_PER_PX ) ) }
276
+ >
277
+ < Iterations />
278
+ </ button >
279
+ < button
280
+ type = "button"
281
+ className = "menu-button"
282
+ onClick = { ( ) => setShowSettingsPanel ( true ) }
283
+ >
264
284
< KebabHorizontal />
265
285
</ button >
266
286
</ div >
@@ -301,7 +321,16 @@ const ManchetteWithSpaceTimeChartWrapper = ({
301
321
</ SpaceTimeChart >
302
322
</ div >
303
323
</ div >
324
+ < Slider
325
+ containerClassName = "space-time-h-slider-container"
326
+ className = "space-time-h-slider"
327
+ value = { xZoom }
328
+ onChange = { ( e ) => {
329
+ handleXZoom ( Number ( e . target . value ) ) ;
330
+ } }
331
+ />
304
332
</ div >
333
+ /* TODO use margin or absolute to align with handle */
305
334
) ;
306
335
} ;
307
336
0 commit comments