LVGL simulator fix
Added obj folder to lvgl
This commit is contained in:
parent
bab8794253
commit
53f9d1b2e0
5 changed files with 109 additions and 0 deletions
|
@ -0,0 +1,13 @@
|
|||
|
||||
Base objects with custom styles
|
||||
-------------------------------
|
||||
|
||||
.. lv_example:: widgets/obj/lv_example_obj_1
|
||||
:language: c
|
||||
|
||||
Make an object draggable
|
||||
------------------------
|
||||
|
||||
.. lv_example:: widgets/obj/lv_example_obj_2
|
||||
:language: c
|
||||
|
|
@ -0,0 +1,22 @@
|
|||
#include "../../lv_examples.h"
|
||||
#if LV_BUILD_EXAMPLES
|
||||
|
||||
void lv_example_obj_1(void)
|
||||
{
|
||||
lv_obj_t * obj1;
|
||||
obj1 = lv_obj_create(lv_scr_act());
|
||||
lv_obj_set_size(obj1, 100, 50);
|
||||
lv_obj_align(obj1, LV_ALIGN_CENTER, -60, -30);
|
||||
|
||||
static lv_style_t style_shadow;
|
||||
lv_style_init(&style_shadow);
|
||||
lv_style_set_shadow_width(&style_shadow, 10);
|
||||
lv_style_set_shadow_spread(&style_shadow, 5);
|
||||
lv_style_set_shadow_color(&style_shadow, lv_palette_main(LV_PALETTE_BLUE));
|
||||
|
||||
lv_obj_t * obj2;
|
||||
obj2 = lv_obj_create(lv_scr_act());
|
||||
lv_obj_add_style(obj2, &style_shadow, 0);
|
||||
lv_obj_align(obj2, LV_ALIGN_CENTER, 60, 30);
|
||||
}
|
||||
#endif
|
|
@ -0,0 +1,14 @@
|
|||
obj1 = lv.obj(lv.scr_act())
|
||||
obj1.set_size(100, 50)
|
||||
obj1.align(lv.ALIGN.CENTER, -60, -30)
|
||||
|
||||
style_shadow = lv.style_t()
|
||||
style_shadow.init()
|
||||
style_shadow.set_shadow_width(10)
|
||||
style_shadow.set_shadow_spread(5)
|
||||
style_shadow.set_shadow_color(lv.palette_main(lv.PALETTE.BLUE))
|
||||
|
||||
obj2 = lv.obj(lv.scr_act())
|
||||
obj2.add_style(style_shadow, 0)
|
||||
obj2.align(lv.ALIGN.CENTER, 60, 30)
|
||||
|
|
@ -0,0 +1,35 @@
|
|||
#include "../../lv_examples.h"
|
||||
#if LV_BUILD_EXAMPLES
|
||||
|
||||
static void drag_event_handler(lv_event_t * e)
|
||||
{
|
||||
lv_obj_t * obj = lv_event_get_target(e);
|
||||
|
||||
lv_indev_t * indev = lv_indev_get_act();
|
||||
if(indev == NULL) return;
|
||||
|
||||
lv_point_t vect;
|
||||
lv_indev_get_vect(indev, &vect);
|
||||
|
||||
lv_coord_t x = lv_obj_get_x(obj) + vect.x;
|
||||
lv_coord_t y = lv_obj_get_y(obj) + vect.y;
|
||||
lv_obj_set_pos(obj, x, y);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Make an object dragable.
|
||||
*/
|
||||
void lv_example_obj_2(void)
|
||||
{
|
||||
lv_obj_t * obj;
|
||||
obj = lv_obj_create(lv_scr_act());
|
||||
lv_obj_set_size(obj, 150, 100);
|
||||
//lv_obj_add_event(obj, drag_event_handler, LV_EVENT_PRESSING, NULL);
|
||||
|
||||
lv_obj_t * label = lv_label_create(obj);
|
||||
lv_label_set_text(label, "Drag me");
|
||||
lv_obj_center(label);
|
||||
|
||||
}
|
||||
#endif
|
|
@ -0,0 +1,25 @@
|
|||
def drag_event_handler(e):
|
||||
|
||||
obj = e.get_target_obj()
|
||||
|
||||
indev = lv.indev_get_act()
|
||||
|
||||
vect = lv.point_t()
|
||||
indev.get_vect(vect)
|
||||
x = obj.get_x() + vect.x
|
||||
y = obj.get_y() + vect.y
|
||||
obj.set_pos(x, y)
|
||||
|
||||
|
||||
#
|
||||
# Make an object dragable.
|
||||
#
|
||||
|
||||
obj = lv.obj(lv.scr_act())
|
||||
obj.set_size(150, 100)
|
||||
obj.add_event(drag_event_handler, lv.EVENT.PRESSING, None)
|
||||
|
||||
label = lv.label(obj)
|
||||
label.set_text("Drag me")
|
||||
label.center()
|
||||
|
Loading…
Reference in a new issue