@@ -9,6 +9,9 @@ import DialogContentText from '@material-ui/core/DialogContentText';
9
9
import DialogTitle from '@material-ui/core/DialogTitle' ;
10
10
import FormGroup from '@material-ui/core/FormGroup' ;
11
11
import FormControlLabel from '@material-ui/core/FormControlLabel' ;
12
+ import FormLabel from '@material-ui/core/FormLabel' ;
13
+ import RadioGroup from '@material-ui/core/RadioGroup' ;
14
+ import Radio from '@material-ui/core/Radio' ;
12
15
import Switch from '@material-ui/core/Switch' ;
13
16
import Input from '@material-ui/core/Input' ;
14
17
import InputAdornment from '@material-ui/core/InputAdornment' ;
@@ -44,6 +47,23 @@ const styles = theme => ({
44
47
display : 'flex' ,
45
48
justifyContent : 'space-between' ,
46
49
} ,
50
+ transitionDuration : {
51
+ width : '7.6em' ,
52
+ } ,
53
+ group : {
54
+ marginTop : theme . spacing . unit * 1 ,
55
+ marginLeft : theme . spacing . unit * 0 ,
56
+ } ,
57
+ tweenPrecisionAbsoluteInput : {
58
+ marginTop : theme . spacing . unit * 1 ,
59
+ marginLeft : theme . spacing . unit * 1.5 ,
60
+ width : '6.9em' ,
61
+ } ,
62
+ tweenPrecisionRelativeInput : {
63
+ marginTop : theme . spacing . unit * 1 ,
64
+ marginLeft : theme . spacing . unit * 1.5 ,
65
+ width : '4.8em' ,
66
+ } ,
47
67
holdOffInput : {
48
68
width : '7.6em' ,
49
69
} ,
@@ -69,6 +89,34 @@ class SettingsDialog extends React.Component {
69
89
this . props . onFitGraphSwitchChange ( event . target . checked ) ;
70
90
} ;
71
91
92
+ handleTransitionDurationChange = ( event ) => {
93
+ this . props . onTransitionDurationChange ( event . target . value ) ;
94
+ } ;
95
+
96
+ handleTweenPathsSwitchChange = ( event ) => {
97
+ this . props . onTweenPathsSwitchChange ( event . target . checked ) ;
98
+ } ;
99
+
100
+ handleTweenShapesSwitchChange = ( event ) => {
101
+ this . props . onTweenShapesSwitchChange ( event . target . checked ) ;
102
+ } ;
103
+
104
+ handleTweenPrecisionChange = ( event ) => {
105
+ let tweenPrecision = event . target . value ;
106
+ if ( event . target . value === 'absolute' || tweenPrecision > 1 ) {
107
+ tweenPrecision = Math . max ( Math . ceil ( tweenPrecision ) , 1 ) ;
108
+ }
109
+ this . props . onTweenPrecisionChange ( tweenPrecision . toString ( ) + ( this . props . tweenPrecision . includes ( '%' ) ? '%' : '' ) ) ;
110
+ } ;
111
+
112
+ handleTweenPrecisionIsRelativeRadioChange = ( event ) => {
113
+ let tweenPrecision = + this . props . tweenPrecision . split ( '%' ) [ 0 ] ;
114
+ if ( event . target . value === 'absolute' || tweenPrecision > 1 ) {
115
+ tweenPrecision = Math . max ( Math . ceil ( tweenPrecision ) , 1 ) ;
116
+ }
117
+ this . props . onTweenPrecisionChange ( tweenPrecision . toString ( ) + ( event . target . value === 'relative' ? '%' : '' ) ) ;
118
+ } ;
119
+
72
120
handleHoldOffChange = ( event ) => {
73
121
this . props . onHoldOffChange ( event . target . value ) ;
74
122
} ;
@@ -83,6 +131,13 @@ class SettingsDialog extends React.Component {
83
131
84
132
render ( ) {
85
133
const { classes } = this . props ;
134
+ const tweenPrecisionIsRelative = this . props . tweenPrecision . includes ( '%' ) ;
135
+ const tweenPrecision = + this . props . tweenPrecision . split ( '%' ) [ 0 ] ;
136
+ const tweenPrecisionType = tweenPrecisionIsRelative ? 'relative' : 'absolute' ;
137
+ const tweenPrecisionUnit = tweenPrecisionIsRelative ? '%' : 'points' ;
138
+ const enableTweenPrecisionSetting = this . props . tweenPaths || this . props . tweenShapes ;
139
+ const tweenPrecisionStep = ( tweenPrecisionIsRelative && tweenPrecision <= 1 ) ? 0.1 : 1 ;
140
+ const tweenPrecisionInputClass = tweenPrecisionIsRelative ? classes . tweenPrecisionRelativeInput : classes . tweenPrecisionAbsoluteInput ;
86
141
return (
87
142
< div >
88
143
< Dialog
@@ -140,6 +195,89 @@ class SettingsDialog extends React.Component {
140
195
label = "Fit graph to available area"
141
196
/>
142
197
</ FormGroup >
198
+ < FormControl
199
+ className = { classes . formControl }
200
+ aria-describedby = "transition-duration-helper-text"
201
+ >
202
+ < InputLabel shrink = { true } > Transition duration</ InputLabel >
203
+ < Input
204
+ className = { classes . transitionDuration }
205
+ id = "transition-duration"
206
+ type = "number"
207
+ value = { this . props . transitionDuration }
208
+ onChange = { this . handleTransitionDurationChange }
209
+ endAdornment = { < InputAdornment position = "end" > seconds</ InputAdornment > }
210
+ inputProps = { {
211
+ 'aria-label' : 'transitionDuration' ,
212
+ min : 0.1 ,
213
+ max : 99 ,
214
+ step : 0.1 ,
215
+ } }
216
+ />
217
+ </ FormControl >
218
+ < FormGroup row >
219
+ < FormControlLabel
220
+ className = { classes . formControlLabel }
221
+ control = {
222
+ < Switch
223
+ checked = { this . props . tweenPaths }
224
+ onChange = { this . handleTweenPathsSwitchChange }
225
+ />
226
+ }
227
+ label = "Enable path tweening during transitions"
228
+ />
229
+ </ FormGroup >
230
+ < FormGroup row >
231
+ < FormControlLabel
232
+ className = { classes . formControlLabel }
233
+ control = {
234
+ < Switch
235
+ checked = { this . props . tweenShapes }
236
+ onChange = { this . handleTweenShapesSwitchChange }
237
+ />
238
+ }
239
+ label = "Enable shape tweening during transitions"
240
+ />
241
+ </ FormGroup >
242
+ < FormControl component = "fieldset" className = { classes . formControl } >
243
+ < FormLabel component = "legend" > Tweening precision</ FormLabel >
244
+ < RadioGroup
245
+ name = "tweenPrecision"
246
+ className = { classes . group }
247
+ value = { tweenPrecisionType }
248
+ onChange = { this . handleTweenPrecisionIsRelativeRadioChange }
249
+ >
250
+ < FormControlLabel
251
+ className = { classes . formControlLabel }
252
+ value = "absolute"
253
+ disabled = { ! enableTweenPrecisionSetting }
254
+ control = { < Radio /> }
255
+ label = "Absolute"
256
+ />
257
+ < FormControlLabel
258
+ className = { classes . formControlLabel }
259
+ value = "relative"
260
+ disabled = { ! enableTweenPrecisionSetting }
261
+ control = { < Radio /> }
262
+ label = "Relative"
263
+ />
264
+ </ RadioGroup >
265
+ < Input
266
+ className = { tweenPrecisionInputClass }
267
+ id = "tween-precision"
268
+ type = "number"
269
+ value = { tweenPrecision }
270
+ disabled = { ! enableTweenPrecisionSetting }
271
+ onChange = { this . handleTweenPrecisionChange }
272
+ endAdornment = { < InputAdornment position = "end" > { tweenPrecisionUnit } </ InputAdornment > }
273
+ inputProps = { {
274
+ 'aria-label' : 'tweenPrecision' ,
275
+ min : tweenPrecisionStep ,
276
+ max : tweenPrecisionIsRelative ? 100 : 999 ,
277
+ step : tweenPrecisionStep ,
278
+ } }
279
+ />
280
+ </ FormControl >
143
281
</ DialogContent >
144
282
< DialogTitle id = "form-dialog-title" > Text Editor</ DialogTitle >
145
283
< DialogContent classes = { { root : classes . root } } >
0 commit comments