diff options
Diffstat (limited to 'indra/llui')
-rw-r--r-- | indra/llui/llemojidictionary.h | 2 | ||||
-rw-r--r-- | indra/llui/llemojihelper.cpp | 10 | ||||
-rw-r--r-- | indra/llui/llemojihelper.h | 6 | ||||
-rw-r--r-- | indra/llui/llscrolllistctrl.cpp | 2 | ||||
-rw-r--r-- | indra/llui/lltexteditor.cpp | 22 | ||||
-rw-r--r-- | indra/llui/lltexteditor.h | 3 |
6 files changed, 27 insertions, 18 deletions
diff --git a/indra/llui/llemojidictionary.h b/indra/llui/llemojidictionary.h index 46a61f1cd7..adc22ced58 100644 --- a/indra/llui/llemojidictionary.h +++ b/indra/llui/llemojidictionary.h @@ -61,6 +61,8 @@ public: const LLEmojiDescriptor* getDescriptorFromShortCode(const std::string& short_code) const; std::string getNameFromEmoji(llwchar ch) const; + const std::map<llwchar, const LLEmojiDescriptor*>& getEmoji2Descr() const { return mEmoji2Descr; } + private: void addEmoji(LLEmojiDescriptor&& descr); diff --git a/indra/llui/llemojihelper.cpp b/indra/llui/llemojihelper.cpp index 1e4c19a183..fb660a9e5b 100644 --- a/indra/llui/llemojihelper.cpp +++ b/indra/llui/llemojihelper.cpp @@ -82,12 +82,12 @@ bool LLEmojiHelper::isCursorInEmojiCode(const LLWString& wtext, S32 cursorPos, S return isShortCode; } -void LLEmojiHelper::showHelper(LLUICtrl* hostctrl_p, S32 local_x, S32 local_y, const std::string& short_code, std::function<void(LLWString)> cb) +void LLEmojiHelper::showHelper(LLUICtrl* hostctrl_p, S32 local_x, S32 local_y, const std::string& short_code, std::function<void(llwchar)> cb) { // Commit immediately if the user already typed a full shortcode if (const auto* emojiDescrp = LLEmojiDictionary::instance().getDescriptorFromShortCode(short_code)) { - cb(LLWString(1, emojiDescrp->Character)); + cb(emojiDescrp->Character); hideHelper(); return; } @@ -96,7 +96,7 @@ void LLEmojiHelper::showHelper(LLUICtrl* hostctrl_p, S32 local_x, S32 local_y, c { LLFloater* pHelperFloater = LLFloaterReg::getInstance(DEFAULT_EMOJI_HELPER_FLOATER); mHelperHandle = pHelperFloater->getHandle(); - mHelperCommitConn = pHelperFloater->setCommitCallback(std::bind([&](const LLSD& sdValue) { onCommitEmoji(utf8str_to_wstring(sdValue.asStringRef())); }, std::placeholders::_2)); + mHelperCommitConn = pHelperFloater->setCommitCallback(std::bind([&](const LLSD& sdValue) { onCommitEmoji(utf8str_to_wstring(sdValue.asStringRef())[0]); }, std::placeholders::_2)); } setHostCtrl(hostctrl_p); mEmojiCommitCb = cb; @@ -135,11 +135,11 @@ bool LLEmojiHelper::handleKey(const LLUICtrl* ctrl_p, KEY key, MASK mask) return mHelperHandle.get()->handleKey(key, mask, true); } -void LLEmojiHelper::onCommitEmoji(const LLWString& wstr) +void LLEmojiHelper::onCommitEmoji(llwchar emoji) { if (!mHostHandle.isDead() && mEmojiCommitCb) { - mEmojiCommitCb(wstr); + mEmojiCommitCb(emoji); } } diff --git a/indra/llui/llemojihelper.h b/indra/llui/llemojihelper.h index 63f5c640c9..58f68d12a4 100644 --- a/indra/llui/llemojihelper.h +++ b/indra/llui/llemojihelper.h @@ -44,12 +44,12 @@ public: std::string getToolTip(llwchar ch) const; bool isActive(const LLUICtrl* ctrl_p) const; static bool isCursorInEmojiCode(const LLWString& wtext, S32 cursor_pos, S32* short_code_pos_p = nullptr); - void showHelper(LLUICtrl* hostctrl_p, S32 local_x, S32 local_y, const std::string& short_code, std::function<void(LLWString)> commit_cb); + void showHelper(LLUICtrl* hostctrl_p, S32 local_x, S32 local_y, const std::string& short_code, std::function<void(llwchar)> commit_cb); void hideHelper(const LLUICtrl* ctrl_p = nullptr); // Eventing bool handleKey(const LLUICtrl* ctrl_p, KEY key, MASK mask); - void onCommitEmoji(const LLWString& wstr); + void onCommitEmoji(llwchar emoji); protected: LLUICtrl* getHostCtrl() const { return mHostHandle.get(); } @@ -60,5 +60,5 @@ private: LLHandle<LLFloater> mHelperHandle; boost::signals2::connection mHostCtrlFocusLostConn; boost::signals2::connection mHelperCommitConn; - std::function<void(LLWString)> mEmojiCommitCb; + std::function<void(llwchar)> mEmojiCommitCb; }; diff --git a/indra/llui/llscrolllistctrl.cpp b/indra/llui/llscrolllistctrl.cpp index 219667f766..2a6e8a6b76 100644 --- a/indra/llui/llscrolllistctrl.cpp +++ b/indra/llui/llscrolllistctrl.cpp @@ -411,7 +411,7 @@ void LLScrollListCtrl::clearRows() LLScrollListItem* LLScrollListCtrl::getFirstSelected() const { item_list::const_iterator iter; - for(iter = mItemList.begin(); iter != mItemList.end(); iter++) + for (iter = mItemList.begin(); iter != mItemList.end(); iter++) { LLScrollListItem* item = *iter; if (item->getSelected()) diff --git a/indra/llui/lltexteditor.cpp b/indra/llui/lltexteditor.cpp index a85ac2a5a3..95d8b666ab 100644 --- a/indra/llui/lltexteditor.cpp +++ b/indra/llui/lltexteditor.cpp @@ -680,18 +680,24 @@ void LLTextEditor::selectByCursorPosition(S32 prev_cursor_pos, S32 next_cursor_p endSelection(); } -void LLTextEditor::handleEmojiCommit(const LLWString& wstr) +void LLTextEditor::insertEmoji(llwchar emoji) { - LLWString wtext(getWText()); S32 shortCodePos; - if (LLEmojiHelper::isCursorInEmojiCode(wtext, mCursorPos, &shortCodePos)) + auto styleParams = LLStyle::Params(); + styleParams.font = LLFontGL::getFontEmoji(); + auto segment = new LLEmojiTextSegment(new LLStyle(styleParams), mCursorPos, mCursorPos + 1, *this); + insert(mCursorPos, LLWString(1, emoji), false, segment); + setCursorPos(mCursorPos + 1); +} + +void LLTextEditor::handleEmojiCommit(llwchar emoji) +{ + S32 shortCodePos; + if (LLEmojiHelper::isCursorInEmojiCode(getWText(), mCursorPos, &shortCodePos)) { remove(shortCodePos, mCursorPos - shortCodePos, true); + setCursorPos(shortCodePos); - auto styleParams = LLStyle::Params(); - styleParams.font = LLFontGL::getFontEmoji(); - insert(shortCodePos, wstr, false, new LLEmojiTextSegment(new LLStyle(styleParams), shortCodePos, shortCodePos + wstr.size(), *this)); - - setCursorPos(shortCodePos + 1); + insertEmoji(emoji); } } diff --git a/indra/llui/lltexteditor.h b/indra/llui/lltexteditor.h index dabd0460c6..f830732cb8 100644 --- a/indra/llui/lltexteditor.h +++ b/indra/llui/lltexteditor.h @@ -92,7 +92,8 @@ public: static S32 spacesPerTab(); - void handleEmojiCommit(const LLWString& wstr); + void insertEmoji(llwchar emoji); + void handleEmojiCommit(llwchar emoji); // mousehandler overrides virtual BOOL handleMouseDown(S32 x, S32 y, MASK mask); |