diff --git a/indra/llcommon/llkeybind.cpp b/indra/llcommon/llkeybind.cpp
index 0eca289d4b..ff88a9c9aa 100644
--- a/indra/llcommon/llkeybind.cpp
+++ b/indra/llcommon/llkeybind.cpp
@@ -218,13 +218,17 @@ bool LLKeyBind::isEmpty() const
LLSD LLKeyBind::asLLSD() const
{
- LLSD data;
- for (data_vector_t::const_iterator iter = mData.begin(); iter != mData.end(); iter++)
+ S32 last = mData.size() - 1;
+ while (mData[last].empty())
{
- if (!iter->isEmpty())
- {
- data.append(iter->asLLSD());
- }
+ last--;
+ }
+
+ LLSD data;
+ for (S32 i = 0; i <= last; ++i)
+ {
+ // append even if empty to not affect visual representation
+ data.append(mData[i].asLLSD());
}
return data;
}
@@ -280,6 +284,43 @@ bool LLKeyBind::hasKeyData(const LLKeyData& data) const
return hasKeyData(data.mMouse, data.mKey, data.mMask, data.mIgnoreMasks);
}
+bool LLKeyBind::hasKeyData(U32 index) const
+{
+ return mData.size() > index;
+}
+
+S32 LLKeyBind::findKeyData(EMouseClickType mouse, KEY key, MASK mask, bool ignore) const
+{
+ if (mouse != CLICK_NONE || key != KEY_NONE)
+ {
+ for (S32 i = 0; i < mData.size(); ++i)
+ {
+ if (mData[i].mKey == key
+ && mData[i].mMask == mask
+ && mData[i].mMouse == mouse
+ && mData[i].mIgnoreMasks == ignore)
+ {
+ return i;
+ }
+ }
+ }
+ return -1;
+}
+
+S32 LLKeyBind::findKeyData(const LLKeyData& data) const
+{
+ return findKeyData(data.mMouse, data.mKey, data.mMask, data.mIgnoreMasks);
+}
+
+LLKeyData LLKeyBind::getKeyData(U32 index) const
+{
+ if (mData.size() > index)
+ {
+ return mData[index];
+ }
+ return LLKeyData();
+}
+
bool LLKeyBind::addKeyData(EMouseClickType mouse, KEY key, MASK mask, bool ignore)
{
if (!hasKeyData(mouse, key, mask, ignore))
@@ -344,28 +385,29 @@ void LLKeyBind::replaceKeyData(const LLKeyData& data, U32 index)
}
}
}
- if (mData.size() > index)
+ if (mData.size() <= index)
{
- mData[index] = data;
- }
- else
- {
- mData.push_back(data);
+ mData.resize(index + 1);
}
+ mData[index] = data;
}
-bool LLKeyBind::hasKeyData(U32 index) const
-{
- return mData.size() > index;
-}
-
-LLKeyData LLKeyBind::getKeyData(U32 index) const
+void LLKeyBind::resetKeyData(S32 index)
{
if (mData.size() > index)
{
- return mData[index];
+ mData[index].reset();
+ }
+}
+
+void LLKeyBind::trimEmpty()
+{
+ S32 last = mData.size() - 1;
+ while (last >= 0 && mData[last].empty())
+ {
+ mData.erase(mData.begin() + last);
+ last--;
}
- return LLKeyData();
}
U32 LLKeyBind::getDataCount()
diff --git a/indra/llcommon/llkeybind.h b/indra/llcommon/llkeybind.h
index 25179a57f3..39cb668aac 100644
--- a/indra/llcommon/llkeybind.h
+++ b/indra/llcommon/llkeybind.h
@@ -74,17 +74,26 @@ public:
bool canHandleKey(KEY key, MASK mask) const;
bool canHandleMouse(EMouseClickType mouse, MASK mask) const;
- bool LLKeyBind::hasKeyData(EMouseClickType mouse, KEY key, MASK mask, bool ignore) const;
- bool LLKeyBind::hasKeyData(const LLKeyData& data) const;
+ // contains specified combination
+ bool hasKeyData(EMouseClickType mouse, KEY key, MASK mask, bool ignore) const;
+ bool hasKeyData(const LLKeyData& data) const;
+ bool hasKeyData(U32 index) const;
+
+ // index of contained LLKeyData
+ S32 findKeyData(EMouseClickType mouse, KEY key, MASK mask, bool ignore) const;
+ S32 findKeyData(const LLKeyData& data) const;
+
+ LLKeyData getKeyData(U32 index) const;
// these methods enshure there will be no repeats
bool addKeyData(EMouseClickType mouse, KEY key, MASK mask, bool ignore);
bool addKeyData(const LLKeyData& data);
void replaceKeyData(EMouseClickType mouse, KEY key, MASK mask, bool ignore, U32 index);
void replaceKeyData(const LLKeyData& data, U32 index);
- bool hasKeyData(U32 index) const;
- void clear() { mData.clear(); };
- LLKeyData getKeyData(U32 index) const;
+ void resetKeyData(S32 index);
+ void clear() { mData.clear(); }
+ // if there any empty LLKeyData in the end of the array, remove them
+ void trimEmpty();
U32 getDataCount();
private:
diff --git a/indra/llui/llscrolllistcell.cpp b/indra/llui/llscrolllistcell.cpp
index 0a33ee8878..d6627a6957 100644
--- a/indra/llui/llscrolllistcell.cpp
+++ b/indra/llui/llscrolllistcell.cpp
@@ -196,7 +196,14 @@ LLScrollListText::LLScrollListText(const LLScrollListCell::Params& p)
void LLScrollListText::highlightText(S32 offset, S32 num_chars)
{
mHighlightOffset = offset;
- mHighlightCount = num_chars;
+ mHighlightCount = llmax(0, num_chars);
+}
+
+//virtual
+void LLScrollListText::setHighlighted(bool highlighted)
+{
+ mHighlightOffset = 0;
+ mHighlightCount = highlighted ? -1 : 0;
}
//virtual
@@ -296,6 +303,7 @@ void LLScrollListText::draw(const LLColor4& color, const LLColor4& highlight_col
if (mHighlightCount > 0)
{
+ // Highlight text
S32 left = 0;
switch(mFontAlignment)
{
@@ -314,11 +322,15 @@ void LLScrollListText::draw(const LLColor4& color, const LLColor4& highlight_col
left + mFont->getWidth(mText.getString(), mHighlightOffset, mHighlightCount) + 1,
1);
mRoundedRectImage->draw(highlight_rect, highlight_color);
- /*LLRect highlight_rect(left - 2,
- mFont->getLineHeight() + 2,
- left + getWidth() + 2,
- 1);
- mRoundedRectImage->draw(highlight_rect, LLColor4::black);*/
+ }
+ else if (mHighlightCount < 0)
+ {
+ // Highlight whole cell
+ LLRect highlight_rect(0,
+ getHeight(),
+ getWidth() - 1,
+ -1);
+ gl_rect_2d(highlight_rect, LLColor4(0.38f, 0.694f, 0.573f, 0.35f));
}
// Try to draw the entire string
diff --git a/indra/llui/llscrolllistcell.h b/indra/llui/llscrolllistcell.h
index 1604a9b1dc..b4bb14bcf1 100644
--- a/indra/llui/llscrolllistcell.h
+++ b/indra/llui/llscrolllistcell.h
@@ -103,6 +103,7 @@ public:
virtual BOOL getVisible() const { return TRUE; }
virtual void setWidth(S32 width) { mWidth = width; }
virtual void highlightText(S32 offset, S32 num_chars) {}
+ virtual void setHighlighted(bool highlighted) {}
virtual BOOL isText() const { return FALSE; }
virtual BOOL needsToolTip() const { return ! mToolTip.empty(); }
virtual void setColor(const LLColor4&) {}
@@ -140,6 +141,7 @@ public:
/*virtual*/ const LLSD getValue() const;
/*virtual*/ BOOL getVisible() const;
/*virtual*/ void highlightText(S32 offset, S32 num_chars);
+ /*virtual*/ void setHighlighted(bool highlighted);
/*virtual*/ void setColor(const LLColor4&);
/*virtual*/ BOOL isText() const;
diff --git a/indra/newview/app_settings/settings.xml b/indra/newview/app_settings/settings.xml
index e8f01f7a60..d0cd4e2b39 100644
--- a/indra/newview/app_settings/settings.xml
+++ b/indra/newview/app_settings/settings.xml
@@ -8274,7 +8274,7 @@
PushToTalkButton