-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path_g_u_i_canvas_component_8h_source.html
111 lines (109 loc) · 22.4 KB
/
_g_u_i_canvas_component_8h_source.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta name="generator" content="Doxygen 1.8.11"/>
<title>OpenGP: /home/drebain/Workspace/research/OpenGPFork/src/OpenGP/GL/Components/GUICanvasComponent.h Source File</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>
<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">
$(document).ready(function() { init_search(); });
</script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
<link href="style.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 style="height: 56px;">
<td id="projectalign" style="padding-left: 0.5em;">
<div id="projectname">OpenGP
 <span id="projectnumber">1.1</span>
</div>
<div id="projectbrief">Open Geometry Processing Library</div>
</td>
</tr>
</tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.8.11 -->
<script type="text/javascript">
var searchBox = new SearchBox("searchBox", "search",false,'Search');
</script>
<div id="navrow1" class="tabs">
<ul class="tablist">
<li><a href="index.html"><span>Main Page</span></a></li>
<li><a href="tutorial.html"><span>Tutorial</span></a></li>
<li><a href="devel.html"><span>Development</span></a></li>
<li><a href="annotated.html"><span>Reference Manual</span></a></li>
<li><a href="https://github.com/OpenGP/OpenGP/issues"><span>Report Bug</span></a></li>
<li>
<div id="MSearchBox" class="MSearchBoxInactive">
<span class="left">
<img id="MSearchSelect" src="search/mag_sel.png"
onmouseover="return searchBox.OnSearchSelectShow()"
onmouseout="return searchBox.OnSearchSelectHide()"
alt=""/>
<input type="text" id="MSearchField" value="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()"><img id="MSearchCloseImg" border="0" src="search/close.png" alt=""/></a>
</span>
</div>
</li>
</ul>
</div>
<!-- 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">
<iframe src="javascript:void(0)" frameborder="0"
name="MSearchResults" id="MSearchResults">
</iframe>
</div>
<div id="nav-path" class="navpath">
<ul>
<li class="navelem"><a class="el" href="dir_68267d1309a1af8e8297ef4c3efbcdba.html">src</a></li><li class="navelem"><a class="el" href="dir_ceaee8241810cc418efcd8e45299d116.html">OpenGP</a></li><li class="navelem"><a class="el" href="dir_6a0bf43eddd697684442bde9dbb98fcf.html">GL</a></li><li class="navelem"><a class="el" href="dir_dc92aa175729e999c0f7f9cf7270beab.html">Components</a></li> </ul>
</div>
</div><!-- top -->
<div class="header">
<div class="headertitle">
<div class="title">GUICanvasComponent.h</div> </div>
</div><!--header-->
<div class="contents">
<div class="fragment"><div class="line"><a name="l00001"></a><span class="lineno"> 1</span> <span class="comment">// This Source Code Form is subject to the terms of the Mozilla Public</span></div><div class="line"><a name="l00002"></a><span class="lineno"> 2</span> <span class="comment">// License, v. 2.0. If a copy of the MPL was not distributed with this</span></div><div class="line"><a name="l00003"></a><span class="lineno"> 3</span> <span class="comment">// file, You can obtain one at http://mozilla.org/MPL/2.0/.</span></div><div class="line"><a name="l00004"></a><span class="lineno"> 4</span> </div><div class="line"><a name="l00005"></a><span class="lineno"> 5</span> <span class="preprocessor">#pragma once</span></div><div class="line"><a name="l00006"></a><span class="lineno"> 6</span> </div><div class="line"><a name="l00007"></a><span class="lineno"> 7</span> <span class="preprocessor">#include <OpenGP/GL/Entity.h></span></div><div class="line"><a name="l00008"></a><span class="lineno"> 8</span> <span class="preprocessor">#include <OpenGP/GL/Components/CameraComponent.h></span></div><div class="line"><a name="l00009"></a><span class="lineno"> 9</span> <span class="preprocessor">#include <OpenGP/GL/ImguiRenderer.h></span></div><div class="line"><a name="l00010"></a><span class="lineno"> 10</span> </div><div class="line"><a name="l00011"></a><span class="lineno"> 11</span> </div><div class="line"><a name="l00012"></a><span class="lineno"> 12</span> <span class="comment">//=============================================================================</span></div><div class="line"><a name="l00013"></a><span class="lineno"> 13</span> <span class="keyword">namespace </span><a class="code" href="namespace_open_g_p.html">OpenGP</a> {</div><div class="line"><a name="l00014"></a><span class="lineno"> 14</span> <span class="comment">//=============================================================================</span></div><div class="line"><a name="l00015"></a><span class="lineno"> 15</span> </div><div class="line"><a name="l00017"></a><span class="lineno"><a class="line" href="struct_open_g_p_1_1_g_u_i_element_draw_event.html"> 17</a></span> <span class="keyword">struct </span><a class="code" href="struct_open_g_p_1_1_g_u_i_element_draw_event.html">GUIElementDrawEvent</a> {</div><div class="line"><a name="l00018"></a><span class="lineno"> 18</span>  <a class="code" href="class_open_g_p_1_1_camera_component.html">CameraComponent</a> &camera;</div><div class="line"><a name="l00019"></a><span class="lineno"> 19</span> };</div><div class="line"><a name="l00020"></a><span class="lineno"> 20</span> </div><div class="line"><a name="l00022"></a><span class="lineno"><a class="line" href="class_open_g_p_1_1_g_u_i_canvas_component.html"> 22</a></span> <span class="keyword">class </span><a class="code" href="class_open_g_p_1_1_g_u_i_canvas_component.html">GUICanvasComponent</a> : <span class="keyword">public</span> <a class="code" href="class_open_g_p_1_1_component.html">Component</a>, <span class="keyword">public</span> <a class="code" href="class_open_g_p_1_1_event_provider.html">EventProvider</a> {</div><div class="line"><a name="l00023"></a><span class="lineno"> 23</span> <span class="keyword">private</span>:</div><div class="line"><a name="l00024"></a><span class="lineno"> 24</span> </div><div class="line"><a name="l00025"></a><span class="lineno"> 25</span>  <a class="code" href="class_open_g_p_1_1_event_sentinel.html">EventSentinel</a> sentinel;</div><div class="line"><a name="l00026"></a><span class="lineno"> 26</span> </div><div class="line"><a name="l00027"></a><span class="lineno"> 27</span>  ImguiRenderer renderer;</div><div class="line"><a name="l00028"></a><span class="lineno"> 28</span> </div><div class="line"><a name="l00029"></a><span class="lineno"> 29</span>  <a class="code" href="class_open_g_p_1_1_camera_component.html">CameraComponent</a> *camera = <span class="keyword">nullptr</span>;</div><div class="line"><a name="l00030"></a><span class="lineno"> 30</span> </div><div class="line"><a name="l00031"></a><span class="lineno"> 31</span>  <span class="keywordtype">bool</span> mouse_captured_by_ui = <span class="keyword">false</span>;</div><div class="line"><a name="l00032"></a><span class="lineno"> 32</span> </div><div class="line"><a name="l00033"></a><span class="lineno"> 33</span>  std::function<void()> action;</div><div class="line"><a name="l00034"></a><span class="lineno"> 34</span> </div><div class="line"><a name="l00035"></a><span class="lineno"> 35</span> <span class="keyword">public</span>:</div><div class="line"><a name="l00036"></a><span class="lineno"> 36</span> </div><div class="line"><a name="l00038"></a><span class="lineno"><a class="line" href="class_open_g_p_1_1_g_u_i_canvas_component.html#a6dac6a9e89f428a0f6f2cd69060b8292"> 38</a></span>  <span class="keywordtype">void</span> <a class="code" href="class_open_g_p_1_1_g_u_i_canvas_component.html#a6dac6a9e89f428a0f6f2cd69060b8292">set_camera</a>(<a class="code" href="class_open_g_p_1_1_camera_component.html">CameraComponent</a> &camera) {</div><div class="line"><a name="l00039"></a><span class="lineno"> 39</span> </div><div class="line"><a name="l00041"></a><span class="lineno"> 41</span> </div><div class="line"><a name="l00042"></a><span class="lineno"> 42</span>  <span class="comment">// Clear any old callbacks</span></div><div class="line"><a name="l00043"></a><span class="lineno"> 43</span>  sentinel.<a class="code" href="class_open_g_p_1_1_event_sentinel.html#ac28d3f5469f37a0cb5bcbbdb78c406b2">reset</a>();</div><div class="line"><a name="l00044"></a><span class="lineno"> 44</span> </div><div class="line"><a name="l00045"></a><span class="lineno"> 45</span>  this->camera = &camera;</div><div class="line"><a name="l00046"></a><span class="lineno"> 46</span> </div><div class="line"><a name="l00047"></a><span class="lineno"> 47</span>  camera.<a class="code" href="class_open_g_p_1_1_event_provider.html#a2182fa1f9ca09ada8b0079d793dca96b">add_listener</a><<a class="code" href="struct_open_g_p_1_1_g_u_i_render_event.html">GUIRenderEvent</a>>([<span class="keyword">this</span>](<span class="keyword">const</span> <a class="code" href="struct_open_g_p_1_1_g_u_i_render_event.html">GUIRenderEvent</a> &event){</div><div class="line"><a name="l00048"></a><span class="lineno"> 48</span> </div><div class="line"><a name="l00049"></a><span class="lineno"> 49</span>  <span class="keyword">auto</span> &cam = *(this->camera);</div><div class="line"><a name="l00050"></a><span class="lineno"> 50</span>  <span class="keyword">auto</span> &window = cam.get_window();</div><div class="line"><a name="l00051"></a><span class="lineno"> 51</span> </div><div class="line"><a name="l00052"></a><span class="lineno"> 52</span>  <span class="keywordtype">int</span> width, height;</div><div class="line"><a name="l00053"></a><span class="lineno"> 53</span>  std::tie(width, height) = window.get_size();</div><div class="line"><a name="l00054"></a><span class="lineno"> 54</span> </div><div class="line"><a name="l00055"></a><span class="lineno"> 55</span>  <span class="keyword">auto</span> &io = ImGui::GetIO();</div><div class="line"><a name="l00056"></a><span class="lineno"> 56</span>  <span class="keyword">auto</span> &input = window.get_input();</div><div class="line"><a name="l00057"></a><span class="lineno"> 57</span> </div><div class="line"><a name="l00058"></a><span class="lineno"> 58</span>  io.MousePos = ImVec2(input.mouse_position(0), input.mouse_position(1));</div><div class="line"><a name="l00059"></a><span class="lineno"> 59</span> </div><div class="line"><a name="l00060"></a><span class="lineno"> 60</span>  <span class="keywordflow">for</span> (<span class="keywordtype">int</span> i = 0;i < 3;i++)</div><div class="line"><a name="l00061"></a><span class="lineno"> 61</span>  io.MouseDown[i] = input.get_mouse(i);</div><div class="line"><a name="l00062"></a><span class="lineno"> 62</span> </div><div class="line"><a name="l00063"></a><span class="lineno"> 63</span>  <span class="keywordflow">for</span> (uint32_t codepoint : input.get_text())</div><div class="line"><a name="l00064"></a><span class="lineno"> 64</span>  io.AddInputCharacter(codepoint);</div><div class="line"><a name="l00065"></a><span class="lineno"> 65</span> </div><div class="line"><a name="l00066"></a><span class="lineno"> 66</span>  renderer.begin_frame(width, height);</div><div class="line"><a name="l00067"></a><span class="lineno"> 67</span> </div><div class="line"><a name="l00068"></a><span class="lineno"> 68</span>  ImGuizmo::Enable(!mouse_captured_by_ui);</div><div class="line"><a name="l00069"></a><span class="lineno"> 69</span> </div><div class="line"><a name="l00070"></a><span class="lineno"> 70</span>  <span class="keywordflow">if</span> (action)</div><div class="line"><a name="l00071"></a><span class="lineno"> 71</span>  action();</div><div class="line"><a name="l00072"></a><span class="lineno"> 72</span> </div><div class="line"><a name="l00073"></a><span class="lineno"> 73</span>  <a class="code" href="struct_open_g_p_1_1_g_u_i_element_draw_event.html">GUIElementDrawEvent</a> draw_event = { cam };</div><div class="line"><a name="l00074"></a><span class="lineno"> 74</span> </div><div class="line"><a name="l00075"></a><span class="lineno"> 75</span>  send_event(draw_event);</div><div class="line"><a name="l00076"></a><span class="lineno"> 76</span> </div><div class="line"><a name="l00077"></a><span class="lineno"> 77</span>  renderer.end_frame();</div><div class="line"><a name="l00078"></a><span class="lineno"> 78</span> </div><div class="line"><a name="l00079"></a><span class="lineno"> 79</span>  <span class="keywordflow">if</span> (io.WantCaptureMouse) {</div><div class="line"><a name="l00080"></a><span class="lineno"> 80</span>  window.capture_mouse();</div><div class="line"><a name="l00081"></a><span class="lineno"> 81</span>  mouse_captured_by_ui = <span class="keyword">true</span>;</div><div class="line"><a name="l00082"></a><span class="lineno"> 82</span>  } <span class="keywordflow">else</span> <span class="keywordflow">if</span> (ImGuizmo::IsUsing()) {</div><div class="line"><a name="l00083"></a><span class="lineno"> 83</span>  window.capture_mouse();</div><div class="line"><a name="l00084"></a><span class="lineno"> 84</span>  mouse_captured_by_ui = <span class="keyword">false</span>;</div><div class="line"><a name="l00085"></a><span class="lineno"> 85</span>  } <span class="keywordflow">else</span> {</div><div class="line"><a name="l00086"></a><span class="lineno"> 86</span>  window.release_mouse();</div><div class="line"><a name="l00087"></a><span class="lineno"> 87</span>  mouse_captured_by_ui = <span class="keyword">false</span>;</div><div class="line"><a name="l00088"></a><span class="lineno"> 88</span>  }</div><div class="line"><a name="l00089"></a><span class="lineno"> 89</span> </div><div class="line"><a name="l00090"></a><span class="lineno"> 90</span> </div><div class="line"><a name="l00091"></a><span class="lineno"> 91</span>  <span class="keywordflow">if</span> (io.WantCaptureKeyboard)</div><div class="line"><a name="l00092"></a><span class="lineno"> 92</span>  window.capture_keyboard();</div><div class="line"><a name="l00093"></a><span class="lineno"> 93</span>  <span class="keywordflow">else</span></div><div class="line"><a name="l00094"></a><span class="lineno"> 94</span>  window.release_keyboard();</div><div class="line"><a name="l00095"></a><span class="lineno"> 95</span> </div><div class="line"><a name="l00096"></a><span class="lineno"> 96</span>  }, sentinel);</div><div class="line"><a name="l00097"></a><span class="lineno"> 97</span> </div><div class="line"><a name="l00098"></a><span class="lineno"> 98</span>  }</div><div class="line"><a name="l00099"></a><span class="lineno"> 99</span> </div><div class="line"><a name="l00101"></a><span class="lineno"><a class="line" href="class_open_g_p_1_1_g_u_i_canvas_component.html#a7eaffdb25358f675dfadfce9ba123b80"> 101</a></span>  <span class="keywordtype">void</span> <a class="code" href="class_open_g_p_1_1_g_u_i_canvas_component.html#a7eaffdb25358f675dfadfce9ba123b80">set_action</a>(std::function<<span class="keywordtype">void</span>()> action) {</div><div class="line"><a name="l00102"></a><span class="lineno"> 102</span>  this->action = action;</div><div class="line"><a name="l00103"></a><span class="lineno"> 103</span>  }</div><div class="line"><a name="l00104"></a><span class="lineno"> 104</span> </div><div class="line"><a name="l00105"></a><span class="lineno"> 105</span> };</div><div class="line"><a name="l00106"></a><span class="lineno"> 106</span> </div><div class="line"><a name="l00107"></a><span class="lineno"> 107</span> <span class="comment">//=============================================================================</span></div><div class="line"><a name="l00108"></a><span class="lineno"> 108</span> } <span class="comment">// OpenGP::</span></div><div class="line"><a name="l00109"></a><span class="lineno"> 109</span> <span class="comment">//=============================================================================</span></div><div class="ttc" id="class_open_g_p_1_1_event_provider_html_a2182fa1f9ca09ada8b0079d793dca96b"><div class="ttname"><a href="class_open_g_p_1_1_event_provider.html#a2182fa1f9ca09ada8b0079d793dca96b">OpenGP::EventProvider::add_listener</a></div><div class="ttdeci">ListenerHandle add_listener(ListenerType listener)</div><div class="ttdoc">Register a listener to be called for events of EventType </div><div class="ttdef"><b>Definition:</b> EventProvider.h:80</div></div>
<div class="ttc" id="struct_open_g_p_1_1_g_u_i_element_draw_event_html"><div class="ttname"><a href="struct_open_g_p_1_1_g_u_i_element_draw_event.html">OpenGP::GUIElementDrawEvent</a></div><div class="ttdoc">An event indicating that listeners should perform their UI creation calls. </div><div class="ttdef"><b>Definition:</b> GUICanvasComponent.h:17</div></div>
<div class="ttc" id="class_open_g_p_1_1_component_html"><div class="ttname"><a href="class_open_g_p_1_1_component.html">OpenGP::Component</a></div><div class="ttdoc">The base class for all components. </div><div class="ttdef"><b>Definition:</b> Entity.h:23</div></div>
<div class="ttc" id="class_open_g_p_1_1_camera_component_html"><div class="ttname"><a href="class_open_g_p_1_1_camera_component.html">OpenGP::CameraComponent</a></div><div class="ttdoc">A component representing a camera in the scene. </div><div class="ttdef"><b>Definition:</b> CameraComponent.h:23</div></div>
<div class="ttc" id="class_open_g_p_1_1_g_u_i_canvas_component_html_a7eaffdb25358f675dfadfce9ba123b80"><div class="ttname"><a href="class_open_g_p_1_1_g_u_i_canvas_component.html#a7eaffdb25358f675dfadfce9ba123b80">OpenGP::GUICanvasComponent::set_action</a></div><div class="ttdeci">void set_action(std::function< void()> action)</div><div class="ttdef"><b>Definition:</b> GUICanvasComponent.h:101</div></div>
<div class="ttc" id="class_open_g_p_1_1_g_u_i_canvas_component_html"><div class="ttname"><a href="class_open_g_p_1_1_g_u_i_canvas_component.html">OpenGP::GUICanvasComponent</a></div><div class="ttdoc">A component representing a GUI layer in a camera view. </div><div class="ttdef"><b>Definition:</b> GUICanvasComponent.h:22</div></div>
<div class="ttc" id="class_open_g_p_1_1_g_u_i_canvas_component_html_a6dac6a9e89f428a0f6f2cd69060b8292"><div class="ttname"><a href="class_open_g_p_1_1_g_u_i_canvas_component.html#a6dac6a9e89f428a0f6f2cd69060b8292">OpenGP::GUICanvasComponent::set_camera</a></div><div class="ttdeci">void set_camera(CameraComponent &camera)</div><div class="ttdoc">Attach this canvas to a camera. </div><div class="ttdef"><b>Definition:</b> GUICanvasComponent.h:38</div></div>
<div class="ttc" id="namespace_open_g_p_html"><div class="ttname"><a href="namespace_open_g_p.html">OpenGP</a></div><div class="ttdef"><b>Definition:</b> VirtualDepthSensor.h:19</div></div>
<div class="ttc" id="struct_open_g_p_1_1_g_u_i_render_event_html"><div class="ttname"><a href="struct_open_g_p_1_1_g_u_i_render_event.html">OpenGP::GUIRenderEvent</a></div><div class="ttdoc">An event indicating that any canvases should draw their UI elements. </div><div class="ttdef"><b>Definition:</b> CameraComponent.h:20</div></div>
<div class="ttc" id="class_open_g_p_1_1_event_sentinel_html"><div class="ttname"><a href="class_open_g_p_1_1_event_sentinel.html">OpenGP::EventSentinel</a></div><div class="ttdoc">Object that allows callbacks to be automatically deregistered if the objects they reference are destr...</div><div class="ttdef"><b>Definition:</b> EventProvider.h:22</div></div>
<div class="ttc" id="class_open_g_p_1_1_event_sentinel_html_ac28d3f5469f37a0cb5bcbbdb78c406b2"><div class="ttname"><a href="class_open_g_p_1_1_event_sentinel.html#ac28d3f5469f37a0cb5bcbbdb78c406b2">OpenGP::EventSentinel::reset</a></div><div class="ttdeci">void reset()</div><div class="ttdoc">Allow all guarded callbacks to be destroyed, as if the sentinel had died. </div><div class="ttdef"><b>Definition:</b> EventProvider.h:43</div></div>
<div class="ttc" id="class_open_g_p_1_1_event_provider_html"><div class="ttname"><a href="class_open_g_p_1_1_event_provider.html">OpenGP::EventProvider</a></div><div class="ttdoc">Base class that provides derived classes the abillity to register callbacks and send events...</div><div class="ttdef"><b>Definition:</b> EventProvider.h:51</div></div>
</div><!-- fragment --></div><!-- contents -->
<div id="footer">
<!-- <address>
<small>
Copyright © 2013
</small>
</address> -->
</div>
</body>
</html>