Panda3D
mouseSubregion.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 mouseSubregion.h
10  * @author drose
11  * @date 2005-05-13
12  */
13 
14 #ifndef MOUSESUBREGION_H
15 #define MOUSESUBREGION_H
16 
17 #include "pandabase.h"
18 
19 #include "mouseInterfaceNode.h"
20 #include "luse.h"
21 #include "linmath_events.h"
22 #include "buttonEventList.h"
23 
24 
25 /**
26  * The MouseSubregion object scales the mouse inputs from within a rectangular
27  * region of the screen, as if they were the full-screen inputs.
28  *
29  * If you choose your MouseSubregion coordinates to exactly match a
30  * DisplayRegion within your window, you end up with a virtual mouse within
31  * your DisplayRegion.
32  */
33 class EXPCL_PANDA_TFORM MouseSubregion : public MouseInterfaceNode {
34 PUBLISHED:
35  explicit MouseSubregion(const std::string &name);
36  ~MouseSubregion();
37 
38  INLINE PN_stdfloat get_left() const;
39  INLINE PN_stdfloat get_right() const;
40  INLINE PN_stdfloat get_bottom() const;
41  INLINE PN_stdfloat get_top() const;
42  INLINE void set_dimensions(PN_stdfloat l, PN_stdfloat r, PN_stdfloat b, PN_stdfloat t);
43 
44 protected:
45  // Inherited from DataNode
46  virtual void do_transmit_data(DataGraphTraverser *trav,
47  const DataNodeTransmit &input,
48  DataNodeTransmit &output);
49 
50 private:
51  PN_stdfloat _l;
52  PN_stdfloat _r;
53  PN_stdfloat _b;
54  PN_stdfloat _t;
55 
56  PN_stdfloat _minx, _miny;
57  PN_stdfloat _scalex, _scaley;
58 
59 private:
60  // inputs
61  int _pixel_xy_input;
62  int _pixel_size_input;
63  int _xy_input;
64  int _button_events_input;
65 
66  // outputs
67  int _pixel_xy_output;
68  int _pixel_size_output;
69  int _xy_output;
70  int _button_events_output;
71 
72  PT(EventStoreVec2) _pixel_xy;
73  PT(EventStoreVec2) _pixel_size;
74  PT(EventStoreVec2) _xy;
75  PT(ButtonEventList) _button_events;
76 
77 public:
78  static TypeHandle get_class_type() {
79  return _type_handle;
80  }
81  static void init_type() {
82  MouseInterfaceNode::init_type();
83  register_type(_type_handle, "MouseSubregion",
84  MouseInterfaceNode::get_class_type());
85  }
86  virtual TypeHandle get_type() const {
87  return get_class_type();
88  }
89  virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
90 
91 private:
92  static TypeHandle _type_handle;
93 };
94 
95 #include "mouseSubregion.I"
96 
97 #endif
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(),...
Definition: register_type.I:22
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
The MouseSubregion object scales the mouse inputs from within a rectangular region of the screen,...
A handy class object for storing simple values (like integers or strings) passed along with an Event ...
Definition: paramValue.h:103
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
Records a set of button events that happened recently.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
This is the base class for some classes that monitor the mouse and keyboard input and perform some ac...
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
TypeHandle is the identifier used to differentiate C++ class types.
Definition: typeHandle.h:81
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
Encapsulates the data generated from (or sent into) any particular DataNode.
This object supervises the traversal of the data graph and the moving of data from one DataNode to it...