Prusa MINI Firmware overview
screen_menu.h File Reference
#include "gui.h"
#include "window_header.h"
#include "status_footer.h"
#include "window_menu.h"

Go to the source code of this file.

Classes

struct  _menu_item_t
 
struct  screen_menu_data_t
 

Macros

#define SCREEN_MENU_RETURN   (screen_t *)SIZE_MAX
 
#define SCREEN_MENU_NO_SCREEN   NULL
 
#define psmd   ((screen_menu_data_t *)screen->pdata)
 

Typedefs

typedef struct _menu_item_t menu_item_t
 

Functions

void screen_menu_init (screen_t *screen, const char *label, int count, uint8_t footer, uint8_t help)
 
void screen_menu_done (screen_t *screen)
 
int screen_menu_event (screen_t *screen, window_t *window, uint8_t event, void *param)
 
void screen_menu_draw (screen_t *screen)
 

Variables

const menu_item_t menu_item_return
 

Macro Definition Documentation

◆ SCREEN_MENU_RETURN

#define SCREEN_MENU_RETURN   (screen_t *)SIZE_MAX

◆ SCREEN_MENU_NO_SCREEN

#define SCREEN_MENU_NO_SCREEN   NULL

◆ psmd

#define psmd   ((screen_menu_data_t *)screen->pdata)

Typedef Documentation

◆ menu_item_t

typedef struct _menu_item_t menu_item_t

Function Documentation

◆ screen_menu_init()

void screen_menu_init ( screen_t screen,
const char *  label,
int  count,
uint8_t  footer,
uint8_t  help 
)
26  {
27  psmd->items = (menu_item_t *)malloc(sizeof(menu_item_t) * count);
28  memset(psmd->items, '\0', sizeof(menu_item_t) * count);
29 
30  rect_ui16_t menu_rect = rect_ui16(10, 32, 220, 278);
31  if (help) {
32  menu_rect.h -= 115;
33  }
34  if (footer) {
35  menu_rect.h -= 41;
36  }
37 
38  int16_t id;
39  int16_t root = window_create_ptr(WINDOW_CLS_FRAME, -1,
40  rect_ui16(0, 0, 0, 0),
41  &(psmd->root));
42  window_disable(root);
43 
45  rect_ui16(0, 0, 240, 31), &(psmd->header));
46  // p_window_header_set_icon(&(psmd->header), IDR_PNG_status_icon_menu);
47  p_window_header_set_text(&(psmd->header), label);
48 
50  menu_rect, &(psmd->menu));
51  psmd->menu.padding = padding_ui8(20, 6, 2, 6);
52  psmd->menu.icon_rect = rect_ui16(0, 0, 16, 30);
53  psmd->menu.count = count;
54  psmd->menu.menu_items = screen_menu_item;
55  psmd->menu.data = (void *)screen;
56  //window_set_item_index(id, 1); // 0 = return
57  window_set_capture(id); // set capture to list
58  window_set_focus(id);
59 
60  if (help) {
61  psmd->phelp = (window_text_t *)gui_malloc(sizeof(window_text_t));
63  (footer) ? rect_ui16(10, 154, 220, 115) : rect_ui16(10, 195, 220, 115),
64  psmd->phelp);
65  psmd->phelp->font = resource_font(IDR_FNT_SPECIAL);
66  } else {
67  psmd->phelp = NULL;
68  }
69 
70  if (footer) {
71  psmd->pfooter = (status_footer_t *)gui_malloc(sizeof(status_footer_t));
72  status_footer_init(psmd->pfooter, root);
73  } else {
74  psmd->pfooter = NULL;
75  }
76 }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ screen_menu_done()

void screen_menu_done ( screen_t screen)
78  {
79  window_destroy(psmd->root.win.id);
80  if (psmd->phelp) {
81  free(psmd->phelp);
82  }
83 
84  if (psmd->pfooter) {
85  free(psmd->pfooter);
86  }
87  free(psmd->items);
88 }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ screen_menu_event()

