aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/linden/indra/newview/llfloatermute.cpp
diff options
context:
space:
mode:
authorJacek Antonelli2008-08-15 23:45:27 -0500
committerJacek Antonelli2008-08-15 23:45:27 -0500
commita8a62201ba762e98dff92cf49033e577fc34d8d4 (patch)
tree11f8513c5cdc222f2fac0c93eb724c089803c200 /linden/indra/newview/llfloatermute.cpp
parentSecond Life viewer sources 1.18.6.4-RC (diff)
downloadmeta-impy-a8a62201ba762e98dff92cf49033e577fc34d8d4.zip
meta-impy-a8a62201ba762e98dff92cf49033e577fc34d8d4.tar.gz
meta-impy-a8a62201ba762e98dff92cf49033e577fc34d8d4.tar.bz2
meta-impy-a8a62201ba762e98dff92cf49033e577fc34d8d4.tar.xz
Second Life viewer sources 1.19.0.0
Diffstat (limited to '')
-rw-r--r--linden/indra/newview/llfloatermute.cpp177
1 files changed, 127 insertions, 50 deletions
diff --git a/linden/indra/newview/llfloatermute.cpp b/linden/indra/newview/llfloatermute.cpp
index 26e2be3..db88d46 100644
--- a/linden/indra/newview/llfloatermute.cpp
+++ b/linden/indra/newview/llfloatermute.cpp
@@ -12,12 +12,12 @@
12 * ("GPL"), unless you have obtained a separate licensing agreement 12 * ("GPL"), unless you have obtained a separate licensing agreement
13 * ("Other License"), formally executed by you and Linden Lab. Terms of 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 14 * the GPL can be found in doc/GPL-license.txt in this distribution, or
15 * online at http://secondlife.com/developers/opensource/gplv2 15 * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2
16 * 16 *
17 * There are special exceptions to the terms and conditions of the GPL as 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 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 19 * in the file doc/FLOSS-exception.txt in this software distribution, or
20 * online at http://secondlife.com/developers/opensource/flossexception 20 * online at http://secondlifegrid.net/programs/open_source/licensing/flossexception
21 * 21 *
22 * By copying, modifying or distributing this software, you acknowledge 22 * By copying, modifying or distributing this software, you acknowledge
23 * that you have read and understood your obligations described above, 23 * that you have read and understood your obligations described above,
@@ -51,6 +51,7 @@
51#include "llviewertexteditor.h" 51#include "llviewertexteditor.h"
52#include "llviewerwindow.h" 52#include "llviewerwindow.h"
53#include "llvieweruictrlfactory.h" 53#include "llvieweruictrlfactory.h"
54#include "llfocusmgr.h"
54 55
55// 56//
56// Constants 57// Constants
@@ -69,6 +70,117 @@ const S32 HPAD = 4;
69// 70//
70LLFloaterMute* gFloaterMute = NULL; 71LLFloaterMute* gFloaterMute = NULL;
71 72
73//-----------------------------------------------------------------------------
74// LLFloaterMuteObjectUI()
75//-----------------------------------------------------------------------------
76// Class for handling mute object by name floater.
77class LLFloaterMuteObjectUI : public LLFloater
78{
79public:
80 typedef void(*callback_t)(const LLString&, void*);
81
82 static LLFloaterMuteObjectUI* show(callback_t callback,
83 void* userdata);
84 virtual BOOL postBuild();
85
86protected:
87 LLFloaterMuteObjectUI();
88 virtual ~LLFloaterMuteObjectUI();
89 virtual BOOL handleKeyHere(KEY key, MASK mask, BOOL called_from_parent);
90
91private:
92 // UI Callbacks
93 static void onBtnOk(void *data);
94 static void onBtnCancel(void *data);
95
96 void (*mCallback)(const LLString& objectName,
97 void* userdata);
98 void* mCallbackUserData;
99
100 static LLFloaterMuteObjectUI* sInstance;
101};
102
103LLFloaterMuteObjectUI* LLFloaterMuteObjectUI::sInstance = NULL;
104
105LLFloaterMuteObjectUI::LLFloaterMuteObjectUI()
106 : LLFloater("Mute object by name"),
107 mCallback(NULL),
108 mCallbackUserData(NULL)
109{
110 gUICtrlFactory->buildFloater(this, "floater_mute_object.xml", NULL);
111}
112
113// Destroys the object
114LLFloaterMuteObjectUI::~LLFloaterMuteObjectUI()
115{
116 gFocusMgr.releaseFocusIfNeeded( this );
117 sInstance = NULL;
118}
119
120LLFloaterMuteObjectUI* LLFloaterMuteObjectUI::show(callback_t callback,
121 void* userdata)
122{
123 const bool firstInstantiation = (sInstance == NULL);
124 if (firstInstantiation)
125 {
126 sInstance = new LLFloaterMuteObjectUI;
127 }
128 sInstance->mCallback = callback;
129 sInstance->mCallbackUserData = userdata;
130
131 sInstance->open();
132 if (firstInstantiation)
133 {
134 sInstance->center();
135 }
136
137 return sInstance;
138}
139
140
141BOOL LLFloaterMuteObjectUI::postBuild()
142{
143 childSetAction("OK", onBtnOk, this);
144 childSetAction("Cancel", onBtnCancel, this);
145 return TRUE;
146}
147
148void LLFloaterMuteObjectUI::onBtnOk(void* userdata)
149{
150 LLFloaterMuteObjectUI* self = (LLFloaterMuteObjectUI*)userdata;
151 if (!self) return;
152
153 if (self->mCallback)
154 {
155 const LLString& text = self->childGetValue("object_name").asString();
156 self->mCallback(text,self->mCallbackUserData);
157 }
158 self->close();
159}
160
161void LLFloaterMuteObjectUI::onBtnCancel(void* userdata)
162{
163 LLFloaterMuteObjectUI* self = (LLFloaterMuteObjectUI*)userdata;
164 if (!self) return;
165
166 self->close();
167}
168
169BOOL LLFloaterMuteObjectUI::handleKeyHere(KEY key, MASK mask, BOOL called_from_parent)
170{
171 if (key == KEY_RETURN && mask == MASK_NONE)
172 {
173 onBtnOk(this);
174 return TRUE;
175 }
176 else if (key == KEY_ESCAPE && mask == MASK_NONE)
177 {
178 onBtnCancel(this);
179 return TRUE;
180 }
181
182 return LLFloater::handleKeyHere(key, mask, called_from_parent);
183}
72 184
73// 185//
74// Member Functions 186// Member Functions
@@ -77,15 +189,16 @@ LLFloaterMute* gFloaterMute = NULL;
77//----------------------------------------------------------------------------- 189//-----------------------------------------------------------------------------
78// LLFloaterMute() 190// LLFloaterMute()
79//----------------------------------------------------------------------------- 191//-----------------------------------------------------------------------------
80LLFloaterMute::LLFloaterMute() 192LLFloaterMute::LLFloaterMute(const LLSD& seed)
81: LLFloater("mute floater", "FloaterMuteRect3", FLOATER_TITLE, 193: LLFloater("mute floater", "FloaterMuteRect3", FLOATER_TITLE,
82 RESIZE_YES, 220, 140, DRAG_ON_TOP, MINIMIZE_YES, CLOSE_YES) 194 RESIZE_YES, 220, 140, DRAG_ON_TOP, MINIMIZE_YES, CLOSE_YES)
83{ 195{
84 196
85 gUICtrlFactory->buildFloater(this, "floater_mute.xml"); 197 gUICtrlFactory->buildFloater(this, "floater_mute.xml", NULL, FALSE);
86 198}
87 setVisible(FALSE);
88 199
200BOOL LLFloaterMute::postBuild()
201{
89 childSetCommitCallback("mutes", onSelectName, this); 202 childSetCommitCallback("mutes", onSelectName, this);
90 childSetAction("Mute resident...", onClickPick, this); 203 childSetAction("Mute resident...", onClickPick, this);
91 childSetAction("Mute object by name...", onClickMuteByName, this); 204 childSetAction("Mute object by name...", onClickMuteByName, this);
@@ -95,6 +208,8 @@ LLFloaterMute::LLFloaterMute()
95 mMuteList->setCommitOnSelectionChange(TRUE); 208 mMuteList->setCommitOnSelectionChange(TRUE);
96 209
97 refreshMuteList(); 210 refreshMuteList();
211
212 return TRUE;
98} 213}
99 214
100//----------------------------------------------------------------------------- 215//-----------------------------------------------------------------------------
@@ -104,39 +219,6 @@ LLFloaterMute::~LLFloaterMute()
104{ 219{
105} 220}
106 221
107
108//-----------------------------------------------------------------------------
109// show()
110//-----------------------------------------------------------------------------
111void LLFloaterMute::show()
112{
113 // Make sure we make a noise.
114 open(); /* Flawfinder: ignore */
115}
116
117//-----------------------------------------------------------------------------
118// toggle()
119//-----------------------------------------------------------------------------
120void LLFloaterMute::toggle(void*)
121{
122 if (gFloaterMute->getVisible())
123 {
124 gFloaterMute->close();
125 }
126 else
127 {
128 gFloaterMute->show();
129 }
130}
131
132//-----------------------------------------------------------------------------
133// visible()
134//-----------------------------------------------------------------------------
135BOOL LLFloaterMute::visible(void*)
136{
137 return (gFloaterMute && gFloaterMute->getVisible());
138}
139
140//----------------------------------------------------------------------------- 222//-----------------------------------------------------------------------------
141// refreshMuteList() 223// refreshMuteList()
142//----------------------------------------------------------------------------- 224//-----------------------------------------------------------------------------
@@ -196,7 +278,7 @@ void LLFloaterMute::onClickRemove(void *data)
196{ 278{
197 LLFloaterMute* floater = (LLFloaterMute *)data; 279 LLFloaterMute* floater = (LLFloaterMute *)data;
198 280
199 LLString name = floater->mMuteList->getSimpleSelectedItem(); 281 LLString name = floater->mMuteList->getSelectedItemLabel();
200 LLUUID id = floater->mMuteList->getStringUUIDSelectedItem(); 282 LLUUID id = floater->mMuteList->getStringUUIDSelectedItem();
201 LLMute mute(id); 283 LLMute mute(id);
202 mute.setFromDisplayName(name); 284 mute.setFromDisplayName(name);
@@ -250,20 +332,15 @@ void LLFloaterMute::onPickUser(const std::vector<std::string>& names, const std:
250 332
251void LLFloaterMute::onClickMuteByName(void* data) 333void LLFloaterMute::onClickMuteByName(void* data)
252{ 334{
335 LLFloaterMuteObjectUI* picker = LLFloaterMuteObjectUI::show(callbackMuteByName,data);
336 assert(picker);
253 337
254 338 LLFloaterMute* floaterp = (LLFloaterMute*)data;
255 LLString::format_map_t args; 339 floaterp->addDependentFloater(picker);
256 gViewerWindow->alertXmlEditText("MuteByName", args,
257 NULL, NULL,
258 callbackMuteByName, data);
259
260
261} 340}
262 341
263 342void LLFloaterMute::callbackMuteByName(const LLString& text, void* data)
264void LLFloaterMute::callbackMuteByName(S32 option, const LLString& text, void* data)
265{ 343{
266 if (option != 0) return;
267 if (text.empty()) return; 344 if (text.empty()) return;
268 345
269 LLMute mute(LLUUID::null, text, LLMute::BY_NAME); 346 LLMute mute(LLUUID::null, text, LLMute::BY_NAME);