parent
7240773581
commit
e22d4fb9e2
@ -0,0 +1,36 @@ |
|||||||
|
#include <malloc.h> |
||||||
|
#include <string.h> |
||||||
|
#include <math.h> |
||||||
|
#include <stdio.h> |
||||||
|
#include <common_utils/utils.h> |
||||||
|
|
||||||
|
#include "analog.h" |
||||||
|
#include "firehazard.h" |
||||||
|
#include "graphics/bitmaps.h" |
||||||
|
#include "liquid.h" |
||||||
|
#include "graphics/drawing.h" |
||||||
|
#include "graphics/display_spec.h" |
||||||
|
|
||||||
|
#include "scenes.h" |
||||||
|
#include "scene_menu.h" |
||||||
|
|
||||||
|
static void paint(struct MenuScene *self) |
||||||
|
{ |
||||||
|
LCD_setShadeOverlay(); |
||||||
|
|
||||||
|
// frame around the menu items
|
||||||
|
LCD_setRect(self->x - 3, self->y - 3, self->x + self->ncols*6 + 3, self->y + self->nlines * 9 + 2, true, WHITE); |
||||||
|
LCD_setRect(self->x - 2, self->y - 2, self->x + self->ncols*6 + 2, self->y + self->nlines * 9 + 1, false, BLACK); |
||||||
|
MenuScene_Paint(self); |
||||||
|
} |
||||||
|
|
||||||
|
struct MenuScene *NewScene_PopupMenu(struct MenuItem *items, size_t items_len) |
||||||
|
{ |
||||||
|
struct MenuScene * scene = NewScene_Menu(items, items_len); |
||||||
|
scene->x = 12; |
||||||
|
scene->y = 6; |
||||||
|
scene->ncols = 10; |
||||||
|
scene->nlines = MIN(items_len, 4); |
||||||
|
scene->base.paint = (Scene_paint_t) paint; |
||||||
|
return scene; |
||||||
|
} |
@ -0,0 +1,25 @@ |
|||||||
|
#include <malloc.h> |
||||||
|
#include <string.h> |
||||||
|
#include "liquid.h" |
||||||
|
|
||||||
|
#include "scenes.h" |
||||||
|
#include "scene_menu.h" |
||||||
|
|
||||||
|
static struct SceneEvent onSelect(struct MenuScene *self) { |
||||||
|
return SceneEvent_Close(0, NULL); |
||||||
|
} |
||||||
|
|
||||||
|
struct Scene *NewScene_PopupTest() { |
||||||
|
struct MenuItem *items = calloc(5, sizeof(struct MenuItem)); |
||||||
|
|
||||||
|
strncpy(items[0].label, "Item 1", MENUITEM_LABEL_LEN); |
||||||
|
strncpy(items[1].label, "Item Two", MENUITEM_LABEL_LEN); |
||||||
|
strncpy(items[2].label, "Item Three hereee", MENUITEM_LABEL_LEN); |
||||||
|
strncpy(items[3].label, "FOURTH", MENUITEM_LABEL_LEN); |
||||||
|
strncpy(items[4].label, "EXTRA SECRET FIFTH ITEM", MENUITEM_LABEL_LEN); |
||||||
|
|
||||||
|
struct MenuScene * scene = NewScene_PopupMenu(items, 5); |
||||||
|
scene->onSelect = onSelect; |
||||||
|
|
||||||
|
return (struct Scene *) scene; |
||||||
|
} |
Loading…
Reference in new issue