Cleaned up some UI code.
This commit is contained in:
@ -77,13 +77,10 @@
|
||||
#include "ui/grid.h"
|
||||
#include "ui/image.h"
|
||||
#include "ui/label.h"
|
||||
#include "ui/menuv2.h"
|
||||
#include "ui/menu.h"
|
||||
#include "ui/rectangle.h"
|
||||
#include "ui/textmenu.h"
|
||||
|
||||
#include "ui/menu.h"
|
||||
#include "ui/menulist.h"
|
||||
|
||||
// Utility Objects
|
||||
#include "util/array.h"
|
||||
#include "util/dynarray.h"
|
||||
|
@ -7,31 +7,17 @@
|
||||
|
||||
#pragma once
|
||||
#include "../libs.h"
|
||||
#include "grid.h"
|
||||
|
||||
/** The maximum number of items a menu can hold */
|
||||
#define MENU_ITEMS_MAX 32
|
||||
/** Generic callback for menu events */
|
||||
typedef void menucallback_t(void *user, uint8_t i);
|
||||
|
||||
|
||||
typedef struct _menuitem_t menuitem_t;
|
||||
typedef struct _menu_t menu_t;
|
||||
|
||||
/** Callback for when menu events are fired. */
|
||||
typedef void menucallback_t(menu_t *m, menuitem_t *t, uint8_t i, void *user);
|
||||
|
||||
typedef struct _menuitem_t {
|
||||
uint8_t x;
|
||||
uint8_t y;
|
||||
uint8_t width;
|
||||
uint8_t height;
|
||||
} menuitem_t;
|
||||
|
||||
typedef struct _menu_t {
|
||||
menuitem_t items[MENU_ITEMS_MAX];
|
||||
uint8_t itemCount;
|
||||
/** Structure for a menu */
|
||||
typedef struct {
|
||||
grid_t grid;
|
||||
uint8_t selected;
|
||||
uint8_t cursorX;
|
||||
uint8_t cursorY;
|
||||
|
||||
void *user;
|
||||
menucallback_t *onSelect;
|
||||
} menu_t;
|
||||
} menu_t;
|
||||
|
@ -1,35 +0,0 @@
|
||||
/**
|
||||
* Copyright (c) 2021 Dominic Masters
|
||||
*
|
||||
* This software is released under the MIT License.
|
||||
* https://opensource.org/licenses/MIT
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
#include "../libs.h"
|
||||
#include "frame.h"
|
||||
#include "label.h"
|
||||
#include "menu.h"
|
||||
#include "rectangle.h"
|
||||
|
||||
/** Color of the menulist selection rectangle */
|
||||
#define MENULIST_SELECTION_COLOR ((pixel_t){ .r=255, .g=255, .b=255, .a=150 })
|
||||
|
||||
/** Maximum number of items that the list supports */
|
||||
#define MENULIST_ITEMS_MAX 32
|
||||
|
||||
typedef struct _menulist_t menulist_t;
|
||||
|
||||
/** Callback for when a menulist item is selected */
|
||||
typedef void menulistcallback_t(menulist_t *list, uint8_t i, void *user);
|
||||
|
||||
/** Representation of a menu list, a menu with multiple menu items. */
|
||||
typedef struct _menulist_t {
|
||||
char *items[MENULIST_ITEMS_MAX];
|
||||
label_t labels[MENULIST_ITEMS_MAX];
|
||||
frame_t frame;
|
||||
menu_t menu;
|
||||
rectangle_t selection;
|
||||
menulistcallback_t *onSelect;
|
||||
void *user;
|
||||
} menulist_t;
|
@ -1,23 +0,0 @@
|
||||
/**
|
||||
* Copyright (c) 2021 Dominic Masters
|
||||
*
|
||||
* This software is released under the MIT License.
|
||||
* https://opensource.org/licenses/MIT
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
#include "../libs.h"
|
||||
#include "grid.h"
|
||||
|
||||
/** Generic callback for menu events */
|
||||
typedef void menuv2callback_t(void *user, uint8_t i);
|
||||
|
||||
/** Structure for a menu */
|
||||
typedef struct {
|
||||
grid_t grid;
|
||||
uint8_t selected;
|
||||
uint8_t cursorX;
|
||||
uint8_t cursorY;
|
||||
void *user;
|
||||
menuv2callback_t *onSelect;
|
||||
} menuv2_t;
|
@ -6,11 +6,13 @@
|
||||
#pragma once
|
||||
#include "../libs.h"
|
||||
#include "../display/font.h"
|
||||
#include "menuv2.h"
|
||||
#include "menu.h"
|
||||
#include "grid.h"
|
||||
#include "label.h"
|
||||
#include "rectangle.h"
|
||||
|
||||
#define TEXTMENU_SELECTION_COLOR ((pixel_t){.r=0xFF,.g=0xFF,.b=0xFF,.a=0x64})
|
||||
|
||||
typedef void textmenucallback_t(void *user, uint8_t i, char *text);
|
||||
|
||||
typedef struct {
|
||||
@ -19,7 +21,7 @@ typedef struct {
|
||||
} textmenulabelinfo_t;
|
||||
|
||||
typedef struct {
|
||||
menuv2_t menu;
|
||||
menu_t menu;
|
||||
char *texts[GRID_CHILD_COUNT];
|
||||
|
||||
font_t *font;
|
||||
|
Reference in New Issue
Block a user