1 // Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
2 // Copyright (C) 2010 Winch Gate Property Limited
4 // This source file has been modified by the following contributors:
5 // Copyright (C) 2013 Laszlo KIS-ADAM (dfighter) <dfighter1985@gmail.com>
7 // This program is free software: you can redistribute it and/or modify
8 // it under the terms of the GNU Affero General Public License as
9 // published by the Free Software Foundation, either version 3 of the
10 // License, or (at your option) any later version.
12 // This program is distributed in the hope that it will be useful,
13 // but WITHOUT ANY WARRANTY; without even the implied warranty of
14 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 // GNU Affero General Public License for more details.
17 // You should have received a copy of the GNU Affero General Public License
18 // along with this program. If not, see <http://www.gnu.org/licenses/>.
22 #ifndef NL_INTERFACE_DDX_H
23 #define NL_INTERFACE_DDX_H
25 #include "nel/misc/types_nl.h"
26 #include "nel/gui/interface_element.h"
27 #include "interface_pointer.h"
29 // Values for float (scrollbar float) must not exceed 200,00 this is due to storing on
30 // an integer value with a precision of 10,000
31 // For the moment realtime parameters are only valid on scrollbar
32 // ***************************************************************************
33 class CInterfaceDDX
: public CInterfaceElement
36 // The number of preset in cfg.
37 enum {NumPreset
= 4, CustomPreset
=NumPreset
};
40 virtual bool parse (xmlNodePtr cur
, CInterfaceGroup
*parentGroup
);
43 virtual ~CInterfaceDDX();
51 // Restore realtime values
54 // Update parameters that are realtime
55 void updateRealtime(CCtrlBase
*pSB
, bool updateOnScrollEnd
);
57 // Update all parameters to obey their preset (no op if no preset or if preset is Custom)
58 void updateParamPreset(NLMISC::CCDBNodeLeaf
*presetChanged
);
60 // set apply button can be pushed
61 void validateApplyButton();
68 // -----------------------
69 enum SParamType
{ DataBase
, ConfigFile
};
70 enum SParamWidget
{ ColorButton
, BoolButton
, ScrollBarInt
, ScrollBarFloat
};
71 enum TRealTimeMode
{ RTModeFalse
=0, RTModeTrue
, RTModeEndScroll
};
73 // -----------------------
75 CInterfaceElementPtr Elt
;
79 // The tex view, result of the scroll
80 CViewTextPtr ResultView
;
81 // The unit to append to the result string
82 std::string ResultUnit
;
83 // For ScrollBarFloat widget only
85 // For ScrollBarFloat widget only
88 // If Widget is scrollbar int or float
91 // When the effect of the param is applied
92 TRealTimeMode RealTimeMode
;
93 sint32 RTBackupValue
; // When canceling
95 // For ConfigFile widget only
96 NLMISC::CCDBNodeLeaf
*PresetDB
;
98 // -----------------------
104 RealTimeMode
= RTModeFalse
;
115 // update ResultView according to widget. Don't modify DB or CFG
116 void WidgetToResultView();
118 // restore the preset value
119 void restoreCFGPreset(uint presetVal
);
121 // From the current CFG value, compare to each preset value, and init the bitfield
122 uint32
getPresetPossibleBF();
125 void updateScrollView(sint32 nVal
);
126 void updateScrollView(double nVal
);
127 void tryRound(double nVal
);
130 // Array of parameters
131 std::vector
<CParam
> _Parameters
;
134 class CPresetObs
: public NLMISC::ICDBNode::IPropertyObserver
137 virtual void update(NLMISC::ICDBNode
* node
);
138 CInterfaceDDX
*Owner
;
140 CPresetObs() : Owner(NULL
) {}
142 CPresetObs _PresetObs
;
143 std::set
<NLMISC::CCDBNodeLeaf
*> _PresetNodes
;
145 // reset the preset values according to parameters values
148 // For apply button ungraying
149 class CCtrlBaseButton
*_ApplyButton
;
152 // ***************************************************************************
157 static CDDXManager
*getInstance()
159 if (_Instance
== NULL
)
160 _Instance
= new CDDXManager
;
165 static void releaseInstance();
167 void add(CInterfaceDDX
*pDDX
);
168 CInterfaceDDX
*get(const std::string
&ddxName
);
169 // Get the ddx from its parent name
170 CInterfaceDDX
*getFromParent(const std::string
&ddxParentName
);
172 // Release the manager
179 static CDDXManager
*_Instance
;
180 std::map
<std::string
, CInterfaceDDX
*> _DDXes
;
183 #endif // NL_INTERFACE_ELEMENT_H
185 /* End of interface_element.h */