diff options
Diffstat (limited to '')
-rw-r--r-- | linden/indra/newview/llviewertexteditor.cpp | 178 |
1 files changed, 88 insertions, 90 deletions
diff --git a/linden/indra/newview/llviewertexteditor.cpp b/linden/indra/newview/llviewertexteditor.cpp index 15085ac..60ec187 100644 --- a/linden/indra/newview/llviewertexteditor.cpp +++ b/linden/indra/newview/llviewertexteditor.cpp | |||
@@ -54,13 +54,15 @@ | |||
54 | #include "llviewerimagelist.h" | 54 | #include "llviewerimagelist.h" |
55 | #include "llviewerwindow.h" | 55 | #include "llviewerwindow.h" |
56 | #include "llviewerinventory.h" | 56 | #include "llviewerinventory.h" |
57 | #include "llvieweruictrlfactory.h" | 57 | #include "lluictrlfactory.h" |
58 | #include "llnotecard.h" | 58 | #include "llnotecard.h" |
59 | #include "llmemorystream.h" | 59 | #include "llmemorystream.h" |
60 | #include "llmenugl.h" | 60 | #include "llmenugl.h" |
61 | 61 | ||
62 | #include "llappviewer.h" // for gPacificDaylightTime | 62 | #include "llappviewer.h" // for gPacificDaylightTime |
63 | 63 | ||
64 | static LLRegisterWidget<LLViewerTextEditor> r("text_editor"); | ||
65 | |||
64 | ///---------------------------------------------------------------------------- | 66 | ///---------------------------------------------------------------------------- |
65 | /// Class LLEmbeddedNotecardOpener | 67 | /// Class LLEmbeddedNotecardOpener |
66 | ///---------------------------------------------------------------------------- | 68 | ///---------------------------------------------------------------------------- |
@@ -424,15 +426,15 @@ void LLEmbeddedItems::bindEmbeddedChars( LLFontGL* font ) const | |||
424 | break; | 426 | break; |
425 | case LLAssetType::AT_NOTECARD: img_name = "inv_item_notecard.tga"; break; | 427 | case LLAssetType::AT_NOTECARD: img_name = "inv_item_notecard.tga"; break; |
426 | case LLAssetType::AT_LSL_TEXT: img_name = "inv_item_script.tga"; break; | 428 | case LLAssetType::AT_LSL_TEXT: img_name = "inv_item_script.tga"; break; |
427 | case LLAssetType::AT_BODYPART: img_name = "inv_item_bodypart.tga"; break; | 429 | case LLAssetType::AT_BODYPART: img_name = "inv_item_skin.tga"; break; |
428 | case LLAssetType::AT_ANIMATION: img_name = "inv_item_animation.tga";break; | 430 | case LLAssetType::AT_ANIMATION: img_name = "inv_item_animation.tga";break; |
429 | case LLAssetType::AT_GESTURE: img_name = "inv_item_gesture.tga"; break; | 431 | case LLAssetType::AT_GESTURE: img_name = "inv_item_gesture.tga"; break; |
430 | default: llassert(0); continue; | 432 | default: llassert(0); continue; |
431 | } | 433 | } |
432 | 434 | ||
433 | LLViewerImage* image = gImageList.getImage(LLUUID(gViewerArt.getString(img_name)), MIPMAP_FALSE, TRUE); | 435 | LLUIImagePtr image = LLUI::getUIImage(img_name); |
434 | 436 | ||
435 | font->addEmbeddedChar( wch, image, item->getName() ); | 437 | font->addEmbeddedChar( wch, image->getImage(), item->getName() ); |
436 | } | 438 | } |
437 | } | 439 | } |
438 | 440 | ||
@@ -575,7 +577,8 @@ LLViewerTextEditor::LLViewerTextEditor(const LLString& name, | |||
575 | // *TODO: Add right click menus for SLURLs | 577 | // *TODO: Add right click menus for SLURLs |
576 | // Build the right click menu | 578 | // Build the right click menu |
577 | // make the popup menu available | 579 | // make the popup menu available |
578 | //LLMenuGL* menu = gUICtrlFactory->buildMenu("menu_slurl.xml", this); | 580 | |
581 | //LLMenuGL* menu = LLUICtrlFactory::getInstance()->buildMenu("menu_slurl.xml", this); | ||
579 | //if (!menu) | 582 | //if (!menu) |
580 | //{ | 583 | //{ |
581 | // menu = new LLMenuGL(""); | 584 | // menu = new LLMenuGL(""); |
@@ -694,7 +697,7 @@ BOOL LLViewerTextEditor::handleMouseDown(S32 x, S32 y, MASK mask) | |||
694 | S32 screen_x; | 697 | S32 screen_x; |
695 | S32 screen_y; | 698 | S32 screen_y; |
696 | localPointToScreen(x, y, &screen_x, &screen_y ); | 699 | localPointToScreen(x, y, &screen_x, &screen_y ); |
697 | gToolDragAndDrop->setDragStart( screen_x, screen_y ); | 700 | LLToolDragAndDrop::getInstance()->setDragStart( screen_x, screen_y ); |
698 | 701 | ||
699 | start_select = FALSE; | 702 | start_select = FALSE; |
700 | } | 703 | } |
@@ -779,108 +782,105 @@ BOOL LLViewerTextEditor::handleHover(S32 x, S32 y, MASK mask) | |||
779 | // leave hover segment active during drag and drop | 782 | // leave hover segment active during drag and drop |
780 | mHoverSegment = NULL; | 783 | mHoverSegment = NULL; |
781 | } | 784 | } |
782 | if( getVisible() ) | 785 | if(hasMouseCapture() ) |
783 | { | 786 | { |
784 | if(hasMouseCapture() ) | 787 | if( mIsSelecting ) |
785 | { | 788 | { |
786 | if( mIsSelecting ) | 789 | if (x != mLastSelectionX || y != mLastSelectionY) |
787 | { | 790 | { |
788 | if (x != mLastSelectionX || y != mLastSelectionY) | 791 | mLastSelectionX = x; |
789 | { | 792 | mLastSelectionY = y; |
790 | mLastSelectionX = x; | 793 | } |
791 | mLastSelectionY = y; | ||
792 | } | ||
793 | |||
794 | if( y > getTextRect().mTop ) | ||
795 | { | ||
796 | mScrollbar->setDocPos( mScrollbar->getDocPos() - 1 ); | ||
797 | } | ||
798 | else | ||
799 | if( y < getTextRect().mBottom ) | ||
800 | { | ||
801 | mScrollbar->setDocPos( mScrollbar->getDocPos() + 1 ); | ||
802 | } | ||
803 | 794 | ||
804 | setCursorAtLocalPos( x, y, TRUE ); | 795 | if( y > getTextRect().mTop ) |
805 | mSelectionEnd = mCursorPos; | 796 | { |
806 | 797 | mScrollbar->setDocPos( mScrollbar->getDocPos() - 1 ); | |
807 | updateScrollFromCursor(); | ||
808 | getWindow()->setCursor(UI_CURSOR_IBEAM); | ||
809 | } | 798 | } |
810 | else if( mDragItem ) | 799 | else |
800 | if( y < getTextRect().mBottom ) | ||
811 | { | 801 | { |
812 | S32 screen_x; | 802 | mScrollbar->setDocPos( mScrollbar->getDocPos() + 1 ); |
813 | S32 screen_y; | ||
814 | localPointToScreen(x, y, &screen_x, &screen_y ); | ||
815 | if( gToolDragAndDrop->isOverThreshold( screen_x, screen_y ) ) | ||
816 | { | ||
817 | gToolDragAndDrop->beginDrag( | ||
818 | LLAssetType::lookupDragAndDropType( mDragItem->getType() ), | ||
819 | mDragItem->getUUID(), | ||
820 | LLToolDragAndDrop::SOURCE_NOTECARD, | ||
821 | getSourceID(), mObjectID); | ||
822 | |||
823 | return gToolDragAndDrop->handleHover( x, y, mask ); | ||
824 | } | ||
825 | getWindow()->setCursor(UI_CURSOR_HAND); | ||
826 | } | 803 | } |
827 | 804 | ||
828 | lldebugst(LLERR_USER_INPUT) << "hover handled by " << getName() << " (active)" << llendl; | 805 | setCursorAtLocalPos( x, y, TRUE ); |
829 | handled = TRUE; | 806 | mSelectionEnd = mCursorPos; |
830 | } | 807 | |
831 | 808 | updateScrollFromCursor(); | |
832 | if( !handled ) | 809 | getWindow()->setCursor(UI_CURSOR_IBEAM); |
833 | { | ||
834 | // Pass to children | ||
835 | handled = LLView::childrenHandleHover(x, y, mask) != NULL; | ||
836 | } | ||
837 | |||
838 | if( handled ) | ||
839 | { | ||
840 | // Delay cursor flashing | ||
841 | resetKeystrokeTimer(); | ||
842 | } | 810 | } |
843 | 811 | else if( mDragItem ) | |
844 | // Opaque | ||
845 | if( !handled && mTakesNonScrollClicks) | ||
846 | { | 812 | { |
847 | // Check to see if we're over an HTML-style link | 813 | S32 screen_x; |
848 | if( !mSegments.empty() ) | 814 | S32 screen_y; |
815 | localPointToScreen(x, y, &screen_x, &screen_y ); | ||
816 | if( LLToolDragAndDrop::getInstance()->isOverThreshold( screen_x, screen_y ) ) | ||
849 | { | 817 | { |
850 | const LLTextSegment* cur_segment = getSegmentAtLocalPos( x, y ); | 818 | LLToolDragAndDrop::getInstance()->beginDrag( |
851 | if( cur_segment ) | 819 | LLAssetType::lookupDragAndDropType( mDragItem->getType() ), |
852 | { | 820 | mDragItem->getUUID(), |
853 | if(cur_segment->getStyle().isLink()) | 821 | LLToolDragAndDrop::SOURCE_NOTECARD, |
854 | { | 822 | getSourceID(), mObjectID); |
855 | lldebugst(LLERR_USER_INPUT) << "hover handled by " << getName() << " (over link, inactive)" << llendl; | 823 | |
856 | getWindow()->setCursor(UI_CURSOR_HAND); | 824 | return LLToolDragAndDrop::getInstance()->handleHover( x, y, mask ); |
857 | handled = TRUE; | ||
858 | } | ||
859 | else | ||
860 | if(cur_segment->getStyle().getIsEmbeddedItem()) | ||
861 | { | ||
862 | lldebugst(LLERR_USER_INPUT) << "hover handled by " << getName() << " (over embedded item, inactive)" << llendl; | ||
863 | getWindow()->setCursor(UI_CURSOR_HAND); | ||
864 | //getWindow()->setCursor(UI_CURSOR_ARROW); | ||
865 | handled = TRUE; | ||
866 | } | ||
867 | mHoverSegment = cur_segment; | ||
868 | } | ||
869 | } | 825 | } |
826 | getWindow()->setCursor(UI_CURSOR_HAND); | ||
827 | } | ||
870 | 828 | ||
871 | if( !handled ) | 829 | lldebugst(LLERR_USER_INPUT) << "hover handled by " << getName() << " (active)" << llendl; |
830 | handled = TRUE; | ||
831 | } | ||
832 | |||
833 | if( !handled ) | ||
834 | { | ||
835 | // Pass to children | ||
836 | handled = LLView::childrenHandleHover(x, y, mask) != NULL; | ||
837 | } | ||
838 | |||
839 | if( handled ) | ||
840 | { | ||
841 | // Delay cursor flashing | ||
842 | resetKeystrokeTimer(); | ||
843 | } | ||
844 | |||
845 | // Opaque | ||
846 | if( !handled && mTakesNonScrollClicks) | ||
847 | { | ||
848 | // Check to see if we're over an HTML-style link | ||
849 | if( !mSegments.empty() ) | ||
850 | { | ||
851 | const LLTextSegment* cur_segment = getSegmentAtLocalPos( x, y ); | ||
852 | if( cur_segment ) | ||
872 | { | 853 | { |
873 | lldebugst(LLERR_USER_INPUT) << "hover handled by " << getName() << " (inactive)" << llendl; | 854 | if(cur_segment->getStyle().isLink()) |
874 | if (!mScrollbar->getVisible() || x < getRect().getWidth() - SCROLLBAR_SIZE) | ||
875 | { | 855 | { |
876 | getWindow()->setCursor(UI_CURSOR_IBEAM); | 856 | lldebugst(LLERR_USER_INPUT) << "hover handled by " << getName() << " (over link, inactive)" << llendl; |
857 | getWindow()->setCursor(UI_CURSOR_HAND); | ||
858 | handled = TRUE; | ||
877 | } | 859 | } |
878 | else | 860 | else |
861 | if(cur_segment->getStyle().getIsEmbeddedItem()) | ||
879 | { | 862 | { |
880 | getWindow()->setCursor(UI_CURSOR_ARROW); | 863 | lldebugst(LLERR_USER_INPUT) << "hover handled by " << getName() << " (over embedded item, inactive)" << llendl; |
864 | getWindow()->setCursor(UI_CURSOR_HAND); | ||
865 | //getWindow()->setCursor(UI_CURSOR_ARROW); | ||
866 | handled = TRUE; | ||
881 | } | 867 | } |
882 | handled = TRUE; | 868 | mHoverSegment = cur_segment; |
869 | } | ||
870 | } | ||
871 | |||
872 | if( !handled ) | ||
873 | { | ||
874 | lldebugst(LLERR_USER_INPUT) << "hover handled by " << getName() << " (inactive)" << llendl; | ||
875 | if (!mScrollbar->getVisible() || x < getRect().getWidth() - SCROLLBAR_SIZE) | ||
876 | { | ||
877 | getWindow()->setCursor(UI_CURSOR_IBEAM); | ||
883 | } | 878 | } |
879 | else | ||
880 | { | ||
881 | getWindow()->setCursor(UI_CURSOR_ARROW); | ||
882 | } | ||
883 | handled = TRUE; | ||
884 | } | 884 | } |
885 | } | 885 | } |
886 | 886 | ||
@@ -962,8 +962,6 @@ BOOL LLViewerTextEditor::handleMouseUp(S32 x, S32 y, MASK mask) | |||
962 | 962 | ||
963 | BOOL LLViewerTextEditor::handleRightMouseDown(S32 x, S32 y, MASK mask) | 963 | BOOL LLViewerTextEditor::handleRightMouseDown(S32 x, S32 y, MASK mask) |
964 | { | 964 | { |
965 | |||
966 | |||
967 | BOOL handled = childrenHandleRightMouseDown(x, y, mask) != NULL; | 965 | BOOL handled = childrenHandleRightMouseDown(x, y, mask) != NULL; |
968 | 966 | ||
969 | // *TODO: Add right click menus for SLURLs | 967 | // *TODO: Add right click menus for SLURLs |