aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/linden/indra/newview/llfloaterpostprocess.cpp
diff options
context:
space:
mode:
authorJacek Antonelli2008-08-15 23:45:34 -0500
committerJacek Antonelli2008-08-15 23:45:34 -0500
commitcd17687f01420952712a500107e0f93e7ab8d5f8 (patch)
treece48c2b706f2c1176290e39fb555fbdf6648ce01 /linden/indra/newview/llfloaterpostprocess.cpp
parentSecond Life viewer sources 1.19.0.5 (diff)
downloadmeta-impy-cd17687f01420952712a500107e0f93e7ab8d5f8.zip
meta-impy-cd17687f01420952712a500107e0f93e7ab8d5f8.tar.gz
meta-impy-cd17687f01420952712a500107e0f93e7ab8d5f8.tar.bz2
meta-impy-cd17687f01420952712a500107e0f93e7ab8d5f8.tar.xz
Second Life viewer sources 1.19.1.0
Diffstat (limited to '')
-rw-r--r--linden/indra/newview/llfloaterpostprocess.cpp273
1 files changed, 273 insertions, 0 deletions
diff --git a/linden/indra/newview/llfloaterpostprocess.cpp b/linden/indra/newview/llfloaterpostprocess.cpp
new file mode 100644
index 0000000..999ad5d
--- /dev/null
+++ b/linden/indra/newview/llfloaterpostprocess.cpp
@@ -0,0 +1,273 @@
1/**
2 * @file llfloaterpostprocess.cpp
3 * @brief LLFloaterPostProcess class definition
4 *
5 * $LicenseInfo:firstyear=2007&license=viewergpl$
6 *
7 * Copyright (c) 2007-2008, Linden Research, Inc.
8 *
9 * Second Life Viewer Source Code
10 * The source code in this file ("Source Code") is provided by Linden Lab
11 * to you under the terms of the GNU General Public License, version 2.0
12 * ("GPL"), unless you have obtained a separate licensing agreement
13 * ("Other License"), formally executed by you and Linden Lab. Terms of
14 * the GPL can be found in doc/GPL-license.txt in this distribution, or
15 * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2
16 *
17 * There are special exceptions to the terms and conditions of the GPL as
18 * it is applied to this Source Code. View the full text of the exception
19 * in the file doc/FLOSS-exception.txt in this software distribution, or
20 * online at http://secondlifegrid.net/programs/open_source/licensing/flossexception
21 *
22 * By copying, modifying or distributing this software, you acknowledge
23 * that you have read and understood your obligations described above,
24 * and agree to abide by those obligations.
25 *
26 * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
27 * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
28 * COMPLETENESS OR PERFORMANCE.
29 * $/LicenseInfo$
30 */
31
32#include "llviewerprecompiledheaders.h"
33
34#include "llfloaterpostprocess.h"
35
36#include "llsliderctrl.h"
37#include "llcheckboxctrl.h"
38#include "llvieweruictrlfactory.h"
39#include "llviewerdisplay.h"
40#include "llpostprocess.h"
41#include "llcombobox.h"
42#include "lllineeditor.h"
43#include "llviewerwindow.h"
44
45
46LLFloaterPostProcess* LLFloaterPostProcess::sPostProcess = NULL;
47
48
49LLFloaterPostProcess::LLFloaterPostProcess() : LLFloater("Post-Process Floater")
50{
51 gUICtrlFactory->buildFloater(this, "floater_post_process.xml");
52
53 /// Color Filter Callbacks
54 childSetCommitCallback("ColorFilterToggle", &LLFloaterPostProcess::onBoolToggle, (char*)"enable_color_filter");
55 //childSetCommitCallback("ColorFilterGamma", &LLFloaterPostProcess::onFloatControlMoved, &(gPostProcess->tweaks.gamma()));
56 childSetCommitCallback("ColorFilterBrightness", &LLFloaterPostProcess::onFloatControlMoved, (char*)"brightness");
57 childSetCommitCallback("ColorFilterSaturation", &LLFloaterPostProcess::onFloatControlMoved, (char*)"saturation");
58 childSetCommitCallback("ColorFilterContrast", &LLFloaterPostProcess::onFloatControlMoved, (char*)"contrast");
59
60 childSetCommitCallback("ColorFilterBaseR", &LLFloaterPostProcess::onColorControlRMoved, (char*)"contrast_base");
61 childSetCommitCallback("ColorFilterBaseG", &LLFloaterPostProcess::onColorControlGMoved, (char*)"contrast_base");
62 childSetCommitCallback("ColorFilterBaseB", &LLFloaterPostProcess::onColorControlBMoved, (char*)"contrast_base");
63 childSetCommitCallback("ColorFilterBaseI", &LLFloaterPostProcess::onColorControlIMoved, (char*)"contrast_base");
64
65 /// Night Vision Callbacks
66 childSetCommitCallback("NightVisionToggle", &LLFloaterPostProcess::onBoolToggle, (char*)"enable_night_vision");
67 childSetCommitCallback("NightVisionBrightMult", &LLFloaterPostProcess::onFloatControlMoved, (char*)"brightness_multiplier");
68 childSetCommitCallback("NightVisionNoiseSize", &LLFloaterPostProcess::onFloatControlMoved, (char*)"noise_size");
69 childSetCommitCallback("NightVisionNoiseStrength", &LLFloaterPostProcess::onFloatControlMoved, (char*)"noise_strength");
70
71 /// Bloom Callbacks
72 childSetCommitCallback("BloomToggle", &LLFloaterPostProcess::onBoolToggle, (char*)"enable_bloom");
73 childSetCommitCallback("BloomExtract", &LLFloaterPostProcess::onFloatControlMoved, (char*)"extract_low");
74 childSetCommitCallback("BloomSize", &LLFloaterPostProcess::onFloatControlMoved, (char*)"bloom_width");
75 childSetCommitCallback("BloomStrength", &LLFloaterPostProcess::onFloatControlMoved, (char*)"bloom_strength");
76
77 // Effect loading and saving.
78 LLComboBox* comboBox = LLUICtrlFactory::getComboBoxByName(this, "PPEffectsCombo");
79 childSetAction("PPLoadEffect", &LLFloaterPostProcess::onLoadEffect, comboBox);
80 comboBox->setCommitCallback(onChangeEffectName);
81
82 LLLineEditor* editBox = LLUICtrlFactory::getLineEditorByName(this, "PPEffectNameEditor");
83 childSetAction("PPSaveEffect", &LLFloaterPostProcess::onSaveEffect, editBox);
84
85 syncMenu();
86
87}
88
89LLFloaterPostProcess::~LLFloaterPostProcess()
90{
91
92
93}
94
95LLFloaterPostProcess* LLFloaterPostProcess::instance()
96{
97 // if we don't have our singleton instance, create it
98 if (!sPostProcess)
99 {
100 sPostProcess = new LLFloaterPostProcess();
101 sPostProcess->open();
102 sPostProcess->setFocus(TRUE);
103 }
104 return sPostProcess;
105}
106
107// Bool Toggle
108void LLFloaterPostProcess::onBoolToggle(LLUICtrl* ctrl, void* userData)
109{
110 char const * boolVariableName = (char const *)userData;
111
112 // check the bool
113 LLCheckBoxCtrl* cbCtrl = static_cast<LLCheckBoxCtrl*>(ctrl);
114 gPostProcess->tweaks[boolVariableName] = cbCtrl->getValue();
115}
116
117// Float Moved
118void LLFloaterPostProcess::onFloatControlMoved(LLUICtrl* ctrl, void* userData)
119{
120 char const * floatVariableName = (char const *)userData;
121 LLSliderCtrl* sldrCtrl = static_cast<LLSliderCtrl*>(ctrl);
122 gPostProcess->tweaks[floatVariableName] = sldrCtrl->getValue();
123}
124
125// Color Moved
126void LLFloaterPostProcess::onColorControlRMoved(LLUICtrl* ctrl, void* userData)
127{
128 char const * floatVariableName = (char const *)userData;
129 LLSliderCtrl* sldrCtrl = static_cast<LLSliderCtrl*>(ctrl);
130 gPostProcess->tweaks[floatVariableName][0] = sldrCtrl->getValue();
131}
132
133// Color Moved
134void LLFloaterPostProcess::onColorControlGMoved(LLUICtrl* ctrl, void* userData)
135{
136 char const * floatVariableName = (char const *)userData;
137 LLSliderCtrl* sldrCtrl = static_cast<LLSliderCtrl*>(ctrl);
138 gPostProcess->tweaks[floatVariableName][1] = sldrCtrl->getValue();
139}
140
141// Color Moved
142void LLFloaterPostProcess::onColorControlBMoved(LLUICtrl* ctrl, void* userData)
143{
144 char const * floatVariableName = (char const *)userData;
145 LLSliderCtrl* sldrCtrl = static_cast<LLSliderCtrl*>(ctrl);
146 gPostProcess->tweaks[floatVariableName][2] = sldrCtrl->getValue();
147}
148
149// Color Moved
150void LLFloaterPostProcess::onColorControlIMoved(LLUICtrl* ctrl, void* userData)
151{
152 char const * floatVariableName = (char const *)userData;
153 LLSliderCtrl* sldrCtrl = static_cast<LLSliderCtrl*>(ctrl);
154 gPostProcess->tweaks[floatVariableName][3] = sldrCtrl->getValue();
155}
156
157void LLFloaterPostProcess::onLoadEffect(void* userData)
158{
159 LLComboBox* comboBox = static_cast<LLComboBox*>(userData);
160
161 LLSD::String effectName(comboBox->getSelectedValue().asString());
162
163 gPostProcess->setSelectedEffect(effectName);
164
165 sPostProcess->syncMenu();
166}
167
168void LLFloaterPostProcess::onSaveEffect(void* userData)
169{
170 LLLineEditor* editBox = static_cast<LLLineEditor*>(userData);
171
172 LLSD::String effectName(editBox->getValue().asString());
173
174 if (gPostProcess->mAllEffects.has(effectName))
175 {
176 gViewerWindow->alertXml("PPSaveEffectAlert", &LLFloaterPostProcess::saveAlertCallback, userData);
177 }
178 else
179 {
180 gPostProcess->saveEffect(effectName);
181 sPostProcess->syncMenu();
182 }
183}
184
185void LLFloaterPostProcess::onChangeEffectName(LLUICtrl* ctrl, void * userData)
186{
187 // get the combo box and name
188 LLComboBox * comboBox = static_cast<LLComboBox*>(ctrl);
189 LLLineEditor* editBox = LLUICtrlFactory::getLineEditorByName(sPostProcess,
190 "PPEffectNameEditor");
191
192 // set the parameter's new name
193 editBox->setValue(comboBox->getSelectedValue());
194}
195
196void LLFloaterPostProcess::saveAlertCallback(S32 option, void* userData)
197{
198 LLLineEditor* editBox = static_cast<LLLineEditor*>(userData);
199
200 // if they choose save, do it. Otherwise, don't do anything
201 if (option == 0)
202 {
203 LLSD::String effectName(editBox->getValue().asString());
204
205 gPostProcess->saveEffect(effectName);
206
207 sPostProcess->syncMenu();
208 }
209
210}
211
212void LLFloaterPostProcess::show()
213{
214 // get the instance, make sure the values are synced
215 // and open the menu
216 LLFloaterPostProcess* postProcess = instance();
217 postProcess->syncMenu();
218 postProcess->open();
219}
220
221// virtual
222void LLFloaterPostProcess::onClose(bool app_quitting)
223{
224 // just set visibility to false, don't get fancy yet
225 if (sPostProcess)
226 {
227 sPostProcess->setVisible(FALSE);
228 }
229}
230
231void LLFloaterPostProcess::syncMenu()
232{
233 // add the combo boxe contents
234 LLComboBox* comboBox = LLUICtrlFactory::getComboBoxByName(this, "PPEffectsCombo");
235
236 if(comboBox != NULL) {
237 comboBox->removeall();
238
239 LLSD::map_const_iterator currEffect;
240 for(currEffect = gPostProcess->mAllEffects.beginMap();
241 currEffect != gPostProcess->mAllEffects.endMap();
242 ++currEffect)
243 {
244 comboBox->add(currEffect->first);
245 }
246
247 // set the current effect as selected.
248 comboBox->selectByValue(gPostProcess->getSelectedEffect());
249 }
250
251 /// Sync Color Filter Menu
252 childSetValue("ColorFilterToggle", gPostProcess->tweaks.useColorFilter());
253 //childSetValue("ColorFilterGamma", gPostProcess->tweaks.gamma());
254 childSetValue("ColorFilterBrightness", gPostProcess->tweaks.brightness());
255 childSetValue("ColorFilterSaturation", gPostProcess->tweaks.saturation());
256 childSetValue("ColorFilterContrast", gPostProcess->tweaks.contrast());
257 childSetValue("ColorFilterBaseR", gPostProcess->tweaks.contrastBaseR());
258 childSetValue("ColorFilterBaseG", gPostProcess->tweaks.contrastBaseG());
259 childSetValue("ColorFilterBaseB", gPostProcess->tweaks.contrastBaseB());
260 childSetValue("ColorFilterBaseI", gPostProcess->tweaks.contrastBaseIntensity());
261
262 /// Sync Night Vision Menu
263 childSetValue("NightVisionToggle", gPostProcess->tweaks.useNightVisionShader());
264 childSetValue("NightVisionBrightMult", gPostProcess->tweaks.brightMult());
265 childSetValue("NightVisionNoiseSize", gPostProcess->tweaks.noiseSize());
266 childSetValue("NightVisionNoiseStrength", gPostProcess->tweaks.noiseStrength());
267
268 /// Sync Bloom Menu
269 childSetValue("BloomToggle", LLSD(gPostProcess->tweaks.useBloomShader()));
270 childSetValue("BloomExtract", gPostProcess->tweaks.extractLow());
271 childSetValue("BloomSize", gPostProcess->tweaks.bloomWidth());
272 childSetValue("BloomStrength", gPostProcess->tweaks.bloomStrength());
273}