~ruther/CTU-FEE-B0B35APO-Semestral-project

ref: 6ada1974eeefafcf50eed752374704d263533283 CTU-FEE-B0B35APO-Semestral-project/lib-gui/include/gui_component_text_view.h -rw-r--r-- 2.0 KiB
6ada1974 — František Boháček feat: add new font with variable width 3 years ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
#ifndef __GUI_COMPONENT_TEXT_VIEW_H__
#define __GUI_COMPONENT_TEXT_VIEW_H__

#include "display_utils.h"
#include "gui.h"

typedef struct {
  char *line;
  uint16_t length;
} line_t;

typedef struct {
  line_t *lines;
  uint16_t lines_count;
  char *text;
  font_t *font;
  display_pixel_t color;
} multiline_text_t;

/**
 * @brief Create multiline text for state of text view
 *
 * @param font
 * @param color
 * @param text
 * @return multiline_text_t*
 */
multiline_text_t *gui_multiline_text_create(font_t *font, display_pixel_t color,
                                            char *text);

/**
 * @brief Create text view component
 *
 * @param gui
 * @param text multiline text state
 * @param x base x coordinate
 * @param y base y coordinate
 * @return component_t
 */
component_t gui_text_view_create(gui_t *gui, multiline_text_t *text, int16_t x,
                                 int16_t y);

/**
 * @brief Get number of lines scrolled from text view
 *
 * @param component
 * @return uint16_t
 */
uint16_t gui_text_view_get_lines_scrolled(component_t *component);

/**
 * @brief Scroll text view by x, y
 *
 * @param text_view
 * @param x x coordinate to scroll by
 * @param y y coordinate to scroll by
 */
void gui_text_view_scroll(component_t *text_view, int32_t x, int32_t y);

/**
 * @brief Reset scroll to 0, 0
 *
 * @param text_view
 */
void gui_text_view_reset_scroll(component_t *text_view);

/**
 * @brief Full scroll to the end of file
 *
 * @param text_view
 */
void gui_text_view_full_scroll(component_t *text_view);

/**
 * @brief Render function of gui text view component
 *
 * @param container
 * @param component
 * @param gui
 */
void gui_text_view_render(container_t *container, component_t *component,
                          gui_t *gui);

/**
 * @brief Update function of gui text view component
 *
 * @param container
 * @param component
 * @param gui
 */
void gui_text_view_update(container_t *container, component_t *component,
                          gui_t *gui);

#endif // __GUI_COMPONENT_TEXT_VIEW_H__
Do not follow this link