Panda3D
callbackGraphicsWindow.I
1 // Filename: callbackGraphicsWindow.I
2 // Created by: drose (06Jan11)
3 //
4 ////////////////////////////////////////////////////////////////////
5 //
6 // PANDA 3D SOFTWARE
7 // Copyright (c) Carnegie Mellon University. All rights reserved.
8 //
9 // All use of this software is subject to the terms of the revised BSD
10 // license. You should have received a copy of this license along
11 // with this source code in a file named "LICENSE."
12 //
13 ////////////////////////////////////////////////////////////////////
14 
15 
16 ////////////////////////////////////////////////////////////////////
17 // Function: CallbackGraphicsWindow::set_events_callback
18 // Access: Published
19 // Description: Sets the CallbackObject that will be notified when
20 // this window is polled for window events, including
21 // mouse and keyboard events, as well as window resize
22 // events and other system-generated events.
23 //
24 // This callback will receive a
25 // CallbackGraphicsWindow::EventsCallbackData.
26 //
27 // This callback should process any system-generated
28 // events, and call data->upcall() to process requested
29 // property change requests made via
30 // request_properties().
31 ////////////////////////////////////////////////////////////////////
32 INLINE void CallbackGraphicsWindow::
34  _events_callback = object;
35 }
36 
37 ////////////////////////////////////////////////////////////////////
38 // Function: CallbackGraphicsWindow::clear_events_callback
39 // Access: Published
40 // Description: Removes the callback set by an earlier call to
41 // set_events_callback().
42 ////////////////////////////////////////////////////////////////////
43 INLINE void CallbackGraphicsWindow::
45  set_events_callback(NULL);
46 }
47 
48 ////////////////////////////////////////////////////////////////////
49 // Function: CallbackGraphicsWindow::get_events_callback
50 // Access: Published
51 // Description: Returns the CallbackObject set by set_events_callback().
52 ////////////////////////////////////////////////////////////////////
55  return _events_callback;
56 }
57 
58 ////////////////////////////////////////////////////////////////////
59 // Function: CallbackGraphicsWindow::set_properties_callback
60 // Access: Published
61 // Description: Sets the CallbackObject that will be notified when
62 // this window receives a property change request from
63 // user code (e.g. via request_properties).
64 //
65 // This callback will receive a
66 // CallbackGraphicsWindow::PropertiesCallbackData, which
67 // provides a get_properties() method that returns a
68 // modifiable reference to a WindowsProperties object.
69 // This object will contain only those properties
70 // requested by user code. The callback should handle
71 // any of the requests it finds, including and
72 // especially set_open(), and remove them from the
73 // object when it has handled them. Any unhandled
74 // properties should be left unchanged in the properties
75 // object.
76 ////////////////////////////////////////////////////////////////////
77 INLINE void CallbackGraphicsWindow::
79  _properties_callback = object;
80 }
81 
82 ////////////////////////////////////////////////////////////////////
83 // Function: CallbackGraphicsWindow::clear_properties_callback
84 // Access: Published
85 // Description: Removes the callback set by an earlier call to
86 // set_properties_callback().
87 ////////////////////////////////////////////////////////////////////
88 INLINE void CallbackGraphicsWindow::
91 }
92 
93 ////////////////////////////////////////////////////////////////////
94 // Function: CallbackGraphicsWindow::get_properties_callback
95 // Access: Published
96 // Description: Returns the CallbackObject set by set_properties_callback().
97 ////////////////////////////////////////////////////////////////////
100  return _properties_callback;
101 }
102 
103 ////////////////////////////////////////////////////////////////////
104 // Function: CallbackGraphicsWindow::set_render_callback
105 // Access: Published
106 // Description: Sets the CallbackObject that will be notified when
107 // this window is invoked (in the draw thread) to render
108 // its contents, and/or flip the graphics buffers.
109 //
110 // This callback will actually serve several different
111 // functions. It receivces a RenderCallbackData, and
112 // you can query data->get_callback_type() to return the
113 // actual function of each particular callback.
114 ////////////////////////////////////////////////////////////////////
115 INLINE void CallbackGraphicsWindow::
117  _render_callback = object;
118 }
119 
120 ////////////////////////////////////////////////////////////////////
121 // Function: CallbackGraphicsWindow::clear_render_callback
122 // Access: Published
123 // Description: Removes the callback set by an earlier call to
124 // set_render_callback().
125 ////////////////////////////////////////////////////////////////////
126 INLINE void CallbackGraphicsWindow::
128  set_render_callback(NULL);
129 }
130 
131 ////////////////////////////////////////////////////////////////////
132 // Function: CallbackGraphicsWindow::get_render_callback
133 // Access: Published
134 // Description: Returns the CallbackObject set by set_render_callback().
135 ////////////////////////////////////////////////////////////////////
138  return _render_callback;
139 }
140 
141 ////////////////////////////////////////////////////////////////////
142 // Function: CallbackGraphicsWindow::WindowCallbackData::Constructor
143 // Access: Public
144 // Description:
145 ////////////////////////////////////////////////////////////////////
146 INLINE CallbackGraphicsWindow::WindowCallbackData::
147 WindowCallbackData(CallbackGraphicsWindow *window) : _window(window) {
148 }
149 
150 ////////////////////////////////////////////////////////////////////
151 // Function: CallbackGraphicsWindow::WindowCallbackData::get_window
152 // Access: Published
153 // Description: Returns the window this callback was triggered from.
154 ////////////////////////////////////////////////////////////////////
156 get_window() const {
157  return _window;
158 }
159 
160 ////////////////////////////////////////////////////////////////////
161 // Function: CallbackGraphicsWindow::EventsCallbackData::Constructor
162 // Access: Public
163 // Description:
164 ////////////////////////////////////////////////////////////////////
165 INLINE CallbackGraphicsWindow::EventsCallbackData::
166 EventsCallbackData(CallbackGraphicsWindow *window) :
167  WindowCallbackData(window)
168 {
169 }
170 
171 
172 ////////////////////////////////////////////////////////////////////
173 // Function: CallbackGraphicsWindow::PropertiesCallbackData::Constructor
174 // Access: Public
175 // Description:
176 ////////////////////////////////////////////////////////////////////
177 INLINE CallbackGraphicsWindow::PropertiesCallbackData::
178 PropertiesCallbackData(CallbackGraphicsWindow *window, WindowProperties &properties) :
179  WindowCallbackData(window),
180  _properties(properties)
181 {
182 }
183 
184 ////////////////////////////////////////////////////////////////////
185 // Function: CallbackGraphicsWindow::PropertiesCallbackData::get_properties
186 // Access: Published
187 // Description: Returns the WindowProperties object that this
188 // callback should process. Any properties that are
189 // handled should be removed from this object;
190 // properties that are unhandled should be left alone.
191 ////////////////////////////////////////////////////////////////////
193 get_properties() const {
194  return _properties;
195 }
196 
197 ////////////////////////////////////////////////////////////////////
198 // Function: CallbackGraphicsWindow::RenderCallbackData::Constructor
199 // Access: Public
200 // Description:
201 ////////////////////////////////////////////////////////////////////
202 INLINE CallbackGraphicsWindow::RenderCallbackData::
203 RenderCallbackData(CallbackGraphicsWindow *window, RenderCallbackType callback_type, FrameMode frame_mode) :
204  WindowCallbackData(window),
205  _callback_type(callback_type),
206  _frame_mode(frame_mode),
207  _render_flag(true)
208 {
209 }
210 
211 ////////////////////////////////////////////////////////////////////
212 // Function: CallbackGraphicsWindow::RenderCallbackData::get_callback_type
213 // Access: Published
214 // Description: Since the render callback is shared for several
215 // functions, this method is needed to indicate which
216 // particular function is being invoked with this
217 // callback.
218 ////////////////////////////////////////////////////////////////////
219 INLINE CallbackGraphicsWindow::RenderCallbackType CallbackGraphicsWindow::RenderCallbackData::
221  return _callback_type;
222 }
223 
224 ////////////////////////////////////////////////////////////////////
225 // Function: CallbackGraphicsWindow::RenderCallbackData::get_frame_mode
226 // Access: Published
227 // Description: If the callback type (returned by get_callback_type)
228 // is RCT_begin_frame or RCT_end_frame, then this method
229 // will return the particular frame mode indicating
230 // what, precisely, we want to do this frame.
231 ////////////////////////////////////////////////////////////////////
232 INLINE GraphicsOutput::FrameMode CallbackGraphicsWindow::RenderCallbackData::
233 get_frame_mode() const {
234  return _frame_mode;
235 }
236 
237 ////////////////////////////////////////////////////////////////////
238 // Function: CallbackGraphicsWindow::RenderCallbackData::set_render_flag
239 // Access: Published
240 // Description: If the callback type is RCT_begin_frame, this call is
241 // available to specify the return value from the
242 // begin_frame() call. If this is true (the default),
243 // the frame is rendered normally; if it is false, the
244 // frame is omitted.
245 ////////////////////////////////////////////////////////////////////
247 set_render_flag(bool render_flag) {
248  _render_flag = render_flag;
249 }
250 
251 ////////////////////////////////////////////////////////////////////
252 // Function: CallbackGraphicsWindow::RenderCallbackData::get_render_flag
253 // Access: Published
254 // Description: Returns the current setting of the render flag. See
255 // set_render_flag().
256 ////////////////////////////////////////////////////////////////////
259  return _render_flag;
260 }
void set_render_flag(bool render_flag)
If the callback type is RCT_begin_frame, this call is available to specify the return value from the ...
WindowProperties & get_properties() const
Returns the WindowProperties object that this callback should process.
void set_events_callback(CallbackObject *object)
Sets the CallbackObject that will be notified when this window is polled for window events...
void set_properties_callback(CallbackObject *object)
Sets the CallbackObject that will be notified when this window receives a property change request fro...
CallbackObject * get_render_callback() const
Returns the CallbackObject set by set_render_callback().
CallbackObject * get_properties_callback() const
Returns the CallbackObject set by set_properties_callback().
void clear_render_callback()
Removes the callback set by an earlier call to set_render_callback().
CallbackObject * get_events_callback() const
Returns the CallbackObject set by set_events_callback().
void clear_events_callback()
Removes the callback set by an earlier call to set_events_callback().
A container for the various kinds of properties we might ask to have on a graphics window before we o...
This special window object doesn't represent a window in its own right, but instead hooks into some t...
GraphicsOutput::FrameMode get_frame_mode() const
If the callback type (returned by get_callback_type) is RCT_begin_frame or RCT_end_frame, then this method will return the particular frame mode indicating what, precisely, we want to do this frame.
CallbackGraphicsWindow * get_window() const
Returns the window this callback was triggered from.
CallbackGraphicsWindow::RenderCallbackType get_callback_type() const
Since the render callback is shared for several functions, this method is needed to indicate which pa...
bool get_render_flag() const
Returns the current setting of the render flag.
This is a generic object that can be assigned to a callback at various points in the rendering proces...
void set_render_callback(CallbackObject *object)
Sets the CallbackObject that will be notified when this window is invoked (in the draw thread) to ren...
void clear_properties_callback()
Removes the callback set by an earlier call to set_properties_callback().