Groups.html 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200
  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: Groups</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('Groups.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">Groups</div></div>
  99. </div><!--header-->
  100. <div class="contents">
  101. <div class="textblock"><p>=============================================================================</p>
  102. <pre class="fragment"> GROUP
  103. </pre><p> =============================================================================</p>
  104. <p>Groups are basically windows inside windows. They allow to subdivide space in a window to layout widgets as a group. Almost all more complex widget layouting requirements can be solved using groups and basic layouting fuctionality. Groups just like windows are identified by an unique name and internally keep track of scrollbar offsets by default. However additional versions are provided to directly manage the scrollbar.</p>
  105. <h1><a class="anchor" id="autotoc_md73"></a>
  106. Usage</h1>
  107. <p>To create a group you have to call one of the three <code>nk_group_begin_xxx</code> functions to start group declarations and <code>nk_group_end</code> at the end. Furthermore it is required to check the return value of <code>nk_group_begin_xxx</code> and only process widgets inside the window if the value is not 0. Nesting groups is possible and even encouraged since many layouting schemes can only be achieved by nesting. Groups, unlike windows, need <code>nk_group_end</code> to be only called if the corresponding <code>nk_group_begin_xxx</code> call does not return 0:</p>
  108. <div class="fragment"><div class="line"><span class="keywordflow">if</span> (nk_group_begin_xxx(ctx, ...) {</div>
  109. <div class="line"> <span class="comment">// [... widgets ...]</span></div>
  110. <div class="line"> <a class="code hl_function" href="nuklear_8h.html#ae0e5210696cae430a9e9b79e1f76cee5">nk_group_end</a>(ctx);</div>
  111. <div class="line">}</div>
  112. <div class="ttc" id="anuklear_8h_html_ae0e5210696cae430a9e9b79e1f76cee5"><div class="ttname"><a href="nuklear_8h.html#ae0e5210696cae430a9e9b79e1f76cee5">nk_group_end</a></div><div class="ttdeci">NK_API void nk_group_end(struct nk_context *)</div><div class="ttdef"><b>Definition</b> <a href="nuklear__group_8c_source.html#l00165">nuklear_group.c:165</a></div></div>
  113. </div><!-- fragment --><p>In the grand concept groups can be called after starting a window with <code>nk_begin_xxx</code> and before calling <code>nk_end</code>:</p>
  114. <div class="fragment"><div class="line"><span class="keyword">struct </span><a class="code hl_struct" href="structnk__context.html">nk_context</a> ctx;</div>
  115. <div class="line">nk_init_xxx(&amp;ctx, ...);</div>
  116. <div class="line"><span class="keywordflow">while</span> (1) {</div>
  117. <div class="line"> <span class="comment">// Input</span></div>
  118. <div class="line"> Event evt;</div>
  119. <div class="line"> <a class="code hl_function" href="nuklear_8h.html#a1dd51949401094f71d10429d45779d53">nk_input_begin</a>(&amp;ctx);</div>
  120. <div class="line"> <span class="keywordflow">while</span> (GetEvent(&amp;evt)) {</div>
  121. <div class="line"> <span class="keywordflow">if</span> (evt.type == MOUSE_MOVE)</div>
  122. <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>
  123. <div class="line"> <span class="keywordflow">else</span> <span class="keywordflow">if</span> (evt.type == [...]) {</div>
  124. <div class="line"> nk_input_xxx(...);</div>
  125. <div class="line"> }</div>
  126. <div class="line"> }</div>
  127. <div class="line"> <a class="code hl_function" href="nuklear_8h.html#a15c0d237b6bb2f5195a09e259fd7b375">nk_input_end</a>(&amp;ctx);</div>
  128. <div class="line"> <span class="comment">//</span></div>
  129. <div class="line"> <span class="comment">// Window</span></div>
  130. <div class="line"> <span class="keywordflow">if</span> (nk_begin_xxx(...) {</div>
  131. <div class="line"> <span class="comment">// [...widgets...]</span></div>
  132. <div class="line"> <a class="code hl_function" href="nuklear_8h.html#a76e65dc775c0bd5efaa3c8f38f96823f">nk_layout_row_dynamic</a>(...);</div>
  133. <div class="line"> <span class="keywordflow">if</span> (nk_group_begin_xxx(ctx, ...) {</div>
  134. <div class="line"> <span class="comment">//[... widgets ...]</span></div>
  135. <div class="line"> <a class="code hl_function" href="nuklear_8h.html#ae0e5210696cae430a9e9b79e1f76cee5">nk_group_end</a>(ctx);</div>
  136. <div class="line"> }</div>
  137. <div class="line"> }</div>
  138. <div class="line"> <a class="code hl_function" href="nuklear_8h.html#ae0ade48c4c8df72456b9d97ab3d195e3">nk_end</a>(ctx);</div>
  139. <div class="line"> <span class="comment">//</span></div>
  140. <div class="line"> <span class="comment">// Draw</span></div>
  141. <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>
  142. <div class="line"> <a class="code hl_define" href="nuklear_8h.html#aaca7101364db82c0f03401fafd2c66a6">nk_foreach</a>(cmd, &amp;ctx) {</div>
  143. <div class="line"> <span class="keywordflow">switch</span> (cmd-&gt;type) {</div>
  144. <div class="line"> <span class="keywordflow">case</span> NK_COMMAND_LINE:</div>
  145. <div class="line"> your_draw_line_function(...)</div>
  146. <div class="line"> break;</div>
  147. <div class="line"> case NK_COMMAND_RECT</div>
  148. <div class="line"> your_draw_rect_function(...)</div>
  149. <div class="line"> break;</div>
  150. <div class="line"> case ...:</div>
  151. <div class="line"> <span class="comment">// [...]</span></div>
  152. <div class="line"> }</div>
  153. <div class="line"> <a class="code hl_function" href="nuklear_8h.html#ade3301f0a92370be1b4beac7eceac279">nk_clear</a>(&amp;ctx);</div>
  154. <div class="line">}</div>
  155. <div class="line"><a class="code hl_function" href="nuklear_8h.html#a06772e194320fa99524681fd32df85e9">nk_free</a>(&amp;ctx);</div>
  156. <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>
  157. <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>
  158. <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>
  159. <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>
  160. <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>
  161. <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>
  162. <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>
  163. <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>
  164. <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>
  165. <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>
  166. </div><!-- fragment --> <h1><a class="anchor" id="autotoc_md74"></a>
  167. Reference</h1>
  168. <table class="markdownTable">
  169. <tr class="markdownTableHead">
  170. <th class="markdownTableHeadNone">Function </th><th class="markdownTableHeadNone">Description </th></tr>
  171. <tr class="markdownTableRowOdd">
  172. <td class="markdownTableBodyNone"><a class="el" href="nuklear_8h.html#a09a50849fef9426cf7a9ad9960b1486a">nk_group_begin</a> </td><td class="markdownTableBodyNone">Start a new group with internal scrollbar handling </td></tr>
  173. <tr class="markdownTableRowEven">
  174. <td class="markdownTableBodyNone"><a class="el" href="nuklear_8h.html#aa8ab5670480005694241e37b188d8e06">nk_group_begin_titled</a> </td><td class="markdownTableBodyNone">Start a new group with separated name and title and internal scrollbar handling </td></tr>
  175. <tr class="markdownTableRowOdd">
  176. <td class="markdownTableBodyNone"><a class="el" href="nuklear_8h.html#ae0e5210696cae430a9e9b79e1f76cee5">nk_group_end</a> </td><td class="markdownTableBodyNone">Ends a group. Should only be called if nk_group_begin returned non-zero </td></tr>
  177. <tr class="markdownTableRowEven">
  178. <td class="markdownTableBodyNone"><a class="el" href="nuklear_8h.html#a6adb72deb66e2714d654c8d57bd277b5">nk_group_scrolled_offset_begin</a> </td><td class="markdownTableBodyNone">Start a new group with manual separated handling of scrollbar x- and y-offset </td></tr>
  179. <tr class="markdownTableRowOdd">
  180. <td class="markdownTableBodyNone"><a class="el" href="nuklear_8h.html#af17d78936039c79f6fe91a4c70d253e2">nk_group_scrolled_begin</a> </td><td class="markdownTableBodyNone">Start a new group with manual scrollbar handling </td></tr>
  181. <tr class="markdownTableRowEven">
  182. <td class="markdownTableBodyNone"><a class="el" href="nuklear_8h.html#a4552d30d3265ccff7c82232da3cea657">nk_group_scrolled_end</a> </td><td class="markdownTableBodyNone">Ends a group with manual scrollbar handling. Should only be called if nk_group_begin returned non-zero </td></tr>
  183. <tr class="markdownTableRowOdd">
  184. <td class="markdownTableBodyNone"><a class="el" href="nuklear_8h.html#a4cdbee562347fba0fae90b8250274d96">nk_group_get_scroll</a> </td><td class="markdownTableBodyNone">Gets the scroll offset for the given group </td></tr>
  185. <tr class="markdownTableRowEven">
  186. <td class="markdownTableBodyNone"><a class="el" href="nuklear_8h.html#ab26b83016c296e5ed1f4c6dc79bd5cd1">nk_group_set_scroll</a> </td><td class="markdownTableBodyNone">Sets the scroll offset for the given group </td></tr>
  187. </table>
  188. </div></div><!-- contents -->
  189. </div><!-- PageDoc -->
  190. </div><!-- doc-content -->
  191. <!-- start footer part -->
  192. <div id="nav-path" class="navpath"><!-- id is needed for treeview function! -->
  193. <ul>
  194. <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>
  195. </ul>
  196. </div>
  197. </body>
  198. </html>