aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/linden/indra/newview/llpanelmorph.cpp
diff options
context:
space:
mode:
authorJacek Antonelli2008-08-15 23:44:46 -0500
committerJacek Antonelli2008-08-15 23:44:46 -0500
commit38d6d37f2d982fa959e9e8a4a3f7e1ccfad7b5d4 (patch)
treeadca584755d22ca041a2dbfc35d4eca01f70b32c /linden/indra/newview/llpanelmorph.cpp
parentREADME.txt (diff)
downloadmeta-impy-38d6d37f2d982fa959e9e8a4a3f7e1ccfad7b5d4.zip
meta-impy-38d6d37f2d982fa959e9e8a4a3f7e1ccfad7b5d4.tar.gz
meta-impy-38d6d37f2d982fa959e9e8a4a3f7e1ccfad7b5d4.tar.bz2
meta-impy-38d6d37f2d982fa959e9e8a4a3f7e1ccfad7b5d4.tar.xz
Second Life viewer sources 1.13.2.12
Diffstat (limited to 'linden/indra/newview/llpanelmorph.cpp')
-rw-r--r--linden/indra/newview/llpanelmorph.cpp346
1 files changed, 346 insertions, 0 deletions
diff --git a/linden/indra/newview/llpanelmorph.cpp b/linden/indra/newview/llpanelmorph.cpp
new file mode 100644
index 0000000..94d5779
--- /dev/null
+++ b/linden/indra/newview/llpanelmorph.cpp
@@ -0,0 +1,346 @@
1/**
2 * @file llpanelmorph.cpp
3 * @brief LLPanelMorph class implementation
4 *
5 * Copyright (c) 2001-2007, Linden Research, Inc.
6 *
7 * The source code in this file ("Source Code") is provided by Linden Lab
8 * to you under the terms of the GNU General Public License, version 2.0
9 * ("GPL"), unless you have obtained a separate licensing agreement
10 * ("Other License"), formally executed by you and Linden Lab. Terms of
11 * the GPL can be found in doc/GPL-license.txt in this distribution, or
12 * online at http://secondlife.com/developers/opensource/gplv2
13 *
14 * There are special exceptions to the terms and conditions of the GPL as
15 * it is applied to this Source Code. View the full text of the exception
16 * in the file doc/FLOSS-exception.txt in this software distribution, or
17 * online at http://secondlife.com/developers/opensource/flossexception
18 *
19 * By copying, modifying or distributing this software, you acknowledge
20 * that you have read and understood your obligations described above,
21 * and agree to abide by those obligations.
22 *
23 * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
24 * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
25 * COMPLETENESS OR PERFORMANCE.
26 */
27
28// file include
29#include "llviewerprecompiledheaders.h"
30
31/*
32#include "llpanelmorph.h"
33
34// library includes
35#include "llerror.h"
36#include "llrect.h"
37#include "llstring.h"
38#include "llfontgl.h"
39
40// project includes
41#include "llui.h"
42#include "llspinctrl.h"
43#include "llcheckboxctrl.h"
44#include "lltextbox.h"
45#include "llbutton.h"
46//#include "lldraghandle.h"
47
48#include "llviewerwindow.h"
49#include "llviewerobject.h"
50#include "llresmgr.h"
51
52#include "llcontrol.h"
53
54#include "llagent.h"
55#include "llvoavatar.h"
56#include "lltoolmgr.h"
57#include "lltoolmorph.h"
58#include "llquantize.h"
59
60//
61// Constants
62//
63const S32 VPAD = 2;
64const S32 HPAD = 4;
65
66const S32 TITLE_WIDTH = 100;
67const S32 TITLE_HEIGHT = 16;
68
69const S32 CLOSE_BOX_SIZE = 16;
70
71const S32 LABEL_HOFF = 8;
72const S32 LABEL_WIDTH = 140;
73const S32 SPIN_WIDTH = 250;
74
75// minimum and maximum morph weight values (a UI/network constraint, not inherent to morphs)
76const F32 MORPH_WEIGHT_MIN = (-1.f);
77const F32 MORPH_WEIGHT_MAX = (1.f);
78// this is the magic number that morph values are quantized to for network transmission purposes
79// the 200 value is a result of encoding the weights as a string (and avoiding NULL terminators
80// and avoiding \n (the between-NV-pair delimiter). Map -1 to 1 to 50-250. HACK. JC
81const S32 MORPH_WEIGHT_OFFSET = (50);
82const S32 MORPH_WEIGHT_QUANTUM = ((MORPH_WEIGHT_MAX - MORPH_WEIGHT_MIN) / MAXSTRINGVAL);
83
84//#define MORPH_PANEL_SHOW_SPINNERS
85
86//
87// Globals
88//
89LLPanelMorph *gPanelMorph = NULL;
90
91//
92// Methods
93//
94
95//static
96//-----------------------------------------------------------------------------
97// LLPanelMorph()
98//-----------------------------------------------------------------------------
99LLPanelMorph::LLPanelMorph(const std::string& name, const LLRect& rect)
100: LLPanel( name, rect )
101{
102 mParamSpinners = NULL;
103 mSexRadioGroup = NULL;
104 mRect = rect;
105 mMesh = NULL;
106 setBackgroundVisible( TRUE );
107}
108
109//-----------------------------------------------------------------------------
110// ~LLPanelMorph()
111//-----------------------------------------------------------------------------
112LLPanelMorph::~LLPanelMorph()
113{
114#ifdef MORPH_PANEL_SHOW_SPINNERS
115 for (S32 i = 0; i < mNumParamSpinners; i++)
116 {
117 removeChild(mParamSpinners[i]);
118 delete mParamSpinners[i];
119 }
120 delete [] mParamSpinners;
121#endif
122}
123
124// static
125//-----------------------------------------------------------------------------
126// onCommitSexChange()
127//-----------------------------------------------------------------------------
128void LLPanelMorph::onCommitSexChange( void *data)
129{
130// LLRadioGroup *group = (LLRadioGroup *)data;
131
132// LLVOAvatar *avatarp = gAgent.getAvatarObject();
133//
134// LLNameValue* avatarSexNV = avatarp->getNVPair("AvatarSex");
135// if (!avatarSexNV)
136// {
137// avatarp->addNVPair( "AvatarSex U32 READ_WRITE SIM_SPACE_VIEWER 0");
138// avatarSexNV = avatarp->getNVPair("AvatarSex");
139// }
140//
141// avatarSexNV->setU32(gSavedSettings.getU32("AvatarSex"));
142//
143// avatarp->sendNVPairToSimulator("AvatarSex");
144//
145// // preemptively update sex based on local value
146// avatarp->updateSex();
147//
148// LLVisualParamHint::requestHintUpdates();
149
150}
151
152
153// static
154//-----------------------------------------------------------------------------
155// onCommitMorphChange()
156//-----------------------------------------------------------------------------
157void LLPanelMorph::onCommitMorphChange( LLUICtrl* ctrl, void* userdata )
158{
159//#ifdef MORPH_PANEL_SHOW_SPINNERS
160// LLVOAvatar *avatarp = gAgent.getAvatarObject();
161//
162// LLPanelMorph* self = (LLPanelMorph*) userdata;
163//
164// S32 i = 0;
165// for(LLPolyMorphTarget* morphTargetp = self->mMesh->getFirstVisualParam();
166// morphTargetp;
167// morphTargetp = self->mMesh->getNextVisualParam())
168// {
169// for(S32 j = 0; j < self->mNumParamSpinners; j++)
170// {
171// if (!strcmp(self->mParamSpinners[j]->getName(), morphTargetp->getName()))
172// {
173// avatarp->mHeadMesh0.getMesh()->setDistortionWeight(morphTargetp, self->mParamSpinners[j]->get());
174// }
175// }
176// i++;
177// }
178// avatarp->updateDistortions();
179// avatarp->sendVisualParams();
180//#endif
181}
182
183//-----------------------------------------------------------------------------
184// updateSpinners()
185//-----------------------------------------------------------------------------
186void LLPanelMorph::updateSpinners(LLPolyMesh *mesh)
187{
188 if (mesh != mMesh) return;
189#ifdef MORPH_PANEL_SHOW_SPINNERS
190
191 for(LLViewerVisualParam *param = (LLViewerVisualParam*)gAgent.getAvatarObject()->getFirstVisualParam();
192 param;
193 param = gAgent.getAvatarObject()->getNextVisualParam())
194 {
195 if (param->getID() == -1 ||
196 param->getGroup() != LLVisualParam::VISUAL_PARAM_GROUP_TWEAKABLE) continue;
197
198 F32 paramWeight = gAgent.getAvatarObject()->getVisualParamWeight(morphTargetp);
199
200 for (S32 i = 0; i < mNumParamSpinners; i++)
201 {
202 if (!strcmp(mParamSpinners[i]->getName() , morphTargetp->getName()))
203 {
204 mParamSpinners[i]->set(paramWeight);
205 }
206 }
207 }
208#endif
209}
210
211//-----------------------------------------------------------------------------
212// createSpinners()
213//-----------------------------------------------------------------------------
214void LLPanelMorph::createSpinners(LLPolyMesh *mesh)
215{
216 const LLFontGL* font = gResMgr->getRes( LLFONT_SANSSERIF_SMALL );
217 S32 cur_y;
218 S32 new_height;
219 S32 control_focus = -1;
220
221 if (mSexRadioGroup)
222 {
223 removeChild(mSexRadioGroup);
224 delete mSexRadioGroup;
225 }
226
227 if (mParamSpinners)
228 {
229 for (S32 i = 0; i < mNumParamSpinners; i++)
230 {
231 if (mParamSpinners[i]->hasFocus())
232 {
233 control_focus = i;
234 mParamSpinners[i]->setFocus(FALSE);
235 }
236 }
237 for (i = 0; i < mNumParamSpinners; i++)
238 {
239 removeChild(mParamSpinners[i]);
240 delete mParamSpinners[i];
241 }
242 delete [] mParamSpinners;
243 mParamSpinners = NULL;
244 }
245
246#ifdef MORPH_PANEL_SHOW_SPINNERS
247 S32 numSpinners = 0;
248
249 for(LLViewerVisualParam *param = (LLViewerVisualParam*)gAgent.getAvatarObject()->getFirstVisualParam();
250 param;
251 param = gAgent.getAvatarObject()->getNextVisualParam())
252 {
253 if(param->getID() != -1 &&
254 param->getGroup() == LLVisualParam::VISUAL_PARAM_GROUP_TWEAKABLE)
255 {
256 numSpinners++;
257 }
258 }
259
260 if (numSpinners != 0)
261 {
262 mParamSpinners = new LLSpinCtrl*[numSpinners];
263 }
264
265 // set focus back to control #n
266 if (control_focus >= 0 && control_focus < numSpinners)
267 {
268 mParamSpinners[control_focus]->setFocus(TRUE);
269 }
270 new_height = numSpinners * (SPINCTRL_HEIGHT + VPAD) + (VPAD * 3) + CHECKBOXCTRL_HEIGHT + VPAD + VPAD;
271
272#else
273 new_height = (VPAD * 3) + CHECKBOXCTRL_HEIGHT + VPAD + VPAD;
274#endif
275
276 LLRect panelRect = getRect();
277 reshape(panelRect.getWidth(), new_height, TRUE);
278
279 cur_y = new_height - VPAD - VPAD;
280
281 LLRect radio_rect;
282 radio_rect.setLeftTopAndSize(HPAD + LABEL_HOFF,
283 cur_y,
284 getRect().getWidth() - HPAD - HPAD - LABEL_HOFF,
285 CHECKBOXCTRL_HEIGHT + VPAD);
286 mSexRadioGroup = new LLRadioGroup("sex radio",
287 radio_rect,
288 "AvatarSex",
289 &LLPanelMorph::onCommitSexChange,
290 (void *)this);
291 addChild(mSexRadioGroup);
292
293 radio_rect.setLeftTopAndSize(HPAD + LABEL_HOFF,
294 0,
295 (getRect().getWidth() - HPAD - HPAD - LABEL_HOFF) / 2.f,
296 0);
297 mSexRadioGroup->addRadioButton("Female", "Female", radio_rect, font);
298
299 radio_rect.setLeftTopAndSize(((getRect().getWidth() - HPAD - HPAD - LABEL_HOFF) / 2.f) + HPAD + LABEL_HOFF,
300 0,
301 (getRect().getWidth() - HPAD - HPAD - LABEL_HOFF) / 2.f,
302 0);
303 mSexRadioGroup->addRadioButton("Male", "Male", radio_rect, font);
304
305 cur_y -= CHECKBOXCTRL_HEIGHT + VPAD + VPAD;
306
307#ifdef MORPH_PANEL_SHOW_SPINNERS
308 S32 i = 0;
309
310 for(LLViewerVisualParam *param = (LLViewerVisualParam*)gAgent.getAvatarObject()->getFirstVisualParam();
311 param;
312 param = gAgent.getAvatarObject()->getNextVisualParam())
313 {
314 if (param->getID() == -1 ||
315 param->getGroup() != LLVisualParam::VISUAL_PARAM_GROUP_TWEAKABLE) continue;
316 LLRect spinnerRect;
317 spinnerRect.setLeftTopAndSize(HPAD + LABEL_HOFF,
318 cur_y,
319 getRect().getWidth() - HPAD - HPAD - LABEL_HOFF,
320 cur_y - SPINCTRL_HEIGHT);
321 mParamSpinners[i] = new LLSpinCtrl(param->getName(),
322 spinnerRect,
323 font,
324 param->getName(),
325 &LLPanelMorph::onCommitMorphChange,
326 this,
327 param->getWeight(),
328 param->getMinWeight(),
329 param->getMaxWeight(),
330 MORPH_WEIGHT_QUANTUM * 2,
331 NULL,
332 LABEL_WIDTH );
333
334 mParamSpinners[i]->setPrecision(2);
335 mParamSpinners[i]->setFollowsTop();
336 mParamSpinners[i]->setFollowsLeft();
337 addChild(mParamSpinners[i]);
338 cur_y -= VPAD + SPINCTRL_HEIGHT;
339 i++;
340 }
341
342 mNumParamSpinners = numSpinners;
343#endif
344 mMesh = mesh;
345}
346*/