Prusa MINI Firmware overview
window_list.c File Reference
#include "window_list.h"
#include "gui.h"

Functions

void window_list_item (window_list_t *pwindow_list, uint16_t index, const char **pptext, uint16_t *pid_icon)
 
void window_list_inc (window_list_t *window, int dif)
 
void window_list_dec (window_list_t *window, int dif)
 
void window_list_init (window_list_t *window)
 
void window_list_done (window_list_t *window)
 
void window_list_draw (window_list_t *window)
 
void window_list_event (window_list_t *window, uint8_t event, void *param)
 

Variables

const char items [11][6]
 
const window_class_list_t window_class_list
 

Function Documentation

◆ window_list_item()

void window_list_item ( window_list_t pwindow_list,
uint16_t  index,
const char **  pptext,
uint16_t *  pid_icon 
)
20  {
21  *pptext = (char *)items[index];
22  *pid_icon = 0;
23 }
Here is the caller graph for this function:

◆ window_list_inc()

void window_list_inc ( window_list_t window,
int  dif 
)
120  {
121  int item_height = window->font->h + window->padding.top + window->padding.bottom;
122  int visible_count = window->win.rect.h / item_height;
123  int old = window->index;
124  window->index += dif;
125  if (window->index < 0) {
126  window->index = 0;
127  }
128  if (window->index >= window->count) {
129  window->index = window->count - 1;
130  }
131 
132  if (window->index < window->top_index) {
133  window->top_index = window->index;
134  }
135  if (window->index >= (window->top_index + visible_count)) {
136  window->top_index = window->index - visible_count + 1;
137  }
138 
139  if (window->index != old) {
140  // optimalization do not redraw when no change - still on end
141  _window_invalidate((window_t *)window);
142  }
143 }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ window_list_dec()

void window_list_dec ( window_list_t window,
int  dif 
)
145  {
146  window_list_inc(window, -dif);
147 }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ window_list_init()

void window_list_init ( window_list_t window)
28  {
31  window->font = gui_defaults.font;
32  window->padding = gui_defaults.padding;
33  window->icon_rect = rect_ui16(0, 0, 16, 16);
35  window->count = 0;
36  window->index = 0;
37  window->top_index = 0;
38  window->list_item = window_list_item;
39  window->win.flg |= WINDOW_FLG_ENABLED;
40 }
Here is the call graph for this function:

◆ window_list_done()

void window_list_done ( window_list_t window)
42  {
43 }

◆ window_list_draw()