int screen_menu_event ( screen_t screen,
window_t window,
uint8_t  event,
void param 
)
93  {
94  if (psmd->pfooter) {
95  status_footer_event(psmd->pfooter, window, event, param);
96  }
97 
98  window_header_events(&(psmd->header));
99 
100  if (event != WINDOW_EVENT_CLICK) {
101  return 0;
102  }
103 
104  const menu_item_t *item = &(psmd->items[(int)param]);
105  if (!(item->item.type & WI_DISABLED) && item->screen == SCREEN_MENU_RETURN) {
106  screen_close();
107  return 1;
108  }
109 
110  if (!(item->item.type & WI_DISABLED) && item->screen != SCREEN_MENU_NO_SCREEN) {
111  screen_open(item->screen->id);
112  return 1;
113  }
114  return 0;
115 }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ screen_menu_draw()

void screen_menu_draw ( screen_t screen)
90 {}

Variable Documentation

◆ menu_item_return

const menu_item_t menu_item_return
_window_text_t
Definition: window_text.h:15
_menu_item_t
Definition: screen_menu.h:19
window_header_events
#define window_header_events(window)
Definition: window_header.h:72
_menu_item_t::screen
screen_t * screen
Definition: screen_menu.h:21
rect_ui16
static rect_ui16_t rect_ui16(uint16_t x, uint16_t y, uint16_t w, uint16_t h)
Definition: guitypes.h:159
gui_malloc
void * gui_malloc(unsigned int size)
Definition: gui.c:35
window_destroy
void window_destroy(int16_t id)
Definition: window.c:132
padding_ui8
static padding_ui8_t padding_ui8(uint8_t l, uint8_t t, uint8_t r, uint8_t b)
Definition: guitypes.h:164
createSpeedLookupTable.help
help
Definition: createSpeedLookupTable.py:15
IDR_FNT_SPECIAL
#define IDR_FNT_SPECIAL
Definition: resource.h:13
SCREEN_MENU_NO_SCREEN
#define SCREEN_MENU_NO_SCREEN
Definition: screen_menu.h:39
screen_open
void screen_open(int16_t screen_id)
Definition: screen.c:62
NULL
#define NULL
Definition: usbd_def.h:53
screen_close
void screen_close(void)
Definition: screen.c:80
window_disable
void window_disable(int16_t id)
Definition: window.c:523
WI_DISABLED
Definition: window_menu.h:20
_menu_item_t::item
window_menu_item_t item
Definition: screen_menu.h:20
SCREEN_MENU_RETURN
#define SCREEN_MENU_RETURN
Definition: screen_menu.h:38
WINDOW_CLS_FRAME
#define WINDOW_CLS_FRAME
Definition: window.h:9
WINDOW_CLS_MENU
#define WINDOW_CLS_MENU
Definition: window.h:18
window_set_focus
void window_set_focus(int16_t id)
Definition: window.c:480
window_set_capture
void window_set_capture(int16_t id)
Definition: window.c:500
psmd
#define psmd
Definition: screen_menu.h:40
_rect_ui16_t
Definition: guitypes.h:69
_rect_ui16_t::h
uint16_t h
Definition: guitypes.h:73
WINDOW_CLS_TEXT
#define WINDOW_CLS_TEXT
Definition: window.h:10
resource_font
font_t * resource_font(uint16_t id)
Definition: guitypes.c:186
_window_menu_item_t::type
uint16_t type
Definition: window_menu.h:65
WINDOW_EVENT_CLICK
#define WINDOW_EVENT_CLICK
Definition: window.h:46
window_create_ptr
int16_t window_create_ptr(int16_t cls_id, int16_t id_parent, rect_ui16_t rect, void *ptr)
Definition: window.c:102
_screen_t::id
int16_t id
Definition: screen.h:19
createSpeedLookupTable.int
int
Definition: createSpeedLookupTable.py:15
WINDOW_CLS_HEADER
int16_t WINDOW_CLS_HEADER
Definition: window_header.c:24
screen_menu_item
void screen_menu_item(window_menu_t *pwindow_menu, uint16_t index, window_menu_item_t **ppitem, void *data)
Definition: screen_menu.c:19
p_window_header_set_text
void p_window_header_set_text(window_header_t *window, const char *text)
Definition: window_header.c:152