#include #include #ifndef UI_ELEMENTS_H #define UI_ELEMENTS_H static const float SCROLL_SENC = 10; static const float TAB_WIDTH = 4; static const int MIN_FONT_SIZE = 10; static const int MAX_FONT_SIZE = 100; void DrawRecBordered(Rectangle rec, Color bg, Color border_color, int border_width); void DrawTextInRec(Rectangle rec, char *text, Font *font, int height, Color color, float padding, int *scroll); float MeasureChar(Font *font, int height, char symbol); bool IsMouseInRec(Rectangle rec); // ========== TEXT EDITOR ========== static const size_t DEFAULT_TEXT_NODE_SIZE = 256; typedef struct { void *PrevNode; void *NextNode; char *text; size_t len; size_t cap; } TextNode; typedef struct { Font *font; int font_size; int spacing; int scroll_h; int scroll_v; /// DO NOT MODIFY THAT! It's for internal use only int _area_width; /// DO NOT MODIFY THAT! It's for internal use only int _area_height; } TextAreaDisplayParams; typedef struct { TextNode *StartNode; /// For the quick access TextNode *CurrentNode; size_t NodeLenth; Vector2 CursorPosition; TextAreaDisplayParams *DisplayParams; } TextArea; TextArea *CreateTextArea(TextAreaDisplayParams *DisplayParams); TextArea *CreateTextAreaFromText(TextAreaDisplayParams *DisplayParams, char *text); void DrawTextArea(TextArea *ta, Rectangle rec); void UpdateTextArea(TextArea *ta, Rectangle rec); char *GetText(TextArea *ta); void FreeTextArea(TextArea *ta); #endif // UI_ELEMENTS_H