|
|
|
@ -12,11 +12,10 @@ |
|
|
|
|
|
|
|
|
|
struct Priv { |
|
|
|
|
int32_t number; |
|
|
|
|
Scene_deinit_t parent_deinit; |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
static struct SceneEvent onSelect(struct MenuScene *self) { |
|
|
|
|
struct Priv *priv = self->private; |
|
|
|
|
struct Priv *priv = self->extra; |
|
|
|
|
|
|
|
|
|
if (self->selected == 0) { |
|
|
|
|
return SceneEvent_Close(0, NULL); |
|
|
|
@ -46,19 +45,15 @@ static struct SceneEvent onSelect(struct MenuScene *self) { |
|
|
|
|
return SceneEvent_None(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
static void deinit(struct MenuScene *self) |
|
|
|
|
static void priv_deinit(struct MenuScene *self) |
|
|
|
|
{ |
|
|
|
|
struct Priv *priv = self->private; |
|
|
|
|
if (priv->parent_deinit) { |
|
|
|
|
priv->parent_deinit((struct Scene *) self); |
|
|
|
|
} |
|
|
|
|
free(self->private); |
|
|
|
|
self->private = NULL; |
|
|
|
|
free(self->extra); |
|
|
|
|
self->extra = NULL; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
static struct SceneEvent onChildReturn(struct MenuScene *self, uint32_t tag, int32_t status, void *data) |
|
|
|
|
{ |
|
|
|
|
struct Priv *priv = self->private; |
|
|
|
|
struct Priv *priv = self->extra; |
|
|
|
|
if (tag == 99) { |
|
|
|
|
priv->number = status; |
|
|
|
|
snprintf(self->items[2].label, MENUITEM_LABEL_LEN, "Set=%d°C", priv->number); |
|
|
|
@ -88,10 +83,10 @@ struct Scene *NewScene_MenuTest() { |
|
|
|
|
// private data added by the subclass
|
|
|
|
|
struct Priv *priv = calloc(1, sizeof(struct Priv)); |
|
|
|
|
priv->number = 0; |
|
|
|
|
priv->parent_deinit = scene->base.deinit; |
|
|
|
|
scene->private = priv; |
|
|
|
|
scene->extra = priv; |
|
|
|
|
scene->extra_deinit = (Scene_deinit_t) priv_deinit; |
|
|
|
|
|
|
|
|
|
scene->base.deinit = (Scene_deinit_t) deinit; |
|
|
|
|
// add a child return handler (base does not use this)
|
|
|
|
|
scene->base.onChildReturn = (Scene_onChildReturn_t) onChildReturn; |
|
|
|
|
|
|
|
|
|
return (struct Scene *) scene; |
|
|
|
|