Prusa MINI Firmware overview
display_helper.c File Reference
#include "display_helper.h"
#include "display.h"

Functions

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)
 
void render_icon_align (rect_ui16_t rc, uint16_t id_res, color_t clr0, uint16_t flags)
 

Function Documentation

◆ 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 
)
6  {
7  rect_ui16_t rc_pad = rect_ui16_sub_padding_ui8(rc, padding);
8  if (flags & RENDER_FLG_WORDB) {
9  //TODO: other alignments, following impl. is for LEFT-TOP
10  uint16_t x;
11  uint16_t y = rc_pad.y;
12  int n;
13  const char *str = text;
14  while ((n = font_line_chars(font, str, rc_pad.w)) && ((y + font->h) <= (rc_pad.y + rc_pad.h))) {
15  x = rc_pad.x;
16  int i = 0;
17  while (str[i] == ' ' || str[i] == '\n')
18  i++;
19  for (; i < n; i++) {
20  display->draw_char(point_ui16(x, y), str[i], font, clr0, clr1);
21  x += font->w;
22  }
23  display->fill_rect(rect_ui16(x, y, (rc_pad.x + rc_pad.w - x), font->h), clr0);
24  str += n;
25  y += font->h;
26  }
27  display->fill_rect(rect_ui16(rc_pad.x, y, rc_pad.w, (rc_pad.y + rc_pad.h - y)), clr0);
28  rect_ui16_t rc_t = { rc.x, rc.y, rc.w, rc_pad.y - rc.y };
29  rect_ui16_t rc_b = { rc.x, rc_pad.y + rc_pad.h, rc.w, (rc.y + rc.h) - (rc_pad.y + rc_pad.h) };
30  rect_ui16_t rc_l = { rc.x, rc.y, rc_pad.x - rc.x, rc.h };
31  rect_ui16_t rc_r = { rc_pad.x + rc_pad.w, rc.y, (rc.x + rc.w) - (rc_pad.x + rc_pad.w), rc.h };
32  display->fill_rect(rc_t, clr0);
33  display->fill_rect(rc_b, clr0);
34  display->fill_rect(rc_l, clr0);
35  display->fill_rect(rc_r, clr0);
36  } else {
37  point_ui16_t wh_txt = font_meas_text(font, text);
38  if (wh_txt.x && wh_txt.y) {
39  rect_ui16_t rc_txt = rect_align_ui16(rc_pad, rect_ui16(0, 0, wh_txt.x, wh_txt.y), flags & ALIGN_MASK);
40  rc_txt = rect_intersect_ui16(rc_pad, rc_txt);
41  rect_ui16_t rc_t = { rc.x, rc.y, rc.w, rc_txt.y - rc.y };
42  rect_ui16_t rc_b = { rc.x, rc_txt.y + rc_txt.h, rc.w, (rc.y + rc.h) - (rc_txt.y + rc_txt.h) };
43  rect_ui16_t rc_l = { rc.x, rc.y, rc_txt.x - rc.x, rc.h };
44  rect_ui16_t rc_r = { rc_txt.x + rc_txt.w, rc.y, (rc.x + rc.w) - (rc_txt.x + rc_txt.w), rc.h };
45  display->fill_rect(rc_t, clr0);
46  display->fill_rect(rc_b, clr0);
47  display->fill_rect(rc_l, clr0);
48  display->fill_rect(rc_r, clr0);
49  display->draw_text(rc_txt, text, font, clr0, clr1);
50  } else
51  display->fill_rect(rc, clr0);
52  }
53 }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ render_icon_align()

