Added aqua_speed for rite geo 50 tryker
[ryzomcore.git] / nel / tools / 3d / object_viewer / value_gradient_dlg.cpp
blob5eff39642376eaaee9de5406e3d97f561e5afd8c
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/>.
18 #include "std_afx.h"
19 #include "object_viewer.h"
20 #include "value_gradient_dlg.h"
22 #include "edit_attrib_dlg.h"
23 #include "editable_range.h"
25 #include "popup_notify.h"
28 /////////////////////////////////////////////////////////////////////////////
29 // CValueGradientDlg dialog
32 CValueGradientDlg::CValueGradientDlg(IValueGradientDlgClient *clientInterface,
33 CParticleWorkspace::CNode *ownerNode,
34 bool destroyClientInterface,
35 CWnd* pParent,
36 IPopupNotify *pn,
37 bool canTuneNbStages /* = true*/,
38 uint minSize /*= 2*/)
39 : CDialog(CValueGradientDlg::IDD, pParent),
40 _ClientInterface(clientInterface),
41 _Node(ownerNode),
42 _DestroyClientInterface(destroyClientInterface),
43 _EditValueDlg(NULL),
44 _CanTuneNbStages(canTuneNbStages),
45 _MinSize(minSize),
46 _PN(pn)
48 //{{AFX_DATA_INIT(CValueGradientDlg)
49 //}}AFX_DATA_INIT
50 _NbStepDlg = new CEditableRangeUInt(std::string("GRADIENT NB STEP"), ownerNode, 1, 255);
54 CValueGradientDlg::~CValueGradientDlg()
56 if (_DestroyClientInterface) delete _ClientInterface;
57 delete _EditValueDlg;
58 _NbStepDlg->DestroyWindow();
59 delete _NbStepDlg;
62 void CValueGradientDlg::init(CWnd *pParent)
64 CDialog::Create(IDD_GRADIENT_DLG, pParent);
65 ShowWindow(SW_SHOW);
70 void CValueGradientDlg::DoDataExchange(CDataExchange* pDX)
72 CDialog::DoDataExchange(pDX);
73 //{{AFX_DATA_MAP(CValueGradientDlg)
74 DDX_Control(pDX, IDC_NO_SAMPLES, m_NoSamples);
75 DDX_Control(pDX, IDC_GRADIENT_LIST, m_GradientList);
76 DDX_Control(pDX, IDC_EDITED_VALUE, m_Value);
77 DDX_Control(pDX, IDC_REMOVE_VALUE, m_RemoveCtrl);
78 //}}AFX_DATA_MAP
82 BEGIN_MESSAGE_MAP(CValueGradientDlg, CDialog)
83 //{{AFX_MSG_MAP(CValueGradientDlg)
84 ON_BN_CLICKED(IDC_ADD_VALUE, OnAddValue)
85 ON_BN_CLICKED(IDC_INSERT_VALUE, OnInsertValue)
86 ON_BN_CLICKED(IDC_REMOVE_VALUE, OnRemoveValue)
87 ON_BN_CLICKED(IDC_VALUE_DOWN, OnValueDown)
88 ON_BN_CLICKED(IDC_VALUE_UP, OnValueUp)
89 ON_LBN_SELCHANGE(IDC_GRADIENT_LIST, OnSelchangeGradientList)
90 ON_WM_CLOSE()
91 //}}AFX_MSG_MAP
92 END_MESSAGE_MAP()
94 /////////////////////////////////////////////////////////////////////////////
95 // CValueGradientDlg message handlers
97 void CValueGradientDlg::OnAddValue()
99 nlassert(_ClientInterface);
100 UpdateData();
101 ++_Size;
102 _ClientInterface->modifyGradient(IValueGradientDlgClient::Add, 0);
103 m_GradientList.AddString(_T("value"));
104 m_RemoveCtrl.EnableWindow(TRUE);
106 m_GradientList.SetCurSel(_Size - 1);
107 m_GradientList.Invalidate();
108 OnSelchangeGradientList();
109 UpdateData(FALSE);
112 void CValueGradientDlg::OnInsertValue()
114 nlassert(_ClientInterface);
115 UpdateData();
116 uint oldIndex = m_GradientList.GetCurSel();
117 ++_Size;
118 _ClientInterface->modifyGradient(IValueGradientDlgClient::Insert, m_GradientList.GetCurSel());
119 m_GradientList.InsertString(m_GradientList.GetCurSel(), _T("value"));
120 m_GradientList.Invalidate();
121 m_GradientList.SetCurSel(oldIndex);
122 OnSelchangeGradientList();
123 UpdateData(FALSE);
126 void CValueGradientDlg::OnRemoveValue()
128 nlassert(_ClientInterface);
129 UpdateData();
131 uint oldIndex = m_GradientList.GetCurSel();
132 --_Size;
133 _ClientInterface->modifyGradient(IValueGradientDlgClient::Delete, m_GradientList.GetCurSel());
134 m_GradientList.DeleteString(m_GradientList.GetCurSel());
136 if (_Size <= _MinSize)
138 m_RemoveCtrl.EnableWindow(FALSE);
140 if (oldIndex < _Size)
142 m_GradientList.SetCurSel(oldIndex);
144 else
146 m_GradientList.SetCurSel(oldIndex - 1);
148 m_GradientList.Invalidate();
149 OnSelchangeGradientList(); /// this won't be called automatically ...
150 UpdateData(FALSE);
153 void CValueGradientDlg::OnValueDown()
155 nlassert(_ClientInterface);
156 UpdateData();
157 uint currIndex = m_GradientList.GetCurSel();
158 if (currIndex == (uint) (m_GradientList.GetCount() - 1)) return;
159 _ClientInterface->modifyGradient(IValueGradientDlgClient::Down, currIndex);
160 m_GradientList.SetCurSel(currIndex + 1);
161 m_GradientList.Invalidate();
162 OnSelchangeGradientList();
163 UpdateData(FALSE);
166 void CValueGradientDlg::OnValueUp()
168 nlassert(_ClientInterface);
169 UpdateData();
170 uint currIndex = m_GradientList.GetCurSel();
171 if (currIndex == 0) return;
172 _ClientInterface->modifyGradient(IValueGradientDlgClient::Up, currIndex);
173 m_GradientList.SetCurSel(currIndex - 1);
174 m_GradientList.Invalidate();
175 OnSelchangeGradientList();
176 UpdateData(FALSE);
179 BOOL CValueGradientDlg::OnInitDialog()
181 nlassert(_ClientInterface);
182 _Size = _ClientInterface->getSchemeSize();
183 CDialog::OnInitDialog();
184 UpdateData();
185 m_GradientList.InitStorage(_Size, 16);
186 for (uint k = 0; k < _Size; ++k)
188 m_GradientList.AddString(_T("value"));
190 m_RemoveCtrl.EnableWindow(_Size > _MinSize ? TRUE : FALSE);
191 m_GradientList.SetCurSel(0);
192 m_GradientList.setCtrlID(IDC_GRADIENT_LIST);
193 m_GradientList.setDrawer(_ClientInterface);
195 if (_CanTuneNbStages)
197 _NbStepWrapper.I = _ClientInterface;
198 _NbStepDlg->setWrapper(&_NbStepWrapper);
199 _NbStepDlg->init(181, 45, this);
200 _NbStepDlg->enableLowerBound(0, true);
202 else
204 m_NoSamples.ShowWindow(SW_HIDE);
206 UpdateData(FALSE);
207 OnSelchangeGradientList();
208 return TRUE; // return TRUE unless you set the focus to a control
209 // EXCEPTION: OCX Property Pages should return FALSE
212 void CValueGradientDlg::OnSelchangeGradientList()
214 nlassert(_ClientInterface);
215 UpdateData(TRUE);
216 delete _EditValueDlg;
217 _EditValueDlg = _ClientInterface->createDialog(m_GradientList.GetCurSel(), this, _Node);
219 RECT r, or;
220 GetWindowRect(&or);
221 m_Value.GetWindowRect(&r);
222 _EditValueDlg->init(r.left - or.left, r.top - or.top, this);
223 UpdateData(FALSE);
228 void CValueGradientDlg::invalidateGrad(void)
230 UpdateData(TRUE);
231 m_GradientList.Invalidate();
232 UpdateData(FALSE);
235 void CValueGradientDlg::OnClose()
237 CDialog::OnClose();
238 if (_PN) _PN->childPopupClosed(this);