Merge branch 'feat/new-event'
This commit is contained in:
@@ -1,9 +1,11 @@
|
||||
#include "../lv_examples.h"
|
||||
#if LV_BUILD_EXAMPLES && LV_USE_BTN
|
||||
|
||||
static void btn_event_cb(lv_obj_t * btn, lv_event_t event)
|
||||
static void btn_event_cb(lv_event_t * e)
|
||||
{
|
||||
if(event == LV_EVENT_CLICKED) {
|
||||
lv_event_code_t code = lv_event_get_code(e);
|
||||
lv_obj_t * btn = lv_event_get_target(e);
|
||||
if(code == LV_EVENT_CLICKED) {
|
||||
static uint8_t cnt = 0;
|
||||
cnt++;
|
||||
|
||||
|
||||
@@ -3,9 +3,12 @@
|
||||
|
||||
static lv_obj_t * label;
|
||||
|
||||
static void slider_event_cb(lv_obj_t * slider, lv_event_t event)
|
||||
static void slider_event_cb(lv_event_t * e)
|
||||
{
|
||||
if(event == LV_EVENT_VALUE_CHANGED) {
|
||||
lv_event_code_t code = lv_event_get_code(e);
|
||||
lv_obj_t * slider = lv_event_get_target(e);
|
||||
|
||||
if(code == LV_EVENT_VALUE_CHANGED) {
|
||||
/*Refresh the text*/
|
||||
lv_label_set_text_fmt(label, "%d", lv_slider_get_value(slider));
|
||||
lv_obj_align_to(label, slider, LV_ALIGN_OUT_TOP_MID, 0, -15); /*Align below the slider*/
|
||||
|
||||
@@ -1,10 +1,13 @@
|
||||
#include "../lv_examples.h"
|
||||
#if LV_BUILD_EXAMPLES && LV_USE_FLEX
|
||||
|
||||
static void sw_event_cb(lv_obj_t * sw, lv_event_t e)
|
||||
static void sw_event_cb(lv_event_t * e)
|
||||
{
|
||||
if(e == LV_EVENT_VALUE_CHANGED) {
|
||||
lv_obj_t * list = lv_event_get_user_data();
|
||||
lv_event_code_t code = lv_event_get_code(e);
|
||||
lv_obj_t * sw = lv_event_get_target(e);
|
||||
|
||||
if(code == LV_EVENT_VALUE_CHANGED) {
|
||||
lv_obj_t * list = lv_event_get_user_data(e);
|
||||
|
||||
if(lv_obj_has_state(sw, LV_STATE_CHECKED)) lv_obj_add_flag(list, LV_OBJ_FLAG_SCROLL_ONE);
|
||||
else lv_obj_clear_flag(list, LV_OBJ_FLAG_SCROLL_ONE);
|
||||
|
||||
@@ -3,10 +3,13 @@
|
||||
|
||||
static uint32_t btn_cnt = 1;
|
||||
|
||||
static void float_btn_event_cb(lv_obj_t * float_btn, lv_event_t e)
|
||||
static void float_btn_event_cb(lv_event_t * e)
|
||||
{
|
||||
if(e == LV_EVENT_CLICKED) {
|
||||
lv_obj_t * list = lv_event_get_user_data();
|
||||
lv_event_code_t code = lv_event_get_code(e);
|
||||
lv_obj_t * float_btn = lv_event_get_target(e);
|
||||
|
||||
if(code == LV_EVENT_CLICKED) {
|
||||
lv_obj_t * list = lv_event_get_user_data(e);
|
||||
char buf[32];
|
||||
lv_snprintf(buf, sizeof(buf), "Track %d", btn_cnt);
|
||||
lv_obj_t * list_btn = lv_list_add_btn(list, LV_SYMBOL_AUDIO, buf, NULL);
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
|
||||
//static void event_cb(lv_obj_t * obj, lv_event_t e)
|
||||
//{
|
||||
// if(e == LV_EVENT_DRAW_POST_END) {
|
||||
// if(code == LV_EVENT_DRAW_POST_END) {
|
||||
// lv_bar_t * bar = (lv_bar_t *)obj;
|
||||
//
|
||||
// lv_draw_label_dsc_t dsc;
|
||||
@@ -38,7 +38,7 @@
|
||||
// txt_area.y1 = bar->indic_area.y1 + (lv_area_get_height(&bar->indic_area) - txt_size.y) / 2;
|
||||
// txt_area.y2 = txt_area.y1 + txt_size.y - 1;
|
||||
//
|
||||
// const lv_area_t * clip_area = lv_event_get_param();
|
||||
// const lv_area_t * clip_area = lv_event_get_param(e);
|
||||
// lv_draw_label(&txt_area, clip_area, &dsc, buf, NULL);
|
||||
// }
|
||||
//}
|
||||
|
||||
@@ -1,13 +1,14 @@
|
||||
#include "../../lv_examples.h"
|
||||
#if LV_USE_BTN && LV_BUILD_EXAMPLES
|
||||
|
||||
static void event_handler(lv_obj_t * obj, lv_event_t event)
|
||||
static void event_handler(lv_event_t * e)
|
||||
{
|
||||
LV_UNUSED(obj);
|
||||
if(event == LV_EVENT_CLICKED) {
|
||||
lv_event_code_t code = lv_event_get_code(e);
|
||||
|
||||
if(code == LV_EVENT_CLICKED) {
|
||||
LV_LOG_USER("Clicked");
|
||||
}
|
||||
else if(event == LV_EVENT_VALUE_CHANGED) {
|
||||
else if(code == LV_EVENT_VALUE_CHANGED) {
|
||||
LV_LOG_USER("Toggled");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,9 +1,11 @@
|
||||
#include "../../lv_examples.h"
|
||||
#if LV_USE_BTNMATRIX && LV_BUILD_EXAMPLES
|
||||
|
||||
static void event_handler(lv_obj_t * obj, lv_event_t event)
|
||||
static void event_handler(lv_event_t * e)
|
||||
{
|
||||
if(event == LV_EVENT_VALUE_CHANGED) {
|
||||
lv_event_code_t code = lv_event_get_code(e);
|
||||
lv_obj_t * obj = lv_event_get_target(e);
|
||||
if(code == LV_EVENT_VALUE_CHANGED) {
|
||||
uint32_t id = lv_btnmatrix_get_selected_btn(obj);
|
||||
const char * txt = lv_btnmatrix_get_btn_text(obj, id);
|
||||
|
||||
|
||||
@@ -2,10 +2,12 @@
|
||||
#if LV_USE_BTNMATRIX && LV_BUILD_EXAMPLES
|
||||
|
||||
|
||||
static void event_cb(lv_obj_t * obj, lv_event_t e)
|
||||
static void event_cb(lv_event_t * e)
|
||||
{
|
||||
if(e == LV_EVENT_DRAW_PART_BEGIN) {
|
||||
lv_obj_draw_dsc_t * dsc = lv_event_get_param();
|
||||
lv_event_code_t code = lv_event_get_code(e);
|
||||
lv_obj_t * obj = lv_event_get_target(e);
|
||||
if(code == LV_EVENT_DRAW_PART_BEGIN) {
|
||||
lv_obj_draw_dsc_t * dsc = lv_event_get_param(e);
|
||||
|
||||
/*Change the draw descriptor the 2nd button*/
|
||||
if(dsc->id == 1) {
|
||||
@@ -31,8 +33,8 @@ static void event_cb(lv_obj_t * obj, lv_event_t e)
|
||||
|
||||
}
|
||||
}
|
||||
if(e == LV_EVENT_DRAW_PART_END) {
|
||||
lv_obj_draw_dsc_t * dsc = lv_event_get_param();
|
||||
if(code == LV_EVENT_DRAW_PART_END) {
|
||||
lv_obj_draw_dsc_t * dsc = lv_event_get_param(e);
|
||||
|
||||
/*Add custom content to the 4th button when the button itself was drawn*/
|
||||
if(dsc->id == 3) {
|
||||
|
||||
@@ -1,9 +1,11 @@
|
||||
#include "../../lv_examples.h"
|
||||
#if LV_USE_BTNMATRIX && LV_BUILD_EXAMPLES
|
||||
|
||||
static void event_cb(lv_obj_t * obj, lv_event_t e)
|
||||
static void event_cb(lv_event_t * e)
|
||||
{
|
||||
if(e == LV_EVENT_VALUE_CHANGED) {
|
||||
lv_event_code_t code = lv_event_get_code(e);
|
||||
lv_obj_t * obj = lv_event_get_target(e);
|
||||
if(code == LV_EVENT_VALUE_CHANGED) {
|
||||
uint32_t id = lv_btnmatrix_get_selected_btn(obj);
|
||||
bool prev = id == 0 ? true : false;
|
||||
bool next = id == 6 ? true : false;
|
||||
|
||||
@@ -1,9 +1,12 @@
|
||||
#include "../../lv_examples.h"
|
||||
#if LV_USE_CALENDAR && LV_BUILD_EXAMPLES
|
||||
|
||||
static void event_handler(lv_obj_t * obj, lv_event_t event)
|
||||
static void event_handler(lv_event_t * e)
|
||||
{
|
||||
if(event == LV_EVENT_VALUE_CHANGED) {
|
||||
lv_event_code_t code = lv_event_get_code(e);
|
||||
lv_obj_t * obj = lv_event_get_target(e);
|
||||
|
||||
if(code == LV_EVENT_VALUE_CHANGED) {
|
||||
lv_calendar_date_t date;
|
||||
if(lv_calendar_get_pressed_date(obj, &date)) {
|
||||
LV_LOG_USER("Clicked date: %02d.%02d.%d", date.day, date.month, date.year);
|
||||
|
||||
@@ -5,11 +5,14 @@ static lv_obj_t * chart1;
|
||||
static lv_chart_series_t * ser1;
|
||||
static lv_chart_series_t * ser2;
|
||||
|
||||
static void event_cb(lv_obj_t * obj, lv_event_t e)
|
||||
static void event_cb(lv_event_t * e)
|
||||
{
|
||||
lv_event_code_t code = lv_event_get_code(e);
|
||||
lv_obj_t * obj = lv_event_get_target(e);
|
||||
|
||||
/*Add the faded area before the lines are drawn*/
|
||||
if(e == LV_EVENT_DRAW_PART_BEGIN) {
|
||||
lv_obj_draw_dsc_t * dsc = lv_event_get_param();
|
||||
if(code == LV_EVENT_DRAW_PART_BEGIN) {
|
||||
lv_obj_draw_dsc_t * dsc = lv_event_get_param(e);
|
||||
if(dsc->part != LV_PART_ITEMS) return;
|
||||
if(!dsc->p1 || !dsc->p2) return;
|
||||
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
#include "../../lv_examples.h"
|
||||
#if LV_USE_CHART && LV_BUILD_EXAMPLES
|
||||
|
||||
static void event_cb(lv_obj_t * chart, lv_event_t e)
|
||||
static void event_cb(lv_event_t * e)
|
||||
{
|
||||
LV_UNUSED(chart);
|
||||
if(e == LV_EVENT_DRAW_PART_BEGIN) {
|
||||
lv_obj_draw_dsc_t * dsc = lv_event_get_param();
|
||||
lv_event_code_t code = lv_event_get_code(e);
|
||||
if(code == LV_EVENT_DRAW_PART_BEGIN) {
|
||||
lv_obj_draw_dsc_t * dsc = lv_event_get_param(e);
|
||||
if(dsc->part == LV_PART_TICKS && dsc->id == LV_CHART_AXIS_X) {
|
||||
const char * month[] = {"Jan", "Febr", "March", "Apr", "May", "Jun", "July", "Aug", "Sept", "Oct", "Nov", "Dec"};
|
||||
lv_snprintf(dsc->text, sizeof(dsc->text), "%s", month[dsc->value]);
|
||||
|
||||
@@ -2,16 +2,19 @@
|
||||
#if LV_USE_CHART && LV_BUILD_EXAMPLES
|
||||
|
||||
|
||||
static void event_cb(lv_obj_t * chart, lv_event_t e)
|
||||
static void event_cb(lv_event_t * e)
|
||||
{
|
||||
if(e == LV_EVENT_VALUE_CHANGED) {
|
||||
lv_event_code_t code = lv_event_get_code(e);
|
||||
lv_obj_t * chart = lv_event_get_target(e);
|
||||
|
||||
if(code == LV_EVENT_VALUE_CHANGED) {
|
||||
lv_obj_invalidate(chart);
|
||||
}
|
||||
if(e == LV_EVENT_REFR_EXT_DRAW_SIZE) {
|
||||
lv_coord_t * s = lv_event_get_param();
|
||||
if(code == LV_EVENT_REFR_EXT_DRAW_SIZE) {
|
||||
lv_coord_t * s = lv_event_get_param(e);
|
||||
*s = LV_MAX(*s, 20);
|
||||
}
|
||||
else if(e == LV_EVENT_DRAW_POST_END) {
|
||||
else if(code == LV_EVENT_DRAW_POST_END) {
|
||||
int32_t id = lv_chart_get_pressed_point(chart);
|
||||
if(id == LV_CHART_POINT_NONE) return;
|
||||
|
||||
@@ -42,7 +45,7 @@ static void event_cb(lv_obj_t * chart, lv_event_t e)
|
||||
a.y1 = chart->coords.y1 + p.y - 30;
|
||||
a.y2 = chart->coords.y1 + p.y - 10;
|
||||
|
||||
const lv_area_t * clip_area = lv_event_get_param();
|
||||
const lv_area_t * clip_area = lv_event_get_param(e);
|
||||
lv_draw_rect(&a, clip_area, &draw_rect_dsc);
|
||||
|
||||
ser = lv_chart_get_series_next(chart, ser);
|
||||
|
||||
@@ -46,17 +46,21 @@ static const lv_coord_t ecg_sample[] = {
|
||||
70, 74, 76, 79, 82, 79, 75, 62,
|
||||
};
|
||||
|
||||
static void slider_x_event_cb(lv_obj_t * obj, lv_event_t e)
|
||||
static void slider_x_event_cb(lv_event_t * e)
|
||||
{
|
||||
if(e == LV_EVENT_VALUE_CHANGED) {
|
||||
lv_event_code_t code = lv_event_get_code(e);
|
||||
lv_obj_t * obj = lv_event_get_target(e);
|
||||
if(code == LV_EVENT_VALUE_CHANGED) {
|
||||
int32_t v = lv_slider_get_value(obj);
|
||||
lv_chart_set_zoom_x(chart, v);
|
||||
}
|
||||
}
|
||||
|
||||
static void slider_y_event_cb(lv_obj_t * obj, lv_event_t e)
|
||||
static void slider_y_event_cb(lv_event_t * e)
|
||||
{
|
||||
if(e == LV_EVENT_VALUE_CHANGED) {
|
||||
lv_event_code_t code = lv_event_get_code(e);
|
||||
lv_obj_t * obj = lv_event_get_target(e);
|
||||
if(code == LV_EVENT_VALUE_CHANGED) {
|
||||
lv_chart_set_zoom_y(chart, lv_slider_get_value(obj));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,10 +5,13 @@ static lv_obj_t * chart;
|
||||
static lv_chart_series_t * ser;
|
||||
static lv_chart_cursor_t * cursor;
|
||||
|
||||
static void event_cb(lv_obj_t * obj, lv_event_t e)
|
||||
static void event_cb(lv_event_t * e)
|
||||
{
|
||||
static int32_t last_id = -1;
|
||||
if(e == LV_EVENT_VALUE_CHANGED) {
|
||||
lv_event_code_t code = lv_event_get_code(e);
|
||||
lv_obj_t * obj = lv_event_get_target(e);
|
||||
|
||||
if(code == LV_EVENT_VALUE_CHANGED) {
|
||||
last_id = lv_chart_get_pressed_point(obj);
|
||||
if(last_id != LV_CHART_POINT_NONE) {
|
||||
lv_point_t p;
|
||||
@@ -16,8 +19,8 @@ static void event_cb(lv_obj_t * obj, lv_event_t e)
|
||||
lv_chart_set_cursor_point(obj, cursor, &p);
|
||||
}
|
||||
}
|
||||
else if(e == LV_EVENT_DRAW_PART_END) {
|
||||
lv_obj_draw_dsc_t * dsc = lv_event_get_param();
|
||||
else if(code == LV_EVENT_DRAW_PART_END) {
|
||||
lv_obj_draw_dsc_t * dsc = lv_event_get_param(e);
|
||||
if(dsc->part == LV_PART_CURSOR && dsc->p1 && dsc->p2 && dsc->p1->y == dsc->p2->y && last_id >= 0) {
|
||||
lv_coord_t * data_array = lv_chart_get_array(chart, ser);
|
||||
lv_coord_t v = data_array[last_id];
|
||||
|
||||
@@ -1,9 +1,11 @@
|
||||
#include "../../lv_examples.h"
|
||||
#if LV_USE_CHECKBOX && LV_BUILD_EXAMPLES
|
||||
|
||||
static void event_handler(lv_obj_t * obj, lv_event_t event)
|
||||
static void event_handler(lv_event_t * e)
|
||||
{
|
||||
if(event == LV_EVENT_VALUE_CHANGED) {
|
||||
lv_event_code_t code = lv_event_get_code(e);
|
||||
lv_obj_t * obj = lv_event_get_target(e);
|
||||
if(code == LV_EVENT_VALUE_CHANGED) {
|
||||
const char * txt = lv_checkbox_get_text(obj);
|
||||
const char * state = lv_obj_get_state(obj) & LV_STATE_CHECKED ? "Checked" : "Unchecked";
|
||||
LV_LOG_USER("%s: %s\n", txt, state);
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
#include "../../lv_examples.h"
|
||||
#if LV_USE_DROPDOWN && LV_BUILD_EXAMPLES
|
||||
|
||||
static void event_handler(lv_obj_t * obj, lv_event_t event)
|
||||
static void event_handler(lv_event_t * e)
|
||||
{
|
||||
if(event == LV_EVENT_VALUE_CHANGED) {
|
||||
#if LV_USE_LOG /*To avoid warnings if LV_LOG_USER is empty*/
|
||||
lv_event_code_t code = lv_event_get_code(e);
|
||||
lv_obj_t * obj = lv_event_get_target(e);
|
||||
if(code == LV_EVENT_VALUE_CHANGED) {
|
||||
char buf[32];
|
||||
lv_dropdown_get_selected_str(obj, buf, sizeof(buf));
|
||||
LV_LOG_USER("Option: %s", buf);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,9 +1,11 @@
|
||||
#include "../../lv_examples.h"
|
||||
#if LV_USE_DROPDOWN && LV_BUILD_EXAMPLES
|
||||
|
||||
static void event_cb(lv_obj_t * dropdown, lv_event_t e)
|
||||
static void event_cb(lv_event_t * e)
|
||||
{
|
||||
if(e == LV_EVENT_VALUE_CHANGED) {
|
||||
lv_event_code_t code = lv_event_get_code(e);
|
||||
lv_obj_t * dropdown = lv_event_get_target(e);
|
||||
if(code == LV_EVENT_VALUE_CHANGED) {
|
||||
char buf[64];
|
||||
lv_dropdown_get_selected_str(dropdown, buf, sizeof(buf));
|
||||
LV_LOG_USER("'%s' is selected", buf);
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
#if LV_USE_IMG && LV_USE_SLIDER && LV_BUILD_EXAMPLES
|
||||
|
||||
static lv_obj_t * create_slider(lv_color_t color);
|
||||
static void slider_event_cb(lv_obj_t * slider, lv_event_t event);
|
||||
static void slider_event_cb(lv_event_t * e);
|
||||
|
||||
static lv_obj_t * red_slider, * green_slider, * blue_slider, * intense_slider;
|
||||
static lv_obj_t * img1;
|
||||
@@ -38,11 +38,11 @@ void lv_example_img_2(void)
|
||||
lv_event_send(intense_slider, LV_EVENT_VALUE_CHANGED, NULL);
|
||||
}
|
||||
|
||||
static void slider_event_cb(lv_obj_t * slider, lv_event_t event)
|
||||
static void slider_event_cb(lv_event_t * e)
|
||||
{
|
||||
LV_UNUSED(slider);
|
||||
|
||||
if(event == LV_EVENT_VALUE_CHANGED) {
|
||||
lv_event_code_t code = lv_event_get_code(e);
|
||||
if(code == LV_EVENT_VALUE_CHANGED) {
|
||||
/*Recolor the image based on the sliders' values*/
|
||||
lv_color_t color = lv_color_make(lv_slider_get_value(red_slider), lv_slider_get_value(green_slider), lv_slider_get_value(blue_slider));
|
||||
lv_opa_t intense = lv_slider_get_value(intense_slider);
|
||||
|
||||
@@ -1,15 +1,17 @@
|
||||
#include "../../lv_examples.h"
|
||||
#if LV_USE_KEYBOARD && LV_BUILD_EXAMPLES
|
||||
|
||||
static void ta_event_cb(lv_obj_t * ta, lv_event_t e)
|
||||
static void ta_event_cb(lv_event_t * e)
|
||||
{
|
||||
lv_obj_t * kb = lv_event_get_user_data();
|
||||
if(e == LV_EVENT_FOCUSED) {
|
||||
lv_event_code_t code = lv_event_get_code(e);
|
||||
lv_obj_t * ta = lv_event_get_target(e);
|
||||
lv_obj_t * kb = lv_event_get_user_data(e);
|
||||
if(code == LV_EVENT_FOCUSED) {
|
||||
lv_keyboard_set_textarea(kb, ta);
|
||||
lv_obj_clear_flag(kb, LV_OBJ_FLAG_HIDDEN);
|
||||
}
|
||||
|
||||
if(e == LV_EVENT_DEFOCUSED) {
|
||||
if(code == LV_EVENT_DEFOCUSED) {
|
||||
lv_keyboard_set_textarea(kb, NULL);
|
||||
lv_obj_add_flag(kb, LV_OBJ_FLAG_HIDDEN);
|
||||
}
|
||||
|
||||
@@ -2,9 +2,11 @@
|
||||
#if LV_USE_LIST && LV_BUILD_EXAMPLES
|
||||
static lv_obj_t * list1;
|
||||
|
||||
static void event_handler(lv_obj_t * obj, lv_event_t event)
|
||||
static void event_handler(lv_event_t * e)
|
||||
{
|
||||
if(event == LV_EVENT_CLICKED) {
|
||||
lv_event_code_t code = lv_event_get_code(e);
|
||||
lv_obj_t * obj = lv_event_get_target(e);
|
||||
if(code == LV_EVENT_CLICKED) {
|
||||
LV_LOG_USER("Clicked: %s", lv_list_get_btn_text(list1, obj));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,9 +1,11 @@
|
||||
#include "../../lv_examples.h"
|
||||
#if LV_USE_MSGBOX && LV_BUILD_EXAMPLES
|
||||
|
||||
static void event_cb(lv_obj_t * obj, lv_event_t event)
|
||||
static void event_cb(lv_event_t * e)
|
||||
{
|
||||
if(event == LV_EVENT_VALUE_CHANGED) {
|
||||
lv_event_code_t code = lv_event_get_code(e);
|
||||
lv_obj_t * obj = lv_event_get_target(e);
|
||||
if(code == LV_EVENT_VALUE_CHANGED) {
|
||||
LV_LOG_USER("Button %s clicked", lv_msgbox_get_active_btn_text(obj));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,9 +1,11 @@
|
||||
#include "../../lv_examples.h"
|
||||
#if LV_USE_ROLLER && LV_BUILD_EXAMPLES
|
||||
|
||||
static void event_handler(lv_obj_t * obj, lv_event_t event)
|
||||
static void event_handler(lv_event_t * e)
|
||||
{
|
||||
if(event == LV_EVENT_VALUE_CHANGED) {
|
||||
lv_event_code_t code = lv_event_get_code(e);
|
||||
lv_obj_t * obj = lv_event_get_target(e);
|
||||
if(code == LV_EVENT_VALUE_CHANGED) {
|
||||
char buf[32];
|
||||
lv_roller_get_selected_str(obj, buf, sizeof(buf));
|
||||
LV_LOG_USER("Selected month: %s\n", buf);
|
||||
|
||||
@@ -1,9 +1,11 @@
|
||||
#include "../../lv_examples.h"
|
||||
#if LV_USE_ROLLER && LV_FONT_MONTSERRAT_22 && LV_BUILD_EXAMPLES
|
||||
|
||||
static void event_handler(lv_obj_t * obj, lv_event_t event)
|
||||
static void event_handler(lv_event_t * e)
|
||||
{
|
||||
if(event == LV_EVENT_VALUE_CHANGED) {
|
||||
lv_event_code_t code = lv_event_get_code(e);
|
||||
lv_obj_t * obj = lv_event_get_target(e);
|
||||
if(code == LV_EVENT_VALUE_CHANGED) {
|
||||
char buf[32];
|
||||
lv_roller_get_selected_str(obj, buf, sizeof(buf));
|
||||
LV_LOG_USER("Selected value: %s\n", buf);
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#include "../../lv_examples.h"
|
||||
#if LV_USE_SLIDER && LV_BUILD_EXAMPLES
|
||||
|
||||
static void slider_event_cb(lv_obj_t * slider, lv_event_t event);
|
||||
static void slider_event_cb(lv_event_t * e);
|
||||
static lv_obj_t * slider_label;
|
||||
|
||||
/**
|
||||
@@ -21,9 +21,11 @@ void lv_example_slider_1(void)
|
||||
lv_obj_align_to(slider_label, slider, LV_ALIGN_OUT_BOTTOM_MID, 0, 10);
|
||||
}
|
||||
|
||||
static void slider_event_cb(lv_obj_t * slider, lv_event_t event)
|
||||
static void slider_event_cb(lv_event_t * e)
|
||||
{
|
||||
if(event == LV_EVENT_VALUE_CHANGED) {
|
||||
lv_event_code_t code = lv_event_get_code(e);
|
||||
lv_obj_t * slider = lv_event_get_target(e);
|
||||
if(code == LV_EVENT_VALUE_CHANGED) {
|
||||
char buf[8];
|
||||
lv_snprintf(buf, sizeof(buf), "%d%%", lv_slider_get_value(slider));
|
||||
lv_label_set_text(slider_label, buf);
|
||||
|
||||
@@ -31,7 +31,7 @@ void lv_example_slider_2(void)
|
||||
//
|
||||
//static void slider_event_cb(lv_obj_t * slider, lv_event_t event)
|
||||
//{
|
||||
// if(event == LV_EVENT_VALUE_CHANGED) {
|
||||
// if(code == LV_EVENT_VALUE_CHANGED) {
|
||||
// static char buf[8];
|
||||
// lv_snprintf(buf, sizeof(buf), "%u", lv_slider_get_value(slider));
|
||||
// lv_obj_set_style_content_text(slider, LV_PART_KNOB, LV_STATE_DEFAULT, buf);
|
||||
|
||||
@@ -29,7 +29,7 @@ void lv_example_slider_3(void)
|
||||
//
|
||||
//static void slider_event_cb(lv_obj_t * slider, lv_event_t event)
|
||||
//{
|
||||
// if(event == LV_EVENT_VALUE_CHANGED) {
|
||||
// if(code == LV_EVENT_VALUE_CHANGED) {
|
||||
// static char buf[8];
|
||||
// lv_snprintf(buf, sizeof(buf), "%d - %d", lv_slider_get_value(slider), lv_slider_get_left_value(slider));
|
||||
// lv_obj_set_style_content_text(slider, LV_PART_INDICATOR, LV_STATE_DEFAULT, buf);
|
||||
|
||||
@@ -4,18 +4,18 @@
|
||||
static lv_obj_t * spinbox;
|
||||
|
||||
|
||||
static void lv_spinbox_increment_event_cb(lv_obj_t * btn, lv_event_t e)
|
||||
static void lv_spinbox_increment_event_cb(lv_event_t * e)
|
||||
{
|
||||
LV_UNUSED(btn);
|
||||
if(e == LV_EVENT_SHORT_CLICKED || e == LV_EVENT_LONG_PRESSED_REPEAT) {
|
||||
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_obj_t * btn, lv_event_t e)
|
||||
static void lv_spinbox_decrement_event_cb(lv_event_t * e)
|
||||
{
|
||||
LV_UNUSED(btn);
|
||||
if(e == LV_EVENT_SHORT_CLICKED || e == LV_EVENT_LONG_PRESSED_REPEAT) {
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,9 +1,11 @@
|
||||
#include "../../lv_examples.h"
|
||||
#if LV_USE_SWITCH && LV_BUILD_EXAMPLES
|
||||
|
||||
static void event_handler(lv_obj_t * obj, lv_event_t event)
|
||||
static void event_handler(lv_event_t * e)
|
||||
{
|
||||
if(event == LV_EVENT_VALUE_CHANGED) {
|
||||
lv_event_code_t code = lv_event_get_code(e);
|
||||
lv_obj_t * obj = lv_event_get_target(e);
|
||||
if(code == LV_EVENT_VALUE_CHANGED) {
|
||||
LV_LOG_USER("State: %s\n", lv_obj_has_state(obj, LV_STATE_CHECKED) ? "On" : "Off");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,10 +1,12 @@
|
||||
#include "../../lv_examples.h"
|
||||
#if LV_USE_TABLE && LV_BUILD_EXAMPLES
|
||||
|
||||
static void event_cb(lv_obj_t * obj, lv_event_t e)
|
||||
static void event_cb(lv_event_t * e)
|
||||
{
|
||||
if(e == LV_EVENT_DRAW_PART_BEGIN) {
|
||||
lv_obj_draw_dsc_t * dsc = lv_event_get_param();
|
||||
lv_event_code_t code = lv_event_get_code(e);
|
||||
lv_obj_t * obj = lv_event_get_target(e);
|
||||
if(code == LV_EVENT_DRAW_PART_BEGIN) {
|
||||
lv_obj_draw_dsc_t * dsc = lv_event_get_param(e);
|
||||
/*If the cells are drawn...*/
|
||||
if(dsc->part == LV_PART_ITEMS) {
|
||||
uint32_t row = dsc->id / lv_table_get_col_cnt(obj);
|
||||
|
||||
@@ -3,10 +3,12 @@
|
||||
|
||||
#define ITEM_CNT 200
|
||||
|
||||
static void event_cb(lv_obj_t * obj, lv_event_t e)
|
||||
static void event_cb(lv_event_t * e)
|
||||
{
|
||||
if(e == LV_EVENT_DRAW_PART_END) {
|
||||
lv_obj_draw_dsc_t * dsc = lv_event_get_param();
|
||||
lv_event_code_t code = lv_event_get_code(e);
|
||||
lv_obj_t * obj = lv_event_get_target(e);
|
||||
if(code == LV_EVENT_DRAW_PART_END) {
|
||||
lv_obj_draw_dsc_t * dsc = lv_event_get_param(e);
|
||||
/*If the cells are drawn...*/
|
||||
if(dsc->part == LV_PART_ITEMS) {
|
||||
bool chk = lv_table_has_cell_ctrl(obj, dsc->id, 0, LV_TABLE_CELL_CTRL_CUSTOM_1);
|
||||
@@ -36,7 +38,7 @@ static void event_cb(lv_obj_t * obj, lv_event_t e)
|
||||
lv_draw_rect(&sw_area, dsc->clip_area, &rect_dsc);
|
||||
}
|
||||
}
|
||||
else if(e == LV_EVENT_VALUE_CHANGED) {
|
||||
else if(code == LV_EVENT_VALUE_CHANGED) {
|
||||
uint16_t col;
|
||||
uint16_t row;
|
||||
lv_table_get_selected_cell(obj, &row, &col);
|
||||
|
||||
@@ -2,10 +2,12 @@
|
||||
#if LV_USE_TEXTAREA && LV_BUILD_EXAMPLES
|
||||
|
||||
|
||||
static void btnm_event_handler(lv_obj_t * obj, lv_event_t event)
|
||||
static void btnm_event_handler(lv_event_t * e)
|
||||
{
|
||||
if(event == LV_EVENT_VALUE_CHANGED) {
|
||||
lv_obj_t * ta = lv_event_get_user_data();
|
||||
lv_event_code_t code = lv_event_get_code(e);
|
||||
lv_obj_t * obj = lv_event_get_target(e);
|
||||
if(code == LV_EVENT_VALUE_CHANGED) {
|
||||
lv_obj_t * ta = lv_event_get_user_data(e);
|
||||
const char * txt = lv_btnmatrix_get_btn_text(obj, lv_btnmatrix_get_selected_btn(obj));
|
||||
|
||||
if(strcmp(txt, LV_SYMBOL_BACKSPACE) == 0) lv_textarea_del_char(ta);
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#include "../../lv_examples.h"
|
||||
#if LV_USE_TEXTAREA && LV_USE_KEYBOARD && LV_BUILD_EXAMPLES
|
||||
|
||||
static void ta_event_cb(lv_obj_t * ta, lv_event_t event);
|
||||
static void ta_event_cb(lv_event_t * e);
|
||||
|
||||
static lv_obj_t * kb;
|
||||
|
||||
@@ -39,16 +39,18 @@ void lv_example_textarea_2(void)
|
||||
lv_keyboard_set_textarea(kb, pwd_ta); /*Focus it on one of the text areas to start*/
|
||||
}
|
||||
|
||||
static void ta_event_cb(lv_obj_t * ta, lv_event_t event)
|
||||
static void ta_event_cb(lv_event_t * e)
|
||||
{
|
||||
if(event == LV_EVENT_CLICKED) {
|
||||
lv_event_code_t code = lv_event_get_code(e);
|
||||
lv_obj_t * ta = lv_event_get_target(e);
|
||||
if(code == LV_EVENT_CLICKED) {
|
||||
/*Focus on the clicked text area*/
|
||||
if(kb != NULL)
|
||||
lv_keyboard_set_textarea(kb, ta);
|
||||
}
|
||||
|
||||
else if(event == LV_EVENT_INSERT) {
|
||||
const char * str = lv_event_get_param();
|
||||
else if(code == LV_EVENT_INSERT) {
|
||||
const char * str = lv_event_get_param(e);
|
||||
if(str[0] == '\n') {
|
||||
LV_LOG_USER("Ready\n");
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#include "../../lv_examples.h"
|
||||
#if LV_USE_TEXTAREA && LV_USE_KEYBOARD && LV_BUILD_EXAMPLES
|
||||
|
||||
static void ta_event_cb(lv_obj_t * ta, lv_event_t event);
|
||||
static void ta_event_cb(lv_event_t * e);
|
||||
|
||||
static lv_obj_t * kb;
|
||||
|
||||
@@ -26,9 +26,11 @@ void lv_example_textarea_3(void)
|
||||
lv_keyboard_set_textarea(kb, ta);
|
||||
}
|
||||
|
||||
static void ta_event_cb(lv_obj_t * ta, lv_event_t event)
|
||||
static void ta_event_cb(lv_event_t * e)
|
||||
{
|
||||
if(event == LV_EVENT_VALUE_CHANGED) {
|
||||
lv_event_code_t code = lv_event_get_code(e);
|
||||
lv_obj_t * ta = lv_event_get_target(e);
|
||||
if(code == LV_EVENT_VALUE_CHANGED) {
|
||||
const char * txt = lv_textarea_get_text(ta);
|
||||
if(txt[0] >= '0' && txt[0] <= '9' &&
|
||||
txt[1] >= '0' && txt[1] <= '9' &&
|
||||
|
||||
@@ -2,9 +2,11 @@
|
||||
#if LV_USE_WIN && LV_BUILD_EXAMPLES
|
||||
|
||||
|
||||
static void event_handler(lv_obj_t * obj, lv_event_t event)
|
||||
static void event_handler(lv_event_t * e)
|
||||
{
|
||||
if(event == LV_EVENT_CLICKED) {
|
||||
lv_event_code_t code = lv_event_get_code(e);
|
||||
lv_obj_t * obj = lv_event_get_target(e);
|
||||
if(code == LV_EVENT_CLICKED) {
|
||||
LV_LOG_USER("Button %d clicked", lv_obj_get_child_id(obj));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user