summaryrefslogtreecommitdiff
path: root/lib/lvgl/examples/widgets/spinbox
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/spinbox
parent6fd588e970470b15936187980829916d0dbe77bb (diff)
downloadtangara-fw-dd27c3530432ea0b09f01e604bf577f31d8ef841.tar.gz
convert lvgl from submodule to a plain old directory
Diffstat (limited to 'lib/lvgl/examples/widgets/spinbox')
m---------lib/lvgl0
-rw-r--r--lib/lvgl/examples/widgets/spinbox/index.rst7
-rw-r--r--lib/lvgl/examples/widgets/spinbox/lv_example_spinbox_1.c48
-rw-r--r--lib/lvgl/examples/widgets/spinbox/lv_example_spinbox_1.py30
4 files changed, 85 insertions, 0 deletions
diff --git a/lib/lvgl b/lib/lvgl
deleted file mode 160000
-Subproject 0732400e7b564dd0e7dc4a924619d8e19c5b23a
diff --git a/lib/lvgl/examples/widgets/spinbox/index.rst b/lib/lvgl/examples/widgets/spinbox/index.rst
new file mode 100644
index 00000000..4ccaddc0
--- /dev/null
+++ b/lib/lvgl/examples/widgets/spinbox/index.rst
@@ -0,0 +1,7 @@
+
+Simple Spinbox
+"""""""""""""""""""""""
+
+.. lv_example:: widgets/spinbox/lv_example_spinbox_1
+ :language: c
+
diff --git a/lib/lvgl/examples/widgets/spinbox/lv_example_spinbox_1.c b/lib/lvgl/examples/widgets/spinbox/lv_example_spinbox_1.c
new file mode 100644
index 00000000..2395aa4e
--- /dev/null
+++ b/lib/lvgl/examples/widgets/spinbox/lv_example_spinbox_1.c
@@ -0,0 +1,48 @@
+#include "../../lv_examples.h"
+#if LV_USE_SPINBOX && LV_BUILD_EXAMPLES
+
+static lv_obj_t * spinbox;
+
+
+static void lv_spinbox_increment_event_cb(lv_event_t * e)
+{
+ lv_event_code_t code = lv_event_get_code(e);
+ if(code == LV_EVENT_SHORT_CLICKED || code == LV_EVENT_LONG_PRESSED_REPEAT) {
+ lv_spinbox_increment(spinbox);
+ }
+}
+
+static void lv_spinbox_decrement_event_cb(lv_event_t * e)
+{
+ lv_event_code_t code = lv_event_get_code(e);
+ if(code == LV_EVENT_SHORT_CLICKED || code == LV_EVENT_LONG_PRESSED_REPEAT) {
+ lv_spinbox_decrement(spinbox);
+ }
+}
+
+
+void lv_example_spinbox_1(void)
+{
+ spinbox = lv_spinbox_create(lv_scr_act());
+ lv_spinbox_set_range(spinbox, -1000, 25000);
+ lv_spinbox_set_digit_format(spinbox, 5, 2);
+ lv_spinbox_step_prev(spinbox);
+ lv_obj_set_width(spinbox, 100);
+ lv_obj_center(spinbox);
+
+ lv_coord_t h = lv_obj_get_height(spinbox);
+
+ lv_obj_t * btn = lv_btn_create(lv_scr_act());
+ lv_obj_set_size(btn, h, h);
+ lv_obj_align_to(btn, spinbox, LV_ALIGN_OUT_RIGHT_MID, 5, 0);
+ lv_obj_set_style_bg_img_src(btn, LV_SYMBOL_PLUS, 0);
+ lv_obj_add_event_cb(btn, lv_spinbox_increment_event_cb, LV_EVENT_ALL, NULL);
+
+ btn = lv_btn_create(lv_scr_act());
+ lv_obj_set_size(btn, h, h);
+ lv_obj_align_to(btn, spinbox, LV_ALIGN_OUT_LEFT_MID, -5, 0);
+ lv_obj_set_style_bg_img_src(btn, LV_SYMBOL_MINUS, 0);
+ lv_obj_add_event_cb(btn, lv_spinbox_decrement_event_cb, LV_EVENT_ALL, NULL);
+}
+
+#endif
diff --git a/lib/lvgl/examples/widgets/spinbox/lv_example_spinbox_1.py b/lib/lvgl/examples/widgets/spinbox/lv_example_spinbox_1.py
new file mode 100644
index 00000000..fa00f9b5
--- /dev/null
+++ b/lib/lvgl/examples/widgets/spinbox/lv_example_spinbox_1.py
@@ -0,0 +1,30 @@
+def increment_event_cb(e):
+ code = e.get_code()
+ if code == lv.EVENT.SHORT_CLICKED or code == lv.EVENT.LONG_PRESSED_REPEAT:
+ spinbox.increment()
+
+def decrement_event_cb(e):
+ code = e.get_code()
+ if code == lv.EVENT.SHORT_CLICKED or code == lv.EVENT.LONG_PRESSED_REPEAT:
+ spinbox.decrement()
+
+spinbox = lv.spinbox(lv.scr_act())
+spinbox.set_range(-1000, 25000)
+spinbox.set_digit_format(5, 2)
+spinbox.step_prev()
+spinbox.set_width(100)
+spinbox.center()
+
+h = spinbox.get_height()
+
+btn = lv.btn(lv.scr_act())
+btn.set_size(h, h)
+btn.align_to(spinbox, lv.ALIGN.OUT_RIGHT_MID, 5, 0)
+btn.set_style_bg_img_src(lv.SYMBOL.PLUS, 0)
+btn.add_event_cb(increment_event_cb, lv.EVENT.ALL, None)
+
+btn = lv.btn(lv.scr_act())
+btn.set_size(h, h)
+btn.align_to(spinbox, lv.ALIGN.OUT_LEFT_MID, -5, 0)
+btn.set_style_bg_img_src(lv.SYMBOL.MINUS, 0)
+btn.add_event_cb(decrement_event_cb, lv.EVENT.ALL, None)