Merge branch '138-toggle-free-look-with-hotkey' into 'main/atys-live'
[ryzomcore.git] / nel / src / misc / rect.cpp
blobd4347b7e989fe31b88e7d6ca797aada221ffc1d8
1 // NeL - MMORPG Framework <http://dev.ryzom.com/projects/nel/>
2 // Copyright (C) 2010 Winch Gate Property Limited
3 //
4 // This program is free software: you can redistribute it and/or modify
5 // it under the terms of the GNU Affero General Public License as
6 // published by the Free Software Foundation, either version 3 of the
7 // License, or (at your option) any later version.
8 //
9 // This program is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU Affero General Public License for more details.
14 // You should have received a copy of the GNU Affero General Public License
15 // along with this program. If not, see <http://www.gnu.org/licenses/>.
17 #include "stdmisc.h"
19 #include "nel/misc/rect.h"
20 #include "nel/misc/vector_2f.h"
22 #ifdef DEBUG_NEW
23 #define new DEBUG_NEW
24 #endif
26 namespace NLMISC {
28 // *********************************************************************
29 void CRect::extend (sint32 x, sint32 y)
31 if (x<X)
33 Width+=(uint32)(X-x);
34 x=X;
36 else if (x>=(X+(sint32)Width))
37 Width=(uint32)(x-X+1);
38 if (y<Y)
40 Height+=(uint32)(Y-y);
41 y=Y;
43 else if (y>=(Y+(sint32)Height))
44 Height=(uint32)(y-Y+1);
48 // *********************************************************************
49 void CRect::setWH(sint32 x, sint32 y, uint32 width, uint32 height)
51 X=x;
52 Y=y;
53 Width=width;
54 Height=height;
58 // *********************************************************************
59 void CRect::set(sint32 x0, sint32 y0, sint32 x1, sint32 y1)
61 if (x0 < x1)
63 X = x0;
64 Width = x1 - x0;
66 else
68 X = x1;
69 Width = y0 - y1;
72 if (y0 < y1)
74 Y = y0;
75 Height = y1 - y0;
77 else
79 Y = y1;
80 Height = y0 - y1;
84 // *********************************************************************
85 CRect::CRect (sint32 x, sint32 y, uint32 width, uint32 height)
87 setWH(x, y, width, height);
93 } // NLMISC