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_fragment_1.c (1395B)
1 /** 2 * @file lv_example_fragment_1.c 3 * @brief Basic usage of obj fragment 4 */ 5 #include "../../lv_examples.h" 6 7 #if LV_USE_FRAGMENT && LV_BUILD_EXAMPLES 8 9 static void sample_fragment_ctor(lv_fragment_t * self, void * args); 10 11 static lv_obj_t * sample_fragment_create_obj(lv_fragment_t * self, lv_obj_t * parent); 12 13 static lv_obj_t * root = NULL; 14 15 struct sample_fragment_t { 16 lv_fragment_t base; 17 const char * name; 18 }; 19 20 static const lv_fragment_class_t sample_cls = { 21 .constructor_cb = sample_fragment_ctor, 22 .create_obj_cb = sample_fragment_create_obj, 23 .instance_size = sizeof(struct sample_fragment_t) 24 }; 25 26 void lv_example_fragment_1(void) 27 { 28 root = lv_obj_create(lv_scr_act()); 29 lv_obj_set_size(root, LV_PCT(100), LV_PCT(100)); 30 lv_fragment_manager_t * manager = lv_fragment_manager_create(NULL); 31 lv_fragment_t * fragment = lv_fragment_create(&sample_cls, "Fragment"); 32 lv_fragment_manager_replace(manager, fragment, &root); 33 } 34 35 36 static void sample_fragment_ctor(lv_fragment_t * self, void * args) 37 { 38 ((struct sample_fragment_t *) self)->name = args; 39 } 40 41 static lv_obj_t * sample_fragment_create_obj(lv_fragment_t * self, lv_obj_t * parent) 42 { 43 lv_obj_t * label = lv_label_create(parent); 44 lv_obj_set_style_bg_opa(label, LV_OPA_COVER, 0);; 45 lv_label_set_text_fmt(label, "Hello, %s!", ((struct sample_fragment_t *) self)->name); 46 return label; 47 } 48 49 #endif