Like iphone confirmation slider

slider

I modified the lv_silder.c file to achieve the effect of the IPHONE shutdown confirmation slider, if you do not modify the source file method, welcome to discuss with me

Why was it required to modify lv_slider.c?

Because I got an funny thing without modification
slider2

Do you mean the strange radius of the indicator below the knob?

yes,this is my modif start at linenums 310

    if(hor) {
        //knob_area->x1 -= (knob_size >> 1);
        knob_area->x1 -= (knob_size );
        if (knob_area->x1 < obj->coords.x1)
            knob_area->x1 = obj->coords.x1;
        knob_area->x2 = knob_area->x1 + knob_size - 1;
        knob_area->y1 = obj->coords.y1;
        knob_area->y2 = obj->coords.y2;
    }
    else {
        
       // knob_area->y1 -= (knob_size >> 1);
        knob_area->y1 -= (knob_size );
1 Like

Probably we could have a config option for it, but it show very well the beauty of using open-source libs: you can easily change 1-2 lines to get what need.

Yes, it would be great to make it configurable, and I’m very grateful to the LVGL team for providing such a great open source UI framework. I’ve used LVGL on three commercial projects so far

1 Like

So happy to hear that! :slight_smile:

This should be pretty easy to get working without having to change the LVGL source code at all. Using the slider and setting the range to 0 - 100 and using an event for value changed and inside that callback check indev to see if the touch has been released and if it has and the value is < x then snap the slider back to zero otherwise snap it up to 100.

It is strange that the knob goes past the indicator. It shouldn’t be able to do that. I would need to see the exact code that is being run that causes it to do that.

Yes, the problem is not the motion control part, as you said, it’s very simple. But in the LAYOUT section, the modified code has been posted ther