mirror of
https://github.com/lvgl/lvgl.git
synced 2025-01-28 07:03:00 +08:00
fix: fix build error when some widgets are disabled (#5290)
This commit is contained in:
parent
8df95aaf4b
commit
fe61f1fc94
@ -1,7 +1,7 @@
|
||||
|
||||
#include "../../lv_examples.h"
|
||||
|
||||
#if LV_USE_TABLE && LV_USE_FILE_EXPLORER && (LV_USE_FS_STDIO || LV_USE_FS_POSIX || LV_USE_FS_WIN32 || LV_USE_FS_FATFS) && LV_BUILD_EXAMPLES
|
||||
#if LV_USE_TABLE && LV_USE_DROPDOWN && LV_USE_FILE_EXPLORER && (LV_USE_FS_STDIO || LV_USE_FS_POSIX || LV_USE_FS_WIN32 || LV_USE_FS_FATFS) && LV_BUILD_EXAMPLES
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
@ -34,21 +34,34 @@ static lv_observer_t * bind_to_bitfield(lv_subject_t * subject, lv_obj_t * obj,
|
||||
int32_t ref_value, bool inv);
|
||||
static void obj_flag_observer_cb(lv_observer_t * observer, lv_subject_t * subject);
|
||||
static void obj_state_observer_cb(lv_observer_t * observer, lv_subject_t * subject);
|
||||
static void btn_value_changed_event_cb(lv_event_t * e);
|
||||
|
||||
static void label_text_observer_cb(lv_observer_t * observer, lv_subject_t * subject);
|
||||
#if LV_USE_BUTTON
|
||||
static void btn_value_changed_event_cb(lv_event_t * e);
|
||||
#endif
|
||||
|
||||
static void arc_value_changed_event_cb(lv_event_t * e);
|
||||
static void arc_value_observer_cb(lv_observer_t * observer, lv_subject_t * subject);
|
||||
#if LV_USE_LABEL
|
||||
static void label_text_observer_cb(lv_observer_t * observer, lv_subject_t * subject);
|
||||
#endif
|
||||
|
||||
static void slider_value_changed_event_cb(lv_event_t * e);
|
||||
static void slider_value_observer_cb(lv_observer_t * observer, lv_subject_t * subject);
|
||||
#if LV_USE_ARC
|
||||
static void arc_value_changed_event_cb(lv_event_t * e);
|
||||
static void arc_value_observer_cb(lv_observer_t * observer, lv_subject_t * subject);
|
||||
#endif
|
||||
|
||||
static void roller_value_changed_event_cb(lv_event_t * e);
|
||||
static void roller_value_observer_cb(lv_observer_t * observer, lv_subject_t * subject);
|
||||
#if LV_USE_SLIDER
|
||||
static void slider_value_changed_event_cb(lv_event_t * e);
|
||||
static void slider_value_observer_cb(lv_observer_t * observer, lv_subject_t * subject);
|
||||
#endif
|
||||
|
||||
static void dropdown_value_changed_event_cb(lv_event_t * e);
|
||||
static void dropdown_value_observer_cb(lv_observer_t * observer, lv_subject_t * subject);
|
||||
#if LV_USE_ROLLER
|
||||
static void roller_value_changed_event_cb(lv_event_t * e);
|
||||
static void roller_value_observer_cb(lv_observer_t * observer, lv_subject_t * subject);
|
||||
#endif
|
||||
|
||||
#if LV_USE_DROPDOWN
|
||||
static void dropdown_value_changed_event_cb(lv_event_t * e);
|
||||
static void dropdown_value_observer_cb(lv_observer_t * observer, lv_subject_t * subject);
|
||||
#endif
|
||||
|
||||
/**********************
|
||||
* STATIC VARIABLES
|
||||
@ -348,8 +361,13 @@ void lv_subject_remove_all_obj(lv_subject_t * subject, lv_obj_t * obj)
|
||||
while(lv_obj_remove_event_cb(obj, unsubscribe_on_delete_cb));
|
||||
while(lv_obj_remove_event_cb(obj, btn_value_changed_event_cb));
|
||||
while(lv_obj_remove_event_cb(obj, arc_value_changed_event_cb));
|
||||
#if LV_USE_ROLLER
|
||||
while(lv_obj_remove_event_cb(obj, roller_value_changed_event_cb));
|
||||
#endif
|
||||
|
||||
#if LV_USE_DROPDOWN
|
||||
while(lv_obj_remove_event_cb(obj, dropdown_value_changed_event_cb));
|
||||
#endif
|
||||
|
||||
lv_observer_t * observer = _lv_ll_get_head(&subject->subs_ll);
|
||||
while(observer) {
|
||||
@ -414,12 +432,16 @@ lv_observer_t * lv_obj_bind_state_if_not_eq(lv_obj_t * obj, lv_subject_t * subje
|
||||
return observable;
|
||||
}
|
||||
|
||||
#if LV_USE_BUTTON
|
||||
lv_observer_t * lv_button_bind_checked(lv_obj_t * obj, lv_subject_t * subject)
|
||||
{
|
||||
lv_observer_t * observable = bind_to_bitfield(subject, obj, obj_state_observer_cb, LV_STATE_CHECKED, 1, false);
|
||||
lv_obj_add_event_cb(obj, btn_value_changed_event_cb, LV_EVENT_VALUE_CHANGED, subject);
|
||||
return observable;
|
||||
}
|
||||
#endif /*LV_USE_BUTTON*/
|
||||
|
||||
#if LV_USE_LABEL
|
||||
lv_observer_t * lv_label_bind_text(lv_obj_t * obj, lv_subject_t * subject, const char * fmt)
|
||||
{
|
||||
if(fmt == NULL) {
|
||||
@ -439,7 +461,9 @@ lv_observer_t * lv_label_bind_text(lv_obj_t * obj, lv_subject_t * subject, const
|
||||
lv_observer_t * observer = lv_subject_add_observer_obj(subject, label_text_observer_cb, obj, (void *)fmt);
|
||||
return observer;
|
||||
}
|
||||
#endif /*LV_USE_LABEL*/
|
||||
|
||||
#if LV_USE_ARC
|
||||
lv_observer_t * lv_arc_bind_value(lv_obj_t * obj, lv_subject_t * subject)
|
||||
{
|
||||
if(subject->type != LV_SUBJECT_TYPE_INT) {
|
||||
@ -452,7 +476,9 @@ lv_observer_t * lv_arc_bind_value(lv_obj_t * obj, lv_subject_t * subject)
|
||||
lv_observer_t * observer = lv_subject_add_observer_obj(subject, arc_value_observer_cb, obj, NULL);
|
||||
return observer;
|
||||
}
|
||||
#endif /*LV_USE_ARC*/
|
||||
|
||||
#if LV_USE_SLIDER
|
||||
lv_observer_t * lv_slider_bind_value(lv_obj_t * obj, lv_subject_t * subject)
|
||||
{
|
||||
if(subject->type != LV_SUBJECT_TYPE_INT) {
|
||||
@ -465,6 +491,9 @@ lv_observer_t * lv_slider_bind_value(lv_obj_t * obj, lv_subject_t * subject)
|
||||
lv_observer_t * observer = lv_subject_add_observer_obj(subject, slider_value_observer_cb, obj, NULL);
|
||||
return observer;
|
||||
}
|
||||
#endif /*LV_USE_SLIDER*/
|
||||
|
||||
#if LV_USE_ROLLER
|
||||
|
||||
lv_observer_t * lv_roller_bind_value(lv_obj_t * obj, lv_subject_t * subject)
|
||||
{
|
||||
@ -479,6 +508,9 @@ lv_observer_t * lv_roller_bind_value(lv_obj_t * obj, lv_subject_t * subject)
|
||||
return observer;
|
||||
|
||||
}
|
||||
#endif /*LV_USE_ROLLER*/
|
||||
|
||||
#if LV_USE_DROPDOWN
|
||||
|
||||
lv_observer_t * lv_dropdown_bind_value(lv_obj_t * obj, lv_subject_t * subject)
|
||||
{
|
||||
@ -494,6 +526,8 @@ lv_observer_t * lv_dropdown_bind_value(lv_obj_t * obj, lv_subject_t * subject)
|
||||
|
||||
}
|
||||
|
||||
#endif /*LV_USE_DROPDOWN*/
|
||||
|
||||
/**********************
|
||||
* STATIC FUNCTIONS
|
||||
**********************/
|
||||
@ -564,6 +598,8 @@ static void obj_state_observer_cb(lv_observer_t * observer, lv_subject_t * subje
|
||||
}
|
||||
}
|
||||
|
||||
#if LV_USE_BUTTON
|
||||
|
||||
static void btn_value_changed_event_cb(lv_event_t * e)
|
||||
{
|
||||
lv_obj_t * obj = lv_event_get_current_target(e);
|
||||
@ -572,6 +608,10 @@ static void btn_value_changed_event_cb(lv_event_t * e)
|
||||
lv_subject_set_int(subject, lv_obj_has_state(obj, LV_STATE_CHECKED));
|
||||
}
|
||||
|
||||
#endif /*LV_USE_BUTTON*/
|
||||
|
||||
#if LV_USE_LABEL
|
||||
|
||||
static void label_text_observer_cb(lv_observer_t * observer, lv_subject_t * subject)
|
||||
{
|
||||
const char * fmt = observer->user_data;
|
||||
@ -594,6 +634,10 @@ static void label_text_observer_cb(lv_observer_t * observer, lv_subject_t * subj
|
||||
}
|
||||
}
|
||||
|
||||
#endif /*LV_USE_LABEL*/
|
||||
|
||||
#if LV_USE_ARC
|
||||
|
||||
static void arc_value_changed_event_cb(lv_event_t * e)
|
||||
{
|
||||
lv_obj_t * arc = lv_event_get_current_target(e);
|
||||
@ -607,6 +651,10 @@ static void arc_value_observer_cb(lv_observer_t * observer, lv_subject_t * subje
|
||||
lv_arc_set_value(observer->target, subject->value.num);
|
||||
}
|
||||
|
||||
#endif /*LV_USE_ARC*/
|
||||
|
||||
#if LV_USE_SLIDER
|
||||
|
||||
static void slider_value_changed_event_cb(lv_event_t * e)
|
||||
{
|
||||
lv_obj_t * slider = lv_event_get_current_target(e);
|
||||
@ -620,6 +668,10 @@ static void slider_value_observer_cb(lv_observer_t * observer, lv_subject_t * su
|
||||
lv_slider_set_value(observer->target, subject->value.num, LV_ANIM_OFF);
|
||||
}
|
||||
|
||||
#endif /*LV_USE_SLIDER*/
|
||||
|
||||
#if LV_USE_ROLLER
|
||||
|
||||
static void roller_value_changed_event_cb(lv_event_t * e)
|
||||
{
|
||||
lv_obj_t * roller = lv_event_get_current_target(e);
|
||||
@ -635,6 +687,10 @@ static void roller_value_observer_cb(lv_observer_t * observer, lv_subject_t * su
|
||||
}
|
||||
}
|
||||
|
||||
#endif /*LV_USE_ROLLER*/
|
||||
|
||||
#if LV_USE_DROPDOWN
|
||||
|
||||
static void dropdown_value_changed_event_cb(lv_event_t * e)
|
||||
{
|
||||
lv_obj_t * dropdown = lv_event_get_current_target(e);
|
||||
@ -648,4 +704,6 @@ static void dropdown_value_observer_cb(lv_observer_t * observer, lv_subject_t *
|
||||
lv_dropdown_set_selected(observer->target, subject->value.num);
|
||||
}
|
||||
|
||||
#endif /*LV_USE_DROPDOWN*/
|
||||
|
||||
#endif /*LV_USE_OBSERVER*/
|
||||
|
@ -329,6 +329,7 @@ lv_observer_t * lv_obj_bind_state_if_eq(lv_obj_t * obj, lv_subject_t * subject,
|
||||
lv_observer_t * lv_obj_bind_state_if_not_eq(lv_obj_t * obj, lv_subject_t * subject, lv_state_t state,
|
||||
int32_t ref_value);
|
||||
|
||||
#if LV_USE_BUTTON
|
||||
/**
|
||||
* Set an integer subject to 1 when a button is checked and set it 0 when unchecked.
|
||||
* @param obj pointer to a button
|
||||
@ -336,7 +337,9 @@ lv_observer_t * lv_obj_bind_state_if_not_eq(lv_obj_t * obj, lv_subject_t * subje
|
||||
* @return pointer to the created observer
|
||||
*/
|
||||
lv_observer_t * lv_button_bind_checked(lv_obj_t * obj, lv_subject_t * subject);
|
||||
#endif
|
||||
|
||||
#if LV_USE_LABEL
|
||||
/**
|
||||
* Bind an integer, string, or pointer subject to a label.
|
||||
* @param obj pointer to a label
|
||||
@ -348,7 +351,9 @@ lv_observer_t * lv_button_bind_checked(lv_obj_t * obj, lv_subject_t * subject);
|
||||
* @note if the subject is a pointer must point to a `\0` terminated string.
|
||||
*/
|
||||
lv_observer_t * lv_label_bind_text(lv_obj_t * obj, lv_subject_t * subject, const char * fmt);
|
||||
#endif
|
||||
|
||||
#if LV_USE_ARC
|
||||
/**
|
||||
* Bind an integer subject to an arc's value
|
||||
* @param obj pointer to an arc
|
||||
@ -356,7 +361,9 @@ lv_observer_t * lv_label_bind_text(lv_obj_t * obj, lv_subject_t * subject, const
|
||||
* @return pointer to the created observer
|
||||
*/
|
||||
lv_observer_t * lv_arc_bind_value(lv_obj_t * obj, lv_subject_t * subject);
|
||||
#endif
|
||||
|
||||
#if LV_USE_SLIDER
|
||||
/**
|
||||
* Bind an integer subject to a slider's value
|
||||
* @param obj pointer to a slider
|
||||
@ -364,7 +371,9 @@ lv_observer_t * lv_arc_bind_value(lv_obj_t * obj, lv_subject_t * subject);
|
||||
* @return pointer to the created observer
|
||||
*/
|
||||
lv_observer_t * lv_slider_bind_value(lv_obj_t * obj, lv_subject_t * subject);
|
||||
#endif
|
||||
|
||||
#if LV_USE_ROLLER
|
||||
/**
|
||||
* Bind an integer subject to a roller's value
|
||||
* @param obj pointer to a roller
|
||||
@ -372,7 +381,9 @@ lv_observer_t * lv_slider_bind_value(lv_obj_t * obj, lv_subject_t * subject);
|
||||
* @return pointer to the created observer
|
||||
*/
|
||||
lv_observer_t * lv_roller_bind_value(lv_obj_t * obj, lv_subject_t * subject);
|
||||
#endif
|
||||
|
||||
#if LV_USE_DROPDOWN
|
||||
/**
|
||||
* Bind an integer subject to a dropdown's value
|
||||
* @param obj pointer to a drop down
|
||||
@ -380,6 +391,7 @@ lv_observer_t * lv_roller_bind_value(lv_obj_t * obj, lv_subject_t * subject);
|
||||
* @return pointer to the created observer
|
||||
*/
|
||||
lv_observer_t * lv_dropdown_bind_value(lv_obj_t * obj, lv_subject_t * subject);
|
||||
#endif
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
|
@ -16,6 +16,10 @@ extern "C" {
|
||||
#include "../../core/lv_obj.h"
|
||||
#if LV_USE_CALENDAR && LV_USE_CALENDAR_HEADER_DROPDOWN
|
||||
|
||||
#if LV_USE_DROPDOWN == 0
|
||||
#error "LV_USE_DROPDOWN needs to be enabled"
|
||||
#endif
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
*********************/
|
||||
|
Loading…
x
Reference in New Issue
Block a user