Properties.html 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  2. <html xmlns="http://www.w3.org/1999/xhtml" lang="en-US">
  3. <head>
  4. <meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
  5. <meta http-equiv="X-UA-Compatible" content="IE=11"/>
  6. <meta name="generator" content="Doxygen 1.9.8"/>
  7. <meta name="viewport" content="width=device-width, initial-scale=1"/>
  8. <title>Nuklear: Properties</title>
  9. <link href="tabs.css" rel="stylesheet" type="text/css"/>
  10. <script type="text/javascript" src="jquery.js"></script>
  11. <script type="text/javascript" src="dynsections.js"></script>
  12. <link href="navtree.css" rel="stylesheet" type="text/css"/>
  13. <script type="text/javascript" src="resize.js"></script>
  14. <script type="text/javascript" src="navtreedata.js"></script>
  15. <script type="text/javascript" src="navtree.js"></script>
  16. <link href="search/search.css" rel="stylesheet" type="text/css"/>
  17. <script type="text/javascript" src="search/searchdata.js"></script>
  18. <script type="text/javascript" src="search/search.js"></script>
  19. <script type="text/javascript">
  20. /* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&amp;dn=expat.txt MIT */
  21. $(document).ready(function() { init_search(); });
  22. /* @license-end */
  23. </script>
  24. <link href="doxygen.css" rel="stylesheet" type="text/css" />
  25. <link href="doxygen-awesome.css" rel="stylesheet" type="text/css"/>
  26. </head>
  27. <body>
  28. <div id="top"><!-- do not remove this div, it is closed by doxygen! -->
  29. <div id="titlearea">
  30. <table cellspacing="0" cellpadding="0">
  31. <tbody>
  32. <tr id="projectrow">
  33. <td id="projectalign">
  34. <div id="projectname">Nuklear
  35. </div>
  36. <div id="projectbrief">This is a minimal-state, immediate-mode graphical user interface toolkit written in ANSI C and licensed under public domain. It was designed as a simple embeddable user interface for application and does not have any dependencies, a default render backend or OS window/input handling but instead provides a highly modular, library-based approach, with simple input state for input and draw commands describing primitive shapes as output. So instead of providing a layered library that tries to abstract over a number of platform and render backends, it focuses only on the actual UI.</div>
  37. </td>
  38. <td> <div id="MSearchBox" class="MSearchBoxInactive">
  39. <span class="left">
  40. <span id="MSearchSelect" onmouseover="return searchBox.OnSearchSelectShow()" onmouseout="return searchBox.OnSearchSelectHide()">&#160;</span>
  41. <input type="text" id="MSearchField" value="" placeholder="Search" accesskey="S"
  42. onfocus="searchBox.OnSearchFieldFocus(true)"
  43. onblur="searchBox.OnSearchFieldFocus(false)"
  44. onkeyup="searchBox.OnSearchFieldChange(event)"/>
  45. </span><span class="right">
  46. <a id="MSearchClose" href="javascript:searchBox.CloseResultsWindow()"><img id="MSearchCloseImg" border="0" src="search/close.svg" alt=""/></a>
  47. </span>
  48. </div>
  49. </td>
  50. </tr>
  51. </tbody>
  52. </table>
  53. </div>
  54. <!-- end header part -->
  55. <!-- Generated by Doxygen 1.9.8 -->
  56. <script type="text/javascript">
  57. /* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&amp;dn=expat.txt MIT */
  58. var searchBox = new SearchBox("searchBox", "search/",'.html');
  59. /* @license-end */
  60. </script>
  61. </div><!-- top -->
  62. <div id="side-nav" class="ui-resizable side-nav-resizable">
  63. <div id="nav-tree">
  64. <div id="nav-tree-contents">
  65. <div id="nav-sync" class="sync"></div>
  66. </div>
  67. </div>
  68. <div id="splitbar" style="-moz-user-select:none;"
  69. class="ui-resizable-handle">
  70. </div>
  71. </div>
  72. <script type="text/javascript">
  73. /* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&amp;dn=expat.txt MIT */
  74. $(document).ready(function(){initNavTree('Properties.html',''); initResizable(); });
  75. /* @license-end */
  76. </script>
  77. <div id="doc-content">
  78. <!-- window showing the filter options -->
  79. <div id="MSearchSelectWindow"
  80. onmouseover="return searchBox.OnSearchSelectShow()"
  81. onmouseout="return searchBox.OnSearchSelectHide()"
  82. onkeydown="return searchBox.OnSearchSelectKey(event)">
  83. </div>
  84. <!-- iframe showing the search results (closed by default) -->
  85. <div id="MSearchResultsWindow">
  86. <div id="MSearchResults">
  87. <div class="SRPage">
  88. <div id="SRIndex">
  89. <div id="SRResults"></div>
  90. <div class="SRStatus" id="Loading">Loading...</div>
  91. <div class="SRStatus" id="Searching">Searching...</div>
  92. <div class="SRStatus" id="NoMatches">No Matches</div>
  93. </div>
  94. </div>
  95. </div>
  96. </div>
  97. <div><div class="header">
  98. <div class="headertitle"><div class="title">Properties</div></div>
  99. </div><!--header-->
  100. <div class="contents">
  101. <div class="textblock"><p>Properties are the main value modification widgets in Nuklear.</p>
  102. <p>Changing a value can be achieved by dragging, adding/removing incremental steps on button click or by directly typing a number.</p>
  103. <h1><a class="anchor" id="autotoc_md94"></a>
  104. Usage</h1>
  105. <p>Each property requires a unique name for identification that is also used for displaying a label. If you want to use the same name multiple times make sure add a '#' before your name. The '#' will not be shown but will generate a unique ID. Each property also takes in a minimum and maximum value. If you want to make use of the complete number range of a type just use the provided type limits from <code>limits.h</code>. For example <code>INT_MIN</code> and <code>INT_MAX</code> for <code>nk_property_int</code> and <code>nk_propertyi</code>. In additional each property takes in a increment value that will be added or subtracted if either the increment decrement button is clicked. Finally there is a value for increment per pixel dragged that is added or subtracted from the value.</p>
  106. <div class="fragment"><div class="line"><span class="keywordtype">int</span> value = 0;</div>
  107. <div class="line"><span class="keyword">struct </span><a class="code hl_struct" href="structnk__context.html">nk_context</a> ctx;</div>
  108. <div class="line">nk_init_xxx(&amp;ctx, ...);</div>
  109. <div class="line"><span class="keywordflow">while</span> (1) {</div>
  110. <div class="line"> <span class="comment">// Input</span></div>
  111. <div class="line"> Event evt;</div>
  112. <div class="line"> <a class="code hl_function" href="nuklear_8h.html#a1dd51949401094f71d10429d45779d53">nk_input_begin</a>(&amp;ctx);</div>
  113. <div class="line"> <span class="keywordflow">while</span> (GetEvent(&amp;evt)) {</div>
  114. <div class="line"> <span class="keywordflow">if</span> (evt.type == MOUSE_MOVE)</div>
  115. <div class="line"> <a class="code hl_function" href="nuklear_8h.html#acdbdc5795b24d36875281cf3cac671fe">nk_input_motion</a>(&amp;ctx, evt.motion.x, evt.motion.y);</div>
  116. <div class="line"> <span class="keywordflow">else</span> <span class="keywordflow">if</span> (evt.type == [...]) {</div>
  117. <div class="line"> nk_input_xxx(...);</div>
  118. <div class="line"> }</div>
  119. <div class="line"> }</div>
  120. <div class="line"> <a class="code hl_function" href="nuklear_8h.html#a15c0d237b6bb2f5195a09e259fd7b375">nk_input_end</a>(&amp;ctx);</div>
  121. <div class="line"> <span class="comment">//</span></div>
  122. <div class="line"> <span class="comment">// Window</span></div>
  123. <div class="line"> <span class="keywordflow">if</span> (nk_begin_xxx(...) {</div>
  124. <div class="line"> <span class="comment">// Property</span></div>
  125. <div class="line"> <a class="code hl_function" href="nuklear_8h.html#a76e65dc775c0bd5efaa3c8f38f96823f">nk_layout_row_dynamic</a>(...);</div>
  126. <div class="line"> nk_property_int(ctx, <span class="stringliteral">&quot;ID&quot;</span>, INT_MIN, &amp;value, INT_MAX, 1, 1);</div>
  127. <div class="line"> }</div>
  128. <div class="line"> <a class="code hl_function" href="nuklear_8h.html#ae0ade48c4c8df72456b9d97ab3d195e3">nk_end</a>(ctx);</div>
  129. <div class="line"> <span class="comment">//</span></div>
  130. <div class="line"> <span class="comment">// Draw</span></div>
  131. <div class="line"> <span class="keyword">const</span> <span class="keyword">struct </span><a class="code hl_struct" href="structnk__command.html">nk_command</a> *cmd = 0;</div>
  132. <div class="line"> <a class="code hl_define" href="nuklear_8h.html#aaca7101364db82c0f03401fafd2c66a6">nk_foreach</a>(cmd, &amp;ctx) {</div>
  133. <div class="line"> <span class="keywordflow">switch</span> (cmd-&gt;type) {</div>
  134. <div class="line"> <span class="keywordflow">case</span> NK_COMMAND_LINE:</div>
  135. <div class="line"> your_draw_line_function(...)</div>
  136. <div class="line"> break;</div>
  137. <div class="line"> case NK_COMMAND_RECT</div>
  138. <div class="line"> your_draw_rect_function(...)</div>
  139. <div class="line"> break;</div>
  140. <div class="line"> case ...:</div>
  141. <div class="line"> <span class="comment">// [...]</span></div>
  142. <div class="line"> }</div>
  143. <div class="line"> <a class="code hl_function" href="nuklear_8h.html#ade3301f0a92370be1b4beac7eceac279">nk_clear</a>(&amp;ctx);</div>
  144. <div class="line">}</div>
  145. <div class="line"><a class="code hl_function" href="nuklear_8h.html#a06772e194320fa99524681fd32df85e9">nk_free</a>(&amp;ctx);</div>
  146. <div class="ttc" id="anuklear_8h_html_a06772e194320fa99524681fd32df85e9"><div class="ttname"><a href="nuklear_8h.html#a06772e194320fa99524681fd32df85e9">nk_free</a></div><div class="ttdeci">NK_API void nk_free(struct nk_context *)</div><div class="ttdoc">Frees all memory allocated by nuklear; Not needed if context was initialized with nk_init_fixed.</div><div class="ttdef"><b>Definition</b> <a href="nuklear__context_8c_source.html#l00088">nuklear_context.c:88</a></div></div>
  147. <div class="ttc" id="anuklear_8h_html_a15c0d237b6bb2f5195a09e259fd7b375"><div class="ttname"><a href="nuklear_8h.html#a15c0d237b6bb2f5195a09e259fd7b375">nk_input_end</a></div><div class="ttdeci">NK_API void nk_input_end(struct nk_context *)</div><div class="ttdoc">End the input mirroring process by resetting mouse grabbing state to ensure the mouse cursor is not g...</div><div class="ttdef"><b>Definition</b> <a href="nuklear__input_8c_source.html#l00030">nuklear_input.c:30</a></div></div>
  148. <div class="ttc" id="anuklear_8h_html_a1dd51949401094f71d10429d45779d53"><div class="ttname"><a href="nuklear_8h.html#a1dd51949401094f71d10429d45779d53">nk_input_begin</a></div><div class="ttdeci">NK_API void nk_input_begin(struct nk_context *)</div><div class="ttdoc">Begins the input mirroring process by resetting text, scroll mouse, previous mouse position and movem...</div><div class="ttdef"><b>Definition</b> <a href="nuklear__input_8c_source.html#l00010">nuklear_input.c:10</a></div></div>
  149. <div class="ttc" id="anuklear_8h_html_a76e65dc775c0bd5efaa3c8f38f96823f"><div class="ttname"><a href="nuklear_8h.html#a76e65dc775c0bd5efaa3c8f38f96823f">nk_layout_row_dynamic</a></div><div class="ttdeci">NK_API void nk_layout_row_dynamic(struct nk_context *ctx, float height, int cols)</div><div class="ttdoc">Sets current row layout to share horizontal space between @cols number of widgets evenly.</div><div class="ttdef"><b>Definition</b> <a href="nuklear__layout_8c_source.html#l00147">nuklear_layout.c:147</a></div></div>
  150. <div class="ttc" id="anuklear_8h_html_aaca7101364db82c0f03401fafd2c66a6"><div class="ttname"><a href="nuklear_8h.html#aaca7101364db82c0f03401fafd2c66a6">nk_foreach</a></div><div class="ttdeci">#define nk_foreach(c, ctx)</div><div class="ttdoc">Iterates over each draw command inside the context draw command list.</div><div class="ttdef"><b>Definition</b> <a href="nuklear_8h_source.html#l01031">nuklear.h:1031</a></div></div>
  151. <div class="ttc" id="anuklear_8h_html_acdbdc5795b24d36875281cf3cac671fe"><div class="ttname"><a href="nuklear_8h.html#acdbdc5795b24d36875281cf3cac671fe">nk_input_motion</a></div><div class="ttdeci">NK_API void nk_input_motion(struct nk_context *, int x, int y)</div><div class="ttdoc">Mirrors current mouse position to nuklear.</div><div class="ttdef"><b>Definition</b> <a href="nuklear__input_8c_source.html#l00045">nuklear_input.c:45</a></div></div>
  152. <div class="ttc" id="anuklear_8h_html_ade3301f0a92370be1b4beac7eceac279"><div class="ttname"><a href="nuklear_8h.html#ade3301f0a92370be1b4beac7eceac279">nk_clear</a></div><div class="ttdeci">NK_API void nk_clear(struct nk_context *)</div><div class="ttdoc">Resets the context state at the end of the frame.</div><div class="ttdef"><b>Definition</b> <a href="nuklear__context_8c_source.html#l00110">nuklear_context.c:110</a></div></div>
  153. <div class="ttc" id="anuklear_8h_html_ae0ade48c4c8df72456b9d97ab3d195e3"><div class="ttname"><a href="nuklear_8h.html#ae0ade48c4c8df72456b9d97ab3d195e3">nk_end</a></div><div class="ttdeci">NK_API void nk_end(struct nk_context *ctx)</div><div class="ttdef"><b>Definition</b> <a href="nuklear__window_8c_source.html#l00297">nuklear_window.c:297</a></div></div>
  154. <div class="ttc" id="astructnk__command_html"><div class="ttname"><a href="structnk__command.html">nk_command</a></div><div class="ttdoc">command base and header of every command inside the buffer</div><div class="ttdef"><b>Definition</b> <a href="nuklear_8h_source.html#l04467">nuklear.h:4467</a></div></div>
  155. <div class="ttc" id="astructnk__context_html"><div class="ttname"><a href="structnk__context.html">nk_context</a></div><div class="ttdef"><b>Definition</b> <a href="nuklear_8h_source.html#l05705">nuklear.h:5705</a></div></div>
  156. </div><!-- fragment --><h1><a class="anchor" id="autotoc_md95"></a>
  157. Reference</h1>
  158. <table class="markdownTable">
  159. <tr class="markdownTableHead">
  160. <th class="markdownTableHeadNone">Function </th><th class="markdownTableHeadNone">Description </th></tr>
  161. <tr class="markdownTableRowOdd">
  162. <td class="markdownTableBodyNone">nk_property_int </td><td class="markdownTableBodyNone">Integer property directly modifying a passed in value </td></tr>
  163. <tr class="markdownTableRowEven">
  164. <td class="markdownTableBodyNone"><a class="el" href="nuklear_8h.html#a2ad0b76d6b0b29ba37ca1777953d4f89">nk_property_float</a> </td><td class="markdownTableBodyNone">Float property directly modifying a passed in value </td></tr>
  165. <tr class="markdownTableRowOdd">
  166. <td class="markdownTableBodyNone"><a class="el" href="nuklear_8h.html#a6078e0bd051eadbaab18f5acea38e516">nk_property_double</a> </td><td class="markdownTableBodyNone">Double property directly modifying a passed in value </td></tr>
  167. <tr class="markdownTableRowEven">
  168. <td class="markdownTableBodyNone"><a class="el" href="nuklear_8h.html#af079769a8700d947492b8b08977eeca2">nk_propertyi</a> </td><td class="markdownTableBodyNone">Integer property returning the modified int value </td></tr>
  169. <tr class="markdownTableRowOdd">
  170. <td class="markdownTableBodyNone"><a class="el" href="nuklear_8h.html#a2030121357983cfabd73fadb997dbf04">nk_propertyf</a> </td><td class="markdownTableBodyNone">Float property returning the modified float value </td></tr>
  171. <tr class="markdownTableRowEven">
  172. <td class="markdownTableBodyNone"><a class="el" href="nuklear_8h.html#ac5840ee35a5f6fcb30a086cf72afd991">nk_propertyd</a> </td><td class="markdownTableBodyNone">Double property returning the modified double value </td></tr>
  173. </table>
  174. <h1><a class="anchor" id="autotoc_md96"></a>
  175. # nk_property_int</h1>
  176. <p>Integer property directly modifying a passed in value !!! </p><dl class="section warning"><dt>Warning</dt><dd>To generate a unique property ID using the same label make sure to insert a <code>#</code> at the beginning. It will not be shown but guarantees correct behavior.</dd></dl>
  177. <div class="fragment"><div class="line"><span class="keywordtype">void</span> nk_property_int(<span class="keyword">struct</span> <a class="code hl_struct" href="structnk__context.html">nk_context</a> *ctx, <span class="keyword">const</span> <span class="keywordtype">char</span> *name, <span class="keywordtype">int</span> min, <span class="keywordtype">int</span> *val, <span class="keywordtype">int</span> max, <span class="keywordtype">int</span> step, <span class="keywordtype">float</span> inc_per_pixel);</div>
  178. </div><!-- fragment --><table class="markdownTable">
  179. <tr class="markdownTableHead">
  180. <th class="markdownTableHeadNone">Parameter </th><th class="markdownTableHeadNone">Description </th></tr>
  181. <tr class="markdownTableRowOdd">
  182. <td class="markdownTableBodyNone"><dl class="params"><dt>Parameters</dt><dd>
  183. <table class="params">
  184. <tr><td class="paramdir">[in]</td><td class="paramname">ctx</td><td></td></tr>
  185. </table>
  186. </dd>
  187. </dl>
  188. </td><td class="markdownTableBodyNone">Must point to an previously initialized <code><a class="el" href="structnk__context.html">nk_context</a></code> struct after calling a layouting function </td></tr>
  189. <tr class="markdownTableRowEven">
  190. <td class="markdownTableBodyNone"><dl class="params"><dt>Parameters</dt><dd>
  191. <table class="params">
  192. <tr><td class="paramdir">[in]</td><td class="paramname">name</td><td></td></tr>
  193. </table>
  194. </dd>
  195. </dl>
  196. </td><td class="markdownTableBodyNone">String used both as a label as well as a unique identifier </td></tr>
  197. <tr class="markdownTableRowOdd">
  198. <td class="markdownTableBodyNone"><dl class="params"><dt>Parameters</dt><dd>
  199. <table class="params">
  200. <tr><td class="paramdir">[in]</td><td class="paramname">min</td><td></td></tr>
  201. </table>
  202. </dd>
  203. </dl>
  204. </td><td class="markdownTableBodyNone">Minimum value not allowed to be underflown </td></tr>
  205. <tr class="markdownTableRowEven">
  206. <td class="markdownTableBodyNone"><dl class="params"><dt>Parameters</dt><dd>
  207. <table class="params">
  208. <tr><td class="paramdir">[in]</td><td class="paramname">val</td><td></td></tr>
  209. </table>
  210. </dd>
  211. </dl>
  212. </td><td class="markdownTableBodyNone">Integer pointer to be modified </td></tr>
  213. <tr class="markdownTableRowOdd">
  214. <td class="markdownTableBodyNone"><dl class="params"><dt>Parameters</dt><dd>
  215. <table class="params">
  216. <tr><td class="paramdir">[in]</td><td class="paramname">max</td><td></td></tr>
  217. </table>
  218. </dd>
  219. </dl>
  220. </td><td class="markdownTableBodyNone">Maximum value not allowed to be overflown </td></tr>
  221. <tr class="markdownTableRowEven">
  222. <td class="markdownTableBodyNone"><dl class="params"><dt>Parameters</dt><dd>
  223. <table class="params">
  224. <tr><td class="paramdir">[in]</td><td class="paramname">step</td><td></td></tr>
  225. </table>
  226. </dd>
  227. </dl>
  228. </td><td class="markdownTableBodyNone">Increment added and subtracted on increment and decrement button </td></tr>
  229. <tr class="markdownTableRowOdd">
  230. <td class="markdownTableBodyNone"><dl class="params"><dt>Parameters</dt><dd>
  231. <table class="params">
  232. <tr><td class="paramdir">[in]</td><td class="paramname">inc_per_pixel</td><td></td></tr>
  233. </table>
  234. </dd>
  235. </dl>
  236. </td><td class="markdownTableBodyNone">Value per pixel added or subtracted on dragging </td></tr>
  237. </table>
  238. </div></div><!-- contents -->
  239. </div><!-- PageDoc -->
  240. </div><!-- doc-content -->
  241. <!-- start footer part -->
  242. <div id="nav-path" class="navpath"><!-- id is needed for treeview function! -->
  243. <ul>
  244. <li class="footer">Generated by <a href="https://www.doxygen.org/index.html"><img class="footer" src="doxygen.svg" width="104" height="31" alt="doxygen"/></a> 1.9.8 </li>
  245. </ul>
  246. </div>
  247. </body>
  248. </html>