diff options
Diffstat (limited to 'indra/newview')
-rw-r--r-- | indra/newview/llpanelemojicomplete.cpp | 49 | ||||
-rw-r--r-- | indra/newview/llpanelemojicomplete.h | 17 | ||||
-rw-r--r-- | indra/newview/skins/default/xui/en/floater_emoji_complete.xml | 22 |
3 files changed, 72 insertions, 16 deletions
diff --git a/indra/newview/llpanelemojicomplete.cpp b/indra/newview/llpanelemojicomplete.cpp index e1d80b62e2..f6823befac 100644 --- a/indra/newview/llpanelemojicomplete.cpp +++ b/indra/newview/llpanelemojicomplete.cpp @@ -39,12 +39,18 @@ constexpr U32 MIN_MOUSE_MOVE_DELTA = 4; static LLDefaultChildRegistry::Register<LLPanelEmojiComplete> r("emoji_complete"); LLPanelEmojiComplete::Params::Params() - : selected_image("selected_image") + : autosize("autosize") + , max_emoji("max_emoji") + , padding("padding") + , selected_image("selected_image") { } LLPanelEmojiComplete::LLPanelEmojiComplete(const LLPanelEmojiComplete::Params& p) : LLUICtrl(p) + , mAutoSize(p.autosize) + , mMaxVisible(p.max_emoji) + , mPadding(p.padding) , mSelectedImage(p.selected_image) { setFont(p.font); @@ -125,9 +131,23 @@ void LLPanelEmojiComplete::reshape(S32 width, S32 height, BOOL called_from_paren void LLPanelEmojiComplete::setEmojiHint(const std::string& hint) { + llwchar curEmoji = (mCurSelected < mEmojis.size()) ? mEmojis.at(mCurSelected) : 0; + size_t curEmojiIdx = (curEmoji) ? mEmojis.find(curEmoji) : std::string::npos; + mEmojis = LLEmojiDictionary::instance().findMatchingEmojis(hint); + mCurSelected = (std::string::npos != curEmojiIdx) ? curEmojiIdx : 0; + + if (mAutoSize) + { + mVisibleEmojis = std::min(mEmojis.size(), mMaxVisible); + reshape(mVisibleEmojis * mEmojiWidth, getRect().getHeight(), false); + } + else + { + updateConstraints(); + } + mScrollPos = llmin(mScrollPos, mEmojis.size()); - updateConstraints(); } size_t LLPanelEmojiComplete::posToIndex(S32 x, S32 y) const @@ -200,11 +220,34 @@ LLFloaterEmojiComplete::LLFloaterEmojiComplete(const LLSD& sdKey) setFocusStealsFrontmost(false); setAutoFocus(false); setBackgroundVisible(false); + setIsChrome(true); } void LLFloaterEmojiComplete::onOpen(const LLSD& key) { - findChild<LLPanelEmojiComplete>("emoji_complete_ctrl")->setEmojiHint(key["hint"].asString()); + mEmojiCtrl->setEmojiHint(key["hint"].asString()); +} + +BOOL LLFloaterEmojiComplete::postBuild() +{ + mEmojiCtrl = findChild<LLPanelEmojiComplete>("emoji_complete_ctrl"); + mEmojiCtrlHorz = getRect().getWidth() - mEmojiCtrl->getRect().getWidth(); + + return TRUE; +} + +void LLFloaterEmojiComplete::reshape(S32 width, S32 height, BOOL called_from_parent) +{ + if (!called_from_parent) + { + LLRect rctFloater = getRect(), rctCtrl = mEmojiCtrl->getRect(); + rctFloater.mRight = rctFloater.mLeft + rctCtrl.getWidth() + mEmojiCtrlHorz; + setRect(rctFloater); + + return; + } + + LLFloater::reshape(width, height, called_from_parent); } // ============================================================================ diff --git a/indra/newview/llpanelemojicomplete.h b/indra/newview/llpanelemojicomplete.h index 85b0609ae9..b389ac9d53 100644 --- a/indra/newview/llpanelemojicomplete.h +++ b/indra/newview/llpanelemojicomplete.h @@ -39,6 +39,10 @@ class LLPanelEmojiComplete : public LLUICtrl public: struct Params : public LLInitParam::Block<Params, LLUICtrl::Params> { + Optional<bool> autosize; + Optional<S32> max_emoji, + padding; + Optional<LLUIImage*> selected_image; Params(); @@ -68,8 +72,12 @@ protected: protected: static constexpr auto npos = std::numeric_limits<size_t>::max(); + bool mAutoSize = false; const LLFontGL* mFont; U16 mEmojiWidth = 0; + size_t mMaxVisible = 0; + S32 mPadding = 8; + LLRect mRenderRect; LLUIImagePtr mSelectedImage; LLWString mEmojis; @@ -78,9 +86,6 @@ protected: size_t mScrollPos = 0; size_t mCurSelected = 0; LLVector2 mLastHover; - - S32 mPadding = 8; - LLRect mRenderRect; }; // ============================================================================ @@ -94,6 +99,12 @@ public: public: void onOpen(const LLSD& key) override; + BOOL postBuild() override; + void reshape(S32 width, S32 height, BOOL called_from_parent) override; + +protected: + LLPanelEmojiComplete* mEmojiCtrl = nullptr; + S32 mEmojiCtrlHorz = 0; }; // ============================================================================ diff --git a/indra/newview/skins/default/xui/en/floater_emoji_complete.xml b/indra/newview/skins/default/xui/en/floater_emoji_complete.xml index eb666bc32c..e9ea8f4de7 100644 --- a/indra/newview/skins/default/xui/en/floater_emoji_complete.xml +++ b/indra/newview/skins/default/xui/en/floater_emoji_complete.xml @@ -13,14 +13,16 @@ single_instance="true" width="240" > - <emoji_complete - height="30" - follows="top|left" - layout="topleft" - left="5" - top="5" - width="230" - name="emoji_complete_ctrl" - > - </emoji_complete> + <emoji_complete + autosize="true" + height="30" + follows="top|left" + layout="topleft" + left="5" + max_emoji="7" + name="emoji_complete_ctrl" + top="5" + width="230" + > + </emoji_complete> </floater> |