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_win.c (2723B)

      1 /**
      2  * @file lv_win.c
      3  *
      4  */
      5 
      6 /*********************
      7  *      INCLUDES
      8  *********************/
      9 #include "lv_win.h"
     10 #if LV_USE_WIN
     11 
     12 
     13 /*********************
     14  *      DEFINES
     15  *********************/
     16 
     17 /**********************
     18  *      TYPEDEFS
     19  **********************/
     20 
     21 /**********************
     22  *  STATIC PROTOTYPES
     23  **********************/
     24 static void lv_win_constructor(const lv_obj_class_t * class_p, lv_obj_t * obj);
     25 
     26 /**********************
     27  *  STATIC VARIABLES
     28  **********************/
     29 const lv_obj_class_t lv_win_class = {
     30     .constructor_cb = lv_win_constructor,
     31     .width_def = LV_PCT(100),
     32     .height_def = LV_PCT(100),
     33     .base_class = &lv_obj_class,
     34     .instance_size = sizeof(lv_win_t)
     35 };
     36 static lv_coord_t create_header_height;
     37 /**********************
     38  *      MACROS
     39  **********************/
     40 
     41 /**********************
     42  *   GLOBAL FUNCTIONS
     43  **********************/
     44 
     45 lv_obj_t * lv_win_create(lv_obj_t * parent, lv_coord_t header_height)
     46 {
     47     LV_LOG_INFO("begin");
     48     create_header_height = header_height;
     49 
     50     lv_obj_t * obj = lv_obj_class_create_obj(&lv_win_class, parent);
     51     lv_obj_class_init_obj(obj);
     52     return obj;
     53 }
     54 
     55 lv_obj_t * lv_win_add_title(lv_obj_t * win, const char * txt)
     56 {
     57     lv_obj_t * header = lv_win_get_header(win);
     58     lv_obj_t * title = lv_label_create(header);
     59     lv_label_set_long_mode(title, LV_LABEL_LONG_DOT);
     60     lv_label_set_text(title, txt);
     61     lv_obj_set_flex_grow(title, 1);
     62     return title;
     63 }
     64 
     65 lv_obj_t * lv_win_add_btn(lv_obj_t * win, const void * icon, lv_coord_t btn_w)
     66 {
     67     lv_obj_t * header = lv_win_get_header(win);
     68     lv_obj_t * btn = lv_btn_create(header);
     69     lv_obj_set_size(btn, btn_w, LV_PCT(100));
     70 
     71     lv_obj_t * img = lv_img_create(btn);
     72     lv_img_set_src(img, icon);
     73     lv_obj_align(img, LV_ALIGN_CENTER, 0, 0);
     74 
     75     return btn;
     76 }
     77 
     78 lv_obj_t * lv_win_get_header(lv_obj_t * win)
     79 {
     80     return lv_obj_get_child(win, 0);
     81 }
     82 
     83 lv_obj_t * lv_win_get_content(lv_obj_t * win)
     84 {
     85     return lv_obj_get_child(win, 1);
     86 }
     87 
     88 /**********************
     89  *   STATIC FUNCTIONS
     90  **********************/
     91 
     92 static void lv_win_constructor(const lv_obj_class_t * class_p, lv_obj_t * obj)
     93 {
     94     LV_UNUSED(class_p);
     95     lv_obj_t * parent = lv_obj_get_parent(obj);
     96     lv_obj_set_size(obj, lv_obj_get_width(parent), lv_obj_get_height(parent));
     97     lv_obj_set_flex_flow(obj, LV_FLEX_FLOW_COLUMN);
     98 
     99     lv_obj_t * header = lv_obj_create(obj);
    100     lv_obj_set_size(header, LV_PCT(100), create_header_height);
    101     lv_obj_set_flex_flow(header, LV_FLEX_FLOW_ROW);
    102     lv_obj_set_flex_align(header, LV_FLEX_ALIGN_START, LV_FLEX_ALIGN_CENTER, LV_FLEX_ALIGN_CENTER);
    103 
    104     lv_obj_t * cont = lv_obj_create(obj);
    105     lv_obj_set_flex_grow(cont, 1);
    106     lv_obj_set_width(cont, LV_PCT(100));
    107 }
    108 
    109 #endif
    110