Animate field type selection
This commit is contained in:
parent
370dbb5ca1
commit
d1b4ad625c
|
@ -102,7 +102,7 @@ DriverViewViewBase::DriverViewViewBase() :
|
||||||
fieldTypeSelection.setPosition(15, 95, 150, 225);
|
fieldTypeSelection.setPosition(15, 95, 150, 225);
|
||||||
fieldTypeSelection.setHorizontal(false);
|
fieldTypeSelection.setHorizontal(false);
|
||||||
fieldTypeSelection.setCircular(true);
|
fieldTypeSelection.setCircular(true);
|
||||||
fieldTypeSelection.setEasingEquation(touchgfx::EasingEquations::backEaseOut);
|
fieldTypeSelection.setEasingEquation(touchgfx::EasingEquations::linearEaseOut);
|
||||||
fieldTypeSelection.setSwipeAcceleration(10);
|
fieldTypeSelection.setSwipeAcceleration(10);
|
||||||
fieldTypeSelection.setDragAcceleration(10);
|
fieldTypeSelection.setDragAcceleration(10);
|
||||||
fieldTypeSelection.setNumberOfItems(1);
|
fieldTypeSelection.setNumberOfItems(1);
|
||||||
|
|
|
@ -38,7 +38,7 @@ private:
|
||||||
DriverViewField &getField(size_t i);
|
DriverViewField &getField(size_t i);
|
||||||
|
|
||||||
void updateSelectedField(size_t select);
|
void updateSelectedField(size_t select);
|
||||||
void updateSelectedFieldType(size_t select);
|
void updateSelectedFieldType(size_t select, bool animate = true);
|
||||||
|
|
||||||
size_t selectedField;
|
size_t selectedField;
|
||||||
size_t selectedFieldType;
|
size_t selectedFieldType;
|
||||||
|
|
|
@ -138,15 +138,22 @@ void DriverViewView::updateSelectedField(size_t selected) {
|
||||||
fieldTypeSelection.invalidate();
|
fieldTypeSelection.invalidate();
|
||||||
selectedField = selected;
|
selectedField = selected;
|
||||||
|
|
||||||
updateSelectedFieldType(fieldTypes[selectedField]);
|
updateSelectedFieldType(fieldTypes[selectedField], false);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DriverViewView::updateSelectedFieldType(size_t selected) {
|
void DriverViewView::updateSelectedFieldType(size_t selected, bool animate) {
|
||||||
size_t previousSelected = selectedFieldType;
|
size_t previousSelected = selectedFieldType;
|
||||||
selectedFieldType = selected;
|
selectedFieldType = selected;
|
||||||
// Trigger update of the background
|
// Trigger update of the background
|
||||||
fieldTypeSelection.itemChanged(previousSelected);
|
fieldTypeSelection.itemChanged(previousSelected);
|
||||||
fieldTypeSelection.itemChanged(selectedFieldType);
|
fieldTypeSelection.itemChanged(selectedFieldType);
|
||||||
|
|
||||||
fieldTypeSelection.animateToItem(selectedFieldType, 0);
|
int16_t steps = animate ? 2 : 0;
|
||||||
|
if (selectedFieldType == 0) {
|
||||||
|
// Just animating to 0 looks very broken when scrolling forwards. Animating
|
||||||
|
// to DataFieldType_COUNT looks good in both directions.
|
||||||
|
fieldTypeSelection.animateToItem(DataFieldType_COUNT, steps);
|
||||||
|
} else {
|
||||||
|
fieldTypeSelection.animateToItem(selectedFieldType, steps);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -436,7 +436,7 @@
|
||||||
"IsCircular": true,
|
"IsCircular": true,
|
||||||
"ItemTemplateName": "DriverViewFieldSelection",
|
"ItemTemplateName": "DriverViewFieldSelection",
|
||||||
"NumberofItems": 1,
|
"NumberofItems": 1,
|
||||||
"Easing": "Back",
|
"Easing": "Linear",
|
||||||
"EasingOption": "Out",
|
"EasingOption": "Out",
|
||||||
"SwipeAcceleration": 1.0,
|
"SwipeAcceleration": 1.0,
|
||||||
"DragAcceleration": 1.0
|
"DragAcceleration": 1.0
|
||||||
|
|
Loading…
Reference in New Issue