Panda3D
mouseSubregion.h
1 // Filename: mouseSubregion.h
2 // Created by: drose (13May05)
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 #ifndef MOUSESUBREGION_H
16 #define MOUSESUBREGION_H
17 
18 #include "pandabase.h"
19 
20 #include "mouseInterfaceNode.h"
21 #include "luse.h"
22 #include "linmath_events.h"
23 #include "buttonEventList.h"
24 
25 
26 ////////////////////////////////////////////////////////////////////
27 // Class : MouseSubregion
28 // Description : The MouseSubregion object scales the mouse inputs
29 // from within a rectangular region of the screen, as if
30 // they were the full-screen inputs.
31 //
32 // If you choose your MouseSubregion coordinates to
33 // exactly match a DisplayRegion within your window, you
34 // end up with a virtual mouse within your
35 // DisplayRegion.
36 ////////////////////////////////////////////////////////////////////
37 class EXPCL_PANDA_TFORM MouseSubregion : public MouseInterfaceNode {
38 PUBLISHED:
39  MouseSubregion(const string &name);
40  ~MouseSubregion();
41 
42  INLINE PN_stdfloat get_left() const;
43  INLINE PN_stdfloat get_right() const;
44  INLINE PN_stdfloat get_bottom() const;
45  INLINE PN_stdfloat get_top() const;
46  INLINE void set_dimensions(PN_stdfloat l, PN_stdfloat r, PN_stdfloat b, PN_stdfloat t);
47 
48 protected:
49  // Inherited from DataNode
50  virtual void do_transmit_data(DataGraphTraverser *trav,
51  const DataNodeTransmit &input,
52  DataNodeTransmit &output);
53 
54 private:
55  PN_stdfloat _l;
56  PN_stdfloat _r;
57  PN_stdfloat _b;
58  PN_stdfloat _t;
59 
60  PN_stdfloat _minx, _miny;
61  PN_stdfloat _scalex, _scaley;
62 
63 private:
64  // inputs
65  int _pixel_xy_input;
66  int _pixel_size_input;
67  int _xy_input;
68  int _button_events_input;
69 
70  // outputs
71  int _pixel_xy_output;
72  int _pixel_size_output;
73  int _xy_output;
74  int _button_events_output;
75 
76  PT(EventStoreVec2) _pixel_xy;
77  PT(EventStoreVec2) _pixel_size;
78  PT(EventStoreVec2) _xy;
79  PT(ButtonEventList) _button_events;
80 
81 public:
82  static TypeHandle get_class_type() {
83  return _type_handle;
84  }
85  static void init_type() {
86  MouseInterfaceNode::init_type();
87  register_type(_type_handle, "MouseSubregion",
88  MouseInterfaceNode::get_class_type());
89  }
90  virtual TypeHandle get_type() const {
91  return get_class_type();
92  }
93  virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
94 
95 private:
96  static TypeHandle _type_handle;
97 };
98 
99 #include "mouseSubregion.I"
100 
101 #endif
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:109
Records a set of button events that happened recently.
This is the base class for some classes that monitor the mouse and keyboard input and perform some ac...
TypeHandle is the identifier used to differentiate C++ class types.
Definition: typeHandle.h:85
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...