raygui.d 47 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512
  1. /*******************************************************************************************
  2. *
  3. * raygui v2.7 - A simple and easy-to-use immediate-mode gui library
  4. *
  5. * DESCRIPTION:
  6. *
  7. * raygui is a tools-dev-focused immediate-mode-gui library based on raylib but also
  8. * available as a standalone library, as long as input and drawing functions are provided.
  9. *
  10. * Controls provided:
  11. *
  12. * # Container/separators Controls
  13. * - WindowBox
  14. * - GroupBox
  15. * - Line
  16. * - Panel
  17. *
  18. * # Basic Controls
  19. * - Label
  20. * - Button
  21. * - LabelButton --> Label
  22. * - ImageButton --> Button
  23. * - ImageButtonEx --> Button
  24. * - Toggle
  25. * - ToggleGroup --> Toggle
  26. * - CheckBox
  27. * - ComboBox
  28. * - DropdownBox
  29. * - TextBox
  30. * - TextBoxMulti
  31. * - ValueBox --> TextBox
  32. * - Spinner --> Button, ValueBox
  33. * - Slider
  34. * - SliderBar --> Slider
  35. * - ProgressBar
  36. * - StatusBar
  37. * - ScrollBar
  38. * - ScrollPanel
  39. * - DummyRec
  40. * - Grid
  41. *
  42. * # Advance Controls
  43. * - ListView
  44. * - ColorPicker --> ColorPanel, ColorBarHue
  45. * - MessageBox --> Window, Label, Button
  46. * - TextInputBox --> Window, Label, TextBox, Button
  47. *
  48. * It also provides a set of functions for styling the controls based on its properties (size, color).
  49. *
  50. * CONFIGURATION:
  51. *
  52. * #define RAYGUI_IMPLEMENTATION
  53. * Generates the implementation of the library into the included file.
  54. * If not defined, the library is in header only mode and can be included in other headers
  55. * or source files without problems. But only ONE file should hold the implementation.
  56. *
  57. * #define RAYGUI_STATIC (defined by default)
  58. * The generated implementation will stay private inside implementation file and all
  59. * internal symbols and functions will only be visible inside that file.
  60. *
  61. * #define RAYGUI_STANDALONE
  62. * Avoid raylib.h header inclusion in this file. Data types defined on raylib are defined
  63. * internally in the library and input management and drawing functions must be provided by
  64. * the user (check library implementation for further details).
  65. *
  66. * #define RAYGUI_SUPPORT_ICONS
  67. * Includes riconsdata.h header defining a set of 128 icons (binary format) to be used on
  68. * multiple controls and following raygui styles
  69. *
  70. *
  71. * VERSIONS HISTORY:
  72. * 2.7 (20-Feb-2020) Added possible tooltips API
  73. * 2.6 (09-Sep-2019) ADDED: GuiTextInputBox()
  74. * REDESIGNED: GuiListView*(), GuiDropdownBox(), GuiSlider*(), GuiProgressBar(), GuiMessageBox()
  75. * REVIEWED: GuiTextBox(), GuiSpinner(), GuiValueBox(), GuiLoadStyle()
  76. * Replaced property INNER_PADDING by TEXT_PADDING, renamed some properties
  77. * Added 8 new custom styles ready to use
  78. * Multiple minor tweaks and bugs corrected
  79. * 2.5 (28-May-2019) Implemented extended GuiTextBox(), GuiValueBox(), GuiSpinner()
  80. * 2.3 (29-Apr-2019) Added rIcons auxiliar library and support for it, multiple controls reviewed
  81. * Refactor all controls drawing mechanism to use control state
  82. * 2.2 (05-Feb-2019) Added GuiScrollBar(), GuiScrollPanel(), reviewed GuiListView(), removed Gui*Ex() controls
  83. * 2.1 (26-Dec-2018) Redesign of GuiCheckBox(), GuiComboBox(), GuiDropdownBox(), GuiToggleGroup() > Use combined text string
  84. * Complete redesign of style system (breaking change)
  85. * 2.0 (08-Nov-2018) Support controls guiLock and custom fonts, reviewed GuiComboBox(), GuiListView()...
  86. * 1.9 (09-Oct-2018) Controls review: GuiGrid(), GuiTextBox(), GuiTextBoxMulti(), GuiValueBox()...
  87. * 1.8 (01-May-2018) Lot of rework and redesign to align with rGuiStyler and rGuiLayout
  88. * 1.5 (21-Jun-2017) Working in an improved styles system
  89. * 1.4 (15-Jun-2017) Rewritten all GUI functions (removed useless ones)
  90. * 1.3 (12-Jun-2017) Redesigned styles system
  91. * 1.1 (01-Jun-2017) Complete review of the library
  92. * 1.0 (07-Jun-2016) Converted to header-only by Ramon Santamaria.
  93. * 0.9 (07-Mar-2016) Reviewed and tested by Albert Martos, Ian Eito, Sergio Martinez and Ramon Santamaria.
  94. * 0.8 (27-Aug-2015) Initial release. Implemented by Kevin Gato, Daniel Nicolás and Ramon Santamaria.
  95. *
  96. * CONTRIBUTORS:
  97. * Ramon Santamaria: Supervision, review, redesign, update and maintenance...
  98. * Vlad Adrian: Complete rewrite of GuiTextBox() to support extended features (2019)
  99. * Sergio Martinez: Review, testing (2015) and redesign of multiple controls (2018)
  100. * Adria Arranz: Testing and Implementation of additional controls (2018)
  101. * Jordi Jorba: Testing and Implementation of additional controls (2018)
  102. * Albert Martos: Review and testing of the library (2015)
  103. * Ian Eito: Review and testing of the library (2015)
  104. * Kevin Gato: Initial implementation of basic components (2014)
  105. * Daniel Nicolas: Initial implementation of basic components (2014)
  106. *
  107. *
  108. * LICENSE: zlib/libpng
  109. *
  110. * Copyright (c) 2014-2020 Ramon Santamaria (@raysan5)
  111. *
  112. * This software is provided "as-is", without any express or implied warranty. In no event
  113. * will the authors be held liable for any damages arising from the use of this software.
  114. *
  115. * Permission is granted to anyone to use this software for any purpose, including commercial
  116. * applications, and to alter it and redistribute it freely, subject to the following restrictions:
  117. *
  118. * 1. The origin of this software must not be misrepresented; you must not claim that you
  119. * wrote the original software. If you use this software in a product, an acknowledgment
  120. * in the product documentation would be appreciated but is not required.
  121. *
  122. * 2. Altered source versions must be plainly marked as such, and must not be misrepresented
  123. * as being the original software.
  124. *
  125. * 3. This notice may not be removed or altered from any source distribution.
  126. *
  127. **********************************************************************************************/
  128. import core.stdc.stdlib;
  129. import raylib;
  130. extern (C):
  131. enum RAYGUI_VERSION = "2.6-dev";
  132. // Define functions scope to be used internally (static) or externally (extern) to the module including this file
  133. // Functions just visible to module including this file
  134. // Functions visible from other files (no name mangling of functions in C++)
  135. // NOTE: By default any function declared in a C file is extern // Functions visible from other files
  136. // We are building raygui as a Win32 shared library (.dll).
  137. // We are using raygui as a Win32 shared library (.dll)
  138. // Required for: malloc(), calloc(), free()
  139. // Allow custom memory allocators
  140. alias RAYGUI_MALLOC = malloc;
  141. alias RAYGUI_CALLOC = calloc;
  142. alias RAYGUI_FREE = free;
  143. //----------------------------------------------------------------------------------
  144. // Defines and Macros
  145. //----------------------------------------------------------------------------------
  146. enum NUM_CONTROLS = 16; // Number of standard controls
  147. enum NUM_PROPS_DEFAULT = 16; // Number of standard properties
  148. enum NUM_PROPS_EXTENDED = 8; // Number of extended properties
  149. enum TEXTEDIT_CURSOR_BLINK_FRAMES = 20; // Text edit controls cursor blink timming
  150. //----------------------------------------------------------------------------------
  151. // Types and Structures Definition
  152. // NOTE: Some types are required for RAYGUI_STANDALONE usage
  153. //----------------------------------------------------------------------------------
  154. // Boolean type
  155. // Vector2 type
  156. // Vector3 type
  157. // Color type, RGBA (32bit)
  158. // Rectangle type
  159. // TODO: Texture2D type is very coupled to raylib, mostly required by GuiImageButton()
  160. // It should be redesigned to be provided by user
  161. // OpenGL texture id
  162. // Texture base width
  163. // Texture base height
  164. // Mipmap levels, 1 by default
  165. // Data format (PixelFormat type)
  166. // Font character info
  167. // TODO: Font type is very coupled to raylib, mostly required by GuiLoadStyle()
  168. // It should be redesigned to be provided by user
  169. // Base size (default chars height)
  170. // Number of characters
  171. // Characters texture atlas
  172. // Characters rectangles in texture
  173. // Characters info data
  174. // Style property
  175. struct GuiStyleProp
  176. {
  177. ushort controlId;
  178. ushort propertyId;
  179. int propertyValue;
  180. }
  181. // Gui control state
  182. enum GuiControlState
  183. {
  184. GUI_STATE_NORMAL = 0,
  185. GUI_STATE_FOCUSED = 1,
  186. GUI_STATE_PRESSED = 2,
  187. GUI_STATE_DISABLED = 3
  188. }
  189. // Gui control text alignment
  190. enum GuiTextAlignment
  191. {
  192. GUI_TEXT_ALIGN_LEFT = 0,
  193. GUI_TEXT_ALIGN_CENTER = 1,
  194. GUI_TEXT_ALIGN_RIGHT = 2
  195. }
  196. // Gui controls
  197. enum GuiControl
  198. {
  199. DEFAULT = 0,
  200. LABEL = 1, // LABELBUTTON
  201. BUTTON = 2, // IMAGEBUTTON
  202. TOGGLE = 3, // TOGGLEGROUP
  203. SLIDER = 4, // SLIDERBAR
  204. PROGRESSBAR = 5,
  205. CHECKBOX = 6,
  206. COMBOBOX = 7,
  207. DROPDOWNBOX = 8,
  208. TEXTBOX = 9, // TEXTBOXMULTI
  209. VALUEBOX = 10,
  210. SPINNER = 11,
  211. LISTVIEW = 12,
  212. COLORPICKER = 13,
  213. SCROLLBAR = 14,
  214. STATUSBAR = 15
  215. }
  216. // Gui base properties for every control
  217. enum GuiControlProperty
  218. {
  219. BORDER_COLOR_NORMAL = 0,
  220. BASE_COLOR_NORMAL = 1,
  221. TEXT_COLOR_NORMAL = 2,
  222. BORDER_COLOR_FOCUSED = 3,
  223. BASE_COLOR_FOCUSED = 4,
  224. TEXT_COLOR_FOCUSED = 5,
  225. BORDER_COLOR_PRESSED = 6,
  226. BASE_COLOR_PRESSED = 7,
  227. TEXT_COLOR_PRESSED = 8,
  228. BORDER_COLOR_DISABLED = 9,
  229. BASE_COLOR_DISABLED = 10,
  230. TEXT_COLOR_DISABLED = 11,
  231. BORDER_WIDTH = 12,
  232. TEXT_PADDING = 13,
  233. TEXT_ALIGNMENT = 14,
  234. RESERVED = 15
  235. }
  236. // Gui extended properties depend on control
  237. // NOTE: We reserve a fixed size of additional properties per control
  238. // DEFAULT properties
  239. enum GuiDefaultProperty
  240. {
  241. TEXT_SIZE = 16,
  242. TEXT_SPACING = 17,
  243. LINE_COLOR = 18,
  244. BACKGROUND_COLOR = 19
  245. }
  246. // Label
  247. //typedef enum { } GuiLabelProperty;
  248. // Button
  249. //typedef enum { } GuiButtonProperty;
  250. // Toggle / ToggleGroup
  251. enum GuiToggleProperty
  252. {
  253. GROUP_PADDING = 16
  254. }
  255. // Slider / SliderBar
  256. enum GuiSliderProperty
  257. {
  258. SLIDER_WIDTH = 16,
  259. SLIDER_PADDING = 17
  260. }
  261. // ProgressBar
  262. enum GuiProgressBarProperty
  263. {
  264. PROGRESS_PADDING = 16
  265. }
  266. // CheckBox
  267. enum GuiCheckBoxProperty
  268. {
  269. CHECK_PADDING = 16
  270. }
  271. // ComboBox
  272. enum GuiComboBoxProperty
  273. {
  274. COMBO_BUTTON_WIDTH = 16,
  275. COMBO_BUTTON_PADDING = 17
  276. }
  277. // DropdownBox
  278. enum GuiDropdownBoxProperty
  279. {
  280. ARROW_PADDING = 16,
  281. DROPDOWN_ITEMS_PADDING = 17
  282. }
  283. // TextBox / TextBoxMulti / ValueBox / Spinner
  284. enum GuiTextBoxProperty
  285. {
  286. TEXT_INNER_PADDING = 16,
  287. TEXT_LINES_PADDING = 17,
  288. COLOR_SELECTED_FG = 18,
  289. COLOR_SELECTED_BG = 19
  290. }
  291. // Spinner
  292. enum GuiSpinnerProperty
  293. {
  294. SPIN_BUTTON_WIDTH = 16,
  295. SPIN_BUTTON_PADDING = 17
  296. }
  297. // ScrollBar
  298. enum GuiScrollBarProperty
  299. {
  300. ARROWS_SIZE = 16,
  301. ARROWS_VISIBLE = 17,
  302. SCROLL_SLIDER_PADDING = 18,
  303. SCROLL_SLIDER_SIZE = 19,
  304. SCROLL_PADDING = 20,
  305. SCROLL_SPEED = 21
  306. }
  307. // ScrollBar side
  308. enum GuiScrollBarSide
  309. {
  310. SCROLLBAR_LEFT_SIDE = 0,
  311. SCROLLBAR_RIGHT_SIDE = 1
  312. }
  313. // ListView
  314. enum GuiListViewProperty
  315. {
  316. LIST_ITEMS_HEIGHT = 16,
  317. LIST_ITEMS_PADDING = 17,
  318. SCROLLBAR_WIDTH = 18,
  319. SCROLLBAR_SIDE = 19
  320. }
  321. // ColorPicker
  322. enum GuiColorPickerProperty
  323. {
  324. COLOR_SELECTOR_SIZE = 16,
  325. HUEBAR_WIDTH = 17, // Right hue bar width
  326. HUEBAR_PADDING = 18, // Right hue bar separation from panel
  327. HUEBAR_SELECTOR_HEIGHT = 19, // Right hue bar selector height
  328. HUEBAR_SELECTOR_OVERFLOW = 20 // Right hue bar selector overflow
  329. }
  330. //----------------------------------------------------------------------------------
  331. // Global Variables Definition
  332. //----------------------------------------------------------------------------------
  333. // ...
  334. //----------------------------------------------------------------------------------
  335. // Module Functions Declaration
  336. //----------------------------------------------------------------------------------
  337. // State modification functions
  338. void GuiEnable (); // Enable gui controls (global state)
  339. void GuiDisable (); // Disable gui controls (global state)
  340. void GuiLock (); // Lock gui controls (global state)
  341. void GuiUnlock (); // Unlock gui controls (global state)
  342. void GuiFade (float alpha); // Set gui controls alpha (global state), alpha goes from 0.0f to 1.0f
  343. void GuiSetState (int state); // Set gui state (global state)
  344. int GuiGetState (); // Get gui state (global state)
  345. // Font set/get functions
  346. void GuiSetFont (Font font); // Set gui custom font (global state)
  347. Font GuiGetFont (); // Get gui custom font (global state)
  348. // Style set/get functions
  349. void GuiSetStyle (int control, int property, int value); // Set one style property
  350. int GuiGetStyle (int control, int property); // Get one style property
  351. // Tooltips set functions
  352. void GuiEnableTooltip (); // Enable gui tooltips
  353. void GuiDisableTooltip (); // Disable gui tooltips
  354. void GuiSetTooltip (const(char)* tooltip); // Set current tooltip for display
  355. void GuiClearTooltip (); // Clear any tooltip registered
  356. // Container/separator controls, useful for controls organization
  357. bool GuiWindowBox (Rectangle bounds, const(char)* title); // Window Box control, shows a window that can be closed
  358. void GuiGroupBox (Rectangle bounds, const(char)* text); // Group Box control with text name
  359. void GuiLine (Rectangle bounds, const(char)* text); // Line separator control, could contain text
  360. void GuiPanel (Rectangle bounds); // Panel control, useful to group controls
  361. Rectangle GuiScrollPanel (Rectangle bounds, Rectangle content, Vector2* scroll); // Scroll Panel control
  362. // Basic controls set
  363. void GuiLabel (Rectangle bounds, const(char)* text); // Label control, shows text
  364. bool GuiButton (Rectangle bounds, const(char)* text); // Button control, returns true when clicked
  365. bool GuiLabelButton (Rectangle bounds, const(char)* text); // Label button control, show true when clicked
  366. bool GuiImageButton (Rectangle bounds, const(char)* text, Texture2D texture); // Image button control, returns true when clicked
  367. bool GuiImageButtonEx (Rectangle bounds, const(char)* text, Texture2D texture, Rectangle texSource); // Image button extended control, returns true when clicked
  368. bool GuiToggle (Rectangle bounds, const(char)* text, bool active); // Toggle Button control, returns true when active
  369. int GuiToggleGroup (Rectangle bounds, const(char)* text, int active); // Toggle Group control, returns active toggle index
  370. bool GuiCheckBox (Rectangle bounds, const(char)* text, bool checked); // Check Box control, returns true when active
  371. int GuiComboBox (Rectangle bounds, const(char)* text, int active); // Combo Box control, returns selected item index
  372. bool GuiDropdownBox (Rectangle bounds, const(char)* text, int* active, bool editMode); // Dropdown Box control, returns selected item
  373. bool GuiSpinner (Rectangle bounds, const(char)* text, int* value, int minValue, int maxValue, bool editMode); // Spinner control, returns selected value
  374. bool GuiValueBox (Rectangle bounds, const(char)* text, int* value, int minValue, int maxValue, bool editMode); // Value Box control, updates input text with numbers
  375. bool GuiTextBox (Rectangle bounds, char* text, int textSize, bool editMode); // Text Box control, updates input text
  376. bool GuiTextBoxMulti (Rectangle bounds, char* text, int textSize, bool editMode); // Text Box control with multiple lines
  377. float GuiSlider (Rectangle bounds, const(char)* textLeft, const(char)* textRight, float value, float minValue, float maxValue); // Slider control, returns selected value
  378. float GuiSliderBar (Rectangle bounds, const(char)* textLeft, const(char)* textRight, float value, float minValue, float maxValue); // Slider Bar control, returns selected value
  379. float GuiProgressBar (Rectangle bounds, const(char)* textLeft, const(char)* textRight, float value, float minValue, float maxValue); // Progress Bar control, shows current progress value
  380. void GuiStatusBar (Rectangle bounds, const(char)* text); // Status Bar control, shows info text
  381. void GuiDummyRec (Rectangle bounds, const(char)* text); // Dummy control for placeholders
  382. int GuiScrollBar (Rectangle bounds, int value, int minValue, int maxValue); // Scroll Bar control
  383. Vector2 GuiGrid (Rectangle bounds, float spacing, int subdivs); // Grid control
  384. // Advance controls set
  385. int GuiListView (Rectangle bounds, const(char)* text, int* scrollIndex, int active); // List View control, returns selected list item index
  386. int GuiListViewEx (Rectangle bounds, const(char*)* text, int count, int* focus, int* scrollIndex, int active); // List View with extended parameters
  387. int GuiMessageBox (Rectangle bounds, const(char)* title, const(char)* message, const(char)* buttons); // Message Box control, displays a message
  388. int GuiTextInputBox (Rectangle bounds, const(char)* title, const(char)* message, const(char)* buttons, char* text); // Text Input Box control, ask for text
  389. Color GuiColorPicker (Rectangle bounds, Color color); // Color Picker control (multiple color controls)
  390. Color GuiColorPanel (Rectangle bounds, Color color); // Color Panel control
  391. float GuiColorBarAlpha (Rectangle bounds, float alpha); // Color Bar Alpha control
  392. float GuiColorBarHue (Rectangle bounds, float value); // Color Bar Hue control
  393. // Styles loading functions
  394. void GuiLoadStyle (const(char)* fileName); // Load style file (.rgs)
  395. void GuiLoadStyleDefault (); // Load style default over global style
  396. /*
  397. typedef GuiStyle (unsigned int *)
  398. RAYGUIDEF GuiStyle LoadGuiStyle(const char *fileName); // Load style from file (.rgs)
  399. RAYGUIDEF void UnloadGuiStyle(GuiStyle style); // Unload style
  400. */
  401. const(char)* GuiIconText (int iconId, const(char)* text); // Get text with icon id prepended (if supported)
  402. // Gui icons functionality
  403. // Get full icons data pointer
  404. // Get icon bit data
  405. // Set icon bit data
  406. // Set icon pixel value
  407. // Clear icon pixel value
  408. // Check icon pixel value
  409. // RAYGUI_H
  410. /***********************************************************************************
  411. *
  412. * RAYGUI IMPLEMENTATION
  413. *
  414. ************************************************************************************/
  415. // Required for: raygui icons data
  416. // Required for: FILE, fopen(), fclose(), fprintf(), feof(), fscanf(), vsprintf()
  417. // Required for: strlen() on GuiTextBox()
  418. // Required for: va_list, va_start(), vfprintf(), va_end()
  419. //----------------------------------------------------------------------------------
  420. // Defines and Macros
  421. //----------------------------------------------------------------------------------
  422. //...
  423. //----------------------------------------------------------------------------------
  424. // Types and Structures Definition
  425. //----------------------------------------------------------------------------------
  426. // Gui control property style color element
  427. //----------------------------------------------------------------------------------
  428. // Global Variables Definition
  429. //----------------------------------------------------------------------------------
  430. // Gui current font (WARNING: highly coupled to raylib)
  431. // Gui lock state (no inputs processed)
  432. // Gui element transpacency on drawing
  433. // Global gui style array (allocated on heap by default)
  434. // NOTE: In raygui we manage a single int array with all the possible style properties.
  435. // When a new style is loaded, it loads over the global style... but default gui style
  436. // could always be recovered with GuiLoadStyleDefault()
  437. // Style loaded flag for lazy style initialization
  438. // Tooltips required variables
  439. // Gui tooltip currently active (user provided)
  440. // Gui tooltips enabled
  441. //----------------------------------------------------------------------------------
  442. // Standalone Mode Functions Declaration
  443. //
  444. // NOTE: raygui depend on some raylib input and drawing functions
  445. // To use raygui as standalone library, below functions must be defined by the user
  446. //----------------------------------------------------------------------------------
  447. // Input required functions
  448. //-------------------------------------------------------------------------------
  449. // -- GuiTextBox(), GuiTextBoxMulti(), GuiValueBox()
  450. //-------------------------------------------------------------------------------
  451. // Drawing required functions
  452. //-------------------------------------------------------------------------------
  453. // -- GuiColorPicker()
  454. // -- GuiDropdownBox(), GuiScrollBar()
  455. // -- GuiImageButtonEx()
  456. // -- GuiTextBoxMulti()
  457. //-------------------------------------------------------------------------------
  458. // Text required functions
  459. //-------------------------------------------------------------------------------
  460. // -- GuiLoadStyleDefault()
  461. // -- GetTextWidth(), GuiTextBoxMulti()
  462. // -- GuiDrawText()
  463. // -- GuiLoadStyle()
  464. // -- GuiLoadStyle()
  465. // -- GuiLoadStyle()
  466. //-------------------------------------------------------------------------------
  467. // raylib functions already implemented in raygui
  468. //-------------------------------------------------------------------------------
  469. // Returns a Color struct from hexadecimal value
  470. // Returns hexadecimal value for a Color
  471. // Color fade-in or fade-out, alpha goes from 0.0f to 1.0f
  472. // Check if point is inside rectangle
  473. // Formatting of text with variables to 'embed'
  474. // Split text into multiple strings
  475. // Get integer value from text
  476. // Draw rectangle filled with color
  477. // Draw rectangle outlines
  478. // Draw rectangle vertical gradient
  479. //-------------------------------------------------------------------------------
  480. // RAYGUI_STANDALONE
  481. //----------------------------------------------------------------------------------
  482. // Module specific Functions Declaration
  483. //----------------------------------------------------------------------------------
  484. // Convert color data from HSV to RGB
  485. // Convert color data from RGB to HSV
  486. // Gui get text width using default font
  487. // TODO: GetTextSize()
  488. // TODO: Consider text icon width here???
  489. // Get text bounds considering control bounds
  490. // Consider TEXT_PADDING properly, depends on control type and TEXT_ALIGNMENT
  491. // NOTE: ValueBox text value always centered, text padding applies to label
  492. // TODO: Special cases (no label): COMBOBOX, DROPDOWNBOX, LISTVIEW (scrollbar?)
  493. // More special cases (label side): CHECKBOX, SLIDER, VALUEBOX, SPINNER
  494. // Get text icon if provided and move text cursor
  495. // NOTE: We support up to 999 values for iconId
  496. // Maybe we have an icon!
  497. // Maximum length for icon value: 3 digits + '\0'
  498. // Move text pointer after icon
  499. // WARNING: If only icon provided, it could point to EOL character!
  500. // Gui draw text using default font
  501. // Vertical alignment for pixel perfect
  502. // Check text for icon and move cursor
  503. // Get text position depending on alignment and iconId
  504. //---------------------------------------------------------------------------------
  505. // NOTE: We get text size after icon been processed
  506. // WARNING: If only icon provided, text could be pointing to eof character!
  507. // Check guiTextAlign global variables
  508. // NOTE: Make sure we get pixel-perfect coordinates,
  509. // In case of decimals we got weird text positioning
  510. //---------------------------------------------------------------------------------
  511. // Draw text (with icon if available)
  512. //---------------------------------------------------------------------------------
  513. // NOTE: We consider icon height, probably different than text size
  514. //---------------------------------------------------------------------------------
  515. // Draw tooltip relatively to bounds
  516. //static int tooltipFramesCounter = 0; // Not possible gets reseted at second function call!
  517. // Split controls text into multiple strings
  518. // Also check for multiple columns (required by GuiToggleGroup())
  519. //----------------------------------------------------------------------------------
  520. // Gui Setup Functions Definition
  521. //----------------------------------------------------------------------------------
  522. // Enable gui global state
  523. // Disable gui global state
  524. // Lock gui global state
  525. // Unlock gui global state
  526. // Set gui controls alpha global state
  527. // Set gui state (global state)
  528. // Get gui state (global state)
  529. // Set custom gui font
  530. // NOTE: Font loading/unloading is external to raygui
  531. // NOTE: If we try to setup a font but default style has not been
  532. // lazily loaded before, it will be overwritten, so we need to force
  533. // default style loading first
  534. // Get custom gui font
  535. // Set control style property value
  536. // Default properties are propagated to all controls
  537. // Get control style property value
  538. // Enable gui tooltips
  539. // Disable gui tooltips
  540. // Set current tooltip for display
  541. // Clear any tooltip registered
  542. //----------------------------------------------------------------------------------
  543. // Gui Controls Functions Definition
  544. //----------------------------------------------------------------------------------
  545. // Window Box control
  546. // NOTE: This define is also used by GuiMessageBox() and GuiTextInputBox()
  547. // Update control
  548. //--------------------------------------------------------------------
  549. // NOTE: Logic is directly managed by button
  550. //--------------------------------------------------------------------
  551. // Draw control
  552. //--------------------------------------------------------------------
  553. // Draw window base
  554. // Draw window header as status bar
  555. // Draw window close button
  556. //--------------------------------------------------------------------
  557. // Group Box control with text name
  558. // Draw control
  559. //--------------------------------------------------------------------
  560. //--------------------------------------------------------------------
  561. // Line control
  562. // Draw control
  563. //--------------------------------------------------------------------
  564. // TODO: Consider text icon
  565. // Draw line with embedded text label: "--- text --------------"
  566. //--------------------------------------------------------------------
  567. // Panel control
  568. // Draw control
  569. //--------------------------------------------------------------------
  570. //--------------------------------------------------------------------
  571. // Scroll Panel control
  572. // Recheck to account for the other scrollbar being visible
  573. // Calculate view area (area without the scrollbars)
  574. // Clip view area to the actual content size
  575. // TODO: Review!
  576. // Update control
  577. //--------------------------------------------------------------------
  578. // Check button state
  579. // Normalize scroll values
  580. //--------------------------------------------------------------------
  581. // Draw control
  582. //--------------------------------------------------------------------
  583. // Draw background
  584. // Save size of the scrollbar slider
  585. // Draw horizontal scrollbar if visible
  586. // Change scrollbar slider size to show the diff in size between the content width and the widget width
  587. // Draw vertical scrollbar if visible
  588. // Change scrollbar slider size to show the diff in size between the content height and the widget height
  589. // Draw detail corner rectangle if both scroll bars are visible
  590. // TODO: Consider scroll bars side
  591. // Set scrollbar slider size back to the way it was before
  592. // Draw scrollbar lines depending on current state
  593. //--------------------------------------------------------------------
  594. // Label control
  595. // Update control
  596. //--------------------------------------------------------------------
  597. // ...
  598. //--------------------------------------------------------------------
  599. // Draw control
  600. //--------------------------------------------------------------------
  601. //--------------------------------------------------------------------
  602. // Button control, returns true when clicked
  603. // Update control
  604. //--------------------------------------------------------------------
  605. // Check button state
  606. //--------------------------------------------------------------------
  607. // Draw control
  608. //--------------------------------------------------------------------
  609. //------------------------------------------------------------------
  610. // Label button control
  611. // NOTE: We force bounds.width to be all text
  612. // Update control
  613. //--------------------------------------------------------------------
  614. // Check checkbox state
  615. //--------------------------------------------------------------------
  616. // Draw control
  617. //--------------------------------------------------------------------
  618. //--------------------------------------------------------------------
  619. // Image button control, returns true when clicked
  620. // Image button control, returns true when clicked
  621. // Update control
  622. //--------------------------------------------------------------------
  623. // Check button state
  624. //--------------------------------------------------------------------
  625. // Draw control
  626. //--------------------------------------------------------------------
  627. //------------------------------------------------------------------
  628. // Toggle Button control, returns true when active
  629. // Update control
  630. //--------------------------------------------------------------------
  631. // Check toggle button state
  632. //--------------------------------------------------------------------
  633. // Draw control
  634. //--------------------------------------------------------------------
  635. //--------------------------------------------------------------------
  636. // Toggle Group control, returns toggled button index
  637. // Get substrings items from text (items pointers)
  638. // Check Box control, returns true when active
  639. // Update control
  640. //--------------------------------------------------------------------
  641. // Check checkbox state
  642. //--------------------------------------------------------------------
  643. // Draw control
  644. //--------------------------------------------------------------------
  645. //--------------------------------------------------------------------
  646. // Combo Box control, returns selected item index
  647. // Get substrings items from text (items pointers, lengths and count)
  648. // Update control
  649. //--------------------------------------------------------------------
  650. //--------------------------------------------------------------------
  651. // Draw control
  652. //--------------------------------------------------------------------
  653. // Draw combo box main
  654. // Draw selector using a custom button
  655. // NOTE: BORDER_WIDTH and TEXT_ALIGNMENT forced values
  656. //--------------------------------------------------------------------
  657. // Dropdown Box control
  658. // NOTE: Returns mouse click
  659. // Get substrings items from text (items pointers, lengths and count)
  660. // Check mouse button pressed
  661. // Update control
  662. //--------------------------------------------------------------------
  663. // Check if mouse has been pressed or released outside limits
  664. // Check if already selected item has been pressed again
  665. // Check focused and selected item
  666. // Update item rectangle y position for next item
  667. // Item selected, change to editMode = false
  668. //--------------------------------------------------------------------
  669. // Draw control
  670. //--------------------------------------------------------------------
  671. // Draw visible items
  672. // Update item rectangle y position for next item
  673. // TODO: Avoid this function, use icon instead or 'v'
  674. //GuiDrawText("v", RAYGUI_CLITERAL(Rectangle){ bounds.x + bounds.width - GuiGetStyle(DROPDOWNBOX, ARROW_PADDING), bounds.y + bounds.height/2 - 2, 10, 10 },
  675. // GUI_TEXT_ALIGN_CENTER, Fade(GetColor(GuiGetStyle(DROPDOWNBOX, TEXT + (state*3))), guiAlpha));
  676. //--------------------------------------------------------------------
  677. // Text Box control, updates input text
  678. // NOTE 1: Requires static variables: framesCounter
  679. // NOTE 2: Returns if KEY_ENTER pressed (useful for data validation)
  680. // Required for blinking cursor
  681. // Update control
  682. //--------------------------------------------------------------------
  683. // Only allow keys in range [32..125]
  684. // Delete text
  685. // Check text alignment to position cursor properly
  686. //--------------------------------------------------------------------
  687. // Draw control
  688. //--------------------------------------------------------------------
  689. // Draw blinking cursor
  690. //--------------------------------------------------------------------
  691. // Spinner control, returns selected value
  692. // Update control
  693. //--------------------------------------------------------------------
  694. // Check spinner state
  695. //--------------------------------------------------------------------
  696. // Draw control
  697. //--------------------------------------------------------------------
  698. // TODO: Set Spinner properties for ValueBox
  699. // Draw value selector custom buttons
  700. // NOTE: BORDER_WIDTH and TEXT_ALIGNMENT forced values
  701. // Draw text label if provided
  702. //--------------------------------------------------------------------
  703. // Value Box control, updates input text with numbers
  704. // NOTE: Requires static variables: framesCounter
  705. // Required for blinking cursor
  706. // Update control
  707. //--------------------------------------------------------------------
  708. // Only allow keys in range [48..57]
  709. // Delete text
  710. //--------------------------------------------------------------------
  711. // Draw control
  712. //--------------------------------------------------------------------
  713. // Draw blinking cursor
  714. // NOTE: ValueBox internal text is always centered
  715. // Draw text label if provided
  716. //--------------------------------------------------------------------
  717. // Text Box control with multiple lines
  718. // Required for blinking cursor
  719. // Cursor position, [x, y] values should be updated
  720. // Update control
  721. //--------------------------------------------------------------------
  722. // Introduce characters
  723. // TODO: Support Unicode inputs
  724. // Delete characters
  725. // Calculate cursor position considering text
  726. // Exit edit mode
  727. // Reset blinking cursor
  728. //--------------------------------------------------------------------
  729. // Draw control
  730. //--------------------------------------------------------------------
  731. // Draw blinking cursor
  732. //--------------------------------------------------------------------
  733. // Slider control with pro parameters
  734. // NOTE: Other GuiSlider*() controls use this one
  735. // Slider
  736. // SliderBar
  737. // Update control
  738. //--------------------------------------------------------------------
  739. // Get equivalent value and slider position from mousePoint.x
  740. // Slider
  741. // SliderBar
  742. // Bar limits check
  743. // Slider
  744. // SliderBar
  745. //--------------------------------------------------------------------
  746. // Draw control
  747. //--------------------------------------------------------------------
  748. // Draw slider internal bar (depends on state)
  749. // Draw left/right text if provided
  750. // TODO: Consider text icon
  751. // TODO: Consider text icon
  752. //--------------------------------------------------------------------
  753. // Slider control extended, returns selected value and has text
  754. // Slider Bar control extended, returns selected value
  755. // Progress Bar control extended, shows current progress value
  756. // Update control
  757. //--------------------------------------------------------------------
  758. //--------------------------------------------------------------------
  759. // Draw control
  760. //--------------------------------------------------------------------
  761. // Draw slider internal progress bar (depends on state)
  762. // Draw left/right text if provided
  763. // TODO: Consider text icon
  764. // TODO: Consider text icon
  765. //--------------------------------------------------------------------
  766. // Status Bar control
  767. // Draw control
  768. //--------------------------------------------------------------------
  769. //--------------------------------------------------------------------
  770. // Dummy rectangle control, intended for placeholding
  771. // Update control
  772. //--------------------------------------------------------------------
  773. // Check button state
  774. //--------------------------------------------------------------------
  775. // Draw control
  776. //--------------------------------------------------------------------
  777. //------------------------------------------------------------------
  778. // Scroll Bar control
  779. // TODO: I feel GuiScrollBar could be simplified...
  780. // Is the scrollbar horizontal or vertical?
  781. // The size (width or height depending on scrollbar type) of the spinner buttons
  782. // Arrow buttons [<] [>] [∧] [∨]
  783. // Actual area of the scrollbar excluding the arrow buttons
  784. // Slider bar that moves --[///]-----
  785. // Normalize value
  786. // Calculate rectangles for all of the components
  787. // Make sure the slider won't get outside of the scrollbar
  788. // Make sure the slider won't get outside of the scrollbar
  789. // Update control
  790. //--------------------------------------------------------------------
  791. // Handle mouse wheel
  792. // Normalize value
  793. //--------------------------------------------------------------------
  794. // Draw control
  795. //--------------------------------------------------------------------
  796. // Draw the background
  797. // Draw the scrollbar active area background
  798. // Draw the slider bar
  799. // Draw arrows
  800. // Coordinates for < 0,1,2
  801. // Coordinates for > 3,4,5
  802. // Coordinates for ∧ 6,7,8
  803. // Coordinates for ∨ 9,10,11
  804. //--------------------------------------------------------------------
  805. // List View control
  806. // List View control with extended parameters
  807. // Check if we need a scroll bar
  808. // Define base item rectangle [0]
  809. // Get items on the list
  810. // Update control
  811. //--------------------------------------------------------------------
  812. // Check mouse inside list view
  813. // Check focused and selected item
  814. // Update item rectangle y position for next item
  815. // Reset item rectangle y to [0]
  816. //--------------------------------------------------------------------
  817. // Draw control
  818. //--------------------------------------------------------------------
  819. // Draw background
  820. // Draw visible items
  821. // Draw item selected
  822. // Draw item focused
  823. // Draw item normal
  824. // Update item rectangle y position for next item
  825. // Calculate percentage of visible items and apply same percentage to scrollbar
  826. // Save default slider size
  827. // Save default scroll speed
  828. // Change slider size
  829. // Change scroll speed
  830. // Reset scroll speed to default
  831. // Reset slider size to default
  832. //--------------------------------------------------------------------
  833. // Color Panel control
  834. // HSV: Saturation
  835. // HSV: Value
  836. // Update control
  837. //--------------------------------------------------------------------
  838. // Calculate color from picker
  839. // Get normalized value on x
  840. // Get normalized value on y
  841. // NOTE: Vector3ToColor() only available on raylib 1.8.1
  842. //--------------------------------------------------------------------
  843. // Draw control
  844. //--------------------------------------------------------------------
  845. // Draw color picker: selector
  846. //--------------------------------------------------------------------
  847. // Color Bar Alpha control
  848. // NOTE: Returns alpha value normalized [0..1]
  849. // Update control
  850. //--------------------------------------------------------------------
  851. //selector.x = bounds.x + (int)(((alpha - 0)/(100 - 0))*(bounds.width - 2*GuiGetStyle(SLIDER, BORDER_WIDTH))) - selector.width/2;
  852. //--------------------------------------------------------------------
  853. // Draw control
  854. //--------------------------------------------------------------------
  855. // Draw alpha bar: checked background
  856. // Draw alpha bar: selector
  857. //--------------------------------------------------------------------
  858. // Color Bar Hue control
  859. // NOTE: Returns hue value normalized [0..1]
  860. // Update control
  861. //--------------------------------------------------------------------
  862. /*if (IsKeyDown(KEY_UP))
  863. {
  864. hue -= 2.0f;
  865. if (hue <= 0.0f) hue = 0.0f;
  866. }
  867. else if (IsKeyDown(KEY_DOWN))
  868. {
  869. hue += 2.0f;
  870. if (hue >= 360.0f) hue = 360.0f;
  871. }*/
  872. //--------------------------------------------------------------------
  873. // Draw control
  874. //--------------------------------------------------------------------
  875. // Draw hue bar:color bars
  876. // Draw hue bar: selector
  877. //--------------------------------------------------------------------
  878. // TODO: Color GuiColorBarSat() [WHITE->color]
  879. // TODO: Color GuiColorBarValue() [BLACK->color], HSV / HSL
  880. // TODO: float GuiColorBarLuminance() [BLACK->WHITE]
  881. // Color Picker control
  882. // NOTE: It's divided in multiple controls:
  883. // Color GuiColorPanel(Rectangle bounds, Color color)
  884. // float GuiColorBarAlpha(Rectangle bounds, float alpha)
  885. // float GuiColorBarHue(Rectangle bounds, float value)
  886. // NOTE: bounds define GuiColorPanel() size
  887. //Rectangle boundsAlpha = { bounds.x, bounds.y + bounds.height + GuiGetStyle(COLORPICKER, BARS_PADDING), bounds.width, GuiGetStyle(COLORPICKER, BARS_THICK) };
  888. //color.a = (unsigned char)(GuiColorBarAlpha(boundsAlpha, (float)color.a/255.0f)*255.0f);
  889. // Message Box control
  890. // Returns clicked button from buttons list, 0 refers to closed window button
  891. // Draw control
  892. //--------------------------------------------------------------------
  893. //--------------------------------------------------------------------
  894. // Text Input Box control, ask for text
  895. // Used to enable text edit mode
  896. // WARNING: No more than one GuiTextInputBox() should be open at the same time
  897. // Draw control
  898. //--------------------------------------------------------------------
  899. // Draw message if available
  900. //--------------------------------------------------------------------
  901. // Grid control
  902. // NOTE: Returns grid mouse-hover selected cell
  903. // About drawing lines at subpixel spacing, simple put, not easy solution:
  904. // https://stackoverflow.com/questions/4435450/2d-opengl-drawing-lines-that-dont-exactly-fit-pixel-raster
  905. // Grid lines alpha amount
  906. // Update control
  907. //--------------------------------------------------------------------
  908. //--------------------------------------------------------------------
  909. // Draw control
  910. //--------------------------------------------------------------------
  911. // Draw vertical grid lines
  912. // Draw horizontal grid lines
  913. //----------------------------------------------------------------------------------
  914. // Styles loading functions
  915. //----------------------------------------------------------------------------------
  916. // Load raygui style file (.rgs)
  917. // Try reading the files as text file first
  918. // Style property: p <control_id> <property_id> <property_value> <property_name>
  919. // Style font: f <gen_font_size> <charmap_file> <font_file>
  920. // Load characters from charmap file,
  921. // expected '\n' separated list of integer values
  922. // DEFAULT control
  923. // If a DEFAULT property is loaded, it is propagated to all controls
  924. // NOTE: All DEFAULT properties should be defined first in the file
  925. // Font loading is highly dependant on raylib API to load font data and image
  926. // TODO: Find some mechanism to support it in standalone mode
  927. // Load custom font if available
  928. // 0-Normal, 1-SDF
  929. // Load font white rectangle
  930. // Load font image parameters
  931. // Load font recs data
  932. // Load font chars info data
  933. // Set font texture source rectangle to be used as white texture to draw shapes
  934. // NOTE: This way, all gui can be draw using a single draw call
  935. // Load style default over global style
  936. // We set this variable first to avoid cyclic function calls
  937. // when calling GuiSetStyle() and GuiGetStyle()
  938. // Initialize default LIGHT style property values
  939. // WARNING: Some controls use other values
  940. // WARNING: Some controls use other values
  941. // WARNING: Some controls use other values
  942. // Initialize control-specific property values
  943. // NOTE: Those properties are in default list but require specific values by control type
  944. // Initialize extended property values
  945. // NOTE: By default, extended property values are initialized to 0
  946. // DEFAULT, shared by all controls
  947. // DEFAULT, shared by all controls
  948. // DEFAULT specific property
  949. // DEFAULT specific property
  950. // Initialize default font
  951. // Get text with icon id prepended
  952. // NOTE: Useful to add icons by name id (enum) instead of
  953. // a number that can change between ricon versions
  954. // Get full icons data pointer
  955. // Load raygui icons file (.rgi)
  956. // NOTE: In case nameIds are required, they can be requested with loadIconsName,
  957. // they are returned as a guiIconsName[iconsCount][RICON_MAX_NAME_LENGTH],
  958. // guiIconsName[]][] memory should be manually freed!
  959. // Style File Structure (.rgi)
  960. // ------------------------------------------------------
  961. // Offset | Size | Type | Description
  962. // ------------------------------------------------------
  963. // 0 | 4 | char | Signature: "rGI "
  964. // 4 | 2 | short | Version: 100
  965. // 6 | 2 | short | reserved
  966. // 8 | 2 | short | Num icons (N)
  967. // 10 | 2 | short | Icons size (Options: 16, 32, 64) (S)
  968. // Icons name id (32 bytes per name id)
  969. // foreach (icon)
  970. // {
  971. // 12+32*i | 32 | char | Icon NameId
  972. // }
  973. // Icons data: One bit per pixel, stored as unsigned int array (depends on icon size)
  974. // S*S pixels/32bit per unsigned int = K unsigned int per icon
  975. // foreach (icon)
  976. // {
  977. // ... | K | unsigned int | Icon Data
  978. // }
  979. // Read icons data directly over guiIcons data array
  980. // Draw selected icon using rectangles pixel-by-pixel
  981. // Get icon bit data
  982. // NOTE: Bit data array grouped as unsigned int (ICON_SIZE*ICON_SIZE/32 elements)
  983. // Set icon bit data
  984. // NOTE: Data must be provided as unsigned int array (ICON_SIZE*ICON_SIZE/32 elements)
  985. // Set icon pixel value
  986. // This logic works for any RICON_SIZE pixels icons,
  987. // For example, in case of 16x16 pixels, every 2 lines fit in one unsigned int data element
  988. // Clear icon pixel value
  989. // This logic works for any RICON_SIZE pixels icons,
  990. // For example, in case of 16x16 pixels, every 2 lines fit in one unsigned int data element
  991. // Check icon pixel value
  992. // RAYGUI_SUPPORT_ICONS
  993. //----------------------------------------------------------------------------------
  994. // Module specific Functions Definition
  995. //----------------------------------------------------------------------------------
  996. // Split controls text into multiple strings
  997. // Also check for multiple columns (required by GuiToggleGroup())
  998. // NOTE: Current implementation returns a copy of the provided string with '\0' (string end delimiter)
  999. // inserted between strings defined by "delimiter" parameter. No memory is dynamically allocated,
  1000. // all used memory is static... it has some limitations:
  1001. // 1. Maximum number of possible split strings is set by TEXTSPLIT_MAX_TEXT_ELEMENTS
  1002. // 2. Maximum size of text to split is TEXTSPLIT_MAX_TEXT_LENGTH
  1003. // NOTE: Those definitions could be externally provided if required
  1004. // Count how many substrings we have on text and point to every one
  1005. // Set an end of string at this point
  1006. // Convert color data from RGB to HSV
  1007. // NOTE: Color data should be passed normalized
  1008. // Value
  1009. // Undefined, maybe NAN?
  1010. // NOTE: If max is 0, this divide would cause a crash
  1011. // Saturation
  1012. // NOTE: If max is 0, then r = g = b = 0, s = 0, h is undefined
  1013. // Undefined, maybe NAN?
  1014. // NOTE: Comparing float values could not work properly
  1015. // Between yellow & magenta
  1016. // Between cyan & yellow
  1017. // Between magenta & cyan
  1018. // Convert to degrees
  1019. // Convert color data from HSV to RGB
  1020. // NOTE: Color data should be passed normalized
  1021. // NOTE: Comparing float values could not work properly
  1022. // Returns a Color struct from hexadecimal value
  1023. // Returns hexadecimal value for a Color
  1024. // Check if point is inside rectangle
  1025. // Color fade-in or fade-out, alpha goes from 0.0f to 1.0f
  1026. // Formatting of text with variables to 'embed'
  1027. // Draw rectangle filled with color
  1028. // Draw rectangle border lines with color
  1029. // Draw rectangle with vertical gradient fill color
  1030. // NOTE: This function is only used by GuiColorPicker()
  1031. // Size of static buffer: TextSplit()
  1032. // Size of static pointers array: TextSplit()
  1033. // Split string into multiple strings
  1034. // NOTE: Current implementation returns a copy of the provided string with '\0' (string end delimiter)
  1035. // inserted between strings defined by "delimiter" parameter. No memory is dynamically allocated,
  1036. // all used memory is static... it has some limitations:
  1037. // 1. Maximum number of possible split strings is set by TEXTSPLIT_MAX_SUBSTRINGS_COUNT
  1038. // 2. Maximum size of text to split is TEXTSPLIT_MAX_TEXT_BUFFER_LENGTH
  1039. // Count how many substrings we have on text and point to every one
  1040. // Set an end of string at this point
  1041. // Get integer value from text
  1042. // NOTE: This function replaces atoi() [stdlib.h]
  1043. // RAYGUI_STANDALONE
  1044. // RAYGUI_IMPLEMENTATION