summaryrefslogtreecommitdiff
path: root/lib/lvgl/examples/widgets/obj
diff options
context:
space:
mode:
authorjacqueline <me@jacqueline.id.au>2023-06-01 15:41:47 +1000
committerjacqueline <me@jacqueline.id.au>2023-06-01 15:41:47 +1000
commitdd27c3530432ea0b09f01e604bf577f31d8ef841 (patch)
treebbf86cf81a78f0ff0b07f31f1c390db473f26fd3 /lib/lvgl/examples/widgets/obj
parent6fd588e970470b15936187980829916d0dbe77bb (diff)
downloadtangara-fw-dd27c3530432ea0b09f01e604bf577f31d8ef841.tar.gz
convert lvgl from submodule to a plain old directory
Diffstat (limited to 'lib/lvgl/examples/widgets/obj')
m---------lib/lvgl0
-rw-r--r--lib/lvgl/examples/widgets/obj/index.rst13
-rw-r--r--lib/lvgl/examples/widgets/obj/lv_example_obj_1.c22
-rw-r--r--lib/lvgl/examples/widgets/obj/lv_example_obj_1.py14
-rw-r--r--lib/lvgl/examples/widgets/obj/lv_example_obj_2.c35
-rw-r--r--lib/lvgl/examples/widgets/obj/lv_example_obj_2.py25
6 files changed, 109 insertions, 0 deletions
diff --git a/lib/lvgl b/lib/lvgl
deleted file mode 160000
-Subproject 0732400e7b564dd0e7dc4a924619d8e19c5b23a
diff --git a/lib/lvgl/examples/widgets/obj/index.rst b/lib/lvgl/examples/widgets/obj/index.rst
new file mode 100644
index 00000000..2bf39db9
--- /dev/null
+++ b/lib/lvgl/examples/widgets/obj/index.rst
@@ -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
+
diff --git a/lib/lvgl/examples/widgets/obj/lv_example_obj_1.c b/lib/lvgl/examples/widgets/obj/lv_example_obj_1.c
new file mode 100644
index 00000000..9c5ff7a0
--- /dev/null
+++ b/lib/lvgl/examples/widgets/obj/lv_example_obj_1.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
diff --git a/lib/lvgl/examples/widgets/obj/lv_example_obj_1.py b/lib/lvgl/examples/widgets/obj/lv_example_obj_1.py
new file mode 100644
index 00000000..f627e520
--- /dev/null
+++ b/lib/lvgl/examples/widgets/obj/lv_example_obj_1.py
@@ -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)
+
diff --git a/lib/lvgl/examples/widgets/obj/lv_example_obj_2.c b/lib/lvgl/examples/widgets/obj/lv_example_obj_2.c
new file mode 100644
index 00000000..627d509f
--- /dev/null
+++ b/lib/lvgl/examples/widgets/obj/lv_example_obj_2.c
@@ -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_cb(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
diff --git a/lib/lvgl/examples/widgets/obj/lv_example_obj_2.py b/lib/lvgl/examples/widgets/obj/lv_example_obj_2.py
new file mode 100644
index 00000000..f1f3626d
--- /dev/null
+++ b/lib/lvgl/examples/widgets/obj/lv_example_obj_2.py
@@ -0,0 +1,25 @@
+def drag_event_handler(e):
+
+ obj = e.get_target()
+
+ 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_cb(drag_event_handler, lv.EVENT.PRESSING, None)
+
+label = lv.label(obj)
+label.set_text("Drag me")
+label.center()
+