elements.h 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  1. #pragma once
  2. #include <stdint.h>
  3. #include <m-string.h>
  4. #include "canvas.h"
  5. #ifdef __cplusplus
  6. extern "C" {
  7. #endif
  8. /** Draw progress bar.
  9. * @param x - progress bar position on X axis
  10. * @param y - progress bar position on Y axis
  11. * @param width - progress bar width
  12. * @param progress - progress in unnamed metric
  13. * @param total - total amount in unnamed metric
  14. */
  15. void elements_progress_bar(
  16. Canvas* canvas,
  17. uint8_t x,
  18. uint8_t y,
  19. uint8_t width,
  20. uint8_t progress,
  21. uint8_t total);
  22. /** Draw scrollbar on canvas at specific position.
  23. * @param x - scrollbar position on X axis
  24. * @param y - scrollbar position on Y axis
  25. * @param height - scrollbar height
  26. * @param pos - current element
  27. * @param total - total elements
  28. */
  29. void elements_scrollbar_pos(
  30. Canvas* canvas,
  31. uint8_t x,
  32. uint8_t y,
  33. uint8_t height,
  34. uint16_t pos,
  35. uint16_t total);
  36. /** Draw scrollbar on canvas.
  37. * width 3px, height equal to canvas height
  38. * @param pos - current element of total elements
  39. * @param total - total elements
  40. */
  41. void elements_scrollbar(Canvas* canvas, uint16_t pos, uint16_t total);
  42. /** Draw rounded frame
  43. * @param x, y - top left corner coordinates
  44. * @param width, height - frame width and height
  45. */
  46. void elements_frame(Canvas* canvas, uint8_t x, uint8_t y, uint8_t width, uint8_t height);
  47. /** Draw button in left corner
  48. * @param str - button text
  49. */
  50. void elements_button_left(Canvas* canvas, const char* str);
  51. /** Draw button in right corner
  52. * @param str - button text
  53. */
  54. void elements_button_right(Canvas* canvas, const char* str);
  55. /** Draw button in center
  56. * @param str - button text
  57. */
  58. void elements_button_center(Canvas* canvas, const char* str);
  59. /** Draw aligned multiline text
  60. * @param x, y - coordinates based on align param
  61. * @param horizontal, vertical - aligment of multiline text
  62. * @param text - string (possible multiline)
  63. */
  64. void elements_multiline_text_aligned(
  65. Canvas* canvas,
  66. uint8_t x,
  67. uint8_t y,
  68. Align horizontal,
  69. Align vertical,
  70. const char* text);
  71. /** Draw multiline text
  72. * @param x, y - top left corner coordinates
  73. * @param text - string (possible multiline)
  74. */
  75. void elements_multiline_text(Canvas* canvas, uint8_t x, uint8_t y, const char* text);
  76. /** Draw framed multiline text
  77. * @param x, y - top left corner coordinates
  78. * @param text - string (possible multiline)
  79. */
  80. void elements_multiline_text_framed(Canvas* canvas, uint8_t x, uint8_t y, const char* text);
  81. /** Draw slightly rounded frame
  82. * @param x, y - top left corner coordinates
  83. * @param width, height - size of frame
  84. */
  85. void elements_slightly_rounded_frame(
  86. Canvas* canvas,
  87. uint8_t x,
  88. uint8_t y,
  89. uint8_t width,
  90. uint8_t height);
  91. /** Draw slightly rounded box
  92. * @param x, y - top left corner coordinates
  93. * @param width, height - size of box
  94. */
  95. void elements_slightly_rounded_box(
  96. Canvas* canvas,
  97. uint8_t x,
  98. uint8_t y,
  99. uint8_t width,
  100. uint8_t height);
  101. /** Draw bubble frame for text
  102. * @param x - left x coordinates
  103. * @param y - top y coordinate
  104. * @param width - bubble width
  105. * @param height - bubble height
  106. */
  107. void elements_bubble(Canvas* canvas, uint8_t x, uint8_t y, uint8_t width, uint8_t height);
  108. /** Trim string buffer to fit width in pixels
  109. * @param string - string to trim
  110. * @param width - max width
  111. */
  112. void elements_string_fit_width(Canvas* canvas, string_t string, uint8_t width);
  113. #ifdef __cplusplus
  114. }
  115. #endif