1 /**
2 * @file lv_btn.c
3 *
4 */
5
6 /*********************
7 * INCLUDES
8 *********************/
9
10 #include "lv_button_private.h"
11 #include "../../core/lv_obj_class_private.h"
12 #if LV_USE_BUTTON != 0
13
14 /*********************
15 * DEFINES
16 *********************/
17 #define MY_CLASS (&lv_button_class)
18
19 /**********************
20 * TYPEDEFS
21 **********************/
22
23 /**********************
24 * STATIC PROTOTYPES
25 **********************/
26 static void lv_button_constructor(const lv_obj_class_t * class_p, lv_obj_t * obj);
27
28 /**********************
29 * STATIC VARIABLES
30 **********************/
31 const lv_obj_class_t lv_button_class = {
32 .constructor_cb = lv_button_constructor,
33 .width_def = LV_SIZE_CONTENT,
34 .height_def = LV_SIZE_CONTENT,
35 .group_def = LV_OBJ_CLASS_GROUP_DEF_TRUE,
36 .instance_size = sizeof(lv_button_t),
37 .base_class = &lv_obj_class,
38 .name = "btn",
39 };
40
41 /**********************
42 * MACROS
43 **********************/
44
45 /**********************
46 * GLOBAL FUNCTIONS
47 **********************/
48
lv_button_create(lv_obj_t * parent)49 lv_obj_t * lv_button_create(lv_obj_t * parent)
50 {
51 LV_LOG_INFO("begin");
52 lv_obj_t * obj = lv_obj_class_create_obj(MY_CLASS, parent);
53 lv_obj_class_init_obj(obj);
54 return obj;
55 }
56
57 /**********************
58 * STATIC FUNCTIONS
59 **********************/
60
lv_button_constructor(const lv_obj_class_t * class_p,lv_obj_t * obj)61 static void lv_button_constructor(const lv_obj_class_t * class_p, lv_obj_t * obj)
62 {
63 LV_UNUSED(class_p);
64 LV_TRACE_OBJ_CREATE("begin");
65
66 lv_obj_remove_flag(obj, LV_OBJ_FLAG_SCROLLABLE);
67 lv_obj_add_flag(obj, LV_OBJ_FLAG_SCROLL_ON_FOCUS);
68
69 LV_TRACE_OBJ_CREATE("finished");
70 }
71
72 #endif
73