WIP sliders and incrimenting
This commit is contained in:
@@ -3,8 +3,27 @@
|
||||
|
||||
#include "display.h"
|
||||
#include "stdint.h"
|
||||
#include "stdbool.h"
|
||||
#include "fonts/font.h"
|
||||
|
||||
void DisplayTest(pixel_t color);
|
||||
void DrawBox(uint32_t topleft_x_loc, uint32_t topleft_y_loc, uint32_t width, uint32_t height, pixel_t color);
|
||||
|
||||
/*
|
||||
* All fields have default values when not provided
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
uint16_t x;
|
||||
uint16_t y;
|
||||
uint16_t width;
|
||||
uint16_t height;
|
||||
pixel_t on_color;
|
||||
pixel_t off_color;
|
||||
pixel_t inner_padding_pixels;
|
||||
bool value;
|
||||
} toggle_switch_t;
|
||||
|
||||
void draw_toggle_switch(volatile pixel_t *const framebuffer, const toggle_switch_t *const toggle_switch);
|
||||
|
||||
#endif
|
||||
@@ -5,41 +5,42 @@
|
||||
#include "stdbool.h"
|
||||
#include "display.h"
|
||||
|
||||
typedef void (*menu_callback_t)(void *args);
|
||||
typedef struct _graphical_menu_layout_t graphical_menu_layout_t;
|
||||
typedef struct _graphical_menu_t graphical_menu_t;
|
||||
typedef struct _menu_entry_size_t menu_entry_size_t;
|
||||
typedef void (*menu_callback_t)(void *const args);
|
||||
|
||||
// TODO
|
||||
// typedef struct {
|
||||
// uint16_t x;
|
||||
// uint16_t y;
|
||||
// uint16_t width;
|
||||
// uint16_t height;
|
||||
// } graphical_menu_position_t;
|
||||
/*
|
||||
* Extra draw function is called after the menu entry is drawn
|
||||
* It is used to draw additional graphics on top of the menu entry
|
||||
* It is passed the size of the menu entry and the args
|
||||
*/
|
||||
typedef void (*extra_draw_function_t)(const menu_entry_size_t *const menu_entry_size, void *const args);
|
||||
|
||||
typedef struct
|
||||
{
|
||||
const char *const title;
|
||||
const bool enabled; // not enabled = grayed out, unhighlightable
|
||||
bool disabled;
|
||||
const menu_callback_t highlighted_callback_function;
|
||||
void *const highlighted_callback_function_args;
|
||||
const menu_callback_t selected_callback_function;
|
||||
void *const selected_callback_function_args;
|
||||
const extra_draw_function_t extra_draw_function; // called after the menu entry is drawn
|
||||
void *const extra_draw_function_args;
|
||||
} graphical_menu_entry_t;
|
||||
|
||||
|
||||
struct _graphical_menu_layout_t {
|
||||
graphical_menu_t *const parent_menu;
|
||||
const uint8_t num_entries;
|
||||
const graphical_menu_entry_t *const entries;
|
||||
};
|
||||
|
||||
struct _graphical_menu_t {
|
||||
const graphical_menu_layout_t *const layout;
|
||||
uint8_t selected_entry_idx;
|
||||
graphical_menu_t *const parent_menu;
|
||||
const uint8_t num_children;
|
||||
uint8_t highlighted_child_idx;
|
||||
graphical_menu_entry_t *const children;
|
||||
};
|
||||
|
||||
|
||||
struct _menu_entry_size_t {
|
||||
const uint16_t x;
|
||||
const uint16_t y;
|
||||
const uint16_t width;
|
||||
const uint16_t height;
|
||||
};
|
||||
|
||||
void draw_menu(volatile pixel_t *const framebuffer, const graphical_menu_t *const menu);
|
||||
void partial_redraw_menu(volatile pixel_t *const framebuffer, graphical_menu_t *const menu, uint8_t old_highlighted_entry_idx, uint8_t new_highlighted_entry_idx);
|
||||
|
||||
Reference in New Issue
Block a user