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_2.c (2385B)
1 #include "../../lv_examples.h" 2 #if LV_USE_GRID && LV_BUILD_EXAMPLES 3 4 5 /** 6 * Demonstrate cell placement and span 7 */ 8 void lv_example_grid_2(void) 9 { 10 static lv_coord_t col_dsc[] = {70, 70, 70, LV_GRID_TEMPLATE_LAST}; 11 static lv_coord_t row_dsc[] = {50, 50, 50, LV_GRID_TEMPLATE_LAST}; 12 13 /*Create a container with grid*/ 14 lv_obj_t * cont = lv_obj_create(lv_scr_act()); 15 lv_obj_set_grid_dsc_array(cont, col_dsc, row_dsc); 16 lv_obj_set_size(cont, 300, 220); 17 lv_obj_center(cont); 18 19 lv_obj_t * label; 20 lv_obj_t * obj; 21 22 /*Cell to 0;0 and align to to the start (left/top) horizontally and vertically too*/ 23 obj = lv_obj_create(cont); 24 lv_obj_set_size(obj, LV_SIZE_CONTENT, LV_SIZE_CONTENT); 25 lv_obj_set_grid_cell(obj, LV_GRID_ALIGN_START, 0, 1, 26 LV_GRID_ALIGN_START, 0, 1); 27 label = lv_label_create(obj); 28 lv_label_set_text(label, "c0, r0"); 29 30 /*Cell to 1;0 and align to to the start (left) horizontally and center vertically too*/ 31 obj = lv_obj_create(cont); 32 lv_obj_set_size(obj, LV_SIZE_CONTENT, LV_SIZE_CONTENT); 33 lv_obj_set_grid_cell(obj, LV_GRID_ALIGN_START, 1, 1, 34 LV_GRID_ALIGN_CENTER, 0, 1); 35 label = lv_label_create(obj); 36 lv_label_set_text(label, "c1, r0"); 37 38 /*Cell to 2;0 and align to to the start (left) horizontally and end (bottom) vertically too*/ 39 obj = lv_obj_create(cont); 40 lv_obj_set_size(obj, LV_SIZE_CONTENT, LV_SIZE_CONTENT); 41 lv_obj_set_grid_cell(obj, LV_GRID_ALIGN_START, 2, 1, 42 LV_GRID_ALIGN_END, 0, 1); 43 label = lv_label_create(obj); 44 lv_label_set_text(label, "c2, r0"); 45 46 /*Cell to 1;1 but 2 column wide (span = 2).Set width and height to stretched.*/ 47 obj = lv_obj_create(cont); 48 lv_obj_set_size(obj, LV_SIZE_CONTENT, LV_SIZE_CONTENT); 49 lv_obj_set_grid_cell(obj, LV_GRID_ALIGN_STRETCH, 1, 2, 50 LV_GRID_ALIGN_STRETCH, 1, 1); 51 label = lv_label_create(obj); 52 lv_label_set_text(label, "c1-2, r1"); 53 54 /*Cell to 0;1 but 2 rows tall (span = 2).Set width and height to stretched.*/ 55 obj = lv_obj_create(cont); 56 lv_obj_set_size(obj, LV_SIZE_CONTENT, LV_SIZE_CONTENT); 57 lv_obj_set_grid_cell(obj, LV_GRID_ALIGN_STRETCH, 0, 1, 58 LV_GRID_ALIGN_STRETCH, 1, 2); 59 label = lv_label_create(obj); 60 lv_label_set_text(label, "c0\nr1-2"); 61 } 62 63 #endif