lltoolpie.cpp

Go to the documentation of this file.
00001 
00032 #include "llviewerprecompiledheaders.h"
00033 
00034 #include "lltoolpie.h"
00035 
00036 #include "indra_constants.h"
00037 #include "llclickaction.h"
00038 #include "llmediabase.h"        // for status codes
00039 #include "llparcel.h"
00040 
00041 #include "llagent.h"
00042 #include "llviewercontrol.h"
00043 #include "llfirstuse.h"
00044 #include "llfloateravatarinfo.h"
00045 #include "llfloaterland.h"
00046 #include "llfloaterscriptdebug.h"
00047 #include "llhoverview.h"
00048 #include "llhudeffecttrail.h"
00049 #include "llhudmanager.h"
00050 #include "llmenugl.h"
00051 #include "llmutelist.h"
00052 #include "llselectmgr.h"
00053 #include "lltoolfocus.h"
00054 #include "lltoolgrab.h"
00055 #include "lltoolmgr.h"
00056 #include "lltoolselect.h"
00057 #include "llviewercamera.h"
00058 #include "llviewerparcelmedia.h"
00059 #include "llviewermenu.h"
00060 #include "llviewerobjectlist.h"
00061 #include "llviewerobject.h"
00062 #include "llviewerparcelmgr.h"
00063 #include "llviewerwindow.h"
00064 #include "llviewermedia.h"
00065 #include "llvoavatar.h"
00066 #include "llworld.h"
00067 #include "llui.h"
00068 #include "llweb.h"
00069 
00070 LLPointer<LLViewerObject> LLToolPie::sClickActionObject;
00071 LLSafeHandle<LLObjectSelection> LLToolPie::sLeftClickSelection = NULL;
00072 U8 LLToolPie::sClickAction = 0;
00073 
00074 extern void handle_buy(void*);
00075 
00076 extern BOOL gDebugClicks;
00077 
00078 static void handle_click_action_play();
00079 static void handle_click_action_open_media(LLPointer<LLViewerObject> objectp);
00080 static ECursorType cursor_from_parcel_media(U8 click_action);
00081 
00082 
00083 LLToolPie::LLToolPie()
00084 :       LLTool("Select"),
00085         mPieMouseButtonDown( FALSE ),
00086         mGrabMouseButtonDown( FALSE ),
00087         mHitLand( FALSE ),
00088         mHitObjectID(),
00089         mMouseOutsideSlop( FALSE )
00090 { }
00091 
00092 
00093 BOOL LLToolPie::handleMouseDown(S32 x, S32 y, MASK mask)
00094 {
00095         gPickFaces = TRUE;
00096         //left mouse down always picks transparent
00097         gViewerWindow->hitObjectOrLandGlobalAsync(x, y, mask, leftMouseCallback, 
00098                                                                                           TRUE, TRUE);
00099         mGrabMouseButtonDown = TRUE;
00100         return TRUE;
00101 }
00102 
00103 // static
00104 void LLToolPie::leftMouseCallback(S32 x, S32 y, MASK mask)
00105 {
00106         LLToolPie::getInstance()->pickAndShowMenu(x, y, mask, FALSE);
00107 }
00108 
00109 BOOL LLToolPie::handleRightMouseDown(S32 x, S32 y, MASK mask)
00110 {
00111         // Pick faces in case they select "Copy Texture" and need that info.
00112         gPickFaces = TRUE;
00113         // don't pick transparent so users can't "pay" transparent objects
00114         gViewerWindow->hitObjectOrLandGlobalAsync(x, y, mask, rightMouseCallback,
00115                                                                                           FALSE, TRUE);
00116         mPieMouseButtonDown = TRUE; 
00117         // don't steal focus from UI
00118         return FALSE;
00119 }
00120 
00121 // static
00122 void LLToolPie::rightMouseCallback(S32 x, S32 y, MASK mask)
00123 {
00124         LLToolPie::getInstance()->pickAndShowMenu(x, y, mask, TRUE);
00125 }
00126 
00127 // True if you selected an object.
00128 BOOL LLToolPie::pickAndShowMenu(S32 x, S32 y, MASK mask, BOOL always_show)
00129 {
00130         if (!always_show && gLastHitParcelWall)
00131         {
00132                 LLParcel* parcel = LLViewerParcelMgr::getInstance()->getCollisionParcel();
00133                 if (parcel)
00134                 {
00135                         LLViewerParcelMgr::getInstance()->selectCollisionParcel();
00136                         if (parcel->getParcelFlag(PF_USE_PASS_LIST) 
00137                                 && !LLViewerParcelMgr::getInstance()->isCollisionBanned())
00138                         {
00139                                 // if selling passes, just buy one
00140                                 void* deselect_when_done = (void*)TRUE;
00141                                 LLPanelLandGeneral::onClickBuyPass(deselect_when_done);
00142                         }
00143                         else
00144                         {
00145                                 // not selling passes, get info
00146                                 LLFloaterLand::showInstance();
00147                         }
00148                 }
00149 
00150                 return LLTool::handleMouseDown(x, y, mask);
00151         }
00152 
00153         // didn't click in any UI object, so must have clicked in the world
00154         LLViewerObject *object = gViewerWindow->lastObjectHit();
00155         LLViewerObject *parent = NULL;
00156 
00157         mHitLand = !object && !gLastHitPosGlobal.isExactlyZero();
00158         if (!mHitLand)
00159         {
00160                 LLViewerParcelMgr::getInstance()->deselectLand();
00161         }
00162         
00163         if (object)
00164         {
00165                 mHitObjectID = object->mID;
00166 
00167                 parent = object->getRootEdit();
00168         }
00169         else
00170         {
00171                 mHitObjectID.setNull();
00172         }
00173 
00174         BOOL touchable = (object && object->flagHandleTouch()) 
00175                                          || (parent && parent->flagHandleTouch());
00176 
00177         // If it's a left-click, and we have a special action, do it.
00178         if (useClickAction(always_show, mask, object, parent))
00179         {
00180                 sClickAction = 0;
00181                 if (object && object->getClickAction()) 
00182                 {
00183                         sClickAction = object->getClickAction();
00184                 }
00185                 else if (parent && parent->getClickAction()) 
00186                 {
00187                         sClickAction = parent->getClickAction();
00188                 }
00189 
00190                 switch(sClickAction)
00191                 {
00192                 case CLICK_ACTION_TOUCH:
00193                 default:
00194                         // nothing
00195                         break;
00196                 case CLICK_ACTION_SIT:
00197                         if ((gAgent.getAvatarObject() != NULL) && (!gAgent.getAvatarObject()->mIsSitting)) // agent not already sitting
00198                         {
00199                                 handle_sit_or_stand();
00200                                 return TRUE;
00201                         } // else nothing (fall through to touch)
00202                         
00203                 case CLICK_ACTION_PAY:
00204                         if (object && object->flagTakesMoney()
00205                                 || parent && parent->flagTakesMoney())
00206                         {
00207                                 // pay event goes to object actually clicked on
00208                                 sClickActionObject = object;
00209                                 sLeftClickSelection = LLToolSelect::handleObjectSelection(object, MASK_NONE, FALSE, TRUE);
00210                                 return TRUE;
00211                         }
00212                         break;
00213                 case CLICK_ACTION_BUY:
00214                         sClickActionObject = parent;
00215                         sLeftClickSelection = LLToolSelect::handleObjectSelection(parent, MASK_NONE, FALSE, TRUE);
00216                         return TRUE;
00217                 case CLICK_ACTION_OPEN:
00218                         if (parent && parent->allowOpen())
00219                         {
00220                                 sClickActionObject = parent;
00221                                 sLeftClickSelection = LLToolSelect::handleObjectSelection(parent, MASK_NONE, FALSE, TRUE);
00222                         }
00223                         return TRUE;
00224                 case CLICK_ACTION_PLAY:
00225                         handle_click_action_play();
00226                         return TRUE;
00227                 case CLICK_ACTION_OPEN_MEDIA:
00228                         // sClickActionObject = object;
00229                         handle_click_action_open_media(object);
00230                         return TRUE;
00231                 }
00232         }
00233 
00234         // Switch to grab tool if physical or triggerable
00235         if (object && 
00236                 !object->isAvatar() && 
00237                 ((object->usePhysics() || (parent && !parent->isAvatar() && parent->usePhysics())) || touchable) && 
00238                 !always_show)
00239         {
00240                 gGrabTransientTool = this;
00241                 LLToolMgr::getInstance()->getCurrentToolset()->selectTool( LLToolGrab::getInstance() );
00242                 return LLToolGrab::getInstance()->handleObjectHit( object, x, y, mask);
00243         }
00244         
00245         if (!object && gLastHitHUDIcon && gLastHitHUDIcon->getSourceObject())
00246         {
00247                 LLFloaterScriptDebug::show(gLastHitHUDIcon->getSourceObject()->getID());
00248         }
00249 
00250         // If left-click never selects or spawns a menu
00251         // Eat the event.
00252         if (!gSavedSettings.getBOOL("LeftClickShowMenu")
00253                 && !always_show)
00254         {
00255                 // mouse already released
00256                 if (!mGrabMouseButtonDown)
00257                 {
00258                         return TRUE;
00259                 }
00260 
00261                 while( object && object->isAttachment() && !object->flagHandleTouch())
00262                 {
00263                         // don't pick avatar through hud attachment
00264                         if (object->isHUDAttachment())
00265                         {
00266                                 break;
00267                         }
00268                         object = (LLViewerObject*)object->getParent();
00269                 }
00270                 if (object && object == gAgent.getAvatarObject())
00271                 {
00272                         // we left clicked on avatar, switch to focus mode
00273                         LLToolMgr::getInstance()->setTransientTool(LLToolCamera::getInstance());
00274                         gViewerWindow->hideCursor();
00275                         LLToolCamera::getInstance()->setMouseCapture(TRUE);
00276                         LLToolCamera::getInstance()->pickCallback(gViewerWindow->getCurrentMouseX(), gViewerWindow->getCurrentMouseY(), mask);
00277                         gAgent.setFocusOnAvatar(TRUE, TRUE);
00278 
00279                         return TRUE;
00280                 }
00281                 // Could be first left-click on nothing
00282                 LLFirstUse::useLeftClickNoHit();
00283 
00284                 // Eat the event
00285                 return LLTool::handleMouseDown(x, y, mask);
00286         }
00287 
00288         if (!always_show && gAgent.leftButtonGrabbed())
00289         {
00290                 // if the left button is grabbed, don't put up the pie menu
00291                 return LLTool::handleMouseDown(x, y, mask);
00292         }
00293 
00294         // Can't ignore children here.
00295         LLToolSelect::handleObjectSelection(object, mask, FALSE, TRUE);
00296 
00297         // Spawn pie menu
00298         if (mHitLand)
00299         {
00300                 LLParcelSelectionHandle selection = LLViewerParcelMgr::getInstance()->selectParcelAt( gLastHitPosGlobal );
00301                 gMenuHolder->setParcelSelection(selection);
00302                 gPieLand->show(x, y, mPieMouseButtonDown);
00303 
00304                 // VEFFECT: ShowPie
00305                 LLHUDEffectSpiral *effectp = (LLHUDEffectSpiral *)LLHUDManager::getInstance()->createViewerEffect(LLHUDObject::LL_HUD_EFFECT_SPHERE, TRUE);
00306                 effectp->setPositionGlobal(gLastHitPosGlobal);
00307                 effectp->setColor(LLColor4U(gAgent.getEffectColor()));
00308                 effectp->setDuration(0.25f);
00309         }
00310         else if (mHitObjectID == gAgent.getID() )
00311         {
00312                 gPieSelf->show(x, y, mPieMouseButtonDown);
00313         }
00314         else if (object)
00315         {
00316                 gMenuHolder->setObjectSelection(LLSelectMgr::getInstance()->getSelection());
00317 
00318                 if (object->isAvatar() 
00319                         || (object->isAttachment() && !object->isHUDAttachment() && !object->permYouOwner()))
00320                 {
00321                         // Find the attachment's avatar
00322                         while( object && object->isAttachment())
00323                         {
00324                                 object = (LLViewerObject*)object->getParent();
00325                         }
00326 
00327                         // Object is an avatar, so check for mute by id.
00328                         LLVOAvatar* avatar = (LLVOAvatar*)object;
00329                         LLString name = avatar->getFullname();
00330                         if (LLMuteList::getInstance()->isMuted(avatar->getID(), name))
00331                         {
00332                                 gMenuHolder->childSetText("Avatar Mute", LLString("Unmute")); // *TODO:Translate
00333                                 //gMutePieMenu->setLabel("Unmute");
00334                         }
00335                         else
00336                         {
00337                                 gMenuHolder->childSetText("Avatar Mute", LLString("Mute")); // *TODO:Translate
00338                                 //gMutePieMenu->setLabel("Mute");
00339                         }
00340 
00341                         gPieAvatar->show(x, y, mPieMouseButtonDown);
00342                 }
00343                 else if (object->isAttachment())
00344                 {
00345                         gPieAttachment->show(x, y, mPieMouseButtonDown);
00346                 }
00347                 else
00348                 {
00349                         // BUG: What about chatting child objects?
00350                         LLString name;
00351                         LLSelectNode* node = LLSelectMgr::getInstance()->getSelection()->getFirstRootNode();
00352                         if (node)
00353                         {
00354                                 name = node->mName;
00355                         }
00356                         if (LLMuteList::getInstance()->isMuted(object->getID(), name))
00357                         {
00358                                 gMenuHolder->childSetText("Object Mute", LLString("Unmute")); // *TODO:Translate
00359                                 //gMuteObjectPieMenu->setLabel("Unmute");
00360                         }
00361                         else
00362                         {
00363                                 gMenuHolder->childSetText("Object Mute", LLString("Mute")); // *TODO:Translate
00364                                 //gMuteObjectPieMenu->setLabel("Mute");
00365                         }
00366                         
00367                         gPieObject->show(x, y, mPieMouseButtonDown);
00368 
00369                         // VEFFECT: ShowPie object
00370                         // Don't show when you click on someone else, it freaks them
00371                         // out.
00372                         LLHUDEffectSpiral *effectp = (LLHUDEffectSpiral *)LLHUDManager::getInstance()->createViewerEffect(LLHUDObject::LL_HUD_EFFECT_SPHERE, TRUE);
00373                         effectp->setPositionGlobal(gLastHitPosGlobal);
00374                         effectp->setColor(LLColor4U(gAgent.getEffectColor()));
00375                         effectp->setDuration(0.25f);
00376                 }
00377         }
00378 
00379         if (always_show)
00380         {
00381                 // ignore return value
00382                 LLTool::handleRightMouseDown(x, y, mask);
00383         }
00384         else
00385         {
00386                 // ignore return value
00387                 LLTool::handleMouseDown(x, y, mask);
00388         }
00389 
00390         // We handled the event.
00391         return TRUE;
00392 }
00393 
00394 BOOL LLToolPie::useClickAction(BOOL always_show, 
00395                                                            MASK mask, 
00396                                                            LLViewerObject* object, 
00397                                                            LLViewerObject* parent)
00398 {
00399         return  !always_show
00400                         && mask == MASK_NONE
00401                         && object
00402                         && !object->isAttachment() 
00403                         && LLPrimitive::isPrimitive(object->getPCode())
00404                         && (object->getClickAction() 
00405                                 || parent->getClickAction());
00406 
00407 }
00408 
00409 U8 final_click_action(LLViewerObject* obj)
00410 {
00411         if (!obj) return CLICK_ACTION_NONE;
00412         if (obj->isAttachment()) return CLICK_ACTION_NONE;
00413 
00414         U8 click_action = CLICK_ACTION_TOUCH;
00415         LLViewerObject* parent = obj->getRootEdit();
00416         if (obj->getClickAction()
00417             || (parent && parent->getClickAction()))
00418         {
00419                 if (obj->getClickAction())
00420                 {
00421                         click_action = obj->getClickAction();
00422                 }
00423                 else if (parent && parent->getClickAction())
00424                 {
00425                         click_action = parent->getClickAction();
00426                 }
00427         }
00428         return click_action;
00429 }
00430 
00431 ECursorType cursor_from_object(LLViewerObject* object)
00432 {
00433         LLViewerObject* parent = NULL;
00434         if (object)
00435         {
00436                 parent = object->getRootEdit();
00437         }
00438         U8 click_action = final_click_action(object);
00439         ECursorType cursor = UI_CURSOR_ARROW;
00440         switch(click_action)
00441         {
00442         case CLICK_ACTION_SIT:
00443                 if ((gAgent.getAvatarObject() != NULL) && (!gAgent.getAvatarObject()->mIsSitting)) // not already sitting?
00444                 {
00445                         cursor = UI_CURSOR_TOOLSIT;
00446                 }
00447                 break;
00448         case CLICK_ACTION_BUY:
00449                 cursor = UI_CURSOR_TOOLBUY;
00450                 break;
00451         case CLICK_ACTION_OPEN:
00452                 // Open always opens the parent.
00453                 if (parent && parent->allowOpen())
00454                 {
00455                         cursor = UI_CURSOR_TOOLOPEN;
00456                 }
00457                 break;
00458         case CLICK_ACTION_PAY:  
00459                 if ((object && object->flagTakesMoney())
00460                         || (parent && parent->flagTakesMoney()))
00461                 {
00462                         cursor = UI_CURSOR_TOOLPAY;
00463                 }
00464                 break;
00465         case CLICK_ACTION_PLAY:
00466         case CLICK_ACTION_OPEN_MEDIA: 
00467                 cursor = cursor_from_parcel_media(click_action);
00468                 break;
00469         default:
00470                 break;
00471         }
00472         return cursor;
00473 }
00474 
00475 // When we get object properties after left-clicking on an object
00476 // with left-click = buy, if it's the same object, do the buy.
00477 // static
00478 void LLToolPie::selectionPropertiesReceived()
00479 {
00480         // Make sure all data has been received.
00481         // This function will be called repeatedly as the data comes in.
00482         if (!LLSelectMgr::getInstance()->selectGetAllValid())
00483         {
00484                 return;
00485         }
00486 
00487         if (!sLeftClickSelection->isEmpty())
00488         {
00489                 LLViewerObject* selected_object = sLeftClickSelection->getPrimaryObject();
00490                 // since we don't currently have a way to lock a selection, it could have changed
00491                 // after we initially clicked on the object
00492                 if (selected_object == sClickActionObject)
00493                 {
00494                         switch (sClickAction)
00495                         {
00496                         case CLICK_ACTION_BUY:
00497                                 handle_buy(NULL);
00498                                 break;
00499                         case CLICK_ACTION_PAY:
00500                                 handle_give_money_dialog();
00501                                 break;
00502                         case CLICK_ACTION_OPEN:
00503                                 handle_object_open();
00504                                 break;
00505                         default:
00506                                 break;
00507                         }
00508                 }
00509         }
00510         sLeftClickSelection = NULL;
00511         sClickActionObject = NULL;
00512         sClickAction = 0;
00513 }
00514 
00515 BOOL LLToolPie::handleHover(S32 x, S32 y, MASK mask)
00516 {
00517                 /*
00518         // If auto-rotate occurs, tag mouse-outside-slop to make sure the drag
00519         // gets started.
00520         const S32 ROTATE_H_MARGIN = (S32) (0.1f * gViewerWindow->getWindowWidth() );
00521         const F32 ROTATE_ANGLE_PER_SECOND = 30.f * DEG_TO_RAD;
00522         const F32 rotate_angle = ROTATE_ANGLE_PER_SECOND / gFPSClamped;
00523         // ...normal modes can only yaw
00524         if (x < ROTATE_H_MARGIN)
00525         {
00526                 gAgent.yaw(rotate_angle);
00527                 mMouseOutsideSlop = TRUE;
00528         }
00529         else if (x > gViewerWindow->getWindowWidth() - ROTATE_H_MARGIN)
00530         {
00531                 gAgent.yaw(-rotate_angle);
00532                 mMouseOutsideSlop = TRUE;
00533         }
00534         */
00535         
00536         LLViewerObject *object = NULL;
00537         LLViewerObject *parent = NULL;
00538         if (gHoverView)
00539         {
00540                 object = gHoverView->getLastHoverObject();
00541         }
00542 
00543         if (object)
00544         {
00545                 parent = object->getRootEdit();
00546         }
00547 
00548         if (object && useClickAction(FALSE, mask, object, parent))
00549         {
00550                 ECursorType cursor = cursor_from_object(object);
00551                 gViewerWindow->getWindow()->setCursor(cursor);
00552                 lldebugst(LLERR_USER_INPUT) << "hover handled by LLToolPie (inactive)" << llendl;
00553         }
00554         else if ((object && !object->isAvatar() && object->usePhysics()) 
00555                          || (parent && !parent->isAvatar() && parent->usePhysics()))
00556         {
00557                 gViewerWindow->getWindow()->setCursor(UI_CURSOR_TOOLGRAB);
00558                 lldebugst(LLERR_USER_INPUT) << "hover handled by LLToolPie (inactive)" << llendl;
00559         }
00560         else if ( (object && object->flagHandleTouch()) 
00561                           || (parent && parent->flagHandleTouch()))
00562         {
00563                 gViewerWindow->getWindow()->setCursor(UI_CURSOR_HAND);
00564                 lldebugst(LLERR_USER_INPUT) << "hover handled by LLToolPie (inactive)" << llendl;
00565         }
00566         else
00567         {
00568                 gViewerWindow->getWindow()->setCursor(UI_CURSOR_ARROW);
00569                 lldebugst(LLERR_USER_INPUT) << "hover handled by LLToolPie (inactive)" << llendl;
00570         }
00571 
00572         return TRUE;
00573 }
00574 
00575 BOOL LLToolPie::handleMouseUp(S32 x, S32 y, MASK mask)
00576 {
00577         LLViewerObject* obj = gViewerWindow->lastObjectHit();
00578         U8 click_action = final_click_action(obj);
00579         if (click_action != CLICK_ACTION_NONE)
00580         {
00581                 switch(click_action)
00582                 {
00583                 case CLICK_ACTION_BUY:
00584                 case CLICK_ACTION_PAY:
00585                 case CLICK_ACTION_OPEN:
00586                         // Because these actions open UI dialogs, we won't change
00587                         // the cursor again until the next hover and GL pick over
00588                         // the world.  Keep the cursor an arrow, assuming that 
00589                         // after the user moves off the UI, they won't be on the
00590                         // same object anymore.
00591                         gViewerWindow->getWindow()->setCursor(UI_CURSOR_ARROW);
00592                         // Make sure the hover-picked object is ignored.
00593                         gHoverView->resetLastHoverObject();
00594                         break;
00595                 default:
00596                         break;
00597                 }
00598         }
00599         mGrabMouseButtonDown = FALSE;
00600         LLToolMgr::getInstance()->clearTransientTool();
00601         gAgent.setLookAt(LOOKAT_TARGET_CONVERSATION, obj); // maybe look at object/person clicked on
00602         return LLTool::handleMouseUp(x, y, mask);
00603 }
00604 
00605 BOOL LLToolPie::handleRightMouseUp(S32 x, S32 y, MASK mask)
00606 {
00607         mPieMouseButtonDown = FALSE; 
00608         LLToolMgr::getInstance()->clearTransientTool();
00609         return LLTool::handleRightMouseUp(x, y, mask);
00610 }
00611 
00612 
00613 BOOL LLToolPie::handleDoubleClick(S32 x, S32 y, MASK mask)
00614 {
00615         if (gDebugClicks)
00616         {
00617                 llinfos << "LLToolPie handleDoubleClick (becoming mouseDown)" << llendl;
00618         }
00619 
00620         if (gSavedSettings.getBOOL("DoubleClickAutoPilot"))
00621         {
00622                 if (gLastHitLand
00623                         && !gLastHitPosGlobal.isExactlyZero())
00624                 {
00625                         handle_go_to();
00626                         return TRUE;
00627                 }
00628                 else if (gLastHitObjectID.notNull()
00629                                  && !gLastHitPosGlobal.isExactlyZero())
00630                 {
00631                         // Hit an object
00632                         // HACK: Call the last hit position the point we hit on the object
00633                         gLastHitPosGlobal += gLastHitObjectOffset;
00634                         handle_go_to();
00635                         return TRUE;
00636                 }
00637         }
00638 
00639         return FALSE;
00640 
00641         /* JC - don't do go-there, because then double-clicking on physical
00642         objects gets you into trouble.
00643 
00644         // If double-click on object or land, go there.
00645         LLViewerObject *object = gViewerWindow->lastObjectHit();
00646         if (object)
00647         {
00648                 if (object->isAvatar())
00649                 {
00650                         LLFloaterAvatarInfo::showFromAvatar(object->getID());
00651                 }
00652                 else
00653                 {
00654                         handle_go_to(NULL);
00655                 }
00656         }
00657         else if (!gLastHitPosGlobal.isExactlyZero())
00658         {
00659                 handle_go_to(NULL);
00660         }
00661 
00662         return TRUE;
00663         */
00664 }
00665 
00666 
00667 void LLToolPie::handleDeselect()
00668 {
00669         if(     hasMouseCapture() )
00670         {
00671                 setMouseCapture( FALSE );  // Calls onMouseCaptureLost() indirectly
00672         }
00673         // remove temporary selection for pie menu
00674         LLSelectMgr::getInstance()->validateSelection();
00675 }
00676 
00677 LLTool* LLToolPie::getOverrideTool(MASK mask)
00678 {
00679         if (mask == MASK_CONTROL)
00680         {
00681                 return LLToolGrab::getInstance();
00682         }
00683         else if (mask == (MASK_CONTROL | MASK_SHIFT))
00684         {
00685                 return LLToolGrab::getInstance();
00686         }
00687 
00688         return LLTool::getOverrideTool(mask);
00689 }
00690 
00691 void LLToolPie::stopEditing()
00692 {
00693         if(     hasMouseCapture() )
00694         {
00695                 setMouseCapture( FALSE );  // Calls onMouseCaptureLost() indirectly
00696         }
00697 }
00698 
00699 void LLToolPie::onMouseCaptureLost()
00700 {
00701         mMouseOutsideSlop = FALSE;
00702 }
00703 
00704 
00705 // true if x,y outside small box around start_x,start_y
00706 BOOL LLToolPie::outsideSlop(S32 x, S32 y, S32 start_x, S32 start_y)
00707 {
00708         S32 dx = x - start_x;
00709         S32 dy = y - start_y;
00710 
00711         return (dx <= -2 || 2 <= dx || dy <= -2 || 2 <= dy);
00712 }
00713 
00714 
00715 void LLToolPie::render()
00716 {
00717         return;
00718 }
00719 
00720 static void handle_click_action_play()
00721 {
00722         LLParcel* parcel = LLViewerParcelMgr::getInstance()->getAgentParcel();
00723         if (!parcel) return;
00724 
00725         LLMediaBase::EStatus status = LLViewerParcelMedia::getStatus();
00726         switch(status)
00727         {
00728                 case LLMediaBase::STATUS_STARTED:
00729                         LLViewerParcelMedia::pause();
00730                         break;
00731 
00732                 case LLMediaBase::STATUS_PAUSED:
00733                         LLViewerParcelMedia::start();
00734                         break;
00735 
00736                 default:
00737                         LLViewerParcelMedia::play(parcel);
00738                         break;
00739         }
00740 }
00741 
00742 static void handle_click_action_open_media(LLPointer<LLViewerObject> objectp)
00743 {
00744         //FIXME: how do we handle object in different parcel than us?
00745         LLParcel* parcel = LLViewerParcelMgr::getInstance()->getAgentParcel();
00746         if (!parcel) return;
00747 
00748         // did we hit an object?
00749         if (objectp.isNull()) return;
00750 
00751         // did we hit a valid face on the object?
00752         if( gLastHitObjectFace < 0 || gLastHitObjectFace >= objectp->getNumTEs() ) return;
00753                 
00754         // is media playing on this face?
00755         if (!LLViewerMedia::isActiveMediaTexture(objectp->getTE(gLastHitObjectFace)->getID()))
00756         {
00757                 handle_click_action_play();
00758                 return;
00759         }
00760 
00761         std::string media_url = std::string ( parcel->getMediaURL () );
00762         std::string media_type = std::string ( parcel->getMediaType() );
00763         LLString::trim(media_url);
00764 
00765         // Get the scheme, see if that is handled as well.
00766         LLURI uri(media_url);
00767         std::string media_scheme = uri.scheme() != "" ? uri.scheme() : "http";
00768 
00769         // HACK: This is directly referencing an impl name.  BAD!
00770         // This can be removed when we have a truly generic media browser that only 
00771         // builds an impl based on the type of url it is passed.
00772 
00773         if(     LLMediaManager::getInstance()->supportsMediaType( "LLMediaImplLLMozLib", media_scheme, media_type ) )
00774         {
00775                 LLWeb::loadURL(media_url);
00776         }
00777 }
00778 
00779 static ECursorType cursor_from_parcel_media(U8 click_action)
00780 {
00781         // HACK: This is directly referencing an impl name.  BAD!
00782         // This can be removed when we have a truly generic media browser that only 
00783         // builds an impl based on the type of url it is passed.
00784         
00785         //FIXME: how do we handle object in different parcel than us?
00786         ECursorType open_cursor = UI_CURSOR_ARROW;
00787         LLParcel* parcel = LLViewerParcelMgr::getInstance()->getAgentParcel();
00788         if (!parcel) return open_cursor;
00789 
00790         std::string media_url = std::string ( parcel->getMediaURL () );
00791         std::string media_type = std::string ( parcel->getMediaType() );
00792         LLString::trim(media_url);
00793 
00794         // Get the scheme, see if that is handled as well.
00795         LLURI uri(media_url);
00796         std::string media_scheme = uri.scheme() != "" ? uri.scheme() : "http";
00797 
00798         if(     LLMediaManager::getInstance()->supportsMediaType( "LLMediaImplLLMozLib", media_scheme, media_type ) )
00799         {
00800                 open_cursor = UI_CURSOR_TOOLMEDIAOPEN;
00801         }
00802 
00803         LLMediaBase::EStatus status = LLViewerParcelMedia::getStatus();
00804         switch(status)
00805         {
00806                 case LLMediaBase::STATUS_STARTED:
00807                         return click_action == CLICK_ACTION_PLAY ? UI_CURSOR_TOOLPAUSE : open_cursor;
00808                 default:
00809                         return UI_CURSOR_TOOLPLAY;
00810         }
00811 }

Generated on Fri May 16 08:34:07 2008 for SecondLife by  doxygen 1.5.5