elements.h 3.1 KB

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