aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/linden/indra/newview/llviewercontrol.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/llviewercontrol.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/llviewercontrol.cpp')
-rw-r--r--linden/indra/newview/llviewercontrol.cpp484
1 files changed, 484 insertions, 0 deletions
diff --git a/linden/indra/newview/llviewercontrol.cpp b/linden/indra/newview/llviewercontrol.cpp
new file mode 100644
index 0000000..de89965
--- /dev/null
+++ b/linden/indra/newview/llviewercontrol.cpp
@@ -0,0 +1,484 @@
1/**
2 * @file llviewercontrol.cpp
3 * @brief Viewer configuration
4 * @author Richard Nelson
5 *
6 * Copyright (c) 2001-2007, Linden Research, Inc.
7 *
8 * The source code in this file ("Source Code") is provided by Linden Lab
9 * to you under the terms of the GNU General Public License, version 2.0
10 * ("GPL"), unless you have obtained a separate licensing agreement
11 * ("Other License"), formally executed by you and Linden Lab. Terms of
12 * the GPL can be found in doc/GPL-license.txt in this distribution, or
13 * online at http://secondlife.com/developers/opensource/gplv2
14 *
15 * There are special exceptions to the terms and conditions of the GPL as
16 * it is applied to this Source Code. View the full text of the exception
17 * in the file doc/FLOSS-exception.txt in this software distribution, or
18 * online at http://secondlife.com/developers/opensource/flossexception
19 *
20 * By copying, modifying or distributing this software, you acknowledge
21 * that you have read and understood your obligations described above,
22 * and agree to abide by those obligations.
23 *
24 * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
25 * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
26 * COMPLETENESS OR PERFORMANCE.
27 */
28
29#include "llviewerprecompiledheaders.h"
30
31#include "llviewercontrol.h"
32
33#include "indra_constants.h"
34
35#include "v3math.h"
36#include "v3dmath.h"
37#include "llrect.h"
38#include "v4color.h"
39#include "v4coloru.h"
40#include "v3color.h"
41
42#include "llfloater.h"
43#include "llvieweruictrlfactory.h"
44#include "llfirstuse.h"
45#include "llcombobox.h"
46#include "llspinctrl.h"
47#include "llcolorswatch.h"
48
49LLFloaterSettingsDebug* LLFloaterSettingsDebug::sInstance = NULL;
50
51LLControlGroup gSavedSettings; // saved at end of session
52LLControlGroup gSavedPerAccountSettings; // saved at end of session
53LLControlGroup gViewerArt; // read-only
54LLControlGroup gColors; // read-only
55LLControlGroup gCrashSettings; // saved at end of session
56
57LLString gLastRunVersion;
58LLString gCurrentVersion;
59
60char gSettingsFileName[LL_MAX_PATH];
61char gPerAccountSettingsFileName[LL_MAX_PATH] = "";
62
63LLFloaterSettingsDebug::LLFloaterSettingsDebug() : LLFloater("Configuration Editor")
64{
65}
66
67LLFloaterSettingsDebug::~LLFloaterSettingsDebug()
68{
69 sInstance = NULL;
70}
71
72BOOL LLFloaterSettingsDebug::postBuild()
73{
74 LLComboBox* settings_combo = LLUICtrlFactory::getComboBoxByName(this, "settings_combo");
75
76 LLControlGroup::ctrl_name_table_t::iterator name_it;
77 for(name_it = gSavedSettings.mNameTable.begin(); name_it != gSavedSettings.mNameTable.end(); ++name_it)
78 {
79 settings_combo->add(name_it->first, (void*)name_it->second);
80 }
81 for(name_it = gSavedPerAccountSettings.mNameTable.begin(); name_it != gSavedPerAccountSettings.mNameTable.end(); ++name_it)
82 {
83 settings_combo->add(name_it->first, (void*)name_it->second);
84 }
85 for(name_it = gColors.mNameTable.begin(); name_it != gColors.mNameTable.end(); ++name_it)
86 {
87 settings_combo->add(name_it->first, (void*)name_it->second);
88 }
89 settings_combo->sortByName();
90 settings_combo->setCommitCallback(onSettingSelect);
91 settings_combo->setCallbackUserData(this);
92 settings_combo->updateSelection();
93
94 childSetCommitCallback("val_spinner_1", onCommitSettings);
95 childSetUserData("val_spinner_1", this);
96 childSetCommitCallback("val_spinner_2", onCommitSettings);
97 childSetUserData("val_spinner_2", this);
98 childSetCommitCallback("val_spinner_3", onCommitSettings);
99 childSetUserData("val_spinner_3", this);
100 childSetCommitCallback("val_spinner_4", onCommitSettings);
101 childSetUserData("val_spinner_4", this);
102 childSetCommitCallback("val_text", onCommitSettings);
103 childSetUserData("val_text", this);
104 childSetCommitCallback("boolean_combo", onCommitSettings);
105 childSetUserData("boolean_combo", this);
106 childSetCommitCallback("color_swatch", onCommitSettings);
107 childSetUserData("color_swatch", this);
108
109 mComment = (LLTextEditor*)getChildByName("comment_text");
110 return TRUE;
111}
112
113void LLFloaterSettingsDebug::draw()
114{
115 LLComboBox* settings_combo = (LLComboBox*)getChildByName("settings_combo");
116 LLControlBase* controlp = (LLControlBase*)settings_combo->getCurrentUserdata();
117 updateControl(controlp);
118
119 LLFloater::draw();
120}
121
122//static
123void LLFloaterSettingsDebug::show(void*)
124{
125 if (sInstance == NULL)
126 {
127 sInstance = new LLFloaterSettingsDebug();
128
129 gUICtrlFactory->buildFloater(sInstance, "floater_settings_debug.xml");
130 }
131
132 sInstance->open();
133}
134
135//static
136void LLFloaterSettingsDebug::onSettingSelect(LLUICtrl* ctrl, void* user_data)
137{
138 LLFloaterSettingsDebug* floaterp = (LLFloaterSettingsDebug*)user_data;
139 LLComboBox* combo_box = (LLComboBox*)ctrl;
140 LLControlBase* controlp = (LLControlBase*)combo_box->getCurrentUserdata();
141
142 floaterp->updateControl(controlp);
143}
144
145//static
146void LLFloaterSettingsDebug::onCommitSettings(LLUICtrl* ctrl, void* user_data)
147{
148 LLFloaterSettingsDebug* floaterp = (LLFloaterSettingsDebug*)user_data;
149
150 LLComboBox* settings_combo = (LLComboBox*)floaterp->getChildByName("settings_combo");
151 LLControlBase* controlp = (LLControlBase*)settings_combo->getCurrentUserdata();
152
153 LLVector3 vector;
154 LLVector3d vectord;
155 LLRect rect;
156 LLColor4 col4;
157 LLColor3 col3;
158 LLColor4U col4U;
159 LLColor4 color_with_alpha;
160
161 switch(controlp->type())
162 {
163 case TYPE_U32:
164 controlp->set(floaterp->childGetValue("val_spinner_1"));
165 break;
166 case TYPE_S32:
167 controlp->set(floaterp->childGetValue("val_spinner_1"));
168 break;
169 case TYPE_F32:
170 controlp->set(LLSD(floaterp->childGetValue("val_spinner_1").asReal()));
171 break;
172 case TYPE_BOOLEAN:
173 controlp->set(floaterp->childGetValue("boolean_combo"));
174 break;
175 case TYPE_STRING:
176 controlp->set(LLSD(floaterp->childGetValue("val_text").asString()));
177 break;
178 case TYPE_VEC3:
179 vector.mV[VX] = (F32)floaterp->childGetValue("val_spinner_1").asReal();
180 vector.mV[VY] = (F32)floaterp->childGetValue("val_spinner_2").asReal();
181 vector.mV[VZ] = (F32)floaterp->childGetValue("val_spinner_3").asReal();
182 controlp->set(vector.getValue());
183 break;
184 case TYPE_VEC3D:
185 vectord.mdV[VX] = floaterp->childGetValue("val_spinner_1").asReal();
186 vectord.mdV[VY] = floaterp->childGetValue("val_spinner_2").asReal();
187 vectord.mdV[VZ] = floaterp->childGetValue("val_spinner_3").asReal();
188 controlp->set(vectord.getValue());
189 break;
190 case TYPE_RECT:
191 rect.mLeft = floaterp->childGetValue("val_spinner_1").asInteger();
192 rect.mRight = floaterp->childGetValue("val_spinner_2").asInteger();
193 rect.mBottom = floaterp->childGetValue("val_spinner_3").asInteger();
194 rect.mTop = floaterp->childGetValue("val_spinner_4").asInteger();
195 controlp->set(rect.getValue());
196 break;
197 case TYPE_COL4:
198 col3.setValue(floaterp->childGetValue("color_swatch"));
199 col4 = LLColor4(col3, (F32)floaterp->childGetValue("val_spinner_4").asReal());
200 controlp->set(col4.getValue());
201 break;
202 case TYPE_COL3:
203 controlp->set(floaterp->childGetValue("color_swatch"));
204 //col3.mV[VRED] = (F32)floaterp->childGetValue("val_spinner_1").asC();
205 //col3.mV[VGREEN] = (F32)floaterp->childGetValue("val_spinner_2").asReal();
206 //col3.mV[VBLUE] = (F32)floaterp->childGetValue("val_spinner_3").asReal();
207 //controlp->set(col3.getValue());
208 break;
209 case TYPE_COL4U:
210 col3.setValue(floaterp->childGetValue("color_swatch"));
211 col4U.setVecScaleClamp(col3);
212 col4U.mV[VALPHA] = floaterp->childGetValue("val_spinner_4").asInteger();
213 controlp->set(col4U.getValue());
214 break;
215 default:
216 break;
217 }
218}
219
220// we've switched controls, or doing per-frame update, so update spinners, etc.
221void LLFloaterSettingsDebug::updateControl(LLControlBase* controlp)
222{
223 LLSpinCtrl* spinner1 = LLUICtrlFactory::getSpinnerByName(this, "val_spinner_1");
224 LLSpinCtrl* spinner2 = LLUICtrlFactory::getSpinnerByName(this, "val_spinner_2");
225 LLSpinCtrl* spinner3 = LLUICtrlFactory::getSpinnerByName(this, "val_spinner_3");
226 LLSpinCtrl* spinner4 = LLUICtrlFactory::getSpinnerByName(this, "val_spinner_4");
227 LLColorSwatchCtrl* color_swatch = LLUICtrlFactory::getColorSwatchByName(this, "color_swatch");
228 spinner1->setVisible(FALSE);
229 spinner2->setVisible(FALSE);
230 spinner3->setVisible(FALSE);
231 spinner4->setVisible(FALSE);
232 color_swatch->setVisible(FALSE);
233 childSetVisible("val_text", FALSE);
234 childSetVisible("boolean_combo", FALSE);
235 mComment->setText("");
236
237 if (controlp)
238 {
239 eControlType type = controlp->type();
240 mComment->setText(controlp->getComment());
241 spinner1->setMaxValue(F32_MAX);
242 spinner2->setMaxValue(F32_MAX);
243 spinner3->setMaxValue(F32_MAX);
244 spinner4->setMaxValue(F32_MAX);
245 spinner1->setMinValue(-F32_MAX);
246 spinner2->setMinValue(-F32_MAX);
247 spinner3->setMinValue(-F32_MAX);
248 spinner4->setMinValue(-F32_MAX);
249 if (!spinner1->hasFocus())
250 {
251 spinner1->setIncrement(0.1f);
252 }
253 if (!spinner2->hasFocus())
254 {
255 spinner2->setIncrement(0.1f);
256 }
257 if (!spinner3->hasFocus())
258 {
259 spinner3->setIncrement(0.1f);
260 }
261 if (!spinner4->hasFocus())
262 {
263 spinner4->setIncrement(0.1f);
264 }
265
266 LLSD sd = controlp->get();
267 switch(type)
268 {
269 case TYPE_U32:
270 spinner1->setVisible(TRUE);
271 spinner1->setLabel("value");
272 if (!spinner1->hasFocus())
273 {
274 spinner1->setValue(sd);
275 spinner1->setMinValue((F32)U32_MIN);
276 spinner1->setMaxValue((F32)U32_MAX);
277 spinner1->setIncrement(1.f);
278 spinner1->setPrecision(0);
279 }
280 break;
281 case TYPE_S32:
282 spinner1->setVisible(TRUE);
283 spinner1->setLabel("value");
284 if (!spinner1->hasFocus())
285 {
286 spinner1->setValue(sd);
287 spinner1->setMinValue((F32)S32_MIN);
288 spinner1->setMaxValue((F32)S32_MAX);
289 spinner1->setIncrement(1.f);
290 spinner1->setPrecision(0);
291 }
292 break;
293 case TYPE_F32:
294 spinner1->setVisible(TRUE);
295 spinner1->setLabel("value");
296 if (!spinner1->hasFocus())
297 {
298 spinner1->setPrecision(3);
299 spinner1->setValue(sd);
300 }
301 break;
302 case TYPE_BOOLEAN:
303 childSetVisible("boolean_combo", TRUE);
304
305 if (!childHasFocus("boolean_combo"))
306 {
307 if (sd.asBoolean())
308 {
309 childSetValue("boolean_combo", LLSD("true"));
310 }
311 else
312 {
313 childSetValue("boolean_combo", LLSD(""));
314 }
315 }
316 break;
317 case TYPE_STRING:
318 childSetVisible("val_text", TRUE);
319 if (!childHasFocus("val_text"))
320 {
321 childSetValue("val_text", sd);
322 }
323 break;
324 case TYPE_VEC3:
325 {
326 LLVector3 v;
327 v.setValue(sd);
328 spinner1->setVisible(TRUE);
329 spinner1->setLabel("X");
330 spinner2->setVisible(TRUE);
331 spinner2->setLabel("Y");
332 spinner3->setVisible(TRUE);
333 spinner3->setLabel("Z");
334 if (!spinner1->hasFocus())
335 {
336 spinner1->setPrecision(3);
337 spinner1->setValue(v[VX]);
338 }
339 if (!spinner2->hasFocus())
340 {
341 spinner2->setPrecision(3);
342 spinner2->setValue(v[VY]);
343 }
344 if (!spinner3->hasFocus())
345 {
346 spinner3->setPrecision(3);
347 spinner3->setValue(v[VZ]);
348 }
349 break;
350 }
351 case TYPE_VEC3D:
352 {
353 LLVector3d v;
354 v.setValue(sd);
355 spinner1->setVisible(TRUE);
356 spinner1->setLabel("X");
357 spinner2->setVisible(TRUE);
358 spinner2->setLabel("Y");
359 spinner3->setVisible(TRUE);
360 spinner3->setLabel("Z");
361 if (!spinner1->hasFocus())
362 {
363 spinner1->setPrecision(3);
364 spinner1->setValue(v[VX]);
365 }
366 if (!spinner2->hasFocus())
367 {
368 spinner2->setPrecision(3);
369 spinner2->setValue(v[VY]);
370 }
371 if (!spinner3->hasFocus())
372 {
373 spinner3->setPrecision(3);
374 spinner3->setValue(v[VZ]);
375 }
376 break;
377 }
378 case TYPE_RECT:
379 {
380 LLRect r;
381 r.setValue(sd);
382 spinner1->setVisible(TRUE);
383 spinner1->setLabel("Left");
384 spinner2->setVisible(TRUE);
385 spinner2->setLabel("Right");
386 spinner3->setVisible(TRUE);
387 spinner3->setLabel("Bottom");
388 spinner4->setVisible(TRUE);
389 spinner4->setLabel("Top");
390 if (!spinner1->hasFocus())
391 {
392 spinner1->setPrecision(0);
393 spinner1->setValue(r.mLeft);
394 }
395 if (!spinner2->hasFocus())
396 {
397 spinner2->setPrecision(0);
398 spinner2->setValue(r.mRight);
399 }
400 if (!spinner3->hasFocus())
401 {
402 spinner3->setPrecision(0);
403 spinner3->setValue(r.mBottom);
404 }
405 if (!spinner4->hasFocus())
406 {
407 spinner4->setPrecision(0);
408 spinner4->setValue(r.mTop);
409 }
410
411 spinner1->setMinValue((F32)S32_MIN);
412 spinner1->setMaxValue((F32)S32_MAX);
413 spinner1->setIncrement(1.f);
414
415 spinner2->setMinValue((F32)S32_MIN);
416 spinner2->setMaxValue((F32)S32_MAX);
417 spinner2->setIncrement(1.f);
418
419 spinner3->setMinValue((F32)S32_MIN);
420 spinner3->setMaxValue((F32)S32_MAX);
421 spinner3->setIncrement(1.f);
422
423 spinner4->setMinValue((F32)S32_MIN);
424 spinner4->setMaxValue((F32)S32_MAX);
425 spinner4->setIncrement(1.f);
426 break;
427 }
428 case TYPE_COL4:
429 {
430 LLColor4 clr;
431 clr.setValue(sd);
432 color_swatch->setVisible(TRUE);
433 // only set if changed so color picker doesn't update
434 if(clr != LLColor4(color_swatch->getValue()))
435 {
436 color_swatch->set(LLColor4(sd), TRUE, FALSE);
437 }
438 spinner4->setVisible(TRUE);
439 spinner4->setLabel("Alpha");
440 if (!spinner4->hasFocus())
441 {
442 spinner4->setPrecision(3);
443 spinner4->setValue(clr.mV[VALPHA]);
444 }
445 break;
446 }
447 case TYPE_COL3:
448 {
449 LLColor3 clr;
450 clr.setValue(sd);
451 color_swatch->setVisible(TRUE);
452 color_swatch->setValue(sd);
453 break;
454 }
455 case TYPE_COL4U:
456 {
457 LLColor4U clr;
458 clr.setValue(sd);
459 color_swatch->setVisible(TRUE);
460 if(LLColor4(clr) != LLColor4(color_swatch->getValue()))
461 {
462 color_swatch->set(LLColor4(clr), TRUE, FALSE);
463 }
464 spinner4->setVisible(TRUE);
465 spinner4->setLabel("Alpha");
466 if(!spinner4->hasFocus())
467 {
468 spinner4->setPrecision(0);
469 spinner4->setValue(clr.mV[VALPHA]);
470 }
471
472 spinner4->setMinValue(0);
473 spinner4->setMaxValue(255);
474 spinner4->setIncrement(1.f);
475
476 break;
477 }
478 default:
479 mComment->setText("unknown");
480 break;
481 }
482 }
483
484}