Create a dashed line

So, I have been thinking about this problem for about a day and im having a little trouble coming up with a good solution.

There are 2 solutions that I can see:

  1. Create an lv_obj_t line object for each dash (This is “easy”, but seems terrible tbh)
  2. Draw the lines using the draw ctx and drawing them directly circumventing lv objects, I suppose if I really wanted to be special I could create a widget lv_fancy_line or some such

Am I missing a potential solution? I coded out 1 and I just hate the solution, waste of memory.

Well, Ill be damned…

In writing a base object for drawing this, im 90% through it and I see I have been wasting my time.

lv_coord_t dash_width;
lv_coord_t dash_gap;

typedef struct {
    lv_color_t color;
    lv_coord_t width;
    lv_coord_t dash_width; 
    lv_coord_t dash_gap;
    lv_opa_t opa;
    lv_blend_mode_t blend_mode  : 2;
    uint8_t round_start : 1;
    uint8_t round_end   : 1;
    uint8_t raw_end     : 1;    /*Do not bother with perpendicular line ending if it's not visible for any reason*/
} lv_draw_line_dsc_t;

le sigh… Well it was a good walk thru the internals of LVGL. :slight_smile:

I really should make a post that entails Ron’s things he learned the hard way

1 Like