aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/linden/indra/llui
diff options
context:
space:
mode:
Diffstat (limited to 'linden/indra/llui')
-rw-r--r--linden/indra/llui/llbutton.cpp12
-rw-r--r--linden/indra/llui/llbutton.h4
-rw-r--r--linden/indra/llui/llcheckboxctrl.cpp21
-rw-r--r--linden/indra/llui/llcheckboxctrl.h6
-rw-r--r--linden/indra/llui/llcombobox.cpp21
-rw-r--r--linden/indra/llui/llcombobox.h4
-rw-r--r--linden/indra/llui/llctrlselectioninterface.h2
-rw-r--r--linden/indra/llui/llfloater.cpp9
-rw-r--r--linden/indra/llui/lllineeditor.cpp56
-rw-r--r--linden/indra/llui/lllineeditor.h5
-rw-r--r--linden/indra/llui/llradiogroup.h2
-rw-r--r--linden/indra/llui/llscrolllistctrl.cpp31
-rw-r--r--linden/indra/llui/llscrolllistctrl.h8
-rw-r--r--linden/indra/llui/lltexteditor.cpp26
-rw-r--r--linden/indra/llui/lltexteditor.h1
-rw-r--r--linden/indra/llui/lluictrl.h4
16 files changed, 175 insertions, 37 deletions
diff --git a/linden/indra/llui/llbutton.cpp b/linden/indra/llui/llbutton.cpp
index aa50a6e..6ed6885 100644
--- a/linden/indra/llui/llbutton.cpp
+++ b/linden/indra/llui/llbutton.cpp
@@ -89,8 +89,7 @@ LLButton::LLButton( const LLString& name, const LLRect& rect, const LLString& co
89 mCurGlowStrength(0.f), 89 mCurGlowStrength(0.f),
90 mNeedsHighlight(FALSE), 90 mNeedsHighlight(FALSE),
91 mCommitOnReturn(TRUE), 91 mCommitOnReturn(TRUE),
92 mImagep( NULL ), 92 mImagep( NULL )
93 mIsDirty( FALSE )
94{ 93{
95 mUnselectedLabel = name; 94 mUnselectedLabel = name;
96 mSelectedLabel = name; 95 mSelectedLabel = name;
@@ -275,8 +274,6 @@ void LLButton::onCommit()
275 { 274 {
276 (*mClickedCallback)( mCallbackUserData ); 275 (*mClickedCallback)( mCallbackUserData );
277 } 276 }
278
279 mIsDirty = TRUE;
280} 277}
281 278
282 279
@@ -291,7 +288,6 @@ BOOL LLButton::handleUnicodeCharHere(llwchar uni_char, BOOL called_from_parent)
291 (*mClickedCallback)( mCallbackUserData ); 288 (*mClickedCallback)( mCallbackUserData );
292 } 289 }
293 handled = TRUE; 290 handled = TRUE;
294 mIsDirty = TRUE;
295 } 291 }
296 return handled; 292 return handled;
297} 293}
@@ -308,7 +304,6 @@ BOOL LLButton::handleKeyHere(KEY key, MASK mask, BOOL called_from_parent )
308 (*mClickedCallback)( mCallbackUserData ); 304 (*mClickedCallback)( mCallbackUserData );
309 } 305 }
310 handled = TRUE; 306 handled = TRUE;
311 mIsDirty = TRUE;
312 } 307 }
313 } 308 }
314 return handled; 309 return handled;
@@ -368,9 +363,7 @@ BOOL LLButton::handleMouseUp(S32 x, S32 y, MASK mask)
368 if (mClickedCallback) 363 if (mClickedCallback)
369 { 364 {
370 (*mClickedCallback)( mCallbackUserData ); 365 (*mClickedCallback)( mCallbackUserData );
371 } 366 }
372
373 mIsDirty = TRUE;
374 } 367 }
375 368
376 mMouseDownTimer.stop(); 369 mMouseDownTimer.stop();
@@ -773,7 +766,6 @@ void LLButton::setToggleState(BOOL b)
773void LLButton::setValue(const LLSD& value ) 766void LLButton::setValue(const LLSD& value )
774{ 767{
775 mToggleState = value.asBoolean(); 768 mToggleState = value.asBoolean();
776 mIsDirty = FALSE;
777} 769}
778 770
779LLSD LLButton::getValue() const 771LLSD LLButton::getValue() const
diff --git a/linden/indra/llui/llbutton.h b/linden/indra/llui/llbutton.h
index aedc411..d26011b 100644
--- a/linden/indra/llui/llbutton.h
+++ b/linden/indra/llui/llbutton.h
@@ -100,8 +100,6 @@ public:
100 // HACK: "committing" a button is the same as clicking on it. 100 // HACK: "committing" a button is the same as clicking on it.
101 virtual void onCommit(); 101 virtual void onCommit();
102 102
103 virtual BOOL isDirty() { return mIsDirty; }; // Returns TRUE if the user has clicked on the button at all
104
105 void setUnselectedLabelColor( const LLColor4& c ) { mUnselectedLabelColor = c; } 103 void setUnselectedLabelColor( const LLColor4& c ) { mUnselectedLabelColor = c; }
106 void setSelectedLabelColor( const LLColor4& c ) { mSelectedLabelColor = c; } 104 void setSelectedLabelColor( const LLColor4& c ) { mSelectedLabelColor = c; }
107 105
@@ -279,8 +277,6 @@ protected:
279 277
280 LLPointer<LLImageGL> mImagep; 278 LLPointer<LLImageGL> mImagep;
281 279
282 BOOL mIsDirty;
283
284 static LLFrameTimer sFlashingTimer; 280 static LLFrameTimer sFlashingTimer;
285}; 281};
286 282
diff --git a/linden/indra/llui/llcheckboxctrl.cpp b/linden/indra/llui/llcheckboxctrl.cpp
index 24cf680..f49e220 100644
--- a/linden/indra/llui/llcheckboxctrl.cpp
+++ b/linden/indra/llui/llcheckboxctrl.cpp
@@ -59,7 +59,8 @@ LLCheckBoxCtrl::LLCheckBoxCtrl(const LLString& name, const LLRect& rect,
59 mTextEnabledColor( LLUI::sColorsGroup->getColor( "LabelTextColor" ) ), 59 mTextEnabledColor( LLUI::sColorsGroup->getColor( "LabelTextColor" ) ),
60 mTextDisabledColor( LLUI::sColorsGroup->getColor( "LabelDisabledColor" ) ), 60 mTextDisabledColor( LLUI::sColorsGroup->getColor( "LabelDisabledColor" ) ),
61 mRadioStyle( use_radio_style ), 61 mRadioStyle( use_radio_style ),
62 mInitialValue( initial_value ) 62 mInitialValue( initial_value ),
63 mSetValue( initial_value )
63{ 64{
64 if (font) 65 if (font)
65 { 66 {
@@ -228,7 +229,8 @@ void LLCheckBoxCtrl::draw()
228//virtual 229//virtual
229void LLCheckBoxCtrl::setValue(const LLSD& value ) 230void LLCheckBoxCtrl::setValue(const LLSD& value )
230{ 231{
231 mButton->setToggleState( value.asBoolean() ); 232 mSetValue = value.asBoolean();
233 mButton->setToggleState( mSetValue );
232} 234}
233 235
234//virtual 236//virtual
@@ -269,16 +271,27 @@ void LLCheckBoxCtrl::setControlName(const LLString& control_name, LLView* contex
269 271
270 272
271// virtual Returns TRUE if the user has modified this control. 273// virtual Returns TRUE if the user has modified this control.
272BOOL LLCheckBoxCtrl::isDirty() 274BOOL LLCheckBoxCtrl::isDirty() const
273{ 275{
274 if ( mButton ) 276 if ( mButton )
275 { 277 {
276 return mButton->isDirty(); 278 return (mSetValue != mButton->getToggleState());
277 } 279 }
278 return FALSE; // Shouldn't get here 280 return FALSE; // Shouldn't get here
279} 281}
280 282
281 283
284// virtual Clear dirty state
285void LLCheckBoxCtrl::resetDirty()
286{
287 if ( mButton )
288 {
289 mSetValue = mButton->getToggleState();
290 }
291}
292
293
294
282// virtual 295// virtual
283LLXMLNodePtr LLCheckBoxCtrl::getXML(bool save_children) const 296LLXMLNodePtr LLCheckBoxCtrl::getXML(bool save_children) const
284{ 297{
diff --git a/linden/indra/llui/llcheckboxctrl.h b/linden/indra/llui/llcheckboxctrl.h
index 37b1330..6aa7113 100644
--- a/linden/indra/llui/llcheckboxctrl.h
+++ b/linden/indra/llui/llcheckboxctrl.h
@@ -110,7 +110,8 @@ public:
110 110
111 static void onButtonPress(void *userdata); 111 static void onButtonPress(void *userdata);
112 112
113 virtual BOOL isDirty(); // Returns TRUE if the user has modified this control. 113 virtual BOOL isDirty() const; // Returns TRUE if the user has modified this control.
114 virtual void resetDirty(); // Clear dirty state
114 115
115protected: 116protected:
116 // note: value is stored in toggle state of button 117 // note: value is stored in toggle state of button
@@ -120,7 +121,8 @@ protected:
120 LLColor4 mTextEnabledColor; 121 LLColor4 mTextEnabledColor;
121 LLColor4 mTextDisabledColor; 122 LLColor4 mTextDisabledColor;
122 BOOL mRadioStyle; 123 BOOL mRadioStyle;
123 BOOL mInitialValue; 124 BOOL mInitialValue; // Value set in constructor
125 BOOL mSetValue; // Value set programmatically
124 BOOL mKeyboardFocusOnClick; 126 BOOL mKeyboardFocusOnClick;
125 LLViewBorder* mBorder; 127 LLViewBorder* mBorder;
126}; 128};
diff --git a/linden/indra/llui/llcombobox.cpp b/linden/indra/llui/llcombobox.cpp
index 27df619..b71d88f 100644
--- a/linden/indra/llui/llcombobox.cpp
+++ b/linden/indra/llui/llcombobox.cpp
@@ -247,6 +247,27 @@ void LLComboBox::onCommit()
247 LLUICtrl::onCommit(); 247 LLUICtrl::onCommit();
248} 248}
249 249
250// virtual
251BOOL LLComboBox::isDirty() const
252{
253 BOOL grubby = FALSE;
254 if ( mList )
255 {
256 grubby = mList->isDirty();
257 }
258 return grubby;
259}
260
261// virtual Clear dirty state
262void LLComboBox::resetDirty()
263{
264 if ( mList )
265 {
266 mList->resetDirty();
267 }
268}
269
270
250// add item "name" to menu 271// add item "name" to menu
251void LLComboBox::add(const LLString& name, EAddPosition pos, BOOL enabled) 272void LLComboBox::add(const LLString& name, EAddPosition pos, BOOL enabled)
252{ 273{
diff --git a/linden/indra/llui/llcombobox.h b/linden/indra/llui/llcombobox.h
index d77224a..1589c30 100644
--- a/linden/indra/llui/llcombobox.h
+++ b/linden/indra/llui/llcombobox.h
@@ -88,6 +88,8 @@ public:
88 virtual void clear(); // select nothing 88 virtual void clear(); // select nothing
89 virtual void onCommit(); 89 virtual void onCommit();
90 virtual BOOL acceptsTextInput() const { return mAllowTextEntry; } 90 virtual BOOL acceptsTextInput() const { return mAllowTextEntry; }
91 virtual BOOL isDirty() const; // Returns TRUE if the user has modified this control.
92 virtual void resetDirty(); // Clear dirty state
91 93
92 virtual void setFocus(BOOL b); 94 virtual void setFocus(BOOL b);
93 95
@@ -147,7 +149,7 @@ public:
147 virtual BOOL getCanSelect() const { return TRUE; } 149 virtual BOOL getCanSelect() const { return TRUE; }
148 virtual BOOL selectFirstItem() { return setCurrentByIndex(0); } 150 virtual BOOL selectFirstItem() { return setCurrentByIndex(0); }
149 virtual BOOL selectNthItem( S32 index ) { return setCurrentByIndex(index); } 151 virtual BOOL selectNthItem( S32 index ) { return setCurrentByIndex(index); }
150 virtual S32 getFirstSelectedIndex() { return getCurrentIndex(); } 152 virtual S32 getFirstSelectedIndex() const { return getCurrentIndex(); }
151 virtual BOOL setCurrentByID( const LLUUID& id ); 153 virtual BOOL setCurrentByID( const LLUUID& id );
152 virtual LLUUID getCurrentID(); // LLUUID::null if no items in menu 154 virtual LLUUID getCurrentID(); // LLUUID::null if no items in menu
153 virtual BOOL setSelectedByValue(LLSD value, BOOL selected); 155 virtual BOOL setSelectedByValue(LLSD value, BOOL selected);
diff --git a/linden/indra/llui/llctrlselectioninterface.h b/linden/indra/llui/llctrlselectioninterface.h
index e21f039..237aa94 100644
--- a/linden/indra/llui/llctrlselectioninterface.h
+++ b/linden/indra/llui/llctrlselectioninterface.h
@@ -56,7 +56,7 @@ public:
56 virtual BOOL selectFirstItem() = 0; 56 virtual BOOL selectFirstItem() = 0;
57 virtual BOOL selectNthItem( S32 index ) = 0; 57 virtual BOOL selectNthItem( S32 index ) = 0;
58 58
59 virtual S32 getFirstSelectedIndex() = 0; 59 virtual S32 getFirstSelectedIndex() const = 0;
60 60
61 // TomY TODO: Simply cast the UUIDs to LLSDs, using the selectByValue function 61 // TomY TODO: Simply cast the UUIDs to LLSDs, using the selectByValue function
62 virtual BOOL setCurrentByID( const LLUUID& id ) = 0; 62 virtual BOOL setCurrentByID( const LLUUID& id ) = 0;
diff --git a/linden/indra/llui/llfloater.cpp b/linden/indra/llui/llfloater.cpp
index b45661f..77fddfb 100644
--- a/linden/indra/llui/llfloater.cpp
+++ b/linden/indra/llui/llfloater.cpp
@@ -1252,10 +1252,13 @@ BOOL LLFloater::getEditModeEnabled()
1252//static 1252//static
1253void LLFloater::show(LLFloater* floaterp) 1253void LLFloater::show(LLFloater* floaterp)
1254{ 1254{
1255 if (floaterp) floaterp->open(); 1255 if (floaterp)
1256 if (floaterp->getHost())
1257 { 1256 {
1258 floaterp->getHost()->open(); 1257 floaterp->open();
1258 if (floaterp->getHost())
1259 {
1260 floaterp->getHost()->open();
1261 }
1259 } 1262 }
1260} 1263}
1261 1264
diff --git a/linden/indra/llui/lllineeditor.cpp b/linden/indra/llui/lllineeditor.cpp
index 98286fa..dca62d7 100644
--- a/linden/indra/llui/lllineeditor.cpp
+++ b/linden/indra/llui/lllineeditor.cpp
@@ -138,6 +138,8 @@ LLLineEditor::LLLineEditor(const LLString& name, const LLRect& rect,
138 mSelectionEnd( 0 ), 138 mSelectionEnd( 0 ),
139 mLastSelectionX(-1), 139 mLastSelectionX(-1),
140 mLastSelectionY(-1), 140 mLastSelectionY(-1),
141 mLastSelectionStart(-1),
142 mLastSelectionEnd(-1),
141 mPrevalidateFunc( prevalidate_func ), 143 mPrevalidateFunc( prevalidate_func ),
142 mCursorColor( LLUI::sColorsGroup->getColor( "TextCursorColor" ) ), 144 mCursorColor( LLUI::sColorsGroup->getColor( "TextCursorColor" ) ),
143 mFgColor( LLUI::sColorsGroup->getColor( "TextFgColor" ) ), 145 mFgColor( LLUI::sColorsGroup->getColor( "TextFgColor" ) ),
@@ -247,6 +249,19 @@ void LLLineEditor::onCommit()
247 selectAll(); 249 selectAll();
248} 250}
249 251
252// virtual
253BOOL LLLineEditor::isDirty() const
254{
255 return ( mText.getString() != mPrevText );
256}
257
258// virtual
259void LLLineEditor::resetDirty()
260{
261 mPrevText = mText.getString();
262}
263
264
250// line history support 265// line history support
251void LLLineEditor::updateHistory() 266void LLLineEditor::updateHistory()
252{ 267{
@@ -468,8 +483,38 @@ BOOL LLLineEditor::handleDoubleClick(S32 x, S32 y, MASK mask)
468 } 483 }
469 else 484 else
470 { 485 {
471 // otherwise select everything 486 const LLWString& wtext = mText.getWString();
472 selectAll(); 487
488 BOOL doSelectAll = TRUE;
489
490 // Select the word we're on
491 if( isPartOfWord( wtext[mCursorPos] ) )
492 {
493 S32 old_selection_start = mLastSelectionStart;
494 S32 old_selection_end = mLastSelectionEnd;
495
496 // Select word the cursor is over
497 while ((mCursorPos > 0) && isPartOfWord( wtext[mCursorPos-1] ))
498 { // Find the start of the word
499 mCursorPos--;
500 }
501 startSelection();
502
503 while ((mCursorPos < (S32)wtext.length()) && isPartOfWord( wtext[mCursorPos] ) )
504 { // Find the end of the word
505 mCursorPos++;
506 }
507 mSelectionEnd = mCursorPos;
508
509 // If nothing changed, then the word was already selected. Select the whole line.
510 doSelectAll = (old_selection_start == mSelectionStart) &&
511 (old_selection_end == mSelectionEnd);
512 }
513
514 if ( doSelectAll )
515 { // Select everything
516 selectAll();
517 }
473 } 518 }
474 519
475 // We don't want handleMouseUp() to "finish" the selection (and thereby 520 // We don't want handleMouseUp() to "finish" the selection (and thereby
@@ -496,6 +541,9 @@ BOOL LLLineEditor::handleMouseDown(S32 x, S32 y, MASK mask)
496 } 541 }
497 else 542 else
498 { 543 {
544 mLastSelectionStart = -1;
545 mLastSelectionStart = -1;
546
499 setFocus( TRUE ); 547 setFocus( TRUE );
500 548
501 if (mask & MASK_SHIFT) 549 if (mask & MASK_SHIFT)
@@ -539,6 +587,10 @@ BOOL LLLineEditor::handleMouseDown(S32 x, S32 y, MASK mask)
539 } 587 }
540 else 588 else
541 { 589 {
590 // Save selection for word/line selecting on double-click
591 mLastSelectionStart = mSelectionStart;
592 mLastSelectionEnd = mSelectionEnd;
593
542 // Move cursor and deselect for regular click 594 // Move cursor and deselect for regular click
543 setCursorAtLocalPos( x ); 595 setCursorAtLocalPos( x );
544 deselect(); 596 deselect();
diff --git a/linden/indra/llui/lllineeditor.h b/linden/indra/llui/lllineeditor.h
index 5ff2de7..04c53b4 100644
--- a/linden/indra/llui/lllineeditor.h
+++ b/linden/indra/llui/lllineeditor.h
@@ -127,7 +127,8 @@ public:
127 virtual void setRect(const LLRect& rect); 127 virtual void setRect(const LLRect& rect);
128 virtual BOOL acceptsTextInput() const; 128 virtual BOOL acceptsTextInput() const;
129 virtual void onCommit(); 129 virtual void onCommit();
130 virtual BOOL isDirty() { return ( mText.getString() != mPrevText ); }; // Returns TRUE if the user has changed value at all 130 virtual BOOL isDirty() const; // Returns TRUE if the user has changed value at all
131 virtual void resetDirty(); // Clear dirty state
131 132
132 // assumes UTF8 text 133 // assumes UTF8 text
133 virtual void setValue(const LLSD& value ); 134 virtual void setValue(const LLSD& value );
@@ -257,6 +258,8 @@ protected:
257 S32 mSelectionEnd; 258 S32 mSelectionEnd;
258 S32 mLastSelectionX; 259 S32 mLastSelectionX;
259 S32 mLastSelectionY; 260 S32 mLastSelectionY;
261 S32 mLastSelectionStart;
262 S32 mLastSelectionEnd;
260 263
261 S32 (*mPrevalidateFunc)(const LLWString &str); 264 S32 (*mPrevalidateFunc)(const LLWString &str);
262 265
diff --git a/linden/indra/llui/llradiogroup.h b/linden/indra/llui/llradiogroup.h
index 3dec41d..5b3e4db 100644
--- a/linden/indra/llui/llradiogroup.h
+++ b/linden/indra/llui/llradiogroup.h
@@ -115,7 +115,7 @@ public:
115 /*virtual*/ BOOL getCanSelect() const { return TRUE; } 115 /*virtual*/ BOOL getCanSelect() const { return TRUE; }
116 /*virtual*/ BOOL selectFirstItem() { return setSelectedIndex(0); } 116 /*virtual*/ BOOL selectFirstItem() { return setSelectedIndex(0); }
117 /*virtual*/ BOOL selectNthItem( S32 index ) { return setSelectedIndex(index); } 117 /*virtual*/ BOOL selectNthItem( S32 index ) { return setSelectedIndex(index); }
118 /*virtual*/ S32 getFirstSelectedIndex() { return getSelectedIndex(); } 118 /*virtual*/ S32 getFirstSelectedIndex() const { return getSelectedIndex(); }
119 /*virtual*/ BOOL setCurrentByID( const LLUUID& id ); 119 /*virtual*/ BOOL setCurrentByID( const LLUUID& id );
120 /*virtual*/ LLUUID getCurrentID(); // LLUUID::null if no items in menu 120 /*virtual*/ LLUUID getCurrentID(); // LLUUID::null if no items in menu
121 /*virtual*/ BOOL setSelectedByValue(LLSD value, BOOL selected); 121 /*virtual*/ BOOL setSelectedByValue(LLSD value, BOOL selected);
diff --git a/linden/indra/llui/llscrolllistctrl.cpp b/linden/indra/llui/llscrolllistctrl.cpp
index 56a6a22..9e1a573 100644
--- a/linden/indra/llui/llscrolllistctrl.cpp
+++ b/linden/indra/llui/llscrolllistctrl.cpp
@@ -447,6 +447,8 @@ LLScrollListCtrl::LLScrollListCtrl(const LLString& name, const LLRect& rect,
447 mSortColumn(-1), 447 mSortColumn(-1),
448 mSortAscending(TRUE), 448 mSortAscending(TRUE),
449 mSorted(TRUE), 449 mSorted(TRUE),
450 mDirty(FALSE),
451 mOriginalSelection(-1),
450 mDrewSelected(FALSE) 452 mDrewSelected(FALSE)
451{ 453{
452 mItemListRect.setOriginAndSize( 454 mItemListRect.setOriginAndSize(
@@ -535,6 +537,7 @@ void LLScrollListCtrl::clearRows()
535 mScrollLines = 0; 537 mScrollLines = 0;
536 mLastSelected = NULL; 538 mLastSelected = NULL;
537 updateMaxContentWidth(NULL); 539 updateMaxContentWidth(NULL);
540 mDirty = FALSE;
538} 541}
539 542
540 543
@@ -567,10 +570,10 @@ std::vector<LLScrollListItem*> LLScrollListCtrl::getAllSelected() const
567 return ret; 570 return ret;
568} 571}
569 572
570S32 LLScrollListCtrl::getFirstSelectedIndex() 573S32 LLScrollListCtrl::getFirstSelectedIndex() const
571{ 574{
572 S32 CurSelectedIndex = 0; 575 S32 CurSelectedIndex = 0;
573 item_list::iterator iter; 576 item_list::const_iterator iter;
574 for (iter = mItemList.begin(); iter != mItemList.end(); iter++) 577 for (iter = mItemList.begin(); iter != mItemList.end(); iter++)
575 { 578 {
576 LLScrollListItem* item = *iter; 579 LLScrollListItem* item = *iter;
@@ -885,6 +888,7 @@ BOOL LLScrollListCtrl::selectFirstItem()
885 selectItem(itemp); 888 selectItem(itemp);
886 } 889 }
887 success = TRUE; 890 success = TRUE;
891 mOriginalSelection = 0;
888 } 892 }
889 else 893 else
890 { 894 {
@@ -918,6 +922,7 @@ BOOL LLScrollListCtrl::selectNthItem( S32 target_index )
918 { 922 {
919 selectItem(itemp); 923 selectItem(itemp);
920 success = TRUE; 924 success = TRUE;
925 mOriginalSelection = target_index;
921 } 926 }
922 } 927 }
923 else 928 else
@@ -1741,6 +1746,7 @@ BOOL LLScrollListCtrl::handleMouseUp(S32 x, S32 y, MASK mask)
1741 // always commit when mouse operation is completed inside list 1746 // always commit when mouse operation is completed inside list
1742 if (mItemListRect.pointInRect(x,y)) 1747 if (mItemListRect.pointInRect(x,y))
1743 { 1748 {
1749 mDirty |= mSelectionChanged;
1744 mSelectionChanged = FALSE; 1750 mSelectionChanged = FALSE;
1745 onCommit(); 1751 onCommit();
1746 } 1752 }
@@ -2141,6 +2147,7 @@ void LLScrollListCtrl::commitIfChanged()
2141{ 2147{
2142 if (mSelectionChanged) 2148 if (mSelectionChanged)
2143 { 2149 {
2150 mDirty = TRUE;
2144 mSelectionChanged = FALSE; 2151 mSelectionChanged = FALSE;
2145 onCommit(); 2152 onCommit();
2146 } 2153 }
@@ -2999,6 +3006,26 @@ void LLScrollListCtrl::setFocus(BOOL b)
2999 LLUICtrl::setFocus(b); 3006 LLUICtrl::setFocus(b);
3000} 3007}
3001 3008
3009
3010// virtual
3011BOOL LLScrollListCtrl::isDirty() const
3012{
3013 BOOL grubby = mDirty;
3014 if ( !mAllowMultipleSelection )
3015 {
3016 grubby = (mOriginalSelection != getFirstSelectedIndex());
3017 }
3018 return grubby;
3019}
3020
3021// Clear dirty state
3022void LLScrollListCtrl::resetDirty()
3023{
3024 mDirty = FALSE;
3025 mOriginalSelection = getFirstSelectedIndex();
3026}
3027
3028
3002//virtual 3029//virtual
3003void LLScrollListCtrl::onFocusReceived() 3030void LLScrollListCtrl::onFocusReceived()
3004{ 3031{
diff --git a/linden/indra/llui/llscrolllistctrl.h b/linden/indra/llui/llscrolllistctrl.h
index 809c528..2e4dad5 100644
--- a/linden/indra/llui/llscrolllistctrl.h
+++ b/linden/indra/llui/llscrolllistctrl.h
@@ -460,7 +460,7 @@ public:
460 LLUUID getStringUUIDSelectedItem(); 460 LLUUID getStringUUIDSelectedItem();
461 461
462 LLScrollListItem* getFirstSelected() const; 462 LLScrollListItem* getFirstSelected() const;
463 virtual S32 getFirstSelectedIndex(); 463 virtual S32 getFirstSelectedIndex() const;
464 std::vector<LLScrollListItem*> getAllSelected() const; 464 std::vector<LLScrollListItem*> getAllSelected() const;
465 465
466 LLScrollListItem* getLastSelectedItem() const { return mLastSelected; } 466 LLScrollListItem* getLastSelectedItem() const { return mLastSelected; }
@@ -515,6 +515,9 @@ public:
515 virtual void onFocusReceived(); 515 virtual void onFocusReceived();
516 virtual void onFocusLost(); 516 virtual void onFocusLost();
517 517
518 virtual BOOL isDirty() const;
519 virtual void resetDirty(); // Clear dirty state
520
518 virtual void reshape(S32 width, S32 height, BOOL called_from_parent = TRUE); 521 virtual void reshape(S32 width, S32 height, BOOL called_from_parent = TRUE);
519 virtual void arrange(S32 max_width, S32 max_height); 522 virtual void arrange(S32 max_width, S32 max_height);
520 virtual LLRect getRequiredRect(); 523 virtual LLRect getRequiredRect();
@@ -658,6 +661,9 @@ protected:
658 std::map<LLString, LLScrollListColumn> mColumns; 661 std::map<LLString, LLScrollListColumn> mColumns;
659 std::vector<LLScrollListColumn*> mColumnsIndexed; 662 std::vector<LLScrollListColumn*> mColumnsIndexed;
660 663
664 BOOL mDirty;
665 S32 mOriginalSelection;
666
661public: 667public:
662 // HACK: Did we draw one selected item this frame? 668 // HACK: Did we draw one selected item this frame?
663 BOOL mDrewSelected; 669 BOOL mDrewSelected;
diff --git a/linden/indra/llui/lltexteditor.cpp b/linden/indra/llui/lltexteditor.cpp
index f49b2db..552a9c9 100644
--- a/linden/indra/llui/lltexteditor.cpp
+++ b/linden/indra/llui/lltexteditor.cpp
@@ -354,6 +354,8 @@ LLTextEditor::LLTextEditor(
354 354
355 appendText(default_text, FALSE, FALSE); 355 appendText(default_text, FALSE, FALSE);
356 356
357 resetDirty(); // Update saved text state
358
357 mParseHTML=FALSE; 359 mParseHTML=FALSE;
358 mHTML=""; 360 mHTML="";
359} 361}
@@ -529,6 +531,8 @@ void LLTextEditor::setText(const LLString &utf8str)
529 531
530 updateLineStartList(); 532 updateLineStartList();
531 updateScrollFromCursor(); 533 updateScrollFromCursor();
534
535 resetDirty();
532} 536}
533 537
534void LLTextEditor::setWText(const LLWString &wtext) 538void LLTextEditor::setWText(const LLWString &wtext)
@@ -545,6 +549,8 @@ void LLTextEditor::setWText(const LLWString &wtext)
545 549
546 updateLineStartList(); 550 updateLineStartList();
547 updateScrollFromCursor(); 551 updateScrollFromCursor();
552
553 resetDirty();
548} 554}
549 555
550void LLTextEditor::setValue(const LLSD& value) 556void LLTextEditor::setValue(const LLSD& value)
@@ -3447,6 +3453,7 @@ void LLTextEditor::appendText(const LLString &new_text, bool allow_undo, bool pr
3447 BOOL was_scrolled_to_bottom = (mScrollbar->getDocPos() == mScrollbar->getDocPosMax()); 3453 BOOL was_scrolled_to_bottom = (mScrollbar->getDocPos() == mScrollbar->getDocPosMax());
3448 S32 selection_start = mSelectionStart; 3454 S32 selection_start = mSelectionStart;
3449 S32 selection_end = mSelectionEnd; 3455 S32 selection_end = mSelectionEnd;
3456 BOOL was_selecting = mIsSelecting;
3450 S32 cursor_pos = mCursorPos; 3457 S32 cursor_pos = mCursorPos;
3451 S32 old_length = getLength(); 3458 S32 old_length = getLength();
3452 BOOL cursor_was_at_end = (mCursorPos == old_length); 3459 BOOL cursor_was_at_end = (mCursorPos == old_length);
@@ -3479,17 +3486,23 @@ void LLTextEditor::appendText(const LLString &new_text, bool allow_undo, bool pr
3479 updateLineStartList(old_length); 3486 updateLineStartList(old_length);
3480 3487
3481 // Set the cursor and scroll position 3488 // Set the cursor and scroll position
3482 // Maintain the scroll position unless the scroll was at the end of the doc 3489 // Maintain the scroll position unless the scroll was at the end of the doc (in which
3483 // (in which case, move it to the new end of the doc) 3490 // case, move it to the new end of the doc) or unless the user was doing actively selecting
3484 if( was_scrolled_to_bottom ) 3491 if( was_scrolled_to_bottom && !was_selecting )
3485 { 3492 {
3493 if( selection_start != selection_end )
3494 {
3495 // maintain an existing non-active selection
3496 mSelectionStart = selection_start;
3497 mSelectionEnd = selection_end;
3498 }
3486 endOfDoc(); 3499 endOfDoc();
3487 } 3500 }
3488 else if( selection_start != selection_end ) 3501 else if( selection_start != selection_end )
3489 { 3502 {
3490 mSelectionStart = selection_start; 3503 mSelectionStart = selection_start;
3491
3492 mSelectionEnd = selection_end; 3504 mSelectionEnd = selection_end;
3505 mIsSelecting = was_selecting;
3493 setCursorPos(cursor_pos); 3506 setCursorPos(cursor_pos);
3494 } 3507 }
3495 else if( cursor_was_at_end ) 3508 else if( cursor_was_at_end )
@@ -3626,6 +3639,11 @@ BOOL LLTextEditor::tryToRevertToPristineState()
3626 return isPristine(); // TRUE => success 3639 return isPristine(); // TRUE => success
3627} 3640}
3628 3641
3642// virtual Return TRUE if changes have been made
3643BOOL LLTextEditor::isDirty() const
3644{
3645 return( mLastCmd != NULL || (mPristineCmd && (mPristineCmd != mLastCmd)) );
3646}
3629 3647
3630 3648
3631void LLTextEditor::updateTextRect() 3649void LLTextEditor::updateTextRect()
diff --git a/linden/indra/llui/lltexteditor.h b/linden/indra/llui/lltexteditor.h
index 68c1d4a..4bcfcfc 100644
--- a/linden/indra/llui/lltexteditor.h
+++ b/linden/indra/llui/lltexteditor.h
@@ -109,6 +109,7 @@ public:
109 virtual void clear(); 109 virtual void clear();
110 virtual void setFocus( BOOL b ); 110 virtual void setFocus( BOOL b );
111 virtual BOOL acceptsTextInput() const; 111 virtual BOOL acceptsTextInput() const;
112 virtual BOOL isDirty() const;
112 113
113 // LLEditMenuHandler interface 114 // LLEditMenuHandler interface
114 virtual void undo(); 115 virtual void undo();
diff --git a/linden/indra/llui/lluictrl.h b/linden/indra/llui/lluictrl.h
index 2060a0d..455a8c0 100644
--- a/linden/indra/llui/lluictrl.h
+++ b/linden/indra/llui/lluictrl.h
@@ -149,7 +149,9 @@ public:
149 }; 149 };
150 150
151 // Returns TRUE if the user has modified this control. Editable controls should override this. 151 // Returns TRUE if the user has modified this control. Editable controls should override this.
152 virtual BOOL isDirty() { return FALSE; }; 152 virtual BOOL isDirty() const { return FALSE; };
153 // Clear the dirty state
154 virtual void resetDirty() {};
153 155
154protected: 156protected:
155 virtual void onFocusReceived(); 157 virtual void onFocusReceived();