diff options
author | McCabe Maxsted | 2009-10-18 17:58:27 -0700 |
---|---|---|
committer | McCabe Maxsted | 2009-10-18 17:58:27 -0700 |
commit | e4b0e7c82d670081c071d8a3da31b5ec407b8e07 (patch) | |
tree | 9410962bbb582eedbec448139e217f2714050777 /linden/indra/llui | |
parent | Started 1.3.0 branch (diff) | |
parent | Updated and added some Linux libs. (diff) | |
download | meta-impy-e4b0e7c82d670081c071d8a3da31b5ec407b8e07.zip meta-impy-e4b0e7c82d670081c071d8a3da31b5ec407b8e07.tar.gz meta-impy-e4b0e7c82d670081c071d8a3da31b5ec407b8e07.tar.bz2 meta-impy-e4b0e7c82d670081c071d8a3da31b5ec407b8e07.tar.xz |
Merged working branch of 1.2 into LL 1.23 merge
Diffstat (limited to 'linden/indra/llui')
-rw-r--r-- | linden/indra/llui/llclipboard.cpp | 41 | ||||
-rw-r--r-- | linden/indra/llui/llclipboard.h | 11 | ||||
-rw-r--r-- | linden/indra/llui/llfloater.cpp | 6 | ||||
-rw-r--r-- | linden/indra/llui/llfloater.h | 2 | ||||
-rw-r--r-- | linden/indra/llui/llkeywords.cpp | 4 | ||||
-rw-r--r-- | linden/indra/llui/lllineeditor.cpp | 83 | ||||
-rw-r--r-- | linden/indra/llui/lllineeditor.h | 13 | ||||
-rw-r--r-- | linden/indra/llui/llscrolllistctrl.cpp | 12 | ||||
-rw-r--r-- | linden/indra/llui/llscrolllistctrl.h | 1 | ||||
-rw-r--r-- | linden/indra/llui/llspinctrl.cpp | 5 | ||||
-rw-r--r-- | linden/indra/llui/lltexteditor.cpp | 97 | ||||
-rw-r--r-- | linden/indra/llui/lltexteditor.h | 12 | ||||
-rw-r--r-- | linden/indra/llui/llview.cpp | 80 | ||||
-rw-r--r-- | linden/indra/llui/llview.h | 6 |
14 files changed, 347 insertions, 26 deletions
diff --git a/linden/indra/llui/llclipboard.cpp b/linden/indra/llui/llclipboard.cpp index 8a7a214..2cb8197 100644 --- a/linden/indra/llui/llclipboard.cpp +++ b/linden/indra/llui/llclipboard.cpp | |||
@@ -93,3 +93,44 @@ BOOL LLClipboard::canPasteString() const | |||
93 | { | 93 | { |
94 | return LLView::getWindow()->isClipboardTextAvailable(); | 94 | return LLView::getWindow()->isClipboardTextAvailable(); |
95 | } | 95 | } |
96 | |||
97 | |||
98 | void LLClipboard::copyFromPrimarySubstring(const LLWString &src, S32 pos, S32 len, const LLUUID& source_id ) | ||
99 | { | ||
100 | mSourceID = source_id; | ||
101 | mString = src.substr(pos, len); | ||
102 | LLView::getWindow()->copyTextToPrimary( mString ); | ||
103 | } | ||
104 | |||
105 | |||
106 | const LLWString& LLClipboard::getPastePrimaryWString( LLUUID* source_id ) | ||
107 | { | ||
108 | if( mSourceID.notNull() ) | ||
109 | { | ||
110 | LLWString temp_string; | ||
111 | LLView::getWindow()->pasteTextFromPrimary(temp_string); | ||
112 | |||
113 | if( temp_string != mString ) | ||
114 | { | ||
115 | mSourceID.setNull(); | ||
116 | mString = temp_string; | ||
117 | } | ||
118 | } | ||
119 | else | ||
120 | { | ||
121 | LLView::getWindow()->pasteTextFromPrimary(mString); | ||
122 | } | ||
123 | |||
124 | if( source_id ) | ||
125 | { | ||
126 | *source_id = mSourceID; | ||
127 | } | ||
128 | |||
129 | return mString; | ||
130 | } | ||
131 | |||
132 | |||
133 | BOOL LLClipboard::canPastePrimaryString() const | ||
134 | { | ||
135 | return LLView::getWindow()->isPrimaryTextAvailable(); | ||
136 | } | ||
diff --git a/linden/indra/llui/llclipboard.h b/linden/indra/llui/llclipboard.h index 37ed1ff..034a7a6 100644 --- a/linden/indra/llui/llclipboard.h +++ b/linden/indra/llui/llclipboard.h | |||
@@ -44,10 +44,19 @@ public: | |||
44 | LLClipboard(); | 44 | LLClipboard(); |
45 | ~LLClipboard(); | 45 | ~LLClipboard(); |
46 | 46 | ||
47 | /* We support two flavors of clipboard. The default is the explicitly | ||
48 | copy-and-pasted clipboard. The second is the so-called 'primary' clipboard | ||
49 | which is implicitly copied upon selection on platforms which expect this | ||
50 | (i.e. X11/Linux). */ | ||
51 | |||
47 | void copyFromSubstring(const LLWString ©_from, S32 pos, S32 len, const LLUUID& source_id = LLUUID::null ); | 52 | void copyFromSubstring(const LLWString ©_from, S32 pos, S32 len, const LLUUID& source_id = LLUUID::null ); |
48 | BOOL canPasteString() const; | 53 | BOOL canPasteString() const; |
49 | const LLWString& getPasteWString(LLUUID* source_id = NULL); | 54 | const LLWString& getPasteWString(LLUUID* source_id = NULL); |
50 | 55 | ||
56 | void copyFromPrimarySubstring(const LLWString ©_from, S32 pos, S32 len, const LLUUID& source_id = LLUUID::null ); | ||
57 | BOOL canPastePrimaryString() const; | ||
58 | const LLWString& getPastePrimaryWString(LLUUID* source_id = NULL); | ||
59 | |||
51 | private: | 60 | private: |
52 | LLUUID mSourceID; | 61 | LLUUID mSourceID; |
53 | LLWString mString; | 62 | LLWString mString; |
diff --git a/linden/indra/llui/llfloater.cpp b/linden/indra/llui/llfloater.cpp index 94af186..defe200 100644 --- a/linden/indra/llui/llfloater.cpp +++ b/linden/indra/llui/llfloater.cpp | |||
@@ -1193,6 +1193,12 @@ BOOL LLFloater::handleRightMouseDown(S32 x, S32 y, MASK mask) | |||
1193 | return was_minimized || LLPanel::handleRightMouseDown( x, y, mask ); | 1193 | return was_minimized || LLPanel::handleRightMouseDown( x, y, mask ); |
1194 | } | 1194 | } |
1195 | 1195 | ||
1196 | BOOL LLFloater::handleMiddleMouseDown(S32 x, S32 y, MASK mask) | ||
1197 | { | ||
1198 | bringToFront( x, y ); | ||
1199 | return LLPanel::handleMiddleMouseDown( x, y, mask ); | ||
1200 | } | ||
1201 | |||
1196 | 1202 | ||
1197 | // virtual | 1203 | // virtual |
1198 | BOOL LLFloater::handleDoubleClick(S32 x, S32 y, MASK mask) | 1204 | BOOL LLFloater::handleDoubleClick(S32 x, S32 y, MASK mask) |
diff --git a/linden/indra/llui/llfloater.h b/linden/indra/llui/llfloater.h index a8f7c21..0e3d148 100644 --- a/linden/indra/llui/llfloater.h +++ b/linden/indra/llui/llfloater.h | |||
@@ -195,7 +195,7 @@ public: | |||
195 | virtual BOOL handleMouseDown(S32 x, S32 y, MASK mask); | 195 | virtual BOOL handleMouseDown(S32 x, S32 y, MASK mask); |
196 | virtual BOOL handleRightMouseDown(S32 x, S32 y, MASK mask); | 196 | virtual BOOL handleRightMouseDown(S32 x, S32 y, MASK mask); |
197 | virtual BOOL handleDoubleClick(S32 x, S32 y, MASK mask); | 197 | virtual BOOL handleDoubleClick(S32 x, S32 y, MASK mask); |
198 | 198 | virtual BOOL handleMiddleMouseDown(S32 x, S32 y, MASK mask); | |
199 | virtual void draw(); | 199 | virtual void draw(); |
200 | 200 | ||
201 | virtual void onOpen() {} | 201 | virtual void onOpen() {} |
diff --git a/linden/indra/llui/llkeywords.cpp b/linden/indra/llui/llkeywords.cpp index 9ecd744..93da44c 100644 --- a/linden/indra/llui/llkeywords.cpp +++ b/linden/indra/llui/llkeywords.cpp | |||
@@ -381,9 +381,9 @@ void LLKeywords::findSegments(std::vector<LLTextSegment *>* seg_list, const LLWS | |||
381 | seg_start = cur - base; | 381 | seg_start = cur - base; |
382 | cur += cur_delimiter->getLength(); | 382 | cur += cur_delimiter->getLength(); |
383 | 383 | ||
384 | if( cur_delimiter->getType() == LLKeywordToken::TWO_SIDED_DELIMITER || LLKeywordToken::TWO_SIDED_DELIMITER_ESC) | 384 | LLKeywordToken::TOKEN_TYPE type = cur_delimiter->getType(); |
385 | if (type == LLKeywordToken::TWO_SIDED_DELIMITER || type == LLKeywordToken::TWO_SIDED_DELIMITER_ESC) | ||
385 | { | 386 | { |
386 | llassert( cur_delimiter->getDelimiter() != NULL ); | ||
387 | while( *cur && !cur_delimiter->isTail(cur)) | 387 | while( *cur && !cur_delimiter->isTail(cur)) |
388 | { | 388 | { |
389 | // Check for an escape sequence. | 389 | // Check for an escape sequence. |
diff --git a/linden/indra/llui/lllineeditor.cpp b/linden/indra/llui/lllineeditor.cpp index f35fa58..fc33dcf 100644 --- a/linden/indra/llui/lllineeditor.cpp +++ b/linden/indra/llui/lllineeditor.cpp | |||
@@ -494,6 +494,9 @@ BOOL LLLineEditor::handleDoubleClick(S32 x, S32 y, MASK mask) | |||
494 | // delay cursor flashing | 494 | // delay cursor flashing |
495 | mKeystrokeTimer.reset(); | 495 | mKeystrokeTimer.reset(); |
496 | 496 | ||
497 | // take selection to 'primary' clipboard | ||
498 | updatePrimary(); | ||
499 | |||
497 | return TRUE; | 500 | return TRUE; |
498 | } | 501 | } |
499 | 502 | ||
@@ -576,6 +579,17 @@ BOOL LLLineEditor::handleMouseDown(S32 x, S32 y, MASK mask) | |||
576 | return TRUE; | 579 | return TRUE; |
577 | } | 580 | } |
578 | 581 | ||
582 | BOOL LLLineEditor::handleMiddleMouseDown(S32 x, S32 y, MASK mask) | ||
583 | { | ||
584 | // llinfos << "MiddleMouseDown" << llendl; | ||
585 | setFocus( TRUE ); | ||
586 | if( canPastePrimary() ) | ||
587 | { | ||
588 | setCursorAtLocalPos(x); | ||
589 | pastePrimary(); | ||
590 | } | ||
591 | return TRUE; | ||
592 | } | ||
579 | 593 | ||
580 | BOOL LLLineEditor::handleHover(S32 x, S32 y, MASK mask) | 594 | BOOL LLLineEditor::handleHover(S32 x, S32 y, MASK mask) |
581 | { | 595 | { |
@@ -670,6 +684,9 @@ BOOL LLLineEditor::handleMouseUp(S32 x, S32 y, MASK mask) | |||
670 | { | 684 | { |
671 | // delay cursor flashing | 685 | // delay cursor flashing |
672 | mKeystrokeTimer.reset(); | 686 | mKeystrokeTimer.reset(); |
687 | |||
688 | // take selection to 'primary' clipboard | ||
689 | updatePrimary(); | ||
673 | } | 690 | } |
674 | 691 | ||
675 | return handled; | 692 | return handled; |
@@ -873,7 +890,12 @@ BOOL LLLineEditor::handleSelectionKey(KEY key, MASK mask) | |||
873 | } | 890 | } |
874 | } | 891 | } |
875 | 892 | ||
876 | 893 | if(handled) | |
894 | { | ||
895 | // take selection to 'primary' clipboard | ||
896 | updatePrimary(); | ||
897 | } | ||
898 | |||
877 | return handled; | 899 | return handled; |
878 | } | 900 | } |
879 | 901 | ||
@@ -946,20 +968,42 @@ BOOL LLLineEditor::canPaste() const | |||
946 | return !mReadOnly && gClipboard.canPasteString(); | 968 | return !mReadOnly && gClipboard.canPasteString(); |
947 | } | 969 | } |
948 | 970 | ||
949 | |||
950 | // paste from clipboard | ||
951 | void LLLineEditor::paste() | 971 | void LLLineEditor::paste() |
952 | { | 972 | { |
953 | if (canPaste()) | 973 | bool is_primary = false; |
974 | pasteHelper(is_primary); | ||
975 | } | ||
976 | |||
977 | void LLLineEditor::pastePrimary() | ||
978 | { | ||
979 | bool is_primary = true; | ||
980 | pasteHelper(is_primary); | ||
981 | } | ||
982 | |||
983 | // paste from primary (is_primary==true) or clipboard (is_primary==false) | ||
984 | void LLLineEditor::pasteHelper(bool is_primary) | ||
985 | { | ||
986 | bool can_paste_it; | ||
987 | if (is_primary) | ||
988 | can_paste_it = canPastePrimary(); | ||
989 | else | ||
990 | can_paste_it = canPaste(); | ||
991 | |||
992 | if (can_paste_it) | ||
954 | { | 993 | { |
955 | LLWString paste = gClipboard.getPasteWString(); | 994 | LLWString paste; |
995 | if (is_primary) | ||
996 | paste = gClipboard.getPastePrimaryWString(); | ||
997 | else | ||
998 | paste = gClipboard.getPasteWString(); | ||
999 | |||
956 | if (!paste.empty()) | 1000 | if (!paste.empty()) |
957 | { | 1001 | { |
958 | // Prepare for possible rollback | 1002 | // Prepare for possible rollback |
959 | LLLineEditorRollback rollback(this); | 1003 | LLLineEditorRollback rollback(this); |
960 | 1004 | ||
961 | // Delete any selected characters | 1005 | // Delete any selected characters |
962 | if (hasSelection()) | 1006 | if ((!is_primary) && hasSelection()) |
963 | { | 1007 | { |
964 | deleteSelection(); | 1008 | deleteSelection(); |
965 | } | 1009 | } |
@@ -995,7 +1039,7 @@ void LLLineEditor::paste() | |||
995 | clean_string = clean_string.substr(0, wchars_that_fit); | 1039 | clean_string = clean_string.substr(0, wchars_that_fit); |
996 | reportBadKeystroke(); | 1040 | reportBadKeystroke(); |
997 | } | 1041 | } |
998 | 1042 | ||
999 | mText.insert(getCursor(), clean_string); | 1043 | mText.insert(getCursor(), clean_string); |
1000 | setCursor( getCursor() + (S32)clean_string.length() ); | 1044 | setCursor( getCursor() + (S32)clean_string.length() ); |
1001 | deselect(); | 1045 | deselect(); |
@@ -1016,7 +1060,30 @@ void LLLineEditor::paste() | |||
1016 | } | 1060 | } |
1017 | } | 1061 | } |
1018 | 1062 | ||
1019 | 1063 | // copy selection to primary | |
1064 | void LLLineEditor::copyPrimary() | ||
1065 | { | ||
1066 | if( canCopy() ) | ||
1067 | { | ||
1068 | S32 left_pos = llmin( mSelectionStart, mSelectionEnd ); | ||
1069 | S32 length = abs( mSelectionStart - mSelectionEnd ); | ||
1070 | gClipboard.copyFromPrimarySubstring( mText.getWString(), left_pos, length ); | ||
1071 | } | ||
1072 | } | ||
1073 | |||
1074 | BOOL LLLineEditor::canPastePrimary() const | ||
1075 | { | ||
1076 | return !mReadOnly && gClipboard.canPastePrimaryString(); | ||
1077 | } | ||
1078 | |||
1079 | void LLLineEditor::updatePrimary() | ||
1080 | { | ||
1081 | if(canCopy() ) | ||
1082 | { | ||
1083 | copyPrimary(); | ||
1084 | } | ||
1085 | } | ||
1086 | |||
1020 | BOOL LLLineEditor::handleSpecialKey(KEY key, MASK mask) | 1087 | BOOL LLLineEditor::handleSpecialKey(KEY key, MASK mask) |
1021 | { | 1088 | { |
1022 | BOOL handled = FALSE; | 1089 | BOOL handled = FALSE; |
diff --git a/linden/indra/llui/lllineeditor.h b/linden/indra/llui/lllineeditor.h index cc12aa1..a670b21 100644 --- a/linden/indra/llui/lllineeditor.h +++ b/linden/indra/llui/lllineeditor.h | |||
@@ -90,6 +90,7 @@ public: | |||
90 | /*virtual*/ BOOL handleMouseUp(S32 x, S32 y, MASK mask); | 90 | /*virtual*/ BOOL handleMouseUp(S32 x, S32 y, MASK mask); |
91 | /*virtual*/ BOOL handleHover(S32 x, S32 y, MASK mask); | 91 | /*virtual*/ BOOL handleHover(S32 x, S32 y, MASK mask); |
92 | /*virtual*/ BOOL handleDoubleClick(S32 x,S32 y,MASK mask); | 92 | /*virtual*/ BOOL handleDoubleClick(S32 x,S32 y,MASK mask); |
93 | /*virtual*/ BOOL handleMiddleMouseDown(S32 x,S32 y,MASK mask); | ||
93 | /*virtual*/ BOOL handleKeyHere(KEY key, MASK mask ); | 94 | /*virtual*/ BOOL handleKeyHere(KEY key, MASK mask ); |
94 | /*virtual*/ BOOL handleUnicodeCharHere(llwchar uni_char); | 95 | /*virtual*/ BOOL handleUnicodeCharHere(llwchar uni_char); |
95 | /*virtual*/ void onMouseCaptureLost(); | 96 | /*virtual*/ void onMouseCaptureLost(); |
@@ -97,13 +98,16 @@ public: | |||
97 | // LLEditMenuHandler overrides | 98 | // LLEditMenuHandler overrides |
98 | virtual void cut(); | 99 | virtual void cut(); |
99 | virtual BOOL canCut() const; | 100 | virtual BOOL canCut() const; |
100 | |||
101 | virtual void copy(); | 101 | virtual void copy(); |
102 | virtual BOOL canCopy() const; | 102 | virtual BOOL canCopy() const; |
103 | |||
104 | virtual void paste(); | 103 | virtual void paste(); |
105 | virtual BOOL canPaste() const; | 104 | virtual BOOL canPaste() const; |
106 | 105 | ||
106 | virtual void updatePrimary(); | ||
107 | virtual void copyPrimary(); | ||
108 | virtual void pastePrimary(); | ||
109 | virtual BOOL canPastePrimary() const; | ||
110 | |||
107 | virtual void doDelete(); | 111 | virtual void doDelete(); |
108 | virtual BOOL canDoDelete() const; | 112 | virtual BOOL canDoDelete() const; |
109 | 113 | ||
@@ -220,6 +224,9 @@ public: | |||
220 | 224 | ||
221 | private: | 225 | private: |
222 | // private helper methods | 226 | // private helper methods |
227 | |||
228 | void pasteHelper(bool is_primary); | ||
229 | |||
223 | void removeChar(); | 230 | void removeChar(); |
224 | void addChar(const llwchar c); | 231 | void addChar(const llwchar c); |
225 | void setCursorAtLocalPos(S32 local_mouse_x); | 232 | void setCursorAtLocalPos(S32 local_mouse_x); |
diff --git a/linden/indra/llui/llscrolllistctrl.cpp b/linden/indra/llui/llscrolllistctrl.cpp index 7b6c125..460b29f 100644 --- a/linden/indra/llui/llscrolllistctrl.cpp +++ b/linden/indra/llui/llscrolllistctrl.cpp | |||
@@ -743,6 +743,18 @@ std::vector<LLScrollListItem*> LLScrollListCtrl::getAllSelected() const | |||
743 | return ret; | 743 | return ret; |
744 | } | 744 | } |
745 | 745 | ||
746 | LLDynamicArray<LLUUID> LLScrollListCtrl::getSelectedIDs() | ||
747 | { | ||
748 | LLUUID selected_id; | ||
749 | LLDynamicArray<LLUUID> ids; | ||
750 | std::vector<LLScrollListItem*> selected = this->getAllSelected(); | ||
751 | for(std::vector<LLScrollListItem*>::iterator itr = selected.begin(); itr != selected.end(); ++itr) | ||
752 | { | ||
753 | ids.push_back((*itr)->getUUID()); | ||
754 | } | ||
755 | return ids; | ||
756 | } | ||
757 | |||
746 | S32 LLScrollListCtrl::getFirstSelectedIndex() const | 758 | S32 LLScrollListCtrl::getFirstSelectedIndex() const |
747 | { | 759 | { |
748 | S32 CurSelectedIndex = 0; | 760 | S32 CurSelectedIndex = 0; |
diff --git a/linden/indra/llui/llscrolllistctrl.h b/linden/indra/llui/llscrolllistctrl.h index 72d8894..516e4f1 100644 --- a/linden/indra/llui/llscrolllistctrl.h +++ b/linden/indra/llui/llscrolllistctrl.h | |||
@@ -458,6 +458,7 @@ public: | |||
458 | LLScrollListItem* getFirstSelected() const; | 458 | LLScrollListItem* getFirstSelected() const; |
459 | virtual S32 getFirstSelectedIndex() const; | 459 | virtual S32 getFirstSelectedIndex() const; |
460 | std::vector<LLScrollListItem*> getAllSelected() const; | 460 | std::vector<LLScrollListItem*> getAllSelected() const; |
461 | LLDynamicArray<LLUUID> getSelectedIDs(); | ||
461 | LLScrollListItem* getLastSelectedItem() const { return mLastSelected; } | 462 | LLScrollListItem* getLastSelectedItem() const { return mLastSelected; } |
462 | 463 | ||
463 | // iterate over all items | 464 | // iterate over all items |
diff --git a/linden/indra/llui/llspinctrl.cpp b/linden/indra/llui/llspinctrl.cpp index 1e973c0..2f531a2 100644 --- a/linden/indra/llui/llspinctrl.cpp +++ b/linden/indra/llui/llspinctrl.cpp | |||
@@ -469,6 +469,11 @@ BOOL LLSpinCtrl::handleKeyHere(KEY key, MASK mask) | |||
469 | LLSpinCtrl::onDownBtn(this); | 469 | LLSpinCtrl::onDownBtn(this); |
470 | return TRUE; | 470 | return TRUE; |
471 | } | 471 | } |
472 | if(key == KEY_RETURN) | ||
473 | { | ||
474 | forceEditorCommit(); | ||
475 | return TRUE; | ||
476 | } | ||
472 | } | 477 | } |
473 | return FALSE; | 478 | return FALSE; |
474 | } | 479 | } |
diff --git a/linden/indra/llui/lltexteditor.cpp b/linden/indra/llui/lltexteditor.cpp index ccdf44b..32106f1 100644 --- a/linden/indra/llui/lltexteditor.cpp +++ b/linden/indra/llui/lltexteditor.cpp | |||
@@ -1205,6 +1205,18 @@ BOOL LLTextEditor::handleMouseDown(S32 x, S32 y, MASK mask) | |||
1205 | } | 1205 | } |
1206 | 1206 | ||
1207 | 1207 | ||
1208 | BOOL LLTextEditor::handleMiddleMouseDown(S32 x, S32 y, MASK mask) | ||
1209 | { | ||
1210 | setFocus( TRUE ); | ||
1211 | if( canPastePrimary() ) | ||
1212 | { | ||
1213 | setCursorAtLocalPos( x, y, TRUE ); | ||
1214 | pastePrimary(); | ||
1215 | } | ||
1216 | return TRUE; | ||
1217 | } | ||
1218 | |||
1219 | |||
1208 | BOOL LLTextEditor::handleHover(S32 x, S32 y, MASK mask) | 1220 | BOOL LLTextEditor::handleHover(S32 x, S32 y, MASK mask) |
1209 | { | 1221 | { |
1210 | BOOL handled = FALSE; | 1222 | BOOL handled = FALSE; |
@@ -1327,6 +1339,9 @@ BOOL LLTextEditor::handleMouseUp(S32 x, S32 y, MASK mask) | |||
1327 | endSelection(); | 1339 | endSelection(); |
1328 | 1340 | ||
1329 | updateScrollFromCursor(); | 1341 | updateScrollFromCursor(); |
1342 | |||
1343 | // take selection to primary clipboard | ||
1344 | updatePrimary(); | ||
1330 | } | 1345 | } |
1331 | 1346 | ||
1332 | if( !hasSelection() ) | 1347 | if( !hasSelection() ) |
@@ -1334,6 +1349,9 @@ BOOL LLTextEditor::handleMouseUp(S32 x, S32 y, MASK mask) | |||
1334 | handleMouseUpOverSegment( x, y, mask ); | 1349 | handleMouseUpOverSegment( x, y, mask ); |
1335 | } | 1350 | } |
1336 | 1351 | ||
1352 | // take selection to 'primary' clipboard | ||
1353 | updatePrimary(); | ||
1354 | |||
1337 | handled = TRUE; | 1355 | handled = TRUE; |
1338 | } | 1356 | } |
1339 | 1357 | ||
@@ -1396,8 +1414,12 @@ BOOL LLTextEditor::handleDoubleClick(S32 x, S32 y, MASK mask) | |||
1396 | // delay cursor flashing | 1414 | // delay cursor flashing |
1397 | resetKeystrokeTimer(); | 1415 | resetKeystrokeTimer(); |
1398 | 1416 | ||
1417 | // take selection to 'primary' clipboard | ||
1418 | updatePrimary(); | ||
1419 | |||
1399 | handled = TRUE; | 1420 | handled = TRUE; |
1400 | } | 1421 | } |
1422 | |||
1401 | return handled; | 1423 | return handled; |
1402 | } | 1424 | } |
1403 | 1425 | ||
@@ -1693,6 +1715,12 @@ BOOL LLTextEditor::handleSelectionKey(const KEY key, const MASK mask) | |||
1693 | } | 1715 | } |
1694 | } | 1716 | } |
1695 | 1717 | ||
1718 | if( handled ) | ||
1719 | { | ||
1720 | // take selection to 'primary' clipboard | ||
1721 | updatePrimary(); | ||
1722 | } | ||
1723 | |||
1696 | return handled; | 1724 | return handled; |
1697 | } | 1725 | } |
1698 | 1726 | ||
@@ -1872,22 +1900,46 @@ BOOL LLTextEditor::canPaste() const | |||
1872 | return !mReadOnly && gClipboard.canPasteString(); | 1900 | return !mReadOnly && gClipboard.canPasteString(); |
1873 | } | 1901 | } |
1874 | 1902 | ||
1875 | |||
1876 | // paste from clipboard | 1903 | // paste from clipboard |
1877 | void LLTextEditor::paste() | 1904 | void LLTextEditor::paste() |
1878 | { | 1905 | { |
1879 | if (!canPaste()) | 1906 | bool is_primary = false; |
1907 | pasteHelper(is_primary); | ||
1908 | } | ||
1909 | |||
1910 | // paste from primary | ||
1911 | void LLTextEditor::pastePrimary() | ||
1912 | { | ||
1913 | bool is_primary = true; | ||
1914 | pasteHelper(is_primary); | ||
1915 | } | ||
1916 | |||
1917 | // paste from primary (itsprimary==true) or clipboard (itsprimary==false) | ||
1918 | void LLTextEditor::pasteHelper(bool is_primary) | ||
1919 | { | ||
1920 | bool can_paste_it; | ||
1921 | if (is_primary) | ||
1922 | can_paste_it = canPastePrimary(); | ||
1923 | else | ||
1924 | can_paste_it = canPaste(); | ||
1925 | |||
1926 | if (!can_paste_it) | ||
1880 | { | 1927 | { |
1881 | return; | 1928 | return; |
1882 | } | 1929 | } |
1883 | LLUUID source_id; | 1930 | LLUUID source_id; |
1884 | LLWString paste = gClipboard.getPasteWString(&source_id); | 1931 | LLWString paste; |
1932 | if (is_primary) | ||
1933 | paste = gClipboard.getPastePrimaryWString(&source_id); | ||
1934 | else | ||
1935 | paste = gClipboard.getPasteWString(&source_id); | ||
1936 | |||
1885 | if (paste.empty()) | 1937 | if (paste.empty()) |
1886 | { | 1938 | { |
1887 | return; | 1939 | return; |
1888 | } | 1940 | } |
1889 | // Delete any selected characters (the paste replaces them) | 1941 | // Delete any selected characters (the paste replaces them) |
1890 | if( hasSelection() ) | 1942 | if( (!is_primary) && hasSelection() ) |
1891 | { | 1943 | { |
1892 | deleteSelection(TRUE); | 1944 | deleteSelection(TRUE); |
1893 | } | 1945 | } |
@@ -1921,6 +1973,32 @@ void LLTextEditor::paste() | |||
1921 | } | 1973 | } |
1922 | 1974 | ||
1923 | 1975 | ||
1976 | |||
1977 | // copy selection to primary | ||
1978 | void LLTextEditor::copyPrimary() | ||
1979 | { | ||
1980 | if( !canCopy() ) | ||
1981 | { | ||
1982 | return; | ||
1983 | } | ||
1984 | S32 left_pos = llmin( mSelectionStart, mSelectionEnd ); | ||
1985 | S32 length = abs( mSelectionStart - mSelectionEnd ); | ||
1986 | gClipboard.copyFromPrimarySubstring(mWText, left_pos, length, mSourceID); | ||
1987 | } | ||
1988 | |||
1989 | BOOL LLTextEditor::canPastePrimary() const | ||
1990 | { | ||
1991 | return !mReadOnly && gClipboard.canPastePrimaryString(); | ||
1992 | } | ||
1993 | |||
1994 | void LLTextEditor::updatePrimary() | ||
1995 | { | ||
1996 | if (canCopy()) | ||
1997 | { | ||
1998 | copyPrimary(); | ||
1999 | } | ||
2000 | } | ||
2001 | |||
1924 | BOOL LLTextEditor::handleControlKey(const KEY key, const MASK mask) | 2002 | BOOL LLTextEditor::handleControlKey(const KEY key, const MASK mask) |
1925 | { | 2003 | { |
1926 | BOOL handled = FALSE; | 2004 | BOOL handled = FALSE; |
@@ -1996,6 +2074,11 @@ BOOL LLTextEditor::handleControlKey(const KEY key, const MASK mask) | |||
1996 | } | 2074 | } |
1997 | } | 2075 | } |
1998 | 2076 | ||
2077 | if (handled) | ||
2078 | { | ||
2079 | updatePrimary(); | ||
2080 | } | ||
2081 | |||
1999 | return handled; | 2082 | return handled; |
2000 | } | 2083 | } |
2001 | 2084 | ||
@@ -3537,9 +3620,9 @@ void LLTextEditor::appendColoredText(const std::string &new_text, | |||
3537 | } | 3620 | } |
3538 | 3621 | ||
3539 | void LLTextEditor::appendStyledText(const std::string &new_text, | 3622 | void LLTextEditor::appendStyledText(const std::string &new_text, |
3540 | bool allow_undo, | 3623 | bool allow_undo, |
3541 | bool prepend_newline, | 3624 | bool prepend_newline, |
3542 | LLStyleSP stylep) | 3625 | const LLStyleSP stylep) |
3543 | { | 3626 | { |
3544 | S32 part = (S32)LLTextParser::WHOLE; | 3627 | S32 part = (S32)LLTextParser::WHOLE; |
3545 | if(mParseHTML) | 3628 | if(mParseHTML) |
@@ -3576,7 +3659,7 @@ void LLTextEditor::appendStyledText(const std::string &new_text, | |||
3576 | 3659 | ||
3577 | html->setLinkHREF(text.substr(start,end-start)); | 3660 | html->setLinkHREF(text.substr(start,end-start)); |
3578 | appendText(text.substr(start, end-start),allow_undo, prepend_newline, html); | 3661 | appendText(text.substr(start, end-start),allow_undo, prepend_newline, html); |
3579 | if (end < (S32)text.length()) | 3662 | if (end < (S32)text.length()) |
3580 | { | 3663 | { |
3581 | text = text.substr(end,text.length() - end); | 3664 | text = text.substr(end,text.length() - end); |
3582 | end=0; | 3665 | end=0; |
diff --git a/linden/indra/llui/lltexteditor.h b/linden/indra/llui/lltexteditor.h index 12195f2..a62f01d 100644 --- a/linden/indra/llui/lltexteditor.h +++ b/linden/indra/llui/lltexteditor.h | |||
@@ -84,6 +84,8 @@ public: | |||
84 | virtual BOOL handleHover(S32 x, S32 y, MASK mask); | 84 | virtual BOOL handleHover(S32 x, S32 y, MASK mask); |
85 | virtual BOOL handleScrollWheel(S32 x, S32 y, S32 clicks); | 85 | virtual BOOL handleScrollWheel(S32 x, S32 y, S32 clicks); |
86 | virtual BOOL handleDoubleClick(S32 x, S32 y, MASK mask ); | 86 | virtual BOOL handleDoubleClick(S32 x, S32 y, MASK mask ); |
87 | virtual BOOL handleMiddleMouseDown(S32 x,S32 y,MASK mask); | ||
88 | |||
87 | virtual BOOL handleKeyHere(KEY key, MASK mask ); | 89 | virtual BOOL handleKeyHere(KEY key, MASK mask ); |
88 | virtual BOOL handleUnicodeCharHere(llwchar uni_char); | 90 | virtual BOOL handleUnicodeCharHere(llwchar uni_char); |
89 | 91 | ||
@@ -119,6 +121,10 @@ public: | |||
119 | virtual BOOL canCopy() const; | 121 | virtual BOOL canCopy() const; |
120 | virtual void paste(); | 122 | virtual void paste(); |
121 | virtual BOOL canPaste() const; | 123 | virtual BOOL canPaste() const; |
124 | virtual void updatePrimary(); | ||
125 | virtual void copyPrimary(); | ||
126 | virtual void pastePrimary(); | ||
127 | virtual BOOL canPastePrimary() const; | ||
122 | virtual void doDelete(); | 128 | virtual void doDelete(); |
123 | virtual BOOL canDoDelete() const; | 129 | virtual BOOL canDoDelete() const; |
124 | virtual void selectAll(); | 130 | virtual void selectAll(); |
@@ -144,12 +150,12 @@ public: | |||
144 | void appendText(const std::string &wtext, bool allow_undo, bool prepend_newline, | 150 | void appendText(const std::string &wtext, bool allow_undo, bool prepend_newline, |
145 | const LLStyleSP stylep = NULL); | 151 | const LLStyleSP stylep = NULL); |
146 | 152 | ||
147 | void appendColoredText(const std::string &wtext, bool allow_undo, | 153 | void appendColoredText(const std::string &wtext, bool allow_undo, |
148 | bool prepend_newline, | 154 | bool prepend_newline, |
149 | const LLColor4 &color, | 155 | const LLColor4 &color, |
150 | const std::string& font_name = LLStringUtil::null); | 156 | const std::string& font_name = LLStringUtil::null); |
151 | // if styled text starts a line, you need to prepend a newline. | 157 | // if styled text starts a line, you need to prepend a newline. |
152 | void appendStyledText(const std::string &new_text, bool allow_undo, | 158 | void appendStyledText(const std::string &new_text, bool allow_undo, |
153 | bool prepend_newline, | 159 | bool prepend_newline, |
154 | LLStyleSP stylep = NULL); | 160 | LLStyleSP stylep = NULL); |
155 | void appendHighlightedText(const std::string &new_text, bool allow_undo, | 161 | void appendHighlightedText(const std::string &new_text, bool allow_undo, |
@@ -431,6 +437,8 @@ private: | |||
431 | // | 437 | // |
432 | // Methods | 438 | // Methods |
433 | // | 439 | // |
440 | void pasteHelper(bool is_primary); | ||
441 | |||
434 | void updateSegments(); | 442 | void updateSegments(); |
435 | void pruneSegments(); | 443 | void pruneSegments(); |
436 | 444 | ||
diff --git a/linden/indra/llui/llview.cpp b/linden/indra/llui/llview.cpp index 7047afc..36bc850 100644 --- a/linden/indra/llui/llview.cpp +++ b/linden/indra/llui/llview.cpp | |||
@@ -984,6 +984,30 @@ BOOL LLView::handleRightMouseUp(S32 x, S32 y, MASK mask) | |||
984 | } | 984 | } |
985 | return handled; | 985 | return handled; |
986 | } | 986 | } |
987 | |||
988 | BOOL LLView::handleMiddleMouseDown(S32 x, S32 y, MASK mask) | ||
989 | { | ||
990 | LLView* handled_view = childrenHandleMiddleMouseDown( x, y, mask ); | ||
991 | BOOL handled = (handled_view != NULL); | ||
992 | if( !handled && blockMouseEvent(x, y) ) | ||
993 | { | ||
994 | handled = TRUE; | ||
995 | handled_view = this; | ||
996 | } | ||
997 | |||
998 | return handled; | ||
999 | } | ||
1000 | |||
1001 | BOOL LLView::handleMiddleMouseUp(S32 x, S32 y, MASK mask) | ||
1002 | { | ||
1003 | BOOL handled = childrenHandleMiddleMouseUp( x, y, mask ) != NULL; | ||
1004 | if( !handled && blockMouseEvent(x, y) ) | ||
1005 | { | ||
1006 | handled = TRUE; | ||
1007 | } | ||
1008 | return handled; | ||
1009 | } | ||
1010 | |||
987 | 1011 | ||
988 | LLView* LLView::childrenHandleScrollWheel(S32 x, S32 y, S32 clicks) | 1012 | LLView* LLView::childrenHandleScrollWheel(S32 x, S32 y, S32 clicks) |
989 | { | 1013 | { |
@@ -1145,6 +1169,34 @@ LLView* LLView::childrenHandleRightMouseDown(S32 x, S32 y, MASK mask) | |||
1145 | return handled_view; | 1169 | return handled_view; |
1146 | } | 1170 | } |
1147 | 1171 | ||
1172 | LLView* LLView::childrenHandleMiddleMouseDown(S32 x, S32 y, MASK mask) | ||
1173 | { | ||
1174 | LLView* handled_view = NULL; | ||
1175 | |||
1176 | if (getVisible() && getEnabled() ) | ||
1177 | { | ||
1178 | for ( child_list_iter_t child_it = mChildList.begin(); child_it != mChildList.end(); ++child_it) | ||
1179 | { | ||
1180 | LLView* viewp = *child_it; | ||
1181 | S32 local_x = x - viewp->getRect().mLeft; | ||
1182 | S32 local_y = y - viewp->getRect().mBottom; | ||
1183 | if (viewp->pointInView(local_x, local_y) && | ||
1184 | viewp->getVisible() && | ||
1185 | viewp->getEnabled() && | ||
1186 | viewp->handleMiddleMouseDown( local_x, local_y, mask )) | ||
1187 | { | ||
1188 | if (sDebugMouseHandling) | ||
1189 | { | ||
1190 | sMouseHandlerMessage = std::string("->") + viewp->mName + sMouseHandlerMessage; | ||
1191 | } | ||
1192 | handled_view = viewp; | ||
1193 | break; | ||
1194 | } | ||
1195 | } | ||
1196 | } | ||
1197 | return handled_view; | ||
1198 | } | ||
1199 | |||
1148 | LLView* LLView::childrenHandleDoubleClick(S32 x, S32 y, MASK mask) | 1200 | LLView* LLView::childrenHandleDoubleClick(S32 x, S32 y, MASK mask) |
1149 | { | 1201 | { |
1150 | LLView* handled_view = NULL; | 1202 | LLView* handled_view = NULL; |
@@ -1230,6 +1282,32 @@ LLView* LLView::childrenHandleRightMouseUp(S32 x, S32 y, MASK mask) | |||
1230 | return handled_view; | 1282 | return handled_view; |
1231 | } | 1283 | } |
1232 | 1284 | ||
1285 | LLView* LLView::childrenHandleMiddleMouseUp(S32 x, S32 y, MASK mask) | ||
1286 | { | ||
1287 | LLView* handled_view = NULL; | ||
1288 | if( getVisible() && getEnabled() ) | ||
1289 | { | ||
1290 | for ( child_list_iter_t child_it = mChildList.begin(); child_it != mChildList.end(); ++child_it) | ||
1291 | { | ||
1292 | LLView* viewp = *child_it; | ||
1293 | S32 local_x = x - viewp->getRect().mLeft; | ||
1294 | S32 local_y = y - viewp->getRect().mBottom; | ||
1295 | if (viewp->pointInView(local_x, local_y) && | ||
1296 | viewp->getVisible() && | ||
1297 | viewp->getEnabled() && | ||
1298 | viewp->handleMiddleMouseUp( local_x, local_y, mask )) | ||
1299 | { | ||
1300 | if (sDebugMouseHandling) | ||
1301 | { | ||
1302 | sMouseHandlerMessage = std::string("->") + viewp->mName + sMouseHandlerMessage; | ||
1303 | } | ||
1304 | handled_view = viewp; | ||
1305 | break; | ||
1306 | } | ||
1307 | } | ||
1308 | } | ||
1309 | return handled_view; | ||
1310 | } | ||
1233 | 1311 | ||
1234 | void LLView::draw() | 1312 | void LLView::draw() |
1235 | { | 1313 | { |
@@ -2555,7 +2633,7 @@ void LLView::initFromXML(LLXMLNodePtr node, LLView* parent) | |||
2555 | node->getAttributeString("hover_cursor", cursor_string); | 2633 | node->getAttributeString("hover_cursor", cursor_string); |
2556 | mHoverCursor = getCursorFromString(cursor_string); | 2634 | mHoverCursor = getCursorFromString(cursor_string); |
2557 | } | 2635 | } |
2558 | 2636 | ||
2559 | node->getAttributeBOOL("use_bounding_rect", mUseBoundingRect); | 2637 | node->getAttributeBOOL("use_bounding_rect", mUseBoundingRect); |
2560 | node->getAttributeBOOL("mouse_opaque", mMouseOpaque); | 2638 | node->getAttributeBOOL("mouse_opaque", mMouseOpaque); |
2561 | 2639 | ||
diff --git a/linden/indra/llui/llview.h b/linden/indra/llui/llview.h index b5a34bd..539adea 100644 --- a/linden/indra/llui/llview.h +++ b/linden/indra/llui/llview.h | |||
@@ -465,6 +465,8 @@ public: | |||
465 | /*virtual*/ BOOL handleHover(S32 x, S32 y, MASK mask); | 465 | /*virtual*/ BOOL handleHover(S32 x, S32 y, MASK mask); |
466 | /*virtual*/ BOOL handleMouseUp(S32 x, S32 y, MASK mask); | 466 | /*virtual*/ BOOL handleMouseUp(S32 x, S32 y, MASK mask); |
467 | /*virtual*/ BOOL handleMouseDown(S32 x, S32 y, MASK mask); | 467 | /*virtual*/ BOOL handleMouseDown(S32 x, S32 y, MASK mask); |
468 | /*virtual*/ BOOL handleMiddleMouseUp(S32 x, S32 y, MASK mask); | ||
469 | /*virtual*/ BOOL handleMiddleMouseDown(S32 x, S32 y, MASK mask); | ||
468 | /*virtual*/ BOOL handleDoubleClick(S32 x, S32 y, MASK mask); | 470 | /*virtual*/ BOOL handleDoubleClick(S32 x, S32 y, MASK mask); |
469 | /*virtual*/ BOOL handleScrollWheel(S32 x, S32 y, S32 clicks); | 471 | /*virtual*/ BOOL handleScrollWheel(S32 x, S32 y, S32 clicks); |
470 | /*virtual*/ BOOL handleRightMouseDown(S32 x, S32 y, MASK mask); | 472 | /*virtual*/ BOOL handleRightMouseDown(S32 x, S32 y, MASK mask); |
@@ -603,6 +605,8 @@ protected: | |||
603 | LLView* childrenHandleHover(S32 x, S32 y, MASK mask); | 605 | LLView* childrenHandleHover(S32 x, S32 y, MASK mask); |
604 | LLView* childrenHandleMouseUp(S32 x, S32 y, MASK mask); | 606 | LLView* childrenHandleMouseUp(S32 x, S32 y, MASK mask); |
605 | LLView* childrenHandleMouseDown(S32 x, S32 y, MASK mask); | 607 | LLView* childrenHandleMouseDown(S32 x, S32 y, MASK mask); |
608 | LLView* childrenHandleMiddleMouseUp(S32 x, S32 y, MASK mask); | ||
609 | LLView* childrenHandleMiddleMouseDown(S32 x, S32 y, MASK mask); | ||
606 | LLView* childrenHandleDoubleClick(S32 x, S32 y, MASK mask); | 610 | LLView* childrenHandleDoubleClick(S32 x, S32 y, MASK mask); |
607 | LLView* childrenHandleScrollWheel(S32 x, S32 y, S32 clicks); | 611 | LLView* childrenHandleScrollWheel(S32 x, S32 y, S32 clicks); |
608 | LLView* childrenHandleRightMouseDown(S32 x, S32 y, MASK mask); | 612 | LLView* childrenHandleRightMouseDown(S32 x, S32 y, MASK mask); |
@@ -658,7 +662,7 @@ private: | |||
658 | boost::signals::connection mControlConnection; | 662 | boost::signals::connection mControlConnection; |
659 | 663 | ||
660 | ECursorType mHoverCursor; | 664 | ECursorType mHoverCursor; |
661 | 665 | ||
662 | public: | 666 | public: |
663 | static BOOL sDebugRects; // Draw debug rects behind everything. | 667 | static BOOL sDebugRects; // Draw debug rects behind everything. |
664 | static BOOL sDebugKeys; | 668 | static BOOL sDebugKeys; |