mirror of
https://github.com/lvgl/lvgl.git
synced 2026-05-24 08:16:29 +08:00
feat(example/scroll): convert old scroll demo to an example (#9049)
This commit is contained in:
@@ -66,5 +66,4 @@ LV_USE_DEMO_MUSIC 1
|
||||
LV_USE_DEMO_FLEX_LAYOUT 1
|
||||
LV_USE_DEMO_MULTILANG 1
|
||||
LV_USE_DEMO_TRANSFORM 1
|
||||
LV_USE_DEMO_SCROLL 1
|
||||
|
||||
|
||||
|
||||
@@ -2210,10 +2210,6 @@ menu "LVGL configuration"
|
||||
bool "Render test for each primitives. Requires at least 480x272 display"
|
||||
default n
|
||||
|
||||
config LV_USE_DEMO_SCROLL
|
||||
bool "Scroll settings test for LVGL"
|
||||
default n
|
||||
|
||||
config LV_USE_DEMO_STRESS
|
||||
bool "Stress test for LVGL"
|
||||
default n
|
||||
|
||||
@@ -80,7 +80,6 @@ LV_USE_DEMO_MUSIC 1
|
||||
LV_USE_DEMO_FLEX_LAYOUT 1
|
||||
LV_USE_DEMO_MULTILANG 1
|
||||
LV_USE_DEMO_TRANSFORM 1
|
||||
LV_USE_DEMO_SCROLL 1
|
||||
LV_USE_DEMO_EBIKE 1
|
||||
LV_USE_DEMO_HIGH_RES 1
|
||||
LV_USE_DEMO_SMARTWATCH 1
|
||||
|
||||
@@ -41,9 +41,6 @@
|
||||
|
||||
/* Widget transformation demo */
|
||||
#define LV_USE_DEMO_TRANSFORM 0
|
||||
|
||||
/* Demonstrate scroll settings */
|
||||
#define LV_USE_DEMO_SCROLL 0
|
||||
...
|
||||
```
|
||||
|
||||
|
||||
@@ -826,10 +826,6 @@ Content of ``0001-change-config-file-to-run-fbdev-with-2-threads.patch``
|
||||
-#define LV_USE_DEMO_TRANSFORM 1
|
||||
+#define LV_USE_DEMO_TRANSFORM 0
|
||||
|
||||
/* Demonstrate scroll settings */
|
||||
-#define LV_USE_DEMO_SCROLL 1
|
||||
+#define LV_USE_DEMO_SCROLL 0
|
||||
|
||||
/* Vector graphic demo */
|
||||
#define LV_USE_DEMO_VECTOR_GRAPHIC 0
|
||||
--
|
||||
|
||||
@@ -48,10 +48,6 @@ else()
|
||||
file(GLOB_RECURSE DEMO_FLEX_LAYOUT_SOURCES ${LVGL_ROOT_DIR}/demos/flex_layout/*.c)
|
||||
list(APPEND DEMO_SOURCES ${DEMO_FLEX_LAYOUT_SOURCES})
|
||||
endif()
|
||||
if(CONFIG_LV_USE_DEMO_SCROLL)
|
||||
file(GLOB_RECURSE DEMO_SCROLL_SOURCES ${LVGL_ROOT_DIR}/demos/scroll/*.c)
|
||||
list(APPEND DEMO_SOURCES ${DEMO_SCROLL_SOURCES})
|
||||
endif()
|
||||
if(CONFIG_LV_USE_DEMO_MUSIC)
|
||||
file(GLOB_RECURSE DEMO_MUSIC_SOURCES ${LVGL_ROOT_DIR}/demos/music/*.c)
|
||||
list(APPEND DEMO_SOURCES ${DEMO_MUSIC_SOURCES})
|
||||
@@ -81,4 +77,4 @@ if(CONFIG_FREERTOS_SMP)
|
||||
target_include_directories(${COMPONENT_LIB} PRIVATE "${IDF_PATH}/components/freertos/FreeRTOS-Kernel-SMP/include/freertos/")
|
||||
else()
|
||||
target_include_directories(${COMPONENT_LIB} PRIVATE "${IDF_PATH}/components/freertos/FreeRTOS-Kernel/include/freertos/")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
@@ -53,7 +53,6 @@ remove the misleading guide above this code segment.
|
||||
- LV_USE_DEMO_FLEX_LAYOUT
|
||||
- LV_USE_DEMO_MULTILANG
|
||||
- LV_USE_DEMO_TRANSFORM
|
||||
- LV_USE_DEMO_SCROLL
|
||||
- LV_USE_DEMO_VECTOR_GRAPHIC
|
||||
- LV_USE_DEMO_EBIKE
|
||||
- LV_USE_DEMO_HIGH_RES
|
||||
|
||||
@@ -35,9 +35,14 @@ Infinite scrolling
|
||||
.. lv_example:: scroll/lv_example_scroll_7
|
||||
:language: c
|
||||
|
||||
circular scrolling
|
||||
Circular scrolling
|
||||
------------------
|
||||
.. lv_example:: scroll/lv_example_scroll_8
|
||||
:language: c
|
||||
|
||||
Scrolling Properties
|
||||
--------------------
|
||||
.. lv_example:: scroll/lv_example_scroll_9
|
||||
:language: c
|
||||
|
||||
|
||||
|
||||
@@ -14,6 +14,8 @@ extern "C" {
|
||||
* INCLUDES
|
||||
*********************/
|
||||
|
||||
#include "../lv_examples.h"
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
*********************/
|
||||
@@ -33,6 +35,7 @@ void lv_example_scroll_5(void);
|
||||
void lv_example_scroll_6(void);
|
||||
void lv_example_scroll_7(void);
|
||||
void lv_example_scroll_8(void);
|
||||
void lv_example_scroll_9(void);
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
|
||||
@@ -0,0 +1,83 @@
|
||||
/**
|
||||
* @file lv_example_scroll_9.c
|
||||
*/
|
||||
|
||||
#include "lv_example_scroll.h"
|
||||
|
||||
#if LV_BUILD_EXAMPLES && LV_USE_FLEX
|
||||
|
||||
static lv_obj_t * switch_create(lv_obj_t * parent, const char * title, lv_obj_flag_t flag, bool en);
|
||||
static void generic_switch_event_cb(lv_event_t * e);
|
||||
|
||||
static lv_obj_t * list;
|
||||
|
||||
void lv_example_scroll_9(void)
|
||||
{
|
||||
lv_obj_t * panel = lv_obj_create(lv_screen_active());
|
||||
lv_obj_set_style_shadow_width(panel, 16, 0);
|
||||
lv_obj_set_style_shadow_offset_y(panel, 8, 0);
|
||||
lv_obj_set_style_shadow_offset_x(panel, 4, 0);
|
||||
lv_obj_set_style_shadow_opa(panel, LV_OPA_40, 0);
|
||||
|
||||
lv_obj_set_size(panel, lv_pct(70), lv_pct(90));
|
||||
lv_obj_center(panel);
|
||||
lv_obj_set_flex_flow(panel, LV_FLEX_FLOW_COLUMN);
|
||||
lv_obj_set_flex_align(panel, LV_FLEX_ALIGN_START, LV_FLEX_ALIGN_CENTER, LV_FLEX_ALIGN_CENTER);
|
||||
|
||||
list = lv_list_create(panel);
|
||||
lv_list_add_button(list, LV_SYMBOL_IMAGE, "Image1.png");
|
||||
lv_list_add_button(list, LV_SYMBOL_IMAGE, "Image2.png");
|
||||
lv_list_add_button(list, LV_SYMBOL_IMAGE, "Image3.png");
|
||||
lv_list_add_button(list, LV_SYMBOL_IMAGE, "Image4.png");
|
||||
lv_list_add_button(list, LV_SYMBOL_IMAGE, "Image5.png");
|
||||
lv_list_add_button(list, LV_SYMBOL_IMAGE, "Image6.png");
|
||||
lv_list_add_button(list, LV_SYMBOL_IMAGE, "Image7.png");
|
||||
lv_list_add_button(list, LV_SYMBOL_IMAGE, "Image8.png");
|
||||
lv_list_add_button(list, LV_SYMBOL_IMAGE, "Image9.png");
|
||||
lv_list_add_button(list, LV_SYMBOL_IMAGE, "Image10.png");
|
||||
|
||||
switch_create(panel, "Scrollable", LV_OBJ_FLAG_SCROLLABLE, true);
|
||||
switch_create(panel, "Scroll chain", LV_OBJ_FLAG_SCROLL_CHAIN, true);
|
||||
switch_create(panel, "Elastic scroll", LV_OBJ_FLAG_SCROLL_ELASTIC, true);
|
||||
switch_create(panel, "Add scroll momentum", LV_OBJ_FLAG_SCROLL_MOMENTUM, true);
|
||||
|
||||
/*Show the switches first*/
|
||||
lv_obj_move_to_index(list, -1);
|
||||
}
|
||||
|
||||
static lv_obj_t * switch_create(lv_obj_t * parent, const char * title, lv_obj_flag_t flag, bool en)
|
||||
{
|
||||
lv_obj_t * cont = lv_obj_create(parent);
|
||||
lv_obj_remove_style_all(cont);
|
||||
lv_obj_set_size(cont, lv_pct(100), LV_SIZE_CONTENT);
|
||||
lv_obj_set_flex_flow(cont, LV_FLEX_FLOW_ROW);
|
||||
lv_obj_set_flex_align(cont, LV_FLEX_ALIGN_START, LV_FLEX_ALIGN_CENTER, LV_FLEX_ALIGN_START);
|
||||
|
||||
lv_obj_t * label = lv_label_create(cont);
|
||||
lv_label_set_text(label, title);
|
||||
lv_obj_set_flex_grow(label, 1);
|
||||
|
||||
lv_obj_t * sw = lv_switch_create(cont);
|
||||
lv_obj_add_event_cb(sw, generic_switch_event_cb, LV_EVENT_VALUE_CHANGED, (void *)((lv_uintptr_t) flag));
|
||||
if(en) {
|
||||
lv_obj_add_state(sw, LV_STATE_CHECKED);
|
||||
lv_obj_add_flag(list, flag);
|
||||
}
|
||||
else {
|
||||
lv_obj_remove_state(sw, LV_STATE_CHECKED);
|
||||
lv_obj_remove_flag(list, flag);
|
||||
}
|
||||
|
||||
return cont;
|
||||
}
|
||||
|
||||
static void generic_switch_event_cb(lv_event_t * e)
|
||||
{
|
||||
lv_obj_t * sw = lv_event_get_target_obj(e);
|
||||
lv_obj_flag_t flag = (lv_obj_flag_t)((lv_uintptr_t)lv_event_get_user_data(e));
|
||||
|
||||
if(lv_obj_has_state(sw, LV_STATE_CHECKED)) lv_obj_add_flag(list, flag);
|
||||
else lv_obj_remove_flag(list, flag);
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -1452,9 +1452,6 @@
|
||||
/** Widget transformation demo */
|
||||
#define LV_USE_DEMO_TRANSFORM 0
|
||||
|
||||
/** Demonstrate scroll settings */
|
||||
#define LV_USE_DEMO_SCROLL 0
|
||||
|
||||
/*E-bike demo with Lottie animations (if LV_USE_LOTTIE is enabled)*/
|
||||
#define LV_USE_DEMO_EBIKE 0
|
||||
#if LV_USE_DEMO_EBIKE
|
||||
|
||||
@@ -248,7 +248,6 @@ LV_EXPORT_CONST_INT(LV_DRAW_BUF_ALIGN);
|
||||
#define LV_USE_DEMO_FLEX_LAYOUT 0
|
||||
#define LV_USE_DEMO_MULTILANG 0
|
||||
#define LV_USE_DEMO_TRANSFORM 0
|
||||
#define LV_USE_DEMO_SCROLL 0
|
||||
#define LV_USE_DEMO_EBIKE 0
|
||||
#define LV_USE_DEMO_HIGH_RES 0
|
||||
#define LV_USE_DEMO_SMARTWATCH 0
|
||||
|
||||
@@ -4667,15 +4667,6 @@
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/** Demonstrate scroll settings */
|
||||
#ifndef LV_USE_DEMO_SCROLL
|
||||
#ifdef CONFIG_LV_USE_DEMO_SCROLL
|
||||
#define LV_USE_DEMO_SCROLL CONFIG_LV_USE_DEMO_SCROLL
|
||||
#else
|
||||
#define LV_USE_DEMO_SCROLL 0
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/*E-bike demo with Lottie animations (if LV_USE_LOTTIE is enabled)*/
|
||||
#ifndef LV_USE_DEMO_EBIKE
|
||||
#ifdef CONFIG_LV_USE_DEMO_EBIKE
|
||||
@@ -4782,7 +4773,6 @@ LV_EXPORT_CONST_INT(LV_DRAW_BUF_ALIGN);
|
||||
#define LV_USE_DEMO_FLEX_LAYOUT 0
|
||||
#define LV_USE_DEMO_MULTILANG 0
|
||||
#define LV_USE_DEMO_TRANSFORM 0
|
||||
#define LV_USE_DEMO_SCROLL 0
|
||||
#define LV_USE_DEMO_EBIKE 0
|
||||
#define LV_USE_DEMO_HIGH_RES 0
|
||||
#define LV_USE_DEMO_SMARTWATCH 0
|
||||
|
||||
@@ -125,7 +125,6 @@
|
||||
#define LV_USE_DEMO_RENDER 1
|
||||
#define LV_USE_DEMO_MUSIC 1
|
||||
#define LV_USE_DEMO_BENCHMARK 1
|
||||
#define LV_USE_DEMO_SCROLL 1
|
||||
#define LV_USE_DEMO_EBIKE 1
|
||||
#define LV_USE_DEMO_VECTOR_GRAPHIC 1
|
||||
#define LV_USE_DEMO_HIGH_RES 1
|
||||
|
||||
@@ -1290,9 +1290,6 @@
|
||||
/** Widget transformation demo */
|
||||
#define LV_USE_DEMO_TRANSFORM 0
|
||||
|
||||
/** Demonstrate scroll settings */
|
||||
#define LV_USE_DEMO_SCROLL 0
|
||||
|
||||
/** Vector graphic demo */
|
||||
#define LV_USE_DEMO_VECTOR_GRAPHIC 0
|
||||
|
||||
|
||||
Reference in New Issue
Block a user