319 #define RAYGUI_VERSION_MAJOR 4 320 #define RAYGUI_VERSION_MINOR 1 321 #define RAYGUI_VERSION_PATCH 0 322 #define RAYGUI_VERSION "4.1-dev" 324 #if !defined(RAYGUI_STANDALONE) 331 #if defined(BUILD_LIBTYPE_SHARED) 332 #define RAYGUIAPI __declspec(dllexport) // We are building the library as a Win32 shared library (.dll) 333 #elif defined(USE_LIBTYPE_SHARED) 334 #define RAYGUIAPI __declspec(dllimport) // We are using the library as a Win32 shared library (.dll) 340 #define RAYGUIAPI // Functions defined as 'extern' by default (implicit specifiers) 347 #ifndef RAYGUI_MALLOC 348 #define RAYGUI_MALLOC(sz) malloc(sz) 350 #ifndef RAYGUI_CALLOC 351 #define RAYGUI_CALLOC(n,sz) calloc(n,sz) 354 #define RAYGUI_FREE(p) free(p) 359 #define RAYGUI_SUPPORT_LOG_INFO 360 #if defined(RAYGUI_SUPPORT_LOG_INFO) 361 #define RAYGUI_LOG(...) printf(__VA_ARGS__) 363 #define RAYGUI_LOG(...) 370 #if defined(RAYGUI_STANDALONE) 374 typedef enum {
false,
true } bool;
392 typedef struct Color {
418 typedef struct Image {
437 typedef struct Font {
450 unsigned short controlId;
451 unsigned short propertyId;
489 } GuiTextAlignmentVertical;
525 BORDER_COLOR_NORMAL = 0,
528 BORDER_COLOR_FOCUSED,
531 BORDER_COLOR_PRESSED,
534 BORDER_COLOR_DISABLED,
544 } GuiControlProperty;
563 TEXT_ALIGNMENT_VERTICAL,
567 } GuiDefaultProperty;
592 PROGRESS_PADDING = 16,
593 } GuiProgressBarProperty;
599 SCROLL_SLIDER_PADDING,
603 } GuiScrollBarProperty;
608 } GuiCheckBoxProperty;
612 COMBO_BUTTON_WIDTH = 16,
614 } GuiComboBoxProperty;
619 DROPDOWN_ITEMS_SPACING,
620 DROPDOWN_ARROW_HIDDEN
621 } GuiDropdownBoxProperty;
626 } GuiTextBoxProperty;
630 SPIN_BUTTON_WIDTH = 16,
632 } GuiSpinnerProperty;
636 LIST_ITEMS_HEIGHT = 16,
640 LIST_ITEMS_BORDER_WIDTH
641 } GuiListViewProperty;
645 COLOR_SELECTOR_SIZE = 16,
648 HUEBAR_SELECTOR_HEIGHT,
649 HUEBAR_SELECTOR_OVERFLOW
650 } GuiColorPickerProperty;
652 #define SCROLLBAR_LEFT_SIDE 0 653 #define SCROLLBAR_RIGHT_SIDE 1 664 #if defined(__cplusplus) 669 RAYGUIAPI
void GuiEnable(
void);
670 RAYGUIAPI
void GuiDisable(
void);
671 RAYGUIAPI
void GuiLock(
void);
672 RAYGUIAPI
void GuiUnlock(
void);
673 RAYGUIAPI
bool GuiIsLocked(
void);
674 RAYGUIAPI
void GuiSetAlpha(
float alpha);
675 RAYGUIAPI
void GuiSetState(
int state);
676 RAYGUIAPI
int GuiGetState(
void);
679 RAYGUIAPI
void GuiSetFont(
Font font);
680 RAYGUIAPI
Font GuiGetFont(
void);
683 RAYGUIAPI
void GuiSetStyle(
int control,
int property,
int value);
684 RAYGUIAPI
int GuiGetStyle(
int control,
int property);
687 RAYGUIAPI
void GuiLoadStyle(
const char *fileName);
688 RAYGUIAPI
void GuiLoadStyleDefault(
void);
691 RAYGUIAPI
void GuiEnableTooltip(
void);
692 RAYGUIAPI
void GuiDisableTooltip(
void);
693 RAYGUIAPI
void GuiSetTooltip(
const char *tooltip);
696 RAYGUIAPI
const char *GuiIconText(
int iconId,
const char *text);
697 #if !defined(RAYGUI_NO_ICONS) 698 RAYGUIAPI
void GuiSetIconScale(
int scale);
699 RAYGUIAPI
unsigned int *GuiGetIcons(
void);
700 RAYGUIAPI
char **GuiLoadIcons(
const char *fileName,
bool loadIconsName);
701 RAYGUIAPI
void GuiDrawIcon(
int iconId,
int posX,
int posY,
int pixelSize,
Color color);
707 RAYGUIAPI
int GuiWindowBox(
Rectangle bounds,
const char *title);
708 RAYGUIAPI
int GuiGroupBox(
Rectangle bounds,
const char *text);
709 RAYGUIAPI
int GuiLine(
Rectangle bounds,
const char *text);
710 RAYGUIAPI
int GuiPanel(
Rectangle bounds,
const char *text);
711 RAYGUIAPI
int GuiTabBar(
Rectangle bounds,
const char **text,
int count,
int *active);
715 RAYGUIAPI
int GuiLabel(
Rectangle bounds,
const char *text);
716 RAYGUIAPI
int GuiButton(
Rectangle bounds,
const char *text);
717 RAYGUIAPI
int GuiLabelButton(
Rectangle bounds,
const char *text);
718 RAYGUIAPI
int GuiToggle(
Rectangle bounds,
const char *text,
bool *active);
719 RAYGUIAPI
int GuiToggleGroup(
Rectangle bounds,
const char *text,
int *active);
720 RAYGUIAPI
int GuiToggleSlider(
Rectangle bounds,
const char *text,
int *active);
721 RAYGUIAPI
int GuiCheckBox(
Rectangle bounds,
const char *text,
bool *checked);
722 RAYGUIAPI
int GuiComboBox(
Rectangle bounds,
const char *text,
int *active);
724 RAYGUIAPI
int GuiDropdownBox(
Rectangle bounds,
const char *text,
int *active,
bool editMode);
725 RAYGUIAPI
int GuiSpinner(
Rectangle bounds,
const char *text,
int *value,
int minValue,
int maxValue,
bool editMode);
726 RAYGUIAPI
int GuiValueBox(
Rectangle bounds,
const char *text,
int *value,
int minValue,
int maxValue,
bool editMode);
727 RAYGUIAPI
int GuiValueBoxFloat(
Rectangle bounds,
const char* text,
char *textValue,
float *value,
bool editMode);
728 RAYGUIAPI
int GuiTextBox(
Rectangle bounds,
char *text,
int textSize,
bool editMode);
730 RAYGUIAPI
int GuiSlider(
Rectangle bounds,
const char *textLeft,
const char *textRight,
float *value,
float minValue,
float maxValue);
731 RAYGUIAPI
int GuiSliderBar(
Rectangle bounds,
const char *textLeft,
const char *textRight,
float *value,
float minValue,
float maxValue);
732 RAYGUIAPI
int GuiProgressBar(
Rectangle bounds,
const char *textLeft,
const char *textRight,
float *value,
float minValue,
float maxValue);
733 RAYGUIAPI
int GuiStatusBar(
Rectangle bounds,
const char *text);
734 RAYGUIAPI
int GuiDummyRec(
Rectangle bounds,
const char *text);
735 RAYGUIAPI
int GuiGrid(
Rectangle bounds,
const char *text,
float spacing,
int subdivs,
Vector2 *mouseCell);
738 RAYGUIAPI
int GuiListView(
Rectangle bounds,
const char *text,
int *scrollIndex,
int *active);
739 RAYGUIAPI
int GuiListViewEx(
Rectangle bounds,
const char **text,
int count,
int *scrollIndex,
int *active,
int *focus);
740 RAYGUIAPI
int GuiMessageBox(
Rectangle bounds,
const char *title,
const char *message,
const char *buttons);
741 RAYGUIAPI
int GuiTextInputBox(
Rectangle bounds,
const char *title,
const char *message,
const char *buttons,
char *text,
int textMaxSize,
bool *secretViewActive);
742 RAYGUIAPI
int GuiColorPicker(
Rectangle bounds,
const char *text,
Color *color);
743 RAYGUIAPI
int GuiColorPanel(
Rectangle bounds,
const char *text,
Color *color);
744 RAYGUIAPI
int GuiColorBarAlpha(
Rectangle bounds,
const char *text,
float *alpha);
745 RAYGUIAPI
int GuiColorBarHue(
Rectangle bounds,
const char *text,
float *value);
746 RAYGUIAPI
int GuiColorPickerHSV(
Rectangle bounds,
const char *text,
Vector3 *colorHsv);
747 RAYGUIAPI
int GuiColorPanelHSV(
Rectangle bounds,
const char *text,
Vector3 *colorHsv);
750 #if !defined(RAYGUI_NO_ICONS) 752 #if !defined(RAYGUI_CUSTOM_ICONS) 758 ICON_FOLDER_FILE_OPEN = 1,
759 ICON_FILE_SAVE_CLASSIC = 2,
760 ICON_FOLDER_OPEN = 3,
761 ICON_FOLDER_SAVE = 4,
764 ICON_FILE_EXPORT = 7,
766 ICON_FILE_DELETE = 9,
767 ICON_FILETYPE_TEXT = 10,
768 ICON_FILETYPE_AUDIO = 11,
769 ICON_FILETYPE_IMAGE = 12,
770 ICON_FILETYPE_PLAY = 13,
771 ICON_FILETYPE_VIDEO = 14,
772 ICON_FILETYPE_INFO = 15,
775 ICON_FILE_PASTE = 18,
776 ICON_CURSOR_HAND = 19,
777 ICON_CURSOR_POINTER = 20,
778 ICON_CURSOR_CLASSIC = 21,
780 ICON_PENCIL_BIG = 23,
781 ICON_BRUSH_CLASSIC = 24,
782 ICON_BRUSH_PAINTER = 25,
783 ICON_WATER_DROP = 26,
784 ICON_COLOR_PICKER = 27,
786 ICON_COLOR_BUCKET = 29,
791 ICON_FILTER_POINT = 34,
792 ICON_FILTER_BILINEAR = 35,
794 ICON_CROP_ALPHA = 37,
795 ICON_SQUARE_TOGGLE = 38,
797 ICON_SYMMETRY_HORIZONTAL = 40,
798 ICON_SYMMETRY_VERTICAL = 41,
803 ICON_FILTER_TOP = 46,
805 ICON_TARGET_POINT = 48,
806 ICON_TARGET_SMALL = 49,
807 ICON_TARGET_BIG = 50,
808 ICON_TARGET_MOVE = 51,
809 ICON_CURSOR_MOVE = 52,
810 ICON_CURSOR_SCALE = 53,
811 ICON_CURSOR_SCALE_RIGHT = 54,
812 ICON_CURSOR_SCALE_LEFT = 55,
822 ICON_TARGET_SMALL_FILL = 65,
823 ICON_TARGET_BIG_FILL = 66,
824 ICON_TARGET_MOVE_FILL = 67,
825 ICON_CURSOR_MOVE_FILL = 68,
826 ICON_CURSOR_SCALE_FILL = 69,
827 ICON_CURSOR_SCALE_RIGHT_FILL = 70,
828 ICON_CURSOR_SCALE_LEFT_FILL = 71,
831 ICON_REREDO_FILL = 74,
832 ICON_MUTATE_FILL = 75,
833 ICON_ROTATE_FILL = 76,
834 ICON_REPEAT_FILL = 77,
835 ICON_SHUFFLE_FILL = 78,
836 ICON_EMPTYBOX_SMALL = 79,
839 ICON_BOX_TOP_RIGHT = 82,
841 ICON_BOX_BOTTOM_RIGHT = 84,
842 ICON_BOX_BOTTOM = 85,
843 ICON_BOX_BOTTOM_LEFT = 86,
845 ICON_BOX_TOP_LEFT = 88,
846 ICON_BOX_CENTER = 89,
847 ICON_BOX_CIRCLE_MASK = 90,
849 ICON_ALPHA_MULTIPLY = 92,
850 ICON_ALPHA_CLEAR = 93,
855 ICON_BOX_CORNERS_SMALL = 98,
856 ICON_BOX_CORNERS_BIG = 99,
857 ICON_FOUR_BOXES = 100,
858 ICON_GRID_FILL = 101,
859 ICON_BOX_MULTISIZE = 102,
860 ICON_ZOOM_SMALL = 103,
861 ICON_ZOOM_MEDIUM = 104,
864 ICON_ZOOM_CENTER = 107,
865 ICON_BOX_DOTS_SMALL = 108,
866 ICON_BOX_DOTS_BIG = 109,
867 ICON_BOX_CONCENTRIC = 110,
868 ICON_BOX_GRID_BIG = 111,
871 ICON_ARROW_LEFT = 114,
872 ICON_ARROW_RIGHT = 115,
873 ICON_ARROW_DOWN = 116,
875 ICON_ARROW_LEFT_FILL = 118,
876 ICON_ARROW_RIGHT_FILL = 119,
877 ICON_ARROW_DOWN_FILL = 120,
878 ICON_ARROW_UP_FILL = 121,
882 ICON_WAVE_SINUS = 125,
883 ICON_WAVE_SQUARE = 126,
884 ICON_WAVE_TRIANGULAR = 127,
885 ICON_CROSS_SMALL = 128,
886 ICON_PLAYER_PREVIOUS = 129,
887 ICON_PLAYER_PLAY_BACK = 130,
888 ICON_PLAYER_PLAY = 131,
889 ICON_PLAYER_PAUSE = 132,
890 ICON_PLAYER_STOP = 133,
891 ICON_PLAYER_NEXT = 134,
892 ICON_PLAYER_RECORD = 135,
894 ICON_LOCK_CLOSE = 137,
895 ICON_LOCK_OPEN = 138,
901 ICON_HAND_POINTER = 144,
904 ICON_EXPLOSION = 147,
907 ICON_PLAYER_JUMP = 150,
910 ICON_TEXT_POPUP = 153,
913 ICON_CRACK_POINTS = 156,
920 ICON_CUBE_FACE_TOP = 163,
921 ICON_CUBE_FACE_LEFT = 164,
922 ICON_CUBE_FACE_FRONT = 165,
923 ICON_CUBE_FACE_BOTTOM = 166,
924 ICON_CUBE_FACE_RIGHT = 167,
925 ICON_CUBE_FACE_BACK = 168,
929 ICON_LINK_BOXES = 172,
930 ICON_LINK_MULTI = 173,
932 ICON_LINK_BROKE = 175,
933 ICON_TEXT_NOTES = 176,
936 ICON_SUITCASE_ZIP = 179,
940 ICON_PHOTO_CAMERA = 183,
941 ICON_PHOTO_CAMERA_FLASH = 184,
945 ICON_VERTICAL_BARS = 188,
946 ICON_VERTICAL_BARS_FILL = 189,
947 ICON_LIFE_BARS = 190,
949 ICON_CROSSLINE = 192,
951 ICON_FILETYPE_ALPHA = 194,
952 ICON_FILETYPE_HOME = 195,
953 ICON_LAYERS_VISIBLE = 196,
957 ICON_FILETYPE_BINARY = 200,
961 ICON_FOLDER_ADD = 204,
965 ICON_STEP_OVER = 208,
966 ICON_STEP_INTO = 209,
969 ICON_BREAKPOINT_ON = 212,
970 ICON_BREAKPOINT_OFF = 213,
971 ICON_BURGER_MENU = 214,
972 ICON_CASE_SENSITIVE = 215,
976 ICON_SAND_TIMER = 219,
1018 #if defined(__cplusplus) 1030 #if defined(RAYGUI_IMPLEMENTATION) 1039 #define RAYGUI_CLITERAL(name) name 1041 #define RAYGUI_CLITERAL(name) (name) 1045 #ifndef CHECK_BOUNDS_ID 1046 #define CHECK_BOUNDS_ID(src, dst) ((src.x == dst.x) && (src.y == dst.y) && (src.width == dst.width) && (src.height == dst.height)) 1049 #if !defined(RAYGUI_NO_ICONS) && !defined(RAYGUI_CUSTOM_ICONS) 1052 #define RAYGUI_ICON_SIZE 16 // Size of icons in pixels (squared) 1053 #define RAYGUI_ICON_MAX_ICONS 256 // Maximum number of icons 1054 #define RAYGUI_ICON_MAX_NAME_LENGTH 32 // Maximum length of icon name id 1061 #define RAYGUI_ICON_DATA_ELEMENTS (RAYGUI_ICON_SIZE*RAYGUI_ICON_SIZE/32) 1074 static unsigned int guiIcons[RAYGUI_ICON_MAX_ICONS*RAYGUI_ICON_DATA_ELEMENTS] = {
1075 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1076 0x3ff80000, 0x2f082008, 0x2042207e, 0x40027fc2, 0x40024002, 0x40024002, 0x40024002, 0x00007ffe,
1077 0x3ffe0000, 0x44226422, 0x400247e2, 0x5ffa4002, 0x57ea500a, 0x500a500a, 0x40025ffa, 0x00007ffe,
1078 0x00000000, 0x0042007e, 0x40027fc2, 0x40024002, 0x41024002, 0x44424282, 0x793e4102, 0x00000100,
1079 0x00000000, 0x0042007e, 0x40027fc2, 0x40024002, 0x41024102, 0x44424102, 0x793e4282, 0x00000000,
1080 0x3ff00000, 0x201c2010, 0x20042004, 0x21042004, 0x24442284, 0x21042104, 0x20042104, 0x00003ffc,
1081 0x3ff00000, 0x201c2010, 0x20042004, 0x21042004, 0x21042104, 0x22842444, 0x20042104, 0x00003ffc,
1082 0x3ff00000, 0x201c2010, 0x00042004, 0x20041004, 0x20844784, 0x00841384, 0x20042784, 0x00003ffc,
1083 0x3ff00000, 0x201c2010, 0x20042004, 0x20042004, 0x22042204, 0x22042f84, 0x20042204, 0x00003ffc,
1084 0x3ff00000, 0x201c2010, 0x20042004, 0x20042004, 0x25042884, 0x25042204, 0x20042884, 0x00003ffc,
1085 0x3ff00000, 0x201c2010, 0x20042004, 0x20042ff4, 0x20042ff4, 0x20042ff4, 0x20042004, 0x00003ffc,
1086 0x3ff00000, 0x201c2010, 0x27042004, 0x244424c4, 0x26442444, 0x20642664, 0x20042004, 0x00003ffc,
1087 0x3ff00000, 0x201c2010, 0x26042604, 0x20042004, 0x35442884, 0x2414222c, 0x20042004, 0x00003ffc,
1088 0x3ff00000, 0x201c2010, 0x20c42004, 0x22442144, 0x22442444, 0x20c42144, 0x20042004, 0x00003ffc,
1089 0x3ff00000, 0x3ffc2ff0, 0x3f3c2ff4, 0x3dbc2eb4, 0x3dbc2bb4, 0x3f3c2eb4, 0x3ffc2ff4, 0x00002ff4,
1090 0x3ff00000, 0x201c2010, 0x21842184, 0x21842004, 0x21842184, 0x21842184, 0x20042184, 0x00003ffc,
1091 0x0ff00000, 0x381c0810, 0x28042804, 0x28042804, 0x28042804, 0x28042804, 0x20102ffc, 0x00003ff0,
1092 0x00000000, 0x701c0000, 0x079c1e14, 0x55a000f0, 0x079c00f0, 0x701c1e14, 0x00000000, 0x00000000,
1093 0x01c00000, 0x13e41bec, 0x3f841004, 0x204420c4, 0x20442044, 0x20442044, 0x207c2044, 0x00003fc0,
1094 0x00000000, 0x3aa00fe0, 0x2abc2aa0, 0x2aa42aa4, 0x20042aa4, 0x20042004, 0x3ffc2004, 0x00000000,
1095 0x00000000, 0x003c000c, 0x030800c8, 0x30100c10, 0x10202020, 0x04400840, 0x01800280, 0x00000000,
1096 0x00000000, 0x00180000, 0x01f00078, 0x03e007f0, 0x07c003e0, 0x04000e40, 0x00000000, 0x00000000,
1097 0x00000000, 0x04000000, 0x11000a00, 0x04400a80, 0x01100220, 0x00580088, 0x00000038, 0x00000000,
1098 0x04000000, 0x15000a00, 0x50402880, 0x14102820, 0x05040a08, 0x015c028c, 0x007c00bc, 0x00000000,
1099 0x01c00000, 0x01400140, 0x01400140, 0x0ff80140, 0x0ff80808, 0x0aa80808, 0x0aa80aa8, 0x00000ff8,
1100 0x1ffc0000, 0x5ffc7ffe, 0x40004000, 0x00807f80, 0x01c001c0, 0x01c001c0, 0x01c001c0, 0x00000080,
1101 0x00000000, 0x00800000, 0x01c00080, 0x03e001c0, 0x07f003e0, 0x036006f0, 0x000001c0, 0x00000000,
1102 0x00000000, 0x3e003800, 0x1f803f80, 0x0c201e40, 0x02080c10, 0x00840104, 0x00380044, 0x00000000,
1103 0x00000000, 0x07800300, 0x1fe00fc0, 0x3f883fd0, 0x0e021f04, 0x02040402, 0x00f00108, 0x00000000,
1104 0x00c00000, 0x02800140, 0x08200440, 0x20081010, 0x2ffe3004, 0x03f807fc, 0x00e001f0, 0x00000040,
1105 0x00000000, 0x21843ffc, 0x01800180, 0x01800180, 0x01800180, 0x01800180, 0x03c00180, 0x00000000,
1106 0x00800000, 0x01400180, 0x06200340, 0x0c100620, 0x1ff80c10, 0x380c1808, 0x70067004, 0x0000f80f,
1107 0x78000000, 0x50004000, 0x00004800, 0x03c003c0, 0x03c003c0, 0x00100000, 0x0002000a, 0x0000000e,
1108 0x75560000, 0x5e004002, 0x54001002, 0x41001202, 0x408200fe, 0x40820082, 0x40820082, 0x00006afe,
1109 0x00000000, 0x3f003f00, 0x3f003f00, 0x3f003f00, 0x00400080, 0x001c0020, 0x001c001c, 0x00000000,
1110 0x6d800000, 0x00004080, 0x40804080, 0x40800000, 0x00406d80, 0x001c0020, 0x001c001c, 0x00000000,
1111 0x40080000, 0x1ffe2008, 0x14081008, 0x11081208, 0x10481088, 0x10081028, 0x10047ff8, 0x00001002,
1112 0x00100000, 0x3ffc0010, 0x2ab03550, 0x22b02550, 0x20b02150, 0x20302050, 0x2000fff0, 0x00002000,
1113 0x40000000, 0x1ff82000, 0x04082808, 0x01082208, 0x00482088, 0x00182028, 0x35542008, 0x00000002,
1114 0x00000000, 0x02800280, 0x06c006c0, 0x0ea00ee0, 0x1e901eb0, 0x3e883e98, 0x7efc7e8c, 0x00000000,
1115 0x01000000, 0x05600100, 0x1d480d50, 0x7d423d44, 0x3d447d42, 0x0d501d48, 0x01000560, 0x00000100,
1116 0x01800000, 0x04200240, 0x10080810, 0x00001ff8, 0x00007ffe, 0x0ff01ff8, 0x03c007e0, 0x00000180,
1117 0x00000000, 0x010800f0, 0x02040204, 0x02040204, 0x07f00308, 0x1c000e00, 0x30003800, 0x00000000,
1118 0x00000000, 0x061803f0, 0x08240c0c, 0x08040814, 0x0c0c0804, 0x23f01618, 0x18002400, 0x00000000,
1119 0x00000000, 0x00000000, 0x1c7007c0, 0x638e3398, 0x1c703398, 0x000007c0, 0x00000000, 0x00000000,
1120 0x00000000, 0x10002000, 0x04700fc0, 0x610e3218, 0x1c703098, 0x001007a0, 0x00000008, 0x00000000,
1121 0x00000000, 0x00007ffc, 0x40047ffc, 0x10102008, 0x04400820, 0x02800280, 0x02800280, 0x00000100,
1122 0x00000000, 0x40027ffe, 0x10082004, 0x04200810, 0x02400240, 0x02400240, 0x01400240, 0x000000c0,
1123 0x00800000, 0x00800080, 0x00000080, 0x3c9e0000, 0x00000000, 0x00800080, 0x00800080, 0x00000000,
1124 0x00800000, 0x00800080, 0x00800080, 0x3f7e01c0, 0x008001c0, 0x00800080, 0x00800080, 0x00000000,
1125 0x00800000, 0x00800080, 0x03e00080, 0x3e3e0220, 0x03e00220, 0x00800080, 0x00800080, 0x00000000,
1126 0x01000000, 0x04400280, 0x01000100, 0x43842008, 0x43849ab2, 0x01002008, 0x04400100, 0x01000280,
1127 0x01000000, 0x04400280, 0x01000100, 0x41042108, 0x41049ff2, 0x01002108, 0x04400100, 0x01000280,
1128 0x781e0000, 0x500a4002, 0x04204812, 0x00000240, 0x02400000, 0x48120420, 0x4002500a, 0x0000781e,
1129 0x00000000, 0x20003c00, 0x24002800, 0x01000200, 0x00400080, 0x00140024, 0x003c0004, 0x00000000,
1130 0x00000000, 0x0004003c, 0x00240014, 0x00800040, 0x02000100, 0x28002400, 0x3c002000, 0x00000000,
1131 0x00000000, 0x00100020, 0x10101fc8, 0x10001020, 0x10001000, 0x10001000, 0x00001fc0, 0x00000000,
1132 0x00000000, 0x08000400, 0x080813f8, 0x00080408, 0x00080008, 0x00080008, 0x000003f8, 0x00000000,
1133 0x00000000, 0x3ffc0000, 0x20042004, 0x20002000, 0x20402000, 0x3f902020, 0x00400020, 0x00000000,
1134 0x00000000, 0x3ffc0000, 0x20042004, 0x27fc2004, 0x20202000, 0x3fc82010, 0x00200010, 0x00000000,
1135 0x00000000, 0x0ff00000, 0x10081818, 0x11801008, 0x10001180, 0x18101020, 0x00100fc8, 0x00000020,
1136 0x00000000, 0x04000200, 0x240429fc, 0x20042204, 0x20442004, 0x3f942024, 0x00400020, 0x00000000,
1137 0x00000000, 0x20001000, 0x22104c0e, 0x00801120, 0x11200040, 0x4c0e2210, 0x10002000, 0x00000000,
1138 0x7ffe0000, 0x50024002, 0x44024802, 0x41024202, 0x40424082, 0x40124022, 0x4002400a, 0x00007ffe,
1139 0x00800000, 0x03e00080, 0x08080490, 0x3c9e0808, 0x08080808, 0x03e00490, 0x00800080, 0x00000000,
1140 0x00800000, 0x00800080, 0x00800080, 0x3ffe01c0, 0x008001c0, 0x00800080, 0x00800080, 0x00000000,
1141 0x00800000, 0x00800080, 0x03e00080, 0x3ffe03e0, 0x03e003e0, 0x00800080, 0x00800080, 0x00000000,
1142 0x01000000, 0x07c00380, 0x01000100, 0x638c2008, 0x638cfbbe, 0x01002008, 0x07c00100, 0x01000380,
1143 0x01000000, 0x07c00380, 0x01000100, 0x610c2108, 0x610cfffe, 0x01002108, 0x07c00100, 0x01000380,
1144 0x781e0000, 0x6006700e, 0x04204812, 0x00000240, 0x02400000, 0x48120420, 0x700e6006, 0x0000781e,
1145 0x00000000, 0x38003c00, 0x24003000, 0x01000200, 0x00400080, 0x000c0024, 0x003c001c, 0x00000000,
1146 0x00000000, 0x001c003c, 0x0024000c, 0x00800040, 0x02000100, 0x30002400, 0x3c003800, 0x00000000,
1147 0x00000000, 0x00300020, 0x10301ff8, 0x10001020, 0x10001000, 0x10001000, 0x00001fc0, 0x00000000,
1148 0x00000000, 0x0c000400, 0x0c081ff8, 0x00080408, 0x00080008, 0x00080008, 0x000003f8, 0x00000000,
1149 0x00000000, 0x3ffc0000, 0x20042004, 0x20002000, 0x20402000, 0x3ff02060, 0x00400060, 0x00000000,
1150 0x00000000, 0x3ffc0000, 0x20042004, 0x27fc2004, 0x20202000, 0x3ff82030, 0x00200030, 0x00000000,
1151 0x00000000, 0x0ff00000, 0x10081818, 0x11801008, 0x10001180, 0x18301020, 0x00300ff8, 0x00000020,
1152 0x00000000, 0x06000200, 0x26042ffc, 0x20042204, 0x20442004, 0x3ff42064, 0x00400060, 0x00000000,
1153 0x00000000, 0x30001000, 0x32107c0e, 0x00801120, 0x11200040, 0x7c0e3210, 0x10003000, 0x00000000,
1154 0x00000000, 0x30043ffc, 0x24042804, 0x21042204, 0x20442084, 0x20142024, 0x3ffc200c, 0x00000000,
1155 0x00000000, 0x20043ffc, 0x20042004, 0x20042004, 0x20042004, 0x20042004, 0x3ffc2004, 0x00000000,
1156 0x00000000, 0x23c43ffc, 0x23c423c4, 0x200423c4, 0x20042004, 0x20042004, 0x3ffc2004, 0x00000000,
1157 0x00000000, 0x3e043ffc, 0x3e043e04, 0x20043e04, 0x20042004, 0x20042004, 0x3ffc2004, 0x00000000,
1158 0x00000000, 0x20043ffc, 0x20042004, 0x3e043e04, 0x3e043e04, 0x20042004, 0x3ffc2004, 0x00000000,
1159 0x00000000, 0x20043ffc, 0x20042004, 0x20042004, 0x3e042004, 0x3e043e04, 0x3ffc3e04, 0x00000000,
1160 0x00000000, 0x20043ffc, 0x20042004, 0x20042004, 0x23c42004, 0x23c423c4, 0x3ffc23c4, 0x00000000,
1161 0x00000000, 0x20043ffc, 0x20042004, 0x20042004, 0x207c2004, 0x207c207c, 0x3ffc207c, 0x00000000,
1162 0x00000000, 0x20043ffc, 0x20042004, 0x207c207c, 0x207c207c, 0x20042004, 0x3ffc2004, 0x00000000,
1163 0x00000000, 0x207c3ffc, 0x207c207c, 0x2004207c, 0x20042004, 0x20042004, 0x3ffc2004, 0x00000000,
1164 0x00000000, 0x20043ffc, 0x20042004, 0x23c423c4, 0x23c423c4, 0x20042004, 0x3ffc2004, 0x00000000,
1165 0x7ffe0000, 0x40024002, 0x47e24182, 0x4ff247e2, 0x47e24ff2, 0x418247e2, 0x40024002, 0x00007ffe,
1166 0x7fff0000, 0x40014001, 0x40014001, 0x49555ddd, 0x4945495d, 0x400149c5, 0x40014001, 0x00007fff,
1167 0x7ffe0000, 0x53327332, 0x44ce4cce, 0x41324332, 0x404e40ce, 0x48125432, 0x4006540e, 0x00007ffe,
1168 0x7ffe0000, 0x53327332, 0x44ce4cce, 0x41324332, 0x5c4e40ce, 0x44124432, 0x40065c0e, 0x00007ffe,
1169 0x7ffe0000, 0x42fe417e, 0x42fe417e, 0x42fe417e, 0x42fe417e, 0x42fe417e, 0x42fe417e, 0x00007ffe,
1170 0x07fe0000, 0x1ffa0002, 0x7fea000a, 0x402a402a, 0x5b2a512a, 0x5128552a, 0x40205128, 0x00007fe0,
1171 0x00000000, 0x1ff80000, 0x12481248, 0x12481ff8, 0x1ff81248, 0x12481248, 0x00001ff8, 0x00000000,
1172 0x12480000, 0x7ffe1248, 0x12481248, 0x12487ffe, 0x7ffe1248, 0x12481248, 0x12487ffe, 0x00001248,
1173 0x00000000, 0x1c380000, 0x1c3817e8, 0x08100810, 0x08100810, 0x17e81c38, 0x00001c38, 0x00000000,
1174 0x700e0000, 0x700e5ffa, 0x20042004, 0x20042004, 0x20042004, 0x20042004, 0x5ffa700e, 0x0000700e,
1175 0x3f7e0000, 0x21422142, 0x21422142, 0x00003f7e, 0x21423f7e, 0x21422142, 0x3f7e2142, 0x00000000,
1176 0x00000000, 0x3bb80000, 0x3bb83bb8, 0x3bb80000, 0x3bb83bb8, 0x3bb80000, 0x3bb83bb8, 0x00000000,
1177 0x7ffe0000, 0x7ffe7ffe, 0x77fe7000, 0x77fe77fe, 0x777e7700, 0x777e777e, 0x777e777e, 0x0000777e,
1178 0x781e0000, 0x40024002, 0x00004002, 0x01800000, 0x00000180, 0x40020000, 0x40024002, 0x0000781e,
1179 0x781e0000, 0x40024002, 0x00004002, 0x03c003c0, 0x03c003c0, 0x40020000, 0x40024002, 0x0000781e,
1180 0x781e0000, 0x40024002, 0x07e04002, 0x07e007e0, 0x07e007e0, 0x400207e0, 0x40024002, 0x0000781e,
1181 0x781e0000, 0x5ffa4002, 0x1ff85ffa, 0x1ff81ff8, 0x1ff81ff8, 0x5ffa1ff8, 0x40025ffa, 0x0000781e,
1182 0x00000000, 0x2004381c, 0x00002004, 0x00000000, 0x00000000, 0x20040000, 0x381c2004, 0x00000000,
1183 0x00000000, 0x1db80000, 0x10081008, 0x10080000, 0x00001008, 0x10081008, 0x00001db8, 0x00000000,
1184 0x35560000, 0x00002002, 0x00002002, 0x00002002, 0x00002002, 0x00002002, 0x35562002, 0x00000000,
1185 0x7ffe0000, 0x40024002, 0x48124ff2, 0x49924812, 0x48124992, 0x4ff24812, 0x40024002, 0x00007ffe,
1186 0x00000000, 0x10841ffc, 0x10841084, 0x1ffc1084, 0x10841084, 0x10841084, 0x00001ffc, 0x00000000,
1187 0x00000000, 0x00000000, 0x10000000, 0x04000800, 0x01040200, 0x00500088, 0x00000020, 0x00000000,
1188 0x00000000, 0x10080000, 0x04200810, 0x01800240, 0x02400180, 0x08100420, 0x00001008, 0x00000000,
1189 0x00000000, 0x02000000, 0x00800100, 0x00200040, 0x00200010, 0x00800040, 0x02000100, 0x00000000,
1190 0x00000000, 0x00400000, 0x01000080, 0x04000200, 0x04000800, 0x01000200, 0x00400080, 0x00000000,
1191 0x00000000, 0x00000000, 0x00000000, 0x08081004, 0x02200410, 0x00800140, 0x00000000, 0x00000000,
1192 0x00000000, 0x00000000, 0x01400080, 0x04100220, 0x10040808, 0x00000000, 0x00000000, 0x00000000,
1193 0x00000000, 0x02000000, 0x03800300, 0x03e003c0, 0x03e003f0, 0x038003c0, 0x02000300, 0x00000000,
1194 0x00000000, 0x00400000, 0x01c000c0, 0x07c003c0, 0x07c00fc0, 0x01c003c0, 0x004000c0, 0x00000000,
1195 0x00000000, 0x00000000, 0x00000000, 0x0ff81ffc, 0x03e007f0, 0x008001c0, 0x00000000, 0x00000000,
1196 0x00000000, 0x00000000, 0x01c00080, 0x07f003e0, 0x1ffc0ff8, 0x00000000, 0x00000000, 0x00000000,
1197 0x00000000, 0x18a008c0, 0x32881290, 0x24822686, 0x26862482, 0x12903288, 0x08c018a0, 0x00000000,
1198 0x00000000, 0x04800780, 0x004000c0, 0x662000f0, 0x08103c30, 0x130a0e18, 0x0000318e, 0x00000000,
1199 0x00000000, 0x00800000, 0x08880888, 0x2aaa0a8a, 0x0a8a2aaa, 0x08880888, 0x00000080, 0x00000000,
1200 0x00000000, 0x00600000, 0x01080090, 0x02040108, 0x42044204, 0x24022402, 0x00001800, 0x00000000,
1201 0x00000000, 0x07f80000, 0x04080408, 0x04080408, 0x04080408, 0x7c0e0408, 0x00000000, 0x00000000,
1202 0x00000000, 0x00000000, 0x00a00040, 0x22084110, 0x08021404, 0x00000000, 0x00000000, 0x00000000,
1203 0x00000000, 0x00000000, 0x04200000, 0x01800240, 0x02400180, 0x00000420, 0x00000000, 0x00000000,
1204 0x00000000, 0x18380000, 0x12281428, 0x10a81128, 0x112810a8, 0x14281228, 0x00001838, 0x00000000,
1205 0x00000000, 0x18000000, 0x11801600, 0x10181060, 0x10601018, 0x16001180, 0x00001800, 0x00000000,
1206 0x00000000, 0x00180000, 0x01880068, 0x18080608, 0x06081808, 0x00680188, 0x00000018, 0x00000000,
1207 0x00000000, 0x1e780000, 0x12481248, 0x12481248, 0x12481248, 0x12481248, 0x00001e78, 0x00000000,
1208 0x00000000, 0x1ff80000, 0x10081008, 0x10081008, 0x10081008, 0x10081008, 0x00001ff8, 0x00000000,
1209 0x00000000, 0x1c180000, 0x14481428, 0x15081488, 0x14881508, 0x14281448, 0x00001c18, 0x00000000,
1210 0x00000000, 0x03c00000, 0x08100420, 0x10081008, 0x10081008, 0x04200810, 0x000003c0, 0x00000000,
1211 0x00000000, 0x0c3007e0, 0x13c81818, 0x14281668, 0x14281428, 0x1c381c38, 0x08102244, 0x00000000,
1212 0x07c00000, 0x08200820, 0x3ff80820, 0x23882008, 0x21082388, 0x20082108, 0x1ff02008, 0x00000000,
1213 0x07c00000, 0x08000800, 0x3ff80800, 0x23882008, 0x21082388, 0x20082108, 0x1ff02008, 0x00000000,
1214 0x01c00000, 0x0c180770, 0x3086188c, 0x60832082, 0x60034781, 0x30062002, 0x0c18180c, 0x01c00770,
1215 0x0a200000, 0x1b201b20, 0x04200e20, 0x04200420, 0x04700420, 0x0e700e70, 0x0e700e70, 0x04200e70,
1216 0x01800000, 0x3bdc318c, 0x0ff01ff8, 0x7c3e1e78, 0x1e787c3e, 0x1ff80ff0, 0x318c3bdc, 0x00000180,
1217 0x01800000, 0x3ffc318c, 0x1c381ff8, 0x781e1818, 0x1818781e, 0x1ff81c38, 0x318c3ffc, 0x00000180,
1218 0x00000000, 0x08080ff8, 0x08081ffc, 0x0aa80aa8, 0x0aa80aa8, 0x0aa80aa8, 0x08080aa8, 0x00000ff8,
1219 0x00000000, 0x00000000, 0x20043ffc, 0x08043f84, 0x04040f84, 0x04040784, 0x000007fc, 0x00000000,
1220 0x00000000, 0x24400400, 0x00001480, 0x6efe0e00, 0x00000e00, 0x24401480, 0x00000400, 0x00000000,
1221 0x00000000, 0x03c00000, 0x08300460, 0x11181118, 0x11181118, 0x04600830, 0x000003c0, 0x00000000,
1222 0x00000000, 0x10880080, 0x06c00810, 0x366c07e0, 0x07e00240, 0x00001768, 0x04200240, 0x00000000,
1223 0x00000000, 0x3d280000, 0x2528252c, 0x3d282528, 0x05280528, 0x05e80528, 0x00000000, 0x00000000,
1224 0x01800000, 0x03c003c0, 0x018003c0, 0x0ff007e0, 0x0bd00bd0, 0x0a500bd0, 0x02400240, 0x02400240,
1225 0x01800000, 0x03c003c0, 0x118013c0, 0x03c81ff8, 0x07c003c8, 0x04400440, 0x0c080478, 0x00000000,
1226 0x3ff80000, 0x30183ff8, 0x30183018, 0x3ff83ff8, 0x03000300, 0x03c003c0, 0x03e00300, 0x000003e0,
1227 0x3ff80000, 0x3ff83ff8, 0x33983ff8, 0x3ff83398, 0x3ff83ff8, 0x00000540, 0x0fe00aa0, 0x00000fe0,
1228 0x00000000, 0x0ff00000, 0x20041008, 0x25442004, 0x10082004, 0x06000bf0, 0x00000300, 0x00000000,
1229 0x00000000, 0x11440000, 0x07f00be8, 0x1c1c0e38, 0x1c1c0c18, 0x07f00e38, 0x11440be8, 0x00000000,
1230 0x00000000, 0x20080000, 0x0c601010, 0x07c00fe0, 0x07c007c0, 0x0c600fe0, 0x20081010, 0x00000000,
1231 0x00000000, 0x20080000, 0x0c601010, 0x04400fe0, 0x04405554, 0x0c600fe0, 0x20081010, 0x00000000,
1232 0x00000000, 0x00800080, 0x01c001c0, 0x1ffc3ffe, 0x03e007f0, 0x07f003e0, 0x0c180770, 0x00000808,
1233 0x0ff00000, 0x08180810, 0x08100818, 0x0a100810, 0x08180810, 0x08100818, 0x08100810, 0x00001ff8,
1234 0x0ff00000, 0x08100810, 0x08100810, 0x10100010, 0x4f902010, 0x10102010, 0x08100010, 0x00000ff0,
1235 0x00040000, 0x001f000e, 0x0ef40004, 0x12f41284, 0x0ef41214, 0x10040004, 0x7ffc3004, 0x10003000,
1236 0x78040000, 0x501f600e, 0x0ef44004, 0x12f41284, 0x0ef41284, 0x10140004, 0x7ffc300c, 0x10003000,
1237 0x7fe00000, 0x50286030, 0x47fe4804, 0x44224402, 0x44224422, 0x241275e2, 0x0c06140a, 0x000007fe,
1238 0x7fe00000, 0x5ff87ff0, 0x47fe4ffc, 0x44224402, 0x44224422, 0x241275e2, 0x0c06140a, 0x000007fe,
1239 0x7fe00000, 0x50386030, 0x47c2483c, 0x443e443e, 0x443e443e, 0x241e75fe, 0x0c06140e, 0x000007fe,
1240 0x7fe00000, 0x50286030, 0x47fe4804, 0x47fe47fe, 0x47fe47fe, 0x27fe77fe, 0x0ffe17fe, 0x000007fe,
1241 0x7fe00000, 0x50286030, 0x47fe4804, 0x44224402, 0x44224422, 0x3bf27be2, 0x0bfe1bfa, 0x000007fe,
1242 0x7fe00000, 0x70286030, 0x7ffe7804, 0x7c227c02, 0x7c227c22, 0x3c127de2, 0x0c061c0a, 0x000007fe,
1243 0x7fe00000, 0x6fe85ff0, 0x781e77e4, 0x7be27be2, 0x7be27be2, 0x24127be2, 0x0c06140a, 0x000007fe,
1244 0x00000000, 0x2a0233fe, 0x22022602, 0x22022202, 0x2a022602, 0x00a033fe, 0x02080110, 0x00000000,
1245 0x00000000, 0x200c3ffc, 0x000c000c, 0x3ffc000c, 0x30003000, 0x30003000, 0x3ffc3004, 0x00000000,
1246 0x00000000, 0x0022003e, 0x012201e2, 0x0100013e, 0x01000100, 0x79000100, 0x4f004900, 0x00007800,
1247 0x00000000, 0x44007c00, 0x45004600, 0x00627cbe, 0x00620022, 0x45007cbe, 0x44004600, 0x00007c00,
1248 0x00000000, 0x0044007c, 0x0010007c, 0x3f100010, 0x3f1021f0, 0x3f100010, 0x3f0021f0, 0x00000000,
1249 0x00000000, 0x0044007c, 0x00440044, 0x0010007c, 0x00100010, 0x44107c10, 0x440047f0, 0x00007c00,
1250 0x00000000, 0x0044007c, 0x00440044, 0x0000007c, 0x00000010, 0x44007c10, 0x44004550, 0x00007c00,
1251 0x02a00000, 0x22a43ffc, 0x20042004, 0x20042ff4, 0x20042ff4, 0x20042ff4, 0x20042004, 0x00003ffc,
1252 0x3ffc0000, 0x20042004, 0x245e27c4, 0x27c42444, 0x2004201e, 0x201e2004, 0x20042004, 0x00003ffc,
1253 0x00000000, 0x07e00000, 0x04200420, 0x24243ffc, 0x24242424, 0x24242424, 0x3ffc2424, 0x00000000,
1254 0x00000000, 0x0fe00000, 0x08200820, 0x40047ffc, 0x7ffc5554, 0x40045554, 0x7ffc4004, 0x00000000,
1255 0x00000000, 0x20043ffc, 0x3ffc2004, 0x13c81008, 0x100813c8, 0x10081008, 0x1ff81008, 0x00000000,
1256 0x00000000, 0x40027ffe, 0x5ffa5ffa, 0x5ffa5ffa, 0x40025ffa, 0x03c07ffe, 0x1ff81ff8, 0x00000000,
1257 0x0ff00000, 0x6bfe7ffe, 0x7ffe7ffe, 0x68167ffe, 0x08106816, 0x08100810, 0x0ff00810, 0x00000000,
1258 0x3ff80000, 0xfffe2008, 0x870a8002, 0x904a888a, 0x904a904a, 0x870a888a, 0xfffe8002, 0x00000000,
1259 0x0fc00000, 0xfcfe0cd8, 0x8002fffe, 0x84428382, 0x84428442, 0x80028382, 0xfffe8002, 0x00000000,
1260 0x00000000, 0x02400180, 0x08100420, 0x20041008, 0x23c42004, 0x22442244, 0x3ffc2244, 0x00000000,
1261 0x00000000, 0x1c700000, 0x3ff83ef8, 0x3ff83ff8, 0x0fe01ff0, 0x038007c0, 0x00000100, 0x00000000,
1262 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x80000000, 0xe000c000,
1263 0x00000000, 0x14001c00, 0x15c01400, 0x15401540, 0x155c1540, 0x15541554, 0x1ddc1554, 0x00000000,
1264 0x00000000, 0x03000300, 0x1b001b00, 0x1b601b60, 0x1b6c1b60, 0x1b6c1b6c, 0x1b6c1b6c, 0x00000000,
1265 0x00000000, 0x00000000, 0x403e7ffe, 0x7ffe403e, 0x7ffe0000, 0x43fe43fe, 0x00007ffe, 0x00000000,
1266 0x7ffc0000, 0x43844004, 0x43844284, 0x43844004, 0x42844284, 0x42844284, 0x40044384, 0x00007ffc,
1267 0x40008000, 0x10002000, 0x04000800, 0x01000200, 0x00400080, 0x00100020, 0x00040008, 0x00010002,
1268 0x00000000, 0x1ff01ff0, 0x18301830, 0x1f001830, 0x03001f00, 0x00000300, 0x03000300, 0x00000000,
1269 0x3ff00000, 0x2abc3550, 0x2aac3554, 0x2aac3554, 0x2aac3554, 0x2aac3554, 0x2aac3554, 0x00003ffc,
1270 0x3ff00000, 0x201c2010, 0x22442184, 0x28142424, 0x29942814, 0x2ff42994, 0x20042004, 0x00003ffc,
1271 0x07fe0000, 0x04020402, 0x7fe20402, 0x44224422, 0x44224422, 0x402047fe, 0x40204020, 0x00007fe0,
1272 0x07fe0000, 0x04020402, 0x7c020402, 0x44024402, 0x44024402, 0x402047fe, 0x40204020, 0x00007fe0,
1273 0x00000000, 0x40027ffe, 0x7ffe4002, 0x40024002, 0x40024002, 0x40024002, 0x7ffe4002, 0x00000000,
1274 0x09100000, 0x09f00910, 0x09100910, 0x00000910, 0x24a2779e, 0x27a224a2, 0x709e20a2, 0x00000000,
1275 0x3ff00000, 0x201c2010, 0x2a842e84, 0x2e842a84, 0x2ba42004, 0x2aa42aa4, 0x20042ba4, 0x00003ffc,
1276 0x00000000, 0x00000000, 0x00120012, 0x4a5e4bd2, 0x485233d2, 0x00004bd2, 0x00000000, 0x00000000,
1277 0x01800000, 0x381c0660, 0x23c42004, 0x23c42044, 0x13c82204, 0x08101008, 0x02400420, 0x00000180,
1278 0x007e0000, 0x20023fc2, 0x40227fe2, 0x400a403a, 0x400a400a, 0x400a400a, 0x4008400e, 0x00007ff8,
1279 0x00000000, 0x0042007e, 0x40027fc2, 0x44024002, 0x5f024402, 0x44024402, 0x7ffe4002, 0x00000000,
1280 0x44220000, 0x12482244, 0xf3cf0000, 0x14280420, 0x48122424, 0x08100810, 0x1ff81008, 0x03c00420,
1281 0x0aa00000, 0x1ff80aa0, 0x1068700e, 0x1008706e, 0x1008700e, 0x1008700e, 0x0aa01ff8, 0x00000aa0,
1282 0x07e00000, 0x04201db8, 0x04a01c38, 0x04a01d38, 0x04a01d38, 0x04a01d38, 0x04201d38, 0x000007e0,
1283 0x00000000, 0x03c00000, 0x3c382ff0, 0x3c04380c, 0x01800000, 0x03c003c0, 0x00000180, 0x00000000,
1284 0x01800000, 0x01800180, 0x01800180, 0x03c007e0, 0x00000180, 0x01800000, 0x03c003c0, 0x00000180,
1285 0x01800000, 0x07e003c0, 0x01800180, 0x01800180, 0x00000180, 0x01800000, 0x03c003c0, 0x00000180,
1286 0x00000000, 0x0ff003c0, 0x181c1c34, 0x303c301c, 0x30003000, 0x1c301800, 0x03c00ff0, 0x00000000,
1287 0x00000000, 0x00000000, 0x07e003c0, 0x0ff00ff0, 0x0ff00ff0, 0x03c007e0, 0x00000000, 0x00000000,
1288 0x00000000, 0x00000000, 0x042003c0, 0x08100810, 0x08100810, 0x03c00420, 0x00000000, 0x00000000,
1289 0x00000000, 0x00000000, 0x1ff81ff8, 0x1ff80000, 0x00001ff8, 0x1ff81ff8, 0x00000000, 0x00000000,
1290 0x00000000, 0x00000000, 0x00880070, 0x0c880088, 0x1e8810f8, 0x3e881288, 0x00000000, 0x00000000,
1291 0x00000000, 0x02000000, 0x07000a80, 0x07001fc0, 0x02000a80, 0x00300030, 0x00000000, 0x00000000,
1292 0x00000000, 0x0042007e, 0x40027fc2, 0x40024002, 0x40024002, 0x40024002, 0x7ffe4002, 0x00000000,
1293 0x3ff00000, 0x201c2010, 0x20042004, 0x20042004, 0x20042004, 0x20042004, 0x20042004, 0x00003ffc,
1294 0x1ff00000, 0x20082008, 0x17d02fe8, 0x05400ba0, 0x09200540, 0x23881010, 0x2fe827c8, 0x00001ff0,
1295 0x01800000, 0x02400240, 0x05a00420, 0x09900990, 0x11881188, 0x21842004, 0x40024182, 0x00003ffc,
1296 0x7ffe0000, 0x4ff24002, 0x4c324ff2, 0x4f824c02, 0x41824f82, 0x41824002, 0x40024182, 0x00007ffe,
1297 0x7ffe0000, 0x41824002, 0x40024182, 0x41824182, 0x41824182, 0x41824182, 0x40024182, 0x00007ffe,
1298 0x01800000, 0x04200240, 0x10080810, 0x7bde2004, 0x0a500a50, 0x08500bd0, 0x08100850, 0x00000ff0,
1299 0x01800000, 0x18180660, 0x80016006, 0x98196006, 0x99996666, 0x19986666, 0x01800660, 0x00000000,
1300 0x07fe0000, 0x1c020402, 0x74021402, 0x54025402, 0x54025402, 0x500857fe, 0x40205ff8, 0x00007fe0,
1301 0x0ffe0000, 0x3ffa0802, 0x7fea200a, 0x402a402a, 0x422a422a, 0x422e422a, 0x40384e28, 0x00007fe0,
1302 0x0ffe0000, 0x3ffa0802, 0x7fea200a, 0x402a402a, 0x5b2a512a, 0x512e552a, 0x40385128, 0x00007fe0,
1303 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1304 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1305 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1306 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1307 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1308 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1309 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1310 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1311 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1312 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1313 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1314 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1315 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1316 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1317 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1318 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1319 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1320 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1321 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1322 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1323 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1324 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1325 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1326 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1327 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1328 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1329 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1330 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1334 static unsigned int *guiIconsPtr = guiIcons;
1336 #endif // !RAYGUI_NO_ICONS && !RAYGUI_CUSTOM_ICONS 1338 #ifndef RAYGUI_ICON_SIZE 1339 #define RAYGUI_ICON_SIZE 0 1344 #define RAYGUI_MAX_CONTROLS 16 // Maximum number of controls 1345 #define RAYGUI_MAX_PROPS_BASE 16 // Maximum number of base properties 1346 #define RAYGUI_MAX_PROPS_EXTENDED 8 // Maximum number of extended properties 1352 typedef enum { BORDER = 0, BASE, TEXT, OTHER } GuiPropertyElement;
1357 static GuiState guiState = STATE_NORMAL;
1359 static Font guiFont = { 0 };
1360 static bool guiLocked =
false;
1361 static float guiAlpha = 1.0f;
1363 static unsigned int guiIconScale = 1;
1365 static bool guiTooltip =
false;
1366 static const char *guiTooltipPtr = NULL;
1368 static bool guiControlExclusiveMode =
false;
1369 static Rectangle guiControlExclusiveRec = { 0 };
1371 static int textBoxCursorIndex = 0;
1373 static int autoCursorCooldownCounter = 0;
1374 static int autoCursorDelayCounter = 0;
1388 static unsigned int guiStyle[RAYGUI_MAX_CONTROLS*(RAYGUI_MAX_PROPS_BASE + RAYGUI_MAX_PROPS_EXTENDED)] = { 0 };
1390 static bool guiStyleLoaded =
false;
1398 #if defined(RAYGUI_STANDALONE) 1400 #define KEY_RIGHT 262 1401 #define KEY_LEFT 263 1402 #define KEY_DOWN 264 1404 #define KEY_BACKSPACE 259 1405 #define KEY_ENTER 257 1407 #define MOUSE_LEFT_BUTTON 0 1411 static Vector2 GetMousePosition(
void);
1412 static float GetMouseWheelMove(
void);
1413 static bool IsMouseButtonDown(
int button);
1414 static bool IsMouseButtonPressed(
int button);
1415 static bool IsMouseButtonReleased(
int button);
1417 static bool IsKeyDown(
int key);
1418 static bool IsKeyPressed(
int key);
1419 static int GetCharPressed(
void);
1424 static void DrawRectangle(
int x,
int y,
int width,
int height,
Color color);
1430 static Font GetFontDefault(
void);
1431 static Font LoadFontEx(
const char *fileName,
int fontSize,
int *codepoints,
int codepointCount);
1436 static char *LoadFileText(
const char *fileName);
1437 static void UnloadFileText(
char *text);
1439 static const char *GetDirectoryPath(
const char *filePath);
1441 static int *LoadCodepoints(
const char *text,
int *count);
1442 static void UnloadCodepoints(
int *codepoints);
1444 static unsigned char *DecompressData(
const unsigned char *compData,
int compDataSize,
int *dataSize);
1449 static Color GetColor(
int hexValue);
1450 static int ColorToInt(
Color color);
1452 static const char *TextFormat(
const char *text, ...);
1453 static const char **TextSplit(
const char *text,
char delimiter,
int *count);
1454 static int TextToInteger(
const char *text);
1455 static float TextToFloat(
const char *text);
1457 static int GetCodepointNext(
const char *text,
int *codepointSize);
1458 static const char *CodepointToUTF8(
int codepoint,
int *byteSize);
1460 static void DrawRectangleGradientV(
int posX,
int posY,
int width,
int height,
Color color1,
Color color2);
1463 #endif // RAYGUI_STANDALONE 1468 static void GuiLoadStyleFromMemory(
const unsigned char *fileData,
int dataSize);
1470 static int GetTextWidth(
const char *text);
1472 static const char *GetTextIcon(
const char *text,
int *iconId);
1474 static void GuiDrawText(
const char *text,
Rectangle textBounds,
int alignment,
Color tint);
1475 static void GuiDrawRectangle(
Rectangle rec,
int borderWidth,
Color borderColor,
Color color);
1477 static const char **GuiTextSplit(
const char *text,
char delimiter,
int *count,
int *textRow);
1481 static int GuiScrollBar(
Rectangle bounds,
int value,
int minValue,
int maxValue);
1482 static void GuiTooltip(
Rectangle controlRec);
1484 static Color GuiFade(
Color color,
float alpha);
1491 void GuiEnable(
void) {
if (guiState == STATE_DISABLED) guiState = STATE_NORMAL; }
1495 void GuiDisable(
void) {
if (guiState == STATE_NORMAL) guiState = STATE_DISABLED; }
1498 void GuiLock(
void) { guiLocked =
true; }
1501 void GuiUnlock(
void) { guiLocked =
false; }
1504 bool GuiIsLocked(
void) {
return guiLocked; }
1507 void GuiSetAlpha(
float alpha)
1509 if (alpha < 0.0f) alpha = 0.0f;
1510 else if (alpha > 1.0f) alpha = 1.0f;
1516 void GuiSetState(
int state) { guiState = (GuiState)state; }
1519 int GuiGetState(
void) {
return guiState; }
1523 void GuiSetFont(
Font font)
1525 if (font.texture.id > 0)
1530 if (!guiStyleLoaded) GuiLoadStyleDefault();
1537 Font GuiGetFont(
void)
1543 void GuiSetStyle(
int control,
int property,
int value)
1545 if (!guiStyleLoaded) GuiLoadStyleDefault();
1546 guiStyle[control*(RAYGUI_MAX_PROPS_BASE + RAYGUI_MAX_PROPS_EXTENDED) + property] = value;
1549 if ((control == 0) && (
property < RAYGUI_MAX_PROPS_BASE))
1551 for (
int i = 1; i < RAYGUI_MAX_CONTROLS; i++) guiStyle[i*(RAYGUI_MAX_PROPS_BASE + RAYGUI_MAX_PROPS_EXTENDED) + property] = value;
1556 int GuiGetStyle(
int control,
int property)
1558 if (!guiStyleLoaded) GuiLoadStyleDefault();
1559 return guiStyle[control*(RAYGUI_MAX_PROPS_BASE + RAYGUI_MAX_PROPS_EXTENDED) + property];
1567 int GuiWindowBox(
Rectangle bounds,
const char *title)
1571 #if !defined(RAYGUI_WINDOWBOX_STATUSBAR_HEIGHT) 1572 #define RAYGUI_WINDOWBOX_STATUSBAR_HEIGHT 24 1578 int statusBarHeight = RAYGUI_WINDOWBOX_STATUSBAR_HEIGHT;
1580 Rectangle statusBar = { bounds.x, bounds.y, bounds.width, (float)statusBarHeight };
1581 if (bounds.height < statusBarHeight*2.0f) bounds.height = statusBarHeight*2.0f;
1583 Rectangle windowPanel = { bounds.x, bounds.y + (float)statusBarHeight - 1, bounds.width, bounds.height - (
float)statusBarHeight + 1 };
1584 Rectangle closeButtonRec = { statusBar.x + statusBar.width - GuiGetStyle(STATUSBAR, BORDER_WIDTH) - 20,
1585 statusBar.y + statusBarHeight/2.0f - 18.0f/2.0f, 18, 18 };
1594 GuiStatusBar(statusBar, title);
1595 GuiPanel(windowPanel, NULL);
1598 int tempBorderWidth = GuiGetStyle(BUTTON, BORDER_WIDTH);
1599 int tempTextAlignment = GuiGetStyle(BUTTON, TEXT_ALIGNMENT);
1600 GuiSetStyle(BUTTON, BORDER_WIDTH, 1);
1601 GuiSetStyle(BUTTON, TEXT_ALIGNMENT, TEXT_ALIGN_CENTER);
1602 #if defined(RAYGUI_NO_ICONS) 1603 result = GuiButton(closeButtonRec,
"x");
1605 result = GuiButton(closeButtonRec, GuiIconText(ICON_CROSS_SMALL, NULL));
1607 GuiSetStyle(BUTTON, BORDER_WIDTH, tempBorderWidth);
1608 GuiSetStyle(BUTTON, TEXT_ALIGNMENT, tempTextAlignment);
1615 int GuiGroupBox(
Rectangle bounds,
const char *text)
1617 #if !defined(RAYGUI_GROUPBOX_LINE_THICK) 1618 #define RAYGUI_GROUPBOX_LINE_THICK 1 1622 GuiState state = guiState;
1626 GuiDrawRectangle(RAYGUI_CLITERAL(
Rectangle){ bounds.x, bounds.y, RAYGUI_GROUPBOX_LINE_THICK, bounds.height }, 0, BLANK, GetColor(GuiGetStyle(DEFAULT, (state == STATE_DISABLED)? BORDER_COLOR_DISABLED : LINE_COLOR)));
1627 GuiDrawRectangle(RAYGUI_CLITERAL(
Rectangle){ bounds.x, bounds.y + bounds.height - 1, bounds.width, RAYGUI_GROUPBOX_LINE_THICK }, 0, BLANK, GetColor(GuiGetStyle(DEFAULT, (state == STATE_DISABLED)? BORDER_COLOR_DISABLED : LINE_COLOR)));
1628 GuiDrawRectangle(RAYGUI_CLITERAL(
Rectangle){ bounds.x + bounds.width - 1, bounds.y, RAYGUI_GROUPBOX_LINE_THICK, bounds.height }, 0, BLANK, GetColor(GuiGetStyle(DEFAULT, (state == STATE_DISABLED)? BORDER_COLOR_DISABLED : LINE_COLOR)));
1630 GuiLine(RAYGUI_CLITERAL(
Rectangle){ bounds.x, bounds.y - GuiGetStyle(DEFAULT, TEXT_SIZE)/2, bounds.width, (float)GuiGetStyle(DEFAULT, TEXT_SIZE) }, text);
1637 int GuiLine(
Rectangle bounds,
const char *text)
1639 #if !defined(RAYGUI_LINE_ORIGIN_SIZE) 1640 #define RAYGUI_LINE_MARGIN_TEXT 12 1642 #if !defined(RAYGUI_LINE_TEXT_PADDING) 1643 #define RAYGUI_LINE_TEXT_PADDING 4 1647 GuiState state = guiState;
1649 Color color = GetColor(GuiGetStyle(DEFAULT, (state == STATE_DISABLED)? BORDER_COLOR_DISABLED : LINE_COLOR));
1653 if (text == NULL) GuiDrawRectangle(RAYGUI_CLITERAL(
Rectangle){ bounds.x, bounds.y + bounds.height/2, bounds.width, 1 }, 0, BLANK, color);
1657 textBounds.width = (float)GetTextWidth(text) + 2;
1658 textBounds.height = bounds.height;
1659 textBounds.x = bounds.x + RAYGUI_LINE_MARGIN_TEXT;
1660 textBounds.y = bounds.y;
1663 GuiDrawRectangle(RAYGUI_CLITERAL(
Rectangle){ bounds.x, bounds.y + bounds.height/2, RAYGUI_LINE_MARGIN_TEXT - RAYGUI_LINE_TEXT_PADDING, 1 }, 0, BLANK, color);
1664 GuiDrawText(text, textBounds, TEXT_ALIGN_LEFT, color);
1665 GuiDrawRectangle(RAYGUI_CLITERAL(
Rectangle){ bounds.x + 12 + textBounds.width + 4, bounds.y + bounds.height/2, bounds.width - textBounds.width - RAYGUI_LINE_MARGIN_TEXT - RAYGUI_LINE_TEXT_PADDING, 1 }, 0, BLANK, color);
1673 int GuiPanel(
Rectangle bounds,
const char *text)
1675 #if !defined(RAYGUI_PANEL_BORDER_WIDTH) 1676 #define RAYGUI_PANEL_BORDER_WIDTH 1 1680 GuiState state = guiState;
1683 Rectangle statusBar = { bounds.x, bounds.y, bounds.width, (float)RAYGUI_WINDOWBOX_STATUSBAR_HEIGHT };
1684 if ((text != NULL) && (bounds.height < RAYGUI_WINDOWBOX_STATUSBAR_HEIGHT*2.0f)) bounds.height = RAYGUI_WINDOWBOX_STATUSBAR_HEIGHT*2.0f;
1689 bounds.y += (float)RAYGUI_WINDOWBOX_STATUSBAR_HEIGHT - 1;
1690 bounds.height -= (float)RAYGUI_WINDOWBOX_STATUSBAR_HEIGHT - 1;
1695 if (text != NULL) GuiStatusBar(statusBar, text);
1697 GuiDrawRectangle(bounds, RAYGUI_PANEL_BORDER_WIDTH, GetColor(GuiGetStyle(DEFAULT, (state == STATE_DISABLED)? BORDER_COLOR_DISABLED: LINE_COLOR)),
1698 GetColor(GuiGetStyle(DEFAULT, (state == STATE_DISABLED)? BASE_COLOR_DISABLED : BACKGROUND_COLOR)));
1706 int GuiTabBar(
Rectangle bounds,
const char **text,
int count,
int *active)
1708 #define RAYGUI_TABBAR_ITEM_WIDTH 160 1713 Rectangle tabBounds = { bounds.x, bounds.y, RAYGUI_TABBAR_ITEM_WIDTH, bounds.height };
1715 if (*active < 0) *active = 0;
1716 else if (*active > count - 1) *active = count - 1;
1719 offsetX = (*active + 2)*RAYGUI_TABBAR_ITEM_WIDTH - GetScreenWidth();
1720 if (offsetX < 0) offsetX = 0;
1722 bool toggle =
false;
1726 for (
int i = 0; i < count; i++)
1728 tabBounds.x = bounds.x + (RAYGUI_TABBAR_ITEM_WIDTH + 4)*i - offsetX;
1730 if (tabBounds.x < GetScreenWidth())
1733 int textAlignment = GuiGetStyle(TOGGLE, TEXT_ALIGNMENT);
1734 int textPadding = GuiGetStyle(TOGGLE, TEXT_PADDING);
1735 GuiSetStyle(TOGGLE, TEXT_ALIGNMENT, TEXT_ALIGN_LEFT);
1736 GuiSetStyle(TOGGLE, TEXT_PADDING, 8);
1741 GuiToggle(tabBounds, GuiIconText(12, text[i]), &toggle);
1746 GuiToggle(tabBounds, GuiIconText(12, text[i]), &toggle);
1747 if (toggle) *active = i;
1751 if (CheckCollisionPointRec(GetMousePosition(), tabBounds) && IsMouseButtonPressed(MOUSE_MIDDLE_BUTTON)) result = i;
1753 GuiSetStyle(TOGGLE, TEXT_PADDING, textPadding);
1754 GuiSetStyle(TOGGLE, TEXT_ALIGNMENT, textAlignment);
1758 int tempBorderWidth = GuiGetStyle(BUTTON, BORDER_WIDTH);
1759 int tempTextAlignment = GuiGetStyle(BUTTON, TEXT_ALIGNMENT);
1760 GuiSetStyle(BUTTON, BORDER_WIDTH, 1);
1761 GuiSetStyle(BUTTON, TEXT_ALIGNMENT, TEXT_ALIGN_CENTER);
1762 #if defined(RAYGUI_NO_ICONS) 1763 if (GuiButton(RAYGUI_CLITERAL(
Rectangle){ tabBounds.x + tabBounds.width - 14 - 5, tabBounds.y + 5, 14, 14 },
"x")) result = i;
1765 if (GuiButton(RAYGUI_CLITERAL(
Rectangle){ tabBounds.x + tabBounds.width - 14 - 5, tabBounds.y + 5, 14, 14 }, GuiIconText(ICON_CROSS_SMALL, NULL))) result = i;
1767 GuiSetStyle(BUTTON, BORDER_WIDTH, tempBorderWidth);
1768 GuiSetStyle(BUTTON, TEXT_ALIGNMENT, tempTextAlignment);
1773 GuiDrawRectangle(RAYGUI_CLITERAL(
Rectangle){ bounds.x, bounds.y + bounds.height - 1, bounds.width, 1 }, 0, BLANK, GetColor(GuiGetStyle(TOGGLE, BORDER_COLOR_NORMAL)));
1782 #define RAYGUI_MIN_SCROLLBAR_WIDTH 40 1783 #define RAYGUI_MIN_SCROLLBAR_HEIGHT 40 1784 #define RAYGUI_MIN_MOUSE_WHEEL_SPEED 20 1787 GuiState state = guiState;
1790 if (view == NULL) view = &temp;
1792 Vector2 scrollPos = { 0.0f, 0.0f };
1793 if (scroll != NULL) scrollPos = *scroll;
1796 Rectangle statusBar = { bounds.x, bounds.y, bounds.width, (float)RAYGUI_WINDOWBOX_STATUSBAR_HEIGHT };
1797 if (bounds.height < RAYGUI_WINDOWBOX_STATUSBAR_HEIGHT*2.0f) bounds.height = RAYGUI_WINDOWBOX_STATUSBAR_HEIGHT*2.0f;
1802 bounds.y += (float)RAYGUI_WINDOWBOX_STATUSBAR_HEIGHT - 1;
1803 bounds.height -= (float)RAYGUI_WINDOWBOX_STATUSBAR_HEIGHT + 1;
1806 bool hasHorizontalScrollBar = (content.width > bounds.width - 2*GuiGetStyle(DEFAULT, BORDER_WIDTH))?
true :
false;
1807 bool hasVerticalScrollBar = (content.height > bounds.height - 2*GuiGetStyle(DEFAULT, BORDER_WIDTH))?
true :
false;
1810 if (!hasHorizontalScrollBar) hasHorizontalScrollBar = (hasVerticalScrollBar && (content.width > (bounds.width - 2*GuiGetStyle(DEFAULT, BORDER_WIDTH) - GuiGetStyle(LISTVIEW, SCROLLBAR_WIDTH))))?
true :
false;
1811 if (!hasVerticalScrollBar) hasVerticalScrollBar = (hasHorizontalScrollBar && (content.height > (bounds.height - 2*GuiGetStyle(DEFAULT, BORDER_WIDTH) - GuiGetStyle(LISTVIEW, SCROLLBAR_WIDTH))))?
true :
false;
1813 int horizontalScrollBarWidth = hasHorizontalScrollBar? GuiGetStyle(LISTVIEW, SCROLLBAR_WIDTH) : 0;
1814 int verticalScrollBarWidth = hasVerticalScrollBar? GuiGetStyle(LISTVIEW, SCROLLBAR_WIDTH) : 0;
1816 (float)((GuiGetStyle(LISTVIEW, SCROLLBAR_SIDE) == SCROLLBAR_LEFT_SIDE)? (float)bounds.x + verticalScrollBarWidth : (
float)bounds.x) + GuiGetStyle(DEFAULT, BORDER_WIDTH),
1817 (float)bounds.y + bounds.height - horizontalScrollBarWidth - GuiGetStyle(DEFAULT, BORDER_WIDTH),
1818 (float)bounds.width - verticalScrollBarWidth - 2*GuiGetStyle(DEFAULT, BORDER_WIDTH),
1819 (float)horizontalScrollBarWidth
1822 (float)((GuiGetStyle(LISTVIEW, SCROLLBAR_SIDE) == SCROLLBAR_LEFT_SIDE)? (
float)bounds.x + GuiGetStyle(DEFAULT, BORDER_WIDTH) : (float)bounds.x + bounds.width - verticalScrollBarWidth - GuiGetStyle(DEFAULT, BORDER_WIDTH)),
1823 (
float)bounds.y + GuiGetStyle(DEFAULT, BORDER_WIDTH),
1824 (float)verticalScrollBarWidth,
1825 (
float)bounds.height - horizontalScrollBarWidth - 2*GuiGetStyle(DEFAULT, BORDER_WIDTH)
1829 if (horizontalScrollBar.width < RAYGUI_MIN_SCROLLBAR_WIDTH) horizontalScrollBar.width = RAYGUI_MIN_SCROLLBAR_WIDTH;
1830 if (verticalScrollBar.height < RAYGUI_MIN_SCROLLBAR_HEIGHT) verticalScrollBar.height = RAYGUI_MIN_SCROLLBAR_HEIGHT;
1833 *view = (GuiGetStyle(LISTVIEW, SCROLLBAR_SIDE) == SCROLLBAR_LEFT_SIDE)?
1834 RAYGUI_CLITERAL(
Rectangle){ bounds.x + verticalScrollBarWidth + GuiGetStyle(DEFAULT, BORDER_WIDTH), bounds.y + GuiGetStyle(DEFAULT, BORDER_WIDTH), bounds.width - 2*GuiGetStyle(DEFAULT, BORDER_WIDTH) - verticalScrollBarWidth, bounds.height - 2*GuiGetStyle(DEFAULT, BORDER_WIDTH) - horizontalScrollBarWidth } :
1835 RAYGUI_CLITERAL(
Rectangle){ bounds.x + GuiGetStyle(DEFAULT, BORDER_WIDTH), bounds.y + GuiGetStyle(DEFAULT, BORDER_WIDTH), bounds.width - 2*GuiGetStyle(DEFAULT, BORDER_WIDTH) - verticalScrollBarWidth, bounds.height - 2*GuiGetStyle(DEFAULT, BORDER_WIDTH) - horizontalScrollBarWidth };
1838 if (view->width > content.width) view->width = content.width;
1839 if (view->height > content.height) view->height = content.height;
1841 float horizontalMin = hasHorizontalScrollBar? ((GuiGetStyle(LISTVIEW, SCROLLBAR_SIDE) == SCROLLBAR_LEFT_SIDE)? (
float)-verticalScrollBarWidth : 0) - (
float)GuiGetStyle(DEFAULT, BORDER_WIDTH) : (((float)GuiGetStyle(LISTVIEW, SCROLLBAR_SIDE) == SCROLLBAR_LEFT_SIDE)? (
float)-verticalScrollBarWidth : 0) - (
float)GuiGetStyle(DEFAULT, BORDER_WIDTH);
1842 float horizontalMax = hasHorizontalScrollBar? content.width - bounds.width + (float)verticalScrollBarWidth + GuiGetStyle(DEFAULT, BORDER_WIDTH) - (((float)GuiGetStyle(LISTVIEW, SCROLLBAR_SIDE) == SCROLLBAR_LEFT_SIDE)? (
float)verticalScrollBarWidth : 0) : (
float)-GuiGetStyle(DEFAULT, BORDER_WIDTH);
1843 float verticalMin = hasVerticalScrollBar? 0.0f : -1.0f;
1844 float verticalMax = hasVerticalScrollBar? content.height - bounds.height + (float)horizontalScrollBarWidth + (
float)GuiGetStyle(DEFAULT, BORDER_WIDTH) : (float)-GuiGetStyle(DEFAULT, BORDER_WIDTH);
1848 if ((state != STATE_DISABLED) && !guiLocked)
1850 Vector2 mousePoint = GetMousePosition();
1853 if (CheckCollisionPointRec(mousePoint, bounds))
1855 if (IsMouseButtonDown(MOUSE_LEFT_BUTTON)) state = STATE_PRESSED;
1856 else state = STATE_FOCUSED;
1858 #if defined(SUPPORT_SCROLLBAR_KEY_INPUT) 1859 if (hasHorizontalScrollBar)
1861 if (IsKeyDown(KEY_RIGHT)) scrollPos.x -= GuiGetStyle(SCROLLBAR, SCROLL_SPEED);
1862 if (IsKeyDown(KEY_LEFT)) scrollPos.x += GuiGetStyle(SCROLLBAR, SCROLL_SPEED);
1865 if (hasVerticalScrollBar)
1867 if (IsKeyDown(KEY_DOWN)) scrollPos.y -= GuiGetStyle(SCROLLBAR, SCROLL_SPEED);
1868 if (IsKeyDown(KEY_UP)) scrollPos.y += GuiGetStyle(SCROLLBAR, SCROLL_SPEED);
1871 float wheelMove = GetMouseWheelMove();
1874 Vector2 mouseWheelSpeed = { content.width / bounds.width, content.height / bounds.height };
1875 if (mouseWheelSpeed.x < RAYGUI_MIN_MOUSE_WHEEL_SPEED) mouseWheelSpeed.x = RAYGUI_MIN_MOUSE_WHEEL_SPEED;
1876 if (mouseWheelSpeed.y < RAYGUI_MIN_MOUSE_WHEEL_SPEED) mouseWheelSpeed.y = RAYGUI_MIN_MOUSE_WHEEL_SPEED;
1879 if (hasHorizontalScrollBar && (IsKeyDown(KEY_LEFT_CONTROL) || IsKeyDown(KEY_LEFT_SHIFT))) scrollPos.x += wheelMove*mouseWheelSpeed.x;
1880 else scrollPos.y += wheelMove*mouseWheelSpeed.y;
1885 if (scrollPos.x > -horizontalMin) scrollPos.x = -horizontalMin;
1886 if (scrollPos.x < -horizontalMax) scrollPos.x = -horizontalMax;
1887 if (scrollPos.y > -verticalMin) scrollPos.y = -verticalMin;
1888 if (scrollPos.y < -verticalMax) scrollPos.y = -verticalMax;
1893 if (text != NULL) GuiStatusBar(statusBar, text);
1895 GuiDrawRectangle(bounds, 0, BLANK, GetColor(GuiGetStyle(DEFAULT, BACKGROUND_COLOR)));
1898 const int slider = GuiGetStyle(SCROLLBAR, SCROLL_SLIDER_SIZE);
1901 if (hasHorizontalScrollBar)
1904 GuiSetStyle(SCROLLBAR, SCROLL_SLIDER_SIZE, (
int)(((bounds.width - 2*GuiGetStyle(DEFAULT, BORDER_WIDTH) - verticalScrollBarWidth)/(
int)content.width)*((
int)bounds.width - 2*GuiGetStyle(DEFAULT, BORDER_WIDTH) - verticalScrollBarWidth)));
1905 scrollPos.x = (float)-GuiScrollBar(horizontalScrollBar, (
int)-scrollPos.x, (int)horizontalMin, (
int)horizontalMax);
1907 else scrollPos.x = 0.0f;
1910 if (hasVerticalScrollBar)
1913 GuiSetStyle(SCROLLBAR, SCROLL_SLIDER_SIZE, (
int)(((bounds.height - 2*GuiGetStyle(DEFAULT, BORDER_WIDTH) - horizontalScrollBarWidth)/(
int)content.height)*((
int)bounds.height - 2*GuiGetStyle(DEFAULT, BORDER_WIDTH) - horizontalScrollBarWidth)));
1914 scrollPos.y = (float)-GuiScrollBar(verticalScrollBar, (
int)-scrollPos.y, (int)verticalMin, (
int)verticalMax);
1916 else scrollPos.y = 0.0f;
1919 if (hasHorizontalScrollBar && hasVerticalScrollBar)
1921 Rectangle corner = { (GuiGetStyle(LISTVIEW, SCROLLBAR_SIDE) == SCROLLBAR_LEFT_SIDE)? (bounds.x + GuiGetStyle(DEFAULT, BORDER_WIDTH) + 2) : (horizontalScrollBar.x + horizontalScrollBar.width + 2), verticalScrollBar.y + verticalScrollBar.height + 2, (float)horizontalScrollBarWidth - 4, (
float)verticalScrollBarWidth - 4 };
1922 GuiDrawRectangle(corner, 0, BLANK, GetColor(GuiGetStyle(LISTVIEW, TEXT + (state*3))));
1926 GuiDrawRectangle(bounds, GuiGetStyle(LISTVIEW, BORDER_WIDTH), GetColor(GuiGetStyle(LISTVIEW, BORDER + (state*3))), BLANK);
1929 GuiSetStyle(SCROLLBAR, SCROLL_SLIDER_SIZE, slider);
1932 if (scroll != NULL) *scroll = scrollPos;
1938 int GuiLabel(
Rectangle bounds,
const char *text)
1941 GuiState state = guiState;
1950 GuiDrawText(text, GetTextBounds(LABEL, bounds), GuiGetStyle(LABEL, TEXT_ALIGNMENT), GetColor(GuiGetStyle(LABEL, TEXT + (state*3))));
1957 int GuiButton(
Rectangle bounds,
const char *text)
1960 GuiState state = guiState;
1964 if ((state != STATE_DISABLED) && !guiLocked && !guiControlExclusiveMode)
1966 Vector2 mousePoint = GetMousePosition();
1969 if (CheckCollisionPointRec(mousePoint, bounds))
1971 if (IsMouseButtonDown(MOUSE_LEFT_BUTTON)) state = STATE_PRESSED;
1972 else state = STATE_FOCUSED;
1974 if (IsMouseButtonReleased(MOUSE_LEFT_BUTTON)) result = 1;
1981 GuiDrawRectangle(bounds, GuiGetStyle(BUTTON, BORDER_WIDTH), GetColor(GuiGetStyle(BUTTON, BORDER + (state*3))), GetColor(GuiGetStyle(BUTTON, BASE + (state*3))));
1982 GuiDrawText(text, GetTextBounds(BUTTON, bounds), GuiGetStyle(BUTTON, TEXT_ALIGNMENT), GetColor(GuiGetStyle(BUTTON, TEXT + (state*3))));
1984 if (state == STATE_FOCUSED) GuiTooltip(bounds);
1991 int GuiLabelButton(
Rectangle bounds,
const char *text)
1993 GuiState state = guiState;
1994 bool pressed =
false;
1997 float textWidth = (float)GetTextWidth(text);
1998 if ((bounds.width - 2*GuiGetStyle(LABEL, BORDER_WIDTH) - 2*GuiGetStyle(LABEL, TEXT_PADDING)) < textWidth) bounds.width = textWidth + 2*GuiGetStyle(LABEL, BORDER_WIDTH) + 2*GuiGetStyle(LABEL, TEXT_PADDING) + 2;
2002 if ((state != STATE_DISABLED) && !guiLocked && !guiControlExclusiveMode)
2004 Vector2 mousePoint = GetMousePosition();
2007 if (CheckCollisionPointRec(mousePoint, bounds))
2009 if (IsMouseButtonDown(MOUSE_LEFT_BUTTON)) state = STATE_PRESSED;
2010 else state = STATE_FOCUSED;
2012 if (IsMouseButtonReleased(MOUSE_LEFT_BUTTON)) pressed =
true;
2019 GuiDrawText(text, GetTextBounds(LABEL, bounds), GuiGetStyle(LABEL, TEXT_ALIGNMENT), GetColor(GuiGetStyle(LABEL, TEXT + (state*3))));
2026 int GuiToggle(
Rectangle bounds,
const char *text,
bool *active)
2029 GuiState state = guiState;
2032 if (active == NULL) active = &temp;
2036 if ((state != STATE_DISABLED) && !guiLocked && !guiControlExclusiveMode)
2038 Vector2 mousePoint = GetMousePosition();
2041 if (CheckCollisionPointRec(mousePoint, bounds))
2043 if (IsMouseButtonDown(MOUSE_LEFT_BUTTON)) state = STATE_PRESSED;
2044 else if (IsMouseButtonReleased(MOUSE_LEFT_BUTTON))
2046 state = STATE_NORMAL;
2047 *active = !(*active);
2049 else state = STATE_FOCUSED;
2056 if (state == STATE_NORMAL)
2058 GuiDrawRectangle(bounds, GuiGetStyle(TOGGLE, BORDER_WIDTH), GetColor(GuiGetStyle(TOGGLE, ((*active)? BORDER_COLOR_PRESSED : (BORDER + state*3)))), GetColor(GuiGetStyle(TOGGLE, ((*active)? BASE_COLOR_PRESSED : (BASE + state*3)))));
2059 GuiDrawText(text, GetTextBounds(TOGGLE, bounds), GuiGetStyle(TOGGLE, TEXT_ALIGNMENT), GetColor(GuiGetStyle(TOGGLE, ((*active)? TEXT_COLOR_PRESSED : (TEXT + state*3)))));
2063 GuiDrawRectangle(bounds, GuiGetStyle(TOGGLE, BORDER_WIDTH), GetColor(GuiGetStyle(TOGGLE, BORDER + state*3)), GetColor(GuiGetStyle(TOGGLE, BASE + state*3)));
2064 GuiDrawText(text, GetTextBounds(TOGGLE, bounds), GuiGetStyle(TOGGLE, TEXT_ALIGNMENT), GetColor(GuiGetStyle(TOGGLE, TEXT + state*3)));
2067 if (state == STATE_FOCUSED) GuiTooltip(bounds);
2074 int GuiToggleGroup(
Rectangle bounds,
const char *text,
int *active)
2076 #if !defined(RAYGUI_TOGGLEGROUP_MAX_ITEMS) 2077 #define RAYGUI_TOGGLEGROUP_MAX_ITEMS 32 2081 float initBoundsX = bounds.x;
2084 if (active == NULL) active = &temp;
2086 bool toggle =
false;
2089 int rows[RAYGUI_TOGGLEGROUP_MAX_ITEMS] = { 0 };
2091 const char **items = GuiTextSplit(text,
';', &itemCount, rows);
2093 int prevRow = rows[0];
2095 for (
int i = 0; i < itemCount; i++)
2097 if (prevRow != rows[i])
2099 bounds.x = initBoundsX;
2100 bounds.y += (bounds.height + GuiGetStyle(TOGGLE, GROUP_PADDING));
2107 GuiToggle(bounds, items[i], &toggle);
2112 GuiToggle(bounds, items[i], &toggle);
2113 if (toggle) *active = i;
2116 bounds.x += (bounds.width + GuiGetStyle(TOGGLE, GROUP_PADDING));
2123 int GuiToggleSlider(
Rectangle bounds,
const char *text,
int *active)
2126 GuiState state = guiState;
2129 if (active == NULL) active = &temp;
2135 const char **items = GuiTextSplit(text,
';', &itemCount, NULL);
2139 bounds.y + GuiGetStyle(SLIDER, BORDER_WIDTH) + GuiGetStyle(SLIDER, SLIDER_PADDING),
2140 (bounds.width - 2*GuiGetStyle(SLIDER, BORDER_WIDTH) - (itemCount + 1)*GuiGetStyle(SLIDER, SLIDER_PADDING))/itemCount,
2141 bounds.height - 2*GuiGetStyle(SLIDER, BORDER_WIDTH) - 2*GuiGetStyle(SLIDER, SLIDER_PADDING) };
2145 if ((state != STATE_DISABLED) && !guiLocked)
2147 Vector2 mousePoint = GetMousePosition();
2149 if (CheckCollisionPointRec(mousePoint, bounds))
2151 if (IsMouseButtonDown(MOUSE_LEFT_BUTTON)) state = STATE_PRESSED;
2152 else if (IsMouseButtonReleased(MOUSE_LEFT_BUTTON))
2154 state = STATE_PRESSED;
2158 else state = STATE_FOCUSED;
2161 if ((*active) && (state != STATE_FOCUSED)) state = STATE_PRESSED;
2164 if (*active >= itemCount) *active = 0;
2165 slider.x = bounds.x + GuiGetStyle(SLIDER, BORDER_WIDTH) + (*active + 1)*GuiGetStyle(SLIDER, SLIDER_PADDING) + (*active)*slider.width;
2170 GuiDrawRectangle(bounds, GuiGetStyle(SLIDER, BORDER_WIDTH), GetColor(GuiGetStyle(TOGGLE, BORDER + (state*3))),
2171 GetColor(GuiGetStyle(TOGGLE, BASE_COLOR_NORMAL)));
2174 if (state == STATE_NORMAL) GuiDrawRectangle(slider, 0, BLANK, GetColor(GuiGetStyle(SLIDER, BASE_COLOR_PRESSED)));
2175 else if (state == STATE_FOCUSED) GuiDrawRectangle(slider, 0, BLANK, GetColor(GuiGetStyle(SLIDER, BASE_COLOR_FOCUSED)));
2176 else if (state == STATE_PRESSED) GuiDrawRectangle(slider, 0, BLANK, GetColor(GuiGetStyle(SLIDER, BASE_COLOR_PRESSED)));
2182 textBounds.width = (float)GetTextWidth(text);
2183 textBounds.height = (float)GuiGetStyle(DEFAULT, TEXT_SIZE);
2184 textBounds.x = slider.x + slider.width/2 - textBounds.width/2;
2185 textBounds.y = bounds.y + bounds.height/2 - GuiGetStyle(DEFAULT, TEXT_SIZE)/2;
2187 GuiDrawText(items[*active], textBounds, GuiGetStyle(TOGGLE, TEXT_ALIGNMENT), Fade(GetColor(GuiGetStyle(TOGGLE, TEXT + (state*3))), guiAlpha));
2195 int GuiCheckBox(
Rectangle bounds,
const char *text,
bool *checked)
2198 GuiState state = guiState;
2201 if (checked == NULL) checked = &temp;
2207 textBounds.width = (float)GetTextWidth(text) + 2;
2208 textBounds.height = (float)GuiGetStyle(DEFAULT, TEXT_SIZE);
2209 textBounds.x = bounds.x + bounds.width + GuiGetStyle(CHECKBOX, TEXT_PADDING);
2210 textBounds.y = bounds.y + bounds.height/2 - GuiGetStyle(DEFAULT, TEXT_SIZE)/2;
2211 if (GuiGetStyle(CHECKBOX, TEXT_ALIGNMENT) == TEXT_ALIGN_LEFT) textBounds.x = bounds.x - textBounds.width - GuiGetStyle(CHECKBOX, TEXT_PADDING);
2216 if ((state != STATE_DISABLED) && !guiLocked && !guiControlExclusiveMode)
2218 Vector2 mousePoint = GetMousePosition();
2221 (GuiGetStyle(CHECKBOX, TEXT_ALIGNMENT) == TEXT_ALIGN_LEFT)? textBounds.x : bounds.x,
2223 bounds.width + textBounds.width + GuiGetStyle(CHECKBOX, TEXT_PADDING),
2228 if (CheckCollisionPointRec(mousePoint, totalBounds))
2230 if (IsMouseButtonDown(MOUSE_LEFT_BUTTON)) state = STATE_PRESSED;
2231 else state = STATE_FOCUSED;
2233 if (IsMouseButtonReleased(MOUSE_LEFT_BUTTON))
2235 *checked = !(*checked);
2244 GuiDrawRectangle(bounds, GuiGetStyle(CHECKBOX, BORDER_WIDTH), GetColor(GuiGetStyle(CHECKBOX, BORDER + (state*3))), BLANK);
2248 Rectangle check = { bounds.x + GuiGetStyle(CHECKBOX, BORDER_WIDTH) + GuiGetStyle(CHECKBOX, CHECK_PADDING),
2249 bounds.y + GuiGetStyle(CHECKBOX, BORDER_WIDTH) + GuiGetStyle(CHECKBOX, CHECK_PADDING),
2250 bounds.width - 2*(GuiGetStyle(CHECKBOX, BORDER_WIDTH) + GuiGetStyle(CHECKBOX, CHECK_PADDING)),
2251 bounds.height - 2*(GuiGetStyle(CHECKBOX, BORDER_WIDTH) + GuiGetStyle(CHECKBOX, CHECK_PADDING)) };
2252 GuiDrawRectangle(check, 0, BLANK, GetColor(GuiGetStyle(CHECKBOX, TEXT + state*3)));
2255 GuiDrawText(text, textBounds, (GuiGetStyle(CHECKBOX, TEXT_ALIGNMENT) == TEXT_ALIGN_RIGHT)? TEXT_ALIGN_LEFT : TEXT_ALIGN_RIGHT, GetColor(GuiGetStyle(LABEL, TEXT + (state*3))));
2262 int GuiComboBox(
Rectangle bounds,
const char *text,
int *active)
2265 GuiState state = guiState;
2268 if (active == NULL) active = &temp;
2270 bounds.width -= (GuiGetStyle(COMBOBOX, COMBO_BUTTON_WIDTH) + GuiGetStyle(COMBOBOX, COMBO_BUTTON_SPACING));
2272 Rectangle selector = { (float)bounds.x + bounds.width + GuiGetStyle(COMBOBOX, COMBO_BUTTON_SPACING),
2273 (float)bounds.y, (
float)GuiGetStyle(COMBOBOX, COMBO_BUTTON_WIDTH), (float)bounds.height };
2277 const char **items = GuiTextSplit(text,
';', &itemCount, NULL);
2279 if (*active < 0) *active = 0;
2280 else if (*active > (itemCount - 1)) *active = itemCount - 1;
2284 if ((state != STATE_DISABLED) && !guiLocked && (itemCount > 1) && !guiControlExclusiveMode)
2286 Vector2 mousePoint = GetMousePosition();
2288 if (CheckCollisionPointRec(mousePoint, bounds) ||
2289 CheckCollisionPointRec(mousePoint, selector))
2291 if (IsMouseButtonPressed(MOUSE_LEFT_BUTTON))
2294 if (*active >= itemCount) *active = 0;
2297 if (IsMouseButtonDown(MOUSE_LEFT_BUTTON)) state = STATE_PRESSED;
2298 else state = STATE_FOCUSED;
2306 GuiDrawRectangle(bounds, GuiGetStyle(COMBOBOX, BORDER_WIDTH), GetColor(GuiGetStyle(COMBOBOX, BORDER + (state*3))), GetColor(GuiGetStyle(COMBOBOX, BASE + (state*3))));
2307 GuiDrawText(items[*active], GetTextBounds(COMBOBOX, bounds), GuiGetStyle(COMBOBOX, TEXT_ALIGNMENT), GetColor(GuiGetStyle(COMBOBOX, TEXT + (state*3))));
2311 int tempBorderWidth = GuiGetStyle(BUTTON, BORDER_WIDTH);
2312 int tempTextAlign = GuiGetStyle(BUTTON, TEXT_ALIGNMENT);
2313 GuiSetStyle(BUTTON, BORDER_WIDTH, 1);
2314 GuiSetStyle(BUTTON, TEXT_ALIGNMENT, TEXT_ALIGN_CENTER);
2316 GuiButton(selector, TextFormat(
"%i/%i", *active + 1, itemCount));
2318 GuiSetStyle(BUTTON, TEXT_ALIGNMENT, tempTextAlign);
2319 GuiSetStyle(BUTTON, BORDER_WIDTH, tempBorderWidth);
2327 int GuiDropdownBox(
Rectangle bounds,
const char *text,
int *active,
bool editMode)
2330 GuiState state = guiState;
2333 if (active == NULL) active = &temp;
2335 int itemSelected = *active;
2336 int itemFocused = -1;
2340 const char **items = GuiTextSplit(text,
';', &itemCount, NULL);
2343 boundsOpen.height = (itemCount + 1)*(bounds.height + GuiGetStyle(DROPDOWNBOX, DROPDOWN_ITEMS_SPACING));
2349 if ((state != STATE_DISABLED) && (editMode || !guiLocked) && (itemCount > 1) && !guiControlExclusiveMode)
2351 Vector2 mousePoint = GetMousePosition();
2355 state = STATE_PRESSED;
2358 if (!CheckCollisionPointRec(mousePoint, boundsOpen))
2360 if (IsMouseButtonPressed(MOUSE_LEFT_BUTTON) || IsMouseButtonReleased(MOUSE_LEFT_BUTTON)) result = 1;
2364 if (CheckCollisionPointRec(mousePoint, bounds) && IsMouseButtonPressed(MOUSE_LEFT_BUTTON)) result = 1;
2367 for (
int i = 0; i < itemCount; i++)
2370 itemBounds.y += (bounds.height + GuiGetStyle(DROPDOWNBOX, DROPDOWN_ITEMS_SPACING));
2372 if (CheckCollisionPointRec(mousePoint, itemBounds))
2375 if (IsMouseButtonReleased(MOUSE_LEFT_BUTTON))
2384 itemBounds = bounds;
2388 if (CheckCollisionPointRec(mousePoint, bounds))
2390 if (IsMouseButtonPressed(MOUSE_LEFT_BUTTON))
2393 state = STATE_PRESSED;
2395 else state = STATE_FOCUSED;
2403 if (editMode) GuiPanel(boundsOpen, NULL);
2405 GuiDrawRectangle(bounds, GuiGetStyle(DROPDOWNBOX, BORDER_WIDTH), GetColor(GuiGetStyle(DROPDOWNBOX, BORDER + state*3)), GetColor(GuiGetStyle(DROPDOWNBOX, BASE + state*3)));
2406 GuiDrawText(items[itemSelected], GetTextBounds(DROPDOWNBOX, bounds), GuiGetStyle(DROPDOWNBOX, TEXT_ALIGNMENT), GetColor(GuiGetStyle(DROPDOWNBOX, TEXT + state*3)));
2411 for (
int i = 0; i < itemCount; i++)
2414 itemBounds.y += (bounds.height + GuiGetStyle(DROPDOWNBOX, DROPDOWN_ITEMS_SPACING));
2416 if (i == itemSelected)
2418 GuiDrawRectangle(itemBounds, GuiGetStyle(DROPDOWNBOX, BORDER_WIDTH), GetColor(GuiGetStyle(DROPDOWNBOX, BORDER_COLOR_PRESSED)), GetColor(GuiGetStyle(DROPDOWNBOX, BASE_COLOR_PRESSED)));
2419 GuiDrawText(items[i], GetTextBounds(DROPDOWNBOX, itemBounds), GuiGetStyle(DROPDOWNBOX, TEXT_ALIGNMENT), GetColor(GuiGetStyle(DROPDOWNBOX, TEXT_COLOR_PRESSED)));
2421 else if (i == itemFocused)
2423 GuiDrawRectangle(itemBounds, GuiGetStyle(DROPDOWNBOX, BORDER_WIDTH), GetColor(GuiGetStyle(DROPDOWNBOX, BORDER_COLOR_FOCUSED)), GetColor(GuiGetStyle(DROPDOWNBOX, BASE_COLOR_FOCUSED)));
2424 GuiDrawText(items[i], GetTextBounds(DROPDOWNBOX, itemBounds), GuiGetStyle(DROPDOWNBOX, TEXT_ALIGNMENT), GetColor(GuiGetStyle(DROPDOWNBOX, TEXT_COLOR_FOCUSED)));
2426 else GuiDrawText(items[i], GetTextBounds(DROPDOWNBOX, itemBounds), GuiGetStyle(DROPDOWNBOX, TEXT_ALIGNMENT), GetColor(GuiGetStyle(DROPDOWNBOX, TEXT_COLOR_NORMAL)));
2430 if (!GuiGetStyle(DROPDOWNBOX, DROPDOWN_ARROW_HIDDEN))
2433 #if defined(RAYGUI_NO_ICONS) 2434 GuiDrawText(
"v", RAYGUI_CLITERAL(
Rectangle){ bounds.x + bounds.width - GuiGetStyle(DROPDOWNBOX, ARROW_PADDING), bounds.y + bounds.height/2 - 2, 10, 10 },
2435 TEXT_ALIGN_CENTER, GetColor(GuiGetStyle(DROPDOWNBOX, TEXT + (state*3))));
2437 GuiDrawText(
"#120#", RAYGUI_CLITERAL(
Rectangle){ bounds.x + bounds.width - GuiGetStyle(DROPDOWNBOX, ARROW_PADDING), bounds.y + bounds.height/2 - 6, 10, 10 },
2438 TEXT_ALIGN_CENTER, GetColor(GuiGetStyle(DROPDOWNBOX, TEXT + (state*3))));
2443 *active = itemSelected;
2451 int GuiTextBox(
Rectangle bounds,
char *text,
int textSize,
bool editMode)
2453 #if !defined(RAYGUI_TEXTBOX_AUTO_CURSOR_COOLDOWN) 2454 #define RAYGUI_TEXTBOX_AUTO_CURSOR_COOLDOWN 40 // Frames to wait for autocursor movement 2456 #if !defined(RAYGUI_TEXTBOX_AUTO_CURSOR_DELAY) 2457 #define RAYGUI_TEXTBOX_AUTO_CURSOR_DELAY 1 // Frames delay for autocursor movement 2461 GuiState state = guiState;
2463 bool multiline =
false;
2464 int wrapMode = GuiGetStyle(DEFAULT, TEXT_WRAP_MODE);
2466 Rectangle textBounds = GetTextBounds(TEXTBOX, bounds);
2467 int textLength = (int)strlen(text);
2468 int thisCursorIndex = textBoxCursorIndex;
2469 if (thisCursorIndex > textLength) thisCursorIndex = textLength;
2470 int textWidth = GetTextWidth(text) - GetTextWidth(text + thisCursorIndex);
2471 int textIndexOffset = 0;
2476 textBounds.x + textWidth + GuiGetStyle(DEFAULT, TEXT_SPACING),
2477 textBounds.y + textBounds.height/2 - GuiGetStyle(DEFAULT, TEXT_SIZE),
2479 (float)GuiGetStyle(DEFAULT, TEXT_SIZE)*2
2482 if (cursor.height >= bounds.height) cursor.height = bounds.height - GuiGetStyle(TEXTBOX, BORDER_WIDTH)*2;
2483 if (cursor.y < (bounds.y + GuiGetStyle(TEXTBOX, BORDER_WIDTH))) cursor.y = bounds.y + GuiGetStyle(TEXTBOX, BORDER_WIDTH);
2489 mouseCursor.width = 1;
2493 if (IsKeyDown(KEY_LEFT) || IsKeyDown(KEY_RIGHT) || IsKeyDown(KEY_UP) || IsKeyDown(KEY_DOWN) || IsKeyDown(KEY_BACKSPACE) || IsKeyDown(KEY_DELETE)) autoCursorCooldownCounter++;
2496 autoCursorCooldownCounter = 0;
2497 autoCursorDelayCounter = 0;
2507 if ((state != STATE_DISABLED) &&
2508 !GuiGetStyle(TEXTBOX, TEXT_READONLY) &&
2510 !guiControlExclusiveMode &&
2511 (wrapMode == TEXT_WRAP_NONE))
2513 Vector2 mousePosition = GetMousePosition();
2517 state = STATE_PRESSED;
2519 if (textBoxCursorIndex > textLength) textBoxCursorIndex = textLength;
2523 while (textWidth >= textBounds.width)
2525 int nextCodepointSize = 0;
2526 GetCodepointNext(text + textIndexOffset, &nextCodepointSize);
2528 textIndexOffset += nextCodepointSize;
2530 textWidth = GetTextWidth(text + textIndexOffset) - GetTextWidth(text + textBoxCursorIndex);
2533 int codepoint = GetCharPressed();
2534 if (multiline && IsKeyPressed(KEY_ENTER)) codepoint = (int)
'\n';
2537 int codepointSize = 0;
2538 const char *charEncoded = CodepointToUTF8(codepoint, &codepointSize);
2542 if (((multiline && (codepoint == (
int)
'\n')) || (codepoint >= 32)) && ((textLength + codepointSize) < textSize))
2545 for (
int i = (textLength + codepointSize); i > textBoxCursorIndex; i--) text[i] = text[i - codepointSize];
2548 for (
int i = 0; i < codepointSize; i++) text[textBoxCursorIndex + i] = charEncoded[i];
2550 textBoxCursorIndex += codepointSize;
2551 textLength += codepointSize;
2554 text[textLength] =
'\0';
2558 if ((textLength > 0) && IsKeyPressed(KEY_HOME)) textBoxCursorIndex = 0;
2561 if ((textLength > textBoxCursorIndex) && IsKeyPressed(KEY_END)) textBoxCursorIndex = textLength;
2564 if ((textLength > textBoxCursorIndex) && (IsKeyPressed(KEY_DELETE) || (IsKeyDown(KEY_DELETE) && (autoCursorCooldownCounter >= RAYGUI_TEXTBOX_AUTO_CURSOR_COOLDOWN))))
2566 autoCursorDelayCounter++;
2568 if (IsKeyPressed(KEY_DELETE) || (autoCursorDelayCounter%RAYGUI_TEXTBOX_AUTO_CURSOR_DELAY) == 0)
2570 int nextCodepointSize = 0;
2571 GetCodepointNext(text + textBoxCursorIndex, &nextCodepointSize);
2574 for (
int i = textBoxCursorIndex; i < textLength; i++) text[i] = text[i + nextCodepointSize];
2576 textLength -= codepointSize;
2577 if (textBoxCursorIndex > textLength) textBoxCursorIndex = textLength;
2580 text[textLength] =
'\0';
2585 if ((textLength > 0) && (IsKeyPressed(KEY_BACKSPACE) || (IsKeyDown(KEY_BACKSPACE) && (autoCursorCooldownCounter >= RAYGUI_TEXTBOX_AUTO_CURSOR_COOLDOWN))))
2587 autoCursorDelayCounter++;
2589 if (IsKeyPressed(KEY_BACKSPACE) || (autoCursorDelayCounter%RAYGUI_TEXTBOX_AUTO_CURSOR_DELAY) == 0)
2591 int prevCodepointSize = 0;
2592 GetCodepointPrevious(text + textBoxCursorIndex, &prevCodepointSize);
2595 for (
int i = (textBoxCursorIndex - prevCodepointSize); i < textLength; i++) text[i] = text[i + prevCodepointSize];
2600 if (textBoxCursorIndex > 0)
2602 textBoxCursorIndex -= codepointSize;
2603 textLength -= codepointSize;
2607 text[textLength] =
'\0';
2612 if (IsKeyPressed(KEY_LEFT) || (IsKeyDown(KEY_LEFT) && (autoCursorCooldownCounter > RAYGUI_TEXTBOX_AUTO_CURSOR_COOLDOWN)))
2614 autoCursorDelayCounter++;
2616 if (IsKeyPressed(KEY_LEFT) || (autoCursorDelayCounter%RAYGUI_TEXTBOX_AUTO_CURSOR_DELAY) == 0)
2618 int prevCodepointSize = 0;
2619 GetCodepointPrevious(text + textBoxCursorIndex, &prevCodepointSize);
2621 if (textBoxCursorIndex >= prevCodepointSize) textBoxCursorIndex -= prevCodepointSize;
2624 else if (IsKeyPressed(KEY_RIGHT) || (IsKeyDown(KEY_RIGHT) && (autoCursorCooldownCounter > RAYGUI_TEXTBOX_AUTO_CURSOR_COOLDOWN)))
2626 autoCursorDelayCounter++;
2628 if (IsKeyPressed(KEY_RIGHT) || (autoCursorDelayCounter%RAYGUI_TEXTBOX_AUTO_CURSOR_DELAY) == 0)
2630 int nextCodepointSize = 0;
2631 GetCodepointNext(text + textBoxCursorIndex, &nextCodepointSize);
2633 if ((textBoxCursorIndex + nextCodepointSize) <= textLength) textBoxCursorIndex += nextCodepointSize;
2638 if (CheckCollisionPointRec(mousePosition, textBounds))
2640 float scaleFactor = (float)GuiGetStyle(DEFAULT, TEXT_SIZE)/(float)guiFont.baseSize;
2641 int codepointIndex = 0;
2642 float glyphWidth = 0.0f;
2643 float widthToMouseX = 0;
2644 int mouseCursorIndex = 0;
2646 for (
int i = textIndexOffset; i < textLength; i++)
2648 codepoint = GetCodepointNext(&text[i], &codepointSize);
2649 codepointIndex = GetGlyphIndex(guiFont, codepoint);
2651 if (guiFont.glyphs[codepointIndex].advanceX == 0) glyphWidth = ((float)guiFont.recs[codepointIndex].width*scaleFactor);
2652 else glyphWidth = ((float)guiFont.glyphs[codepointIndex].advanceX*scaleFactor);
2654 if (mousePosition.x <= (textBounds.x + (widthToMouseX + glyphWidth/2)))
2656 mouseCursor.x = textBounds.x + widthToMouseX;
2657 mouseCursorIndex = i;
2661 widthToMouseX += (glyphWidth + (float)GuiGetStyle(DEFAULT, TEXT_SPACING));
2665 int textEndWidth = GetTextWidth(text + textIndexOffset);
2666 if (GetMousePosition().x >= (textBounds.x + textEndWidth - glyphWidth/2))
2668 mouseCursor.x = textBounds.x + textEndWidth;
2669 mouseCursorIndex = textLength;
2673 if ((mouseCursor.x >= 0) && IsMouseButtonPressed(MOUSE_LEFT_BUTTON))
2675 cursor.x = mouseCursor.x;
2676 textBoxCursorIndex = mouseCursorIndex;
2679 else mouseCursor.x = -1;
2682 cursor.x = bounds.x + GuiGetStyle(TEXTBOX, TEXT_PADDING) + GetTextWidth(text + textIndexOffset) - GetTextWidth(text + textBoxCursorIndex) + GuiGetStyle(DEFAULT, TEXT_SPACING);
2686 if ((!multiline && IsKeyPressed(KEY_ENTER)) ||
2687 (!CheckCollisionPointRec(mousePosition, bounds) && IsMouseButtonPressed(MOUSE_LEFT_BUTTON)))
2689 textBoxCursorIndex = 0;
2695 if (CheckCollisionPointRec(mousePosition, bounds))
2697 state = STATE_FOCUSED;
2699 if (IsMouseButtonPressed(MOUSE_LEFT_BUTTON))
2701 textBoxCursorIndex = textLength;
2711 if (state == STATE_PRESSED)
2713 GuiDrawRectangle(bounds, GuiGetStyle(TEXTBOX, BORDER_WIDTH), GetColor(GuiGetStyle(TEXTBOX, BORDER + (state*3))), GetColor(GuiGetStyle(TEXTBOX, BASE_COLOR_PRESSED)));
2715 else if (state == STATE_DISABLED)
2717 GuiDrawRectangle(bounds, GuiGetStyle(TEXTBOX, BORDER_WIDTH), GetColor(GuiGetStyle(TEXTBOX, BORDER + (state*3))), GetColor(GuiGetStyle(TEXTBOX, BASE_COLOR_DISABLED)));
2719 else GuiDrawRectangle(bounds, GuiGetStyle(TEXTBOX, BORDER_WIDTH), GetColor(GuiGetStyle(TEXTBOX, BORDER + (state*3))), BLANK);
2723 GuiDrawText(text + textIndexOffset, textBounds, GuiGetStyle(TEXTBOX, TEXT_ALIGNMENT), GetColor(GuiGetStyle(TEXTBOX, TEXT + (state*3))));
2726 if (editMode && !GuiGetStyle(TEXTBOX, TEXT_READONLY))
2729 GuiDrawRectangle(cursor, 0, BLANK, GetColor(GuiGetStyle(TEXTBOX, BORDER_COLOR_PRESSED)));
2732 if (mouseCursor.x >= 0) GuiDrawRectangle(mouseCursor, 0, BLANK, GetColor(GuiGetStyle(TEXTBOX, BORDER_COLOR_PRESSED)));
2734 else if (state == STATE_FOCUSED) GuiTooltip(bounds);
2763 int GuiSpinner(
Rectangle bounds,
const char *text,
int *value,
int minValue,
int maxValue,
bool editMode)
2766 GuiState state = guiState;
2768 int tempValue = *value;
2770 Rectangle spinner = { bounds.x + GuiGetStyle(SPINNER, SPIN_BUTTON_WIDTH) + GuiGetStyle(SPINNER, SPIN_BUTTON_SPACING), bounds.y,
2771 bounds.width - 2*(GuiGetStyle(SPINNER, SPIN_BUTTON_WIDTH) + GuiGetStyle(SPINNER, SPIN_BUTTON_SPACING)), bounds.height };
2772 Rectangle leftButtonBound = { (float)bounds.x, (
float)bounds.y, (float)GuiGetStyle(SPINNER, SPIN_BUTTON_WIDTH), (float)bounds.height };
2773 Rectangle rightButtonBound = { (float)bounds.x + bounds.width - GuiGetStyle(SPINNER, SPIN_BUTTON_WIDTH), (float)bounds.y, (
float)GuiGetStyle(SPINNER, SPIN_BUTTON_WIDTH), (float)bounds.height };
2778 textBounds.width = (float)GetTextWidth(text) + 2;
2779 textBounds.height = (float)GuiGetStyle(DEFAULT, TEXT_SIZE);
2780 textBounds.x = bounds.x + bounds.width + GuiGetStyle(SPINNER, TEXT_PADDING);
2781 textBounds.y = bounds.y + bounds.height/2 - GuiGetStyle(DEFAULT, TEXT_SIZE)/2;
2782 if (GuiGetStyle(SPINNER, TEXT_ALIGNMENT) == TEXT_ALIGN_LEFT) textBounds.x = bounds.x - textBounds.width - GuiGetStyle(SPINNER, TEXT_PADDING);
2787 if ((state != STATE_DISABLED) && !guiLocked && !guiControlExclusiveMode)
2789 Vector2 mousePoint = GetMousePosition();
2792 if (CheckCollisionPointRec(mousePoint, bounds))
2794 if (IsMouseButtonDown(MOUSE_LEFT_BUTTON)) state = STATE_PRESSED;
2795 else state = STATE_FOCUSED;
2799 #if defined(RAYGUI_NO_ICONS) 2800 if (GuiButton(leftButtonBound,
"<")) tempValue--;
2801 if (GuiButton(rightButtonBound,
">")) tempValue++;
2803 if (GuiButton(leftButtonBound, GuiIconText(ICON_ARROW_LEFT_FILL, NULL))) tempValue--;
2804 if (GuiButton(rightButtonBound, GuiIconText(ICON_ARROW_RIGHT_FILL, NULL))) tempValue++;
2809 if (tempValue < minValue) tempValue = minValue;
2810 if (tempValue > maxValue) tempValue = maxValue;
2816 result = GuiValueBox(spinner, NULL, &tempValue, minValue, maxValue, editMode);
2820 int tempBorderWidth = GuiGetStyle(BUTTON, BORDER_WIDTH);
2821 int tempTextAlign = GuiGetStyle(BUTTON, TEXT_ALIGNMENT);
2822 GuiSetStyle(BUTTON, BORDER_WIDTH, GuiGetStyle(SPINNER, BORDER_WIDTH));
2823 GuiSetStyle(BUTTON, TEXT_ALIGNMENT, TEXT_ALIGN_CENTER);
2825 GuiSetStyle(BUTTON, TEXT_ALIGNMENT, tempTextAlign);
2826 GuiSetStyle(BUTTON, BORDER_WIDTH, tempBorderWidth);
2829 GuiDrawText(text, textBounds, (GuiGetStyle(SPINNER, TEXT_ALIGNMENT) == TEXT_ALIGN_RIGHT)? TEXT_ALIGN_LEFT : TEXT_ALIGN_RIGHT, GetColor(GuiGetStyle(LABEL, TEXT + (state*3))));
2838 int GuiValueBox(
Rectangle bounds,
const char *text,
int *value,
int minValue,
int maxValue,
bool editMode)
2840 #if !defined(RAYGUI_VALUEBOX_MAX_CHARS) 2841 #define RAYGUI_VALUEBOX_MAX_CHARS 32 2845 GuiState state = guiState;
2847 char textValue[RAYGUI_VALUEBOX_MAX_CHARS + 1] =
"\0";
2848 sprintf(textValue,
"%i", *value);
2853 textBounds.width = (float)GetTextWidth(text) + 2;
2854 textBounds.height = (float)GuiGetStyle(DEFAULT, TEXT_SIZE);
2855 textBounds.x = bounds.x + bounds.width + GuiGetStyle(VALUEBOX, TEXT_PADDING);
2856 textBounds.y = bounds.y + bounds.height/2 - GuiGetStyle(DEFAULT, TEXT_SIZE)/2;
2857 if (GuiGetStyle(VALUEBOX, TEXT_ALIGNMENT) == TEXT_ALIGN_LEFT) textBounds.x = bounds.x - textBounds.width - GuiGetStyle(VALUEBOX, TEXT_PADDING);
2862 if ((state != STATE_DISABLED) && !guiLocked && !guiControlExclusiveMode)
2864 Vector2 mousePoint = GetMousePosition();
2866 bool valueHasChanged =
false;
2870 state = STATE_PRESSED;
2872 int keyCount = (int)strlen(textValue);
2875 if (keyCount < RAYGUI_VALUEBOX_MAX_CHARS)
2877 if (GetTextWidth(textValue) < bounds.width)
2879 int key = GetCharPressed();
2880 if ((key >= 48) && (key <= 57))
2882 textValue[keyCount] = (char)key;
2884 valueHasChanged =
true;
2892 if (IsKeyPressed(KEY_BACKSPACE))
2895 textValue[keyCount] =
'\0';
2896 valueHasChanged =
true;
2900 if (valueHasChanged) *value = TextToInteger(textValue);
2906 if (IsKeyPressed(KEY_ENTER) || (!CheckCollisionPointRec(mousePoint, bounds) && IsMouseButtonPressed(MOUSE_LEFT_BUTTON)))
2908 if (*value > maxValue) *value = maxValue;
2909 else if (*value < minValue) *value = minValue;
2916 if (*value > maxValue) *value = maxValue;
2917 else if (*value < minValue) *value = minValue;
2919 if (CheckCollisionPointRec(mousePoint, bounds))
2921 state = STATE_FOCUSED;
2922 if (IsMouseButtonPressed(MOUSE_LEFT_BUTTON)) result = 1;
2930 Color baseColor = BLANK;
2931 if (state == STATE_PRESSED) baseColor = GetColor(GuiGetStyle(VALUEBOX, BASE_COLOR_PRESSED));
2932 else if (state == STATE_DISABLED) baseColor = GetColor(GuiGetStyle(VALUEBOX, BASE_COLOR_DISABLED));
2934 GuiDrawRectangle(bounds, GuiGetStyle(VALUEBOX, BORDER_WIDTH), GetColor(GuiGetStyle(VALUEBOX, BORDER + (state*3))), baseColor);
2935 GuiDrawText(textValue, GetTextBounds(VALUEBOX, bounds), TEXT_ALIGN_CENTER, GetColor(GuiGetStyle(VALUEBOX, TEXT + (state*3))));
2941 Rectangle cursor = { bounds.x + GetTextWidth(textValue)/2 + bounds.width/2 + 1, bounds.y + 2*GuiGetStyle(VALUEBOX, BORDER_WIDTH), 4, bounds.height - 4*GuiGetStyle(VALUEBOX, BORDER_WIDTH) };
2942 GuiDrawRectangle(cursor, 0, BLANK, GetColor(GuiGetStyle(VALUEBOX, BORDER_COLOR_PRESSED)));
2946 GuiDrawText(text, textBounds, (GuiGetStyle(VALUEBOX, TEXT_ALIGNMENT) == TEXT_ALIGN_RIGHT)? TEXT_ALIGN_LEFT : TEXT_ALIGN_RIGHT, GetColor(GuiGetStyle(LABEL, TEXT + (state*3))));
2954 int GuiValueBoxFloat(
Rectangle bounds,
const char *text,
char *textValue,
float *value,
bool editMode)
2956 #if !defined(RAYGUI_VALUEBOX_MAX_CHARS) 2957 #define RAYGUI_VALUEBOX_MAX_CHARS 32 2961 GuiState state = guiState;
2969 textBounds.width = (float)GetTextWidth(text) + 2;
2970 textBounds.height = (float)GuiGetStyle(DEFAULT, TEXT_SIZE);
2971 textBounds.x = bounds.x + bounds.width + GuiGetStyle(VALUEBOX, TEXT_PADDING);
2972 textBounds.y = bounds.y + bounds.height/2 - GuiGetStyle(DEFAULT, TEXT_SIZE)/2;
2973 if (GuiGetStyle(VALUEBOX, TEXT_ALIGNMENT) == TEXT_ALIGN_LEFT) textBounds.x = bounds.x - textBounds.width - GuiGetStyle(VALUEBOX, TEXT_PADDING);
2978 if ((state != STATE_DISABLED) && !guiLocked && !guiControlExclusiveMode)
2980 Vector2 mousePoint = GetMousePosition();
2982 bool valueHasChanged =
false;
2986 state = STATE_PRESSED;
2988 int keyCount = (int)strlen(textValue);
2991 if (keyCount < RAYGUI_VALUEBOX_MAX_CHARS)
2993 if (GetTextWidth(textValue) < bounds.width)
2995 int key = GetCharPressed();
2996 if (((key >= 48) && (key <= 57)) ||
2998 ((keyCount == 0) && (key ==
'+')) ||
2999 ((keyCount == 0) && (key ==
'-')))
3001 textValue[keyCount] = (char)key;
3004 valueHasChanged =
true;
3010 if (IsKeyPressed(KEY_BACKSPACE))
3015 textValue[keyCount] =
'\0';
3016 valueHasChanged =
true;
3020 if (valueHasChanged) *value = TextToFloat(textValue);
3022 if (IsKeyPressed(KEY_ENTER) || (!CheckCollisionPointRec(mousePoint, bounds) && IsMouseButtonPressed(MOUSE_LEFT_BUTTON))) result = 1;
3026 if (CheckCollisionPointRec(mousePoint, bounds))
3028 state = STATE_FOCUSED;
3029 if (IsMouseButtonPressed(MOUSE_LEFT_BUTTON)) result = 1;
3037 Color baseColor = BLANK;
3038 if (state == STATE_PRESSED) baseColor = GetColor(GuiGetStyle(VALUEBOX, BASE_COLOR_PRESSED));
3039 else if (state == STATE_DISABLED) baseColor = GetColor(GuiGetStyle(VALUEBOX, BASE_COLOR_DISABLED));
3041 GuiDrawRectangle(bounds, GuiGetStyle(VALUEBOX, BORDER_WIDTH), GetColor(GuiGetStyle(VALUEBOX, BORDER + (state*3))), baseColor);
3042 GuiDrawText(textValue, GetTextBounds(VALUEBOX, bounds), TEXT_ALIGN_CENTER, GetColor(GuiGetStyle(VALUEBOX, TEXT + (state*3))));
3048 Rectangle cursor = {bounds.x + GetTextWidth(textValue)/2 + bounds.width/2 + 1,
3049 bounds.y + 2*GuiGetStyle(VALUEBOX, BORDER_WIDTH), 4,
3050 bounds.height - 4*GuiGetStyle(VALUEBOX, BORDER_WIDTH)};
3051 GuiDrawRectangle(cursor, 0, BLANK, GetColor(GuiGetStyle(VALUEBOX, BORDER_COLOR_PRESSED)));
3055 GuiDrawText(text, textBounds,
3056 (GuiGetStyle(VALUEBOX, TEXT_ALIGNMENT) == TEXT_ALIGN_RIGHT)? TEXT_ALIGN_LEFT : TEXT_ALIGN_RIGHT,
3057 GetColor(GuiGetStyle(LABEL, TEXT + (state*3))));
3065 int GuiSliderPro(
Rectangle bounds,
const char *textLeft,
const char *textRight,
float *value,
float minValue,
float maxValue,
int sliderWidth)
3068 GuiState state = guiState;
3070 float temp = (maxValue - minValue)/2.0f;
3071 if (value == NULL) value = &temp;
3072 float oldValue = *value;
3074 Rectangle slider = { bounds.x, bounds.y + GuiGetStyle(SLIDER, BORDER_WIDTH) + GuiGetStyle(SLIDER, SLIDER_PADDING),
3075 0, bounds.height - 2*GuiGetStyle(SLIDER, BORDER_WIDTH) - 2*GuiGetStyle(SLIDER, SLIDER_PADDING) };
3079 if ((state != STATE_DISABLED) && !guiLocked)
3081 Vector2 mousePoint = GetMousePosition();
3083 if (guiControlExclusiveMode)
3085 if (IsMouseButtonDown(MOUSE_LEFT_BUTTON))
3087 if (CHECK_BOUNDS_ID(bounds, guiControlExclusiveRec))
3089 state = STATE_PRESSED;
3091 *value = (maxValue - minValue)*((mousePoint.x - bounds.x - sliderWidth/2)/(bounds.width-sliderWidth)) + minValue;
3096 guiControlExclusiveMode =
false;
3097 guiControlExclusiveRec = RAYGUI_CLITERAL(
Rectangle){ 0, 0, 0, 0 };
3100 else if (CheckCollisionPointRec(mousePoint, bounds))
3102 if (IsMouseButtonDown(MOUSE_LEFT_BUTTON))
3104 state = STATE_PRESSED;
3105 guiControlExclusiveMode =
true;
3106 guiControlExclusiveRec = bounds;
3108 if (!CheckCollisionPointRec(mousePoint, slider))
3111 *value = (maxValue - minValue)*((mousePoint.x - bounds.x - sliderWidth/2)/(bounds.width-sliderWidth)) + minValue;
3114 else state = STATE_FOCUSED;
3117 if (*value > maxValue) *value = maxValue;
3118 else if (*value < minValue) *value = minValue;
3122 if (oldValue == *value) result = 0;
3126 float sliderValue = (((*value - minValue)/(maxValue - minValue))*(bounds.width - sliderWidth - 2*GuiGetStyle(SLIDER, BORDER_WIDTH)));
3127 if (sliderWidth > 0)
3129 slider.x += sliderValue;
3130 slider.width = (float)sliderWidth;
3131 if (slider.x <= (bounds.x + GuiGetStyle(SLIDER, BORDER_WIDTH))) slider.x = bounds.x + GuiGetStyle(SLIDER, BORDER_WIDTH);
3132 else if ((slider.x + slider.width) >= (bounds.x + bounds.width)) slider.x = bounds.x + bounds.width - slider.width - GuiGetStyle(SLIDER, BORDER_WIDTH);
3134 else if (sliderWidth == 0)
3136 slider.x += GuiGetStyle(SLIDER, BORDER_WIDTH);
3137 slider.width = sliderValue;
3138 if (slider.width > bounds.width) slider.width = bounds.width - 2*GuiGetStyle(SLIDER, BORDER_WIDTH);
3144 GuiDrawRectangle(bounds, GuiGetStyle(SLIDER, BORDER_WIDTH), GetColor(GuiGetStyle(SLIDER, BORDER + (state*3))), GetColor(GuiGetStyle(SLIDER, (state != STATE_DISABLED)? BASE_COLOR_NORMAL : BASE_COLOR_DISABLED)));
3147 if (state == STATE_NORMAL) GuiDrawRectangle(slider, 0, BLANK, GetColor(GuiGetStyle(SLIDER, BASE_COLOR_PRESSED)));
3148 else if (state == STATE_FOCUSED) GuiDrawRectangle(slider, 0, BLANK, GetColor(GuiGetStyle(SLIDER, TEXT_COLOR_FOCUSED)));
3149 else if (state == STATE_PRESSED) GuiDrawRectangle(slider, 0, BLANK, GetColor(GuiGetStyle(SLIDER, TEXT_COLOR_PRESSED)));
3152 if (textLeft != NULL)
3155 textBounds.width = (float)GetTextWidth(textLeft);
3156 textBounds.height = (float)GuiGetStyle(DEFAULT, TEXT_SIZE);
3157 textBounds.x = bounds.x - textBounds.width - GuiGetStyle(SLIDER, TEXT_PADDING);
3158 textBounds.y = bounds.y + bounds.height/2 - GuiGetStyle(DEFAULT, TEXT_SIZE)/2;
3160 GuiDrawText(textLeft, textBounds, TEXT_ALIGN_RIGHT, GetColor(GuiGetStyle(SLIDER, TEXT + (state*3))));
3163 if (textRight != NULL)
3166 textBounds.width = (float)GetTextWidth(textRight);
3167 textBounds.height = (float)GuiGetStyle(DEFAULT, TEXT_SIZE);
3168 textBounds.x = bounds.x + bounds.width + GuiGetStyle(SLIDER, TEXT_PADDING);
3169 textBounds.y = bounds.y + bounds.height/2 - GuiGetStyle(DEFAULT, TEXT_SIZE)/2;
3171 GuiDrawText(textRight, textBounds, TEXT_ALIGN_LEFT, GetColor(GuiGetStyle(SLIDER, TEXT + (state*3))));
3179 int GuiSlider(
Rectangle bounds,
const char *textLeft,
const char *textRight,
float *value,
float minValue,
float maxValue)
3181 return GuiSliderPro(bounds, textLeft, textRight, value, minValue, maxValue, GuiGetStyle(SLIDER, SLIDER_WIDTH));
3185 int GuiSliderBar(
Rectangle bounds,
const char *textLeft,
const char *textRight,
float *value,
float minValue,
float maxValue)
3187 return GuiSliderPro(bounds, textLeft, textRight, value, minValue, maxValue, 0);
3191 int GuiProgressBar(
Rectangle bounds,
const char *textLeft,
const char *textRight,
float *value,
float minValue,
float maxValue)
3194 GuiState state = guiState;
3196 float temp = (maxValue - minValue)/2.0f;
3197 if (value == NULL) value = &temp;
3200 Rectangle progress = { bounds.x + GuiGetStyle(PROGRESSBAR, BORDER_WIDTH),
3201 bounds.y + GuiGetStyle(PROGRESSBAR, BORDER_WIDTH) + GuiGetStyle(PROGRESSBAR, PROGRESS_PADDING), 0,
3202 bounds.height - 2*GuiGetStyle(PROGRESSBAR, BORDER_WIDTH) - 2*GuiGetStyle(PROGRESSBAR, PROGRESS_PADDING) };
3206 if (*value > maxValue) *value = maxValue;
3209 if ((state != STATE_DISABLED)) progress.width = (float)(*value/(maxValue - minValue))*bounds.width - ((*value >= maxValue)? (float)(2*GuiGetStyle(PROGRESSBAR, BORDER_WIDTH)) : 0.0f);
3214 if (state == STATE_DISABLED)
3216 GuiDrawRectangle(bounds, GuiGetStyle(PROGRESSBAR, BORDER_WIDTH), GetColor(GuiGetStyle(PROGRESSBAR, BORDER + (state*3))), BLANK);
3220 if (*value > minValue)
3223 GuiDrawRectangle(RAYGUI_CLITERAL(
Rectangle){ bounds.x, bounds.y, (int)progress.width + (
float)GuiGetStyle(PROGRESSBAR, BORDER_WIDTH), (float)GuiGetStyle(PROGRESSBAR, BORDER_WIDTH) }, 0, BLANK, GetColor(GuiGetStyle(PROGRESSBAR, BORDER_COLOR_FOCUSED)));
3224 GuiDrawRectangle(RAYGUI_CLITERAL(
Rectangle){ bounds.x, bounds.y + 1, (float)GuiGetStyle(PROGRESSBAR, BORDER_WIDTH), bounds.height - 2 }, 0, BLANK, GetColor(GuiGetStyle(PROGRESSBAR, BORDER_COLOR_FOCUSED)));
3225 GuiDrawRectangle(RAYGUI_CLITERAL(
Rectangle){ bounds.x, bounds.y + bounds.height - 1, (int)progress.width + (
float)GuiGetStyle(PROGRESSBAR, BORDER_WIDTH), (float)GuiGetStyle(PROGRESSBAR, BORDER_WIDTH) }, 0, BLANK, GetColor(GuiGetStyle(PROGRESSBAR, BORDER_COLOR_FOCUSED)));
3227 else GuiDrawRectangle(RAYGUI_CLITERAL(
Rectangle){ bounds.x, bounds.y, (float)GuiGetStyle(PROGRESSBAR, BORDER_WIDTH), bounds.height }, 0, BLANK, GetColor(GuiGetStyle(PROGRESSBAR, BORDER_COLOR_NORMAL)));
3229 if (*value >= maxValue) GuiDrawRectangle(RAYGUI_CLITERAL(
Rectangle){ bounds.x + progress.width + 1, bounds.y, (float)GuiGetStyle(PROGRESSBAR, BORDER_WIDTH), bounds.height }, 0, BLANK, GetColor(GuiGetStyle(PROGRESSBAR, BORDER_COLOR_FOCUSED)));
3233 GuiDrawRectangle(RAYGUI_CLITERAL(
Rectangle){ bounds.x + (int)progress.width + 1, bounds.y, bounds.width - (
int)progress.width - 1, (float)GuiGetStyle(PROGRESSBAR, BORDER_WIDTH) }, 0, BLANK, GetColor(GuiGetStyle(PROGRESSBAR, BORDER_COLOR_NORMAL)));
3234 GuiDrawRectangle(RAYGUI_CLITERAL(
Rectangle){ bounds.x + (int)progress.width + 1, bounds.y + bounds.height - 1, bounds.width - (
int)progress.width - 1, (float)GuiGetStyle(PROGRESSBAR, BORDER_WIDTH) }, 0, BLANK, GetColor(GuiGetStyle(PROGRESSBAR, BORDER_COLOR_NORMAL)));
3235 GuiDrawRectangle(RAYGUI_CLITERAL(
Rectangle){ bounds.x + bounds.width - 1, bounds.y + 1, (float)GuiGetStyle(PROGRESSBAR, BORDER_WIDTH), bounds.height - 2 }, 0, BLANK, GetColor(GuiGetStyle(PROGRESSBAR, BORDER_COLOR_NORMAL)));
3239 GuiDrawRectangle(progress, 0, BLANK, GetColor(GuiGetStyle(PROGRESSBAR, BASE_COLOR_PRESSED)));
3243 if (textLeft != NULL)
3246 textBounds.width = (float)GetTextWidth(textLeft);
3247 textBounds.height = (float)GuiGetStyle(DEFAULT, TEXT_SIZE);
3248 textBounds.x = bounds.x - textBounds.width - GuiGetStyle(PROGRESSBAR, TEXT_PADDING);
3249 textBounds.y = bounds.y + bounds.height/2 - GuiGetStyle(DEFAULT, TEXT_SIZE)/2;
3251 GuiDrawText(textLeft, textBounds, TEXT_ALIGN_RIGHT, GetColor(GuiGetStyle(PROGRESSBAR, TEXT + (state*3))));
3254 if (textRight != NULL)
3257 textBounds.width = (float)GetTextWidth(textRight);
3258 textBounds.height = (float)GuiGetStyle(DEFAULT, TEXT_SIZE);
3259 textBounds.x = bounds.x + bounds.width + GuiGetStyle(PROGRESSBAR, TEXT_PADDING);
3260 textBounds.y = bounds.y + bounds.height/2 - GuiGetStyle(DEFAULT, TEXT_SIZE)/2;
3262 GuiDrawText(textRight, textBounds, TEXT_ALIGN_LEFT, GetColor(GuiGetStyle(PROGRESSBAR, TEXT + (state*3))));
3270 int GuiStatusBar(
Rectangle bounds,
const char *text)
3273 GuiState state = guiState;
3277 GuiDrawRectangle(bounds, GuiGetStyle(STATUSBAR, BORDER_WIDTH), GetColor(GuiGetStyle(STATUSBAR, BORDER + (state*3))), GetColor(GuiGetStyle(STATUSBAR, BASE + (state*3))));
3278 GuiDrawText(text, GetTextBounds(STATUSBAR, bounds), GuiGetStyle(STATUSBAR, TEXT_ALIGNMENT), GetColor(GuiGetStyle(STATUSBAR, TEXT + (state*3))));
3285 int GuiDummyRec(
Rectangle bounds,
const char *text)
3288 GuiState state = guiState;
3292 if ((state != STATE_DISABLED) && !guiLocked && !guiControlExclusiveMode)
3294 Vector2 mousePoint = GetMousePosition();
3297 if (CheckCollisionPointRec(mousePoint, bounds))
3299 if (IsMouseButtonDown(MOUSE_LEFT_BUTTON)) state = STATE_PRESSED;
3300 else state = STATE_FOCUSED;
3307 GuiDrawRectangle(bounds, 0, BLANK, GetColor(GuiGetStyle(DEFAULT, (state != STATE_DISABLED)? BASE_COLOR_NORMAL : BASE_COLOR_DISABLED)));
3308 GuiDrawText(text, GetTextBounds(DEFAULT, bounds), TEXT_ALIGN_CENTER, GetColor(GuiGetStyle(BUTTON, (state != STATE_DISABLED)? TEXT_COLOR_NORMAL : TEXT_COLOR_DISABLED)));
3315 int GuiListView(
Rectangle bounds,
const char *text,
int *scrollIndex,
int *active)
3319 const char **items = NULL;
3321 if (text != NULL) items = GuiTextSplit(text,
';', &itemCount, NULL);
3323 result = GuiListViewEx(bounds, items, itemCount, scrollIndex, active, NULL);
3329 int GuiListViewEx(
Rectangle bounds,
const char **text,
int count,
int *scrollIndex,
int *active,
int *focus)
3332 GuiState state = guiState;
3334 int itemFocused = (focus == NULL)? -1 : *focus;
3335 int itemSelected = (active == NULL)? -1 : *active;
3338 bool useScrollBar =
false;
3339 if ((GuiGetStyle(LISTVIEW, LIST_ITEMS_HEIGHT) + GuiGetStyle(LISTVIEW, LIST_ITEMS_SPACING))*count > bounds.height) useScrollBar =
true;
3343 itemBounds.x = bounds.x + GuiGetStyle(LISTVIEW, LIST_ITEMS_SPACING);
3344 itemBounds.y = bounds.y + GuiGetStyle(LISTVIEW, LIST_ITEMS_SPACING) + GuiGetStyle(DEFAULT, BORDER_WIDTH);
3345 itemBounds.width = bounds.width - 2*GuiGetStyle(LISTVIEW, LIST_ITEMS_SPACING) - GuiGetStyle(DEFAULT, BORDER_WIDTH);
3346 itemBounds.height = (float)GuiGetStyle(LISTVIEW, LIST_ITEMS_HEIGHT);
3347 if (useScrollBar) itemBounds.width -= GuiGetStyle(LISTVIEW, SCROLLBAR_WIDTH);
3350 int visibleItems = (int)bounds.height/(GuiGetStyle(LISTVIEW, LIST_ITEMS_HEIGHT) + GuiGetStyle(LISTVIEW, LIST_ITEMS_SPACING));
3351 if (visibleItems > count) visibleItems = count;
3353 int startIndex = (scrollIndex == NULL)? 0 : *scrollIndex;
3354 if ((startIndex < 0) || (startIndex > (count - visibleItems))) startIndex = 0;
3355 int endIndex = startIndex + visibleItems;
3359 if ((state != STATE_DISABLED) && !guiLocked && !guiControlExclusiveMode)
3361 Vector2 mousePoint = GetMousePosition();
3364 if (CheckCollisionPointRec(mousePoint, bounds))
3366 state = STATE_FOCUSED;
3369 for (
int i = 0; i < visibleItems; i++)
3371 if (CheckCollisionPointRec(mousePoint, itemBounds))
3373 itemFocused = startIndex + i;
3374 if (IsMouseButtonPressed(MOUSE_LEFT_BUTTON))
3376 if (itemSelected == (startIndex + i)) itemSelected = -1;
3377 else itemSelected = startIndex + i;
3383 itemBounds.y += (GuiGetStyle(LISTVIEW, LIST_ITEMS_HEIGHT) + GuiGetStyle(LISTVIEW, LIST_ITEMS_SPACING));
3388 int wheelMove = (int)GetMouseWheelMove();
3389 startIndex -= wheelMove;
3391 if (startIndex < 0) startIndex = 0;
3392 else if (startIndex > (count - visibleItems)) startIndex = count - visibleItems;
3394 endIndex = startIndex + visibleItems;
3395 if (endIndex > count) endIndex = count;
3398 else itemFocused = -1;
3401 itemBounds.y = bounds.y + GuiGetStyle(LISTVIEW, LIST_ITEMS_SPACING) + GuiGetStyle(DEFAULT, BORDER_WIDTH);
3407 GuiDrawRectangle(bounds, GuiGetStyle(DEFAULT, BORDER_WIDTH), GetColor(GuiGetStyle(LISTVIEW, BORDER + state*3)), GetColor(GuiGetStyle(DEFAULT, BACKGROUND_COLOR)));
3410 for (
int i = 0; ((i < visibleItems) && (text != NULL)); i++)
3412 GuiDrawRectangle(itemBounds, GuiGetStyle(LISTVIEW, LIST_ITEMS_BORDER_WIDTH), GetColor(GuiGetStyle(LISTVIEW, BORDER_COLOR_NORMAL)), BLANK);
3414 if (state == STATE_DISABLED)
3416 if ((startIndex + i) == itemSelected) GuiDrawRectangle(itemBounds, GuiGetStyle(LISTVIEW, BORDER_WIDTH), GetColor(GuiGetStyle(LISTVIEW, BORDER_COLOR_DISABLED)), GetColor(GuiGetStyle(LISTVIEW, BASE_COLOR_DISABLED)));
3418 GuiDrawText(text[startIndex + i], GetTextBounds(DEFAULT, itemBounds), GuiGetStyle(LISTVIEW, TEXT_ALIGNMENT), GetColor(GuiGetStyle(LISTVIEW, TEXT_COLOR_DISABLED)));
3422 if (((startIndex + i) == itemSelected) && (active != NULL))
3425 GuiDrawRectangle(itemBounds, GuiGetStyle(LISTVIEW, BORDER_WIDTH), GetColor(GuiGetStyle(LISTVIEW, BORDER_COLOR_PRESSED)), GetColor(GuiGetStyle(LISTVIEW, BASE_COLOR_PRESSED)));
3426 GuiDrawText(text[startIndex + i], GetTextBounds(DEFAULT, itemBounds), GuiGetStyle(LISTVIEW, TEXT_ALIGNMENT), GetColor(GuiGetStyle(LISTVIEW, TEXT_COLOR_PRESSED)));
3428 else if (((startIndex + i) == itemFocused))
3431 GuiDrawRectangle(itemBounds, GuiGetStyle(LISTVIEW, BORDER_WIDTH), GetColor(GuiGetStyle(LISTVIEW, BORDER_COLOR_FOCUSED)), GetColor(GuiGetStyle(LISTVIEW, BASE_COLOR_FOCUSED)));
3432 GuiDrawText(text[startIndex + i], GetTextBounds(DEFAULT, itemBounds), GuiGetStyle(LISTVIEW, TEXT_ALIGNMENT), GetColor(GuiGetStyle(LISTVIEW, TEXT_COLOR_FOCUSED)));
3437 GuiDrawText(text[startIndex + i], GetTextBounds(DEFAULT, itemBounds), GuiGetStyle(LISTVIEW, TEXT_ALIGNMENT), GetColor(GuiGetStyle(LISTVIEW, TEXT_COLOR_NORMAL)));
3442 itemBounds.y += (GuiGetStyle(LISTVIEW, LIST_ITEMS_HEIGHT) + GuiGetStyle(LISTVIEW, LIST_ITEMS_SPACING));
3448 bounds.x + bounds.width - GuiGetStyle(LISTVIEW, BORDER_WIDTH) - GuiGetStyle(LISTVIEW, SCROLLBAR_WIDTH),
3449 bounds.y + GuiGetStyle(LISTVIEW, BORDER_WIDTH), (float)GuiGetStyle(LISTVIEW, SCROLLBAR_WIDTH),
3450 bounds.height - 2*GuiGetStyle(DEFAULT, BORDER_WIDTH)
3454 float percentVisible = (float)(endIndex - startIndex)/count;
3455 float sliderSize = bounds.height*percentVisible;
3457 int prevSliderSize = GuiGetStyle(SCROLLBAR, SCROLL_SLIDER_SIZE);
3458 int prevScrollSpeed = GuiGetStyle(SCROLLBAR, SCROLL_SPEED);
3459 GuiSetStyle(SCROLLBAR, SCROLL_SLIDER_SIZE, (
int)sliderSize);
3460 GuiSetStyle(SCROLLBAR, SCROLL_SPEED, count - visibleItems);
3462 startIndex = GuiScrollBar(scrollBarBounds, startIndex, 0, count - visibleItems);
3464 GuiSetStyle(SCROLLBAR, SCROLL_SPEED, prevScrollSpeed);
3465 GuiSetStyle(SCROLLBAR, SCROLL_SLIDER_SIZE, prevSliderSize);
3469 if (active != NULL) *active = itemSelected;
3470 if (focus != NULL) *focus = itemFocused;
3471 if (scrollIndex != NULL) *scrollIndex = startIndex;
3477 int GuiColorPanel(
Rectangle bounds,
const char *text,
Color *color)
3481 Vector3 vcolor = { (float)color->r/255.0f, (
float)color->g/255.0f, (float)color->b/255.0f };
3482 Vector3 hsv = ConvertRGBtoHSV(vcolor);
3485 GuiColorPanelHSV(bounds, text, &hsv);
3492 if (hsv.x != prevHsv.x || hsv.y != prevHsv.y || hsv.z != prevHsv.z)
3494 Vector3 rgb = ConvertHSVtoRGB(hsv);
3497 *color = RAYGUI_CLITERAL(
Color){ (
unsigned char)(255.0f*rgb.x),
3498 (
unsigned char)(255.0f*rgb.y),
3499 (
unsigned char)(255.0f*rgb.z),
3507 int GuiColorBarAlpha(
Rectangle bounds,
const char *text,
float *alpha)
3509 #if !defined(RAYGUI_COLORBARALPHA_CHECKED_SIZE) 3510 #define RAYGUI_COLORBARALPHA_CHECKED_SIZE 10 3514 GuiState state = guiState;
3515 Rectangle selector = { (float)bounds.x + (*alpha)*bounds.width - GuiGetStyle(COLORPICKER, HUEBAR_SELECTOR_HEIGHT)/2, (float)bounds.y - GuiGetStyle(COLORPICKER, HUEBAR_SELECTOR_OVERFLOW), (float)GuiGetStyle(COLORPICKER, HUEBAR_SELECTOR_HEIGHT), (float)bounds.height + GuiGetStyle(COLORPICKER, HUEBAR_SELECTOR_OVERFLOW)*2 };
3519 if ((state != STATE_DISABLED) && !guiLocked)
3521 Vector2 mousePoint = GetMousePosition();
3523 if (guiControlExclusiveMode)
3525 if (IsMouseButtonDown(MOUSE_LEFT_BUTTON))
3527 if (CHECK_BOUNDS_ID(bounds, guiControlExclusiveRec))
3529 state = STATE_PRESSED;
3531 *alpha = (mousePoint.x - bounds.x)/bounds.width;
3532 if (*alpha <= 0.0f) *alpha = 0.0f;
3533 if (*alpha >= 1.0f) *alpha = 1.0f;
3538 guiControlExclusiveMode =
false;
3539 guiControlExclusiveRec = RAYGUI_CLITERAL(
Rectangle){ 0, 0, 0, 0 };
3542 else if (CheckCollisionPointRec(mousePoint, bounds) || CheckCollisionPointRec(mousePoint, selector))
3544 if (IsMouseButtonDown(MOUSE_LEFT_BUTTON))
3546 state = STATE_PRESSED;
3547 guiControlExclusiveMode =
true;
3548 guiControlExclusiveRec = bounds;
3550 *alpha = (mousePoint.x - bounds.x)/bounds.width;
3551 if (*alpha <= 0.0f) *alpha = 0.0f;
3552 if (*alpha >= 1.0f) *alpha = 1.0f;
3555 else state = STATE_FOCUSED;
3564 if (state != STATE_DISABLED)
3566 int checksX = (int)bounds.width/RAYGUI_COLORBARALPHA_CHECKED_SIZE;
3567 int checksY = (
int)bounds.height/RAYGUI_COLORBARALPHA_CHECKED_SIZE;
3569 for (
int x = 0; x < checksX; x++)
3571 for (
int y = 0; y < checksY; y++)
3573 Rectangle check = { bounds.x + x*RAYGUI_COLORBARALPHA_CHECKED_SIZE, bounds.y + y*RAYGUI_COLORBARALPHA_CHECKED_SIZE, RAYGUI_COLORBARALPHA_CHECKED_SIZE, RAYGUI_COLORBARALPHA_CHECKED_SIZE };
3574 GuiDrawRectangle(check, 0, BLANK, ((x + y)%2)? Fade(GetColor(GuiGetStyle(COLORPICKER, BORDER_COLOR_DISABLED)), 0.4f) : Fade(GetColor(GuiGetStyle(COLORPICKER, BASE_COLOR_DISABLED)), 0.4f));
3578 DrawRectangleGradientEx(bounds, RAYGUI_CLITERAL(
Color){ 255, 255, 255, 0 }, RAYGUI_CLITERAL(
Color){ 255, 255, 255, 0 }, Fade(RAYGUI_CLITERAL(
Color){ 0, 0, 0, 255 }, guiAlpha), Fade(RAYGUI_CLITERAL(
Color){ 0, 0, 0, 255 }, guiAlpha));
3580 else DrawRectangleGradientEx(bounds, Fade(GetColor(GuiGetStyle(COLORPICKER, BASE_COLOR_DISABLED)), 0.1f), Fade(GetColor(GuiGetStyle(COLORPICKER, BASE_COLOR_DISABLED)), 0.1f), Fade(GetColor(GuiGetStyle(COLORPICKER, BORDER_COLOR_DISABLED)), guiAlpha), Fade(GetColor(GuiGetStyle(COLORPICKER, BORDER_COLOR_DISABLED)), guiAlpha));
3582 GuiDrawRectangle(bounds, GuiGetStyle(COLORPICKER, BORDER_WIDTH), GetColor(GuiGetStyle(COLORPICKER, BORDER + state*3)), BLANK);
3585 GuiDrawRectangle(selector, 0, BLANK, GetColor(GuiGetStyle(COLORPICKER, BORDER + state*3)));
3597 int GuiColorBarHue(
Rectangle bounds,
const char *text,
float *hue)
3600 GuiState state = guiState;
3601 Rectangle selector = { (float)bounds.x - GuiGetStyle(COLORPICKER, HUEBAR_SELECTOR_OVERFLOW), (float)bounds.y + (*hue)/360.0f*bounds.height - GuiGetStyle(COLORPICKER, HUEBAR_SELECTOR_HEIGHT)/2, (float)bounds.width + GuiGetStyle(COLORPICKER, HUEBAR_SELECTOR_OVERFLOW)*2, (float)GuiGetStyle(COLORPICKER, HUEBAR_SELECTOR_HEIGHT) };
3605 if ((state != STATE_DISABLED) && !guiLocked)
3607 Vector2 mousePoint = GetMousePosition();
3609 if (guiControlExclusiveMode)
3611 if (IsMouseButtonDown(MOUSE_LEFT_BUTTON))
3613 if (CHECK_BOUNDS_ID(bounds, guiControlExclusiveRec))
3615 state = STATE_PRESSED;
3617 *hue = (mousePoint.y - bounds.y)*360/bounds.height;
3618 if (*hue <= 0.0f) *hue = 0.0f;
3619 if (*hue >= 359.0f) *hue = 359.0f;
3624 guiControlExclusiveMode =
false;
3625 guiControlExclusiveRec = RAYGUI_CLITERAL(
Rectangle){ 0, 0, 0, 0 };
3628 else if (CheckCollisionPointRec(mousePoint, bounds) || CheckCollisionPointRec(mousePoint, selector))
3630 if (IsMouseButtonDown(MOUSE_LEFT_BUTTON))
3632 state = STATE_PRESSED;
3633 guiControlExclusiveMode =
true;
3634 guiControlExclusiveRec = bounds;
3636 *hue = (mousePoint.y - bounds.y)*360/bounds.height;
3637 if (*hue <= 0.0f) *hue = 0.0f;
3638 if (*hue >= 359.0f) *hue = 359.0f;
3641 else state = STATE_FOCUSED;
3659 if (state != STATE_DISABLED)
3663 DrawRectangleGradientV((
int)bounds.x, (
int)(bounds.y), (
int)bounds.width, (
int)ceilf(bounds.height/6), Fade(RAYGUI_CLITERAL(
Color){ 255, 0, 0, 255 }, guiAlpha), Fade(RAYGUI_CLITERAL(
Color){ 255, 255, 0, 255 }, guiAlpha));
3664 DrawRectangleGradientV((
int)bounds.x, (
int)(bounds.y + bounds.height/6), (
int)bounds.width, (
int)ceilf(bounds.height/6), Fade(RAYGUI_CLITERAL(
Color){ 255, 255, 0, 255 }, guiAlpha), Fade(RAYGUI_CLITERAL(
Color){ 0, 255, 0, 255 }, guiAlpha));
3665 DrawRectangleGradientV((
int)bounds.x, (
int)(bounds.y + 2*(bounds.height/6)), (
int)bounds.width, (
int)ceilf(bounds.height/6), Fade(RAYGUI_CLITERAL(
Color){ 0, 255, 0, 255 }, guiAlpha), Fade(RAYGUI_CLITERAL(
Color){ 0, 255, 255, 255 }, guiAlpha));
3666 DrawRectangleGradientV((
int)bounds.x, (
int)(bounds.y + 3*(bounds.height/6)), (
int)bounds.width, (
int)ceilf(bounds.height/6), Fade(RAYGUI_CLITERAL(
Color){ 0, 255, 255, 255 }, guiAlpha), Fade(RAYGUI_CLITERAL(
Color){ 0, 0, 255, 255 }, guiAlpha));
3667 DrawRectangleGradientV((
int)bounds.x, (
int)(bounds.y + 4*(bounds.height/6)), (
int)bounds.width, (
int)ceilf(bounds.height/6), Fade(RAYGUI_CLITERAL(
Color){ 0, 0, 255, 255 }, guiAlpha), Fade(RAYGUI_CLITERAL(
Color){ 255, 0, 255, 255 }, guiAlpha));
3668 DrawRectangleGradientV((
int)bounds.x, (
int)(bounds.y + 5*(bounds.height/6)), (
int)bounds.width, (
int)(bounds.height/6), Fade(RAYGUI_CLITERAL(
Color){ 255, 0, 255, 255 }, guiAlpha), Fade(RAYGUI_CLITERAL(
Color){ 255, 0, 0, 255 }, guiAlpha));
3670 else DrawRectangleGradientV((
int)bounds.x, (
int)bounds.y, (
int)bounds.width, (
int)bounds.height, Fade(Fade(GetColor(GuiGetStyle(COLORPICKER, BASE_COLOR_DISABLED)), 0.1f), guiAlpha), Fade(GetColor(GuiGetStyle(COLORPICKER, BORDER_COLOR_DISABLED)), guiAlpha));
3672 GuiDrawRectangle(bounds, GuiGetStyle(COLORPICKER, BORDER_WIDTH), GetColor(GuiGetStyle(COLORPICKER, BORDER + state*3)), BLANK);
3675 GuiDrawRectangle(selector, 0, BLANK, GetColor(GuiGetStyle(COLORPICKER, BORDER + state*3)));
3688 int GuiColorPicker(
Rectangle bounds,
const char *text,
Color *color)
3692 Color temp = { 200, 0, 0, 255 };
3693 if (color == NULL) color = &temp;
3695 GuiColorPanel(bounds, NULL, color);
3697 Rectangle boundsHue = { (float)bounds.x + bounds.width + GuiGetStyle(COLORPICKER, HUEBAR_PADDING), (float)bounds.y, (
float)GuiGetStyle(COLORPICKER, HUEBAR_WIDTH), (float)bounds.height };
3701 Vector3 hsv = ConvertRGBtoHSV(RAYGUI_CLITERAL(
Vector3){ (*color).r/255.0f, (*color).g/255.0f, (*color).b/255.0f });
3703 GuiColorBarHue(boundsHue, NULL, &hsv.x);
3706 Vector3 rgb = ConvertHSVtoRGB(hsv);
3708 *color = RAYGUI_CLITERAL(
Color){ (
unsigned char)roundf(rgb.x*255.0f), (
unsigned char)roundf(rgb.y*255.0f), (
unsigned char)roundf(rgb.z*255.0f), (*color).a };
3720 int GuiColorPickerHSV(
Rectangle bounds,
const char *text,
Vector3 *colorHsv)
3726 if (colorHsv == NULL)
3728 const Vector3 tempColor = { 200.0f/255.0f, 0.0f, 0.0f };
3729 tempHsv = ConvertRGBtoHSV(tempColor);
3730 colorHsv = &tempHsv;
3733 GuiColorPanelHSV(bounds, NULL, colorHsv);
3735 const Rectangle boundsHue = { (float)bounds.x + bounds.width + GuiGetStyle(COLORPICKER, HUEBAR_PADDING), (float)bounds.y, (
float)GuiGetStyle(COLORPICKER, HUEBAR_WIDTH), (float)bounds.height };
3737 GuiColorBarHue(boundsHue, NULL, &colorHsv->x);
3743 int GuiColorPanelHSV(
Rectangle bounds,
const char *text,
Vector3 *colorHsv)
3746 GuiState state = guiState;
3747 Vector2 pickerSelector = { 0 };
3749 const Color colWhite = { 255, 255, 255, 255 };
3750 const Color colBlack = { 0, 0, 0, 255 };
3752 pickerSelector.x = bounds.x + (float)colorHsv->y*bounds.width;
3753 pickerSelector.y = bounds.y + (1.0f - (
float)colorHsv->z)*bounds.height;
3755 Vector3 maxHue = { colorHsv->x, 1.0f, 1.0f };
3756 Vector3 rgbHue = ConvertHSVtoRGB(maxHue);
3757 Color maxHueCol = { (
unsigned char)(255.0f*rgbHue.x),
3758 (
unsigned char)(255.0f*rgbHue.y),
3759 (
unsigned char)(255.0f*rgbHue.z), 255 };
3763 if ((state != STATE_DISABLED) && !guiLocked)
3765 Vector2 mousePoint = GetMousePosition();
3767 if (guiControlExclusiveMode)
3769 if (IsMouseButtonDown(MOUSE_LEFT_BUTTON))
3771 if (CHECK_BOUNDS_ID(bounds, guiControlExclusiveRec))
3773 pickerSelector = mousePoint;
3775 if (pickerSelector.x < bounds.x) pickerSelector.x = bounds.x;
3776 if (pickerSelector.x > bounds.x + bounds.width) pickerSelector.x = bounds.x + bounds.width;
3777 if (pickerSelector.y < bounds.y) pickerSelector.y = bounds.y;
3778 if (pickerSelector.y > bounds.y + bounds.height) pickerSelector.y = bounds.y + bounds.height;
3781 Vector2 colorPick = { pickerSelector.x - bounds.x, pickerSelector.y - bounds.y };
3783 colorPick.x /= (float)bounds.width;
3784 colorPick.y /= (
float)bounds.height;
3786 colorHsv->y = colorPick.x;
3787 colorHsv->z = 1.0f - colorPick.y;
3793 guiControlExclusiveMode =
false;
3794 guiControlExclusiveRec = RAYGUI_CLITERAL(
Rectangle){ 0, 0, 0, 0 };
3797 else if (CheckCollisionPointRec(mousePoint, bounds))
3799 if (IsMouseButtonDown(MOUSE_LEFT_BUTTON))
3801 state = STATE_PRESSED;
3802 guiControlExclusiveMode =
true;
3803 guiControlExclusiveRec = bounds;
3804 pickerSelector = mousePoint;
3807 Vector2 colorPick = { pickerSelector.x - bounds.x, pickerSelector.y - bounds.y };
3809 colorPick.x /= (float)bounds.width;
3810 colorPick.y /= (
float)bounds.height;
3812 colorHsv->y = colorPick.x;
3813 colorHsv->z = 1.0f - colorPick.y;
3815 else state = STATE_FOCUSED;
3822 if (state != STATE_DISABLED)
3824 DrawRectangleGradientEx(bounds, Fade(colWhite, guiAlpha), Fade(colWhite, guiAlpha), Fade(maxHueCol, guiAlpha), Fade(maxHueCol, guiAlpha));
3825 DrawRectangleGradientEx(bounds, Fade(colBlack, 0), Fade(colBlack, guiAlpha), Fade(colBlack, guiAlpha), Fade(colBlack, 0));
3828 Rectangle selector = { pickerSelector.x - GuiGetStyle(COLORPICKER, COLOR_SELECTOR_SIZE)/2, pickerSelector.y - GuiGetStyle(COLORPICKER, COLOR_SELECTOR_SIZE)/2, (float)GuiGetStyle(COLORPICKER, COLOR_SELECTOR_SIZE), (float)GuiGetStyle(COLORPICKER, COLOR_SELECTOR_SIZE) };
3829 GuiDrawRectangle(selector, 0, BLANK, colWhite);
3833 DrawRectangleGradientEx(bounds, Fade(Fade(GetColor(GuiGetStyle(COLORPICKER, BASE_COLOR_DISABLED)), 0.1f), guiAlpha), Fade(Fade(colBlack, 0.6f), guiAlpha), Fade(Fade(colBlack, 0.6f), guiAlpha), Fade(Fade(GetColor(GuiGetStyle(COLORPICKER, BORDER_COLOR_DISABLED)), 0.6f), guiAlpha));
3836 GuiDrawRectangle(bounds, GuiGetStyle(COLORPICKER, BORDER_WIDTH), GetColor(GuiGetStyle(COLORPICKER, BORDER + state*3)), BLANK);
3843 int GuiMessageBox(
Rectangle bounds,
const char *title,
const char *message,
const char *buttons)
3845 #if !defined(RAYGUI_MESSAGEBOX_BUTTON_HEIGHT) 3846 #define RAYGUI_MESSAGEBOX_BUTTON_HEIGHT 24 3848 #if !defined(RAYGUI_MESSAGEBOX_BUTTON_PADDING) 3849 #define RAYGUI_MESSAGEBOX_BUTTON_PADDING 12 3854 int buttonCount = 0;
3855 const char **buttonsText = GuiTextSplit(buttons,
';', &buttonCount, NULL);
3857 buttonBounds.x = bounds.x + RAYGUI_MESSAGEBOX_BUTTON_PADDING;
3858 buttonBounds.y = bounds.y + bounds.height - RAYGUI_MESSAGEBOX_BUTTON_HEIGHT - RAYGUI_MESSAGEBOX_BUTTON_PADDING;
3859 buttonBounds.width = (bounds.width - RAYGUI_MESSAGEBOX_BUTTON_PADDING*(buttonCount + 1))/buttonCount;
3860 buttonBounds.height = RAYGUI_MESSAGEBOX_BUTTON_HEIGHT;
3862 int textWidth = GetTextWidth(message) + 2;
3865 textBounds.x = bounds.x + RAYGUI_MESSAGEBOX_BUTTON_PADDING;
3866 textBounds.y = bounds.y + RAYGUI_WINDOWBOX_STATUSBAR_HEIGHT + RAYGUI_MESSAGEBOX_BUTTON_PADDING;
3867 textBounds.width = bounds.width - RAYGUI_MESSAGEBOX_BUTTON_PADDING*2;
3868 textBounds.height = bounds.height - RAYGUI_WINDOWBOX_STATUSBAR_HEIGHT - 3*RAYGUI_MESSAGEBOX_BUTTON_PADDING - RAYGUI_MESSAGEBOX_BUTTON_HEIGHT;
3872 if (GuiWindowBox(bounds, title)) result = 0;
3874 int prevTextAlignment = GuiGetStyle(LABEL, TEXT_ALIGNMENT);
3875 GuiSetStyle(LABEL, TEXT_ALIGNMENT, TEXT_ALIGN_CENTER);
3876 GuiLabel(textBounds, message);
3877 GuiSetStyle(LABEL, TEXT_ALIGNMENT, prevTextAlignment);
3879 prevTextAlignment = GuiGetStyle(BUTTON, TEXT_ALIGNMENT);
3880 GuiSetStyle(BUTTON, TEXT_ALIGNMENT, TEXT_ALIGN_CENTER);
3882 for (
int i = 0; i < buttonCount; i++)
3884 if (GuiButton(buttonBounds, buttonsText[i])) result = i + 1;
3885 buttonBounds.x += (buttonBounds.width + RAYGUI_MESSAGEBOX_BUTTON_PADDING);
3888 GuiSetStyle(BUTTON, TEXT_ALIGNMENT, prevTextAlignment);
3895 int GuiTextInputBox(
Rectangle bounds,
const char *title,
const char *message,
const char *buttons,
char *text,
int textMaxSize,
bool *secretViewActive)
3897 #if !defined(RAYGUI_TEXTINPUTBOX_BUTTON_HEIGHT) 3898 #define RAYGUI_TEXTINPUTBOX_BUTTON_HEIGHT 24 3900 #if !defined(RAYGUI_TEXTINPUTBOX_BUTTON_PADDING) 3901 #define RAYGUI_TEXTINPUTBOX_BUTTON_PADDING 12 3903 #if !defined(RAYGUI_TEXTINPUTBOX_HEIGHT) 3904 #define RAYGUI_TEXTINPUTBOX_HEIGHT 26 3909 static bool textEditMode =
false;
3913 int buttonCount = 0;
3914 const char **buttonsText = GuiTextSplit(buttons,
';', &buttonCount, NULL);
3916 buttonBounds.x = bounds.x + RAYGUI_TEXTINPUTBOX_BUTTON_PADDING;
3917 buttonBounds.y = bounds.y + bounds.height - RAYGUI_TEXTINPUTBOX_BUTTON_HEIGHT - RAYGUI_TEXTINPUTBOX_BUTTON_PADDING;
3918 buttonBounds.width = (bounds.width - RAYGUI_TEXTINPUTBOX_BUTTON_PADDING*(buttonCount + 1))/buttonCount;
3919 buttonBounds.height = RAYGUI_TEXTINPUTBOX_BUTTON_HEIGHT;
3921 int messageInputHeight = (int)bounds.height - RAYGUI_WINDOWBOX_STATUSBAR_HEIGHT - GuiGetStyle(STATUSBAR, BORDER_WIDTH) - RAYGUI_TEXTINPUTBOX_BUTTON_HEIGHT - 2*RAYGUI_TEXTINPUTBOX_BUTTON_PADDING;
3924 if (message != NULL)
3926 int textSize = GetTextWidth(message) + 2;
3928 textBounds.x = bounds.x + bounds.width/2 - textSize/2;
3929 textBounds.y = bounds.y + RAYGUI_WINDOWBOX_STATUSBAR_HEIGHT + messageInputHeight/4 - (float)GuiGetStyle(DEFAULT, TEXT_SIZE)/2;
3930 textBounds.width = (float)textSize;
3931 textBounds.height = (float)GuiGetStyle(DEFAULT, TEXT_SIZE);
3935 textBoxBounds.x = bounds.x + RAYGUI_TEXTINPUTBOX_BUTTON_PADDING;
3936 textBoxBounds.y = bounds.y + RAYGUI_WINDOWBOX_STATUSBAR_HEIGHT - RAYGUI_TEXTINPUTBOX_HEIGHT/2;
3937 if (message == NULL) textBoxBounds.y = bounds.y + 24 + RAYGUI_TEXTINPUTBOX_BUTTON_PADDING;
3938 else textBoxBounds.y += (messageInputHeight/2 + messageInputHeight/4);
3939 textBoxBounds.width = bounds.width - RAYGUI_TEXTINPUTBOX_BUTTON_PADDING*2;
3940 textBoxBounds.height = RAYGUI_TEXTINPUTBOX_HEIGHT;
3944 if (GuiWindowBox(bounds, title)) result = 0;
3947 if (message != NULL)
3949 int prevTextAlignment = GuiGetStyle(LABEL, TEXT_ALIGNMENT);
3950 GuiSetStyle(LABEL, TEXT_ALIGNMENT, TEXT_ALIGN_CENTER);
3951 GuiLabel(textBounds, message);
3952 GuiSetStyle(LABEL, TEXT_ALIGNMENT, prevTextAlignment);
3955 if (secretViewActive != NULL)
3957 static char stars[] =
"****************";
3958 if (GuiTextBox(RAYGUI_CLITERAL(
Rectangle){ textBoxBounds.x, textBoxBounds.y, textBoxBounds.width - 4 - RAYGUI_TEXTINPUTBOX_HEIGHT, textBoxBounds.height },
3959 ((*secretViewActive == 1) || textEditMode)? text : stars, textMaxSize, textEditMode)) textEditMode = !textEditMode;
3961 GuiToggle(RAYGUI_CLITERAL(
Rectangle){ textBoxBounds.x + textBoxBounds.width - RAYGUI_TEXTINPUTBOX_HEIGHT, textBoxBounds.y, RAYGUI_TEXTINPUTBOX_HEIGHT, RAYGUI_TEXTINPUTBOX_HEIGHT }, (*secretViewActive == 1)?
"#44#" :
"#45#", secretViewActive);
3965 if (GuiTextBox(textBoxBounds, text, textMaxSize, textEditMode)) textEditMode = !textEditMode;
3968 int prevBtnTextAlignment = GuiGetStyle(BUTTON, TEXT_ALIGNMENT);
3969 GuiSetStyle(BUTTON, TEXT_ALIGNMENT, TEXT_ALIGN_CENTER);
3971 for (
int i = 0; i < buttonCount; i++)
3973 if (GuiButton(buttonBounds, buttonsText[i])) result = i + 1;
3974 buttonBounds.x += (buttonBounds.width + RAYGUI_MESSAGEBOX_BUTTON_PADDING);
3977 if (result >= 0) textEditMode =
false;
3979 GuiSetStyle(BUTTON, TEXT_ALIGNMENT, prevBtnTextAlignment);
3989 int GuiGrid(
Rectangle bounds,
const char *text,
float spacing,
int subdivs,
Vector2 *mouseCell)
3992 #if !defined(RAYGUI_GRID_ALPHA) 3993 #define RAYGUI_GRID_ALPHA 0.15f 3997 GuiState state = guiState;
3999 Vector2 mousePoint = GetMousePosition();
4000 Vector2 currentMouseCell = { -1, -1 };
4002 float spaceWidth = spacing/(float)subdivs;
4003 int linesV = (int)(bounds.width/spaceWidth) + 1;
4004 int linesH = (int)(bounds.height/spaceWidth) + 1;
4006 int color = GuiGetStyle(DEFAULT, LINE_COLOR);
4010 if ((state != STATE_DISABLED) && !guiLocked && !guiControlExclusiveMode)
4012 if (CheckCollisionPointRec(mousePoint, bounds))
4015 currentMouseCell.x = floorf((mousePoint.x - bounds.x)/spacing);
4016 currentMouseCell.y = floorf((mousePoint.y - bounds.y)/spacing);
4023 if (state == STATE_DISABLED) color = GuiGetStyle(DEFAULT, BORDER_COLOR_DISABLED);
4028 for (
int i = 0; i < linesV; i++)
4030 Rectangle lineV = { bounds.x + spacing*i/subdivs, bounds.y, 1, bounds.height + 1 };
4031 GuiDrawRectangle(lineV, 0, BLANK, ((i%subdivs) == 0)? GuiFade(GetColor(color), RAYGUI_GRID_ALPHA*4) : GuiFade(GetColor(color), RAYGUI_GRID_ALPHA));
4035 for (
int i = 0; i < linesH; i++)
4037 Rectangle lineH = { bounds.x, bounds.y + spacing*i/subdivs, bounds.width + 1, 1 };
4038 GuiDrawRectangle(lineH, 0, BLANK, ((i%subdivs) == 0)? GuiFade(GetColor(color), RAYGUI_GRID_ALPHA*4) : GuiFade(GetColor(color), RAYGUI_GRID_ALPHA));
4042 if (mouseCell != NULL) *mouseCell = currentMouseCell;
4051 void GuiEnableTooltip(
void) { guiTooltip =
true; }
4054 void GuiDisableTooltip(
void) { guiTooltip =
false; }
4057 void GuiSetTooltip(
const char *tooltip) { guiTooltipPtr = tooltip; }
4066 void GuiLoadStyle(
const char *fileName)
4068 #define MAX_LINE_BUFFER_SIZE 256 4070 bool tryBinary =
false;
4071 if (!guiStyleLoaded) GuiLoadStyleDefault();
4074 FILE *rgsFile = fopen(fileName,
"rt");
4076 if (rgsFile != NULL)
4078 char buffer[MAX_LINE_BUFFER_SIZE] = { 0 };
4079 fgets(buffer, MAX_LINE_BUFFER_SIZE, rgsFile);
4081 if (buffer[0] ==
'#')
4085 unsigned int propertyValue = 0;
4087 while (!feof(rgsFile))
4095 sscanf(buffer,
"p %d %d 0x%x", &controlId, &propertyId, &propertyValue);
4096 GuiSetStyle(controlId, propertyId, (
int)propertyValue);
4104 char charmapFileName[256] = { 0 };
4105 char fontFileName[256] = { 0 };
4106 sscanf(buffer,
"f %d %s %[^\r\n]s", &fontSize, charmapFileName, fontFileName);
4109 int *codepoints = NULL;
4110 int codepointCount = 0;
4112 if (charmapFileName[0] !=
'0')
4116 char *textData = LoadFileText(TextFormat(
"%s/%s", GetDirectoryPath(fileName), charmapFileName));
4117 codepoints = LoadCodepoints(textData, &codepointCount);
4118 UnloadFileText(textData);
4121 if (fontFileName[0] !=
'\0')
4124 if (font.texture.id != GetFontDefault().texture.id) UnloadTexture(font.texture);
4126 if (codepointCount > 0) font = LoadFontEx(TextFormat(
"%s/%s", GetDirectoryPath(fileName), fontFileName), fontSize, codepoints, codepointCount);
4127 else font = LoadFontEx(TextFormat(
"%s/%s", GetDirectoryPath(fileName), fontFileName), fontSize, NULL, 0);
4131 if (font.texture.id == 0)
4133 font = GetFontDefault();
4134 GuiSetStyle(DEFAULT, TEXT_SIZE, 10);
4135 GuiSetStyle(DEFAULT, TEXT_SPACING, 1);
4138 UnloadCodepoints(codepoints);
4140 if ((font.texture.id > 0) && (font.glyphCount > 0)) GuiSetFont(font);
4146 fgets(buffer, MAX_LINE_BUFFER_SIZE, rgsFile);
4149 else tryBinary =
true;
4156 rgsFile = fopen(fileName,
"rb");
4158 if (rgsFile != NULL)
4160 fseek(rgsFile, 0, SEEK_END);
4161 int fileDataSize = ftell(rgsFile);
4162 fseek(rgsFile, 0, SEEK_SET);
4164 if (fileDataSize > 0)
4166 unsigned char *fileData = (
unsigned char *)RAYGUI_MALLOC(fileDataSize*
sizeof(
unsigned char));
4167 fread(fileData,
sizeof(
unsigned char), fileDataSize, rgsFile);
4169 GuiLoadStyleFromMemory(fileData, fileDataSize);
4171 RAYGUI_FREE(fileData);
4180 void GuiLoadStyleDefault(
void)
4184 guiStyleLoaded =
true;
4189 GuiSetStyle(DEFAULT, BORDER_COLOR_NORMAL, 0x838383ff);
4190 GuiSetStyle(DEFAULT, BASE_COLOR_NORMAL, 0xc9c9c9ff);
4191 GuiSetStyle(DEFAULT, TEXT_COLOR_NORMAL, 0x686868ff);
4192 GuiSetStyle(DEFAULT, BORDER_COLOR_FOCUSED, 0x5bb2d9ff);
4193 GuiSetStyle(DEFAULT, BASE_COLOR_FOCUSED, 0xc9effeff);
4194 GuiSetStyle(DEFAULT, TEXT_COLOR_FOCUSED, 0x6c9bbcff);
4195 GuiSetStyle(DEFAULT, BORDER_COLOR_PRESSED, 0x0492c7ff);
4196 GuiSetStyle(DEFAULT, BASE_COLOR_PRESSED, 0x97e8ffff);
4197 GuiSetStyle(DEFAULT, TEXT_COLOR_PRESSED, 0x368bafff);
4198 GuiSetStyle(DEFAULT, BORDER_COLOR_DISABLED, 0xb5c1c2ff);
4199 GuiSetStyle(DEFAULT, BASE_COLOR_DISABLED, 0xe6e9e9ff);
4200 GuiSetStyle(DEFAULT, TEXT_COLOR_DISABLED, 0xaeb7b8ff);
4201 GuiSetStyle(DEFAULT, BORDER_WIDTH, 1);
4202 GuiSetStyle(DEFAULT, TEXT_PADDING, 0);
4203 GuiSetStyle(DEFAULT, TEXT_ALIGNMENT, TEXT_ALIGN_CENTER);
4207 GuiSetStyle(DEFAULT, TEXT_SIZE, 10);
4208 GuiSetStyle(DEFAULT, TEXT_SPACING, 1);
4209 GuiSetStyle(DEFAULT, LINE_COLOR, 0x90abb5ff);
4210 GuiSetStyle(DEFAULT, BACKGROUND_COLOR, 0xf5f5f5ff);
4211 GuiSetStyle(DEFAULT, TEXT_LINE_SPACING, 15);
4212 GuiSetStyle(DEFAULT, TEXT_ALIGNMENT_VERTICAL, TEXT_ALIGN_MIDDLE);
4216 GuiSetStyle(LABEL, TEXT_ALIGNMENT, TEXT_ALIGN_LEFT);
4217 GuiSetStyle(BUTTON, BORDER_WIDTH, 2);
4218 GuiSetStyle(SLIDER, TEXT_PADDING, 4);
4219 GuiSetStyle(PROGRESSBAR, TEXT_PADDING, 4);
4220 GuiSetStyle(CHECKBOX, TEXT_PADDING, 4);
4221 GuiSetStyle(CHECKBOX, TEXT_ALIGNMENT, TEXT_ALIGN_RIGHT);
4222 GuiSetStyle(DROPDOWNBOX, TEXT_PADDING, 0);
4223 GuiSetStyle(DROPDOWNBOX, TEXT_ALIGNMENT, TEXT_ALIGN_CENTER);
4224 GuiSetStyle(TEXTBOX, TEXT_PADDING, 4);
4225 GuiSetStyle(TEXTBOX, TEXT_ALIGNMENT, TEXT_ALIGN_LEFT);
4226 GuiSetStyle(VALUEBOX, TEXT_PADDING, 0);
4227 GuiSetStyle(VALUEBOX, TEXT_ALIGNMENT, TEXT_ALIGN_LEFT);
4228 GuiSetStyle(SPINNER, TEXT_PADDING, 0);
4229 GuiSetStyle(SPINNER, TEXT_ALIGNMENT, TEXT_ALIGN_LEFT);
4230 GuiSetStyle(STATUSBAR, TEXT_PADDING, 8);
4231 GuiSetStyle(STATUSBAR, TEXT_ALIGNMENT, TEXT_ALIGN_LEFT);
4235 GuiSetStyle(TOGGLE, GROUP_PADDING, 2);
4236 GuiSetStyle(SLIDER, SLIDER_WIDTH, 16);
4237 GuiSetStyle(SLIDER, SLIDER_PADDING, 1);
4238 GuiSetStyle(PROGRESSBAR, PROGRESS_PADDING, 1);
4239 GuiSetStyle(CHECKBOX, CHECK_PADDING, 1);
4240 GuiSetStyle(COMBOBOX, COMBO_BUTTON_WIDTH, 32);
4241 GuiSetStyle(COMBOBOX, COMBO_BUTTON_SPACING, 2);
4242 GuiSetStyle(DROPDOWNBOX, ARROW_PADDING, 16);
4243 GuiSetStyle(DROPDOWNBOX, DROPDOWN_ITEMS_SPACING, 2);
4244 GuiSetStyle(SPINNER, SPIN_BUTTON_WIDTH, 24);
4245 GuiSetStyle(SPINNER, SPIN_BUTTON_SPACING, 2);
4246 GuiSetStyle(SCROLLBAR, BORDER_WIDTH, 0);
4247 GuiSetStyle(SCROLLBAR, ARROWS_VISIBLE, 0);
4248 GuiSetStyle(SCROLLBAR, ARROWS_SIZE, 6);
4249 GuiSetStyle(SCROLLBAR, SCROLL_SLIDER_PADDING, 0);
4250 GuiSetStyle(SCROLLBAR, SCROLL_SLIDER_SIZE, 16);
4251 GuiSetStyle(SCROLLBAR, SCROLL_PADDING, 0);
4252 GuiSetStyle(SCROLLBAR, SCROLL_SPEED, 12);
4253 GuiSetStyle(LISTVIEW, LIST_ITEMS_HEIGHT, 28);
4254 GuiSetStyle(LISTVIEW, LIST_ITEMS_SPACING, 2);
4255 GuiSetStyle(LISTVIEW, SCROLLBAR_WIDTH, 12);
4256 GuiSetStyle(LISTVIEW, SCROLLBAR_SIDE, SCROLLBAR_RIGHT_SIDE);
4257 GuiSetStyle(COLORPICKER, COLOR_SELECTOR_SIZE, 8);
4258 GuiSetStyle(COLORPICKER, HUEBAR_WIDTH, 16);
4259 GuiSetStyle(COLORPICKER, HUEBAR_PADDING, 8);
4260 GuiSetStyle(COLORPICKER, HUEBAR_SELECTOR_HEIGHT, 8);
4261 GuiSetStyle(COLORPICKER, HUEBAR_SELECTOR_OVERFLOW, 2);
4263 if (guiFont.texture.id != GetFontDefault().texture.id)
4266 UnloadTexture(guiFont.texture);
4267 RL_FREE(guiFont.recs);
4268 RL_FREE(guiFont.glyphs);
4269 guiFont.recs = NULL;
4270 guiFont.glyphs = NULL;
4273 guiFont = GetFontDefault();
4279 SetShapesTexture(guiFont.texture, RAYGUI_CLITERAL(
Rectangle){ whiteChar.x + 1, whiteChar.y + 1, whiteChar.width - 2, whiteChar.height - 2 });
4286 const char *GuiIconText(
int iconId,
const char *text)
4288 #if defined(RAYGUI_NO_ICONS) 4291 static char buffer[1024] = { 0 };
4292 static char iconBuffer[16] = { 0 };
4296 memset(buffer, 0, 1024);
4297 sprintf(buffer,
"#%03i#", iconId);
4299 for (
int i = 5; i < 1024; i++)
4301 buffer[i] = text[i - 5];
4302 if (text[i - 5] ==
'\0')
break;
4309 sprintf(iconBuffer,
"#%03i#", iconId);
4316 #if !defined(RAYGUI_NO_ICONS) 4318 unsigned int *GuiGetIcons(
void) {
return guiIconsPtr; }
4324 char **GuiLoadIcons(
const char *fileName,
bool loadIconsName)
4350 FILE *rgiFile = fopen(fileName,
"rb");
4352 char **guiIconsName = NULL;
4354 if (rgiFile != NULL)
4356 char signature[5] = { 0 };
4359 short iconCount = 0;
4362 fread(signature, 1, 4, rgiFile);
4363 fread(&version,
sizeof(
short), 1, rgiFile);
4364 fread(&reserved,
sizeof(
short), 1, rgiFile);
4365 fread(&iconCount,
sizeof(
short), 1, rgiFile);
4366 fread(&iconSize,
sizeof(
short), 1, rgiFile);
4368 if ((signature[0] ==
'r') &&
4369 (signature[1] ==
'G') &&
4370 (signature[2] ==
'I') &&
4371 (signature[3] ==
' '))
4375 guiIconsName = (
char **)RAYGUI_MALLOC(iconCount*
sizeof(
char **));
4376 for (
int i = 0; i < iconCount; i++)
4378 guiIconsName[i] = (
char *)RAYGUI_MALLOC(RAYGUI_ICON_MAX_NAME_LENGTH);
4379 fread(guiIconsName[i], 1, RAYGUI_ICON_MAX_NAME_LENGTH, rgiFile);
4382 else fseek(rgiFile, iconCount*RAYGUI_ICON_MAX_NAME_LENGTH, SEEK_CUR);
4385 fread(guiIconsPtr,
sizeof(
unsigned int), iconCount*(iconSize*iconSize/32), rgiFile);
4391 return guiIconsName;
4395 void GuiDrawIcon(
int iconId,
int posX,
int posY,
int pixelSize,
Color color)
4397 #define BIT_CHECK(a,b) ((a) & (1u<<(b))) 4399 for (
int i = 0, y = 0; i < RAYGUI_ICON_SIZE*RAYGUI_ICON_SIZE/32; i++)
4401 for (
int k = 0; k < 32; k++)
4403 if (BIT_CHECK(guiIconsPtr[iconId*RAYGUI_ICON_DATA_ELEMENTS + i], k))
4405 #if !defined(RAYGUI_STANDALONE) 4406 GuiDrawRectangle(RAYGUI_CLITERAL(
Rectangle){ (float)posX + (k%RAYGUI_ICON_SIZE)*pixelSize, (float)posY + y*pixelSize, (
float)pixelSize, (float)pixelSize }, 0, BLANK, color);
4410 if ((k == 15) || (k == 31)) y++;
4416 void GuiSetIconScale(
int scale)
4418 if (scale >= 1) guiIconScale = scale;
4421 #endif // !RAYGUI_NO_ICONS 4429 static void GuiLoadStyleFromMemory(
const unsigned char *fileData,
int dataSize)
4431 unsigned char *fileDataPtr = (
unsigned char *)fileData;
4433 char signature[5] = { 0 };
4436 int propertyCount = 0;
4438 memcpy(signature, fileDataPtr, 4);
4439 memcpy(&version, fileDataPtr + 4,
sizeof(
short));
4440 memcpy(&reserved, fileDataPtr + 4 + 2,
sizeof(
short));
4441 memcpy(&propertyCount, fileDataPtr + 4 + 2 + 2,
sizeof(
int));
4444 if ((signature[0] ==
'r') &&
4445 (signature[1] ==
'G') &&
4446 (signature[2] ==
'S') &&
4447 (signature[3] ==
' '))
4449 short controlId = 0;
4450 short propertyId = 0;
4451 unsigned int propertyValue = 0;
4453 for (
int i = 0; i < propertyCount; i++)
4455 memcpy(&controlId, fileDataPtr,
sizeof(
short));
4456 memcpy(&propertyId, fileDataPtr + 2,
sizeof(
short));
4457 memcpy(&propertyValue, fileDataPtr + 2 + 2,
sizeof(
unsigned int));
4464 GuiSetStyle(0, (
int)propertyId, propertyValue);
4466 if (propertyId < RAYGUI_MAX_PROPS_BASE)
for (
int i = 1; i < RAYGUI_MAX_CONTROLS; i++) GuiSetStyle(i, (
int)propertyId, propertyValue);
4468 else GuiSetStyle((
int)controlId, (
int)propertyId, propertyValue);
4473 #if !defined(RAYGUI_STANDALONE) 4475 int fontDataSize = 0;
4476 memcpy(&fontDataSize, fileDataPtr,
sizeof(
int));
4479 if (fontDataSize > 0)
4484 memcpy(&font.baseSize, fileDataPtr,
sizeof(
int));
4485 memcpy(&font.glyphCount, fileDataPtr + 4,
sizeof(
int));
4486 memcpy(&fontType, fileDataPtr + 4 + 4,
sizeof(
int));
4491 memcpy(&fontWhiteRec, fileDataPtr,
sizeof(
Rectangle));
4495 int fontImageUncompSize = 0;
4496 int fontImageCompSize = 0;
4497 memcpy(&fontImageUncompSize, fileDataPtr,
sizeof(
int));
4498 memcpy(&fontImageCompSize, fileDataPtr + 4,
sizeof(
int));
4501 Image imFont = { 0 };
4503 memcpy(&imFont.width, fileDataPtr,
sizeof(
int));
4504 memcpy(&imFont.height, fileDataPtr + 4,
sizeof(
int));
4505 memcpy(&imFont.format, fileDataPtr + 4 + 4,
sizeof(
int));
4508 if ((fontImageCompSize > 0) && (fontImageCompSize != fontImageUncompSize))
4511 int dataUncompSize = 0;
4512 unsigned char *compData = (
unsigned char *)RAYGUI_MALLOC(fontImageCompSize);
4513 memcpy(compData, fileDataPtr, fontImageCompSize);
4514 fileDataPtr += fontImageCompSize;
4516 imFont.data = DecompressData(compData, fontImageCompSize, &dataUncompSize);
4519 if (dataUncompSize != fontImageUncompSize) RAYGUI_LOG(
"WARNING: Uncompressed font atlas image data could be corrupted");
4521 RAYGUI_FREE(compData);
4526 imFont.data = (
unsigned char *)RAYGUI_MALLOC(fontImageUncompSize);
4527 memcpy(imFont.data, fileDataPtr, fontImageUncompSize);
4528 fileDataPtr += fontImageUncompSize;
4531 if (font.texture.id != GetFontDefault().texture.id) UnloadTexture(font.texture);
4532 font.texture = LoadTextureFromImage(imFont);
4534 RAYGUI_FREE(imFont.data);
4537 if (font.texture.id != 0)
4540 int recsDataSize = font.glyphCount*
sizeof(
Rectangle);
4541 int recsDataCompressedSize = 0;
4547 memcpy(&recsDataCompressedSize, fileDataPtr,
sizeof(
int));
4548 fileDataPtr +=
sizeof(int);
4551 if ((recsDataCompressedSize > 0) && (recsDataCompressedSize != recsDataSize))
4554 unsigned char *recsDataCompressed = (
unsigned char *)RAYGUI_MALLOC(recsDataCompressedSize);
4556 memcpy(recsDataCompressed, fileDataPtr, recsDataCompressedSize);
4557 fileDataPtr += recsDataCompressedSize;
4559 int recsDataUncompSize = 0;
4560 font.recs = (
Rectangle *)DecompressData(recsDataCompressed, recsDataCompressedSize, &recsDataUncompSize);
4563 if (recsDataUncompSize != recsDataSize) RAYGUI_LOG(
"WARNING: Uncompressed font recs data could be corrupted");
4565 RAYGUI_FREE(recsDataCompressed);
4571 for (
int i = 0; i < font.glyphCount; i++)
4573 memcpy(&font.recs[i], fileDataPtr,
sizeof(
Rectangle));
4579 int glyphsDataSize = font.glyphCount*16;
4580 int glyphsDataCompressedSize = 0;
4586 memcpy(&glyphsDataCompressedSize, fileDataPtr,
sizeof(
int));
4587 fileDataPtr +=
sizeof(int);
4593 if ((glyphsDataCompressedSize > 0) && (glyphsDataCompressedSize != glyphsDataSize))
4596 unsigned char *glypsDataCompressed = (
unsigned char *)RAYGUI_MALLOC(glyphsDataCompressedSize);
4598 memcpy(glypsDataCompressed, fileDataPtr, glyphsDataCompressedSize);
4599 fileDataPtr += glyphsDataCompressedSize;
4601 int glyphsDataUncompSize = 0;
4602 unsigned char *glyphsDataUncomp = DecompressData(glypsDataCompressed, glyphsDataCompressedSize, &glyphsDataUncompSize);
4605 if (glyphsDataUncompSize != glyphsDataSize) RAYGUI_LOG(
"WARNING: Uncompressed font glyphs data could be corrupted");
4607 unsigned char *glyphsDataUncompPtr = glyphsDataUncomp;
4609 for (
int i = 0; i < font.glyphCount; i++)
4611 memcpy(&font.glyphs[i].value, glyphsDataUncompPtr,
sizeof(
int));
4612 memcpy(&font.glyphs[i].offsetX, glyphsDataUncompPtr + 4,
sizeof(
int));
4613 memcpy(&font.glyphs[i].offsetY, glyphsDataUncompPtr + 8,
sizeof(
int));
4614 memcpy(&font.glyphs[i].advanceX, glyphsDataUncompPtr + 12,
sizeof(
int));
4615 glyphsDataUncompPtr += 16;
4618 RAYGUI_FREE(glypsDataCompressed);
4619 RAYGUI_FREE(glyphsDataUncomp);
4624 for (
int i = 0; i < font.glyphCount; i++)
4626 memcpy(&font.glyphs[i].value, fileDataPtr,
sizeof(
int));
4627 memcpy(&font.glyphs[i].offsetX, fileDataPtr + 4,
sizeof(
int));
4628 memcpy(&font.glyphs[i].offsetY, fileDataPtr + 8,
sizeof(
int));
4629 memcpy(&font.glyphs[i].advanceX, fileDataPtr + 12,
sizeof(
int));
4634 else font = GetFontDefault();
4640 if ((fontWhiteRec.x > 0) &&
4641 (fontWhiteRec.y > 0) &&
4642 (fontWhiteRec.width > 0) &&
4643 (fontWhiteRec.height > 0)) SetShapesTexture(font.texture, fontWhiteRec);
4650 static int GetTextWidth(
const char *text)
4652 #if !defined(ICON_TEXT_PADDING) 4653 #define ICON_TEXT_PADDING 4 4657 int textIconOffset = 0;
4659 if ((text != NULL) && (text[0] !=
'\0'))
4663 for (
int i = 1; (i < 5) && (text[i] !=
'\0'); i++)
4673 text += textIconOffset;
4676 float fontSize = (float)GuiGetStyle(DEFAULT, TEXT_SIZE);
4679 if ((guiFont.texture.id > 0) && (text != NULL))
4683 for (
int i = 0; i < MAX_LINE_BUFFER_SIZE; i++)
4685 if ((text[i] !=
'\0') && (text[i] !=
'\n')) size++;
4689 float scaleFactor = fontSize/(float)guiFont.baseSize;
4690 textSize.y = (
float)guiFont.baseSize*scaleFactor;
4691 float glyphWidth = 0.0f;
4693 for (
int i = 0, codepointSize = 0; i < size; i += codepointSize)
4695 int codepoint = GetCodepointNext(&text[i], &codepointSize);
4696 int codepointIndex = GetGlyphIndex(guiFont, codepoint);
4698 if (guiFont.glyphs[codepointIndex].advanceX == 0) glyphWidth = ((float)guiFont.recs[codepointIndex].width*scaleFactor);
4699 else glyphWidth = ((float)guiFont.glyphs[codepointIndex].advanceX*scaleFactor);
4701 textSize.x += (glyphWidth + (float)GuiGetStyle(DEFAULT, TEXT_SPACING));
4705 if (textIconOffset > 0) textSize.x += (RAYGUI_ICON_SIZE + ICON_TEXT_PADDING);
4708 return (
int)textSize.x;
4716 textBounds.x = bounds.x + GuiGetStyle(control, BORDER_WIDTH);
4717 textBounds.y = bounds.y + GuiGetStyle(control, BORDER_WIDTH) + GuiGetStyle(control, TEXT_PADDING);
4718 textBounds.width = bounds.width - 2*GuiGetStyle(control, BORDER_WIDTH) - 2*GuiGetStyle(control, TEXT_PADDING);
4719 textBounds.height = bounds.height - 2*GuiGetStyle(control, BORDER_WIDTH) - 2*GuiGetStyle(control, TEXT_PADDING);
4736 if (GuiGetStyle(control, TEXT_ALIGNMENT) == TEXT_ALIGN_RIGHT) textBounds.x -= GuiGetStyle(control, TEXT_PADDING);
4737 else textBounds.x += GuiGetStyle(control, TEXT_PADDING);
4747 static const char *GetTextIcon(
const char *text,
int *iconId)
4749 #if !defined(RAYGUI_NO_ICONS) 4753 char iconValue[4] = { 0 };
4756 while ((pos < 4) && (text[pos] >=
'0') && (text[pos] <=
'9'))
4758 iconValue[pos - 1] = text[pos];
4762 if (text[pos] ==
'#')
4764 *iconId = TextToInteger(iconValue);
4768 if (*iconId >= 0) text += (pos + 1);
4777 const char **GetTextLines(
const char *text,
int *count)
4779 #define RAYGUI_MAX_TEXT_LINES 128 4781 static const char *lines[RAYGUI_MAX_TEXT_LINES] = { 0 };
4782 for (
int i = 0; i < RAYGUI_MAX_TEXT_LINES; i++) lines[i] = NULL;
4784 int textSize = (int)strlen(text);
4791 for (
int i = 0, k = 0; (i < textSize) && (*count < RAYGUI_MAX_TEXT_LINES); i++)
4793 if (text[i] ==
'\n')
4797 lines[k] = &text[i + 1];
4810 static float GetNextSpaceWidth(
const char *text,
int *nextSpaceIndex)
4813 int codepointByteCount = 0;
4816 float glyphWidth = 0;
4817 float scaleFactor = (float)GuiGetStyle(DEFAULT, TEXT_SIZE)/guiFont.baseSize;
4819 for (
int i = 0; text[i] !=
'\0'; i++)
4823 codepoint = GetCodepoint(&text[i], &codepointByteCount);
4824 index = GetGlyphIndex(guiFont, codepoint);
4825 glyphWidth = (guiFont.glyphs[index].advanceX == 0)? guiFont.recs[index].width*scaleFactor : guiFont.glyphs[index].advanceX*scaleFactor;
4826 width += (glyphWidth + (
float)GuiGetStyle(DEFAULT, TEXT_SPACING));
4830 *nextSpaceIndex = i;
4839 static void GuiDrawText(
const char *text,
Rectangle textBounds,
int alignment,
Color tint)
4841 #define TEXT_VALIGN_PIXEL_OFFSET(h) ((int)h%2) // Vertical alignment for pixel perfect 4843 #if !defined(ICON_TEXT_PADDING) 4844 #define ICON_TEXT_PADDING 4 4847 if ((text == NULL) || (text[0] ==
'\0'))
return;
4859 const char **lines = GetTextLines(text, &lineCount);
4863 int alignmentVertical = GuiGetStyle(DEFAULT, TEXT_ALIGNMENT_VERTICAL);
4864 int wrapMode = GuiGetStyle(DEFAULT, TEXT_WRAP_MODE);
4867 float totalHeight = (float)(lineCount*GuiGetStyle(DEFAULT, TEXT_SIZE) + (lineCount - 1)*GuiGetStyle(DEFAULT, TEXT_SIZE)/2);
4868 float posOffsetY = 0.0f;
4870 for (
int i = 0; i < lineCount; i++)
4873 lines[i] = GetTextIcon(lines[i], &iconId);
4877 Vector2 textBoundsPosition = { textBounds.x, textBounds.y };
4878 float textBoundsWidthOffset = 0.0f;
4882 int textSizeX = GetTextWidth(lines[i]);
4887 textSizeX += RAYGUI_ICON_SIZE*guiIconScale;
4890 #if !defined(RAYGUI_NO_ICONS) 4891 if ((lines[i] != NULL) && (lines[i][0] !=
'\0')) textSizeX += ICON_TEXT_PADDING;
4898 case TEXT_ALIGN_LEFT: textBoundsPosition.x = textBounds.x;
break;
4899 case TEXT_ALIGN_CENTER: textBoundsPosition.x = textBounds.x + textBounds.width/2 - textSizeX/2;
break;
4900 case TEXT_ALIGN_RIGHT: textBoundsPosition.x = textBounds.x + textBounds.width - textSizeX;
break;
4904 if (textSizeX > textBounds.width && (lines[i] != NULL) && (lines[i][0] !=
'\0')) textBoundsPosition.x = textBounds.x;
4906 switch (alignmentVertical)
4909 case TEXT_ALIGN_TOP: textBoundsPosition.y = textBounds.y + posOffsetY;
break;
4910 case TEXT_ALIGN_MIDDLE: textBoundsPosition.y = textBounds.y + posOffsetY + textBounds.height/2 - totalHeight/2 + TEXT_VALIGN_PIXEL_OFFSET(textBounds.height);
break;
4911 case TEXT_ALIGN_BOTTOM: textBoundsPosition.y = textBounds.y + posOffsetY + textBounds.height - totalHeight + TEXT_VALIGN_PIXEL_OFFSET(textBounds.height);
break;
4917 textBoundsPosition.x = (float)((
int)textBoundsPosition.x);
4918 textBoundsPosition.y = (float)((
int)textBoundsPosition.y);
4923 #if !defined(RAYGUI_NO_ICONS) 4927 GuiDrawIcon(iconId, (
int)textBoundsPosition.x, (
int)(textBounds.y + textBounds.height/2 - RAYGUI_ICON_SIZE*guiIconScale/2 + TEXT_VALIGN_PIXEL_OFFSET(textBounds.height)), guiIconScale, tint);
4928 textBoundsPosition.x += (float)(RAYGUI_ICON_SIZE*guiIconScale + ICON_TEXT_PADDING);
4929 textBoundsWidthOffset = (float)(RAYGUI_ICON_SIZE*guiIconScale + ICON_TEXT_PADDING);
4935 for (
int c = 0; (lines[i][c] !=
'\0') && (lines[i][c] !=
'\n') && (lines[i][c] !=
'\r'); c++, lineSize++){ }
4936 float scaleFactor = (float)GuiGetStyle(DEFAULT, TEXT_SIZE)/guiFont.baseSize;
4938 int lastSpaceIndex = 0;
4939 bool tempWrapCharMode =
false;
4941 int textOffsetY = 0;
4942 float textOffsetX = 0.0f;
4943 float glyphWidth = 0;
4945 int ellipsisWidth = GetTextWidth(
"...");
4946 bool overflowReached =
false;
4947 for (
int c = 0, codepointSize = 0; c < lineSize; c += codepointSize)
4949 int codepoint = GetCodepointNext(&lines[i][c], &codepointSize);
4950 int index = GetGlyphIndex(guiFont, codepoint);
4954 if (codepoint == 0x3f) codepointSize = 1;
4957 if (guiFont.glyphs[index].advanceX == 0) glyphWidth = ((float)guiFont.recs[index].width*scaleFactor);
4958 else glyphWidth = (float)guiFont.glyphs[index].advanceX*scaleFactor;
4962 if (wrapMode == TEXT_WRAP_CHAR)
4965 if ((textOffsetX + glyphWidth) > textBounds.width - textBoundsWidthOffset)
4968 textOffsetY += GuiGetStyle(DEFAULT, TEXT_LINE_SPACING);
4970 if (tempWrapCharMode)
4972 wrapMode = TEXT_WRAP_WORD;
4973 tempWrapCharMode =
false;
4977 else if (wrapMode == TEXT_WRAP_WORD)
4979 if (codepoint == 32) lastSpaceIndex = c;
4982 int nextSpaceIndex = 0;
4983 float nextSpaceWidth = GetNextSpaceWidth(lines[i] + c, &nextSpaceIndex);
4985 int nextSpaceIndex2 = 0;
4986 float nextWordSize = GetNextSpaceWidth(lines[i] + lastSpaceIndex + 1, &nextSpaceIndex2);
4988 if (nextWordSize > textBounds.width - textBoundsWidthOffset)
4991 tempWrapCharMode =
true;
4992 wrapMode = TEXT_WRAP_CHAR;
4994 else if ((textOffsetX + nextSpaceWidth) > textBounds.width - textBoundsWidthOffset)
4997 textOffsetY += GuiGetStyle(DEFAULT, TEXT_LINE_SPACING);
5001 if (codepoint ==
'\n')
break;
5006 if ((codepoint !=
' ') && (codepoint !=
'\t'))
5008 if (wrapMode == TEXT_WRAP_NONE)
5011 if (textSizeX > textBounds.width)
5013 if (textOffsetX <= (textBounds.width - glyphWidth - textBoundsWidthOffset - ellipsisWidth))
5015 DrawTextCodepoint(guiFont, codepoint, RAYGUI_CLITERAL(
Vector2){ textBoundsPosition.x + textOffsetX, textBoundsPosition.y + textOffsetY }, (float)GuiGetStyle(DEFAULT, TEXT_SIZE), GuiFade(tint, guiAlpha));
5017 else if (!overflowReached)
5019 overflowReached =
true;
5021 for (
int j = 0; j < ellipsisWidth; j += ellipsisWidth/3)
5023 DrawTextCodepoint(guiFont,
'.', RAYGUI_CLITERAL(
Vector2){ textBoundsPosition.x + textOffsetX + j, textBoundsPosition.y + textOffsetY }, (float)GuiGetStyle(DEFAULT, TEXT_SIZE), GuiFade(tint, guiAlpha));
5029 DrawTextCodepoint(guiFont, codepoint, RAYGUI_CLITERAL(
Vector2){ textBoundsPosition.x + textOffsetX, textBoundsPosition.y + textOffsetY }, (float)GuiGetStyle(DEFAULT, TEXT_SIZE), GuiFade(tint, guiAlpha));
5032 else if ((wrapMode == TEXT_WRAP_CHAR) || (wrapMode == TEXT_WRAP_WORD))
5035 if ((textBoundsPosition.y + textOffsetY) <= (textBounds.y + textBounds.height - GuiGetStyle(DEFAULT, TEXT_SIZE)))
5037 DrawTextCodepoint(guiFont, codepoint, RAYGUI_CLITERAL(
Vector2){ textBoundsPosition.x + textOffsetX, textBoundsPosition.y + textOffsetY }, (float)GuiGetStyle(DEFAULT, TEXT_SIZE), GuiFade(tint, guiAlpha));
5042 if (guiFont.glyphs[index].advanceX == 0) textOffsetX += ((float)guiFont.recs[index].width*scaleFactor + (
float)GuiGetStyle(DEFAULT, TEXT_SPACING));
5043 else textOffsetX += ((float)guiFont.glyphs[index].advanceX*scaleFactor + (
float)GuiGetStyle(DEFAULT, TEXT_SPACING));
5047 if (wrapMode == TEXT_WRAP_NONE) posOffsetY += (float)GuiGetStyle(DEFAULT, TEXT_LINE_SPACING);
5048 else if ((wrapMode == TEXT_WRAP_CHAR) || (wrapMode == TEXT_WRAP_WORD)) posOffsetY += (textOffsetY + (float)GuiGetStyle(DEFAULT, TEXT_LINE_SPACING));
5052 #if defined(RAYGUI_DEBUG_TEXT_BOUNDS) 5053 GuiDrawRectangle(textBounds, 0, WHITE, Fade(BLUE, 0.4f));
5058 static void GuiDrawRectangle(
Rectangle rec,
int borderWidth,
Color borderColor,
Color color)
5063 DrawRectangle((
int)rec.x, (
int)rec.y, (
int)rec.width, (
int)rec.height, GuiFade(color, guiAlpha));
5066 if (borderWidth > 0)
5069 DrawRectangle((
int)rec.x, (
int)rec.y, (
int)rec.width, borderWidth, GuiFade(borderColor, guiAlpha));
5070 DrawRectangle((
int)rec.x, (
int)rec.y + borderWidth, borderWidth, (
int)rec.height - 2*borderWidth, GuiFade(borderColor, guiAlpha));
5071 DrawRectangle((
int)rec.x + (
int)rec.width - borderWidth, (
int)rec.y + borderWidth, borderWidth, (
int)rec.height - 2*borderWidth, GuiFade(borderColor, guiAlpha));
5072 DrawRectangle((
int)rec.x, (
int)rec.y + (
int)rec.height - borderWidth, (
int)rec.width, borderWidth, GuiFade(borderColor, guiAlpha));
5075 #if defined(RAYGUI_DEBUG_RECS_BOUNDS) 5076 DrawRectangle((
int)rec.x, (
int)rec.y, (
int)rec.width, (
int)rec.height, Fade(RED, 0.4f));
5081 static void GuiTooltip(
Rectangle controlRec)
5083 if (!guiLocked && guiTooltip && (guiTooltipPtr != NULL) && !guiControlExclusiveMode)
5085 Vector2 textSize = MeasureTextEx(GuiGetFont(), guiTooltipPtr, (
float)GuiGetStyle(DEFAULT, TEXT_SIZE), (
float)GuiGetStyle(DEFAULT, TEXT_SPACING));
5087 if ((controlRec.x + textSize.x + 16) > GetScreenWidth()) controlRec.x -= (textSize.x + 16 - controlRec.width);
5089 GuiPanel(RAYGUI_CLITERAL(
Rectangle){ controlRec.x, controlRec.y + controlRec.height + 4, textSize.x + 16, GuiGetStyle(DEFAULT, TEXT_SIZE) + 8.f }, NULL);
5091 int textPadding = GuiGetStyle(LABEL, TEXT_PADDING);
5092 int textAlignment = GuiGetStyle(LABEL, TEXT_ALIGNMENT);
5093 GuiSetStyle(LABEL, TEXT_PADDING, 0);
5094 GuiSetStyle(LABEL, TEXT_ALIGNMENT, TEXT_ALIGN_CENTER);
5095 GuiLabel(RAYGUI_CLITERAL(
Rectangle){ controlRec.x, controlRec.y + controlRec.height + 4, textSize.x + 16, GuiGetStyle(DEFAULT, TEXT_SIZE) + 8.f }, guiTooltipPtr);
5096 GuiSetStyle(LABEL, TEXT_ALIGNMENT, textAlignment);
5097 GuiSetStyle(LABEL, TEXT_PADDING, textPadding);
5103 static const char **GuiTextSplit(
const char *text,
char delimiter,
int *count,
int *textRow)
5115 #if !defined(RAYGUI_TEXTSPLIT_MAX_ITEMS) 5116 #define RAYGUI_TEXTSPLIT_MAX_ITEMS 128 5118 #if !defined(RAYGUI_TEXTSPLIT_MAX_TEXT_SIZE) 5119 #define RAYGUI_TEXTSPLIT_MAX_TEXT_SIZE 1024 5122 static const char *result[RAYGUI_TEXTSPLIT_MAX_ITEMS] = { NULL };
5123 static char buffer[RAYGUI_TEXTSPLIT_MAX_TEXT_SIZE] = { 0 };
5124 memset(buffer, 0, RAYGUI_TEXTSPLIT_MAX_TEXT_SIZE);
5129 if (textRow != NULL) textRow[0] = 0;
5132 for (
int i = 0; i < RAYGUI_TEXTSPLIT_MAX_TEXT_SIZE; i++)
5134 buffer[i] = text[i];
5135 if (buffer[i] ==
'\0')
break;
5136 else if ((buffer[i] == delimiter) || (buffer[i] ==
'\n'))
5138 result[counter] = buffer + i + 1;
5140 if (textRow != NULL)
5142 if (buffer[i] ==
'\n') textRow[counter] = textRow[counter - 1] + 1;
5143 else textRow[counter] = textRow[counter - 1];
5149 if (counter > RAYGUI_TEXTSPLIT_MAX_ITEMS)
break;
5167 min = (rgb.x < rgb.y)? rgb.x : rgb.y;
5168 min = (min < rgb.z)? min : rgb.z;
5170 max = (rgb.x > rgb.y)? rgb.x : rgb.y;
5171 max = (max > rgb.z)? max : rgb.z;
5176 if (delta < 0.00001f)
5186 hsv.y = (delta/max);
5197 if (rgb.x >= max) hsv.x = (rgb.y - rgb.z)/delta;
5200 if (rgb.y >= max) hsv.x = 2.0f + (rgb.z - rgb.x)/delta;
5201 else hsv.x = 4.0f + (rgb.x - rgb.y)/delta;
5206 if (hsv.x < 0.0f) hsv.x += 360.0f;
5216 float hh = 0.0f, p = 0.0f, q = 0.0f, t = 0.0f, ff = 0.0f;
5229 if (hh >= 360.0f) hh = 0.0f;
5234 p = hsv.z*(1.0f - hsv.y);
5235 q = hsv.z*(1.0f - (hsv.y*ff));
5236 t = hsv.z*(1.0f - (hsv.y*(1.0f - ff)));
5283 static int GuiScrollBar(
Rectangle bounds,
int value,
int minValue,
int maxValue)
5285 GuiState state = guiState;
5288 bool isVertical = (bounds.width > bounds.height)?
false :
true;
5291 const int spinnerSize = GuiGetStyle(SCROLLBAR, ARROWS_VISIBLE)?
5292 (isVertical? (int)bounds.width - 2*GuiGetStyle(SCROLLBAR, BORDER_WIDTH) :
5293 (int)bounds.height - 2*GuiGetStyle(SCROLLBAR, BORDER_WIDTH)) : 0;
5306 if (value > maxValue) value = maxValue;
5307 if (value < minValue) value = minValue;
5309 int valueRange = maxValue - minValue;
5310 if (valueRange <= 0) valueRange = 1;
5312 int sliderSize = GuiGetStyle(SCROLLBAR, SCROLL_SLIDER_SIZE);
5313 if (sliderSize < 1) sliderSize = 1;
5316 arrowUpLeft = RAYGUI_CLITERAL(
Rectangle){
5317 (float)bounds.x + GuiGetStyle(SCROLLBAR, BORDER_WIDTH),
5318 (float)bounds.y + GuiGetStyle(SCROLLBAR, BORDER_WIDTH),
5319 (float)spinnerSize, (
float)spinnerSize };
5323 arrowDownRight = RAYGUI_CLITERAL(
Rectangle){ (float)bounds.x + GuiGetStyle(SCROLLBAR, BORDER_WIDTH), (float)bounds.y + bounds.height - spinnerSize - GuiGetStyle(SCROLLBAR, BORDER_WIDTH), (float)spinnerSize, (
float)spinnerSize };
5324 scrollbar = RAYGUI_CLITERAL(
Rectangle){ bounds.x + GuiGetStyle(SCROLLBAR, BORDER_WIDTH) + GuiGetStyle(SCROLLBAR, SCROLL_PADDING), arrowUpLeft.y + arrowUpLeft.height, bounds.width - 2*(GuiGetStyle(SCROLLBAR, BORDER_WIDTH) + GuiGetStyle(SCROLLBAR, SCROLL_PADDING)), bounds.height - arrowUpLeft.height - arrowDownRight.height - 2*GuiGetStyle(SCROLLBAR, BORDER_WIDTH) };
5327 sliderSize = (sliderSize >= scrollbar.height)? ((
int)scrollbar.height - 2) : sliderSize;
5329 bounds.x + GuiGetStyle(SCROLLBAR, BORDER_WIDTH) + GuiGetStyle(SCROLLBAR, SCROLL_SLIDER_PADDING),
5330 scrollbar.y + (int)(((
float)(value - minValue)/valueRange)*(scrollbar.height - sliderSize)),
5331 bounds.width - 2*(GuiGetStyle(SCROLLBAR, BORDER_WIDTH) + GuiGetStyle(SCROLLBAR, SCROLL_SLIDER_PADDING)),
5332 (
float)sliderSize };
5336 arrowDownRight = RAYGUI_CLITERAL(
Rectangle){ (float)bounds.x + bounds.width - spinnerSize - GuiGetStyle(SCROLLBAR, BORDER_WIDTH), (float)bounds.y + GuiGetStyle(SCROLLBAR, BORDER_WIDTH), (float)spinnerSize, (
float)spinnerSize };
5337 scrollbar = RAYGUI_CLITERAL(
Rectangle){ arrowUpLeft.x + arrowUpLeft.width, bounds.y + GuiGetStyle(SCROLLBAR, BORDER_WIDTH) + GuiGetStyle(SCROLLBAR, SCROLL_PADDING), bounds.width - arrowUpLeft.width - arrowDownRight.width - 2*GuiGetStyle(SCROLLBAR, BORDER_WIDTH), bounds.height - 2*(GuiGetStyle(SCROLLBAR, BORDER_WIDTH) + GuiGetStyle(SCROLLBAR, SCROLL_PADDING)) };
5340 sliderSize = (sliderSize >= scrollbar.width)? ((
int)scrollbar.width - 2) : sliderSize;
5342 scrollbar.x + (int)(((
float)(value - minValue)/valueRange)*(scrollbar.width - sliderSize)),
5343 bounds.y + GuiGetStyle(SCROLLBAR, BORDER_WIDTH) + GuiGetStyle(SCROLLBAR, SCROLL_SLIDER_PADDING),
5345 bounds.height - 2*(GuiGetStyle(SCROLLBAR, BORDER_WIDTH) + GuiGetStyle(SCROLLBAR, SCROLL_SLIDER_PADDING)) };
5350 if ((state != STATE_DISABLED) && !guiLocked)
5352 Vector2 mousePoint = GetMousePosition();
5354 if (guiControlExclusiveMode)
5356 if (IsMouseButtonDown(MOUSE_LEFT_BUTTON) &&
5357 !CheckCollisionPointRec(mousePoint, arrowUpLeft) &&
5358 !CheckCollisionPointRec(mousePoint, arrowDownRight))
5360 if (CHECK_BOUNDS_ID(bounds, guiControlExclusiveRec))
5362 state = STATE_PRESSED;
5364 if (isVertical) value = (int)(((
float)(mousePoint.y - scrollbar.y - slider.height/2)*valueRange)/(scrollbar.height - slider.height) + minValue);
5365 else value = (int)(((
float)(mousePoint.x - scrollbar.x - slider.width/2)*valueRange)/(scrollbar.width - slider.width) + minValue);
5370 guiControlExclusiveMode =
false;
5371 guiControlExclusiveRec = RAYGUI_CLITERAL(
Rectangle){ 0, 0, 0, 0 };
5374 else if (CheckCollisionPointRec(mousePoint, bounds))
5376 state = STATE_FOCUSED;
5379 int wheel = (int)GetMouseWheelMove();
5380 if (wheel != 0) value += wheel;
5383 if (IsMouseButtonPressed(MOUSE_LEFT_BUTTON))
5385 guiControlExclusiveMode =
true;
5386 guiControlExclusiveRec = bounds;
5389 if (CheckCollisionPointRec(mousePoint, arrowUpLeft)) value -= valueRange/GuiGetStyle(SCROLLBAR, SCROLL_SPEED);
5390 else if (CheckCollisionPointRec(mousePoint, arrowDownRight)) value += valueRange/GuiGetStyle(SCROLLBAR, SCROLL_SPEED);
5391 else if (!CheckCollisionPointRec(mousePoint, slider))
5394 if (isVertical) value = (int)(((
float)(mousePoint.y - scrollbar.y - slider.height/2)*valueRange)/(scrollbar.height - slider.height) + minValue);
5395 else value = (int)(((
float)(mousePoint.x - scrollbar.x - slider.width/2)*valueRange)/(scrollbar.width - slider.width) + minValue);
5398 state = STATE_PRESSED;
5417 if (value > maxValue) value = maxValue;
5418 if (value < minValue) value = minValue;
5424 GuiDrawRectangle(bounds, GuiGetStyle(SCROLLBAR, BORDER_WIDTH), GetColor(GuiGetStyle(LISTVIEW, BORDER + state*3)), GetColor(GuiGetStyle(DEFAULT, BORDER_COLOR_DISABLED)));
5426 GuiDrawRectangle(scrollbar, 0, BLANK, GetColor(GuiGetStyle(BUTTON, BASE_COLOR_NORMAL)));
5427 GuiDrawRectangle(slider, 0, BLANK, GetColor(GuiGetStyle(SLIDER, BORDER + state*3)));
5430 if (GuiGetStyle(SCROLLBAR, ARROWS_VISIBLE))
5432 #if defined(RAYGUI_NO_ICONS) 5433 GuiDrawText(isVertical?
"^" :
"<",
5434 RAYGUI_CLITERAL(
Rectangle){ arrowUpLeft.x, arrowUpLeft.y, isVertical? bounds.width : bounds.height, isVertical? bounds.width : bounds.height },
5435 TEXT_ALIGN_CENTER, GetColor(GuiGetStyle(DROPDOWNBOX, TEXT + (state*3))));
5436 GuiDrawText(isVertical?
"v" :
">",
5437 RAYGUI_CLITERAL(
Rectangle){ arrowDownRight.x, arrowDownRight.y, isVertical? bounds.width : bounds.height, isVertical? bounds.width : bounds.height },
5438 TEXT_ALIGN_CENTER, GetColor(GuiGetStyle(DROPDOWNBOX, TEXT + (state*3))));
5440 GuiDrawText(isVertical?
"#121#" :
"#118#",
5441 RAYGUI_CLITERAL(
Rectangle){ arrowUpLeft.x, arrowUpLeft.y, isVertical? bounds.width : bounds.height, isVertical? bounds.width : bounds.height },
5442 TEXT_ALIGN_CENTER, GetColor(GuiGetStyle(SCROLLBAR, TEXT + state*3)));
5443 GuiDrawText(isVertical?
"#120#" :
"#119#",
5444 RAYGUI_CLITERAL(
Rectangle){ arrowDownRight.x, arrowDownRight.y, isVertical? bounds.width : bounds.height, isVertical? bounds.width : bounds.height },
5445 TEXT_ALIGN_CENTER, GetColor(GuiGetStyle(SCROLLBAR, TEXT + state*3)));
5455 static Color GuiFade(
Color color,
float alpha)
5457 if (alpha < 0.0f) alpha = 0.0f;
5458 else if (alpha > 1.0f) alpha = 1.0f;
5460 Color result = { color.r, color.g, color.b, (
unsigned char)(color.a*alpha) };
5465 #if defined(RAYGUI_STANDALONE) 5467 static Color GetColor(
int hexValue)
5471 color.r = (
unsigned char)(hexValue >> 24) & 0xFF;
5472 color.g = (
unsigned char)(hexValue >> 16) & 0xFF;
5473 color.b = (
unsigned char)(hexValue >> 8) & 0xFF;
5474 color.a = (
unsigned char)hexValue & 0xFF;
5480 static int ColorToInt(
Color color)
5482 return (((
int)color.r << 24) | ((
int)color.g << 16) | ((
int)color.b << 8) | (
int)color.a);
5488 bool collision =
false;
5490 if ((point.x >= rec.x) && (point.x <= (rec.x + rec.width)) &&
5491 (point.y >= rec.y) && (point.y <= (rec.y + rec.height))) collision =
true;
5497 static const char *TextFormat(
const char *text, ...)
5499 #if !defined(RAYGUI_TEXTFORMAT_MAX_SIZE) 5500 #define RAYGUI_TEXTFORMAT_MAX_SIZE 256 5503 static char buffer[RAYGUI_TEXTFORMAT_MAX_SIZE];
5506 va_start(args, text);
5507 vsprintf(buffer, text, args);
5515 static void DrawRectangleGradientV(
int posX,
int posY,
int width,
int height,
Color color1,
Color color2)
5517 Rectangle bounds = { (float)posX, (
float)posY, (float)width, (
float)height };
5518 DrawRectangleGradientEx(bounds, color1, color2, color2, color1);
5522 const char **TextSplit(
const char *text,
char delimiter,
int *count)
5530 #if !defined(RAYGUI_TEXTSPLIT_MAX_ITEMS) 5531 #define RAYGUI_TEXTSPLIT_MAX_ITEMS 128 5533 #if !defined(RAYGUI_TEXTSPLIT_MAX_TEXT_SIZE) 5534 #define RAYGUI_TEXTSPLIT_MAX_TEXT_SIZE 1024 5537 static const char *result[RAYGUI_TEXTSPLIT_MAX_ITEMS] = { NULL };
5538 static char buffer[RAYGUI_TEXTSPLIT_MAX_TEXT_SIZE] = { 0 };
5539 memset(buffer, 0, RAYGUI_TEXTSPLIT_MAX_TEXT_SIZE);
5549 for (
int i = 0; i < RAYGUI_TEXTSPLIT_MAX_TEXT_SIZE; i++)
5551 buffer[i] = text[i];
5552 if (buffer[i] ==
'\0')
break;
5553 else if (buffer[i] == delimiter)
5556 result[counter] = buffer + i + 1;
5559 if (counter == RAYGUI_TEXTSPLIT_MAX_ITEMS)
break;
5570 static int TextToInteger(
const char *text)
5575 if ((text[0] ==
'+') || (text[0] ==
'-'))
5577 if (text[0] ==
'-') sign = -1;
5581 for (
int i = 0; ((text[i] >=
'0') && (text[i] <=
'9')); ++i) value = value*10 + (
int)(text[i] -
'0');
5589 static float TextToFloat(
const char *text)
5594 if ((text[0] ==
'+') || (text[0] ==
'-'))
5596 if (text[0] ==
'-') sign = -1.0f;
5601 for (; ((text[i] >=
'0') && (text[i] <=
'9')); i++) value = value*10.0f + (
float)(text[i] -
'0');
5603 if (text[i++] !=
'.') value *= sign;
5606 float divisor = 10.0f;
5607 for (; ((text[i] >=
'0') && (text[i] <=
'9')); i++)
5609 value += ((float)(text[i] -
'0'))/divisor;
5610 divisor = divisor*10.0f;
5618 static const char *CodepointToUTF8(
int codepoint,
int *byteSize)
5620 static char utf8[6] = { 0 };
5623 if (codepoint <= 0x7f)
5625 utf8[0] = (char)codepoint;
5628 else if (codepoint <= 0x7ff)
5630 utf8[0] = (char)(((codepoint >> 6) & 0x1f) | 0xc0);
5631 utf8[1] = (char)((codepoint & 0x3f) | 0x80);
5634 else if (codepoint <= 0xffff)
5636 utf8[0] = (char)(((codepoint >> 12) & 0x0f) | 0xe0);
5637 utf8[1] = (char)(((codepoint >> 6) & 0x3f) | 0x80);
5638 utf8[2] = (char)((codepoint & 0x3f) | 0x80);
5641 else if (codepoint <= 0x10ffff)
5643 utf8[0] = (char)(((codepoint >> 18) & 0x07) | 0xf0);
5644 utf8[1] = (char)(((codepoint >> 12) & 0x3f) | 0x80);
5645 utf8[2] = (char)(((codepoint >> 6) & 0x3f) | 0x80);
5646 utf8[3] = (char)((codepoint & 0x3f) | 0x80);
5660 static int GetCodepointNext(
const char *text,
int *codepointSize)
5662 const char *ptr = text;
5663 int codepoint = 0x3f;
5667 if (0xf0 == (0xf8 & ptr[0]))
5670 if (((ptr[1] & 0xC0) ^ 0x80) || ((ptr[2] & 0xC0) ^ 0x80) || ((ptr[3] & 0xC0) ^ 0x80)) {
return codepoint; }
5671 codepoint = ((0x07 & ptr[0]) << 18) | ((0x3f & ptr[1]) << 12) | ((0x3f & ptr[2]) << 6) | (0x3f & ptr[3]);
5674 else if (0xe0 == (0xf0 & ptr[0]))
5677 if (((ptr[1] & 0xC0) ^ 0x80) || ((ptr[2] & 0xC0) ^ 0x80)) {
return codepoint; }
5678 codepoint = ((0x0f & ptr[0]) << 12) | ((0x3f & ptr[1]) << 6) | (0x3f & ptr[2]);
5681 else if (0xc0 == (0xe0 & ptr[0]))
5684 if ((ptr[1] & 0xC0) ^ 0x80) {
return codepoint; }
5685 codepoint = ((0x1f & ptr[0]) << 6) | (0x3f & ptr[1]);
5688 else if (0x00 == (0x80 & ptr[0]))
5697 #endif // RAYGUI_STANDALONE 5699 #endif // RAYGUI_IMPLEMENTATION Definition: rlgl_standalone.c:79