Skip to content

Commit

Permalink
fix(sw): make knob size calculation more intuitive
Browse files Browse the repository at this point in the history
  • Loading branch information
kisvegabor committed Jan 24, 2022
1 parent 1900c21 commit 5ec532d
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/widgets/lv_switch.c
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ static void draw_main(lv_event_t * e)
/*Draw the knob*/
lv_coord_t anim_value_x = 0;
lv_coord_t knob_size = lv_obj_get_height(obj);
lv_coord_t anim_length = obj->coords.x2 - bg_right - obj->coords.x1 - bg_left - knob_size;
lv_coord_t anim_length = lv_area_get_width(&obj->coords) - knob_size;

if(LV_SWITCH_IS_ANIMATING(sw)) {
/* Use the animation's coordinate */
Expand All @@ -190,7 +190,7 @@ static void draw_main(lv_event_t * e)
}

lv_area_t knob_area;
knob_area.x1 = obj->coords.x1 + bg_left + anim_value_x;
knob_area.x1 = obj->coords.x1 + anim_value_x;
knob_area.x2 = knob_area.x1 + knob_size;

knob_area.y1 = obj->coords.y1;
Expand Down

0 comments on commit 5ec532d

Please sign in to comment.