raygui.d 47 KB

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