elements.h 3.0 KB

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