Panda3D

mouseSubregion.I

00001 // Filename: mouseSubregion.I
00002 // Created by:  drose (13May05)
00003 //
00004 ////////////////////////////////////////////////////////////////////
00005 //
00006 // PANDA 3D SOFTWARE
00007 // Copyright (c) Carnegie Mellon University.  All rights reserved.
00008 //
00009 // All use of this software is subject to the terms of the revised BSD
00010 // license.  You should have received a copy of this license along
00011 // with this source code in a file named "LICENSE."
00012 //
00013 ////////////////////////////////////////////////////////////////////
00014 
00015 
00016 ////////////////////////////////////////////////////////////////////
00017 //     Function: MouseSubregion::get_left
00018 //       Access: Published
00019 //  Description: Retrieves the x coordinate of the left edge of the
00020 //               rectangle within the window.  This number will be in
00021 //               the range [0..1].
00022 ////////////////////////////////////////////////////////////////////
00023 PN_stdfloat MouseSubregion::
00024 get_left() const {
00025   return _l;
00026 }
00027 
00028 ////////////////////////////////////////////////////////////////////
00029 //     Function: MouseSubregion::get_right
00030 //       Access: Published
00031 //  Description: Retrieves the x coordinate of the right edge of the
00032 //               rectangle within the window.  This number will be in
00033 //               the range [0..1].
00034 ////////////////////////////////////////////////////////////////////
00035 PN_stdfloat MouseSubregion::
00036 get_right() const {
00037   return _r;
00038 }
00039 
00040 ////////////////////////////////////////////////////////////////////
00041 //     Function: MouseSubregion::get_bottom
00042 //       Access: Published
00043 //  Description: Retrieves the y coordinate of the bottom edge of 
00044 //               the rectangle within the window.  This number will be
00045 //               in the range [0..1].
00046 ////////////////////////////////////////////////////////////////////
00047 PN_stdfloat MouseSubregion::
00048 get_bottom() const {
00049   return _b;
00050 }
00051 
00052 ////////////////////////////////////////////////////////////////////
00053 //     Function: MouseSubregion::get_top
00054 //       Access: Published
00055 //  Description: Retrieves the y coordinate of the top edge of the
00056 //               rectangle within the window.  This number will be in
00057 //               the range [0..1].
00058 ////////////////////////////////////////////////////////////////////
00059 PN_stdfloat MouseSubregion::
00060 get_top() const {
00061   return _t;
00062 }
00063 
00064 ////////////////////////////////////////////////////////////////////
00065 //     Function: MouseSubregion::set_dimensions
00066 //       Access: Published
00067 //  Description: Changes the region of the window in which the mouse
00068 //               is considered to be active.  The parameters are
00069 //               identical to those for a DisplayRegion: they range
00070 //               from 0 to 1, where 0,0 is the lower left corner and
00071 //               1,1 is the upper right; (0, 1, 0, 1) represents the
00072 //               whole window.
00073 ////////////////////////////////////////////////////////////////////
00074 void MouseSubregion::
00075 set_dimensions(PN_stdfloat l, PN_stdfloat r, PN_stdfloat b, PN_stdfloat t) {
00076   _l = l;
00077   _r = r;
00078   _b = b;
00079   _t = t;
00080 
00081   _minx = l * 2.0f - 1.0f;
00082   _miny = b * 2.0f - 1.0f;
00083 
00084   PN_stdfloat maxx = r * 2.0f - 1.0f;
00085   PN_stdfloat maxy = t * 2.0f - 1.0f;
00086 
00087   _scalex = 2.0f / (maxx - _minx);
00088   _scaley = 2.0f / (maxy - _miny);
00089 }
 All Classes Functions Variables Enumerations