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_obj_2.c (773B)

      1 #include "../../lv_examples.h"
      2 #if LV_BUILD_EXAMPLES
      3 
      4 static void drag_event_handler(lv_event_t * e)
      5 {
      6     lv_obj_t * obj = lv_event_get_target(e);
      7 
      8     lv_indev_t * indev = lv_indev_get_act();
      9     if(indev == NULL)  return;
     10 
     11     lv_point_t vect;
     12     lv_indev_get_vect(indev, &vect);
     13 
     14     lv_coord_t x = lv_obj_get_x(obj) + vect.x;
     15     lv_coord_t y = lv_obj_get_y(obj) + vect.y;
     16     lv_obj_set_pos(obj, x, y);
     17 }
     18 
     19 
     20 /**
     21  * Make an object dragable.
     22  */
     23 void lv_example_obj_2(void)
     24 {
     25     lv_obj_t * obj;
     26     obj = lv_obj_create(lv_scr_act());
     27     lv_obj_set_size(obj, 150, 100);
     28     lv_obj_add_event_cb(obj, drag_event_handler, LV_EVENT_PRESSING, NULL);
     29 
     30     lv_obj_t * label = lv_label_create(obj);
     31     lv_label_set_text(label, "Drag me");
     32     lv_obj_center(label);
     33 
     34 }
     35 #endif