acid-drop

- Hacking the planet from a LilyGo T-Deck using custom firmware
git clone git://git.acid.vegas/acid-drop.git
Log | Files | Refs | Archive | README | LICENSE

lv_example_grid_3.c (1345B)

      1 #include "../../lv_examples.h"
      2 #if LV_USE_GRID && LV_BUILD_EXAMPLES
      3 
      4 /**
      5  * Demonstrate grid's "free unit"
      6  */
      7 void lv_example_grid_3(void)
      8 {
      9     /*Column 1: fix width 60 px
     10      *Column 2: 1 unit from the remaining free space
     11      *Column 3: 2 unit from the remaining free space*/
     12     static lv_coord_t col_dsc[] = {60, LV_GRID_FR(1), LV_GRID_FR(2), LV_GRID_TEMPLATE_LAST};
     13 
     14     /*Row 1: fix width 50 px
     15      *Row 2: 1 unit from the remaining free space
     16      *Row 3: fix width 50 px*/
     17     static lv_coord_t row_dsc[] = {50, LV_GRID_FR(1), 50, LV_GRID_TEMPLATE_LAST};
     18 
     19     /*Create a container with grid*/
     20     lv_obj_t * cont = lv_obj_create(lv_scr_act());
     21     lv_obj_set_size(cont, 300, 220);
     22     lv_obj_center(cont);
     23     lv_obj_set_grid_dsc_array(cont, col_dsc, row_dsc);
     24 
     25     lv_obj_t * label;
     26     lv_obj_t * obj;
     27     uint32_t i;
     28     for(i = 0; i < 9; i++) {
     29         uint8_t col = i % 3;
     30         uint8_t row = i / 3;
     31 
     32         obj = lv_obj_create(cont);
     33         /*Stretch the cell horizontally and vertically too
     34          *Set span to 1 to make the cell 1 column/row sized*/
     35         lv_obj_set_grid_cell(obj, LV_GRID_ALIGN_STRETCH, col, 1,
     36                              LV_GRID_ALIGN_STRETCH, row, 1);
     37 
     38         label = lv_label_create(obj);
     39         lv_label_set_text_fmt(label, "%d,%d", col, row);
     40         lv_obj_center(label);
     41     }
     42 }
     43 
     44 #endif