From fe5e80529a2666b4a036e6361ebdba36e94d41a8 Mon Sep 17 00:00:00 2001 From: fvanroie <15969459+fvanroie@users.noreply.github.com> Date: Mon, 25 Jan 2021 23:49:10 +0100 Subject: [PATCH] Add .to_front and .to_back --- src/hasp/hasp_attribute.cpp | 28 +++++++++++++++++++++------- src/hasp/hasp_attribute.h | 4 ++++ 2 files changed, 25 insertions(+), 7 deletions(-) diff --git a/src/hasp/hasp_attribute.cpp b/src/hasp/hasp_attribute.cpp index 02474977..93ba3207 100644 --- a/src/hasp/hasp_attribute.cpp +++ b/src/hasp/hasp_attribute.cpp @@ -1779,13 +1779,6 @@ void hasp_process_obj_attribute(lv_obj_t * obj, const char * attr_p, const char } break; // attribute_found - case ATTR_DELETE: - if(obj->user_data.id == 0) { - return Log.error(TAG_ATTR, F("Unable to delete a page")); - } - lv_obj_del_async(obj); - break; // attribute_found - case ATTR_RED: // TODO: remove temp RED if(check_obj_type(obj, LV_HASP_BTNMATRIX)) { my_btnmatrix_map_clear(obj); // TODO : remove this test property @@ -1802,6 +1795,27 @@ void hasp_process_obj_attribute(lv_obj_t * obj, const char * attr_p, const char } break; // attribute_found + case ATTR_DELETE: + if(!lv_obj_get_parent(obj)) { + return Log.error(TAG_ATTR, F("Unable to call %s on a page"), attr_p); + } + lv_obj_del_async(obj); + break; // attribute_found + + case ATTR_TO_FRONT: + if(!lv_obj_get_parent(obj)) { + return Log.error(TAG_ATTR, F("Unable to call %s on a page"), attr_p); + } + lv_obj_move_foreground(obj); + break; // attribute_found + + case ATTR_TO_BACK: + if(!lv_obj_get_parent(obj)) { + return Log.error(TAG_ATTR, F("Unable to call %s on a page"), attr_p); + } + lv_obj_move_background(obj); + break; // attribute_found + default: hasp_local_style_attr(obj, attr, attr_hash, payload, update); } diff --git a/src/hasp/hasp_attribute.h b/src/hasp/hasp_attribute.h index c50fddd0..33023b5e 100644 --- a/src/hasp/hasp_attribute.h +++ b/src/hasp/hasp_attribute.h @@ -275,7 +275,11 @@ _HASP_ATTRIBUTE(SCALE_END_LINE_WIDTH, scale_end_line_width, lv_style_int_t) #define ATTR_TXT 9328 #define ATTR_SRC 4964 #define ATTR_ID 6715 + +// methods #define ATTR_DELETE 50027 +#define ATTR_TO_FRONT 44741 +#define ATTR_TO_BACK 24555 // Gauge #define ATTR_CRITICAL_VALUE 39281