From dd27c3530432ea0b09f01e604bf577f31d8ef841 Mon Sep 17 00:00:00 2001 From: jacqueline Date: Thu, 1 Jun 2023 15:41:47 +1000 Subject: convert lvgl from submodule to a plain old directory --- lib/lvgl | 1 - lib/lvgl/examples/widgets/win/index.rst | 7 ++++ lib/lvgl/examples/widgets/win/lv_example_win_1.c | 45 +++++++++++++++++++++++ lib/lvgl/examples/widgets/win/lv_example_win_1.py | 36 ++++++++++++++++++ 4 files changed, 88 insertions(+), 1 deletion(-) delete mode 160000 lib/lvgl create mode 100644 lib/lvgl/examples/widgets/win/index.rst create mode 100644 lib/lvgl/examples/widgets/win/lv_example_win_1.c create mode 100644 lib/lvgl/examples/widgets/win/lv_example_win_1.py (limited to 'lib/lvgl/examples/widgets/win') diff --git a/lib/lvgl b/lib/lvgl deleted file mode 160000 index 0732400e..00000000 --- a/lib/lvgl +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 0732400e7b564dd0e7dc4a924619d8e19c5b23a0 diff --git a/lib/lvgl/examples/widgets/win/index.rst b/lib/lvgl/examples/widgets/win/index.rst new file mode 100644 index 00000000..2f6fc3a2 --- /dev/null +++ b/lib/lvgl/examples/widgets/win/index.rst @@ -0,0 +1,7 @@ + +Simple window +""""""""""""""" + +.. lv_example:: widgets/win/lv_example_win_1 + :language: c + diff --git a/lib/lvgl/examples/widgets/win/lv_example_win_1.c b/lib/lvgl/examples/widgets/win/lv_example_win_1.c new file mode 100644 index 00000000..4df0bff7 --- /dev/null +++ b/lib/lvgl/examples/widgets/win/lv_example_win_1.c @@ -0,0 +1,45 @@ +#include "../../lv_examples.h" +#if LV_USE_WIN && LV_BUILD_EXAMPLES + + +static void event_handler(lv_event_t * e) +{ + lv_obj_t * obj = lv_event_get_target(e); + LV_LOG_USER("Button %d clicked", (int)lv_obj_get_index(obj)); +} + +void lv_example_win_1(void) +{ + lv_obj_t * win = lv_win_create(lv_scr_act(), 40); + lv_obj_t * btn; + btn = lv_win_add_btn(win, LV_SYMBOL_LEFT, 40); + lv_obj_add_event_cb(btn, event_handler, LV_EVENT_CLICKED, NULL); + + lv_win_add_title(win, "A title"); + + btn = lv_win_add_btn(win, LV_SYMBOL_RIGHT, 40); + lv_obj_add_event_cb(btn, event_handler, LV_EVENT_CLICKED, NULL); + + btn = lv_win_add_btn(win, LV_SYMBOL_CLOSE, 60); + lv_obj_add_event_cb(btn, event_handler, LV_EVENT_CLICKED, NULL); + + lv_obj_t * cont = lv_win_get_content(win); /*Content can be added here*/ + lv_obj_t * label = lv_label_create(cont); + lv_label_set_text(label, "This is\n" + "a pretty\n" + "long text\n" + "to see how\n" + "the window\n" + "becomes\n" + "scrollable.\n" + "\n" + "\n" + "Some more\n" + "text to be\n" + "sure it\n" + "overflows. :)"); + + +} + +#endif diff --git a/lib/lvgl/examples/widgets/win/lv_example_win_1.py b/lib/lvgl/examples/widgets/win/lv_example_win_1.py new file mode 100644 index 00000000..2f5156ce --- /dev/null +++ b/lib/lvgl/examples/widgets/win/lv_example_win_1.py @@ -0,0 +1,36 @@ +def event_handler(e): + code = e.get_code() + obj = e.get_target() + if code == lv.EVENT.CLICKED: + print("Button {:d} clicked".format(obj.get_child_id())) + + +win = lv.win(lv.scr_act(), 60) +btn1 = win.add_btn(lv.SYMBOL.LEFT, 40) +btn1.add_event_cb(event_handler, lv.EVENT.ALL, None) +win.add_title("A title") +btn2=win.add_btn(lv.SYMBOL.RIGHT, 40) +btn2.add_event_cb(event_handler, lv.EVENT.ALL, None) +btn3 = win.add_btn(lv.SYMBOL.CLOSE, 60) +btn3.add_event_cb(event_handler, lv.EVENT.ALL, None) + +cont = win.get_content() # Content can be added here +label = lv.label(cont) +label.set_text("""This is +a pretty +long text +to see how +the window +becomes +scrollable. + + +We need +quite some text +and we will +even put +some more +text to be +sure it +overflows. +""") -- cgit v1.2.3