Panda3D
Loading...
Searching...
No Matches
graphicsWindow.h
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 graphicsWindow.h
10 * @author mike
11 * @date 1997-01-09
12 */
13
14#ifndef GRAPHICSWINDOW_H
15#define GRAPHICSWINDOW_H
16
17#include "pandabase.h"
18
19#include "graphicsOutput.h"
21#include "graphicsWindowProc.h"
23#include "windowProperties.h"
24#include "mouseData.h"
25#include "modifierButtons.h"
26#include "buttonEvent.h"
27#include "keyboardButton.h"
28#include "buttonMap.h"
29#include "pnotify.h"
30#include "lightMutex.h"
31#include "lightReMutex.h"
32#include "pvector.h"
33#include "windowHandle.h"
34#include "touchInfo.h"
35
36/**
37 * A window, fullscreen or on a desktop, into which a graphics device sends
38 * its output for interactive display.
39 */
40class EXPCL_PANDA_DISPLAY GraphicsWindow : public GraphicsOutput {
41protected:
42 GraphicsWindow(GraphicsEngine *engine,
43 GraphicsPipe *pipe,
44 const std::string &name,
45 const FrameBufferProperties &fb_prop,
46 const WindowProperties &win_prop,
47 int flags,
49 GraphicsOutput *host);
50
51PUBLISHED:
52 virtual ~GraphicsWindow();
53
54 const WindowProperties get_properties() const;
58 void request_properties(const WindowProperties &requested_properties);
59 INLINE bool is_closed() const;
60 virtual bool is_active() const;
61 INLINE bool is_fullscreen() const;
62
63 MAKE_PROPERTY(properties, get_properties);
64 MAKE_PROPERTY(requested_properties, get_requested_properties);
65 MAKE_PROPERTY(rejected_properties, get_rejected_properties);
66 MAKE_PROPERTY(closed, is_closed);
67
68 void set_window_event(const std::string &window_event);
69 std::string get_window_event() const;
70 MAKE_PROPERTY(window_event, get_window_event, set_window_event);
71
72 void set_close_request_event(const std::string &close_request_event);
73 std::string get_close_request_event() const;
74 MAKE_PROPERTY(close_request_event, get_close_request_event, set_close_request_event);
75
76 INLINE void set_unexposed_draw(bool unexposed_draw);
77 INLINE bool get_unexposed_draw() const;
78 MAKE_PROPERTY(unexposed_draw, get_unexposed_draw, set_unexposed_draw);
79
80 INLINE WindowHandle *get_window_handle() const;
81 MAKE_PROPERTY(window_handle, get_window_handle);
82
83 // Mouse and keyboard routines
84 int get_num_input_devices() const;
85 InputDevice *get_input_device(int i) const;
86 std::string get_input_device_name(int device) const;
87 MAKE_SEQ(get_input_devices, get_num_input_devices, get_input_device);
88 MAKE_SEQ(get_input_device_names, get_num_input_devices, get_input_device_name);
89 bool has_pointer(int device) const;
90 bool has_keyboard(int device) const;
91 virtual ButtonMap *get_keyboard_map() const;
92
93 void enable_pointer_events(int device);
94 void disable_pointer_events(int device);
95 /*void enable_pointer_mode(int device, double speed);
96 void disable_pointer_mode(int device);*/
97
98 virtual MouseData get_pointer(int device) const;
99 virtual bool move_pointer(int device, int x, int y);
100 virtual void close_ime();
101
102public:
103 virtual void add_window_proc( const GraphicsWindowProc* wnd_proc_object ){};
104 virtual void remove_window_proc( const GraphicsWindowProc* wnd_proc_object ){};
105 virtual void clear_window_procs(){};
106 virtual bool supports_window_procs() const;
107
108 virtual int verify_window_sizes(int numsizes, int *dimen);
109
110 virtual bool is_touch_event(GraphicsWindowProcCallbackData* callbackData);
111 virtual int get_num_touches();
112 virtual TouchInfo get_touch_info(int index);
113
114public:
115 virtual void request_open();
116 virtual void request_close();
117
118 // It is an error to call any of the following methods from any thread other
119 // than the window thread. These methods are normally called by the
120 // GraphicsEngine.
121 virtual void set_close_now();
122 virtual void process_events();
123 virtual void set_properties_now(WindowProperties &properties);
124
125protected:
126 virtual void close_window();
127 virtual bool open_window();
128 virtual void reset_window(bool swapchain);
129
130 virtual bool do_reshape_request(int x_origin, int y_origin, bool has_origin,
131 int x_size, int y_size);
132
133 virtual void mouse_mode_absolute();
134 virtual void mouse_mode_relative();
135
136 // It is an error to call any of the following methods from any thread other
137 // than the window thread.
138 void system_changed_properties(const WindowProperties &properties);
139 void system_changed_size(int x_size, int y_size);
140
141protected:
142 int add_input_device(InputDevice *device);
143 typedef pvector<PT(InputDevice)> InputDevices;
144 InputDevices _input_devices;
145 LightMutex _input_lock;
146
147protected:
148 WindowProperties _properties;
149 PT(WindowHandle) _window_handle;
150 PT(WindowHandle) _parent_window_handle;
151
152 bool _got_expose_event;
153
154private:
155 LightReMutex _properties_lock;
156 // protects _requested_properties, _rejected_properties, and _window_event.
157
158 WindowProperties _requested_properties;
159 WindowProperties _rejected_properties;
160 std::string _window_event;
161 std::string _close_request_event;
162 bool _unexposed_draw;
163
164#ifdef HAVE_PYTHON
165 typedef pset<GraphicsWindowProc*> PythonWinProcClasses;
166 PythonWinProcClasses _python_window_proc_classes;
167#endif
168
169public:
170 static TypeHandle get_class_type() {
171 return _type_handle;
172 }
173 static void init_type() {
174 GraphicsOutput::init_type();
175 register_type(_type_handle, "GraphicsWindow",
176 GraphicsOutput::get_class_type());
177 }
178 virtual TypeHandle get_type() const {
179 return get_class_type();
180 }
181 virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
182
183private:
184 static TypeHandle _type_handle;
185
186 friend class GraphicsEngine;
187 friend class Extension<GraphicsWindow>;
188};
189
190#include "graphicsWindow.I"
191
192#endif /* GRAPHICSWINDOW_H */
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
This class represents a map containing all of the buttons of a (keyboard) device, though it can also ...
Definition buttonMap.h:30
A container for the various kinds of properties we might ask to have on a graphics frameBuffer before...
virtual void process_events()
Do whatever processing in the window thread is appropriate for this output object each frame.
is_active
Returns true if the window is ready to be rendered into, false otherwise.
virtual void reset_window(bool swapchain)
Resets the window framebuffer from its derived children.
virtual void request_close()
This is called by the GraphicsEngine to request that the window (or whatever) close itself or,...
virtual void request_open()
This is called by the GraphicsEngine to request that the window (or whatever) open itself or,...
virtual void set_close_now()
This is called by the GraphicsEngine to insist that the output be closed immediately.
Encapsulates all the communication with a particular instance of a given rendering backend.
Defines an interface for storing platform-specific window processor methods.
set_close_request_event
Sets the event that is triggered when the user requests to close the window, e.g.
get_input_device_name
Returns the name of the nth input device.
void disable_pointer_events(int device)
Turn off the generation of pointer events.
void clear_rejected_properties()
Empties the set of failed properties that will be returned by get_rejected_properties().
virtual bool move_pointer(int device, int x, int y)
Forces the pointer to the indicated position within the window, if possible.
get_unexposed_draw
See set_unexposed_draw().
get_input_device
Returns the nth input device associated with the window.
set_unexposed_draw
If this flag is false, the window is redrawn only after it has received a recent "unexpose" or "draw"...
get_window_event
Returns the name of the event that is generated when this window is modified externally,...
get_properties
Returns the current properties of the window.
bool is_fullscreen() const
Returns true if the window has been opened as a fullscreen window, false otherwise.
get_requested_properties
Returns the properties of the window that are currently requested.
set_window_event
Changes the name of the event that is generated when this window is modified externally,...
get_num_input_devices
Returns the number of separate input devices associated with the window.
void request_properties(const WindowProperties &requested_properties)
Requests a property change on the window.
get_window_handle
Returns the WindowHandle corresponding to this window on the desktop.
get_close_request_event
Returns the name of the event set via set_close_request_event().
virtual MouseData get_pointer(int device) const
See GraphicsWindowInputDevice::enable_pointer_mode.
virtual void close_ime()
Forces the ime window to close if any.
get_rejected_properties
Returns the set of properties that have recently been requested, but could not be applied to the wind...
is_closed
Returns true if the window has not yet been opened, or has been fully closed, false if it is open.
bool has_pointer(int device) const
Returns true if the nth input device has a screen-space pointer (for instance, a mouse),...
void enable_pointer_events(int device)
Turn on the generation of pointer events.
virtual ButtonMap * get_keyboard_map() const
Returns a ButtonMap containing the association between raw buttons and virtual buttons.
bool has_keyboard(int device) const
Returns true if the nth input device has a keyboard, false otherwise.
This is a structure representing a single input device.
Definition inputDevice.h:53
This object represents a window on the desktop, not necessarily a Panda window.
A container for the various kinds of properties we might ask to have on a graphics window before we o...
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
BEGIN_PUBLISH typedef PointerData MouseData
Deprecated alias for PointerData.
Definition mouseData.h:23
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
void register_type(TypeHandle &type_handle, const std::string &name)
This inline function is just a convenient way to call TypeRegistry::register_type(),...
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.