aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/linden/indra/newview/jcfloaterareasearch.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'linden/indra/newview/jcfloaterareasearch.cpp')
-rw-r--r--linden/indra/newview/jcfloaterareasearch.cpp117
1 files changed, 117 insertions, 0 deletions
diff --git a/linden/indra/newview/jcfloaterareasearch.cpp b/linden/indra/newview/jcfloaterareasearch.cpp
index ed00447..0918431 100644
--- a/linden/indra/newview/jcfloaterareasearch.cpp
+++ b/linden/indra/newview/jcfloaterareasearch.cpp
@@ -38,7 +38,14 @@
38#include "llscrolllistctrl.h" 38#include "llscrolllistctrl.h"
39 39
40#include "llagent.h" 40#include "llagent.h"
41
42#include "llfloatertools.h"
43#include "llmenugl.h"
44#include "llselectmgr.h"
45#include "lltoolcomp.h"
46#include "lltoolmgr.h"
41#include "lltracker.h" 47#include "lltracker.h"
48#include "llviewerjoystick.h"
42#include "llviewerobjectlist.h" 49#include "llviewerobjectlist.h"
43#include "llviewercontrol.h" 50#include "llviewercontrol.h"
44#include "jcfloaterareasearch.h" 51#include "jcfloaterareasearch.h"
@@ -63,6 +70,19 @@ mResultList(0)
63 llassert_always(sInstance == NULL); 70 llassert_always(sInstance == NULL);
64 sInstance = this; 71 sInstance = this;
65 mLastUpdateTimer.reset(); 72 mLastUpdateTimer.reset();
73
74
75 // Register event listeners for popup menu
76 mPopupMenuHandler = new PopupMenuHandler(this);
77 mPopupMenuHandler->registerListener(this, "Popup.HandleMenu");
78
79 LLMenuGL* menu = LLUICtrlFactory::getInstance()->buildMenu("menu_areasearch.xml", this);
80 if (!menu)
81 {
82 menu = new LLMenuGL(LLStringUtil::null);
83 }
84 menu->setVisible(FALSE);
85 mPopupMenuHandle = menu->getHandle();
66} 86}
67 87
68JCFloaterAreaSearch::~JCFloaterAreaSearch() 88JCFloaterAreaSearch::~JCFloaterAreaSearch()
@@ -90,6 +110,7 @@ BOOL JCFloaterAreaSearch::postBuild()
90 mResultList = getChild<LLScrollListCtrl>("result_list"); 110 mResultList = getChild<LLScrollListCtrl>("result_list");
91 mResultList->setCallbackUserData(this); 111 mResultList->setCallbackUserData(this);
92 mResultList->setDoubleClickCallback(onDoubleClick); 112 mResultList->setDoubleClickCallback(onDoubleClick);
113 mResultList->setRightMouseDownCallback(onRightMouseDown);
93 mResultList->sortByColumn("Name", TRUE); 114 mResultList->sortByColumn("Name", TRUE);
94 115
95 mCounterText = getChild<LLTextBox>("counter"); 116 mCounterText = getChild<LLTextBox>("counter");
@@ -159,6 +180,102 @@ void JCFloaterAreaSearch::onDoubleClick(void *userdata)
159 } 180 }
160} 181}
161 182
183//static
184void JCFloaterAreaSearch::onRightMouseDown(S32 x, S32 y, void *userdata)
185{
186 JCFloaterAreaSearch* self = (JCFloaterAreaSearch*)userdata;
187
188 self->setFocus( TRUE );
189 LLMenuGL* menu = (LLMenuGL*)self->mPopupMenuHandle.get();
190 if(menu)
191 {
192 if(menu->getVisible())
193 {
194 menu->setVisible(FALSE);
195 }
196 else
197 {
198 LLScrollListItem *item = self->mResultList->getFirstSelected();
199 if (item)
200 {
201 self->mSelectedItem = item;
202 menu->setVisible(TRUE);
203 menu->setFocus(TRUE);
204 menu->arrange();
205 menu->updateParent(LLMenuGL::sMenuContainer);
206 LLMenuGL::showPopup(self, menu, x, y+50);
207 }
208 else
209 {
210 self->mSelectedItem = NULL;
211 }
212 }
213 }
214
215}
216
217JCFloaterAreaSearch::PopupMenuHandler::PopupMenuHandler(const JCFloaterAreaSearch* instance)
218 : mInstance(instance)
219{
220
221}
222
223// static
224bool JCFloaterAreaSearch::PopupMenuHandler::handleEvent(LLPointer<LLEvent> event, const LLSD& userdata)
225{
226 std::string command = userdata.asString();
227 JCFloaterAreaSearch* self = (JCFloaterAreaSearch*)mInstance;
228
229 if (self && self->mSelectedItem && !command.empty())
230 {
231 LLUUID object_id = self->mSelectedItem->getUUID();
232 LLViewerObject* object = gObjectList.findObject(object_id);
233
234 if (object && !object->isAvatar())
235 {
236
237
238 if ("teleport" == command)
239 {
240 LLVector3d pos = object->getPositionGlobal();
241 gAgent.teleportViaLocation(pos);
242
243 }
244 else
245 {
246 if ("cam" || "edit" == command)
247 {
248
249 gAgent.setFocusOnAvatar(FALSE, FALSE);
250 gAgent.changeCameraToThirdPerson();
251 gAgent.setFocusGlobal(object->getPositionGlobal(), object_id);
252 gAgent.setCameraPosAndFocusGlobal(object->getPositionGlobal()
253 + LLVector3d(3.5,1.35,0.75) * object->getRotation(),
254 object->getPositionGlobal(),
255 object_id );
256 if ("edit" == command)
257 {
258 if(!object->isSelected())
259 {
260 LLSelectMgr::getInstance()->deselectAll();
261 LLSelectMgr::getInstance()->selectObjectAndFamily(object);
262 }
263
264 gFloaterTools->open();
265 LLToolMgr::getInstance()->setCurrentToolset(gBasicToolset);
266 gFloaterTools->setEditTool( LLToolCompTranslate::getInstance() );
267
268 LLViewerJoystick::getInstance()->moveObjects(true);
269 LLViewerJoystick::getInstance()->setNeedsReset(true);
270 }
271 }
272 }
273 }
274 }
275
276 return true;
277}
278
162// static 279// static
163void JCFloaterAreaSearch::cancel(void* data) 280void JCFloaterAreaSearch::cancel(void* data)
164{ 281{