summaryrefslogtreecommitdiff
path: root/indra/llui
diff options
context:
space:
mode:
authorChristian Goetze <cg@lindenlab.com>2007-08-21 22:17:53 +0000
committerChristian Goetze <cg@lindenlab.com>2007-08-21 22:17:53 +0000
commitce0a5fe14590b8d675b885fccd5f79d7ea17a302 (patch)
tree3388e6f8ff02292ec4521d278c841801462945b8 /indra/llui
parentb699ae454d8477d19342d320758cd993d1d28cec (diff)
EFFECTIVE MERGE: svn merge -r 66133:68118 svn+ssh://svn/svn/linden/branches/maintenance into release
Actual action: branched maintenance-r68118, merged in release, then copied result into release
Diffstat (limited to 'indra/llui')
-rw-r--r--indra/llui/llbutton.cpp12
-rw-r--r--indra/llui/llbutton.h4
-rw-r--r--indra/llui/llcheckboxctrl.cpp21
-rw-r--r--indra/llui/llcheckboxctrl.h6
-rw-r--r--indra/llui/llcombobox.cpp21
-rw-r--r--indra/llui/llcombobox.h4
-rw-r--r--indra/llui/llctrlselectioninterface.h2
-rw-r--r--indra/llui/llfloater.cpp9
-rw-r--r--indra/llui/lllineeditor.cpp56
-rw-r--r--indra/llui/lllineeditor.h5
-rw-r--r--indra/llui/llradiogroup.h2
-rw-r--r--indra/llui/llscrolllistctrl.cpp31
-rw-r--r--indra/llui/llscrolllistctrl.h8
-rw-r--r--indra/llui/lltexteditor.cpp26
-rw-r--r--indra/llui/lltexteditor.h1
-rw-r--r--indra/llui/lluictrl.h4
16 files changed, 175 insertions, 37 deletions
diff --git a/indra/llui/llbutton.cpp b/indra/llui/llbutton.cpp
index bdf1c12b79..2fe43c04f2 100644
--- a/indra/llui/llbutton.cpp
+++ b/indra/llui/llbutton.cpp
@@ -69,8 +69,7 @@ LLButton::LLButton( const LLString& name, const LLRect& rect, const LLString& co
mCurGlowStrength(0.f),
mNeedsHighlight(FALSE),
mCommitOnReturn(TRUE),
- mImagep( NULL ),
- mIsDirty( FALSE )
+ mImagep( NULL )
{
mUnselectedLabel = name;
mSelectedLabel = name;
@@ -255,8 +254,6 @@ void LLButton::onCommit()
{
(*mClickedCallback)( mCallbackUserData );
}
-
- mIsDirty = TRUE;
}
@@ -271,7 +268,6 @@ BOOL LLButton::handleUnicodeCharHere(llwchar uni_char, BOOL called_from_parent)
(*mClickedCallback)( mCallbackUserData );
}
handled = TRUE;
- mIsDirty = TRUE;
}
return handled;
}
@@ -288,7 +284,6 @@ BOOL LLButton::handleKeyHere(KEY key, MASK mask, BOOL called_from_parent )
(*mClickedCallback)( mCallbackUserData );
}
handled = TRUE;
- mIsDirty = TRUE;
}
}
return handled;
@@ -348,9 +343,7 @@ BOOL LLButton::handleMouseUp(S32 x, S32 y, MASK mask)
if (mClickedCallback)
{
(*mClickedCallback)( mCallbackUserData );
- }
-
- mIsDirty = TRUE;
+ }
}
mMouseDownTimer.stop();
@@ -753,7 +746,6 @@ void LLButton::setToggleState(BOOL b)
void LLButton::setValue(const LLSD& value )
{
mToggleState = value.asBoolean();
- mIsDirty = FALSE;
}
LLSD LLButton::getValue() const
diff --git a/indra/llui/llbutton.h b/indra/llui/llbutton.h
index a638b5be49..9c737956ba 100644
--- a/indra/llui/llbutton.h
+++ b/indra/llui/llbutton.h
@@ -80,8 +80,6 @@ public:
// HACK: "committing" a button is the same as clicking on it.
virtual void onCommit();
- virtual BOOL isDirty() { return mIsDirty; }; // Returns TRUE if the user has clicked on the button at all
-
void setUnselectedLabelColor( const LLColor4& c ) { mUnselectedLabelColor = c; }
void setSelectedLabelColor( const LLColor4& c ) { mSelectedLabelColor = c; }
@@ -259,8 +257,6 @@ protected:
LLPointer<LLImageGL> mImagep;
- BOOL mIsDirty;
-
static LLFrameTimer sFlashingTimer;
};
diff --git a/indra/llui/llcheckboxctrl.cpp b/indra/llui/llcheckboxctrl.cpp
index 6c181acc94..318268bdb6 100644
--- a/indra/llui/llcheckboxctrl.cpp
+++ b/indra/llui/llcheckboxctrl.cpp
@@ -39,7 +39,8 @@ LLCheckBoxCtrl::LLCheckBoxCtrl(const LLString& name, const LLRect& rect,
mTextEnabledColor( LLUI::sColorsGroup->getColor( "LabelTextColor" ) ),
mTextDisabledColor( LLUI::sColorsGroup->getColor( "LabelDisabledColor" ) ),
mRadioStyle( use_radio_style ),
- mInitialValue( initial_value )
+ mInitialValue( initial_value ),
+ mSetValue( initial_value )
{
if (font)
{
@@ -208,7 +209,8 @@ void LLCheckBoxCtrl::draw()
//virtual
void LLCheckBoxCtrl::setValue(const LLSD& value )
{
- mButton->setToggleState( value.asBoolean() );
+ mSetValue = value.asBoolean();
+ mButton->setToggleState( mSetValue );
}
//virtual
@@ -249,16 +251,27 @@ void LLCheckBoxCtrl::setControlName(const LLString& control_name, LLView* contex
// virtual Returns TRUE if the user has modified this control.
-BOOL LLCheckBoxCtrl::isDirty()
+BOOL LLCheckBoxCtrl::isDirty() const
{
if ( mButton )
{
- return mButton->isDirty();
+ return (mSetValue != mButton->getToggleState());
}
return FALSE; // Shouldn't get here
}
+// virtual Clear dirty state
+void LLCheckBoxCtrl::resetDirty()
+{
+ if ( mButton )
+ {
+ mSetValue = mButton->getToggleState();
+ }
+}
+
+
+
// virtual
LLXMLNodePtr LLCheckBoxCtrl::getXML(bool save_children) const
{
diff --git a/indra/llui/llcheckboxctrl.h b/indra/llui/llcheckboxctrl.h
index 76b197125d..3b1883ce8d 100644
--- a/indra/llui/llcheckboxctrl.h
+++ b/indra/llui/llcheckboxctrl.h
@@ -90,7 +90,8 @@ public:
static void onButtonPress(void *userdata);
- virtual BOOL isDirty(); // Returns TRUE if the user has modified this control.
+ virtual BOOL isDirty() const; // Returns TRUE if the user has modified this control.
+ virtual void resetDirty(); // Clear dirty state
protected:
// note: value is stored in toggle state of button
@@ -100,7 +101,8 @@ protected:
LLColor4 mTextEnabledColor;
LLColor4 mTextDisabledColor;
BOOL mRadioStyle;
- BOOL mInitialValue;
+ BOOL mInitialValue; // Value set in constructor
+ BOOL mSetValue; // Value set programmatically
BOOL mKeyboardFocusOnClick;
LLViewBorder* mBorder;
};
diff --git a/indra/llui/llcombobox.cpp b/indra/llui/llcombobox.cpp
index d63a53fdff..5eeb1d19c8 100644
--- a/indra/llui/llcombobox.cpp
+++ b/indra/llui/llcombobox.cpp
@@ -227,6 +227,27 @@ void LLComboBox::onCommit()
LLUICtrl::onCommit();
}
+// virtual
+BOOL LLComboBox::isDirty() const
+{
+ BOOL grubby = FALSE;
+ if ( mList )
+ {
+ grubby = mList->isDirty();
+ }
+ return grubby;
+}
+
+// virtual Clear dirty state
+void LLComboBox::resetDirty()
+{
+ if ( mList )
+ {
+ mList->resetDirty();
+ }
+}
+
+
// add item "name" to menu
void LLComboBox::add(const LLString& name, EAddPosition pos, BOOL enabled)
{
diff --git a/indra/llui/llcombobox.h b/indra/llui/llcombobox.h
index 02aa0084ed..fea54c554e 100644
--- a/indra/llui/llcombobox.h
+++ b/indra/llui/llcombobox.h
@@ -68,6 +68,8 @@ public:
virtual void clear(); // select nothing
virtual void onCommit();
virtual BOOL acceptsTextInput() const { return mAllowTextEntry; }
+ virtual BOOL isDirty() const; // Returns TRUE if the user has modified this control.
+ virtual void resetDirty(); // Clear dirty state
virtual void setFocus(BOOL b);
@@ -127,7 +129,7 @@ public:
virtual BOOL getCanSelect() const { return TRUE; }
virtual BOOL selectFirstItem() { return setCurrentByIndex(0); }
virtual BOOL selectNthItem( S32 index ) { return setCurrentByIndex(index); }
- virtual S32 getFirstSelectedIndex() { return getCurrentIndex(); }
+ virtual S32 getFirstSelectedIndex() const { return getCurrentIndex(); }
virtual BOOL setCurrentByID( const LLUUID& id );
virtual LLUUID getCurrentID(); // LLUUID::null if no items in menu
virtual BOOL setSelectedByValue(LLSD value, BOOL selected);
diff --git a/indra/llui/llctrlselectioninterface.h b/indra/llui/llctrlselectioninterface.h
index 9df7475a6c..daa84712d4 100644
--- a/indra/llui/llctrlselectioninterface.h
+++ b/indra/llui/llctrlselectioninterface.h
@@ -36,7 +36,7 @@ public:
virtual BOOL selectFirstItem() = 0;
virtual BOOL selectNthItem( S32 index ) = 0;
- virtual S32 getFirstSelectedIndex() = 0;
+ virtual S32 getFirstSelectedIndex() const = 0;
// TomY TODO: Simply cast the UUIDs to LLSDs, using the selectByValue function
virtual BOOL setCurrentByID( const LLUUID& id ) = 0;
diff --git a/indra/llui/llfloater.cpp b/indra/llui/llfloater.cpp
index 17b4dffa3f..9ea4165ea4 100644
--- a/indra/llui/llfloater.cpp
+++ b/indra/llui/llfloater.cpp
@@ -1232,10 +1232,13 @@ BOOL LLFloater::getEditModeEnabled()
//static
void LLFloater::show(LLFloater* floaterp)
{
- if (floaterp) floaterp->open();
- if (floaterp->getHost())
+ if (floaterp)
{
- floaterp->getHost()->open();
+ floaterp->open();
+ if (floaterp->getHost())
+ {
+ floaterp->getHost()->open();
+ }
}
}
diff --git a/indra/llui/lllineeditor.cpp b/indra/llui/lllineeditor.cpp
index 5e043ecea3..ccf18a3506 100644
--- a/indra/llui/lllineeditor.cpp
+++ b/indra/llui/lllineeditor.cpp
@@ -118,6 +118,8 @@ LLLineEditor::LLLineEditor(const LLString& name, const LLRect& rect,
mSelectionEnd( 0 ),
mLastSelectionX(-1),
mLastSelectionY(-1),
+ mLastSelectionStart(-1),
+ mLastSelectionEnd(-1),
mPrevalidateFunc( prevalidate_func ),
mCursorColor( LLUI::sColorsGroup->getColor( "TextCursorColor" ) ),
mFgColor( LLUI::sColorsGroup->getColor( "TextFgColor" ) ),
@@ -227,6 +229,19 @@ void LLLineEditor::onCommit()
selectAll();
}
+// virtual
+BOOL LLLineEditor::isDirty() const
+{
+ return ( mText.getString() != mPrevText );
+}
+
+// virtual
+void LLLineEditor::resetDirty()
+{
+ mPrevText = mText.getString();
+}
+
+
// line history support
void LLLineEditor::updateHistory()
{
@@ -448,8 +463,38 @@ BOOL LLLineEditor::handleDoubleClick(S32 x, S32 y, MASK mask)
}
else
{
- // otherwise select everything
- selectAll();
+ const LLWString& wtext = mText.getWString();
+
+ BOOL doSelectAll = TRUE;
+
+ // Select the word we're on
+ if( isPartOfWord( wtext[mCursorPos] ) )
+ {
+ S32 old_selection_start = mLastSelectionStart;
+ S32 old_selection_end = mLastSelectionEnd;
+
+ // Select word the cursor is over
+ while ((mCursorPos > 0) && isPartOfWord( wtext[mCursorPos-1] ))
+ { // Find the start of the word
+ mCursorPos--;
+ }
+ startSelection();
+
+ while ((mCursorPos < (S32)wtext.length()) && isPartOfWord( wtext[mCursorPos] ) )
+ { // Find the end of the word
+ mCursorPos++;
+ }
+ mSelectionEnd = mCursorPos;
+
+ // If nothing changed, then the word was already selected. Select the whole line.
+ doSelectAll = (old_selection_start == mSelectionStart) &&
+ (old_selection_end == mSelectionEnd);
+ }
+
+ if ( doSelectAll )
+ { // Select everything
+ selectAll();
+ }
}
// We don't want handleMouseUp() to "finish" the selection (and thereby
@@ -476,6 +521,9 @@ BOOL LLLineEditor::handleMouseDown(S32 x, S32 y, MASK mask)
}
else
{
+ mLastSelectionStart = -1;
+ mLastSelectionStart = -1;
+
setFocus( TRUE );
if (mask & MASK_SHIFT)
@@ -519,6 +567,10 @@ BOOL LLLineEditor::handleMouseDown(S32 x, S32 y, MASK mask)
}
else
{
+ // Save selection for word/line selecting on double-click
+ mLastSelectionStart = mSelectionStart;
+ mLastSelectionEnd = mSelectionEnd;
+
// Move cursor and deselect for regular click
setCursorAtLocalPos( x );
deselect();
diff --git a/indra/llui/lllineeditor.h b/indra/llui/lllineeditor.h
index 110e40b92d..db6aea8432 100644
--- a/indra/llui/lllineeditor.h
+++ b/indra/llui/lllineeditor.h
@@ -107,7 +107,8 @@ public:
virtual void setRect(const LLRect& rect);
virtual BOOL acceptsTextInput() const;
virtual void onCommit();
- virtual BOOL isDirty() { return ( mText.getString() != mPrevText ); }; // Returns TRUE if the user has changed value at all
+ virtual BOOL isDirty() const; // Returns TRUE if the user has changed value at all
+ virtual void resetDirty(); // Clear dirty state
// assumes UTF8 text
virtual void setValue(const LLSD& value );
@@ -237,6 +238,8 @@ protected:
S32 mSelectionEnd;
S32 mLastSelectionX;
S32 mLastSelectionY;
+ S32 mLastSelectionStart;
+ S32 mLastSelectionEnd;
S32 (*mPrevalidateFunc)(const LLWString &str);
diff --git a/indra/llui/llradiogroup.h b/indra/llui/llradiogroup.h
index 2a856ee6cf..38b56a179e 100644
--- a/indra/llui/llradiogroup.h
+++ b/indra/llui/llradiogroup.h
@@ -95,7 +95,7 @@ public:
/*virtual*/ BOOL getCanSelect() const { return TRUE; }
/*virtual*/ BOOL selectFirstItem() { return setSelectedIndex(0); }
/*virtual*/ BOOL selectNthItem( S32 index ) { return setSelectedIndex(index); }
- /*virtual*/ S32 getFirstSelectedIndex() { return getSelectedIndex(); }
+ /*virtual*/ S32 getFirstSelectedIndex() const { return getSelectedIndex(); }
/*virtual*/ BOOL setCurrentByID( const LLUUID& id );
/*virtual*/ LLUUID getCurrentID(); // LLUUID::null if no items in menu
/*virtual*/ BOOL setSelectedByValue(LLSD value, BOOL selected);
diff --git a/indra/llui/llscrolllistctrl.cpp b/indra/llui/llscrolllistctrl.cpp
index e802b3426b..ffad4809e9 100644
--- a/indra/llui/llscrolllistctrl.cpp
+++ b/indra/llui/llscrolllistctrl.cpp
@@ -427,6 +427,8 @@ LLScrollListCtrl::LLScrollListCtrl(const LLString& name, const LLRect& rect,
mSortColumn(-1),
mSortAscending(TRUE),
mSorted(TRUE),
+ mDirty(FALSE),
+ mOriginalSelection(-1),
mDrewSelected(FALSE)
{
mItemListRect.setOriginAndSize(
@@ -515,6 +517,7 @@ void LLScrollListCtrl::clearRows()
mScrollLines = 0;
mLastSelected = NULL;
updateMaxContentWidth(NULL);
+ mDirty = FALSE;
}
@@ -547,10 +550,10 @@ std::vector<LLScrollListItem*> LLScrollListCtrl::getAllSelected() const
return ret;
}
-S32 LLScrollListCtrl::getFirstSelectedIndex()
+S32 LLScrollListCtrl::getFirstSelectedIndex() const
{
S32 CurSelectedIndex = 0;
- item_list::iterator iter;
+ item_list::const_iterator iter;
for (iter = mItemList.begin(); iter != mItemList.end(); iter++)
{
LLScrollListItem* item = *iter;
@@ -865,6 +868,7 @@ BOOL LLScrollListCtrl::selectFirstItem()
selectItem(itemp);
}
success = TRUE;
+ mOriginalSelection = 0;
}
else
{
@@ -898,6 +902,7 @@ BOOL LLScrollListCtrl::selectNthItem( S32 target_index )
{
selectItem(itemp);
success = TRUE;
+ mOriginalSelection = target_index;
}
}
else
@@ -1721,6 +1726,7 @@ BOOL LLScrollListCtrl::handleMouseUp(S32 x, S32 y, MASK mask)
// always commit when mouse operation is completed inside list
if (mItemListRect.pointInRect(x,y))
{
+ mDirty |= mSelectionChanged;
mSelectionChanged = FALSE;
onCommit();
}
@@ -2121,6 +2127,7 @@ void LLScrollListCtrl::commitIfChanged()
{
if (mSelectionChanged)
{
+ mDirty = TRUE;
mSelectionChanged = FALSE;
onCommit();
}
@@ -2979,6 +2986,26 @@ void LLScrollListCtrl::setFocus(BOOL b)
LLUICtrl::setFocus(b);
}
+
+// virtual
+BOOL LLScrollListCtrl::isDirty() const
+{
+ BOOL grubby = mDirty;
+ if ( !mAllowMultipleSelection )
+ {
+ grubby = (mOriginalSelection != getFirstSelectedIndex());
+ }
+ return grubby;
+}
+
+// Clear dirty state
+void LLScrollListCtrl::resetDirty()
+{
+ mDirty = FALSE;
+ mOriginalSelection = getFirstSelectedIndex();
+}
+
+
//virtual
void LLScrollListCtrl::onFocusReceived()
{
diff --git a/indra/llui/llscrolllistctrl.h b/indra/llui/llscrolllistctrl.h
index 9604b0569c..c7dfa870fb 100644
--- a/indra/llui/llscrolllistctrl.h
+++ b/indra/llui/llscrolllistctrl.h
@@ -440,7 +440,7 @@ public:
LLUUID getStringUUIDSelectedItem();
LLScrollListItem* getFirstSelected() const;
- virtual S32 getFirstSelectedIndex();
+ virtual S32 getFirstSelectedIndex() const;
std::vector<LLScrollListItem*> getAllSelected() const;
LLScrollListItem* getLastSelectedItem() const { return mLastSelected; }
@@ -495,6 +495,9 @@ public:
virtual void onFocusReceived();
virtual void onFocusLost();
+ virtual BOOL isDirty() const;
+ virtual void resetDirty(); // Clear dirty state
+
virtual void reshape(S32 width, S32 height, BOOL called_from_parent = TRUE);
virtual void arrange(S32 max_width, S32 max_height);
virtual LLRect getRequiredRect();
@@ -638,6 +641,9 @@ protected:
std::map<LLString, LLScrollListColumn> mColumns;
std::vector<LLScrollListColumn*> mColumnsIndexed;
+ BOOL mDirty;
+ S32 mOriginalSelection;
+
public:
// HACK: Did we draw one selected item this frame?
BOOL mDrewSelected;
diff --git a/indra/llui/lltexteditor.cpp b/indra/llui/lltexteditor.cpp
index ea5897e28e..52f8c19ebd 100644
--- a/indra/llui/lltexteditor.cpp
+++ b/indra/llui/lltexteditor.cpp
@@ -334,6 +334,8 @@ LLTextEditor::LLTextEditor(
appendText(default_text, FALSE, FALSE);
+ resetDirty(); // Update saved text state
+
mParseHTML=FALSE;
mHTML="";
}
@@ -509,6 +511,8 @@ void LLTextEditor::setText(const LLString &utf8str)
updateLineStartList();
updateScrollFromCursor();
+
+ resetDirty();
}
void LLTextEditor::setWText(const LLWString &wtext)
@@ -525,6 +529,8 @@ void LLTextEditor::setWText(const LLWString &wtext)
updateLineStartList();
updateScrollFromCursor();
+
+ resetDirty();
}
void LLTextEditor::setValue(const LLSD& value)
@@ -3427,6 +3433,7 @@ void LLTextEditor::appendText(const LLString &new_text, bool allow_undo, bool pr
BOOL was_scrolled_to_bottom = (mScrollbar->getDocPos() == mScrollbar->getDocPosMax());
S32 selection_start = mSelectionStart;
S32 selection_end = mSelectionEnd;
+ BOOL was_selecting = mIsSelecting;
S32 cursor_pos = mCursorPos;
S32 old_length = getLength();
BOOL cursor_was_at_end = (mCursorPos == old_length);
@@ -3459,17 +3466,23 @@ void LLTextEditor::appendText(const LLString &new_text, bool allow_undo, bool pr
updateLineStartList(old_length);
// Set the cursor and scroll position
- // Maintain the scroll position unless the scroll was at the end of the doc
- // (in which case, move it to the new end of the doc)
- if( was_scrolled_to_bottom )
+ // Maintain the scroll position unless the scroll was at the end of the doc (in which
+ // case, move it to the new end of the doc) or unless the user was doing actively selecting
+ if( was_scrolled_to_bottom && !was_selecting )
{
+ if( selection_start != selection_end )
+ {
+ // maintain an existing non-active selection
+ mSelectionStart = selection_start;
+ mSelectionEnd = selection_end;
+ }
endOfDoc();
}
else if( selection_start != selection_end )
{
mSelectionStart = selection_start;
-
mSelectionEnd = selection_end;
+ mIsSelecting = was_selecting;
setCursorPos(cursor_pos);
}
else if( cursor_was_at_end )
@@ -3606,6 +3619,11 @@ BOOL LLTextEditor::tryToRevertToPristineState()
return isPristine(); // TRUE => success
}
+// virtual Return TRUE if changes have been made
+BOOL LLTextEditor::isDirty() const
+{
+ return( mLastCmd != NULL || (mPristineCmd && (mPristineCmd != mLastCmd)) );
+}
void LLTextEditor::updateTextRect()
diff --git a/indra/llui/lltexteditor.h b/indra/llui/lltexteditor.h
index 0b6e291843..7c7ec9c13b 100644
--- a/indra/llui/lltexteditor.h
+++ b/indra/llui/lltexteditor.h
@@ -89,6 +89,7 @@ public:
virtual void clear();
virtual void setFocus( BOOL b );
virtual BOOL acceptsTextInput() const;
+ virtual BOOL isDirty() const;
// LLEditMenuHandler interface
virtual void undo();
diff --git a/indra/llui/lluictrl.h b/indra/llui/lluictrl.h
index 7b96ec5655..1355b12924 100644
--- a/indra/llui/lluictrl.h
+++ b/indra/llui/lluictrl.h
@@ -129,7 +129,9 @@ public:
};
// Returns TRUE if the user has modified this control. Editable controls should override this.
- virtual BOOL isDirty() { return FALSE; };
+ virtual BOOL isDirty() const { return FALSE; };
+ // Clear the dirty state
+ virtual void resetDirty() {};
protected:
virtual void onFocusReceived();