summaryrefslogtreecommitdiff
path: root/shared-bindings/displayio/Group.c
diff options
context:
space:
mode:
authorScott Shawcroft <scott@tannewt.org>2019-08-27 16:03:05 -0700
committerScott Shawcroft <scott@tannewt.org>2019-09-03 16:15:27 -0700
commit949f8761b8c41ecbf8660bcd5a333890a37e426e (patch)
tree850cc67d0aa4c91414552292be63b5202215b608 /shared-bindings/displayio/Group.c
parente92b5f7e3e16fc118929f373366ca79519ab1182 (diff)
Add .hidden to TileGrid and Group
This allows for one to preserve ordering within a Group while hiding something temporarily. Fixes #1688
Diffstat (limited to 'shared-bindings/displayio/Group.c')
-rw-r--r--shared-bindings/displayio/Group.c27
1 files changed, 27 insertions, 0 deletions
diff --git a/shared-bindings/displayio/Group.c b/shared-bindings/displayio/Group.c
index 5a35424ce..dd7600eb9 100644
--- a/shared-bindings/displayio/Group.c
+++ b/shared-bindings/displayio/Group.c
@@ -90,6 +90,32 @@ displayio_group_t* native_group(mp_obj_t group_obj) {
return MP_OBJ_TO_PTR(native_group);
}
+//| .. attribute:: hidden
+//|
+//| True when the Group and all of it's layers are not visible. When False, the Group's layers
+//| are visible if they haven't been hidden.
+//|
+STATIC mp_obj_t displayio_group_obj_get_hidden(mp_obj_t self_in) {
+ displayio_group_t *self = native_group(self_in);
+ return mp_obj_new_bool(common_hal_displayio_group_get_hidden(self));
+}
+MP_DEFINE_CONST_FUN_OBJ_1(displayio_group_get_hidden_obj, displayio_group_obj_get_hidden);
+
+STATIC mp_obj_t displayio_group_obj_set_hidden(mp_obj_t self_in, mp_obj_t hidden_obj) {
+ displayio_group_t *self = native_group(self_in);
+
+ common_hal_displayio_group_set_hidden(self, mp_obj_is_true(hidden_obj));
+ return mp_const_none;
+}
+MP_DEFINE_CONST_FUN_OBJ_2(displayio_group_set_hidden_obj, displayio_group_obj_set_hidden);
+
+const mp_obj_property_t displayio_group_hidden_obj = {
+ .base.type = &mp_type_property,
+ .proxy = {(mp_obj_t)&displayio_group_get_hidden_obj,
+ (mp_obj_t)&displayio_group_set_hidden_obj,
+ (mp_obj_t)&mp_const_none_obj},
+};
+
//| .. attribute:: scale
//|
//| Scales each pixel within the Group in both directions. For example, when scale=2 each pixel
@@ -305,6 +331,7 @@ STATIC mp_obj_t group_subscr(mp_obj_t self_in, mp_obj_t index_obj, mp_obj_t valu
}
STATIC const mp_rom_map_elem_t displayio_group_locals_dict_table[] = {
+ { MP_ROM_QSTR(MP_QSTR_hidden), MP_ROM_PTR(&displayio_group_hidden_obj) },
{ MP_ROM_QSTR(MP_QSTR_scale), MP_ROM_PTR(&displayio_group_scale_obj) },
{ MP_ROM_QSTR(MP_QSTR_x), MP_ROM_PTR(&displayio_group_x_obj) },
{ MP_ROM_QSTR(MP_QSTR_y), MP_ROM_PTR(&displayio_group_y_obj) },