void render_icon_align ( rect_ui16_t  rc,
uint16_t  id_res,
color_t  clr0,
uint16_t  flags 
)
55  {
56  point_ui16_t wh_ico = icon_meas(resource_ptr(id_res));
57  if (wh_ico.x && wh_ico.y) {
58  rect_ui16_t rc_ico = rect_align_ui16(rc, rect_ui16(0, 0, wh_ico.x, wh_ico.y), flags & ALIGN_MASK);
59  rc_ico = rect_intersect_ui16(rc, rc_ico);
60  rect_ui16_t rc_t = { rc.x, rc.y, rc.w, rc_ico.y - rc.y };
61  rect_ui16_t rc_b = { rc.x, rc_ico.y + rc_ico.h, rc.w, (rc.y + rc.h) - (rc_ico.y + rc_ico.h) };
62  rect_ui16_t rc_l = { rc.x, rc.y, rc_ico.x - rc.x, rc.h };
63  rect_ui16_t rc_r = { rc_ico.x + rc_ico.w, rc.y, (rc.x + rc.w) - (rc_ico.x + rc_ico.w), rc.h };
64  display->fill_rect(rc_t, ((flags >> 8) & ROPFN_SWAPBW) ? clr0 ^ 0xffffffff : clr0);
65  display->fill_rect(rc_b, ((flags >> 8) & ROPFN_SWAPBW) ? clr0 ^ 0xffffffff : clr0);
66  display->fill_rect(rc_l, ((flags >> 8) & ROPFN_SWAPBW) ? clr0 ^ 0xffffffff : clr0);
67  display->fill_rect(rc_r, ((flags >> 8) & ROPFN_SWAPBW) ? clr0 ^ 0xffffffff : clr0);
68  display->draw_icon(point_ui16(rc_ico.x, rc_ico.y), id_res, clr0, (flags >> 8) & 0x0f);
69  } else
70  display->fill_rect(rc, clr0);
71 }
Here is the call graph for this function:
Here is the caller graph for this function:
_rect_ui16_t::y
uint16_t y
Definition: guitypes.h:71
_font_t::h
uint8_t h
Definition: guitypes.h:78
_rect_ui16_t::w
uint16_t w
Definition: guitypes.h:72
_display_t::draw_char
display_draw_char_t * draw_char
Definition: display.h:34
rect_ui16
static rect_ui16_t rect_ui16(uint16_t x, uint16_t y, uint16_t w, uint16_t h)
Definition: guitypes.h:159
_point_ui16_t::x
uint16_t x
Definition: guitypes.h:65
ALIGN_MASK
#define ALIGN_MASK
Definition: guitypes.h:18
RENDER_FLG_WORDB
#define RENDER_FLG_WORDB
Definition: display_helper.h:9
i
uint8_t i
Definition: screen_test_graph.c:72
netif::flags
u8_t flags
Definition: netif.h:305
_display_t::draw_text
display_draw_text_t * draw_text
Definition: display.h:35
_point_ui16_t
Definition: guitypes.h:64
font_line_chars
int font_line_chars(font_t *pf, const char *str, uint16_t line_width)
Definition: guitypes.c:122
rect_ui16_sub_padding_ui8
rect_ui16_t rect_ui16_sub_padding_ui8(rect_ui16_t rc, padding_ui8_t pad)
Definition: guitypes.c:55
_display_t::fill_rect
display_fill_rect_t * fill_rect
Definition: display.h:33
_point_ui16_t::y
uint16_t y
Definition: guitypes.h:66
rect_intersect_ui16
rect_ui16_t rect_intersect_ui16(rect_ui16_t rc, rect_ui16_t rc1)
Definition: guitypes.c:37
_font_t::w
uint8_t w
Definition: guitypes.h:77
icon_meas
point_ui16_t icon_meas(const uint8_t *pi)
Definition: guitypes.c:155
ROPFN_SWAPBW
#define ROPFN_SWAPBW
Definition: guitypes.h:32
_rect_ui16_t
Definition: guitypes.h:69
resource_ptr
const uint8_t * resource_ptr(uint16_t id)
Definition: guitypes.c:168
display
display_t * display
Definition: display.c:6
_rect_ui16_t::h
uint16_t h
Definition: guitypes.h:73
_display_t::draw_icon
display_draw_icon_t * draw_icon
Definition: display.h:36
_rect_ui16_t::x
uint16_t x
Definition: guitypes.h:70
font_meas_text
point_ui16_t font_meas_text(font_t *pf, const char *str)
Definition: guitypes.c:97
point_ui16
static point_ui16_t point_ui16(uint16_t x, uint16_t y)
Definition: guitypes.h:154
rect_align_ui16
rect_ui16_t rect_align_ui16(rect_ui16_t rc, rect_ui16_t rc1, uint8_t align)
Definition: guitypes.c:64