void window_list_draw ( window_list_t window)
45  {
46  if (!((window->win.flg & (WINDOW_FLG_INVALID | WINDOW_FLG_VISIBLE))
48  return;
49  }
50 
51  int item_height = window->font->h + window->padding.top + window->padding.bottom;
52  rect_ui16_t rc_win = window->win.rect;
53 
54  int visible_count = rc_win.h / item_height;
55  int i;
56  for (i = 0; i < visible_count && i < window->count; i++) {
57  int idx = i + window->top_index;
58  const char *label;
59  uint16_t id_icon;
60  window->list_item(window, idx, &label, &id_icon);
61 
62  color_t color_text = window->color_text;
63  color_t color_back = window->color_back;
64  uint8_t swap = 0;
65 
66  rect_ui16_t rc = { rc_win.x, rc_win.y + i * item_height,
67  rc_win.w, item_height };
68  padding_ui8_t padding = window->padding;
69 
70  if (rect_in_rect_ui16(rc, rc_win)) {
71  if (window->index == idx) {
72  color_t swp = color_text;
73  color_text = color_back;
74  color_back = swp;
75  swap = ROPFN_SWAPBW;
76  }
77 
78  if (id_icon) {
79  rect_ui16_t irc = { rc.x, rc.y,
80  window->icon_rect.w, window->icon_rect.h };
81  rc.x += irc.w;
82  rc.w -= irc.w;
83  render_icon_align(irc, id_icon,
84  window->color_back, RENDER_FLG(ALIGN_CENTER, swap));
85  } else {
86  padding.left += window->icon_rect.w;
87  }
88 
89  // render
90  render_text_align(rc, label, window->font,
91  color_back, color_text,
92  padding, window->alignment);
93  }
94  }
95  rc_win.h = rc_win.h - (i * item_height);
96 
97  if (rc_win.h) {
98  rc_win.y += i * item_height;
99  display->fill_rect(rc_win, window->color_back);
100  }
101 }
Here is the call graph for this function:

◆ window_list_event()

void window_list_event ( window_list_t window,
uint8_t  event,
void param 
)
103  {
104  switch (event) {
105  case WINDOW_EVENT_BTN_DN:
107  break;
108  case WINDOW_EVENT_ENC_DN:
109  window_list_dec(window, (int)param);
110  break;
111  case WINDOW_EVENT_ENC_UP:
112  window_list_inc(window, (int)param);
113  break;
114  case WINDOW_EVENT_CAPT_1:
115  //TODO: change flag to checked
116  break;
117  }
118 }
Here is the call graph for this function:

Variable Documentation

◆ items

const char items[11][6]
Initial value:
= {
"item0",
"item1",
"item2",
"item3",
"item4",
"item5",
"item6",
"item7",
"item8",
"item9",
"item10",
}

◆ window_class_list

RENDER_FLG
#define RENDER_FLG(a, r)
Definition: display_helper.h:10
window_draw_t
void() window_draw_t(void *window)
Definition: window.h:57
items
const char items[11][6]
Definition: window_list.c:5
WINDOW_EVENT_CAPT_1
#define WINDOW_EVENT_CAPT_1
Definition: window.h:45
window_list_done
void window_list_done(window_list_t *window)
Definition: window_list.c:42
_rect_ui16_t::y
uint16_t y
Definition: guitypes.h:71
_font_t::h
uint8_t h
Definition: guitypes.h:78
_window_list_t::count
int count
Definition: window_list.h:23
_rect_ui16_t::w
uint16_t w
Definition: guitypes.h:72
window_list_inc
void window_list_inc(window_list_t *window, int dif)
Definition: window_list.c:120
_window_t::id_parent
int16_t id_parent
Definition: window.h:78
_padding_ui8_t::bottom
uint8_t bottom
Definition: guitypes.h:90
window_list_init
void window_list_init(window_list_t *window)
Definition: window_list.c:28
window_list_dec
void window_list_dec(window_list_t *window, int dif)
Definition: window_list.c:145
_gui_defaults_t::color_text
color_t color_text
Definition: guitypes.h:108
_padding_ui8_t::top
uint8_t top
Definition: guitypes.h:88
window_list_t
struct _window_list_t window_list_t
Definition: window.h:60
WINDOW_EVENT_ENC_UP
#define WINDOW_EVENT_ENC_UP
Definition: window.h:41
ALIGN_CENTER
#define ALIGN_CENTER
Definition: guitypes.h:19
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_defaults_t::font
font_t * font
Definition: guitypes.h:110
_window_list_t::icon_rect
rect_ui16_t icon_rect
Definition: window_list.h:22
i
uint8_t i
Definition: screen_test_graph.c:72
_window_list_t::color_text
color_t color_text
Definition: window_list.h:18
WINDOW_FLG_VISIBLE
#define WINDOW_FLG_VISIBLE
Definition: window.h:24
rect_in_rect_ui16
static int rect_in_rect_ui16(rect_ui16_t rc, rect_ui16_t rc1)
Definition: guitypes.h:173
_display_t::fill_rect
display_fill_rect_t * fill_rect
Definition: display.h:33
_padding_ui8_t::left
uint8_t left
Definition: guitypes.h:87
_gui_defaults_t::padding
padding_ui8_t padding
Definition: guitypes.h:112
WINDOW_CLS_LIST
#define WINDOW_CLS_LIST
Definition: window.h:13
window_done_t
void() window_done_t(void *window)
Definition: window.h:56
_window_list_t::win
window_t win
Definition: window_list.h:16
_window_t
Definition: window.h:76
_window_list_t::list_item
window_list_item_t * list_item
Definition: window_list.h:26
_window_list_t::padding
padding_ui8_t padding
Definition: window_list.h:20
window_list_item
void window_list_item(window_list_t *pwindow_list, uint16_t index, const char **pptext, uint16_t *pid_icon)
Definition: window_list.c:19
_gui_defaults_t::color_back
color_t color_back
Definition: guitypes.h:107
_window_list_t::alignment
uint8_t alignment
Definition: window_list.h:21
window_set_capture
void window_set_capture(int16_t id)
Definition: window.c:500
_padding_ui8_t
Definition: guitypes.h:86
ROPFN_SWAPBW
#define ROPFN_SWAPBW
Definition: guitypes.h:32
window_event_t
void() window_event_t(void *window, uint8_t event, void *param)
Definition: window.h:58
_rect_ui16_t
Definition: guitypes.h:69
render_text_align
void render_text_align(rect_ui16_t rc, const char *text, font_t *font, color_t clr0, color_t clr1, padding_ui8_t padding, uint16_t flags)
Definition: display_helper.c:6
uint8_t
const uint8_t[]
Definition: 404_html.c:3
display
display_t * display
Definition: display.c:6
_rect_ui16_t::h
uint16_t h
Definition: guitypes.h:73
_window_t::rect
rect_ui16_t rect
Definition: window.h:101
_window_list_t::index
int index
Definition: window_list.h:24
_window_list_t::color_back
color_t color_back
Definition: window_list.h:17
_rect_ui16_t::x
uint16_t x
Definition: guitypes.h:70
color_t
uint32_t color_t
Definition: guitypes.h:62
window_init_t
void() window_init_t(void *window)
Definition: window.h:55
gui_defaults
gui_defaults_t gui_defaults
Definition: gui.c:20
render_icon_align
void render_icon_align(rect_ui16_t rc, uint16_t id_res, color_t clr0, uint16_t flags)
Definition: display_helper.c:55
WINDOW_EVENT_BTN_DN
#define WINDOW_EVENT_BTN_DN
Definition: window.h:38
_window_list_t::top_index
int top_index
Definition: window_list.h:25
_gui_defaults_t::alignment
uint8_t alignment
Definition: guitypes.h:113
window_list_draw
void window_list_draw(window_list_t *window)
Definition: window_list.c:45
_window_t::flg
uint32_t flg
Definition: window.h:81
_window_list_t::font
font_t * font
Definition: window_list.h:19
WINDOW_FLG_INVALID
#define WINDOW_FLG_INVALID
Definition: window.h:26
WINDOW_FLG_ENABLED
#define WINDOW_FLG_ENABLED
Definition: window.h:25
_window_invalidate
static void _window_invalidate(window_t *window)
Definition: window.h:257
WINDOW_EVENT_ENC_DN
#define WINDOW_EVENT_ENC_DN
Definition: window.h:40
window_list_event
void window_list_event(window_list_t *window, uint8_t event, void *param)
Definition: window_list.c:103