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_spinbox_1.c (1477B)

      1 #include "../../lv_examples.h"
      2 #if LV_USE_SPINBOX && LV_BUILD_EXAMPLES
      3 
      4 static lv_obj_t * spinbox;
      5 
      6 
      7 static void lv_spinbox_increment_event_cb(lv_event_t * e)
      8 {
      9     lv_event_code_t code = lv_event_get_code(e);
     10     if(code == LV_EVENT_SHORT_CLICKED || code  == LV_EVENT_LONG_PRESSED_REPEAT) {
     11         lv_spinbox_increment(spinbox);
     12     }
     13 }
     14 
     15 static void lv_spinbox_decrement_event_cb(lv_event_t * e)
     16 {
     17     lv_event_code_t code = lv_event_get_code(e);
     18     if(code == LV_EVENT_SHORT_CLICKED || code == LV_EVENT_LONG_PRESSED_REPEAT) {
     19         lv_spinbox_decrement(spinbox);
     20     }
     21 }
     22 
     23 
     24 void lv_example_spinbox_1(void)
     25 {
     26     spinbox = lv_spinbox_create(lv_scr_act());
     27     lv_spinbox_set_range(spinbox, -1000, 25000);
     28     lv_spinbox_set_digit_format(spinbox, 5, 2);
     29     lv_spinbox_step_prev(spinbox);
     30     lv_obj_set_width(spinbox, 100);
     31     lv_obj_center(spinbox);
     32 
     33     lv_coord_t h = lv_obj_get_height(spinbox);
     34 
     35     lv_obj_t * btn = lv_btn_create(lv_scr_act());
     36     lv_obj_set_size(btn, h, h);
     37     lv_obj_align_to(btn, spinbox, LV_ALIGN_OUT_RIGHT_MID, 5, 0);
     38     lv_obj_set_style_bg_img_src(btn, LV_SYMBOL_PLUS, 0);
     39     lv_obj_add_event_cb(btn, lv_spinbox_increment_event_cb, LV_EVENT_ALL,  NULL);
     40 
     41     btn = lv_btn_create(lv_scr_act());
     42     lv_obj_set_size(btn, h, h);
     43     lv_obj_align_to(btn, spinbox, LV_ALIGN_OUT_LEFT_MID, -5, 0);
     44     lv_obj_set_style_bg_img_src(btn, LV_SYMBOL_MINUS, 0);
     45     lv_obj_add_event_cb(btn, lv_spinbox_decrement_event_cb, LV_EVENT_ALL, NULL);
     46 }
     47 
     48 #endif