Panda3D
 All Classes Functions Variables Enumerations
mouseSubregion.I
1 // Filename: mouseSubregion.I
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 
16 ////////////////////////////////////////////////////////////////////
17 // Function: MouseSubregion::get_left
18 // Access: Published
19 // Description: Retrieves the x coordinate of the left edge of the
20 // rectangle within the window. This number will be in
21 // the range [0..1].
22 ////////////////////////////////////////////////////////////////////
23 PN_stdfloat MouseSubregion::
24 get_left() const {
25  return _l;
26 }
27 
28 ////////////////////////////////////////////////////////////////////
29 // Function: MouseSubregion::get_right
30 // Access: Published
31 // Description: Retrieves the x coordinate of the right edge of the
32 // rectangle within the window. This number will be in
33 // the range [0..1].
34 ////////////////////////////////////////////////////////////////////
35 PN_stdfloat MouseSubregion::
36 get_right() const {
37  return _r;
38 }
39 
40 ////////////////////////////////////////////////////////////////////
41 // Function: MouseSubregion::get_bottom
42 // Access: Published
43 // Description: Retrieves the y coordinate of the bottom edge of
44 // the rectangle within the window. This number will be
45 // in the range [0..1].
46 ////////////////////////////////////////////////////////////////////
47 PN_stdfloat MouseSubregion::
48 get_bottom() const {
49  return _b;
50 }
51 
52 ////////////////////////////////////////////////////////////////////
53 // Function: MouseSubregion::get_top
54 // Access: Published
55 // Description: Retrieves the y coordinate of the top edge of the
56 // rectangle within the window. This number will be in
57 // the range [0..1].
58 ////////////////////////////////////////////////////////////////////
59 PN_stdfloat MouseSubregion::
60 get_top() const {
61  return _t;
62 }
63 
64 ////////////////////////////////////////////////////////////////////
65 // Function: MouseSubregion::set_dimensions
66 // Access: Published
67 // Description: Changes the region of the window in which the mouse
68 // is considered to be active. The parameters are
69 // identical to those for a DisplayRegion: they range
70 // from 0 to 1, where 0,0 is the lower left corner and
71 // 1,1 is the upper right; (0, 1, 0, 1) represents the
72 // whole window.
73 ////////////////////////////////////////////////////////////////////
75 set_dimensions(PN_stdfloat l, PN_stdfloat r, PN_stdfloat b, PN_stdfloat t) {
76  _l = l;
77  _r = r;
78  _b = b;
79  _t = t;
80 
81  _minx = l * 2.0f - 1.0f;
82  _miny = b * 2.0f - 1.0f;
83 
84  PN_stdfloat maxx = r * 2.0f - 1.0f;
85  PN_stdfloat maxy = t * 2.0f - 1.0f;
86 
87  _scalex = 2.0f / (maxx - _minx);
88  _scaley = 2.0f / (maxy - _miny);
89 }
PN_stdfloat get_left() const
Retrieves the x coordinate of the left edge of the rectangle within the window.
void set_dimensions(PN_stdfloat l, PN_stdfloat r, PN_stdfloat b, PN_stdfloat t)
Changes the region of the window in which the mouse is considered to be active.
PN_stdfloat get_right() const
Retrieves the x coordinate of the right edge of the rectangle within the window.
PN_stdfloat get_bottom() const
Retrieves the y coordinate of the bottom edge of the rectangle within the window. ...
PN_stdfloat get_top() const
Retrieves the y coordinate of the top edge of the rectangle within the window.