Panda3D
callbackGraphicsWindow.I
Go to the documentation of this file.
1 /**
2  * PANDA 3D SOFTWARE
3  * Copyright (c) Carnegie Mellon University. All rights reserved.
4  *
5  * All use of this software is subject to the terms of the revised BSD
6  * license. You should have received a copy of this license along
7  * with this source code in a file named "LICENSE."
8  *
9  * @file callbackGraphicsWindow.I
10  * @author drose
11  * @date 2011-01-06
12  */
13 
14 /**
15  * Sets the CallbackObject that will be notified when this window is polled
16  * for window events, including mouse and keyboard events, as well as window
17  * resize events and other system-generated events.
18  *
19  * This callback will receive a CallbackGraphicsWindow::EventsCallbackData.
20  *
21  * This callback should process any system-generated events, and call
22  * data->upcall() to process requested property change requests made via
23  * request_properties().
24  */
25 INLINE void CallbackGraphicsWindow::
27  _events_callback = object;
28 }
29 
30 /**
31  * Removes the callback set by an earlier call to set_events_callback().
32  */
33 INLINE void CallbackGraphicsWindow::
35  set_events_callback(nullptr);
36 }
37 
38 /**
39  * Returns the CallbackObject set by set_events_callback().
40  */
43  return _events_callback;
44 }
45 
46 /**
47  * Sets the CallbackObject that will be notified when this window receives a
48  * property change request from user code (e.g. via request_properties).
49  *
50  * This callback will receive a
51  * CallbackGraphicsWindow::PropertiesCallbackData, which provides a
52  * get_properties() method that returns a modifiable reference to a
53  * WindowsProperties object. This object will contain only those properties
54  * requested by user code. The callback should handle any of the requests it
55  * finds, including and especially set_open(), and remove them from the object
56  * when it has handled them. Any unhandled properties should be left
57  * unchanged in the properties object.
58  */
59 INLINE void CallbackGraphicsWindow::
61  _properties_callback = object;
62 }
63 
64 /**
65  * Removes the callback set by an earlier call to set_properties_callback().
66  */
67 INLINE void CallbackGraphicsWindow::
69  set_properties_callback(nullptr);
70 }
71 
72 /**
73  * Returns the CallbackObject set by set_properties_callback().
74  */
77  return _properties_callback;
78 }
79 
80 /**
81  * Sets the CallbackObject that will be notified when this window is invoked
82  * (in the draw thread) to render its contents, and/or flip the graphics
83  * buffers.
84  *
85  * This callback will actually serve several different functions. It
86  * receivces a RenderCallbackData, and you can query data->get_callback_type()
87  * to return the actual function of each particular callback.
88  */
89 INLINE void CallbackGraphicsWindow::
91  _render_callback = object;
92 }
93 
94 /**
95  * Removes the callback set by an earlier call to set_render_callback().
96  */
97 INLINE void CallbackGraphicsWindow::
99  set_render_callback(nullptr);
100 }
101 
102 /**
103  * Returns the CallbackObject set by set_render_callback().
104  */
107  return _render_callback;
108 }
109 
110 /**
111  *
112  */
113 INLINE CallbackGraphicsWindow::WindowCallbackData::
114 WindowCallbackData(CallbackGraphicsWindow *window) : _window(window) {
115 }
116 
117 /**
118  * Returns the window this callback was triggered from.
119  */
120 INLINE CallbackGraphicsWindow *CallbackGraphicsWindow::WindowCallbackData::
121 get_window() const {
122  return _window;
123 }
124 
125 /**
126  *
127  */
128 INLINE CallbackGraphicsWindow::EventsCallbackData::
129 EventsCallbackData(CallbackGraphicsWindow *window) :
130  WindowCallbackData(window)
131 {
132 }
133 
134 
135 /**
136  *
137  */
138 INLINE CallbackGraphicsWindow::PropertiesCallbackData::
139 PropertiesCallbackData(CallbackGraphicsWindow *window, WindowProperties &properties) :
140  WindowCallbackData(window),
141  _properties(properties)
142 {
143 }
144 
145 /**
146  * Returns the WindowProperties object that this callback should process. Any
147  * properties that are handled should be removed from this object; properties
148  * that are unhandled should be left alone.
149  */
151 get_properties() const {
152  return _properties;
153 }
154 
155 /**
156  *
157  */
158 INLINE CallbackGraphicsWindow::RenderCallbackData::
159 RenderCallbackData(CallbackGraphicsWindow *window, RenderCallbackType callback_type, FrameMode frame_mode) :
160  WindowCallbackData(window),
161  _callback_type(callback_type),
162  _frame_mode(frame_mode),
163  _render_flag(true)
164 {
165 }
166 
167 /**
168  * Since the render callback is shared for several functions, this method is
169  * needed to indicate which particular function is being invoked with this
170  * callback.
171  */
172 INLINE CallbackGraphicsWindow::RenderCallbackType CallbackGraphicsWindow::RenderCallbackData::
173 get_callback_type() const {
174  return _callback_type;
175 }
176 
177 /**
178  * If the callback type (returned by get_callback_type) is RCT_begin_frame or
179  * RCT_end_frame, then this method will return the particular frame mode
180  * indicating what, precisely, we want to do this frame.
181  */
182 INLINE GraphicsOutput::FrameMode CallbackGraphicsWindow::RenderCallbackData::
183 get_frame_mode() const {
184  return _frame_mode;
185 }
186 
187 /**
188  * If the callback type is RCT_begin_frame, this call is available to specify
189  * the return value from the begin_frame() call. If this is true (the
190  * default), the frame is rendered normally; if it is false, the frame is
191  * omitted.
192  */
194 set_render_flag(bool render_flag) {
195  _render_flag = render_flag;
196 }
197 
198 /**
199  * Returns the current setting of the render flag. See set_render_flag().
200  */
201 INLINE bool CallbackGraphicsWindow::RenderCallbackData::
202 get_render_flag() const {
203  return _render_flag;
204 }
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...
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...
set_render_flag
If the callback type is RCT_begin_frame, this call is available to specify the return value from the ...
void clear_properties_callback()
Removes the callback set by an earlier call to set_properties_callback().