@@ -3,6 +3,7 @@ import { sliderList, Card, BasicButton, ToggleSwitch } from "../generic"
3
3
import { SECTION_NAMES , RESET_LABEL } from "../vars"
4
4
import getWalkSequence from "../../hexapod/solvers/walkSequenceSolver"
5
5
import PoseTable from "./PoseTable"
6
+ import { DEFAULT_POSE } from "../../templates"
6
7
7
8
const ANIMATION_DELAY = 1
8
9
@@ -14,8 +15,8 @@ const SLIDER_LABELS = [
14
15
"ry" ,
15
16
"hipStance" ,
16
17
"hipSwing" ,
17
- "stepCount" ,
18
18
"liftSwing" ,
19
+ "stepCount" ,
19
20
]
20
21
21
22
const PARAMS = {
@@ -49,6 +50,7 @@ class WalkingGaitsPage extends Component {
49
50
pageName = SECTION_NAMES . walkingGaits
50
51
state = {
51
52
gaitParams : DEFAULT_GAIT_VARS ,
53
+ pose : DEFAULT_POSE ,
52
54
isAnimating : false ,
53
55
isTripodGait : true ,
54
56
isForward : true ,
@@ -133,29 +135,23 @@ class WalkingGaitsPage extends Component {
133
135
134
136
get widgetsSwitch ( ) {
135
137
return (
136
- < p >
137
- < ToggleSwitch
138
- id = "gaitWidgetSwitch"
139
- value = { this . state . showGaitWidgets ? "controlsShown" : "poseShown" }
140
- handleChange = { this . toggleWidgets }
141
- showValue = { true }
142
- />
143
- </ p >
138
+ < ToggleSwitch
139
+ id = "gaitWidgetSwitch"
140
+ value = { this . state . showGaitWidgets ? "controlsShown" : "poseShown" }
141
+ handleChange = { this . toggleWidgets }
142
+ showValue = { true }
143
+ />
144
144
)
145
145
}
146
146
147
147
get animatingSwitch ( ) {
148
148
return (
149
- < p className = "row-container" >
150
- < ToggleSwitch
151
- id = "IsAnimatingSwitch"
152
- value = { this . state . isAnimating ? "PLAYING... " : "...PAUSED. " }
153
- handleChange = { this . toggleAnimating }
154
- showValue = { true }
155
- />
156
- { " <" } --- Press this!{ " " }
157
- { this . state . isAnimating ? this . state . animationCount : null }
158
- </ p >
149
+ < ToggleSwitch
150
+ id = "IsAnimatingSwitch"
151
+ value = { this . state . isAnimating ? "PLAYING... " : "...PAUSED. " }
152
+ handleChange = { this . toggleAnimating }
153
+ showValue = { true }
154
+ />
159
155
)
160
156
}
161
157
@@ -182,44 +178,48 @@ class WalkingGaitsPage extends Component {
182
178
}
183
179
184
180
get sliders ( ) {
185
- return sliderList ( {
181
+ const sliders = sliderList ( {
186
182
names : SLIDER_LABELS ,
187
183
values : this . state . gaitParams ,
188
184
rangeParams : PARAMS ,
189
185
handleChange : this . updateGaitParams ,
190
186
} )
191
- }
192
187
193
- get gaitWidgets ( ) {
194
- const sliders = this . sliders
195
188
return (
196
189
< >
197
190
< div className = "row-container" > { sliders . slice ( 6 , 9 ) } </ div >
198
191
< div className = "row-container" > { sliders . slice ( 0 , 3 ) } </ div >
199
192
< div className = "row-container" > { sliders . slice ( 3 , 6 ) } </ div >
200
- < p className = "row-container" >
201
- < div className = "cell" > { this . gaitTypeSwitch } </ div >
202
- < div className = "cell" > { this . directionSwitch } </ div >
203
- < div className = "cell" > </ div >
204
- </ p >
205
- < BasicButton handleClick = { this . reset } > { RESET_LABEL } </ BasicButton >
206
193
</ >
207
194
)
208
195
}
209
196
210
- get widgetsShown ( ) {
211
- if ( this . state . showGaitWidgets ) {
212
- return this . gaitWidgets
213
- } else {
214
- return < PoseTable pose = { this . state . pose } />
215
- }
197
+ get animationCount ( ) {
198
+ return < p hidden = { ! this . state . isAnimating } > { this . state . animationCount } </ p >
216
199
}
217
200
201
+ twoSwitches = ( switch1 , switch2 ) => (
202
+ < div className = "row-container" style = { { padding : "10px" } } >
203
+ < div className = "cell" > { switch1 } </ div >
204
+ < div className = "cell" > { switch2 } </ div >
205
+ < div className = "cell" > </ div >
206
+ </ div >
207
+ )
208
+
218
209
render = ( ) => {
219
210
return (
220
- < Card title = { < h2 > { this . pageName } </ h2 > } other = { this . widgetsSwitch } >
221
- { this . animatingSwitch }
222
- { this . widgetsShown }
211
+ < Card title = { < h2 > { this . pageName } </ h2 > } other = { this . animationCount } >
212
+ { this . twoSwitches ( this . animatingSwitch , this . widgetsSwitch ) }
213
+
214
+ < div hidden = { ! this . state . showGaitWidgets } >
215
+ { this . twoSwitches ( this . gaitTypeSwitch , this . directionSwitch ) }
216
+ { this . sliders }
217
+ < BasicButton handleClick = { this . reset } > { RESET_LABEL } </ BasicButton >
218
+ </ div >
219
+
220
+ < div hidden = { this . state . showGaitWidgets } >
221
+ < PoseTable pose = { this . state . pose } />
222
+ </ div >
223
223
</ Card >
224
224
)
225
225
}
0 commit comments