summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexander Gavriliuk <alexandrgproductengine@lindenlab.com>2023-08-29 15:07:41 +0200
committerGuru <alexandrgproductengine@lindenlab.com>2023-08-29 15:12:25 +0200
commitb9de65d2750c0f5632116864af792c40078830ab (patch)
tree8d5c919e277d96451076e99e2573f9d352aef7bf
parent1e5ac99fd840b7d85d06fd08b27f2c2cb6201b9c (diff)
SL-20209 Add 'noscroll' parameter to LLPanelEmojiComplete::Params
-rw-r--r--indra/newview/llpanelemojicomplete.cpp25
-rw-r--r--indra/newview/llpanelemojicomplete.h17
2 files changed, 34 insertions, 8 deletions
diff --git a/indra/newview/llpanelemojicomplete.cpp b/indra/newview/llpanelemojicomplete.cpp
index 8b89e3aa14..8fc84c0387 100644
--- a/indra/newview/llpanelemojicomplete.cpp
+++ b/indra/newview/llpanelemojicomplete.cpp
@@ -41,6 +41,7 @@ static LLDefaultChildRegistry::Register<LLPanelEmojiComplete> r("emoji_complete"
LLPanelEmojiComplete::Params::Params()
: autosize("autosize")
+ , noscroll("noscroll")
, max_emoji("max_emoji")
, padding("padding")
, selected_image("selected_image")
@@ -50,6 +51,7 @@ LLPanelEmojiComplete::Params::Params()
LLPanelEmojiComplete::LLPanelEmojiComplete(const LLPanelEmojiComplete::Params& p)
: LLUICtrl(p)
, mAutoSize(p.autosize)
+ , mNoScroll(p.noscroll)
, mMaxVisible(p.max_emoji)
, mPadding(p.padding)
, mSelectedImage(p.selected_image)
@@ -152,7 +154,7 @@ BOOL LLPanelEmojiComplete::handleMouseUp(S32 x, S32 y, MASK mask)
void LLPanelEmojiComplete::onCommit()
{
- if (npos != mCurSelected)
+ if (mCurSelected < mEmojis.size())
{
LLWString wstr;
wstr.push_back(mEmojis.at(mCurSelected));
@@ -167,6 +169,14 @@ void LLPanelEmojiComplete::reshape(S32 width, S32 height, BOOL called_from_paren
updateConstraints();
}
+void LLPanelEmojiComplete::setEmojis(const LLWString& emojis)
+{
+ mEmojis = emojis;
+ mCurSelected = 0;
+
+ onEmojisChanged();
+}
+
void LLPanelEmojiComplete::setEmojiHint(const std::string& hint)
{
llwchar curEmoji = (mCurSelected < mEmojis.size()) ? mEmojis.at(mCurSelected) : 0;
@@ -175,6 +185,11 @@ void LLPanelEmojiComplete::setEmojiHint(const std::string& hint)
size_t curEmojiIdx = (curEmoji) ? mEmojis.find(curEmoji) : std::string::npos;
mCurSelected = (std::string::npos != curEmojiIdx) ? curEmojiIdx : 0;
+ onEmojisChanged();
+}
+
+void LLPanelEmojiComplete::onEmojisChanged()
+{
if (mAutoSize)
{
mVisibleEmojis = std::min(mEmojis.size(), mMaxVisible);
@@ -233,9 +248,13 @@ void LLPanelEmojiComplete::updateConstraints()
void LLPanelEmojiComplete::updateScrollPos()
{
const size_t cntEmoji = mEmojis.size();
- if (0 == cntEmoji || cntEmoji < mVisibleEmojis || 0 == mCurSelected)
+ if (mNoScroll || 0 == cntEmoji || cntEmoji < mVisibleEmojis || 0 == mCurSelected)
{
mScrollPos = 0;
+ if (mCurSelected >= mVisibleEmojis)
+ {
+ mCurSelected = mVisibleEmojis ? mVisibleEmojis - 1 : 0;
+ }
}
else if (cntEmoji - 1 == mCurSelected)
{
@@ -273,11 +292,11 @@ BOOL LLFloaterEmojiComplete::handleKey(KEY key, MASK mask, BOOL called_from_pare
handled = true;
break;
}
-
}
if (handled)
return TRUE;
+
return LLFloater::handleKey(key, mask, called_from_parent);
}
diff --git a/indra/newview/llpanelemojicomplete.h b/indra/newview/llpanelemojicomplete.h
index aa0f806525..3456de4044 100644
--- a/indra/newview/llpanelemojicomplete.h
+++ b/indra/newview/llpanelemojicomplete.h
@@ -40,6 +40,7 @@ public:
struct Params : public LLInitParam::Block<Params, LLUICtrl::Params>
{
Optional<bool> autosize;
+ Optional<bool> noscroll;
Optional<S32> max_emoji,
padding;
@@ -50,6 +51,7 @@ public:
protected:
LLPanelEmojiComplete(const LLPanelEmojiComplete::Params&);
+
public:
virtual ~LLPanelEmojiComplete();
@@ -62,9 +64,13 @@ public:
void reshape(S32 width, S32 height, BOOL called_from_parent) override;
public:
+ const LLWString& getEmojis() const { return mEmojis; }
size_t getEmojiCount() const { return mEmojis.size(); }
- void setEmojiHint(const std::string& hint);
+ void setEmojis(const LLWString& emojis);
+ void setEmojiHint(const std::string& hint);
+
protected:
+ void LLPanelEmojiComplete::onEmojisChanged();
size_t posToIndex(S32 x, S32 y) const;
void select(size_t emoji_idx);
void selectNext();
@@ -76,13 +82,14 @@ protected:
protected:
static constexpr auto npos = std::numeric_limits<size_t>::max();
- bool mAutoSize = false;
+ const bool mAutoSize = false;
+ const bool mNoScroll = false;
const LLFontGL* mFont;
U16 mEmojiWidth = 0;
- size_t mMaxVisible = 0;
- S32 mPadding = 8;
+ const size_t mMaxVisible = 0;
+ const S32 mPadding = 8;
LLRect mRenderRect;
- LLUIImagePtr mSelectedImage;
+ const LLUIImagePtr mSelectedImage;
LLWString mEmojis;
size_t mVisibleEmojis = 0;