You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by ac...@apache.org on 2020/04/15 14:38:41 UTC
[incubator-nuttx-apps] 09/15: examples/lvgldemo: Port all demos to
LVGL V6.1.2
This is an automated email from the ASF dual-hosted git repository.
acassis pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-nuttx-apps.git
commit 94b8dbe7aa043dbae1ca1ba2ceaaf5b34105cc0d
Author: Qi Huang <hu...@xiaomi.com>
AuthorDate: Thu Apr 9 09:14:22 2020 +0000
examples/lvgldemo: Port all demos to LVGL V6.1.2
Signed-off-by: Qi Huang <hu...@xiaomi.com>
Change-Id: Ie139af71e88d887bffefcd9b97977124c5a9e1c3
---
examples/lvgldemo/Kconfig | 5 +
examples/lvgldemo/demo.h | 6 +
examples/lvgldemo/lv_test_theme_1.c | 559 +++++++++++++++++-------------------
examples/lvgldemo/lv_test_theme_2.c | 409 +++++++++++++-------------
4 files changed, 469 insertions(+), 510 deletions(-)
diff --git a/examples/lvgldemo/Kconfig b/examples/lvgldemo/Kconfig
index c2de77a..b7f1778 100644
--- a/examples/lvgldemo/Kconfig
+++ b/examples/lvgldemo/Kconfig
@@ -39,6 +39,11 @@ config EXAMPLES_LVGLDEMO_WALLPAPER
depends on EXAMPLES_LVGLDEMO_SIMPLE
default y
+config EXAMPLES_LVGLDEMO_SLIDE_SHOW
+ bool "Use slide"
+ depends on EXAMPLES_LVGLDEMO_SIMPLE
+ default n
+
choice
prompt "Selected Theme"
depends on EXAMPLES_LVGLDEMO_THEME_1
diff --git a/examples/lvgldemo/demo.h b/examples/lvgldemo/demo.h
index 37251d1..18e9050 100644
--- a/examples/lvgldemo/demo.h
+++ b/examples/lvgldemo/demo.h
@@ -50,6 +50,12 @@
# define LV_DEMO_WALLPAPER 0
#endif
+#ifdef CONFIG_EXAMPLES_LVGLDEMO_SLIDE_SHOW
+# define LV_DEMO_SLIDE_SHOW 1
+#else
+# define LV_DEMO_SLIDE_SHOW 0
+#endif
+
/****************************************************************************
* Public Function Prototypes
****************************************************************************/
diff --git a/examples/lvgldemo/lv_test_theme_1.c b/examples/lvgldemo/lv_test_theme_1.c
index 8aefb4f..cd8fec6 100644
--- a/examples/lvgldemo/lv_test_theme_1.c
+++ b/examples/lvgldemo/lv_test_theme_1.c
@@ -83,183 +83,164 @@ static void create_tab3(FAR lv_obj_t *parent);
*
****************************************************************************/
-static void create_tab1(FAR lv_obj_t *parent)
+static void create_tab1(lv_obj_t * parent)
{
- FAR lv_theme_t *th;
- FAR lv_obj_t *h;
- FAR lv_obj_t *btn;
- FAR lv_obj_t *btn_label;
- FAR lv_obj_t *label;
- FAR lv_obj_t *btnm;
- FAR lv_obj_t *table;
- FAR lv_obj_t *sw_h;
- FAR lv_obj_t *sw;
- FAR lv_obj_t *bar;
- FAR lv_obj_t *slider;
- FAR lv_obj_t *line;
- FAR lv_obj_t *cb;
- FAR lv_obj_t *list_btn;
- FAR lv_obj_t *list;
- FAR lv_obj_t *roller;
-
- static lv_style_t h_style;
- static const char *btnm_str[] =
- {
- "1", "2", "3", SYMBOL_OK, SYMBOL_CLOSE, ""
- };
-
- static const lv_point_t line_p[] =
- {
- { 0, 0 }, { LV_HOR_RES / 5, 0 }
- };
-
- lv_page_set_scrl_layout(parent, LV_LAYOUT_PRETTY);
-
- th = lv_theme_get_current();
-
- lv_style_copy(&h_style, &lv_style_transp);
- h_style.body.padding.inner = LV_DPI / 4;
- h_style.body.padding.hor = LV_DPI / 4;
- h_style.body.padding.ver = LV_DPI / 6;
-
- h = lv_cont_create(parent, NULL);
- lv_obj_set_style(h, &h_style);
- lv_obj_set_click(h, false);
- lv_cont_set_fit(h, true, true);
- lv_cont_set_layout(h, LV_LAYOUT_COL_M);
-
- btn = lv_btn_create(h, NULL);
- lv_btn_set_style(btn, LV_BTN_STYLE_REL, th->btn.rel);
- lv_btn_set_style(btn, LV_BTN_STYLE_PR, th->btn.pr);
- lv_btn_set_style(btn, LV_BTN_STYLE_TGL_REL, th->btn.tgl_rel);
- lv_btn_set_style(btn, LV_BTN_STYLE_TGL_PR, th->btn.tgl_pr);
- lv_btn_set_style(btn, LV_BTN_STYLE_INA, th->btn.ina);
- lv_btn_set_fit(btn, true, true);
- lv_btn_set_toggle(btn, true);
-
- btn_label = lv_label_create(btn, NULL);
- lv_label_set_text(btn_label, "Button");
-
- btn = lv_btn_create(h, btn);
- lv_btn_toggle(btn);
- btn_label = lv_label_create(btn, NULL);
- lv_label_set_text(btn_label, "Toggled");
-
- btn = lv_btn_create(h, btn);
- lv_btn_set_state(btn, LV_BTN_STATE_INA);
- btn_label = lv_label_create(btn, NULL);
- lv_label_set_text(btn_label, "Inactive");
-
- label = lv_label_create(h, NULL);
- lv_label_set_text(label, "Primary");
- lv_obj_set_style(label, th->label.prim);
-
- label = lv_label_create(h, NULL);
- lv_label_set_text(label, "Secondary");
- lv_obj_set_style(label, th->label.sec);
-
- label = lv_label_create(h, NULL);
- lv_label_set_text(label, "Hint");
- lv_obj_set_style(label, th->label.hint);
-
- btnm = lv_btnm_create(h, NULL);
- lv_obj_set_size(btnm, LV_HOR_RES / 4, 2 * LV_DPI / 3);
- lv_btnm_set_map(btnm, btnm_str);
- lv_btnm_set_toggle(btnm, true, 3);
-
-#if LVGL_VERSION_MAJOR == 5 && LVGL_VERSION_MINOR >= 3
- table = lv_table_create(h, NULL);
- lv_table_set_col_cnt(table, 3);
- lv_table_set_row_cnt(table, 4);
- lv_table_set_col_width(table, 0, LV_DPI / 3);
- lv_table_set_col_width(table, 1, LV_DPI / 2);
- lv_table_set_col_width(table, 2, LV_DPI / 2);
- lv_table_set_cell_merge_right(table, 0, 0, true);
- lv_table_set_cell_merge_right(table, 0, 1, true);
-
- lv_table_set_cell_value(table, 0, 0, "Table");
- lv_table_set_cell_align(table, 0, 0, LV_LABEL_ALIGN_CENTER);
-
- lv_table_set_cell_value(table, 1, 0, "1");
- lv_table_set_cell_value(table, 1, 1, "13");
- lv_table_set_cell_align(table, 1, 1, LV_LABEL_ALIGN_RIGHT);
- lv_table_set_cell_value(table, 1, 2, "ms");
-
- lv_table_set_cell_value(table, 2, 0, "2");
- lv_table_set_cell_value(table, 2, 1, "46");
- lv_table_set_cell_align(table, 2, 1, LV_LABEL_ALIGN_RIGHT);
- lv_table_set_cell_value(table, 2, 2, "ms");
-
- lv_table_set_cell_value(table, 3, 0, "3");
- lv_table_set_cell_value(table, 3, 1, "61");
- lv_table_set_cell_align(table, 3, 1, LV_LABEL_ALIGN_RIGHT);
- lv_table_set_cell_value(table, 3, 2, "ms");
-#endif
-
- h = lv_cont_create(parent, h);
-
- sw_h = lv_cont_create(h, NULL);
- lv_cont_set_style(sw_h, &lv_style_transp);
- lv_cont_set_fit(sw_h, false, true);
- lv_obj_set_width(sw_h, LV_HOR_RES / 4);
- lv_cont_set_layout(sw_h, LV_LAYOUT_PRETTY);
-
- sw = lv_sw_create(sw_h, NULL);
-#if LVGL_VERSION_MAJOR == 5 && LVGL_VERSION_MINOR >= 3
- lv_sw_set_anim_time(sw, 250);
-#endif
-
- sw = lv_sw_create(sw_h, sw);
- lv_sw_on(sw);
-
- bar = lv_bar_create(h, NULL);
- lv_bar_set_value(bar, 70);
-
- slider = lv_slider_create(h, NULL);
- lv_bar_set_value(slider, 70);
-
- line = lv_line_create(h, NULL);
- lv_line_set_points(line, line_p, 2);
- lv_line_set_style(line, th->line.decor);
-
- cb = lv_cb_create(h, NULL);
-
- cb = lv_cb_create(h, cb);
- lv_btn_set_state(cb, LV_BTN_STATE_TGL_REL);
-
- lv_obj_t * ddlist = lv_ddlist_create(h, NULL);
- lv_ddlist_open(ddlist, false);
- lv_ddlist_set_selected(ddlist, 1);
-
- h = lv_cont_create(parent, h);
-
- list = lv_list_create(h, NULL);
- list_btn = lv_list_add(list, SYMBOL_GPS, "GPS", NULL);
- lv_obj_set_size(list, LV_HOR_RES / 4, LV_VER_RES / 2);
- lv_btn_set_toggle(list_btn, true);
- lv_list_add(list, SYMBOL_WIFI, "WiFi", NULL);
- lv_list_add(list, SYMBOL_GPS, "GPS", NULL);
- lv_list_add(list, SYMBOL_AUDIO, "Audio", NULL);
- lv_list_add(list, SYMBOL_VIDEO, "Video", NULL);
- lv_list_add(list, SYMBOL_CALL, "Call", NULL);
- lv_list_add(list, SYMBOL_BELL, "Bell", NULL);
- lv_list_add(list, SYMBOL_FILE, "File", NULL);
- lv_list_add(list, SYMBOL_EDIT, "Edit", NULL);
- lv_list_add(list, SYMBOL_CUT, "Cut", NULL);
- lv_list_add(list, SYMBOL_COPY, "Copy", NULL);
-
- roller = lv_roller_create(h, NULL);
- lv_roller_set_options(roller,
- "Monday\n"
- "Tuesday\n"
- "Wednesday\n"
- "Thursday\n"
- "Friday\n"
- "Saturday\n"
- "Sunday");
-
- lv_roller_set_selected(roller, 1, false);
- lv_roller_set_visible_row_count(roller, 3);
+ lv_page_set_scrl_layout(parent, LV_LAYOUT_PRETTY);
+
+ lv_theme_t * th = lv_theme_get_current();
+
+ static lv_style_t h_style;
+ lv_style_copy(&h_style, &lv_style_transp);
+ h_style.body.padding.inner = LV_DPI / 10;
+ h_style.body.padding.left = LV_DPI / 4;
+ h_style.body.padding.right = LV_DPI / 4;
+ h_style.body.padding.top = LV_DPI / 10;
+ h_style.body.padding.bottom = LV_DPI / 10;
+
+ lv_obj_t * h = lv_cont_create(parent, NULL);
+ lv_obj_set_style(h, &h_style);
+ lv_obj_set_click(h, false);
+ lv_cont_set_fit(h, LV_FIT_TIGHT);
+ lv_cont_set_layout(h, LV_LAYOUT_COL_M);
+
+ lv_obj_t * btn = lv_btn_create(h, NULL);
+ lv_btn_set_fit(btn, LV_FIT_TIGHT);
+ lv_btn_set_toggle(btn, true);
+ lv_obj_t * btn_label = lv_label_create(btn, NULL);
+ lv_label_set_text(btn_label, "Button");
+
+ btn = lv_btn_create(h, btn);
+ lv_btn_toggle(btn);
+ btn_label = lv_label_create(btn, NULL);
+ lv_label_set_text(btn_label, "Toggled");
+
+ btn = lv_btn_create(h, btn);
+ lv_btn_set_state(btn, LV_BTN_STATE_INA);
+ btn_label = lv_label_create(btn, NULL);
+ lv_label_set_text(btn_label, "Inactive");
+
+ lv_obj_t * label = lv_label_create(h, NULL);
+ lv_label_set_text(label, "Primary");
+ lv_obj_set_style(label, th->style.label.prim);
+
+ label = lv_label_create(h, NULL);
+ lv_label_set_text(label, "Secondary");
+ lv_obj_set_style(label, th->style.label.sec);
+
+ label = lv_label_create(h, NULL);
+ lv_label_set_text(label, "Hint");
+ lv_obj_set_style(label, th->style.label.hint);
+
+ static const char * btnm_str[] =
+ {
+ "1", "2", "3", LV_SYMBOL_OK, LV_SYMBOL_CLOSE, ""
+ };
+
+ lv_obj_t * btnm = lv_btnm_create(h, NULL);
+ lv_obj_set_size(btnm, lv_disp_get_hor_res(NULL) / 4, 2 * LV_DPI / 3);
+ lv_btnm_set_map(btnm, btnm_str);
+ lv_btnm_set_btn_ctrl_all(btnm, LV_BTNM_CTRL_TGL_ENABLE);
+ lv_btnm_set_one_toggle(btnm, true);
+
+ lv_obj_t * table = lv_table_create(h, NULL);
+ lv_table_set_col_cnt(table, 3);
+ lv_table_set_row_cnt(table, 4);
+ lv_table_set_col_width(table, 0, LV_DPI / 3);
+ lv_table_set_col_width(table, 1, LV_DPI / 2);
+ lv_table_set_col_width(table, 2, LV_DPI / 2);
+ lv_table_set_cell_merge_right(table, 0, 0, true);
+ lv_table_set_cell_merge_right(table, 0, 1, true);
+
+ lv_table_set_cell_value(table, 0, 0, "Table");
+ lv_table_set_cell_align(table, 0, 0, LV_LABEL_ALIGN_CENTER);
+
+ lv_table_set_cell_value(table, 1, 0, "1");
+ lv_table_set_cell_value(table, 1, 1, "13");
+ lv_table_set_cell_align(table, 1, 1, LV_LABEL_ALIGN_RIGHT);
+ lv_table_set_cell_value(table, 1, 2, "ms");
+
+ lv_table_set_cell_value(table, 2, 0, "2");
+ lv_table_set_cell_value(table, 2, 1, "46");
+ lv_table_set_cell_align(table, 2, 1, LV_LABEL_ALIGN_RIGHT);
+ lv_table_set_cell_value(table, 2, 2, "ms");
+
+ lv_table_set_cell_value(table, 3, 0, "3");
+ lv_table_set_cell_value(table, 3, 1, "61");
+ lv_table_set_cell_align(table, 3, 1, LV_LABEL_ALIGN_RIGHT);
+ lv_table_set_cell_value(table, 3, 2, "ms");
+
+ h = lv_cont_create(parent, h);
+
+ lv_obj_t * sw_h = lv_cont_create(h, NULL);
+ lv_cont_set_style(sw_h, LV_CONT_STYLE_MAIN, &lv_style_transp);
+ lv_cont_set_fit2(sw_h, LV_FIT_NONE, LV_FIT_TIGHT);
+ lv_obj_set_width(sw_h, LV_HOR_RES / 4);
+ lv_cont_set_layout(sw_h, LV_LAYOUT_PRETTY);
+
+ lv_obj_t * sw = lv_sw_create(sw_h, NULL);
+ lv_sw_set_anim_time(sw, 250);
+
+ sw = lv_sw_create(sw_h, sw);
+ lv_sw_on(sw, LV_ANIM_OFF);
+
+ lv_obj_t * bar = lv_bar_create(h, NULL);
+ lv_bar_set_value(bar, 70, false);
+
+ lv_obj_t * slider = lv_slider_create(h, NULL);
+ lv_bar_set_value(slider, 70, false);
+
+ lv_obj_t * line = lv_line_create(h, NULL);
+ static lv_point_t line_p[2];
+ line_p[0].x = 0;
+ line_p[0].y = 0;
+ line_p[1].x = lv_disp_get_hor_res(NULL) / 5;
+ line_p[1].y = 0;
+
+ lv_line_set_points(line, line_p, 2);
+ lv_line_set_style(line, LV_LINE_STYLE_MAIN, th->style.line.decor);
+
+ lv_obj_t * cb = lv_cb_create(h, NULL);
+
+ cb = lv_cb_create(h, cb);
+ lv_btn_set_state(cb, LV_BTN_STATE_TGL_REL);
+
+ lv_obj_t * ddlist = lv_ddlist_create(h, NULL);
+ lv_ddlist_set_fix_width(ddlist, lv_obj_get_width(ddlist) + LV_DPI / 2);
+ lv_ddlist_set_draw_arrow(ddlist, true);
+
+ h = lv_cont_create(parent, h);
+
+ lv_obj_t * list = lv_list_create(h, NULL);
+ lv_obj_set_size(list,
+ lv_disp_get_hor_res(NULL) / 4,
+ lv_disp_get_ver_res(NULL) / 2);
+ lv_obj_t * list_btn;
+ list_btn = lv_list_add_btn(list, LV_SYMBOL_GPS, "GPS");
+ lv_btn_set_toggle(list_btn, true);
+
+ lv_list_add_btn(list, LV_SYMBOL_WIFI, "WiFi");
+ lv_list_add_btn(list, LV_SYMBOL_GPS, "GPS");
+ lv_list_add_btn(list, LV_SYMBOL_AUDIO, "Audio");
+ lv_list_add_btn(list, LV_SYMBOL_VIDEO, "Video");
+ lv_list_add_btn(list, LV_SYMBOL_CALL, "Call");
+ lv_list_add_btn(list, LV_SYMBOL_BELL, "Bell");
+ lv_list_add_btn(list, LV_SYMBOL_FILE, "File");
+ lv_list_add_btn(list, LV_SYMBOL_EDIT, "Edit");
+ lv_list_add_btn(list, LV_SYMBOL_CUT, "Cut");
+ lv_list_add_btn(list, LV_SYMBOL_COPY, "Copy");
+
+ lv_obj_t * roller = lv_roller_create(h, NULL);
+ lv_roller_set_options(roller,
+ "Monday\n"
+ "Tuesday\n"
+ "Wednesday\n"
+ "Thursday\n"
+ "Friday\n"
+ "Saturday\n"
+ "Sunday",
+ true);
+ lv_roller_set_selected(roller, 1, false);
+ lv_roller_set_visible_row_count(roller, 3);
}
/****************************************************************************
@@ -280,56 +261,45 @@ static void create_tab1(FAR lv_obj_t *parent)
static void create_tab2(lv_obj_t * parent)
{
- lv_coord_t w;
- lv_obj_t *chart;
- lv_chart_series_t *s1;
- lv_obj_t *gauge;
- lv_obj_t *arc;
- lv_obj_t *ta;
- lv_obj_t *kb;
-#if USE_LV_ANIMATION
- lv_obj_t *loader;
-#endif
-
- w = lv_page_get_scrl_width(parent);
-
- chart = lv_chart_create(parent, NULL);
- lv_obj_set_size(chart, w / 3, LV_VER_RES / 3);
- lv_obj_set_pos(chart, LV_DPI / 10, LV_DPI / 10);
-
- s1 = lv_chart_add_series(chart, LV_COLOR_RED);
- lv_chart_set_next(chart, s1, 30);
- lv_chart_set_next(chart, s1, 20);
- lv_chart_set_next(chart, s1, 10);
- lv_chart_set_next(chart, s1, 12);
- lv_chart_set_next(chart, s1, 20);
- lv_chart_set_next(chart, s1, 27);
- lv_chart_set_next(chart, s1, 35);
- lv_chart_set_next(chart, s1, 55);
- lv_chart_set_next(chart, s1, 70);
- lv_chart_set_next(chart, s1, 75);
-
- gauge = lv_gauge_create(parent, NULL);
- lv_gauge_set_value(gauge, 0, 40);
- lv_obj_set_size(gauge, w / 4, w / 4);
- lv_obj_align(gauge, chart, LV_ALIGN_OUT_BOTTOM_LEFT, 0, LV_DPI / 4);
-
- arc = lv_arc_create(parent, NULL);
- lv_obj_align(arc, gauge, LV_ALIGN_OUT_BOTTOM_MID, 0, LV_DPI / 8);
-
- ta = lv_ta_create(parent, NULL);
- lv_obj_set_size(ta, w / 3, LV_VER_RES / 4);
- lv_obj_align(ta, NULL, LV_ALIGN_IN_TOP_RIGHT, -LV_DPI / 10, LV_DPI / 10);
- lv_ta_set_cursor_type(ta, LV_CURSOR_BLOCK);
-
- kb = lv_kb_create(parent, NULL);
- lv_obj_set_size(kb, 2 * w / 3, LV_VER_RES / 3);
- lv_obj_align(kb, ta, LV_ALIGN_OUT_BOTTOM_RIGHT, 0, LV_DPI);
- lv_kb_set_ta(kb, ta);
-
-#if USE_LV_ANIMATION
- loader = lv_preload_create(parent, NULL);
- lv_obj_align(loader, NULL, LV_ALIGN_CENTER, 0, -LV_DPI);
+ lv_coord_t w = lv_page_get_scrl_width(parent);
+
+ lv_obj_t * chart = lv_chart_create(parent, NULL);
+ lv_chart_set_type(chart, LV_CHART_TYPE_AREA);
+ lv_obj_set_size(chart, w / 3, lv_disp_get_ver_res(NULL) / 3);
+ lv_obj_set_pos(chart, LV_DPI / 10, LV_DPI / 10);
+ lv_chart_series_t * s1 = lv_chart_add_series(chart, LV_COLOR_RED);
+ lv_chart_set_next(chart, s1, 30);
+ lv_chart_set_next(chart, s1, 20);
+ lv_chart_set_next(chart, s1, 10);
+ lv_chart_set_next(chart, s1, 12);
+ lv_chart_set_next(chart, s1, 20);
+ lv_chart_set_next(chart, s1, 27);
+ lv_chart_set_next(chart, s1, 35);
+ lv_chart_set_next(chart, s1, 55);
+ lv_chart_set_next(chart, s1, 70);
+ lv_chart_set_next(chart, s1, 75);
+
+ lv_obj_t * gauge = lv_gauge_create(parent, NULL);
+ lv_gauge_set_value(gauge, 0, 40);
+ lv_obj_set_size(gauge, w / 4, w / 4);
+ lv_obj_align(gauge, chart, LV_ALIGN_OUT_BOTTOM_LEFT, 0, LV_DPI / 4);
+
+ lv_obj_t * arc = lv_arc_create(parent, NULL);
+ lv_obj_align(arc, gauge, LV_ALIGN_OUT_BOTTOM_MID, 0, LV_DPI / 8);
+
+ lv_obj_t * ta = lv_ta_create(parent, NULL);
+ lv_obj_set_size(ta, w / 3, lv_disp_get_ver_res(NULL) / 4);
+ lv_obj_align(ta, NULL, LV_ALIGN_IN_TOP_RIGHT, -LV_DPI / 10, LV_DPI / 10);
+ lv_ta_set_cursor_type(ta, LV_CURSOR_BLOCK);
+
+ lv_obj_t * kb = lv_kb_create(parent, NULL);
+ lv_obj_set_size(kb, 2 * w / 3, lv_disp_get_ver_res(NULL) / 3);
+ lv_obj_align(kb, ta, LV_ALIGN_OUT_BOTTOM_RIGHT, 0, LV_DPI);
+ lv_kb_set_ta(kb, ta);
+
+#if LV_USE_ANIMATION
+ lv_obj_t * loader = lv_preload_create(parent, NULL);
+ lv_obj_align(loader, NULL, LV_ALIGN_CENTER, 0, - LV_DPI);
#endif
}
@@ -351,89 +321,82 @@ static void create_tab2(lv_obj_t * parent)
static void create_tab3(lv_obj_t *parent)
{
- FAR lv_obj_t *win;
- FAR lv_obj_t *label;
- FAR lv_obj_t *lmeter;
- FAR lv_obj_t *led1;
- FAR lv_obj_t *led2;
- FAR lv_obj_t *page;
- FAR lv_obj_t *cal;
- FAR lv_obj_t *mbox;
-
- static lv_calendar_date_t highlighted_days[2];
-
- static const char *mbox_btn_map[] =
- {
- "\211", "\222Got it!", "\211", ""
- };
-
/* Create a Window */
- win = lv_win_create(parent, NULL);
-
- lv_win_add_btn(win, SYMBOL_CLOSE, lv_win_close_action);
- lv_win_add_btn(win, SYMBOL_DOWN, NULL);
- lv_obj_set_size(win, LV_HOR_RES / 2, LV_VER_RES / 2);
+ lv_obj_t *win = lv_win_create(parent, NULL);
+ lv_obj_t *win_btn = lv_win_add_btn(win, LV_SYMBOL_CLOSE);
+ lv_obj_set_event_cb(win_btn, lv_win_close_event_cb);
+ lv_win_add_btn(win, LV_SYMBOL_DOWN);
+ lv_obj_set_size(win, lv_disp_get_hor_res(NULL) / 2,
+ lv_disp_get_ver_res(NULL) / 2);
lv_obj_set_pos(win, LV_DPI / 20, LV_DPI / 20);
lv_obj_set_top(win, true);
/* Create a Label in the Window */
- label = lv_label_create(win, NULL);
+ lv_obj_t *label = lv_label_create(win, NULL);
lv_label_set_text(label, "Label in the window");
- /* Create a Line meter in the Window */
+ /* Create a Line meter in the Window */
- lmeter = lv_lmeter_create(win, NULL);
+ lv_obj_t *lmeter = lv_lmeter_create(win, NULL);
lv_obj_align(lmeter, label, LV_ALIGN_OUT_BOTTOM_LEFT, 0, LV_DPI / 2);
lv_lmeter_set_value(lmeter, 70);
- /* Create 2 LEDs in the Window */
+ /* Create a 2 LEDs in the Window */
- led1 = lv_led_create(win, NULL);
+ lv_obj_t *led1 = lv_led_create(win, NULL);
lv_obj_align(led1, lmeter, LV_ALIGN_OUT_RIGHT_MID, LV_DPI / 2, 0);
lv_led_on(led1);
- led2 = lv_led_create(win, NULL);
+ lv_obj_t *led2 = lv_led_create(win, NULL);
lv_obj_align(led2, led1, LV_ALIGN_OUT_RIGHT_MID, LV_DPI / 2, 0);
lv_led_off(led2);
/* Create a Page */
- page = lv_page_create(parent, NULL);
- lv_obj_set_size(page, LV_HOR_RES / 3, LV_VER_RES / 2);
+ lv_obj_t *page = lv_page_create(parent, NULL);
+ lv_obj_set_size(page, lv_disp_get_hor_res(NULL) / 3,
+ lv_disp_get_ver_res(NULL) / 2);
lv_obj_set_top(page, true);
- lv_obj_align(page, win, LV_ALIGN_IN_TOP_RIGHT, LV_DPI, LV_DPI);
+ lv_obj_align(page, win, LV_ALIGN_IN_TOP_RIGHT, LV_DPI, LV_DPI);
label = lv_label_create(page, NULL);
lv_label_set_text(label,
- "Lorem ipsum dolor sit amet, repudiare voluptatibus pri cu.\n"
- "Ei mundi pertinax posidonium eum, cum tempor maiorum at,\n"
- "mea fuisset assentior ad. Usu cu suas civibus iudicabit.\n"
- "Eum eu congue tempor facilisi. Tale hinc unum te vim.\n"
- "Te cum populo animal eruditi, labitur inciderint at nec.\n\n"
- "Eius corpora et quo. Everti voluptaria instructior est id,\n"
- "vel in falli primis. Mea ei porro essent admodum,\n"
- "his ei malis quodsi, te quis aeterno his.\n"
- "Qui tritani recusabo reprehendunt ne,\n"
- "per duis explicari at. Simul mediocritatem mei et.");
-
- lv_page_set_scrl_fit(page, true, true);
+ "Lorem ipsum dolor sit amet, "
+ "repudiare voluptatibus pri cu.\n"
+ "Ei mundi pertinax posidonium eum,"
+ " cum tempor maiorum at,\n"
+ "mea fuisset assentior ad. "
+ "Usu cu suas civibus iudicabit.\n"
+ "Eum eu congue tempor facilisi. "
+ "Tale hinc unum te vim.\n"
+ "Te cum populo animal eruditi,"
+ "labitur inciderint at nec.\n\n"
+ "Eius corpora et quo. Everti"
+ "voluptaria instructior est id,\n"
+ "vel in falli primis."
+ "Mea ei porro essent admodum,\n"
+ "his ei malis quodsi, te quis aeterno his.\n"
+ "Qui tritani recusabo reprehendunt ne,\n"
+ "per duis explicari at."
+ " Simul mediocritatem mei et.");
/* Create a Calendar */
- cal = lv_calendar_create(parent, NULL);
+ lv_obj_t *cal = lv_calendar_create(parent, NULL);
lv_obj_set_size(cal, 5 * LV_DPI / 2, 5 * LV_DPI / 2);
lv_obj_align(cal, page, LV_ALIGN_OUT_RIGHT_TOP, -LV_DPI / 2, LV_DPI / 3);
lv_obj_set_top(cal, true);
- highlighted_days[0].day = 5;
+ static lv_calendar_date_t highlighted_days[2];
+ highlighted_days[0].day = 5;
highlighted_days[0].month = 5;
- highlighted_days[0].year = 2019;
+ highlighted_days[0].year = 2018;
- highlighted_days[1].day = 8;
+ highlighted_days[1].day = 8;
highlighted_days[1].month = 5;
- highlighted_days[1].year = 2019;
+ highlighted_days[1].year = 2018;
lv_calendar_set_highlighted_dates(cal, highlighted_days, 2);
lv_calendar_set_today_date(cal, &highlighted_days[0]);
@@ -441,10 +404,19 @@ static void create_tab3(lv_obj_t *parent)
/* Create a Message box */
- mbox = lv_mbox_create(parent, NULL);
+ static const char *mbox_btn_map[] =
+ {
+ " ", "Got it!", " ", ""
+ };
+
+ lv_obj_t *mbox = lv_mbox_create(parent, NULL);
lv_mbox_set_text(mbox,
- "Click on the window or the page to bring it to the foreground");
- lv_mbox_add_btns(mbox, mbox_btn_map, NULL);
+ "Click on the window or the page"
+ " to bring it to the foreground");
+ lv_mbox_add_btns(mbox, mbox_btn_map);
+ lv_btnm_set_btn_ctrl(lv_mbox_get_btnm(mbox), 0, LV_BTNM_CTRL_HIDDEN);
+ lv_btnm_set_btn_width(lv_mbox_get_btnm(mbox), 1, 7);
+ lv_btnm_set_btn_ctrl(lv_mbox_get_btnm(mbox), 2, LV_BTNM_CTRL_HIDDEN);
lv_obj_set_top(mbox, true);
}
@@ -456,7 +428,8 @@ static void create_tab3(lv_obj_t *parent)
* Name: lv_test_theme_1
*
* Description:
- * Create a test screen with a lot objects and apply the given theme on them
+ * Create a test screen with a lot objects and apply
+ * the given theme on them
*
* Input Parameters:
* th - pointer to a theme
@@ -469,32 +442,22 @@ static void create_tab3(lv_obj_t *parent)
*
****************************************************************************/
-void lv_test_theme_1(lv_theme_t *th)
+void lv_test_theme_1(lv_theme_t * th)
{
- FAR lv_obj_t *scr;
- FAR lv_obj_t *tv;
- FAR lv_obj_t *tab1;
- FAR lv_obj_t *tab2;
- FAR lv_obj_t *tab3;
-
lv_theme_set_current(th);
- /* If `LV_THEME_LIVE_UPDATE 1` `th` is not used directly so get the real
- * theme after set
- */
+ /* If `LV_THEME_LIVE_UPDATE 1` `th` is not used directly so get the real theme after set */
th = lv_theme_get_current();
-
- scr = lv_cont_create(NULL, NULL);
- lv_scr_load(scr);
- lv_cont_set_style(scr, th->bg);
-
- tv = lv_tabview_create(scr, NULL);
- lv_obj_set_size(tv, LV_HOR_RES, LV_VER_RES);
-
- tab1 = lv_tabview_add_tab(tv, "Tab 1");
- tab2 = lv_tabview_add_tab(tv, "Tab 2");
- tab3 = lv_tabview_add_tab(tv, "Tab 3");
+ FAR lv_obj_t * scr = lv_cont_create(NULL, NULL);
+ lv_disp_load_scr(scr);
+
+ FAR lv_obj_t * tv = lv_tabview_create(scr, NULL);
+ lv_obj_set_size(tv, lv_disp_get_hor_res(NULL),
+ lv_disp_get_ver_res(NULL));
+ FAR lv_obj_t * tab1 = lv_tabview_add_tab(tv, "Tab 1");
+ FAR lv_obj_t * tab2 = lv_tabview_add_tab(tv, "Tab 2");
+ FAR lv_obj_t * tab3 = lv_tabview_add_tab(tv, "Tab 3");
create_tab1(tab1);
create_tab2(tab2);
diff --git a/examples/lvgldemo/lv_test_theme_2.c b/examples/lvgldemo/lv_test_theme_2.c
index 29022a0..bcc016c 100644
--- a/examples/lvgldemo/lv_test_theme_2.c
+++ b/examples/lvgldemo/lv_test_theme_2.c
@@ -36,7 +36,6 @@
#include <graphics/lvgl.h>
#include "lv_test_theme_2.h"
-#include "lv_misc/lv_math.h"
#ifdef CONFIG_EXAMPLES_LVGLDEMO_THEME_2
@@ -55,9 +54,10 @@
static void header_create(void);
static void sb_create(void);
static void content_create(void);
-static lv_res_t theme_select_action(lv_obj_t *roller);
-static lv_res_t hue_select_action(lv_obj_t *roller);
+static void theme_select_event_handler(lv_obj_t *roller, lv_event_t event);
+static void hue_select_event_cb(lv_obj_t *roller, lv_event_t event);
static void init_all_themes(uint16_t hue);
+static void bar_set_value(lv_obj_t *bar, int16_t value);
/****************************************************************************
* Private Data
@@ -68,26 +68,27 @@ static lv_obj_t *sb;
static lv_obj_t *content;
static lv_theme_t *th_act;
-static const char *th_options = {
-#if USE_LV_THEME_NIGHT
+static const char *th_options =
+{
+#if LV_USE_THEME_NIGHT
"Night"
#endif
-#if USE_LV_THEME_MATERIAL
+#if LV_USE_THEME_MATERIAL
"\nMaterial"
#endif
-#if USE_LV_THEME_ALIEN
+#if LV_USE_THEME_ALIEN
"\nAlien"
#endif
-#if USE_LV_THEME_ZEN
+#if LV_USE_THEME_ZEN
"\nZen"
#endif
-#if USE_LV_THEME_NEMO
+#if LV_USE_THEME_NEMO
"\nNemo"
#endif
-#if USE_LV_THEME_MONO
+#if LV_USE_THEME_MONO
"\nMono"
#endif
-#if USE_LV_THEME_DEFAULT
+#if LV_USE_THEME_DEFAULT
"\nDefault"
#endif
""
@@ -121,34 +122,22 @@ static lv_theme_t *themes[8];
static void header_create(void)
{
- lv_obj_t *sym;
- lv_obj_t *clock;
-
- /* Create the global header object */
-
- header = lv_cont_create(lv_scr_act(), NULL);
- lv_obj_set_width(header, LV_HOR_RES);
+ header = lv_cont_create(lv_disp_get_scr_act(NULL), NULL);
+ lv_obj_set_width(header, lv_disp_get_hor_res(NULL));
- /* Add a few symbols */
-
- sym = lv_label_create(header, NULL);
+ lv_obj_t *sym = lv_label_create(header, NULL);
lv_label_set_text(sym,
- SYMBOL_GPS " "
- SYMBOL_WIFI " "
- SYMBOL_BLUETOOTH " "
- SYMBOL_VOLUME_MAX);
-
+ LV_SYMBOL_GPS
+ LV_SYMBOL_WIFI
+ LV_SYMBOL_BLUETOOTH
+ LV_SYMBOL_VOLUME_MAX);
lv_obj_align(sym, NULL, LV_ALIGN_IN_RIGHT_MID, -LV_DPI / 10, 0);
- /* Create a fake clock */
-
- clock = lv_label_create(header, NULL);
+ lv_obj_t *clock = lv_label_create(header, NULL);
lv_label_set_text(clock, "14:21");
lv_obj_align(clock, NULL, LV_ALIGN_IN_LEFT_MID, LV_DPI / 10, 0);
- /* Let the height set automatically */
-
- lv_cont_set_fit(header, false, true);
+ lv_cont_set_fit2(header, LV_FIT_NONE, LV_FIT_TIGHT);
lv_obj_set_pos(header, 0, 0);
}
@@ -170,42 +159,42 @@ static void header_create(void)
static void sb_create(void)
{
- lv_obj_t *th_label;
- lv_obj_t *th_roller;
- lv_obj_t *hue_label;
- lv_obj_t *hue_roller;
+ lv_coord_t hres = lv_disp_get_hor_res(NULL);
+ lv_coord_t vres = lv_disp_get_ver_res(NULL);
- sb = lv_page_create(lv_scr_act(), NULL);
+ sb = lv_page_create(lv_disp_get_scr_act(NULL), NULL);
lv_page_set_scrl_layout(sb, LV_LAYOUT_COL_M);
lv_page_set_style(sb, LV_PAGE_STYLE_BG, &lv_style_transp_tight);
lv_page_set_style(sb, LV_PAGE_STYLE_SCRL, &lv_style_transp);
- th_label = lv_label_create(sb, NULL);
+ lv_obj_t *th_label = lv_label_create(sb, NULL);
lv_label_set_text(th_label, "Theme");
- th_roller = lv_roller_create(sb, NULL);
- lv_roller_set_options(th_roller, th_options);
- lv_roller_set_action(th_roller, theme_select_action);
+ lv_obj_t *th_roller = lv_roller_create(sb, NULL);
+ lv_roller_set_options(th_roller, th_options, true);
+ lv_obj_set_event_cb(th_roller, theme_select_event_handler);
- hue_label = lv_label_create(sb, NULL);
+ lv_obj_t *hue_label = lv_label_create(sb, NULL);
lv_label_set_text(hue_label, "\nColor");
- hue_roller = lv_roller_create(sb, NULL);
- lv_roller_set_options(hue_roller,
- "0\n30\n60\n90\n120\n150\n180\n210\n240\n270\n300\n330");
- lv_roller_set_action(hue_roller, hue_select_action);
-
-#if LV_HOR_RES > LV_VER_RES
- lv_obj_set_height(sb, LV_VER_RES - lv_obj_get_height(header));
- lv_cont_set_fit(sb, true, false);
- lv_page_set_scrl_fit(sb, true, false);
- lv_obj_align(sb, header, LV_ALIGN_OUT_BOTTOM_LEFT, 0, 0);
- lv_page_set_sb_mode(sb, LV_SB_MODE_DRAG);
-#else
- lv_obj_set_size(sb, LV_HOR_RES, LV_VER_RES / 2 - lv_obj_get_height(header));
- lv_obj_align(sb, header, LV_ALIGN_OUT_BOTTOM_LEFT, 0, 0);
- lv_page_set_sb_mode(sb, LV_SB_MODE_AUTO);
-#endif
+ lv_obj_t *hue_roller = lv_roller_create(sb, NULL);
+ lv_roller_set_options(hue_roller, "0\n30\n60\n90\n120\n150\n"
+ "180\n210\n240\n270\n300\n330", true);
+ lv_obj_set_event_cb(hue_roller, hue_select_event_cb);
+
+ if (hres > vres)
+ {
+ lv_obj_set_height(sb, vres - lv_obj_get_height(header));
+ lv_cont_set_fit2(sb, LV_FIT_TIGHT, LV_FIT_NONE);
+ lv_obj_align(sb, header, LV_ALIGN_OUT_BOTTOM_LEFT, 0, 0);
+ lv_page_set_sb_mode(sb, LV_SB_MODE_DRAG);
+ }
+ else
+ {
+ lv_obj_set_size(sb, hres, vres / 2 - lv_obj_get_height(header));
+ lv_obj_align(sb, header, LV_ALIGN_OUT_BOTTOM_LEFT, 0, 0);
+ lv_page_set_sb_mode(sb, LV_SB_MODE_AUTO);
+ }
}
/****************************************************************************
@@ -227,67 +216,44 @@ static void sb_create(void)
static void content_create(void)
{
- FAR lv_obj_t *btn;
- FAR lv_obj_t *label;
- FAR lv_obj_t *sw;
- FAR lv_obj_t *bar;
- FAR lv_obj_t *slider;
- FAR lv_obj_t *lmeter;
- FAR lv_obj_t *gauge;
- FAR lv_obj_t *ta;
- FAR lv_obj_t *ddlist;
- FAR lv_obj_t *kb;
- FAR lv_obj_t *mbox;
- FAR lv_obj_t *roller;
-
- lv_coord_t max_w;
-
- lv_anim_t a;
-
- static const char *nums = "One\nTwo\nThree\nFour";
+ lv_coord_t hres = lv_disp_get_hor_res(NULL);
+ lv_coord_t vres = lv_disp_get_ver_res(NULL);
- static const char *days =
- "Monday\nTuesday\nWednesday\nThursday\nFriday\nSaturday\nSunday";
+ content = lv_page_create(lv_disp_get_scr_act(NULL), NULL);
- static const char *mbox_btns[] =
- {
- "Ok", ""
- };
-
- content = lv_page_create(lv_scr_act(), NULL);
-
-#if LV_HOR_RES > LV_VER_RES
- lv_obj_set_size(content, LV_HOR_RES - lv_obj_get_width(
- sb), LV_VER_RES - lv_obj_get_height(header));
- lv_obj_set_pos(content, lv_obj_get_width(sb), lv_obj_get_height(header));
-#else
- lv_obj_set_size(content, LV_HOR_RES, LV_VER_RES / 2);
- lv_obj_set_pos(content, 0, LV_VER_RES / 2);
-#endif
+ if (hres > vres)
+ {
+ lv_obj_set_size(content,
+ hres - lv_obj_get_width(sb),
+ vres - lv_obj_get_height(header));
+ lv_obj_set_pos(content,
+ lv_obj_get_width(sb),
+ lv_obj_get_height(header));
+ }
+ else
+ {
+ lv_obj_set_size(content, hres, vres / 2);
+ lv_obj_set_pos(content, 0, vres / 2);
+ }
lv_page_set_scrl_layout(content, LV_LAYOUT_PRETTY);
+ lv_page_set_scrl_fit2(content, LV_FIT_FLOOD, LV_FIT_TIGHT);
- max_w = lv_page_get_fit_width(content);
+ lv_coord_t max_w = lv_page_get_fit_width(content);
/* Button */
- btn = lv_btn_create(content, NULL);
+ lv_obj_t *btn = lv_btn_create(content, NULL);
lv_btn_set_ink_in_time(btn, 200);
lv_btn_set_ink_wait_time(btn, 100);
lv_btn_set_ink_out_time(btn, 500);
-
- label = lv_label_create(btn, NULL);
+ lv_obj_t *label = lv_label_create(btn, NULL);
lv_label_set_text(label, "Button");
/* Switch */
- sw = lv_sw_create(content, NULL);
-
-#if USE_LV_ANIMATION
-#if LVGL_VERSION_MAJOR == 5 && LVGL_VERSION_MINOR >= 3
+ lv_obj_t *sw = lv_sw_create(content, NULL);
lv_sw_set_anim_time(sw, 250);
-#endif
-#endif
/* Check box */
@@ -295,165 +261,172 @@ static void content_create(void)
/* Bar */
- bar = lv_bar_create(content, NULL);
+ lv_obj_t *bar = lv_bar_create(content, NULL);
lv_obj_set_width(bar, LV_MATH_MIN(max_w, 3 * LV_DPI / 2));
-
-#if USE_LV_ANIMATION
- a.var = bar;
- a.start = 0;
- a.end = 100;
- a.fp = (lv_anim_fp_t)lv_bar_set_value;
- a.path = lv_anim_path_linear;
- a.end_cb = NULL;
- a.act_time = 0;
- a.time = 1000;
- a.playback = 1;
- a.playback_pause = 100;
- a.repeat = 1;
- a.repeat_pause = 100;
+#if LV_USE_ANIMATION
+ lv_anim_t a;
+ a.var = bar;
+ a.start = 0;
+ a.end = 100;
+ a.exec_cb = (lv_anim_exec_xcb_t)bar_set_value;
+ a.path_cb = lv_anim_path_linear;
+ a.ready_cb = NULL;
+ a.act_time = 0;
+ a.time = 1000;
+ a.playback = 1;
+ a.playback_pause = 100;
+ a.repeat = 1;
+ a.repeat_pause = 100;
lv_anim_create(&a);
#endif
/* Slider */
- slider = lv_slider_create(content, NULL);
+ lv_obj_t *slider = lv_slider_create(content, NULL);
lv_obj_set_width(slider, LV_MATH_MIN(max_w, 3 * LV_DPI / 2));
- lv_slider_set_value(slider, 30);
+ lv_slider_set_value(slider, 30, false);
/* Roller */
- roller = lv_roller_create(content, NULL);
- lv_roller_set_options(roller, days);
+ static const char *days = "Monday\nTuesday\nWednesday\n"
+ "Thursday\nFriday\nSaturday\nSunday";
+ lv_obj_t *roller = lv_roller_create(content, NULL);
+ lv_roller_set_options(roller, days, false);
/* Drop down list */
- ddlist = lv_ddlist_create(content, NULL);
+ static const char *nums = "One\nTwo\nThree\nFour";
+ lv_obj_t *ddlist = lv_ddlist_create(content, NULL);
lv_ddlist_set_options(ddlist, nums);
/* Line meter */
- lmeter = lv_lmeter_create(content, NULL);
+ lv_obj_t *lmeter = lv_lmeter_create(content, NULL);
lv_obj_set_click(lmeter, false);
-#if USE_LV_ANIMATION
- a.var = lmeter;
- a.start = 0;
- a.end = 100;
- a.fp = (lv_anim_fp_t)lv_lmeter_set_value;
- a.path = lv_anim_path_linear;
- a.end_cb = NULL;
- a.act_time = 0;
- a.time = 1000;
- a.playback = 1;
- a.playback_pause = 100;
- a.repeat = 1;
- a.repeat_pause = 100;
+#if LV_USE_ANIMATION
+ a.var = lmeter;
+ a.start = 0;
+ a.end = 100;
+ a.exec_cb = (lv_anim_exec_xcb_t)lv_lmeter_set_value;
+ a.path_cb = lv_anim_path_linear;
+ a.ready_cb = NULL;
+ a.act_time = 0;
+ a.time = 1000;
+ a.playback = 1;
+ a.playback_pause = 100;
+ a.repeat = 1;
+ a.repeat_pause = 100;
lv_anim_create(&a);
#endif
/* Gauge */
- gauge = lv_gauge_create(content, NULL);
+ lv_obj_t *gauge = lv_gauge_create(content, NULL);
lv_gauge_set_value(gauge, 0, 47);
lv_obj_set_size(gauge, LV_MATH_MIN(max_w, LV_DPI * 3 / 2),
- LV_MATH_MIN(max_w, LV_DPI * 3 / 2));
+ LV_MATH_MIN(max_w, LV_DPI * 3 / 2));
lv_obj_set_click(gauge, false);
/* Text area */
- ta = lv_ta_create(content, NULL);
+ lv_obj_t *ta = lv_ta_create(content, NULL);
lv_obj_set_width(ta, LV_MATH_MIN(max_w, LV_DPI * 3 / 2));
lv_ta_set_one_line(ta, true);
lv_ta_set_text(ta, "Type...");
/* Keyboard */
- kb = lv_kb_create(content, NULL);
- lv_obj_set_width(kb, LV_MATH_MIN(max_w, LV_DPI * 3));
+ lv_obj_t *kb = lv_kb_create(content, NULL);
+ lv_obj_set_width(kb, max_w - LV_DPI / 4);
lv_kb_set_ta(kb, ta);
- /* Message Box */
-
- mbox = lv_mbox_create(lv_scr_act(), NULL);
+ lv_obj_t *mbox = lv_mbox_create(lv_disp_get_scr_act(NULL), NULL);
lv_obj_set_drag(mbox, true);
lv_mbox_set_text(mbox, "Choose a theme and a color on the left!");
- lv_mbox_add_btns(mbox, mbox_btns, NULL);
+ static const char *mbox_btns[] =
+ {
+ "Ok", ""
+ };
+
+ lv_mbox_add_btns(mbox, mbox_btns);
lv_obj_align(mbox, NULL, LV_ALIGN_CENTER, 0, 0);
}
/****************************************************************************
- * Name: theme_select_action
+ * Name: theme_select_event_handler
*
* Description:
- * Callback for the theme selection roller
+ * Callback for the theme selection event
*
* Input Parameters:
* roller - the roller object that triggered the action
- *
- * Returned Value:
- * LV_RES_OK in all cases
+ * event - the theme select evnet type
*
* Assumptions/Limitations:
*
****************************************************************************/
-static lv_res_t theme_select_action(lv_obj_t *roller)
+static void theme_select_event_handler(lv_obj_t *roller, lv_event_t event)
{
- uint16_t opt;
-
- opt = lv_roller_get_selected(roller);
-
- th_act = themes[opt];
- lv_theme_set_current(th_act);
-
- lv_obj_align(header, NULL, LV_ALIGN_IN_TOP_MID, 0, 0);
- lv_obj_align(sb, header, LV_ALIGN_OUT_BOTTOM_LEFT, 0, 0);
-
-#if LV_HOR_RES > LV_VER_RES
- lv_obj_set_size(content,
- LV_HOR_RES - lv_obj_get_width(sb),
- LV_VER_RES - lv_obj_get_height(header));
- lv_obj_set_pos(content, lv_obj_get_width(sb), lv_obj_get_height(header));
-#else
- lv_obj_set_size(content, LV_HOR_RES, LV_VER_RES / 2);
- lv_obj_set_pos(content, 0, LV_VER_RES / 2);
-#endif
-
- lv_page_focus(sb, roller, 200);
-
- return LV_RES_OK;
+ if (event == LV_EVENT_VALUE_CHANGED)
+ {
+ lv_coord_t hres = lv_disp_get_hor_res(NULL);
+ lv_coord_t vres = lv_disp_get_ver_res(NULL);
+
+ uint16_t opt = lv_roller_get_selected(roller);
+ th_act = themes[opt];
+ lv_theme_set_current(th_act);
+
+ lv_obj_align(header, NULL, LV_ALIGN_IN_TOP_MID, 0, 0);
+ lv_obj_align(sb, header, LV_ALIGN_OUT_BOTTOM_LEFT, 0, 0);
+
+ if (hres > vres)
+ {
+ lv_obj_set_size(content,
+ hres - lv_obj_get_width(sb),
+ vres - lv_obj_get_height(header));
+ lv_obj_set_pos(content,
+ lv_obj_get_width(sb),
+ lv_obj_get_height(header));
+ }
+ else
+ {
+ lv_obj_set_size(content, hres, vres / 2);
+ lv_obj_set_pos(content, 0, vres / 2);
+ }
+
+ lv_page_focus(sb, roller, LV_ANIM_ON);
+ }
}
/****************************************************************************
- * Name: hue_select_action
+ * Name: hue_select_event_cb
*
* Description:
- * Callback for the hue roller object upon selection change
+ * Callback for the hue selection event
*
* Input Parameters:
* roller - the roller object that triggered the action
- *
- * Returned Value:
- * LV_RES_OK in all cases
+ * event - the hue select evnet type
*
* Assumptions/Limitations:
*
****************************************************************************/
-static lv_res_t hue_select_action(lv_obj_t * roller)
+static void hue_select_event_cb(lv_obj_t *roller, lv_event_t event)
{
- uint16_t hue;
-
- hue = lv_roller_get_selected(roller) * 30;
-
- init_all_themes(hue);
+ if (event == LV_EVENT_VALUE_CHANGED)
+ {
+ uint16_t hue = lv_roller_get_selected(roller) * 30;
- lv_theme_set_current(th_act);
+ init_all_themes(hue);
- lv_page_focus(sb, roller, 200);
+ lv_theme_set_current(th_act);
- return LV_RES_OK;
+ lv_page_focus(sb, roller, LV_ANIM_ON);
+ }
}
/****************************************************************************
@@ -475,38 +448,54 @@ static lv_res_t hue_select_action(lv_obj_t * roller)
static void init_all_themes(uint16_t hue)
{
- int i = 0;
-
-#if USE_LV_THEME_NIGHT
- themes[i++] = lv_theme_night_init(hue, NULL);
+ int i = 0;
+#if LV_USE_THEME_NIGHT
+ themes[i++] = lv_theme_night_init(hue, NULL);
#endif
-#if USE_LV_THEME_MATERIAL
- themes[i++] = lv_theme_material_init(hue, NULL);
+#if LV_USE_THEME_MATERIAL
+ themes[i++] = lv_theme_material_init(hue, NULL);
#endif
-#if USE_LV_THEME_ALIEN
- themes[i++] = lv_theme_alien_init(hue, NULL);
+#if LV_USE_THEME_ALIEN
+ themes[i++] = lv_theme_alien_init(hue, NULL);
#endif
-#if USE_LV_THEME_ZEN
- themes[i++] = lv_theme_zen_init(hue, NULL);
+#if LV_USE_THEME_ZEN
+ themes[i++] = lv_theme_zen_init(hue, NULL);
#endif
-#if USE_LV_THEME_NEMO
- themes[i++] = lv_theme_nemo_init(hue, NULL);
+#if LV_USE_THEME_NEMO
+ themes[i++] = lv_theme_nemo_init(hue, NULL);
#endif
-#if USE_LV_THEME_MONO
- themes[i++] = lv_theme_mono_init(hue, NULL);
+#if LV_USE_THEME_MONO
+ themes[i++] = lv_theme_mono_init(hue, NULL);
#endif
-#if USE_LV_THEME_DEFAULT
- themes[i++] = lv_theme_default_init(hue, NULL);
+#if LV_USE_THEME_DEFAULT
+ themes[i++] = lv_theme_default_init(hue, NULL);
#endif
}
/****************************************************************************
+ * Name: bar_set_value
+ *
+ * Description:
+ * Initialize all compiled-in themes to a hue
+ *
+ * Input Parameters:
+ * bar - bar instance
+ * value - value of bar
+ *
+ ****************************************************************************/
+
+static void bar_set_value(lv_obj_t *bar, int16_t value)
+{
+ lv_bar_set_value(bar, value, LV_ANIM_OFF);
+}
+
+/****************************************************************************
* Public Functions
****************************************************************************/
@@ -528,14 +517,10 @@ static void init_all_themes(uint16_t hue)
void lv_test_theme_2(void)
{
- lv_obj_t *scr;
-
/* By doing this, we hide the first (empty) option. */
if (th_options[0] == '\n')
- {
- th_options++;
- }
+ th_options++;
init_all_themes(0);
th_act = themes[0];
@@ -547,8 +532,8 @@ void lv_test_theme_2(void)
lv_theme_set_current(th_act);
- scr = lv_obj_create(NULL, NULL);
- lv_scr_load(scr);
+ lv_obj_t *scr = lv_obj_create(NULL, NULL);
+ lv_disp_load_scr(scr);
header_create();
sb_create();