diff options
author | Armin Weatherwax | 2010-11-08 19:51:32 +0100 |
---|---|---|
committer | Armin Weatherwax | 2010-11-09 23:31:11 +0100 |
commit | 44c07eb2c58c4898752ad813d46c224ccd7229f1 (patch) | |
tree | 27d79577d2f4afc0401cd9593e2c7a60e333c624 /linden/indra/newview/jcfloaterareasearch.cpp | |
parent | As we currently do not build the gstreamer plugin for windows, do not try to ... (diff) | |
download | meta-impy-44c07eb2c58c4898752ad813d46c224ccd7229f1.zip meta-impy-44c07eb2c58c4898752ad813d46c224ccd7229f1.tar.gz meta-impy-44c07eb2c58c4898752ad813d46c224ccd7229f1.tar.bz2 meta-impy-44c07eb2c58c4898752ad813d46c224ccd7229f1.tar.xz |
feature: add a tiny context menu to areasearch scroll list items
rightclick one of the results and teleport or cam to the object or bring it in edit mode
Diffstat (limited to 'linden/indra/newview/jcfloaterareasearch.cpp')
-rw-r--r-- | linden/indra/newview/jcfloaterareasearch.cpp | 117 |
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 | ||
68 | JCFloaterAreaSearch::~JCFloaterAreaSearch() | 88 | JCFloaterAreaSearch::~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 | ||
184 | void 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 | |||
217 | JCFloaterAreaSearch::PopupMenuHandler::PopupMenuHandler(const JCFloaterAreaSearch* instance) | ||
218 | : mInstance(instance) | ||
219 | { | ||
220 | |||
221 | } | ||
222 | |||
223 | // static | ||
224 | bool 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 |
163 | void JCFloaterAreaSearch::cancel(void* data) | 280 | void JCFloaterAreaSearch::cancel(void* data) |
164 | { | 281 | { |