diff --git a/lv_objx/lv_win.c b/lv_objx/lv_win.c index ebd4404b8..940a85a48 100644 --- a/lv_objx/lv_win.c +++ b/lv_objx/lv_win.c @@ -299,6 +299,18 @@ void lv_win_set_style(lv_obj_t * win, lv_win_style_t type, lv_style_t * style) } } +/** + * Set drag status of a window. If set to 'true' window can be dragged like on a PC. + * @param win pointer to a window object + * @param drag_en whether dragging is enabled + */ +void lv_win_set_drag(lv_obj_t *win, bool drag_en) +{ + lv_win_ext_t * ext = lv_obj_get_ext_attr(win); + lv_obj_t * win_header = ext->header; + lv_obj_set_drag_parent(win_header, drag_en); + lv_obj_set_drag(win, drag_en); +} /*===================== * Getter functions diff --git a/lv_objx/lv_win.h b/lv_objx/lv_win.h index 158c93ae9..915f2c174 100644 --- a/lv_objx/lv_win.h +++ b/lv_objx/lv_win.h @@ -157,6 +157,12 @@ void lv_win_set_sb_mode(lv_obj_t *win, lv_sb_mode_t sb_mode); */ void lv_win_set_style(lv_obj_t *win, lv_win_style_t type, lv_style_t *style); +/** + * Set drag status of a window. If set to 'true' window can be dragged like on a PC. + * @param win pointer to a window object + * @param drag_en whether dragging is enabled + */ +void lv_win_set_drag(lv_obj_t *win, bool drag_en); /*===================== * Getter functions @@ -220,6 +226,16 @@ lv_coord_t lv_win_get_width(lv_obj_t * win); */ lv_style_t * lv_win_get_style(const lv_obj_t *win, lv_win_style_t type); +/** + * Get drag status of a window. If set to 'true' window can be dragged like on a PC. + * @param win pointer to a window object + * @return whether window is draggable + */ +static inline bool lv_win_get_drag(const lv_obj_t *win) +{ + return lv_obj_get_drag(win); +} + /*===================== * Other functions *====================*/