| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879 |
- #ifndef SCUFENG_TEXT_H_
- #define SCUFENG_TEXT_H_
- #include <stdint.h>
- #include "cglm/types.h"
- #include "scufeng/engine.h"
- #include "scufeng/Mesh.h"
- #include "scufcont/DString.h"
- typedef struct {
- unsigned int textures[128];
- ivec2 sizes[128];
- ivec2 bearings[128];
- unsigned int advances[128];
- int size_x_max;
- int size_y_max;
- int bearing_y_max;
- } SEFont;
- typedef enum : uint8_t {
- TI_FIXED_WIDTH = 1,
- } SETextInputOptions;
- typedef struct {
- SETextInputOptions opts;
- bool active;
- size_t cursor;
- SEMesh cursor_mesh;
- SEMesh bg_mesh;
- SCDString text;
- int x;
- int y;
- float scale;
- vec3 text_color;
- float fixed_width;
- } SETextInput;
- SEResult se_font_load(
- const char *path,
- const unsigned int pixel_w,
- const unsigned int pixel_h,
- size_t *const font_id
- );
- void se_font_set(const size_t font_id);
- SEFont *se_font_current_get();
- size_t se_font_current_get_id();
- int se_text_render(
- const char *text,
- int x,
- int y,
- float scale,
- const vec3 color
- );
- SETextInput SETextInput_alloc(
- const char *text,
- const size_t text_len,
- const int x,
- const int y,
- vec3 color,
- vec4 bg_color,
- const SETextInputOptions opts
- );
- void SETextInput_free(SETextInput *const ti);
- void SETextInput_deactivate();
- void SETextInput_activate(SETextInput *const ti);
- SCDString *SETextInput_string_get_ref(SETextInput *const ti);
- SEResult SETextInput_text_copy(const SETextInput *const ti, SCDString *const dst);
- const char *SETextInput_c_str(const SETextInput *const ti);
- SEResult SETextInput_char_insert_at_cursor(SETextInput *const ti, const char ch);
- void SETextInput_char_remove_at_cursor(SETextInput *const ti);
- bool SETextInput_is_pos_inside(const SETextInput *const ti, const float x, const float y);
- void SETextInput_fixed_width_set(SETextInput *const ti, const float w);
- void SETextInput_render_2d(SETextInput *const ti);
- void SETextInput_render_multiple_2d(SETextInput *const *const tis, const size_t ti_count);
- #endif // SCUFENG_TEXT_H_
|