2021-04-08 13:07:48 +02:00
|
|
|
#include "../../lv_examples.h"
|
2021-02-14 14:56:34 +01:00
|
|
|
#if LV_USE_SPINBOX && LV_BUILD_EXAMPLES
|
2021-02-08 09:53:03 +01:00
|
|
|
|
|
|
|
static lv_obj_t * spinbox;
|
|
|
|
|
|
|
|
|
|
|
|
static void lv_spinbox_increment_event_cb(lv_obj_t * btn, lv_event_t e)
|
|
|
|
{
|
2021-02-14 22:07:38 +01:00
|
|
|
LV_UNUSED(btn);
|
2021-02-08 09:53:03 +01:00
|
|
|
if(e == LV_EVENT_SHORT_CLICKED || e == LV_EVENT_LONG_PRESSED_REPEAT) {
|
|
|
|
lv_spinbox_increment(spinbox);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void lv_spinbox_decrement_event_cb(lv_obj_t * btn, lv_event_t e)
|
|
|
|
{
|
2021-02-14 22:07:38 +01:00
|
|
|
LV_UNUSED(btn);
|
2021-02-08 09:53:03 +01:00
|
|
|
if(e == LV_EVENT_SHORT_CLICKED || e == LV_EVENT_LONG_PRESSED_REPEAT) {
|
|
|
|
lv_spinbox_decrement(spinbox);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void lv_example_spinbox_1(void)
|
|
|
|
{
|
|
|
|
spinbox = lv_spinbox_create(lv_scr_act());
|
|
|
|
lv_spinbox_set_range(spinbox, -1000, 25000);
|
|
|
|
lv_spinbox_set_digit_format(spinbox, 5, 2);
|
|
|
|
lv_spinbox_step_prev(spinbox);
|
|
|
|
lv_obj_set_width(spinbox, 100);
|
2021-03-25 16:14:17 +01:00
|
|
|
lv_obj_center(spinbox);
|
2021-02-08 09:53:03 +01:00
|
|
|
|
|
|
|
lv_coord_t h = lv_obj_get_height(spinbox);
|
|
|
|
|
2021-03-25 13:36:50 +01:00
|
|
|
lv_obj_t * btn = lv_btn_create(lv_scr_act());
|
2021-02-08 09:53:03 +01:00
|
|
|
lv_obj_set_size(btn, h, h);
|
2021-03-25 16:14:17 +01:00
|
|
|
lv_obj_align_to(btn, spinbox, LV_ALIGN_OUT_RIGHT_MID, 5, 0);
|
2021-03-31 19:57:14 +02:00
|
|
|
lv_obj_set_style_bg_img_src(btn, LV_SYMBOL_PLUS, 0);
|
2021-02-08 09:53:03 +01:00
|
|
|
lv_obj_add_event_cb(btn, lv_spinbox_increment_event_cb, NULL);
|
|
|
|
|
2021-03-25 13:36:50 +01:00
|
|
|
btn = lv_btn_create(lv_scr_act());
|
2021-02-08 09:53:03 +01:00
|
|
|
lv_obj_set_size(btn, h, h);
|
2021-03-25 16:14:17 +01:00
|
|
|
lv_obj_align_to(btn, spinbox, LV_ALIGN_OUT_LEFT_MID, -5, 0);
|
2021-03-31 19:57:14 +02:00
|
|
|
lv_obj_set_style_bg_img_src(btn, LV_SYMBOL_MINUS, 0);
|
2021-02-08 09:53:03 +01:00
|
|
|
lv_obj_add_event_cb(btn, lv_spinbox_decrement_event_cb, NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|