Merge branch '138-toggle-free-look-with-hotkey' into main/gingo-test
[ryzomcore.git] / ryzom / client / src / interfaces_manager / scrollable_control.cpp
bloba29b077ca5e0c34b90fc4cbdff15bd573139a8e6
1 // Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
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/>.
19 #include "stdpch.h"
21 #include "scrollable_control.h"
25 * default Constructor
27 CScrollableControl::CScrollableControl(uint id)
28 : CControl(id)
30 _HScroll = NULL;
31 _VScroll = NULL;
32 _AutoHide = false;
33 _Show = !_AutoHide;
37 * Destructor
39 CScrollableControl::~CScrollableControl()
41 if ( _HScroll != NULL )
42 delete _HScroll;
44 if ( _VScroll != NULL )
45 delete _VScroll;
49 /**
50 * hScroll
52 void CScrollableControl::hScroll( bool on)
54 // if we want to show a HScroll bar and that it doesn't exist, build a new one
55 if ( (on == true) && ( _HScroll == NULL) )
57 _HScroll = new CScrollBar(0, 0, 0, 0, 0, _W , 0, _W_Pixel , 16, false, this);
58 _HScroll->hotSpot( CControl::THotSpot::HS_TR );
59 _HScroll->origin( CControl::THotSpot::HS_BL );
61 _Children.push_back( _HScroll );
63 // hide the scroll bar
64 else if ( (on == false) && ( _HScroll != NULL) )
66 if (_AutoHide == true)
67 _HScroll->show( false );
68 else
69 _HScroll->enable( false );
71 // show the scroll bar
72 else if ( (on == true)&& ( _HScroll != NULL) )
74 _HScroll->show( true );
75 _HScroll->enable( true );
79 /**
80 * vScroll
82 void CScrollableControl::vScroll( bool on )
84 if ( (on == true) && ( _VScroll == NULL) )
86 _VScroll = new CScrollBar(0, 0, 0, 0, 0, 0 , _H, 16 , _H_Pixel, false, this);
88 _HScroll->hotSpot( CControl::THotSpot::HS_TL );
89 _HScroll->origin( CControl::THotSpot::HS_BR );
91 _Children.push_back( _VScroll );
93 // hide the scroll bar
94 else if ( (on == false) && ( _VScroll != NULL) )
96 if (_AutoHide == true)
97 _VScroll->show( false );
98 else
99 _VScroll->enable( false );
101 // show the scroll bar
102 else if ( (on == true)&& ( _VScroll != NULL) )
104 _VScroll->show( true );
105 _VScroll->enable( true );
111 * autoHide
113 void CScrollableControl::autoHide(bool on)
115 _AutoHide = on;
119 //-----------------------------------------------
120 // click :
121 //-----------------------------------------------
122 void CScrollableControl::click(float x, float y, bool &taken)
124 if (_VScroll != NULL)
125 _VScroll->click(x,y,taken);
126 if (_HScroll != NULL)
127 _HScroll->click(x,y,taken);
131 //-----------------------------------------------
132 // clickRight :
133 //-----------------------------------------------
134 void CScrollableControl::clickRight(float x, float y, bool &taken)
136 if (_VScroll != NULL)
137 _VScroll->clickRight(x,y,taken);
138 if (_HScroll != NULL)
139 _HScroll->clickRight(x,y,taken);