Skip to content

Commit d4aae76

Browse files
committed
fix LVGL timeline animation in Studio simulator
1 parent 1f9d7e2 commit d4aae76

File tree

3 files changed

+17
-53
lines changed

3 files changed

+17
-53
lines changed
Binary file not shown.
Binary file not shown.

wasm/lvgl-runtime/common/src/flow.cpp

+17-53
Original file line numberDiff line numberDiff line change
@@ -225,14 +225,6 @@ void updateTimelineProperties(WidgetTimeline &widgetTimeline, float timelinePosi
225225
float scale = widgetTimeline.scale;
226226
float rotate = widgetTimeline.rotate;
227227

228-
bool setX = false;
229-
bool setY = false;
230-
bool setWidth = false;
231-
bool setHeight = false;
232-
bool setOPA = false;
233-
bool setScale = false;
234-
bool setRotate = false;
235-
236228
for (auto itKeyframe = widgetTimeline.timeline.begin(); itKeyframe != widgetTimeline.timeline.end(); itKeyframe++) {
237229
TimelineKeyframe &keyframe = *itKeyframe;
238230

@@ -273,14 +265,10 @@ void updateTimelineProperties(WidgetTimeline &widgetTimeline, float timelinePosi
273265
auto p2 = keyframe.x;
274266
x = (1 - t2) * p1 + t2 * p2;
275267
}
276-
277-
setX = true;
278268
}
279269

280270
if (keyframe.enabledProperties & WIDGET_TIMELINE_PROPERTY_WIDTH) {
281271
w += eez::g_easingFuncs[keyframe.widthEasingFunc](t) * (keyframe.width - w);
282-
283-
setWidth = true;
284272
}
285273

286274
if (keyframe.enabledProperties & WIDGET_TIMELINE_PROPERTY_Y) {
@@ -309,32 +297,22 @@ void updateTimelineProperties(WidgetTimeline &widgetTimeline, float timelinePosi
309297
auto p2 = keyframe.y;
310298
y = (1 - t2) * p1 + t2 * p2;
311299
}
312-
313-
setY = true;
314300
}
315301

316302
if (keyframe.enabledProperties & WIDGET_TIMELINE_PROPERTY_HEIGHT) {
317303
h += eez::g_easingFuncs[keyframe.heightEasingFunc](t) * (keyframe.height - h);
318-
319-
setHeight = true;
320304
}
321305

322306
if (keyframe.enabledProperties & WIDGET_TIMELINE_PROPERTY_OPACITY) {
323307
opacity += eez::g_easingFuncs[keyframe.opacityEasingFunc](t) * (keyframe.opacity - opacity);
324-
325-
setOPA = true;
326308
}
327309

328310
if (keyframe.enabledProperties & WIDGET_TIMELINE_PROPERTY_SCALE) {
329311
scale += eez::g_easingFuncs[keyframe.scaleEasingFunc](t) * (keyframe.scale - scale);
330-
331-
setScale = true;
332312
}
333313

334314
if (keyframe.enabledProperties & WIDGET_TIMELINE_PROPERTY_ROTATE) {
335315
rotate += eez::g_easingFuncs[keyframe.rotateEasingFunc](t) * (keyframe.rotate - rotate);
336-
337-
setRotate = true;
338316
}
339317

340318
break;
@@ -368,49 +346,35 @@ void updateTimelineProperties(WidgetTimeline &widgetTimeline, float timelinePosi
368346

369347
lv_style_value_t value;
370348

371-
if (setX) {
372-
value.num = (int16_t)roundf(x);
373-
lv_obj_set_local_style_prop(widgetTimeline.obj, LV_STYLE_X, value, LV_PART_MAIN);
374-
}
349+
value.num = (int16_t)roundf(x);
350+
lv_obj_set_local_style_prop(widgetTimeline.obj, LV_STYLE_X, value, LV_PART_MAIN);
375351

376-
if (setY) {
377-
value.num = (int16_t)roundf(y);
378-
lv_obj_set_local_style_prop(widgetTimeline.obj, LV_STYLE_Y, value, LV_PART_MAIN);
379-
}
352+
value.num = (int16_t)roundf(y);
353+
lv_obj_set_local_style_prop(widgetTimeline.obj, LV_STYLE_Y, value, LV_PART_MAIN);
380354

381-
if (setWidth) {
382-
value.num = (int16_t)roundf(w);
383-
lv_obj_set_local_style_prop(widgetTimeline.obj, LV_STYLE_WIDTH, value, LV_PART_MAIN);
384-
}
355+
value.num = (int16_t)roundf(w);
356+
lv_obj_set_local_style_prop(widgetTimeline.obj, LV_STYLE_WIDTH, value, LV_PART_MAIN);
385357

386-
if (setHeight) {
387-
value.num = (int16_t)roundf(h);
388-
lv_obj_set_local_style_prop(widgetTimeline.obj, LV_STYLE_HEIGHT, value, LV_PART_MAIN);
389-
}
358+
value.num = (int16_t)roundf(h);
359+
lv_obj_set_local_style_prop(widgetTimeline.obj, LV_STYLE_HEIGHT, value, LV_PART_MAIN);
390360

391-
if (setOPA) {
392-
value.num = (int32_t)roundf(opacity * 255.0f);
393-
lv_obj_set_local_style_prop(widgetTimeline.obj, LV_STYLE_OPA, value, LV_PART_MAIN);
394-
}
361+
value.num = (int32_t)roundf(opacity * 255.0f);
362+
lv_obj_set_local_style_prop(widgetTimeline.obj, LV_STYLE_OPA, value, LV_PART_MAIN);
395363

396-
if (setScale) {
397-
value.num = (int32_t)roundf(scale);
364+
value.num = (int32_t)roundf(scale);
398365
#if LVGL_VERSION_MAJOR >= 9
399-
lv_obj_set_local_style_prop(widgetTimeline.obj, LV_STYLE_TRANSFORM_SCALE_X, value, LV_PART_MAIN);
400-
lv_obj_set_local_style_prop(widgetTimeline.obj, LV_STYLE_TRANSFORM_SCALE_Y, value, LV_PART_MAIN);
366+
lv_obj_set_local_style_prop(widgetTimeline.obj, LV_STYLE_TRANSFORM_SCALE_X, value, LV_PART_MAIN);
367+
lv_obj_set_local_style_prop(widgetTimeline.obj, LV_STYLE_TRANSFORM_SCALE_Y, value, LV_PART_MAIN);
401368
#else
402-
lv_obj_set_local_style_prop(widgetTimeline.obj, LV_STYLE_TRANSFORM_ZOOM, value, LV_PART_MAIN);
369+
lv_obj_set_local_style_prop(widgetTimeline.obj, LV_STYLE_TRANSFORM_ZOOM, value, LV_PART_MAIN);
403370
#endif
404-
}
405371

406-
if (setRotate) {
407-
value.num = (int32_t)roundf(rotate);
372+
value.num = (int32_t)roundf(rotate);
408373
#if LVGL_VERSION_MAJOR >= 9
409-
lv_obj_set_local_style_prop(widgetTimeline.obj, LV_STYLE_TRANSFORM_ROTATION, value, LV_PART_MAIN);
374+
lv_obj_set_local_style_prop(widgetTimeline.obj, LV_STYLE_TRANSFORM_ROTATION, value, LV_PART_MAIN);
410375
#else
411-
lv_obj_set_local_style_prop(widgetTimeline.obj, LV_STYLE_TRANSFORM_ANGLE, value, LV_PART_MAIN);
376+
lv_obj_set_local_style_prop(widgetTimeline.obj, LV_STYLE_TRANSFORM_ANGLE, value, LV_PART_MAIN);
412377
#endif
413-
}
414378
}
415379

416380
void doAnimateFlowState(eez::flow::FlowState *flowState) {

0 commit comments

Comments
 (0)