mirror of
https://github.com/Immediate-Mode-UI/Nuklear.git
synced 2026-11-30 16:48:10 +01:00
298 lines
21 KiB
HTML
298 lines
21 KiB
HTML
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
|
<html xmlns="http://www.w3.org/1999/xhtml" lang="en-US">
|
|
<head>
|
|
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
|
|
<meta http-equiv="X-UA-Compatible" content="IE=11"/>
|
|
<meta name="generator" content="Doxygen 1.15.0"/>
|
|
<meta name="viewport" content="width=device-width, initial-scale=1"/>
|
|
<title>Nuklear: Window</title>
|
|
<link href="tabs.css" rel="stylesheet" type="text/css"/>
|
|
<script type="text/javascript" src="jquery.js"></script>
|
|
<script type="text/javascript" src="dynsections.js"></script>
|
|
<script type="text/javascript" src="clipboard.js"></script>
|
|
<link href="navtree.css" rel="stylesheet" type="text/css"/>
|
|
<script type="text/javascript" src="navtreedata.js"></script>
|
|
<script type="text/javascript" src="navtree.js"></script>
|
|
<script type="text/javascript" src="cookie.js"></script>
|
|
<link href="search/search.css" rel="stylesheet" type="text/css"/>
|
|
<script type="text/javascript" src="search/searchdata.js"></script>
|
|
<script type="text/javascript" src="search/search.js"></script>
|
|
<script type="text/javascript">
|
|
$(function() { init_search(); });
|
|
</script>
|
|
<link href="doxygen.css" rel="stylesheet" type="text/css" />
|
|
<link href="doxygen-awesome.css" rel="stylesheet" type="text/css"/>
|
|
</head>
|
|
<body>
|
|
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
|
|
<div id="titlearea">
|
|
<table cellspacing="0" cellpadding="0">
|
|
<tbody>
|
|
<tr id="projectrow">
|
|
<td id="projectalign">
|
|
<div id="projectname">Nuklear
|
|
</div>
|
|
<div id="projectbrief">Minimal-state, immediate-mode graphical user interface toolkit written in ANSI C.</div>
|
|
</td>
|
|
<td> <div id="MSearchBox" class="MSearchBoxInactive">
|
|
<span class="left">
|
|
<span id="MSearchSelect" class="search-icon" onmouseover="return searchBox.OnSearchSelectShow()" onmouseout="return searchBox.OnSearchSelectHide()"><span class="search-icon-dropdown"></span></span>
|
|
<input type="text" id="MSearchField" value="" placeholder="Search" accesskey="S"
|
|
onfocus="searchBox.OnSearchFieldFocus(true)"
|
|
onblur="searchBox.OnSearchFieldFocus(false)"
|
|
onkeyup="searchBox.OnSearchFieldChange(event)"/>
|
|
</span><span class="right">
|
|
<a id="MSearchClose" href="javascript:searchBox.CloseResultsWindow()"><div id="MSearchCloseImg" class="close-icon"></div></a>
|
|
</span>
|
|
</div>
|
|
</td>
|
|
</tr>
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
<!-- end header part -->
|
|
<!-- Generated by Doxygen 1.15.0 -->
|
|
<script type="text/javascript">
|
|
var searchBox = new SearchBox("searchBox", "search/",'.html');
|
|
</script>
|
|
<script type="text/javascript">
|
|
$(function() { codefold.init(); });
|
|
</script>
|
|
</div><!-- top -->
|
|
<div id="side-nav" class="ui-resizable side-nav-resizable">
|
|
<div id="nav-tree">
|
|
<div id="nav-tree-contents">
|
|
<div id="nav-sync" class="sync"></div>
|
|
</div>
|
|
</div>
|
|
<div id="splitbar" style="-moz-user-select:none;"
|
|
class="ui-resizable-handle">
|
|
</div>
|
|
</div>
|
|
<script type="text/javascript">
|
|
$(function(){initNavTree('Window.html','',''); });
|
|
</script>
|
|
<div id="container">
|
|
<div id="doc-content">
|
|
<!-- window showing the filter options -->
|
|
<div id="MSearchSelectWindow"
|
|
onmouseover="return searchBox.OnSearchSelectShow()"
|
|
onmouseout="return searchBox.OnSearchSelectHide()"
|
|
onkeydown="return searchBox.OnSearchSelectKey(event)">
|
|
</div>
|
|
|
|
<!-- iframe showing the search results (closed by default) -->
|
|
<div id="MSearchResultsWindow">
|
|
<div id="MSearchResults">
|
|
<div class="SRPage">
|
|
<div id="SRIndex">
|
|
<div id="SRResults"></div>
|
|
<div class="SRStatus" id="Loading">Loading...</div>
|
|
<div class="SRStatus" id="Searching">Searching...</div>
|
|
<div class="SRStatus" id="NoMatches">No Matches</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<div><div class="header">
|
|
<div class="headertitle"><div class="title">Window </div></div>
|
|
</div><!--header-->
|
|
<div class="contents">
|
|
<div class="textblock"><p>Windows are the main persistent state used inside nuklear and are life time controlled by simply "retouching" (i.e. calling) each window each frame.</p>
|
|
<p>All widgets inside nuklear can only be added inside the function pair <span class="tt">nk_begin_xxx</span> and <span class="tt">nk_end</span>. Calling any widgets outside these two functions will result in an assert in debug or no state change in release mode.<br />
|
|
<br />
|
|
</p>
|
|
<p>Each window holds frame persistent state like position, size, flags, state tables, and some garbage collected internal persistent widget state. Each window is linked into a window stack list which determines the drawing and overlapping order. The topmost window thereby is the currently active window.<br />
|
|
<br />
|
|
</p>
|
|
<p>To change window position inside the stack occurs either automatically by user input by being clicked on or programmatically by calling <span class="tt">nk_window_set_focus</span>. Windows by default are visible unless explicitly being defined with flag <span class="tt">NK_WINDOW_HIDDEN</span>, the user clicked the close button on windows with flag <span class="tt">NK_WINDOW_CLOSABLE</span> or if a window was explicitly hidden by calling <span class="tt">nk_window_show</span>. To explicitly close and destroy a window call <span class="tt">nk_window_close</span>.<br />
|
|
<br />
|
|
</p>
|
|
<h1 class="doxsection"><a class="anchor" id="autotoc_md23"></a>
|
|
Usage</h1>
|
|
<p>To create and keep a window you have to call one of the two <span class="tt">nk_begin_xxx</span> functions to start window declarations and <span class="tt">nk_end</span> at the end. Furthermore it is recommended to check the return value of <span class="tt">nk_begin_xxx</span> and only process widgets inside the window if the value is not 0. Either way you have to call <span class="tt">nk_end</span> at the end of window declarations. Furthermore, do not attempt to nest <span class="tt">nk_begin_xxx</span> calls which will hopefully result in an assert or if not in a segmentation fault.</p>
|
|
<div class="fragment"><div class="line"><span class="keywordflow">if</span> (nk_begin_xxx(...) {</div>
|
|
<div class="line"> <span class="comment">// [... widgets ...]</span></div>
|
|
<div class="line">}</div>
|
|
<div class="line">nk_end(ctx);</div>
|
|
</div><!-- fragment --><p>In the grand concept window and widget declarations need to occur after input handling and before drawing to screen. Not doing so can result in higher latency or at worst invalid behavior. Furthermore make sure that <span class="tt">nk_clear</span> is called at the end of the frame. While nuklear's default platform backends already call <span class="tt">nk_clear</span> for you if you write your own backend not calling <span class="tt">nk_clear</span> can cause asserts or even worse undefined behavior.</p>
|
|
<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>
|
|
<div class="line">nk_init_xxx(&ctx, ...);</div>
|
|
<div class="line"><span class="keywordflow">while</span> (1) {</div>
|
|
<div class="line"> Event evt;</div>
|
|
<div class="line"> nk_input_begin(&ctx);</div>
|
|
<div class="line"> <span class="keywordflow">while</span> (GetEvent(&evt)) {</div>
|
|
<div class="line"> <span class="keywordflow">if</span> (evt.type == MOUSE_MOVE)</div>
|
|
<div class="line"> nk_input_motion(&ctx, evt.motion.x, evt.motion.y);</div>
|
|
<div class="line"> <span class="keywordflow">else</span> <span class="keywordflow">if</span> (evt.type == [...]) {</div>
|
|
<div class="line"> nk_input_xxx(...);</div>
|
|
<div class="line"> }</div>
|
|
<div class="line"> }</div>
|
|
<div class="line"> nk_input_end(&ctx);</div>
|
|
<div class="line"> </div>
|
|
<div class="line"> <span class="keywordflow">if</span> (nk_begin_xxx(...) {</div>
|
|
<div class="line"> <span class="comment">//[...]</span></div>
|
|
<div class="line"> }</div>
|
|
<div class="line"> nk_end(ctx);</div>
|
|
<div class="line"> </div>
|
|
<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>
|
|
<div class="line"> nk_foreach(cmd, &ctx) {</div>
|
|
<div class="line"> <span class="keywordflow">case</span> NK_COMMAND_LINE:</div>
|
|
<div class="line"> your_draw_line_function(...)</div>
|
|
<div class="line"> break;</div>
|
|
<div class="line"> case NK_COMMAND_RECT</div>
|
|
<div class="line"> your_draw_rect_function(...)</div>
|
|
<div class="line"> break;</div>
|
|
<div class="line"> case <span class="comment">//...:</span></div>
|
|
<div class="line"> <span class="comment">//[...]</span></div>
|
|
<div class="line"> }</div>
|
|
<div class="line"> nk_clear(&ctx);</div>
|
|
<div class="line">}</div>
|
|
<div class="line">nk_free(&ctx);</div>
|
|
<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#l04577">nuklear.h:4577</a></div></div>
|
|
<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#l05843">nuklear.h:5843</a></div></div>
|
|
</div><!-- fragment --><h1 class="doxsection"><a class="anchor" id="autotoc_md24"></a>
|
|
Reference</h1>
|
|
<table class="markdownTable">
|
|
<tr class="markdownTableHead">
|
|
<th class="markdownTableHeadNone">Function </th><th class="markdownTableHeadNone">Description </th></tr>
|
|
<tr class="markdownTableRowOdd">
|
|
<td class="markdownTableBodyNone">nk_begin </td><td class="markdownTableBodyNone">Starts a new window; needs to be called every frame for every window (unless hidden) or otherwise the window gets removed </td></tr>
|
|
<tr class="markdownTableRowEven">
|
|
<td class="markdownTableBodyNone">nk_begin_titled </td><td class="markdownTableBodyNone">Extended window start with separated title and identifier to allow multiple windows with same name but not title </td></tr>
|
|
<tr class="markdownTableRowOdd">
|
|
<td class="markdownTableBodyNone">nk_end </td><td class="markdownTableBodyNone">Needs to be called at the end of the window building process to process scaling, scrollbars and general cleanup </td></tr>
|
|
</table>
|
|
<table class="markdownTable">
|
|
<tr class="markdownTableHead">
|
|
<th class="markdownTableHeadNone">Function </th><th class="markdownTableHeadNone">Description </th></tr>
|
|
<tr class="markdownTableRowOdd">
|
|
<td class="markdownTableBodyNone">nk_window_find </td><td class="markdownTableBodyNone">Finds and returns the window with give name </td></tr>
|
|
<tr class="markdownTableRowEven">
|
|
<td class="markdownTableBodyNone">nk_window_get_bounds </td><td class="markdownTableBodyNone">Returns a rectangle with screen position and size of the currently processed window. </td></tr>
|
|
<tr class="markdownTableRowOdd">
|
|
<td class="markdownTableBodyNone">nk_window_get_position </td><td class="markdownTableBodyNone">Returns the position of the currently processed window </td></tr>
|
|
<tr class="markdownTableRowEven">
|
|
<td class="markdownTableBodyNone">nk_window_get_size </td><td class="markdownTableBodyNone">Returns the size with width and height of the currently processed window </td></tr>
|
|
<tr class="markdownTableRowOdd">
|
|
<td class="markdownTableBodyNone">nk_window_get_width </td><td class="markdownTableBodyNone">Returns the width of the currently processed window </td></tr>
|
|
<tr class="markdownTableRowEven">
|
|
<td class="markdownTableBodyNone">nk_window_get_height </td><td class="markdownTableBodyNone">Returns the height of the currently processed window </td></tr>
|
|
<tr class="markdownTableRowOdd">
|
|
<td class="markdownTableBodyNone">nk_window_get_panel </td><td class="markdownTableBodyNone">Returns the underlying panel which contains all processing state of the current window </td></tr>
|
|
<tr class="markdownTableRowEven">
|
|
<td class="markdownTableBodyNone">nk_window_get_content_region </td><td class="markdownTableBodyNone">Returns the position and size of the currently visible and non-clipped space inside the currently processed window </td></tr>
|
|
<tr class="markdownTableRowOdd">
|
|
<td class="markdownTableBodyNone">nk_window_get_content_region_min </td><td class="markdownTableBodyNone">Returns the upper rectangle position of the currently visible and non-clipped space inside the currently processed window </td></tr>
|
|
<tr class="markdownTableRowEven">
|
|
<td class="markdownTableBodyNone">nk_window_get_content_region_max </td><td class="markdownTableBodyNone">Returns the upper rectangle position of the currently visible and non-clipped space inside the currently processed window </td></tr>
|
|
<tr class="markdownTableRowOdd">
|
|
<td class="markdownTableBodyNone">nk_window_get_content_region_size </td><td class="markdownTableBodyNone">Returns the size of the currently visible and non-clipped space inside the currently processed window </td></tr>
|
|
<tr class="markdownTableRowEven">
|
|
<td class="markdownTableBodyNone">nk_window_get_canvas </td><td class="markdownTableBodyNone">Returns the draw command buffer. Can be used to draw custom widgets </td></tr>
|
|
<tr class="markdownTableRowOdd">
|
|
<td class="markdownTableBodyNone">nk_window_get_scroll </td><td class="markdownTableBodyNone">Gets the scroll offset of the current window </td></tr>
|
|
<tr class="markdownTableRowEven">
|
|
<td class="markdownTableBodyNone">nk_window_has_focus </td><td class="markdownTableBodyNone">Returns if the currently processed window is currently active </td></tr>
|
|
<tr class="markdownTableRowOdd">
|
|
<td class="markdownTableBodyNone">nk_window_is_collapsed </td><td class="markdownTableBodyNone">Returns if the window with given name is currently minimized/collapsed </td></tr>
|
|
<tr class="markdownTableRowEven">
|
|
<td class="markdownTableBodyNone">nk_window_is_closed </td><td class="markdownTableBodyNone">Returns if the currently processed window was closed </td></tr>
|
|
<tr class="markdownTableRowOdd">
|
|
<td class="markdownTableBodyNone">nk_window_is_hidden </td><td class="markdownTableBodyNone">Returns if the currently processed window was hidden </td></tr>
|
|
<tr class="markdownTableRowEven">
|
|
<td class="markdownTableBodyNone">nk_window_is_active </td><td class="markdownTableBodyNone">Same as nk_window_has_focus for some reason </td></tr>
|
|
<tr class="markdownTableRowOdd">
|
|
<td class="markdownTableBodyNone">nk_window_is_hovered </td><td class="markdownTableBodyNone">Returns if the currently processed window is currently being hovered by mouse </td></tr>
|
|
<tr class="markdownTableRowEven">
|
|
<td class="markdownTableBodyNone">nk_window_is_any_hovered </td><td class="markdownTableBodyNone">Return if any window currently hovered </td></tr>
|
|
<tr class="markdownTableRowOdd">
|
|
<td class="markdownTableBodyNone">nk_item_is_any_active </td><td class="markdownTableBodyNone">Returns if any window or widgets is currently hovered or active </td></tr>
|
|
</table>
|
|
<table class="markdownTable">
|
|
<tr class="markdownTableHead">
|
|
<th class="markdownTableHeadNone">Function </th><th class="markdownTableHeadNone">Description </th></tr>
|
|
<tr class="markdownTableRowOdd">
|
|
<td class="markdownTableBodyNone">nk_window_set_bounds </td><td class="markdownTableBodyNone">Updates position and size of the currently processed window </td></tr>
|
|
<tr class="markdownTableRowEven">
|
|
<td class="markdownTableBodyNone">nk_window_set_position </td><td class="markdownTableBodyNone">Updates position of the currently process window </td></tr>
|
|
<tr class="markdownTableRowOdd">
|
|
<td class="markdownTableBodyNone">nk_window_set_size </td><td class="markdownTableBodyNone">Updates the size of the currently processed window </td></tr>
|
|
<tr class="markdownTableRowEven">
|
|
<td class="markdownTableBodyNone">nk_window_set_focus </td><td class="markdownTableBodyNone">Set the currently processed window as active window </td></tr>
|
|
<tr class="markdownTableRowOdd">
|
|
<td class="markdownTableBodyNone">nk_window_set_scroll </td><td class="markdownTableBodyNone">Sets the scroll offset of the current window </td></tr>
|
|
</table>
|
|
<table class="markdownTable">
|
|
<tr class="markdownTableHead">
|
|
<th class="markdownTableHeadNone">Function </th><th class="markdownTableHeadNone">Description </th></tr>
|
|
<tr class="markdownTableRowOdd">
|
|
<td class="markdownTableBodyNone">nk_window_close </td><td class="markdownTableBodyNone">Closes the window with given window name which deletes the window at the end of the frame </td></tr>
|
|
<tr class="markdownTableRowEven">
|
|
<td class="markdownTableBodyNone">nk_window_collapse </td><td class="markdownTableBodyNone">Collapses the window with given window name </td></tr>
|
|
<tr class="markdownTableRowOdd">
|
|
<td class="markdownTableBodyNone">nk_window_collapse_if </td><td class="markdownTableBodyNone">Collapses the window with given window name if the given condition was met </td></tr>
|
|
<tr class="markdownTableRowEven">
|
|
<td class="markdownTableBodyNone">nk_window_show </td><td class="markdownTableBodyNone">Hides a visible or reshows a hidden window </td></tr>
|
|
<tr class="markdownTableRowOdd">
|
|
<td class="markdownTableBodyNone">nk_window_show_if </td><td class="markdownTableBodyNone">Hides/shows a window depending on condition </td></tr>
|
|
</table>
|
|
<h1 class="doxsection"><a class="anchor" id="autotoc_md25"></a>
|
|
nk_panel_flags</h1>
|
|
<table class="markdownTable">
|
|
<tr class="markdownTableHead">
|
|
<th class="markdownTableHeadNone">Flag </th><th class="markdownTableHeadNone">Description </th></tr>
|
|
<tr class="markdownTableRowOdd">
|
|
<td class="markdownTableBodyNone">NK_WINDOW_BORDER </td><td class="markdownTableBodyNone">Draws a border around the window to visually separate window from the background </td></tr>
|
|
<tr class="markdownTableRowEven">
|
|
<td class="markdownTableBodyNone">NK_WINDOW_MOVABLE </td><td class="markdownTableBodyNone">The movable flag indicates that a window can be moved by user input or by dragging the window header </td></tr>
|
|
<tr class="markdownTableRowOdd">
|
|
<td class="markdownTableBodyNone">NK_WINDOW_SCALABLE </td><td class="markdownTableBodyNone">The scalable flag indicates that a window can be scaled by user input by dragging a scaler icon at the button of the window </td></tr>
|
|
<tr class="markdownTableRowEven">
|
|
<td class="markdownTableBodyNone">NK_WINDOW_CLOSABLE </td><td class="markdownTableBodyNone">Adds a closable icon into the header </td></tr>
|
|
<tr class="markdownTableRowOdd">
|
|
<td class="markdownTableBodyNone">NK_WINDOW_MINIMIZABLE </td><td class="markdownTableBodyNone">Adds a minimize icon into the header </td></tr>
|
|
<tr class="markdownTableRowEven">
|
|
<td class="markdownTableBodyNone">NK_WINDOW_NO_SCROLLBAR </td><td class="markdownTableBodyNone">Removes the scrollbar from the window </td></tr>
|
|
<tr class="markdownTableRowOdd">
|
|
<td class="markdownTableBodyNone">NK_WINDOW_TITLE </td><td class="markdownTableBodyNone">Forces a header at the top at the window showing the title </td></tr>
|
|
<tr class="markdownTableRowEven">
|
|
<td class="markdownTableBodyNone">NK_WINDOW_SCROLL_AUTO_HIDE </td><td class="markdownTableBodyNone">Automatically hides the window scrollbar if no user interaction: also requires delta time in <span class="tt"><a class="el" href="structnk__context.html">nk_context</a></span> to be set each frame </td></tr>
|
|
<tr class="markdownTableRowOdd">
|
|
<td class="markdownTableBodyNone">NK_WINDOW_BACKGROUND </td><td class="markdownTableBodyNone">Always keep window in the background </td></tr>
|
|
<tr class="markdownTableRowEven">
|
|
<td class="markdownTableBodyNone">NK_WINDOW_SCALE_LEFT </td><td class="markdownTableBodyNone">Puts window scaler in the left-bottom corner instead right-bottom </td></tr>
|
|
<tr class="markdownTableRowOdd">
|
|
<td class="markdownTableBodyNone">NK_WINDOW_NO_INPUT </td><td class="markdownTableBodyNone">Prevents window of scaling, moving or getting focus </td></tr>
|
|
</table>
|
|
<h1 class="doxsection"><a class="anchor" id="autotoc_md26"></a>
|
|
nk_collapse_states</h1>
|
|
<table class="markdownTable">
|
|
<tr class="markdownTableHead">
|
|
<th class="markdownTableHeadNone">State </th><th class="markdownTableHeadNone">Description </th></tr>
|
|
<tr class="markdownTableRowOdd">
|
|
<td class="markdownTableBodyNone">NK_MINIMIZED </td><td class="markdownTableBodyNone">UI section is collapsed and not visible until maximized </td></tr>
|
|
<tr class="markdownTableRowEven">
|
|
<td class="markdownTableBodyNone">NK_MAXIMIZED </td><td class="markdownTableBodyNone">UI section is extended and visible until minimized </td></tr>
|
|
</table>
|
|
</div></div><!-- contents -->
|
|
</div><!-- PageDoc -->
|
|
</div><!-- doc-content -->
|
|
<div id="page-nav" class="page-nav-panel">
|
|
<div id="page-nav-resize-handle"></div>
|
|
<div id="page-nav-tree">
|
|
<div id="page-nav-contents">
|
|
</div><!-- page-nav-contents -->
|
|
</div><!-- page-nav-tree -->
|
|
</div><!-- page-nav -->
|
|
</div><!-- container -->
|
|
<!-- start footer part -->
|
|
<div id="nav-path" class="navpath"><!-- id is needed for treeview function! -->
|
|
<ul>
|
|
<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.15.0 </li>
|
|
</ul>
|
|
</div>
|
|
</body>
|
|
</html>
|