aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/linden/indra/newview/lltoolpie.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'linden/indra/newview/lltoolpie.cpp')
-rw-r--r--linden/indra/newview/lltoolpie.cpp208
1 files changed, 164 insertions, 44 deletions
diff --git a/linden/indra/newview/lltoolpie.cpp b/linden/indra/newview/lltoolpie.cpp
index 2b63a24..b121b1a 100644
--- a/linden/indra/newview/lltoolpie.cpp
+++ b/linden/indra/newview/lltoolpie.cpp
@@ -36,11 +36,11 @@
36 36
37#include "indra_constants.h" 37#include "indra_constants.h"
38#include "llclickaction.h" 38#include "llclickaction.h"
39#include "llmediabase.h" // for status codes
40#include "llparcel.h" 39#include "llparcel.h"
41 40
42#include "llagent.h" 41#include "llagent.h"
43#include "llviewercontrol.h" 42#include "llviewercontrol.h"
43#include "llfocusmgr.h"
44#include "llfirstuse.h" 44#include "llfirstuse.h"
45#include "llfloateravatarinfo.h" 45#include "llfloateravatarinfo.h"
46#include "llfloaterland.h" 46#include "llfloaterland.h"
@@ -63,6 +63,7 @@
63#include "llviewerparcelmgr.h" 63#include "llviewerparcelmgr.h"
64#include "llviewerwindow.h" 64#include "llviewerwindow.h"
65#include "llviewermedia.h" 65#include "llviewermedia.h"
66#include "llviewermediafocus.h"
66#include "llvoavatar.h" 67#include "llvoavatar.h"
67#include "llworld.h" 68#include "llworld.h"
68#include "llui.h" 69#include "llui.h"
@@ -72,13 +73,15 @@ extern void handle_buy(void*);
72 73
73extern BOOL gDebugClicks; 74extern BOOL gDebugClicks;
74 75
76static bool handle_media_click(const LLPickInfo& info);
77static bool handle_media_hover(const LLPickInfo& info);
75static void handle_click_action_play(); 78static void handle_click_action_play();
76static void handle_click_action_open_media(LLPointer<LLViewerObject> objectp); 79static void handle_click_action_open_media(LLPointer<LLViewerObject> objectp);
77static ECursorType cursor_from_parcel_media(U8 click_action); 80static ECursorType cursor_from_parcel_media(U8 click_action);
78 81
79 82
80LLToolPie::LLToolPie() 83LLToolPie::LLToolPie()
81: LLTool(std::string("Select")), 84: LLTool(std::string("Pie")),
82 mPieMouseButtonDown( FALSE ), 85 mPieMouseButtonDown( FALSE ),
83 mGrabMouseButtonDown( FALSE ), 86 mGrabMouseButtonDown( FALSE ),
84 mMouseOutsideSlop( FALSE ), 87 mMouseOutsideSlop( FALSE ),
@@ -110,6 +113,10 @@ BOOL LLToolPie::handleRightMouseDown(S32 x, S32 y, MASK mask)
110 return FALSE; 113 return FALSE;
111} 114}
112 115
116BOOL LLToolPie::handleScrollWheel(S32 x, S32 y, S32 clicks)
117{
118 return LLViewerMediaFocus::getInstance()->handleScrollWheel(x, y, clicks);
119}
113// static 120// static
114void LLToolPie::rightMouseCallback(const LLPickInfo& pick_info) 121void LLToolPie::rightMouseCallback(const LLPickInfo& pick_info)
115{ 122{
@@ -143,6 +150,7 @@ BOOL LLToolPie::pickAndShowMenu(BOOL always_show)
143 } 150 }
144 } 151 }
145 152
153 gFocusMgr.setKeyboardFocus(NULL);
146 return LLTool::handleMouseDown(x, y, mask); 154 return LLTool::handleMouseDown(x, y, mask);
147 } 155 }
148 156
@@ -161,9 +169,11 @@ BOOL LLToolPie::pickAndShowMenu(BOOL always_show)
161 parent = object->getRootEdit(); 169 parent = object->getRootEdit();
162 } 170 }
163 171
172
164 BOOL touchable = (object && object->flagHandleTouch()) 173 BOOL touchable = (object && object->flagHandleTouch())
165 || (parent && parent->flagHandleTouch()); 174 || (parent && parent->flagHandleTouch());
166 175
176
167 // If it's a left-click, and we have a special action, do it. 177 // If it's a left-click, and we have a special action, do it.
168 if (useClickAction(always_show, mask, object, parent)) 178 if (useClickAction(always_show, mask, object, parent))
169 { 179 {
@@ -195,6 +205,8 @@ BOOL LLToolPie::pickAndShowMenu(BOOL always_show)
195 if ((gAgent.getAvatarObject() != NULL) && (!gAgent.getAvatarObject()->mIsSitting) && !gSavedSettings.getBOOL("BlockClickSit")) // agent not already sitting 205 if ((gAgent.getAvatarObject() != NULL) && (!gAgent.getAvatarObject()->mIsSitting) && !gSavedSettings.getBOOL("BlockClickSit")) // agent not already sitting
196 { 206 {
197 handle_sit_or_stand(); 207 handle_sit_or_stand();
208 // put focus in world when sitting on an object
209 gFocusMgr.setKeyboardFocus(NULL);
198 return TRUE; 210 return TRUE;
199 } // else nothing (fall through to touch) 211 } // else nothing (fall through to touch)
200 212
@@ -247,6 +259,14 @@ BOOL LLToolPie::pickAndShowMenu(BOOL always_show)
247 } 259 }
248 } 260 }
249 261
262 if (!always_show && handle_media_click(mPick))
263 {
264 return FALSE;
265 }
266
267 // put focus back "in world"
268 gFocusMgr.setKeyboardFocus(NULL);
269
250 // Switch to grab tool if physical or triggerable 270 // Switch to grab tool if physical or triggerable
251 if (object && 271 if (object &&
252 !object->isAvatar() && 272 !object->isAvatar() &&
@@ -614,41 +634,46 @@ BOOL LLToolPie::handleHover(S32 x, S32 y, MASK mask)
614 mMouseOutsideSlop = TRUE; 634 mMouseOutsideSlop = TRUE;
615 } 635 }
616 */ 636 */
637
617 638
639 gViewerWindow->getWindow()->setCursor(UI_CURSOR_ARROW);
640
618 LLViewerObject *object = NULL; 641 LLViewerObject *object = NULL;
619 LLViewerObject *parent = NULL; 642 LLViewerObject *parent = NULL;
620 if (gHoverView) 643 object = gViewerWindow->getHoverPick().getObject();
621 {
622 object = gViewerWindow->getHoverPick().getObject();
623 }
624 644
625 if (object) 645 if (object)
626 { 646 {
627 parent = object->getRootEdit(); 647 parent = object->getRootEdit();
628 }
629 648
630 if (object && useClickAction(FALSE, mask, object, parent)) 649 if (object && useClickAction(FALSE, mask, object, parent))
631 { 650 {
632 ECursorType cursor = cursor_from_object(object); 651 ECursorType cursor = cursor_from_object(object);
633 gViewerWindow->getWindow()->setCursor(cursor); 652 gViewerWindow->getWindow()->setCursor(cursor);
634 lldebugst(LLERR_USER_INPUT) << "hover handled by LLToolPie (inactive)" << llendl; 653 }
635 } 654 else if (handle_media_hover(gViewerWindow->getHoverPick()))
636 else if ((object && !object->isAvatar() && object->usePhysics()) 655 {
637 || (parent && !parent->isAvatar() && parent->usePhysics())) 656 // cursor set by media object
638 { 657 }
639 gViewerWindow->getWindow()->setCursor(UI_CURSOR_TOOLGRAB); 658 else if ((object && !object->isAvatar() && object->usePhysics())
640 lldebugst(LLERR_USER_INPUT) << "hover handled by LLToolPie (inactive)" << llendl; 659 || (parent && !parent->isAvatar() && parent->usePhysics()))
641 } 660 {
642 else if ( (object && object->flagHandleTouch()) 661 gViewerWindow->getWindow()->setCursor(UI_CURSOR_TOOLGRAB);
643 || (parent && parent->flagHandleTouch())) 662 }
644 { 663 else if ( (object && object->flagHandleTouch())
645 gViewerWindow->getWindow()->setCursor(UI_CURSOR_HAND); 664 || (parent && parent->flagHandleTouch()))
646 lldebugst(LLERR_USER_INPUT) << "hover handled by LLToolPie (inactive)" << llendl; 665 {
666 gViewerWindow->getWindow()->setCursor(UI_CURSOR_HAND);
667 }
647 } 668 }
648 else 669 else
649 { 670 {
650 gViewerWindow->getWindow()->setCursor(UI_CURSOR_ARROW); 671 // We need to clear media hover flag
651 lldebugst(LLERR_USER_INPUT) << "hover handled by LLToolPie (inactive)" << llendl; 672 if (LLViewerMediaFocus::getInstance()->getMouseOverFlag())
673 {
674 LLViewerMediaFocus::getInstance()->setMouseOverFlag(false);
675 }
676
652 } 677 }
653 678
654 return TRUE; 679 return TRUE;
@@ -830,14 +855,14 @@ static void handle_click_action_play()
830 LLParcel* parcel = LLViewerParcelMgr::getInstance()->getAgentParcel(); 855 LLParcel* parcel = LLViewerParcelMgr::getInstance()->getAgentParcel();
831 if (!parcel) return; 856 if (!parcel) return;
832 857
833 LLMediaBase::EStatus status = LLViewerParcelMedia::getStatus(); 858 LLViewerMediaImpl::EMediaStatus status = LLViewerParcelMedia::getStatus();
834 switch(status) 859 switch(status)
835 { 860 {
836 case LLMediaBase::STATUS_STARTED: 861 case LLViewerMediaImpl::MEDIA_PLAYING:
837 LLViewerParcelMedia::pause(); 862 LLViewerParcelMedia::pause();
838 break; 863 break;
839 864
840 case LLMediaBase::STATUS_PAUSED: 865 case LLViewerMediaImpl::MEDIA_PAUSED:
841 LLViewerParcelMedia::start(); 866 LLViewerParcelMedia::start();
842 break; 867 break;
843 868
@@ -847,6 +872,111 @@ static void handle_click_action_play()
847 } 872 }
848} 873}
849 874
875static bool handle_media_click(const LLPickInfo& pick)
876{
877 //FIXME: how do we handle object in different parcel than us?
878 LLParcel* parcel = LLViewerParcelMgr::getInstance()->getAgentParcel();
879 LLPointer<LLViewerObject> objectp = pick.getObject();
880
881
882 if (!parcel ||
883 objectp.isNull() ||
884 pick.mObjectFace < 0 ||
885 pick.mObjectFace >= objectp->getNumTEs())
886 {
887 LLSelectMgr::getInstance()->deselect();
888 LLViewerMediaFocus::getInstance()->clearFocus();
889
890 return false;
891 }
892
893
894
895 // HACK: This is directly referencing an impl name. BAD!
896 // This can be removed when we have a truly generic media browser that only
897 // builds an impl based on the type of url it is passed.
898
899 // is media playing on this face?
900 const LLTextureEntry* tep = objectp->getTE(pick.mObjectFace);
901
902 viewer_media_t media_impl = LLViewerMedia::getMediaImplFromTextureID(tep->getID());
903 if (tep
904 && media_impl.notNull()
905 && media_impl->hasMedia()
906 && gSavedSettings.getBOOL("MediaOnAPrimUI"))
907 {
908 LLObjectSelectionHandle selection = LLViewerMediaFocus::getInstance()->getSelection();
909 if (! selection->contains(pick.getObject(), pick.mObjectFace))
910 {
911 LLViewerMediaFocus::getInstance()->setFocusFace(TRUE, pick.getObject(), pick.mObjectFace, media_impl);
912 }
913 else
914 {
915 media_impl->mouseDown(pick.mXYCoords.mX, pick.mXYCoords.mY);
916 media_impl->mouseCapture(); // the mouse-up will happen when capture is lost
917 }
918
919 return true;
920 }
921
922 LLSelectMgr::getInstance()->deselect();
923 LLViewerMediaFocus::getInstance()->clearFocus();
924
925 return false;
926}
927
928static bool handle_media_hover(const LLPickInfo& pick)
929{
930 //FIXME: how do we handle object in different parcel than us?
931 LLParcel* parcel = LLViewerParcelMgr::getInstance()->getAgentParcel();
932 if (!parcel) return false;
933
934 LLPointer<LLViewerObject> objectp = pick.getObject();
935
936 // Early out cases. Must clear mouse over media focus flag
937 // did not hit an object or did not hit a valid face
938 if ( objectp.isNull() ||
939 pick.mObjectFace < 0 ||
940 pick.mObjectFace >= objectp->getNumTEs() )
941 {
942 LLViewerMediaFocus::getInstance()->setMouseOverFlag(false);
943 return false;
944 }
945
946
947 // HACK: This is directly referencing an impl name. BAD!
948 // This can be removed when we have a truly generic media browser that only
949 // builds an impl based on the type of url it is passed.
950
951 // is media playing on this face?
952 const LLTextureEntry* tep = objectp->getTE(pick.mObjectFace);
953 viewer_media_t media_impl = LLViewerMedia::getMediaImplFromTextureID(tep->getID());
954 if (tep
955 && media_impl.notNull()
956 && media_impl->hasMedia()
957 && gSavedSettings.getBOOL("MediaOnAPrimUI"))
958 {
959 if(LLViewerMediaFocus::getInstance()->getFocus())
960 {
961 media_impl->mouseMove(pick.mXYCoords.mX, pick.mXYCoords.mY);
962 }
963
964 // Set mouse over flag if unset
965 if (! LLViewerMediaFocus::getInstance()->getMouseOverFlag())
966 {
967 LLSelectMgr::getInstance()->setHoverObject(objectp, pick.mObjectFace);
968 LLViewerMediaFocus::getInstance()->setMouseOverFlag(true, media_impl);
969 LLViewerMediaFocus::getInstance()->setPickInfo(pick);
970 }
971
972 return true;
973 }
974 LLViewerMediaFocus::getInstance()->setMouseOverFlag(false);
975
976 return false;
977}
978
979
850static void handle_click_action_open_media(LLPointer<LLViewerObject> objectp) 980static void handle_click_action_open_media(LLPointer<LLViewerObject> objectp)
851{ 981{
852 //FIXME: how do we handle object in different parcel than us? 982 //FIXME: how do we handle object in different parcel than us?
@@ -861,7 +991,7 @@ static void handle_click_action_open_media(LLPointer<LLViewerObject> objectp)
861 if( face < 0 || face >= objectp->getNumTEs() ) return; 991 if( face < 0 || face >= objectp->getNumTEs() ) return;
862 992
863 // is media playing on this face? 993 // is media playing on this face?
864 if (!LLViewerMedia::isActiveMediaTexture(objectp->getTE(face)->getID())) 994 if (LLViewerMedia::getMediaImplFromTextureID(objectp->getTE(face)->getID()) != NULL)
865 { 995 {
866 handle_click_action_play(); 996 handle_click_action_play();
867 return; 997 return;
@@ -879,10 +1009,7 @@ static void handle_click_action_open_media(LLPointer<LLViewerObject> objectp)
879 // This can be removed when we have a truly generic media browser that only 1009 // This can be removed when we have a truly generic media browser that only
880 // builds an impl based on the type of url it is passed. 1010 // builds an impl based on the type of url it is passed.
881 1011
882 if( LLMediaManager::getInstance()->supportsMediaType( "LLMediaImplLLMozLib", media_scheme, media_type ) ) 1012 LLWeb::loadURL(media_url);
883 {
884 LLWeb::loadURL(media_url);
885 }
886} 1013}
887 1014
888static ECursorType cursor_from_parcel_media(U8 click_action) 1015static ECursorType cursor_from_parcel_media(U8 click_action)
@@ -900,19 +1027,12 @@ static ECursorType cursor_from_parcel_media(U8 click_action)
900 std::string media_type = std::string ( parcel->getMediaType() ); 1027 std::string media_type = std::string ( parcel->getMediaType() );
901 LLStringUtil::trim(media_url); 1028 LLStringUtil::trim(media_url);
902 1029
903 // Get the scheme, see if that is handled as well. 1030 open_cursor = UI_CURSOR_TOOLMEDIAOPEN;
904 LLURI uri(media_url);
905 std::string media_scheme = uri.scheme() != "" ? uri.scheme() : "http";
906
907 if( LLMediaManager::getInstance()->supportsMediaType( "LLMediaImplLLMozLib", media_scheme, media_type ) )
908 {
909 open_cursor = UI_CURSOR_TOOLMEDIAOPEN;
910 }
911 1031
912 LLMediaBase::EStatus status = LLViewerParcelMedia::getStatus(); 1032 LLViewerMediaImpl::EMediaStatus status = LLViewerParcelMedia::getStatus();
913 switch(status) 1033 switch(status)
914 { 1034 {
915 case LLMediaBase::STATUS_STARTED: 1035 case LLViewerMediaImpl::MEDIA_PLAYING:
916 return click_action == CLICK_ACTION_PLAY ? UI_CURSOR_TOOLPAUSE : open_cursor; 1036 return click_action == CLICK_ACTION_PLAY ? UI_CURSOR_TOOLPAUSE : open_cursor;
917 default: 1037 default:
918 return UI_CURSOR_TOOLPLAY; 1038 return UI_CURSOR_TOOLPLAY;