1 #pragma once 2 3 #include <stdint.h> 4 #include <stdbool.h> 5 #include <SDL2/SDL.h> 6 7 enum // TEXTBOXES 8 { 9 TB_RES_1, // reserved 10 11 TB_INST1, 12 TB_INST2, 13 TB_INST3, 14 TB_INST4, 15 TB_INST5, 16 TB_INST6, 17 TB_INST7, 18 TB_INST8, 19 20 TB_SAMP1, 21 TB_SAMP2, 22 TB_SAMP3, 23 TB_SAMP4, 24 TB_SAMP5, 25 26 TB_SONG_NAME, 27 28 TB_DISKOP_FILENAME, 29 30 TB_CONF_DEF_MODS_DIR, 31 TB_CONF_DEF_INSTRS_DIR, 32 TB_CONF_DEF_SAMPS_DIR, 33 TB_CONF_DEF_PATTS_DIR, 34 TB_CONF_DEF_TRACKS_DIR, 35 36 NUM_TEXTBOXES 37 }; 38 39 #define TEXT_CURSOR_BLINK_RATE 6 40 #define TEXT_SCROLL_VALUE 30 41 42 enum 43 { 44 TEXTBOX_NO_UPDATE = 0, 45 TEXTBOX_UPDATE = 1 46 }; 47 48 typedef struct textBox_t // DO NOT TOUCH! 49 { 50 uint16_t x, y, w; 51 uint8_t h, tx, ty; 52 uint16_t maxChars; 53 bool rightMouseButton, changeMouseCursor; 54 55 // these ones are changed at run time 56 char *textPtr; 57 bool visible; 58 uint8_t *renderBuf; 59 int16_t cursorPos; 60 uint16_t renderW, renderBufW, renderBufH; 61 int32_t bufOffset; 62 } textBox_t; 63 64 bool textIsMarked(void); 65 void exitTextEditing(void); 66 int16_t getTextCursorX(textBox_t *t); 67 int16_t getTextCursorY(textBox_t *t); 68 void drawTextBox(uint16_t textBoxID); 69 void showTextBox(uint16_t textBoxID); 70 void hideTextBox(uint16_t textBoxID); 71 bool testTextBoxMouseDown(void); 72 void updateTextBoxPointers(void); 73 void setupInitialTextBoxPointers(void); 74 void setTextCursorToEnd(textBox_t *t); 75 void handleTextEditControl(SDL_Keycode keycode); 76 void handleTextEditInputChar(char textChar); 77 void handleTextBoxWhileMouseDown(void); 78 void freeTextBoxes(void); 79