1
0

text.h 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. #ifndef SCUFENG_TEXT_H_
  2. #define SCUFENG_TEXT_H_
  3. #include <stdint.h>
  4. #include "cglm/types.h"
  5. #include "scufeng/engine.h"
  6. #include "scufeng/Mesh.h"
  7. #include "scufcont/DString.h"
  8. typedef enum : uint8_t {
  9. TI_FIXED_WIDTH = 1,
  10. } SETextInputOptions;
  11. typedef struct {
  12. SETextInputOptions opts;
  13. bool active;
  14. size_t cursor;
  15. SEMesh cursor_mesh;
  16. SEMesh bg_mesh;
  17. SCDString text;
  18. int x;
  19. int y;
  20. float scale;
  21. vec3 text_color;
  22. float fixed_width;
  23. } SETextInput;
  24. SEResult se_font_load(
  25. const char *path,
  26. const unsigned int pixel_w,
  27. const unsigned int pixel_h
  28. );
  29. int se_text_render(
  30. const char *text,
  31. int x,
  32. int y,
  33. float scale,
  34. const vec3 color
  35. );
  36. SETextInput SETextInput_alloc(
  37. const char *text,
  38. const size_t text_len,
  39. const int x,
  40. const int y,
  41. vec3 color,
  42. vec4 bg_color,
  43. const SETextInputOptions opts
  44. );
  45. void SETextInput_free(SETextInput *const ti);
  46. void SETextInput_deactivate();
  47. void SETextInput_activate(SETextInput *const ti);
  48. SEResult SETextInput_char_insert_at_cursor(SETextInput *const ti, const char ch);
  49. void SETextInput_char_remove_at_cursor(SETextInput *const ti);
  50. bool SETextInput_is_pos_inside(const SETextInput *const ti, const float x, const float y);
  51. void SETextInput_fixed_width_set(SETextInput *const ti, const float w);
  52. void SETextInput_render_2d(SETextInput *const ti);
  53. void SETextInput_render_multiple_2d(SETextInput *const *const tis, const size_t ti_count);
  54. #endif // SCUFENG_TEXT_H_