From d95571cf7cd319e17338bc509d46ab5eab4eb968 Mon Sep 17 00:00:00 2001 From: Kitty Barnett Date: Sun, 23 Oct 2022 16:10:06 +0200 Subject: Add mini emoji (auto-)complete helper --- indra/newview/llpanelemojicomplete.cpp | 210 +++++++++++++++++++++++++++++++++ 1 file changed, 210 insertions(+) create mode 100644 indra/newview/llpanelemojicomplete.cpp (limited to 'indra/newview/llpanelemojicomplete.cpp') diff --git a/indra/newview/llpanelemojicomplete.cpp b/indra/newview/llpanelemojicomplete.cpp new file mode 100644 index 0000000000..e1d80b62e2 --- /dev/null +++ b/indra/newview/llpanelemojicomplete.cpp @@ -0,0 +1,210 @@ +/** +* @file llpanelemojicomplete.h +* @brief Header file for LLPanelEmojiComplete +* +* $LicenseInfo:firstyear=2012&license=lgpl$ +* Second Life Viewer Source Code +* Copyright (C) 2011, Linden Research, Inc. +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; +* version 2.1 of the License only. +* +* This library is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +* +* Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA +* $/LicenseInfo$ +*/ + +#include "llviewerprecompiledheaders.h" + +#include "llemojidictionary.h" +#include "llpanelemojicomplete.h" +#include "lluictrlfactory.h" + +constexpr U32 MIN_MOUSE_MOVE_DELTA = 4; + +// ============================================================================ +// LLPanelEmojiComplete +// + +static LLDefaultChildRegistry::Register r("emoji_complete"); + +LLPanelEmojiComplete::Params::Params() + : selected_image("selected_image") +{ +} + +LLPanelEmojiComplete::LLPanelEmojiComplete(const LLPanelEmojiComplete::Params& p) + : LLUICtrl(p) + , mSelectedImage(p.selected_image) +{ + setFont(p.font); +} + +LLPanelEmojiComplete::~LLPanelEmojiComplete() +{ +} + +void LLPanelEmojiComplete::draw() +{ + if (!mEmojis.empty()) + { + const S32 centerY = mRenderRect.getCenterY(); + const size_t firstVisibleIdx = mScrollPos, lastVisibleIdx = llmin(mScrollPos + mVisibleEmojis, mEmojis.size()) - 1; + + if (mCurSelected >= firstVisibleIdx && mCurSelected <= lastVisibleIdx) + { + const S32 emoji_left = mRenderRect.mLeft + (mCurSelected - firstVisibleIdx) * mEmojiWidth; + const S32 emoji_height = mFont->getLineHeight() + mPadding; + mSelectedImage->draw(emoji_left, centerY - emoji_height / 2, mEmojiWidth, emoji_height); + } + + U32 left = mRenderRect.mLeft + mPadding; + for (U32 curIdx = firstVisibleIdx; curIdx <= lastVisibleIdx; curIdx++) + { + mFont->render( + mEmojis, curIdx, + left, centerY, + LLColor4::white, LLFontGL::LEFT, LLFontGL::VCENTER, LLFontGL::NORMAL, LLFontGL::DROP_SHADOW_SOFT, + 1, S32_MAX, nullptr, false, true); + left += mEmojiWidth; + } + } +} + +BOOL LLPanelEmojiComplete::handleHover(S32 x, S32 y, MASK mask) +{ + LLVector2 curHover(x, y); + if ((mLastHover - curHover).lengthSquared() > MIN_MOUSE_MOVE_DELTA) + { + mCurSelected = posToIndex(x, y); + mLastHover = curHover; + } + + return TRUE; +} + +BOOL LLPanelEmojiComplete::handleKey(KEY key, MASK mask, BOOL called_from_parent) +{ + if (MASK_NONE == mask) + { + bool handled = false; + switch (key) + { + case KEY_LEFT: + case KEY_UP: + selectPrevious(); + handled = true; + break; + case KEY_RIGHT: + case KEY_DOWN: + selectNext(); + handled = true; + break; + } + return handled; + } + + return false; +} + +void LLPanelEmojiComplete::reshape(S32 width, S32 height, BOOL called_from_parent) +{ + LLUICtrl::reshape(width, height, called_from_parent); + updateConstraints(); +} + +void LLPanelEmojiComplete::setEmojiHint(const std::string& hint) +{ + mEmojis = LLEmojiDictionary::instance().findMatchingEmojis(hint); + mScrollPos = llmin(mScrollPos, mEmojis.size()); + updateConstraints(); +} + +size_t LLPanelEmojiComplete::posToIndex(S32 x, S32 y) const +{ + if (mRenderRect.pointInRect(x, y)) + { + return llmin((size_t)x / mEmojiWidth, mEmojis.size() - 1); + } + return npos; +} + +void LLPanelEmojiComplete::select(size_t emoji_idx) +{ + mCurSelected = llclamp(emoji_idx, 0, mEmojis.size()); + updateScrollPos(); +} + +void LLPanelEmojiComplete::selectNext() +{ + select(mCurSelected + 1 < mEmojis.size() ? mCurSelected + 1 : 0); +} + +void LLPanelEmojiComplete::selectPrevious() +{ + select(mCurSelected - 1 >= 0 ? mCurSelected - 1 : mEmojis.size() - 1); +} + +void LLPanelEmojiComplete::setFont(const LLFontGL* fontp) +{ + mFont = fontp; + updateConstraints(); +} + +void LLPanelEmojiComplete::updateConstraints() +{ + const S32 ctrlWidth = getLocalRect().getWidth(); + + mEmojiWidth = mFont->getWidthF32(u8"\U0001F431") + mPadding * 2; + mVisibleEmojis = ctrlWidth / mEmojiWidth; + mRenderRect = getLocalRect().stretch((ctrlWidth - mVisibleEmojis * mEmojiWidth) / -2, 0); + + updateScrollPos(); +} + +void LLPanelEmojiComplete::updateScrollPos() +{ + const size_t cntEmoji = mEmojis.size(); + if (0 == cntEmoji || cntEmoji < mVisibleEmojis || 0 == mCurSelected) + { + mScrollPos = 0; + } + else if (cntEmoji - 1 == mCurSelected) + { + mScrollPos = mCurSelected - mVisibleEmojis + 1; + } + else + { + mScrollPos = mCurSelected - ((float)mCurSelected / (cntEmoji - 2) * (mVisibleEmojis - 2)); + } +} + +// ============================================================================ +// LLFloaterEmojiComplete +// + +LLFloaterEmojiComplete::LLFloaterEmojiComplete(const LLSD& sdKey) + : LLFloater(sdKey) +{ + // This floater should hover on top of our dependent (with the dependent having the focus) + setFocusStealsFrontmost(false); + setAutoFocus(false); + setBackgroundVisible(false); +} + +void LLFloaterEmojiComplete::onOpen(const LLSD& key) +{ + findChild("emoji_complete_ctrl")->setEmojiHint(key["hint"].asString()); +} + +// ============================================================================ -- cgit v1.3 From 90e272993bb4c591fd2a98772d7fe1104dbff921 Mon Sep 17 00:00:00 2001 From: Kitty Barnett Date: Sun, 23 Oct 2022 16:24:25 +0200 Subject: Autosize the mini emoji helper to fit the number of shown emojis --- indra/newview/llpanelemojicomplete.cpp | 49 ++++++++++++++++++++-- indra/newview/llpanelemojicomplete.h | 17 ++++++-- .../default/xui/en/floater_emoji_complete.xml | 22 +++++----- 3 files changed, 72 insertions(+), 16 deletions(-) (limited to 'indra/newview/llpanelemojicomplete.cpp') 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 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("emoji_complete_ctrl")->setEmojiHint(key["hint"].asString()); + mEmojiCtrl->setEmojiHint(key["hint"].asString()); +} + +BOOL LLFloaterEmojiComplete::postBuild() +{ + mEmojiCtrl = findChild("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 { + Optional autosize; + Optional max_emoji, + padding; + Optional selected_image; Params(); @@ -68,8 +72,12 @@ protected: protected: static constexpr auto npos = std::numeric_limits::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" > - - + + -- cgit v1.3 From 58cdcd5dd23778c6fad9fa0da31b670ceff8eeeb Mon Sep 17 00:00:00 2001 From: Kitty Barnett Date: Sun, 23 Oct 2022 17:47:51 +0200 Subject: Handle return and escape in the mini emoji helper --- indra/llui/llemojihelper.cpp | 5 ++++ indra/llui/llemojihelper.h | 2 +- indra/newview/llpanelemojicomplete.cpp | 48 +++++++++++++++++++++++++++++++--- indra/newview/llpanelemojicomplete.h | 1 + 4 files changed, 51 insertions(+), 5 deletions(-) (limited to 'indra/newview/llpanelemojicomplete.cpp') diff --git a/indra/llui/llemojihelper.cpp b/indra/llui/llemojihelper.cpp index d4c31ee986..54c801ab7b 100644 --- a/indra/llui/llemojihelper.cpp +++ b/indra/llui/llemojihelper.cpp @@ -98,6 +98,11 @@ void LLEmojiHelper::showHelper(LLUICtrl* hostctrl_p, S32 local_x, S32 local_y, c void LLEmojiHelper::hideHelper(const LLUICtrl* ctrl_p) { + if (ctrl_p && !isActive(ctrl_p)) + { + return; + } + setHostCtrl(nullptr); } diff --git a/indra/llui/llemojihelper.h b/indra/llui/llemojihelper.h index 7ed042fc5f..63f5c640c9 100644 --- a/indra/llui/llemojihelper.h +++ b/indra/llui/llemojihelper.h @@ -45,7 +45,7 @@ public: 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 commit_cb); - void hideHelper(const LLUICtrl* ctrl_p); + void hideHelper(const LLUICtrl* ctrl_p = nullptr); // Eventing bool handleKey(const LLUICtrl* ctrl_p, KEY key, MASK mask); diff --git a/indra/newview/llpanelemojicomplete.cpp b/indra/newview/llpanelemojicomplete.cpp index f6823befac..61b08ad48d 100644 --- a/indra/newview/llpanelemojicomplete.cpp +++ b/indra/newview/llpanelemojicomplete.cpp @@ -27,6 +27,7 @@ #include "llviewerprecompiledheaders.h" #include "llemojidictionary.h" +#include "llemojihelper.h" #include "llpanelemojicomplete.h" #include "lluictrlfactory.h" @@ -101,9 +102,9 @@ BOOL LLPanelEmojiComplete::handleHover(S32 x, S32 y, MASK mask) BOOL LLPanelEmojiComplete::handleKey(KEY key, MASK mask, BOOL called_from_parent) { + bool handled = false; if (MASK_NONE == mask) { - bool handled = false; switch (key) { case KEY_LEFT: @@ -116,11 +117,24 @@ BOOL LLPanelEmojiComplete::handleKey(KEY key, MASK mask, BOOL called_from_parent selectNext(); handled = true; break; + case KEY_RETURN: + if (!mEmojis.empty()) + { + LLWString wstr; + wstr.push_back(mEmojis.at(mCurSelected)); + setValue(wstring_to_utf8str(wstr)); + onCommit(); + handled = true; + } + break; } - return handled; } - return false; + if (handled) + { + return TRUE; + } + return LLUICtrl::handleKey(key, mask, called_from_parent); } void LLPanelEmojiComplete::reshape(S32 width, S32 height, BOOL called_from_parent) @@ -223,6 +237,26 @@ LLFloaterEmojiComplete::LLFloaterEmojiComplete(const LLSD& sdKey) setIsChrome(true); } +BOOL LLFloaterEmojiComplete::handleKey(KEY key, MASK mask, BOOL called_from_parent) +{ + bool handled = false; + if (MASK_NONE == mask) + { + switch (key) + { + case KEY_ESCAPE: + LLEmojiHelper::instance().hideHelper(); + handled = true; + break; + } + + } + + if (handled) + return TRUE; + return LLFloater::handleKey(key, mask, called_from_parent); +} + void LLFloaterEmojiComplete::onOpen(const LLSD& key) { mEmojiCtrl->setEmojiHint(key["hint"].asString()); @@ -231,9 +265,15 @@ void LLFloaterEmojiComplete::onOpen(const LLSD& key) BOOL LLFloaterEmojiComplete::postBuild() { mEmojiCtrl = findChild("emoji_complete_ctrl"); + mEmojiCtrl->setCommitCallback( + std::bind([&](const LLSD& sdValue) + { + setValue(sdValue); + onCommit(); + }, std::placeholders::_2)); mEmojiCtrlHorz = getRect().getWidth() - mEmojiCtrl->getRect().getWidth(); - return TRUE; + return LLFloater::postBuild(); } void LLFloaterEmojiComplete::reshape(S32 width, S32 height, BOOL called_from_parent) diff --git a/indra/newview/llpanelemojicomplete.h b/indra/newview/llpanelemojicomplete.h index b389ac9d53..361a2dc9b7 100644 --- a/indra/newview/llpanelemojicomplete.h +++ b/indra/newview/llpanelemojicomplete.h @@ -98,6 +98,7 @@ public: LLFloaterEmojiComplete(const LLSD& sdKey); public: + BOOL handleKey(KEY key, MASK mask, BOOL called_from_parent) override; void onOpen(const LLSD& key) override; BOOL postBuild() override; void reshape(S32 width, S32 height, BOOL called_from_parent) override; -- cgit v1.3 From cb0bb91108b628e1134f1f655eaca9d305961cda Mon Sep 17 00:00:00 2001 From: Kitty Barnett Date: Sun, 23 Oct 2022 17:51:22 +0200 Subject: Mini emoji helper shows as a small slice when there are no matching emojis --- indra/newview/llpanelemojicomplete.cpp | 4 ++++ indra/newview/llpanelemojicomplete.h | 3 ++- 2 files changed, 6 insertions(+), 1 deletion(-) (limited to 'indra/newview/llpanelemojicomplete.cpp') diff --git a/indra/newview/llpanelemojicomplete.cpp b/indra/newview/llpanelemojicomplete.cpp index 61b08ad48d..a7058a6724 100644 --- a/indra/newview/llpanelemojicomplete.cpp +++ b/indra/newview/llpanelemojicomplete.cpp @@ -260,6 +260,10 @@ BOOL LLFloaterEmojiComplete::handleKey(KEY key, MASK mask, BOOL called_from_pare void LLFloaterEmojiComplete::onOpen(const LLSD& key) { mEmojiCtrl->setEmojiHint(key["hint"].asString()); + if (0 == mEmojiCtrl->getEmojiCount()) + { + LLEmojiHelper::instance().hideHelper(); + } } BOOL LLFloaterEmojiComplete::postBuild() diff --git a/indra/newview/llpanelemojicomplete.h b/indra/newview/llpanelemojicomplete.h index 361a2dc9b7..138cc465ba 100644 --- a/indra/newview/llpanelemojicomplete.h +++ b/indra/newview/llpanelemojicomplete.h @@ -59,7 +59,8 @@ public: void reshape(S32 width, S32 height, BOOL called_from_parent) override; public: - void setEmojiHint(const std::string& hint); + size_t getEmojiCount() const { return mEmojis.size(); } + void setEmojiHint(const std::string& hint); protected: size_t posToIndex(S32 x, S32 y) const; void select(size_t emoji_idx); -- cgit v1.3 From 81dd143d0d901e8e5234cff01fbda246e4621628 Mon Sep 17 00:00:00 2001 From: Kitty Barnett Date: Tue, 8 Nov 2022 00:16:58 +0100 Subject: [FIXED] Various minor issues - Typing :+1: doesn't replace the short code with the thumbs-up emoji - Moving the mouse over the emoji complete panel highlights the wrong emoji when mScrollPos > 0 - Emoji complete panel is missing attributes - Crash when attempting to show the tooltip for an emoji text segment - Emoji autocomplete panel can sometimes show empty (type ':cat', select the heart eyed one, Ctrl-Z and then type 2 which should show the emoji for :cat2 but shows an empty square instead) --- indra/llui/llemojidictionary.cpp | 8 ++++---- indra/llui/llemojidictionary.h | 4 ++-- indra/llui/llemojihelper.cpp | 3 ++- indra/newview/llpanelemojicomplete.cpp | 4 ++-- indra/newview/skins/default/xui/en/widgets/emoji_complete.xml | 3 +++ 5 files changed, 13 insertions(+), 9 deletions(-) (limited to 'indra/newview/llpanelemojicomplete.cpp') diff --git a/indra/llui/llemojidictionary.cpp b/indra/llui/llemojidictionary.cpp index c31638b0bf..b70a9b2e7a 100644 --- a/indra/llui/llemojidictionary.cpp +++ b/indra/llui/llemojidictionary.cpp @@ -178,22 +178,22 @@ LLWString LLEmojiDictionary::findMatchingEmojis(const std::string& needle) const const LLEmojiDescriptor* LLEmojiDictionary::getDescriptorFromShortCode(const std::string& short_code) const { const auto it = mShortCode2Descr.find(short_code); - return (mShortCode2Descr.end() != it) ? &it->second : nullptr; + return (mShortCode2Descr.end() != it) ? it->second : nullptr; } std::string LLEmojiDictionary::getNameFromEmoji(llwchar ch) const { const auto it = mEmoji2Descr.find(ch); - return (mEmoji2Descr.end() != it) ? it->second.Name : LLStringUtil::null; + return (mEmoji2Descr.end() != it) ? it->second->Name : LLStringUtil::null; } void LLEmojiDictionary::addEmoji(LLEmojiDescriptor&& descr) { mEmojis.push_back(descr); - mEmoji2Descr.insert(std::make_pair(descr.Character, mEmojis.back())); + mEmoji2Descr.insert(std::make_pair(descr.Character, &mEmojis.back())); for (const std::string& shortCode : descr.ShortCodes) { - mShortCode2Descr.insert(std::make_pair(shortCode, mEmojis.back())); + mShortCode2Descr.insert(std::make_pair(shortCode, &mEmojis.back())); } } diff --git a/indra/llui/llemojidictionary.h b/indra/llui/llemojidictionary.h index 0cde663719..46a61f1cd7 100644 --- a/indra/llui/llemojidictionary.h +++ b/indra/llui/llemojidictionary.h @@ -66,8 +66,8 @@ private: private: std::list mEmojis; - std::map mEmoji2Descr; - std::map mShortCode2Descr; + std::map mEmoji2Descr; + std::map mShortCode2Descr; }; // ============================================================================ diff --git a/indra/llui/llemojihelper.cpp b/indra/llui/llemojihelper.cpp index 32471e59a8..1e4c19a183 100644 --- a/indra/llui/llemojihelper.cpp +++ b/indra/llui/llemojihelper.cpp @@ -57,7 +57,8 @@ bool LLEmojiHelper::isActive(const LLUICtrl* ctrl_p) const // static bool LLEmojiHelper::isCursorInEmojiCode(const LLWString& wtext, S32 cursorPos, S32* pShortCodePos) { - S32 shortCodePos = cursorPos; + // If the cursor is currently on a colon start the check one character further back + S32 shortCodePos = (cursorPos == 0 || L':' != wtext[cursorPos - 1]) ? cursorPos : cursorPos - 1; auto isPartOfShortcode = [](llwchar ch) { switch (ch) diff --git a/indra/newview/llpanelemojicomplete.cpp b/indra/newview/llpanelemojicomplete.cpp index a7058a6724..f890a14e8e 100644 --- a/indra/newview/llpanelemojicomplete.cpp +++ b/indra/newview/llpanelemojicomplete.cpp @@ -146,9 +146,9 @@ 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); + size_t curEmojiIdx = (curEmoji) ? mEmojis.find(curEmoji) : std::string::npos; mCurSelected = (std::string::npos != curEmojiIdx) ? curEmojiIdx : 0; if (mAutoSize) @@ -168,7 +168,7 @@ size_t LLPanelEmojiComplete::posToIndex(S32 x, S32 y) const { if (mRenderRect.pointInRect(x, y)) { - return llmin((size_t)x / mEmojiWidth, mEmojis.size() - 1); + return mScrollPos + llmin((size_t)x / mEmojiWidth, mEmojis.size() - 1); } return npos; } diff --git a/indra/newview/skins/default/xui/en/widgets/emoji_complete.xml b/indra/newview/skins/default/xui/en/widgets/emoji_complete.xml index f35105ff7e..370f1d174e 100644 --- a/indra/newview/skins/default/xui/en/widgets/emoji_complete.xml +++ b/indra/newview/skins/default/xui/en/widgets/emoji_complete.xml @@ -1,7 +1,10 @@ -- cgit v1.3 From 17a3924a28770e6910022ad8f627bb8e2b667730 Mon Sep 17 00:00:00 2001 From: Kitty Barnett Date: Tue, 8 Nov 2022 01:10:09 +0100 Subject: Add proper mouse down handler to the emoji complete panel -> the previous commit didn't properly set mFrontChild after restoring the topmost floaters -> additionally we don't want mouse clicks in "can't steal focus from frontmost" floaters to set focus to them --- indra/llui/llfloater.cpp | 23 ++++++++++++++--------- indra/newview/llpanelemojicomplete.cpp | 30 +++++++++++++++++++++++++++--- indra/newview/llpanelemojicomplete.h | 3 +++ 3 files changed, 44 insertions(+), 12 deletions(-) (limited to 'indra/newview/llpanelemojicomplete.cpp') diff --git a/indra/llui/llfloater.cpp b/indra/llui/llfloater.cpp index 04f6b11b7c..6f341bc0cd 100644 --- a/indra/llui/llfloater.cpp +++ b/indra/llui/llfloater.cpp @@ -2486,7 +2486,7 @@ void LLFloaterView::bringToFront(LLFloater* child, BOOL give_focus, BOOL restore if (mFrontChild == child) { - if (give_focus && !gFocusMgr.childHasKeyboardFocus(child)) + if (give_focus && child->canFocusStealFrontmost() && !gFocusMgr.childHasKeyboardFocus(child)) { child->setFocus(TRUE); } @@ -3042,24 +3042,29 @@ void LLFloaterView::syncFloaterTabOrder() if (mFrontChild != floaterp) { // Grab a list of the top floaters that want to stay on top of the focused floater - std::list listTop; + std::list listTop; if (mFrontChild && !mFrontChild->canFocusStealFrontmost()) { - for (LLView* childfloaterp : *getChildList()) + for (LLView* childp : *getChildList()) { - if (static_cast(childfloaterp)->canFocusStealFrontmost()) + LLFloater* child_floaterp = static_cast(childp); + if (child_floaterp->canFocusStealFrontmost()) break; - listTop.push_back(childfloaterp); + listTop.push_back(child_floaterp); } } bringToFront(floaterp, FALSE); // Restore top floaters - for (LLView* childp :listTop) - { - sendChildToFront(childp); - } + if (!listTop.empty()) + { + for (LLView* childp : listTop) + { + sendChildToFront(childp); + } + mFrontChild = listTop.back(); + } } break; diff --git a/indra/newview/llpanelemojicomplete.cpp b/indra/newview/llpanelemojicomplete.cpp index f890a14e8e..8b89e3aa14 100644 --- a/indra/newview/llpanelemojicomplete.cpp +++ b/indra/newview/llpanelemojicomplete.cpp @@ -120,9 +120,6 @@ BOOL LLPanelEmojiComplete::handleKey(KEY key, MASK mask, BOOL called_from_parent case KEY_RETURN: if (!mEmojis.empty()) { - LLWString wstr; - wstr.push_back(mEmojis.at(mCurSelected)); - setValue(wstring_to_utf8str(wstr)); onCommit(); handled = true; } @@ -137,6 +134,33 @@ BOOL LLPanelEmojiComplete::handleKey(KEY key, MASK mask, BOOL called_from_parent return LLUICtrl::handleKey(key, mask, called_from_parent); } +BOOL LLPanelEmojiComplete::handleMouseDown(S32 x, S32 y, MASK mask) +{ + mCurSelected = posToIndex(x, y); + mLastHover = LLVector2(x, y); + + return TRUE; +} + +BOOL LLPanelEmojiComplete::handleMouseUp(S32 x, S32 y, MASK mask) +{ + mCurSelected = posToIndex(x, y); + onCommit(); + + return TRUE; +} + +void LLPanelEmojiComplete::onCommit() +{ + if (npos != mCurSelected) + { + LLWString wstr; + wstr.push_back(mEmojis.at(mCurSelected)); + setValue(wstring_to_utf8str(wstr)); + LLUICtrl::onCommit(); + } +} + void LLPanelEmojiComplete::reshape(S32 width, S32 height, BOOL called_from_parent) { LLUICtrl::reshape(width, height, called_from_parent); diff --git a/indra/newview/llpanelemojicomplete.h b/indra/newview/llpanelemojicomplete.h index 138cc465ba..2116b350be 100644 --- a/indra/newview/llpanelemojicomplete.h +++ b/indra/newview/llpanelemojicomplete.h @@ -56,6 +56,9 @@ public: void draw() override; BOOL handleHover(S32 x, S32 y, MASK mask) override; BOOL handleKey(KEY key, MASK mask, BOOL called_from_parent) override; + BOOL handleMouseDown(S32 x, S32 y, MASK mask) override; + BOOL handleMouseUp(S32 x, S32 y, MASK mask) override; + void onCommit() override; void reshape(S32 width, S32 height, BOOL called_from_parent) override; public: -- cgit v1.3 From b9de65d2750c0f5632116864af792c40078830ab Mon Sep 17 00:00:00 2001 From: Alexander Gavriliuk Date: Tue, 29 Aug 2023 15:07:41 +0200 Subject: SL-20209 Add 'noscroll' parameter to LLPanelEmojiComplete::Params --- indra/newview/llpanelemojicomplete.cpp | 25 ++++++++++++++++++++++--- indra/newview/llpanelemojicomplete.h | 17 ++++++++++++----- 2 files changed, 34 insertions(+), 8 deletions(-) (limited to 'indra/newview/llpanelemojicomplete.cpp') 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 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 { Optional autosize; + Optional noscroll; Optional 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::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; -- cgit v1.3 From be655fef7f1f5717df73dedf84e84b73d246a0ec Mon Sep 17 00:00:00 2001 From: Alexander Gavriliuk Date: Tue, 3 Oct 2023 13:54:07 +0200 Subject: :x --- indra/llrender/llfontgl.cpp | 4 +- indra/llrender/llfontgl.h | 4 +- indra/llui/llemojihelper.cpp | 9 +- indra/newview/llpanelemojicomplete.cpp | 181 ++++++++++++++++----- indra/newview/llpanelemojicomplete.h | 13 +- .../default/xui/en/floater_emoji_complete.xml | 18 +- .../default/xui/en/widgets/emoji_complete.xml | 3 +- 7 files changed, 165 insertions(+), 67 deletions(-) (limited to 'indra/newview/llpanelemojicomplete.cpp') diff --git a/indra/llrender/llfontgl.cpp b/indra/llrender/llfontgl.cpp index 165d83992b..3e8185de77 100644 --- a/indra/llrender/llfontgl.cpp +++ b/indra/llrender/llfontgl.cpp @@ -423,7 +423,7 @@ S32 LLFontGL::render(const LLWString &text, S32 begin_offset, F32 x, F32 y, cons return render(text, begin_offset, x, y, color, LEFT, BASELINE, NORMAL, NO_SHADOW, S32_MAX, S32_MAX, NULL, FALSE); } -S32 LLFontGL::renderUTF8(const std::string &text, S32 begin_offset, F32 x, F32 y, const LLColor4 &color, HAlign halign, VAlign valign, U8 style, ShadowType shadow, S32 max_chars, S32 max_pixels, F32* right_x, BOOL use_ellipses, BOOL use_color) const +S32 LLFontGL::renderUTF8(const std::string &text, S32 begin_offset, F32 x, F32 y, const LLColor4 &color, HAlign halign, VAlign valign, U8 style, ShadowType shadow, S32 max_chars, S32 max_pixels, F32* right_x, BOOL use_ellipses, BOOL use_color) const { return render(utf8str_to_wstring(text), begin_offset, x, y, color, halign, valign, style, shadow, max_chars, max_pixels, right_x, use_ellipses, use_color); } @@ -488,7 +488,7 @@ F32 LLFontGL::getWidthF32(const llwchar* wchars) const return getWidthF32(wchars, 0, S32_MAX); } -F32 LLFontGL::getWidthF32(const std::string& utf8text, S32 begin_offset, S32 max_chars ) const +F32 LLFontGL::getWidthF32(const std::string& utf8text, S32 begin_offset, S32 max_chars) const { LLWString wtext = utf8str_to_wstring(utf8text); return getWidthF32(wtext.c_str(), begin_offset, max_chars); diff --git a/indra/llrender/llfontgl.h b/indra/llrender/llfontgl.h index 4d4f564033..c56dd96e00 100644 --- a/indra/llrender/llfontgl.h +++ b/indra/llrender/llfontgl.h @@ -135,12 +135,12 @@ public: S32 getWidth(const std::string& utf8text) const; S32 getWidth(const llwchar* wchars) const; - S32 getWidth(const std::string& utf8text, S32 offset, S32 max_chars ) const; + S32 getWidth(const std::string& utf8text, S32 offset, S32 max_chars) const; S32 getWidth(const llwchar* wchars, S32 offset, S32 max_chars) const; F32 getWidthF32(const std::string& utf8text) const; F32 getWidthF32(const llwchar* wchars) const; - F32 getWidthF32(const std::string& text, S32 offset, S32 max_chars ) const; + F32 getWidthF32(const std::string& text, S32 offset, S32 max_chars) const; F32 getWidthF32(const llwchar* wchars, S32 offset, S32 max_chars, bool no_padding = false) const; // The following are called often, frequently with large buffers, so do not use a string interface diff --git a/indra/llui/llemojihelper.cpp b/indra/llui/llemojihelper.cpp index 1d7744cb55..9411f7cac5 100644 --- a/indra/llui/llemojihelper.cpp +++ b/indra/llui/llemojihelper.cpp @@ -109,11 +109,12 @@ void LLEmojiHelper::showHelper(LLUICtrl* hostctrl_p, S32 local_x, S32 local_y, c } LLFloater* pHelperFloater = mHelperHandle.get(); - LLRect rct = pHelperFloater->getRect(); - rct.setLeftTopAndSize(floater_x - HELPER_FLOATER_OFFSET_X, floater_y - HELPER_FLOATER_OFFSET_Y + rct.getHeight(), rct.getWidth(), rct.getHeight()); - pHelperFloater->setRect(rct); + LLRect rect = pHelperFloater->getRect(); + S32 left = floater_x - HELPER_FLOATER_OFFSET_X; + S32 top = floater_y - HELPER_FLOATER_OFFSET_Y + rect.getHeight(); + rect.setLeftTopAndSize(left, top, rect.getWidth(), rect.getHeight()); + pHelperFloater->setRect(rect); pHelperFloater->openFloater(LLSD().with("hint", short_code)); - gFloaterView->adjustToFitScreen(pHelperFloater, FALSE); } void LLEmojiHelper::hideHelper(const LLUICtrl* ctrl_p) diff --git a/indra/newview/llpanelemojicomplete.cpp b/indra/newview/llpanelemojicomplete.cpp index 8fc84c0387..732531691b 100644 --- a/indra/newview/llpanelemojicomplete.cpp +++ b/indra/newview/llpanelemojicomplete.cpp @@ -32,6 +32,7 @@ #include "lluictrlfactory.h" constexpr U32 MIN_MOUSE_MOVE_DELTA = 4; +constexpr U32 MIN_SHORT_CODE_WIDTH = 100; // ============================================================================ // LLPanelEmojiComplete @@ -42,6 +43,7 @@ static LLDefaultChildRegistry::Register r("emoji_complete" LLPanelEmojiComplete::Params::Params() : autosize("autosize") , noscroll("noscroll") + , vertical("vertical") , max_emoji("max_emoji") , padding("padding") , selected_image("selected_image") @@ -52,11 +54,13 @@ LLPanelEmojiComplete::LLPanelEmojiComplete(const LLPanelEmojiComplete::Params& p : LLUICtrl(p) , mAutoSize(p.autosize) , mNoScroll(p.noscroll) + , mVertical(p.vertical) , mMaxVisible(p.max_emoji) , mPadding(p.padding) , mSelectedImage(p.selected_image) + , mIconFont(LLFontGL::getFontEmojiHuge()) + , mTextFont(LLFontGL::getFontSansSerifBig()) { - setFont(p.font); } LLPanelEmojiComplete::~LLPanelEmojiComplete() @@ -65,29 +69,61 @@ LLPanelEmojiComplete::~LLPanelEmojiComplete() void LLPanelEmojiComplete::draw() { - if (!mEmojis.empty()) - { - const S32 centerY = mRenderRect.getCenterY(); - const size_t firstVisibleIdx = mScrollPos, lastVisibleIdx = llmin(mScrollPos + mVisibleEmojis, mEmojis.size()) - 1; - - if (mCurSelected >= firstVisibleIdx && mCurSelected <= lastVisibleIdx) - { - const S32 emoji_left = mRenderRect.mLeft + (mCurSelected - firstVisibleIdx) * mEmojiWidth; - const S32 emoji_height = mFont->getLineHeight() + mPadding; - mSelectedImage->draw(emoji_left, centerY - emoji_height / 2, mEmojiWidth, emoji_height); - } - - U32 left = mRenderRect.mLeft + mPadding; - for (U32 curIdx = firstVisibleIdx; curIdx <= lastVisibleIdx; curIdx++) - { - mFont->render( - mEmojis, curIdx, - left, centerY, - LLColor4::white, LLFontGL::LEFT, LLFontGL::VCENTER, LLFontGL::NORMAL, LLFontGL::DROP_SHADOW_SOFT, - 1, S32_MAX, nullptr, false, true); - left += mEmojiWidth; - } - } + if (mEmojis.empty()) + return; + + const size_t firstVisibleIdx = mScrollPos; + const size_t lastVisibleIdx = llmin(mScrollPos + mVisibleEmojis, mEmojis.size()) - 1; + + if (mCurSelected >= firstVisibleIdx && mCurSelected <= lastVisibleIdx) + { + S32 x, y, width, height; + if (mVertical) + { + x = mRenderRect.mLeft; + y = mRenderRect.mTop - (mCurSelected - firstVisibleIdx + 1) * mEmojiHeight; + width = mRenderRect.getWidth(); + height = mEmojiHeight; + } + else + { + x = mRenderRect.mLeft + (mCurSelected - firstVisibleIdx) * mEmojiWidth; + y = mRenderRect.mBottom; + width = mEmojiWidth; + height = mRenderRect.getHeight(); + } + mSelectedImage->draw(x, y, width, height); + } + + S32 iconCenterX = mRenderRect.mLeft + mEmojiWidth / 2; + S32 iconCenterY = mRenderRect.mTop - mEmojiHeight / 2; + S32 textLeft = mVertical ? mRenderRect.mLeft + mEmojiWidth + mPadding : 0; + S32 textWidth = mVertical ? getRect().getWidth() - textLeft - mPadding : 0; + + for (U32 curIdx = firstVisibleIdx; curIdx <= lastVisibleIdx; curIdx++) + { + mIconFont->render(mEmojis, curIdx, iconCenterX, iconCenterY, + LLColor4::white, LLFontGL::HCENTER, LLFontGL::VCENTER, LLFontGL::NORMAL, + LLFontGL::DROP_SHADOW_SOFT, 1, S32_MAX, nullptr, false, true); + if (mVertical) + { + llwchar emoji = mEmojis[curIdx]; + auto& emoji2descr = LLEmojiDictionary::instance().getEmoji2Descr(); + auto it = emoji2descr.find(emoji); + if (it != emoji2descr.end()) + { + const std::string& shortCode = it->second->ShortCodes.front(); + mTextFont->renderUTF8(shortCode, 0, textLeft, iconCenterY, LLColor4::white, + LLFontGL::LEFT, LLFontGL::VCENTER, LLFontGL::NORMAL, LLFontGL::NO_SHADOW, + shortCode.size(), textWidth, NULL, FALSE, FALSE); + } + iconCenterY -= mEmojiHeight; + } + else + { + iconCenterX += mEmojiWidth; + } + } } BOOL LLPanelEmojiComplete::handleHover(S32 x, S32 y, MASK mask) @@ -182,18 +218,49 @@ void LLPanelEmojiComplete::setEmojiHint(const std::string& hint) llwchar curEmoji = (mCurSelected < mEmojis.size()) ? mEmojis.at(mCurSelected) : 0; mEmojis = LLEmojiDictionary::instance().findMatchingEmojis(hint); - size_t curEmojiIdx = (curEmoji) ? mEmojis.find(curEmoji) : std::string::npos; + size_t curEmojiIdx = curEmoji ? mEmojis.find(curEmoji) : std::string::npos; mCurSelected = (std::string::npos != curEmojiIdx) ? curEmojiIdx : 0; onEmojisChanged(); } +U32 LLPanelEmojiComplete::getMaxShortCodeWidth() const +{ + U32 max_width = 0; + auto& emoji2descr = LLEmojiDictionary::instance().getEmoji2Descr(); + for (llwchar emoji : mEmojis) + { + auto it = emoji2descr.find(emoji); + if (it != emoji2descr.end()) + { + const std::string& shortCode = it->second->ShortCodes.front(); + S32 width = mTextFont->getWidth(shortCode); + if (width > max_width) + { + max_width = width; + } + } + } + return max_width; +} + void LLPanelEmojiComplete::onEmojisChanged() { if (mAutoSize) { mVisibleEmojis = std::min(mEmojis.size(), mMaxVisible); - reshape(mVisibleEmojis * mEmojiWidth, getRect().getHeight(), false); + if (mVertical) + { + U32 maxShortCodeWidth = getMaxShortCodeWidth(); + U32 shortCodeWidth = std::max(maxShortCodeWidth, MIN_SHORT_CODE_WIDTH); + S32 width = mEmojiWidth + shortCodeWidth + mPadding * 2; + reshape(width, mVisibleEmojis * mEmojiHeight, false); + } + else + { + S32 height = getRect().getHeight(); + reshape(mVisibleEmojis * mEmojiWidth, height, false); + } } else { @@ -207,7 +274,8 @@ size_t LLPanelEmojiComplete::posToIndex(S32 x, S32 y) const { if (mRenderRect.pointInRect(x, y)) { - return mScrollPos + llmin((size_t)x / mEmojiWidth, mEmojis.size() - 1); + U32 pos = mVertical ? (U32)(mRenderRect.mTop - y) / mEmojiHeight : x / mEmojiWidth; + return mScrollPos + llmin((size_t)pos, mEmojis.size() - 1); } return npos; } @@ -228,21 +296,32 @@ void LLPanelEmojiComplete::selectPrevious() select(mCurSelected - 1 >= 0 ? mCurSelected - 1 : mEmojis.size() - 1); } -void LLPanelEmojiComplete::setFont(const LLFontGL* fontp) -{ - mFont = fontp; - updateConstraints(); -} - void LLPanelEmojiComplete::updateConstraints() { - const S32 ctrlWidth = getLocalRect().getWidth(); - - mEmojiWidth = mFont->getWidthF32(u8"\U0001F431") + mPadding * 2; - mVisibleEmojis = ctrlWidth / mEmojiWidth; - mRenderRect = getLocalRect().stretch((ctrlWidth - mVisibleEmojis * mEmojiWidth) / -2, 0); - - updateScrollPos(); + mRenderRect = getLocalRect(); + S32 ctrlWidth = mRenderRect.getWidth(); + S32 ctrlHeight = mRenderRect.getHeight(); + + mEmojiHeight = mIconFont->getLineHeight() + mPadding * 2; + mEmojiWidth = mIconFont->getWidthF32(u8"\U0001F431") + mPadding * 2; + if (mVertical) + { + mVisibleEmojis = ctrlHeight / mEmojiHeight; + mRenderRect.mBottom = mRenderRect.mTop - mVisibleEmojis * mEmojiHeight; + } + else + { + mVisibleEmojis = ctrlWidth / mEmojiWidth; + S32 padding = (ctrlWidth - mVisibleEmojis * mEmojiWidth) / 2; + mRenderRect.mLeft += padding; + mRenderRect.mRight -= padding; + if (mEmojiHeight > ctrlHeight) + { + mEmojiHeight = ctrlHeight; + } + } + + updateScrollPos(); } void LLPanelEmojiComplete::updateScrollPos() @@ -302,11 +381,23 @@ BOOL LLFloaterEmojiComplete::handleKey(KEY key, MASK mask, BOOL called_from_pare void LLFloaterEmojiComplete::onOpen(const LLSD& key) { - mEmojiCtrl->setEmojiHint(key["hint"].asString()); - if (0 == mEmojiCtrl->getEmojiCount()) - { - LLEmojiHelper::instance().hideHelper(); - } + mEmojiCtrl->setEmojiHint(key["hint"].asString()); + if (0 == mEmojiCtrl->getEmojiCount()) + { + LLEmojiHelper::instance().hideHelper(); + return; + } + + if (mEmojiCtrl->isAutoSize()) + { + LLRect outer_rect = getRect(); + const LLRect& inner_rect = mEmojiCtrl->getRect(); + outer_rect.mTop = outer_rect.mBottom + inner_rect.mBottom * 2 + inner_rect.getHeight(); + outer_rect.mRight = outer_rect.mLeft + inner_rect.mLeft * 2 + inner_rect.getWidth(); + setRect(outer_rect); + } + + gFloaterView->adjustToFitScreen(this, FALSE); } BOOL LLFloaterEmojiComplete::postBuild() diff --git a/indra/newview/llpanelemojicomplete.h b/indra/newview/llpanelemojicomplete.h index 02104efbcb..20d3413765 100644 --- a/indra/newview/llpanelemojicomplete.h +++ b/indra/newview/llpanelemojicomplete.h @@ -41,6 +41,7 @@ public: { Optional autosize; Optional noscroll; + Optional vertical; Optional max_emoji, padding; @@ -68,6 +69,8 @@ public: size_t getEmojiCount() const { return mEmojis.size(); } void setEmojis(const LLWString& emojis); void setEmojiHint(const std::string& hint); + bool isAutoSize() const { return mAutoSize; } + U32 getMaxShortCodeWidth() const; protected: void onEmojisChanged(); @@ -75,7 +78,6 @@ protected: void select(size_t emoji_idx); void selectNext(); void selectPrevious(); - void setFont(const LLFontGL* fontp); void updateConstraints(); void updateScrollPos(); @@ -84,14 +86,17 @@ protected: const bool mAutoSize = false; const bool mNoScroll = false; - const LLFontGL* mFont; - U16 mEmojiWidth = 0; + const bool mVertical = false; const size_t mMaxVisible = 0; const S32 mPadding = 8; - LLRect mRenderRect; const LLUIImagePtr mSelectedImage; + const LLFontGL* mIconFont; + const LLFontGL* mTextFont; LLWString mEmojis; + LLRect mRenderRect; + U16 mEmojiWidth = 0; + U16 mEmojiHeight = 0; size_t mVisibleEmojis = 0; size_t mFirstVisible = 0; size_t mScrollPos = 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 e9ea8f4de7..207a8af118 100644 --- a/indra/newview/skins/default/xui/en/floater_emoji_complete.xml +++ b/indra/newview/skins/default/xui/en/floater_emoji_complete.xml @@ -1,5 +1,8 @@ diff --git a/indra/newview/skins/default/xui/en/widgets/emoji_complete.xml b/indra/newview/skins/default/xui/en/widgets/emoji_complete.xml index 370f1d174e..f9db441815 100644 --- a/indra/newview/skins/default/xui/en/widgets/emoji_complete.xml +++ b/indra/newview/skins/default/xui/en/widgets/emoji_complete.xml @@ -1,10 +1,9 @@ -- cgit v1.3 From 9f8763cae1ccb3577a2cd148ffc5cee564a2df65 Mon Sep 17 00:00:00 2001 From: Alexander Gavriliuk Date: Wed, 4 Oct 2023 22:30:48 +0200 Subject: SL-20402 Emoji Completion floater - use vertical scrollbar when needed --- indra/llui/llscrollbar.cpp | 6 +- indra/newview/llpanelemojicomplete.cpp | 449 +++++++++++++-------- indra/newview/llpanelemojicomplete.h | 125 +++--- .../default/xui/en/floater_emoji_complete.xml | 6 +- .../skins/default/xui/en/floater_im_session.xml | 2 +- .../default/xui/en/widgets/emoji_complete.xml | 2 +- 6 files changed, 350 insertions(+), 240 deletions(-) (limited to 'indra/newview/llpanelemojicomplete.cpp') diff --git a/indra/llui/llscrollbar.cpp b/indra/llui/llscrollbar.cpp index fde6de4921..d5d0d97b55 100644 --- a/indra/llui/llscrollbar.cpp +++ b/indra/llui/llscrollbar.cpp @@ -475,13 +475,15 @@ void LLScrollbar::reshape(S32 width, S32 height, BOOL called_from_parent) { up_button->reshape(up_button->getRect().getWidth(), llmin(getRect().getHeight() / 2, mThickness)); down_button->reshape(down_button->getRect().getWidth(), llmin(getRect().getHeight() / 2, mThickness)); - up_button->setOrigin(up_button->getRect().mLeft, getRect().getHeight() - up_button->getRect().getHeight()); + up_button->setOrigin(0, getRect().getHeight() - up_button->getRect().getHeight()); + down_button->setOrigin(0, 0); } else { up_button->reshape(llmin(getRect().getWidth() / 2, mThickness), up_button->getRect().getHeight()); down_button->reshape(llmin(getRect().getWidth() / 2, mThickness), down_button->getRect().getHeight()); - down_button->setOrigin(getRect().getWidth() - down_button->getRect().getWidth(), down_button->getRect().mBottom); + up_button->setOrigin(0, 0); + down_button->setOrigin(getRect().getWidth() - down_button->getRect().getWidth(), 0); } updateThumbRect(); } diff --git a/indra/newview/llpanelemojicomplete.cpp b/indra/newview/llpanelemojicomplete.cpp index 732531691b..b03f16899e 100644 --- a/indra/newview/llpanelemojicomplete.cpp +++ b/indra/newview/llpanelemojicomplete.cpp @@ -29,10 +29,12 @@ #include "llemojidictionary.h" #include "llemojihelper.h" #include "llpanelemojicomplete.h" +#include "llscrollbar.h" #include "lluictrlfactory.h" constexpr U32 MIN_MOUSE_MOVE_DELTA = 4; constexpr U32 MIN_SHORT_CODE_WIDTH = 100; +constexpr U32 DEF_PADDING = 8; // ============================================================================ // LLPanelEmojiComplete @@ -41,26 +43,35 @@ constexpr U32 MIN_SHORT_CODE_WIDTH = 100; static LLDefaultChildRegistry::Register r("emoji_complete"); LLPanelEmojiComplete::Params::Params() - : autosize("autosize") - , noscroll("noscroll") - , vertical("vertical") - , max_emoji("max_emoji") - , padding("padding") - , selected_image("selected_image") + : autosize("autosize") + , noscroll("noscroll") + , vertical("vertical") + , max_visible("max_visible") + , padding("padding", DEF_PADDING) + , selected_image("selected_image") { } LLPanelEmojiComplete::LLPanelEmojiComplete(const LLPanelEmojiComplete::Params& p) - : LLUICtrl(p) - , mAutoSize(p.autosize) - , mNoScroll(p.noscroll) - , mVertical(p.vertical) - , mMaxVisible(p.max_emoji) - , mPadding(p.padding) - , mSelectedImage(p.selected_image) - , mIconFont(LLFontGL::getFontEmojiHuge()) - , mTextFont(LLFontGL::getFontSansSerifBig()) + : LLUICtrl(p) + , mAutoSize(p.autosize) + , mNoScroll(p.noscroll) + , mVertical(p.vertical) + , mMaxVisible(p.max_visible) + , mPadding(p.padding) + , mSelectedImage(p.selected_image) + , mIconFont(LLFontGL::getFontEmojiHuge()) + , mTextFont(LLFontGL::getFontSansSerifBig()) + , mScrollbar(nullptr) { + if (mVertical) + { + LLScrollbar::Params sbparams; + sbparams.orientation(LLScrollbar::VERTICAL); + sbparams.change_callback([this](S32 index, LLScrollbar*) { onScrollbarChange(index); }); + mScrollbar = LLUICtrlFactory::create(sbparams); + addChild(mScrollbar); + } } LLPanelEmojiComplete::~LLPanelEmojiComplete() @@ -69,13 +80,15 @@ LLPanelEmojiComplete::~LLPanelEmojiComplete() void LLPanelEmojiComplete::draw() { + LLUICtrl::draw(); + if (mEmojis.empty()) return; const size_t firstVisibleIdx = mScrollPos; - const size_t lastVisibleIdx = llmin(mScrollPos + mVisibleEmojis, mEmojis.size()) - 1; + const size_t lastVisibleIdx = llmin(mScrollPos + mVisibleEmojis, mTotalEmojis); - if (mCurSelected >= firstVisibleIdx && mCurSelected <= lastVisibleIdx) + if (mCurSelected >= firstVisibleIdx && mCurSelected < lastVisibleIdx) { S32 x, y, width, height; if (mVertical) @@ -100,7 +113,7 @@ void LLPanelEmojiComplete::draw() S32 textLeft = mVertical ? mRenderRect.mLeft + mEmojiWidth + mPadding : 0; S32 textWidth = mVertical ? getRect().getWidth() - textLeft - mPadding : 0; - for (U32 curIdx = firstVisibleIdx; curIdx <= lastVisibleIdx; curIdx++) + for (U32 curIdx = firstVisibleIdx; curIdx < lastVisibleIdx; curIdx++) { mIconFont->render(mEmojis, curIdx, iconCenterX, iconCenterY, LLColor4::white, LLFontGL::HCENTER, LLFontGL::VCENTER, LLFontGL::NORMAL, @@ -128,100 +141,154 @@ void LLPanelEmojiComplete::draw() BOOL LLPanelEmojiComplete::handleHover(S32 x, S32 y, MASK mask) { - LLVector2 curHover(x, y); - if ((mLastHover - curHover).lengthSquared() > MIN_MOUSE_MOVE_DELTA) - { - mCurSelected = posToIndex(x, y); - mLastHover = curHover; - } - - return TRUE; + if (mScrollbar && mScrollbar->getVisible() && childrenHandleHover(x, y, mask)) + return TRUE; + + LLVector2 curHover(x, y); + if ((mLastHover - curHover).lengthSquared() > MIN_MOUSE_MOVE_DELTA) + { + size_t index = posToIndex(x, y); + if (index < mTotalEmojis) + mCurSelected = index; + mLastHover = curHover; + } + + return TRUE; } BOOL LLPanelEmojiComplete::handleKey(KEY key, MASK mask, BOOL called_from_parent) { - bool handled = false; - if (MASK_NONE == mask) - { - switch (key) - { - case KEY_LEFT: - case KEY_UP: - selectPrevious(); - handled = true; - break; - case KEY_RIGHT: - case KEY_DOWN: - selectNext(); - handled = true; - break; - case KEY_RETURN: - if (!mEmojis.empty()) - { - onCommit(); - handled = true; - } - break; - } - } - - if (handled) - { - return TRUE; - } - return LLUICtrl::handleKey(key, mask, called_from_parent); + bool handled = false; + if (mTotalEmojis && MASK_NONE == mask) + { + switch (key) + { + case KEY_HOME: + select(0); + handled = true; + break; + + case KEY_END: + select(mTotalEmojis - 1); + handled = true; + break; + + case KEY_PAGE_DOWN: + select(mCurSelected + mVisibleEmojis - 1); + handled = true; + break; + + case KEY_PAGE_UP: + select(mCurSelected - llmin(mCurSelected, mVisibleEmojis + 1)); + handled = true; + break; + + case KEY_LEFT: + case KEY_UP: + selectPrevious(); + handled = true; + break; + + case KEY_RIGHT: + case KEY_DOWN: + selectNext(); + handled = true; + break; + + case KEY_RETURN: + onCommit(); + handled = true; + break; + } + } + + if (handled) + { + return TRUE; + } + + return LLUICtrl::handleKey(key, mask, called_from_parent); } BOOL LLPanelEmojiComplete::handleMouseDown(S32 x, S32 y, MASK mask) { - mCurSelected = posToIndex(x, y); - mLastHover = LLVector2(x, y); + if (mScrollbar && mScrollbar->getVisible() && childrenHandleMouseDown(x, y, mask)) + return TRUE; + + mCurSelected = posToIndex(x, y); + mLastHover = LLVector2(x, y); - return TRUE; + return TRUE; } BOOL LLPanelEmojiComplete::handleMouseUp(S32 x, S32 y, MASK mask) { - mCurSelected = posToIndex(x, y); - onCommit(); + if (mScrollbar && mScrollbar->getVisible() && childrenHandleMouseUp(x, y, mask)) + return TRUE; + + mCurSelected = posToIndex(x, y); + onCommit(); + + return TRUE; +} + +BOOL LLPanelEmojiComplete::handleScrollWheel(S32 x, S32 y, S32 clicks) +{ + if (mNoScroll) + return FALSE; - return TRUE; + if (mScrollbar && mScrollbar->getVisible() && mScrollbar->handleScrollWheel(x, y, clicks)) + { + mCurSelected = posToIndex(x, y); + return TRUE; + } + + if (mTotalEmojis > mVisibleEmojis) + { + mScrollPos = llclamp(mScrollPos + clicks, 0, mTotalEmojis - mVisibleEmojis); + mCurSelected = posToIndex(x, y); + return TRUE; + } + + return FALSE; } void LLPanelEmojiComplete::onCommit() { - if (mCurSelected < mEmojis.size()) - { - LLWString wstr; - wstr.push_back(mEmojis.at(mCurSelected)); - setValue(wstring_to_utf8str(wstr)); - LLUICtrl::onCommit(); - } + if (mCurSelected < mTotalEmojis) + { + LLWString wstr; + wstr.push_back(mEmojis.at(mCurSelected)); + setValue(wstring_to_utf8str(wstr)); + LLUICtrl::onCommit(); + } } void LLPanelEmojiComplete::reshape(S32 width, S32 height, BOOL called_from_parent) { - LLUICtrl::reshape(width, height, called_from_parent); - updateConstraints(); + LLUICtrl::reshape(width, height, called_from_parent); + updateConstraints(); } void LLPanelEmojiComplete::setEmojis(const LLWString& emojis) { - mEmojis = emojis; - mCurSelected = 0; + mEmojis = emojis; + mTotalEmojis = mEmojis.size(); + mCurSelected = 0; - onEmojisChanged(); + onEmojisChanged(); } void LLPanelEmojiComplete::setEmojiHint(const std::string& hint) { - llwchar curEmoji = (mCurSelected < mEmojis.size()) ? mEmojis.at(mCurSelected) : 0; + llwchar curEmoji = mCurSelected < mTotalEmojis ? mEmojis.at(mCurSelected) : 0; - mEmojis = LLEmojiDictionary::instance().findMatchingEmojis(hint); - size_t curEmojiIdx = curEmoji ? mEmojis.find(curEmoji) : std::string::npos; - mCurSelected = (std::string::npos != curEmojiIdx) ? curEmojiIdx : 0; + mEmojis = LLEmojiDictionary::instance().findMatchingEmojis(hint); + mTotalEmojis = mEmojis.size(); + size_t curEmojiIdx = curEmoji ? mEmojis.find(curEmoji) : std::string::npos; + mCurSelected = std::string::npos != curEmojiIdx ? curEmojiIdx : 0; - onEmojisChanged(); + onEmojisChanged(); } U32 LLPanelEmojiComplete::getMaxShortCodeWidth() const @@ -246,79 +313,104 @@ U32 LLPanelEmojiComplete::getMaxShortCodeWidth() const void LLPanelEmojiComplete::onEmojisChanged() { - if (mAutoSize) - { - mVisibleEmojis = std::min(mEmojis.size(), mMaxVisible); + if (mAutoSize) + { + S32 width, height; + mVisibleEmojis = llmin(mTotalEmojis, mMaxVisible); if (mVertical) { U32 maxShortCodeWidth = getMaxShortCodeWidth(); - U32 shortCodeWidth = std::max(maxShortCodeWidth, MIN_SHORT_CODE_WIDTH); - S32 width = mEmojiWidth + shortCodeWidth + mPadding * 2; - reshape(width, mVisibleEmojis * mEmojiHeight, false); + U32 shortCodeWidth = llmax(maxShortCodeWidth, MIN_SHORT_CODE_WIDTH); + width = mEmojiWidth + shortCodeWidth + mPadding * 2; + if (!mNoScroll && mVisibleEmojis < mTotalEmojis) + { + width += mScrollbar->getThickness(); + } + height = mVisibleEmojis * mEmojiHeight; } else { - S32 height = getRect().getHeight(); - reshape(mVisibleEmojis * mEmojiWidth, height, false); + width = mVisibleEmojis * mEmojiWidth; + height = getRect().getHeight(); } - } - else - { - updateConstraints(); - } + LLUICtrl::reshape(width, height, false); + } + else + { + mVisibleEmojis = mVertical ? getRect().getHeight() / mEmojiHeight : getRect().getWidth() / mEmojiWidth; + } - mScrollPos = llmin(mScrollPos, mEmojis.size()); + updateConstraints(); +} + +void LLPanelEmojiComplete::onScrollbarChange(S32 index) +{ + mScrollPos = llclamp(index, 0, mTotalEmojis - mVisibleEmojis); } size_t LLPanelEmojiComplete::posToIndex(S32 x, S32 y) const { - if (mRenderRect.pointInRect(x, y)) - { - U32 pos = mVertical ? (U32)(mRenderRect.mTop - y) / mEmojiHeight : x / mEmojiWidth; - return mScrollPos + llmin((size_t)pos, mEmojis.size() - 1); - } - return npos; + if (mRenderRect.pointInRect(x, y)) + { + U32 pos = mVertical ? (U32)(mRenderRect.mTop - y) / mEmojiHeight : x / mEmojiWidth; + return llmin(mScrollPos + pos, mTotalEmojis - 1); + } + return std::string::npos; } void LLPanelEmojiComplete::select(size_t emoji_idx) { - mCurSelected = llclamp(emoji_idx, 0, mEmojis.size()); - updateScrollPos(); + mCurSelected = llclamp(emoji_idx, 0, mTotalEmojis - 1); + + updateScrollPos(); } void LLPanelEmojiComplete::selectNext() { - select(mCurSelected + 1 < mEmojis.size() ? mCurSelected + 1 : 0); + if (!mTotalEmojis) + return; + + mCurSelected = (mCurSelected < mTotalEmojis - 1) ? mCurSelected + 1 : 0; + + updateScrollPos(); } void LLPanelEmojiComplete::selectPrevious() { - select(mCurSelected - 1 >= 0 ? mCurSelected - 1 : mEmojis.size() - 1); + if (!mTotalEmojis) + return; + + mCurSelected = (mCurSelected && mCurSelected < mTotalEmojis) ? mCurSelected - 1 : mTotalEmojis - 1; + + updateScrollPos(); } void LLPanelEmojiComplete::updateConstraints() { mRenderRect = getLocalRect(); - S32 ctrlWidth = mRenderRect.getWidth(); - S32 ctrlHeight = mRenderRect.getHeight(); - mEmojiHeight = mIconFont->getLineHeight() + mPadding * 2; mEmojiWidth = mIconFont->getWidthF32(u8"\U0001F431") + mPadding * 2; if (mVertical) { - mVisibleEmojis = ctrlHeight / mEmojiHeight; - mRenderRect.mBottom = mRenderRect.mTop - mVisibleEmojis * mEmojiHeight; + mEmojiHeight = mIconFont->getLineHeight() + mPadding * 2; + if (!mNoScroll && mVisibleEmojis < mTotalEmojis) + { + mRenderRect.mRight -= mScrollbar->getThickness(); + mScrollbar->setDocSize(mTotalEmojis); + mScrollbar->setPageSize(mVisibleEmojis); + mScrollbar->setOrigin(mRenderRect.mRight, 0); + mScrollbar->reshape(mScrollbar->getThickness(), mRenderRect.mTop, TRUE); + mScrollbar->setVisible(TRUE); + } + else + { + mScrollbar->setVisible(FALSE); + } } else { - mVisibleEmojis = ctrlWidth / mEmojiWidth; - S32 padding = (ctrlWidth - mVisibleEmojis * mEmojiWidth) / 2; - mRenderRect.mLeft += padding; - mRenderRect.mRight -= padding; - if (mEmojiHeight > ctrlHeight) - { - mEmojiHeight = ctrlHeight; - } + mEmojiHeight = mRenderRect.getHeight(); + mRenderRect.stretch((mRenderRect.getWidth() - mVisibleEmojis * mEmojiWidth) / -2, 0); } updateScrollPos(); @@ -326,23 +418,27 @@ void LLPanelEmojiComplete::updateConstraints() void LLPanelEmojiComplete::updateScrollPos() { - const size_t cntEmoji = mEmojis.size(); - if (mNoScroll || 0 == cntEmoji || cntEmoji < mVisibleEmojis || 0 == mCurSelected) - { - mScrollPos = 0; - if (mCurSelected >= mVisibleEmojis) - { - mCurSelected = mVisibleEmojis ? mVisibleEmojis - 1 : 0; - } - } - else if (cntEmoji - 1 == mCurSelected) - { - mScrollPos = mCurSelected - mVisibleEmojis + 1; - } - else - { - mScrollPos = mCurSelected - ((float)mCurSelected / (cntEmoji - 2) * (mVisibleEmojis - 2)); - } + if (mNoScroll || 0 == mTotalEmojis || mTotalEmojis < mVisibleEmojis || 0 == mCurSelected) + { + mScrollPos = 0; + if (mCurSelected >= mVisibleEmojis) + { + mCurSelected = mVisibleEmojis ? mVisibleEmojis - 1 : 0; + } + } + else if (mTotalEmojis - 1 == mCurSelected) + { + mScrollPos = mTotalEmojis - mVisibleEmojis; + } + else + { + mScrollPos = mCurSelected - ((float)mCurSelected / (mTotalEmojis - 2) * (mVisibleEmojis - 2)); + } + + if (mScrollbar && mScrollbar->getVisible()) + { + mScrollbar->setDocPos(mScrollPos); + } } // ============================================================================ @@ -350,33 +446,33 @@ void LLPanelEmojiComplete::updateScrollPos() // LLFloaterEmojiComplete::LLFloaterEmojiComplete(const LLSD& sdKey) - : LLFloater(sdKey) + : LLFloater(sdKey) { - // This floater should hover on top of our dependent (with the dependent having the focus) - setFocusStealsFrontmost(false); - setAutoFocus(false); - setBackgroundVisible(false); - setIsChrome(true); + // This floater should hover on top of our dependent (with the dependent having the focus) + setFocusStealsFrontmost(false); + setAutoFocus(false); + setBackgroundVisible(false); + setIsChrome(true); } BOOL LLFloaterEmojiComplete::handleKey(KEY key, MASK mask, BOOL called_from_parent) { - bool handled = false; - if (MASK_NONE == mask) - { - switch (key) - { - case KEY_ESCAPE: - LLEmojiHelper::instance().hideHelper(); - handled = true; - break; - } - } - - if (handled) - return TRUE; - - return LLFloater::handleKey(key, mask, called_from_parent); + bool handled = false; + if (MASK_NONE == mask) + { + switch (key) + { + case KEY_ESCAPE: + LLEmojiHelper::instance().hideHelper(); + handled = true; + break; + } + } + + if (handled) + return TRUE; + + return LLFloater::handleKey(key, mask, called_from_parent); } void LLFloaterEmojiComplete::onOpen(const LLSD& key) @@ -402,30 +498,33 @@ void LLFloaterEmojiComplete::onOpen(const LLSD& key) BOOL LLFloaterEmojiComplete::postBuild() { - mEmojiCtrl = findChild("emoji_complete_ctrl"); - mEmojiCtrl->setCommitCallback( - std::bind([&](const LLSD& sdValue) - { - setValue(sdValue); - onCommit(); - }, std::placeholders::_2)); - mEmojiCtrlHorz = getRect().getWidth() - mEmojiCtrl->getRect().getWidth(); - - return LLFloater::postBuild(); + mEmojiCtrl = findChild("emoji_complete_ctrl"); + mEmojiCtrl->setCommitCallback( + [this](LLUICtrl* ctrl, const LLSD& param) + { + setValue(param); + onCommit(); + }); + + mEmojiCtrlHorz = getRect().getWidth() - mEmojiCtrl->getRect().getWidth(); + mEmojiCtrlVert = getRect().getHeight() - mEmojiCtrl->getRect().getHeight(); + + return LLFloater::postBuild(); } 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); + if (called_from_parent) + { + LLFloater::reshape(width, height, called_from_parent); + } + else + { + LLRect outer(getRect()), inner(mEmojiCtrl->getRect()); + outer.mRight = outer.mLeft + inner.getWidth() + mEmojiCtrlHorz; + outer.mTop = outer.mBottom + inner.getHeight() + mEmojiCtrlVert; + setRect(outer); + } } // ============================================================================ diff --git a/indra/newview/llpanelemojicomplete.h b/indra/newview/llpanelemojicomplete.h index 20d3413765..1af923bda2 100644 --- a/indra/newview/llpanelemojicomplete.h +++ b/indra/newview/llpanelemojicomplete.h @@ -29,79 +29,83 @@ #include "llfloater.h" #include "lluictrl.h" +class LLScrollbar; + // ============================================================================ // LLPanelEmojiComplete // class LLPanelEmojiComplete : public LLUICtrl { - friend class LLUICtrlFactory; + friend class LLUICtrlFactory; public: - struct Params : public LLInitParam::Block - { - Optional autosize; - Optional noscroll; - Optional vertical; - Optional max_emoji, - padding; + struct Params : public LLInitParam::Block + { + Optional autosize; + Optional noscroll; + Optional vertical; + Optional max_visible, + padding; - Optional selected_image; + Optional selected_image; - Params(); - }; + Params(); + }; protected: - LLPanelEmojiComplete(const LLPanelEmojiComplete::Params&); + LLPanelEmojiComplete(const LLPanelEmojiComplete::Params&); public: - virtual ~LLPanelEmojiComplete(); + virtual ~LLPanelEmojiComplete(); - void draw() override; - BOOL handleHover(S32 x, S32 y, MASK mask) override; - BOOL handleKey(KEY key, MASK mask, BOOL called_from_parent) override; - BOOL handleMouseDown(S32 x, S32 y, MASK mask) override; - BOOL handleMouseUp(S32 x, S32 y, MASK mask) override; - void onCommit() override; - void reshape(S32 width, S32 height, BOOL called_from_parent) override; + void draw() override; + BOOL handleHover(S32 x, S32 y, MASK mask) override; + BOOL handleKey(KEY key, MASK mask, BOOL called_from_parent) override; + BOOL handleMouseDown(S32 x, S32 y, MASK mask) override; + BOOL handleMouseUp(S32 x, S32 y, MASK mask) override; + BOOL handleScrollWheel(S32 x, S32 y, S32 clicks) override; + void onCommit() override; + 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 setEmojis(const LLWString& emojis); - void setEmojiHint(const std::string& hint); - bool isAutoSize() const { return mAutoSize; } - U32 getMaxShortCodeWidth() const; + const LLWString& getEmojis() const { return mEmojis; } + size_t getEmojiCount() const { return mEmojis.size(); } + void setEmojis(const LLWString& emojis); + void setEmojiHint(const std::string& hint); + bool isAutoSize() const { return mAutoSize; } + U32 getMaxShortCodeWidth() const; protected: - void onEmojisChanged(); - size_t posToIndex(S32 x, S32 y) const; - void select(size_t emoji_idx); - void selectNext(); - void selectPrevious(); - void updateConstraints(); - void updateScrollPos(); + void onEmojisChanged(); + void onScrollbarChange(S32 index); + size_t posToIndex(S32 x, S32 y) const; + void select(size_t emoji_idx); + void selectNext(); + void selectPrevious(); + void updateConstraints(); + void updateScrollPos(); protected: - static constexpr auto npos = std::numeric_limits::max(); - - const bool mAutoSize = false; - const bool mNoScroll = false; - const bool mVertical = false; - const size_t mMaxVisible = 0; - const S32 mPadding = 8; - const LLUIImagePtr mSelectedImage; - const LLFontGL* mIconFont; - const LLFontGL* mTextFont; - - LLWString mEmojis; - LLRect mRenderRect; - U16 mEmojiWidth = 0; - U16 mEmojiHeight = 0; - size_t mVisibleEmojis = 0; - size_t mFirstVisible = 0; - size_t mScrollPos = 0; - size_t mCurSelected = 0; - LLVector2 mLastHover; + const bool mAutoSize; + const bool mNoScroll; + const bool mVertical; + const size_t mMaxVisible; + const S32 mPadding; + const LLUIImagePtr mSelectedImage; + const LLFontGL* mIconFont; + const LLFontGL* mTextFont; + + LLWString mEmojis; + LLScrollbar* mScrollbar; + LLRect mRenderRect; + U16 mEmojiWidth = 0; + U16 mEmojiHeight = 0; + size_t mTotalEmojis = 0; + size_t mVisibleEmojis = 0; + size_t mFirstVisible = 0; + size_t mScrollPos = 0; + size_t mCurSelected = 0; + LLVector2 mLastHover; }; // ============================================================================ @@ -111,17 +115,18 @@ protected: class LLFloaterEmojiComplete : public LLFloater { public: - LLFloaterEmojiComplete(const LLSD& sdKey); + LLFloaterEmojiComplete(const LLSD& sdKey); public: - BOOL handleKey(KEY key, MASK mask, BOOL called_from_parent) override; - void onOpen(const LLSD& key) override; - BOOL postBuild() override; - void reshape(S32 width, S32 height, BOOL called_from_parent) override; + BOOL handleKey(KEY key, MASK mask, BOOL called_from_parent) override; + 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; + LLPanelEmojiComplete* mEmojiCtrl = nullptr; + S32 mEmojiCtrlHorz = 0; + S32 mEmojiCtrlVert = 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 207a8af118..d290d647e8 100644 --- a/indra/newview/skins/default/xui/en/floater_emoji_complete.xml +++ b/indra/newview/skins/default/xui/en/floater_emoji_complete.xml @@ -3,6 +3,8 @@ name="emoji_complete" single_instance="true" layout="topleft" + bg_opaque_image="Window_NoTitle_Foreground" + bg_alpha_image="Window_NoTitle_Background" can_close="false" can_dock="false" can_drag_on_left="false" @@ -11,6 +13,7 @@ can_tear_off="false" header_height="0" legacy_header_height="0" + show_title="false" width="240" height="40" > @@ -20,7 +23,8 @@ layout="topleft" autosize="true" vertical="true" - max_emoji="7" + max_visible="7" + padding="4" width="230" height="30" left="5" diff --git a/indra/newview/skins/default/xui/en/floater_im_session.xml b/indra/newview/skins/default/xui/en/floater_im_session.xml index fa65842c28..eb5d88bba6 100644 --- a/indra/newview/skins/default/xui/en/floater_im_session.xml +++ b/indra/newview/skins/default/xui/en/floater_im_session.xml @@ -353,7 +353,7 @@ name="emoji_recent_icons_ctrl" follows="top|left|right" layout="topleft" - max_emoji="20" + max_visible="20" top="0" left="1" right="-65" diff --git a/indra/newview/skins/default/xui/en/widgets/emoji_complete.xml b/indra/newview/skins/default/xui/en/widgets/emoji_complete.xml index f9db441815..6cc8d7118f 100644 --- a/indra/newview/skins/default/xui/en/widgets/emoji_complete.xml +++ b/indra/newview/skins/default/xui/en/widgets/emoji_complete.xml @@ -3,7 +3,7 @@ autosize="false" hover_image="ListItem_Over" selected_image="ListItem_Select" - max_emoji="7" + max_visible="7" padding="8" > -- cgit v1.3 From 98214577c36d9c8dd0e13c7b678a399b35450bd3 Mon Sep 17 00:00:00 2001 From: Alexander Gavriliuk Date: Thu, 5 Oct 2023 11:28:54 +0200 Subject: SL-20390 Emoji Completion floater - ignore symbols in shortcodes when searching by pattern --- indra/llui/llemojidictionary.cpp | 64 ++++++++++++++++++++++++++++++ indra/llui/llemojidictionary.h | 20 ++++++++++ indra/newview/llpanelemojicomplete.cpp | 72 ++++++++++++++++++++-------------- indra/newview/llpanelemojicomplete.h | 4 +- 4 files changed, 128 insertions(+), 32 deletions(-) (limited to 'indra/newview/llpanelemojicomplete.cpp') diff --git a/indra/llui/llemojidictionary.cpp b/indra/llui/llemojidictionary.cpp index 1ee97ea2d2..bf7e53701d 100644 --- a/indra/llui/llemojidictionary.cpp +++ b/indra/llui/llemojidictionary.cpp @@ -143,6 +143,70 @@ LLWString LLEmojiDictionary::findMatchingEmojis(const std::string& needle) const return result; } +void LLEmojiDictionary::findByShortCode(std::vector& result, const std::string& needle) const +{ + result.clear(); + + if (needle.empty() || needle.front() != ':') + return; + + auto search = [needle](std::size_t& begin, std::size_t& end, const std::string& shortCode) -> bool + { + begin = 0; + end = 1; + std::size_t index = 1; + // Search for begin + char d = tolower(needle[index++]); + while (end < shortCode.size()) + { + char s = tolower(shortCode[end++]); + if (s == d) + { + begin = end - 1; + break; + } + } + if (!begin) + return false; + // Search for end + d = tolower(needle[index++]); + while (end < shortCode.size() && index <= needle.size()) + { + char s = tolower(shortCode[end++]); + if (s == d) + { + if (index == needle.size()) + return true; + d = tolower(needle[index++]); + continue; + } + switch (s) + { + case L'-': + case L'_': + case L'+': + continue; + } + break; + } + return false; + }; + + for (const LLEmojiDescriptor& d : mEmojis) + { + if (d.ShortCodes.empty()) + continue; + const std::string& shortCode = d.ShortCodes.front(); + if (shortCode.size() < needle.size() || shortCode.front() != needle.front()) + continue; + std::size_t begin, end; + if (search(begin, end, shortCode)) + { + result.emplace_back(d.Character, shortCode, begin, end); + } + } +} + const LLEmojiDescriptor* LLEmojiDictionary::getDescriptorFromEmoji(llwchar emoji) const { const auto it = mEmoji2Descr.find(emoji); diff --git a/indra/llui/llemojidictionary.h b/indra/llui/llemojidictionary.h index f6442684a7..66b564b70a 100644 --- a/indra/llui/llemojidictionary.h +++ b/indra/llui/llemojidictionary.h @@ -52,6 +52,25 @@ struct LLEmojiGroup std::list Categories; }; +// ============================================================================ +// LLEmojiSearchResult class +// + +struct LLEmojiSearchResult +{ + llwchar Character; + std::string String; + std::size_t Begin, End; + + LLEmojiSearchResult(llwchar character, const std::string& string, std::size_t begin, std::size_t end) + : Character(character) + , String(string) + , Begin(begin) + , End(end) + { + } +}; + // ============================================================================ // LLEmojiDictionary class // @@ -70,6 +89,7 @@ public: static void initClass(); LLWString findMatchingEmojis(const std::string& needle) const; + void findByShortCode(std::vector& result, const std::string& needle) const; const LLEmojiDescriptor* getDescriptorFromEmoji(llwchar emoji) const; const LLEmojiDescriptor* getDescriptorFromShortCode(const std::string& short_code) const; std::string getNameFromEmoji(llwchar ch) const; diff --git a/indra/newview/llpanelemojicomplete.cpp b/indra/newview/llpanelemojicomplete.cpp index b03f16899e..22cac8ad88 100644 --- a/indra/newview/llpanelemojicomplete.cpp +++ b/indra/newview/llpanelemojicomplete.cpp @@ -82,7 +82,7 @@ void LLPanelEmojiComplete::draw() { LLUICtrl::draw(); - if (mEmojis.empty()) + if (!mTotalEmojis) return; const size_t firstVisibleIdx = mScrollPos; @@ -115,21 +115,16 @@ void LLPanelEmojiComplete::draw() for (U32 curIdx = firstVisibleIdx; curIdx < lastVisibleIdx; curIdx++) { - mIconFont->render(mEmojis, curIdx, iconCenterX, iconCenterY, + LLWString text(1, mEmojis[curIdx].Character); + mIconFont->render(text, 0, iconCenterX, iconCenterY, LLColor4::white, LLFontGL::HCENTER, LLFontGL::VCENTER, LLFontGL::NORMAL, LLFontGL::DROP_SHADOW_SOFT, 1, S32_MAX, nullptr, false, true); if (mVertical) { - llwchar emoji = mEmojis[curIdx]; - auto& emoji2descr = LLEmojiDictionary::instance().getEmoji2Descr(); - auto it = emoji2descr.find(emoji); - if (it != emoji2descr.end()) - { - const std::string& shortCode = it->second->ShortCodes.front(); - mTextFont->renderUTF8(shortCode, 0, textLeft, iconCenterY, LLColor4::white, - LLFontGL::LEFT, LLFontGL::VCENTER, LLFontGL::NORMAL, LLFontGL::NO_SHADOW, - shortCode.size(), textWidth, NULL, FALSE, FALSE); - } + const std::string& shortCode = mEmojis[curIdx].String; + mTextFont->renderUTF8(shortCode, 0, textLeft, iconCenterY, LLColor4::white, + LLFontGL::LEFT, LLFontGL::VCENTER, LLFontGL::NORMAL, LLFontGL::NO_SHADOW, + shortCode.size(), textWidth, NULL, FALSE, FALSE); iconCenterY -= mEmojiHeight; } else @@ -257,9 +252,8 @@ void LLPanelEmojiComplete::onCommit() { if (mCurSelected < mTotalEmojis) { - LLWString wstr; - wstr.push_back(mEmojis.at(mCurSelected)); - setValue(wstring_to_utf8str(wstr)); + LLSD value(wstring_to_utf8str(LLWString(1, mEmojis[mCurSelected].Character))); + setValue(value); LLUICtrl::onCommit(); } } @@ -272,7 +266,23 @@ void LLPanelEmojiComplete::reshape(S32 width, S32 height, BOOL called_from_paren void LLPanelEmojiComplete::setEmojis(const LLWString& emojis) { - mEmojis = emojis; + mEmojis.clear(); + + auto& emoji2descr = LLEmojiDictionary::instance().getEmoji2Descr(); + for (const llwchar& emoji : emojis) + { + std::string shortCode; + if (mVertical) + { + auto it = emoji2descr.find(emoji); + if (it != emoji2descr.end() && !it->second->ShortCodes.empty()) + { + shortCode = it->second->ShortCodes.front(); + } + } + mEmojis.emplace_back(emoji, shortCode, 0, 0); + } + mTotalEmojis = mEmojis.size(); mCurSelected = 0; @@ -281,12 +291,20 @@ void LLPanelEmojiComplete::setEmojis(const LLWString& emojis) void LLPanelEmojiComplete::setEmojiHint(const std::string& hint) { - llwchar curEmoji = mCurSelected < mTotalEmojis ? mEmojis.at(mCurSelected) : 0; + llwchar curEmoji = mCurSelected < mTotalEmojis ? mEmojis[mCurSelected].Character : 0; - mEmojis = LLEmojiDictionary::instance().findMatchingEmojis(hint); + LLEmojiDictionary::instance().findByShortCode(mEmojis, hint); mTotalEmojis = mEmojis.size(); - size_t curEmojiIdx = curEmoji ? mEmojis.find(curEmoji) : std::string::npos; - mCurSelected = std::string::npos != curEmojiIdx ? curEmojiIdx : 0; + + mCurSelected = 0; + for (size_t i = 1; i < mTotalEmojis; ++i) + { + if (mEmojis[i].Character == curEmoji) + { + mCurSelected = i; + break; + } + } onEmojisChanged(); } @@ -294,18 +312,12 @@ void LLPanelEmojiComplete::setEmojiHint(const std::string& hint) U32 LLPanelEmojiComplete::getMaxShortCodeWidth() const { U32 max_width = 0; - auto& emoji2descr = LLEmojiDictionary::instance().getEmoji2Descr(); - for (llwchar emoji : mEmojis) + for (const LLEmojiSearchResult& result : mEmojis) { - auto it = emoji2descr.find(emoji); - if (it != emoji2descr.end()) + S32 width = mTextFont->getWidth(result.String); + if (width > max_width) { - const std::string& shortCode = it->second->ShortCodes.front(); - S32 width = mTextFont->getWidth(shortCode); - if (width > max_width) - { - max_width = width; - } + max_width = width; } } return max_width; diff --git a/indra/newview/llpanelemojicomplete.h b/indra/newview/llpanelemojicomplete.h index 1af923bda2..36a965202e 100644 --- a/indra/newview/llpanelemojicomplete.h +++ b/indra/newview/llpanelemojicomplete.h @@ -26,6 +26,7 @@ #pragma once +#include "llemojidictionary.h" #include "llfloater.h" #include "lluictrl.h" @@ -68,7 +69,6 @@ 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 setEmojis(const LLWString& emojis); void setEmojiHint(const std::string& hint); @@ -95,7 +95,7 @@ protected: const LLFontGL* mIconFont; const LLFontGL* mTextFont; - LLWString mEmojis; + std::vector mEmojis; LLScrollbar* mScrollbar; LLRect mRenderRect; U16 mEmojiWidth = 0; -- cgit v1.3 From da783d1750ec8a03d62ddf81a0b44bba1b2f565b Mon Sep 17 00:00:00 2001 From: Alexander Gavriliuk Date: Thu, 5 Oct 2023 14:17:50 +0200 Subject: SL-20389 Emoji Completion floater - highlight the entered part of the shortcode --- indra/newview/llpanelemojicomplete.cpp | 38 +++++++++++++++++++++++++++------- 1 file changed, 31 insertions(+), 7 deletions(-) (limited to 'indra/newview/llpanelemojicomplete.cpp') diff --git a/indra/newview/llpanelemojicomplete.cpp b/indra/newview/llpanelemojicomplete.cpp index 22cac8ad88..29e1a29ed3 100644 --- a/indra/newview/llpanelemojicomplete.cpp +++ b/indra/newview/llpanelemojicomplete.cpp @@ -108,10 +108,10 @@ void LLPanelEmojiComplete::draw() mSelectedImage->draw(x, y, width, height); } - S32 iconCenterX = mRenderRect.mLeft + mEmojiWidth / 2; - S32 iconCenterY = mRenderRect.mTop - mEmojiHeight / 2; - S32 textLeft = mVertical ? mRenderRect.mLeft + mEmojiWidth + mPadding : 0; - S32 textWidth = mVertical ? getRect().getWidth() - textLeft - mPadding : 0; + F32 iconCenterX = mRenderRect.mLeft + (F32)mEmojiWidth / 2; + F32 iconCenterY = mRenderRect.mTop - (F32)mEmojiHeight / 2; + F32 textLeft = mVertical ? mRenderRect.mLeft + mEmojiWidth + mPadding : 0; + F32 textWidth = mVertical ? getRect().getWidth() - textLeft - mPadding : 0; for (U32 curIdx = firstVisibleIdx; curIdx < lastVisibleIdx; curIdx++) { @@ -122,9 +122,33 @@ void LLPanelEmojiComplete::draw() if (mVertical) { const std::string& shortCode = mEmojis[curIdx].String; - mTextFont->renderUTF8(shortCode, 0, textLeft, iconCenterY, LLColor4::white, - LLFontGL::LEFT, LLFontGL::VCENTER, LLFontGL::NORMAL, LLFontGL::NO_SHADOW, - shortCode.size(), textWidth, NULL, FALSE, FALSE); + F32 x0 = textLeft; + F32 x1 = textWidth; + if (mEmojis[curIdx].Begin) + { + std::string text = shortCode.substr(0, mEmojis[curIdx].Begin); + mTextFont->renderUTF8(text, 0, x0, iconCenterY, LLColor4::white, + LLFontGL::LEFT, LLFontGL::VCENTER, LLFontGL::NORMAL, LLFontGL::NO_SHADOW, + text.size(), x1, NULL, FALSE, FALSE); + x0 += mTextFont->getWidthF32(text); + x1 = textLeft + textWidth - x0; + } + if (x1 > 0 && mEmojis[curIdx].End > mEmojis[curIdx].Begin) + { + std::string text = shortCode.substr(mEmojis[curIdx].Begin, mEmojis[curIdx].End - mEmojis[curIdx].Begin); + mTextFont->renderUTF8(text, 0, x0, iconCenterY, LLColor4::yellow6, + LLFontGL::LEFT, LLFontGL::VCENTER, LLFontGL::NORMAL, LLFontGL::NO_SHADOW, + text.size(), x1, NULL, FALSE, FALSE); + x0 += mTextFont->getWidthF32(text); + x1 = textLeft + textWidth - x0; + } + if (x1 > 0 && mEmojis[curIdx].End < shortCode.size()) + { + std::string text = shortCode.substr(mEmojis[curIdx].End); + mTextFont->renderUTF8(text, 0, x0, iconCenterY, LLColor4::white, + LLFontGL::LEFT, LLFontGL::VCENTER, LLFontGL::NORMAL, LLFontGL::NO_SHADOW, + text.size(), x1, NULL, FALSE, FALSE); + } iconCenterY -= mEmojiHeight; } else -- cgit v1.3 From 93e4d069d1a9d003664f23f842cf100f635607ed Mon Sep 17 00:00:00 2001 From: Alexander Gavriliuk Date: Wed, 8 Nov 2023 17:53:16 +0100 Subject: SL-20518 EmojiPicker - The 'More' button is overlapped the recently used emojis row after narrowing back the 'Conversations' floater --- indra/newview/llfloaterimsessiontab.cpp | 12 ++++++------ indra/newview/llpanelemojicomplete.cpp | 13 +++++++++++-- 2 files changed, 17 insertions(+), 8 deletions(-) (limited to 'indra/newview/llpanelemojicomplete.cpp') diff --git a/indra/newview/llfloaterimsessiontab.cpp b/indra/newview/llfloaterimsessiontab.cpp index 04385409ca..5804d8701b 100644 --- a/indra/newview/llfloaterimsessiontab.cpp +++ b/indra/newview/llfloaterimsessiontab.cpp @@ -495,11 +495,11 @@ void LLFloaterIMSessionTab::initEmojiRecentPanel(bool moveFocus) std::list& recentlyUsed = LLFloaterEmojiPicker::getRecentlyUsed(); if (recentlyUsed.empty()) { - mEmojiRecentEmptyText->setVisible(true); - mEmojiRecentIconsCtrl->setVisible(false); + mEmojiRecentEmptyText->setVisible(TRUE); + mEmojiRecentIconsCtrl->setVisible(FALSE); if (moveFocus) { - mEmojiPickerToggleBtn->setFocus(true); + mEmojiPickerToggleBtn->setFocus(TRUE); } } else @@ -510,11 +510,11 @@ void LLFloaterIMSessionTab::initEmojiRecentPanel(bool moveFocus) emojis += emoji; } mEmojiRecentIconsCtrl->setEmojis(emojis); - mEmojiRecentEmptyText->setVisible(false); - mEmojiRecentIconsCtrl->setVisible(true); + mEmojiRecentEmptyText->setVisible(FALSE); + mEmojiRecentIconsCtrl->setVisible(TRUE); if (moveFocus) { - mEmojiRecentIconsCtrl->setFocus(true); + mEmojiRecentIconsCtrl->setFocus(TRUE); } } } diff --git a/indra/newview/llpanelemojicomplete.cpp b/indra/newview/llpanelemojicomplete.cpp index 29e1a29ed3..9bfe04fc31 100644 --- a/indra/newview/llpanelemojicomplete.cpp +++ b/indra/newview/llpanelemojicomplete.cpp @@ -285,7 +285,14 @@ void LLPanelEmojiComplete::onCommit() void LLPanelEmojiComplete::reshape(S32 width, S32 height, BOOL called_from_parent) { LLUICtrl::reshape(width, height, called_from_parent); - updateConstraints(); + if (mAutoSize) + { + updateConstraints(); + } + else + { + onEmojisChanged(); + } } void LLPanelEmojiComplete::setEmojis(const LLWString& emojis) @@ -373,7 +380,9 @@ void LLPanelEmojiComplete::onEmojisChanged() } else { - mVisibleEmojis = mVertical ? getRect().getHeight() / mEmojiHeight : getRect().getWidth() / mEmojiWidth; + mVisibleEmojis = mVertical ? + mEmojiHeight ? getRect().getHeight() / mEmojiHeight : 0 : + mEmojiWidth ? getRect().getWidth() / mEmojiWidth : 0; } updateConstraints(); -- cgit v1.3 From 6173bd6236dc452b05b6e32258b59c6db05a022d Mon Sep 17 00:00:00 2001 From: Alexander Gavriliuk Date: Thu, 11 Jan 2024 19:19:35 +0100 Subject: SL-20749 Scrolling up by mouse wheel is endless in LLPanelEmojiComplete --- indra/newview/llpanelemojicomplete.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'indra/newview/llpanelemojicomplete.cpp') diff --git a/indra/newview/llpanelemojicomplete.cpp b/indra/newview/llpanelemojicomplete.cpp index 9bfe04fc31..46f455aede 100644 --- a/indra/newview/llpanelemojicomplete.cpp +++ b/indra/newview/llpanelemojicomplete.cpp @@ -264,7 +264,11 @@ BOOL LLPanelEmojiComplete::handleScrollWheel(S32 x, S32 y, S32 clicks) if (mTotalEmojis > mVisibleEmojis) { - mScrollPos = llclamp(mScrollPos + clicks, 0, mTotalEmojis - mVisibleEmojis); + // In case of wheel up (clicks < 0) we shouldn't subtract more than value of mScrollPos + // Example: if mScrollPos = 0, clicks = -1 then (mScrollPos + clicks) becomes SIZE_MAX + // As a result of llclamp() mScrollPos becomes (mTotalEmojis - mVisibleEmojis) + S32 newScrollPos = llmax(0, (S32)mScrollPos + clicks); + mScrollPos = llclamp((size_t)newScrollPos, 0, mTotalEmojis - mVisibleEmojis); mCurSelected = posToIndex(x, y); return TRUE; } -- cgit v1.3 From ae91ae43a51c58cc496f3947921fbf886c6be86e Mon Sep 17 00:00:00 2001 From: Alexander Gavriliuk Date: Mon, 15 Jan 2024 23:20:24 +0100 Subject: SL-20795 Part of previously typed emojis disappear in the 'Save settings as a preset...' option of the 'Preferences' floater --- indra/llcommon/llstring.cpp | 2 -- indra/llrender/llfontfreetype.cpp | 11 ++++++++++- indra/llrender/llfontgl.cpp | 6 +++--- indra/llrender/llfontgl.h | 8 ++++---- indra/llui/llbutton.cpp | 2 +- indra/llui/llfolderviewitem.cpp | 10 +++++----- indra/llui/lllineeditor.cpp | 2 +- indra/llui/llview.cpp | 3 +-- indra/newview/llfloateremojipicker.cpp | 22 ++++------------------ indra/newview/llfloateruipreview.cpp | 8 ++++---- indra/newview/llpanelemojicomplete.cpp | 8 ++++---- indra/newview/lltextureview.cpp | 3 +-- indra/newview/llviewerwindow.cpp | 3 +-- indra/newview/llworldmapview.cpp | 3 +-- .../default/xui/en/panel_preferences_graphics1.xml | 2 +- 15 files changed, 41 insertions(+), 52 deletions(-) (limited to 'indra/newview/llpanelemojicomplete.cpp') diff --git a/indra/llcommon/llstring.cpp b/indra/llcommon/llstring.cpp index 81b0207038..17d69351ec 100644 --- a/indra/llcommon/llstring.cpp +++ b/indra/llcommon/llstring.cpp @@ -339,8 +339,6 @@ S32 wchar_utf8_length(const llwchar wc) { if (wc < 0x80) { - // This case will also catch negative values which are - // technically invalid. return 1; } else if (wc < 0x800) diff --git a/indra/llrender/llfontfreetype.cpp b/indra/llrender/llfontfreetype.cpp index ca9f2ed778..d87fb5245c 100644 --- a/indra/llrender/llfontfreetype.cpp +++ b/indra/llrender/llfontfreetype.cpp @@ -665,7 +665,16 @@ void LLFontFreetype::renderGlyph(EFontGlyphType bitmap_type, U32 glyph_index) co load_flags |= FT_LOAD_COLOR; } - llassert_always(! FT_Load_Glyph(mFTFace, glyph_index, load_flags) ); + FT_Error error = FT_Load_Glyph(mFTFace, glyph_index, load_flags); + if (FT_Err_Ok != error) + { + std::string message = llformat( + "Error %d (%s) loading glyph %u: bitmap_type=%u, load_flags=%d", + error, FT_Error_String(error), glyph_index, bitmap_type, load_flags); + LL_WARNS_ONCE() << message << LL_ENDL; + error = FT_Load_Glyph(mFTFace, glyph_index, load_flags ^ FT_LOAD_COLOR); + llassert_always_msg(FT_Err_Ok == error, message.c_str()); + } llassert_always(! FT_Render_Glyph(mFTFace->glyph, gFontRenderMode) ); diff --git a/indra/llrender/llfontgl.cpp b/indra/llrender/llfontgl.cpp index f0b89f9a1d..53661b6a63 100644 --- a/indra/llrender/llfontgl.cpp +++ b/indra/llrender/llfontgl.cpp @@ -420,7 +420,7 @@ S32 LLFontGL::render(const LLWString &wstr, S32 begin_offset, F32 x, F32 y, cons S32 LLFontGL::render(const LLWString &text, S32 begin_offset, F32 x, F32 y, const LLColor4 &color) const { - return render(text, begin_offset, x, y, color, LEFT, BASELINE, NORMAL, NO_SHADOW, S32_MAX, S32_MAX, NULL, FALSE); + return render(text, begin_offset, x, y, color, LEFT, BASELINE, NORMAL, NO_SHADOW); } S32 LLFontGL::renderUTF8(const std::string &text, S32 begin_offset, F32 x, F32 y, const LLColor4 &color, HAlign halign, VAlign valign, U8 style, ShadowType shadow, S32 max_chars, S32 max_pixels, F32* right_x, BOOL use_ellipses, BOOL use_color) const @@ -430,12 +430,12 @@ S32 LLFontGL::renderUTF8(const std::string &text, S32 begin_offset, F32 x, F32 y S32 LLFontGL::renderUTF8(const std::string &text, S32 begin_offset, S32 x, S32 y, const LLColor4 &color) const { - return renderUTF8(text, begin_offset, (F32)x, (F32)y, color, LEFT, BASELINE, NORMAL, NO_SHADOW, S32_MAX, S32_MAX, NULL, FALSE, FALSE); + return renderUTF8(text, begin_offset, (F32)x, (F32)y, color, LEFT, BASELINE, NORMAL, NO_SHADOW); } S32 LLFontGL::renderUTF8(const std::string &text, S32 begin_offset, S32 x, S32 y, const LLColor4 &color, HAlign halign, VAlign valign, U8 style, ShadowType shadow) const { - return renderUTF8(text, begin_offset, (F32)x, (F32)y, color, halign, valign, style, shadow, S32_MAX, S32_MAX, NULL, FALSE, FALSE); + return renderUTF8(text, begin_offset, (F32)x, (F32)y, color, halign, valign, style, shadow); } // font metrics - override for LLFontFreetype that returns units of virtual pixels diff --git a/indra/llrender/llfontgl.h b/indra/llrender/llfontgl.h index a9d512f7ce..f6ec416c8b 100644 --- a/indra/llrender/llfontgl.h +++ b/indra/llrender/llfontgl.h @@ -99,7 +99,7 @@ public: S32 max_chars = S32_MAX, F32* right_x=NULL, BOOL use_ellipses = FALSE, - BOOL use_color = FALSE) const; + BOOL use_color = TRUE) const; S32 render(const LLWString &text, S32 begin_offset, const LLRectf& rect, @@ -109,7 +109,7 @@ public: S32 max_chars = S32_MAX, F32* right_x=NULL, BOOL use_ellipses = FALSE, - BOOL use_color = FALSE) const; + BOOL use_color = TRUE) const; S32 render(const LLWString &text, S32 begin_offset, F32 x, F32 y, @@ -119,12 +119,12 @@ public: S32 max_chars = S32_MAX, S32 max_pixels = S32_MAX, F32* right_x=NULL, BOOL use_ellipses = FALSE, - BOOL use_color = FALSE) const; + BOOL use_color = TRUE) const; S32 render(const LLWString &text, S32 begin_offset, F32 x, F32 y, const LLColor4 &color) const; // renderUTF8 does a conversion, so is slower! - S32 renderUTF8(const std::string &text, S32 begin_offset, F32 x, F32 y, const LLColor4 &color, HAlign halign, VAlign valign, U8 style, ShadowType shadow, S32 max_chars, S32 max_pixels, F32* right_x, BOOL use_ellipses, BOOL use_color) const; + S32 renderUTF8(const std::string &text, S32 begin_offset, F32 x, F32 y, const LLColor4 &color, HAlign halign, VAlign valign, U8 style, ShadowType shadow, S32 max_chars = S32_MAX, S32 max_pixels = S32_MAX, F32* right_x = NULL, BOOL use_ellipses = FALSE, BOOL use_color = TRUE) const; S32 renderUTF8(const std::string &text, S32 begin_offset, S32 x, S32 y, const LLColor4 &color) const; S32 renderUTF8(const std::string &text, S32 begin_offset, S32 x, S32 y, const LLColor4 &color, HAlign halign, VAlign valign, U8 style = NORMAL, ShadowType shadow = NO_SHADOW) const; diff --git a/indra/llui/llbutton.cpp b/indra/llui/llbutton.cpp index 5ce1cbd63c..9ef019840a 100644 --- a/indra/llui/llbutton.cpp +++ b/indra/llui/llbutton.cpp @@ -68,7 +68,7 @@ LLButton::Params::Params() label_shadow("label_shadow", true), auto_resize("auto_resize", false), use_ellipses("use_ellipses", false), - use_font_color("use_font_color", false), + use_font_color("use_font_color", true), image_unselected("image_unselected"), image_selected("image_selected"), image_hover_selected("image_hover_selected"), diff --git a/indra/llui/llfolderviewitem.cpp b/indra/llui/llfolderviewitem.cpp index c47f4c60e3..bc9469cfad 100644 --- a/indra/llui/llfolderviewitem.cpp +++ b/indra/llui/llfolderviewitem.cpp @@ -890,7 +890,7 @@ void LLFolderViewItem::drawLabel(const LLFontGL * font, const F32 x, const F32 y // font->renderUTF8(mLabel, 0, x, y, color, LLFontGL::LEFT, LLFontGL::BOTTOM, LLFontGL::NORMAL, LLFontGL::NO_SHADOW, - S32_MAX, getRect().getWidth() - (S32) x - mLabelPaddingRight, &right_x, /*use_ellipses*/TRUE, /*use_color*/FALSE); + S32_MAX, getRect().getWidth() - (S32) x - mLabelPaddingRight, &right_x, /*use_ellipses*/TRUE); } void LLFolderViewItem::draw() @@ -999,7 +999,7 @@ void LLFolderViewItem::draw() { suffix_font->renderUTF8( mLabelSuffix, 0, right_x, y, isFadeItem() ? color : (LLColor4)sSuffixColor, LLFontGL::LEFT, LLFontGL::BOTTOM, LLFontGL::NORMAL, LLFontGL::NO_SHADOW, - S32_MAX, S32_MAX, &right_x, /*use_ellipses*/FALSE, /*use_color*/FALSE ); + S32_MAX, S32_MAX, &right_x); } //--------------------------------------------------------------------------------// @@ -1013,7 +1013,7 @@ void LLFolderViewItem::draw() F32 yy = (F32)getRect().getHeight() - font->getLineHeight() - (F32)mTextPad - (F32)TOP_PAD; font->renderUTF8(combined_string, filter_offset, match_string_left, yy, sFilterTextColor, LLFontGL::LEFT, LLFontGL::BOTTOM, LLFontGL::NORMAL, LLFontGL::NO_SHADOW, - filter_string_length, S32_MAX, &right_x, FALSE, FALSE); + filter_string_length, S32_MAX, &right_x); } else { @@ -1024,7 +1024,7 @@ void LLFolderViewItem::draw() F32 yy = (F32)getRect().getHeight() - font->getLineHeight() - (F32)mTextPad - (F32)TOP_PAD; font->renderUTF8(mLabel, filter_offset, match_string_left, yy, sFilterTextColor, LLFontGL::LEFT, LLFontGL::BOTTOM, LLFontGL::NORMAL, LLFontGL::NO_SHADOW, - label_filter_length, S32_MAX, &right_x, FALSE, FALSE); + label_filter_length, S32_MAX, &right_x); } S32 suffix_filter_length = label_filter_length > 0 ? filter_string_length - label_filter_length : filter_string_length; @@ -1035,7 +1035,7 @@ void LLFolderViewItem::draw() F32 yy = (F32)getRect().getHeight() - suffix_font->getLineHeight() - (F32)mTextPad - (F32)TOP_PAD; suffix_font->renderUTF8(mLabelSuffix, suffix_offset, match_string_left, yy, sFilterTextColor, LLFontGL::LEFT, LLFontGL::BOTTOM, LLFontGL::NORMAL, LLFontGL::NO_SHADOW, - suffix_filter_length, S32_MAX, &right_x, FALSE, FALSE); + suffix_filter_length, S32_MAX, &right_x); } } diff --git a/indra/llui/lllineeditor.cpp b/indra/llui/lllineeditor.cpp index bd6fd5b79e..e032b4b8c2 100644 --- a/indra/llui/lllineeditor.cpp +++ b/indra/llui/lllineeditor.cpp @@ -2107,7 +2107,7 @@ void LLLineEditor::draw() LLFontGL::NO_SHADOW, S32_MAX, mTextRightEdge - ll_round(rendered_pixels_right), - &rendered_pixels_right, FALSE); + &rendered_pixels_right); } // Draw children (border) LLView::draw(); diff --git a/indra/llui/llview.cpp b/indra/llui/llview.cpp index 7b6661a519..0afccef735 100644 --- a/indra/llui/llview.cpp +++ b/indra/llui/llview.cpp @@ -1336,8 +1336,7 @@ void LLView::drawDebugRect() std::string debug_text = llformat("%s (%d x %d)", getName().c_str(), debug_rect.getWidth(), debug_rect.getHeight()); LLFontGL::getFontSansSerifSmall()->renderUTF8(debug_text, 0, (F32)x, (F32)y, border_color, - LLFontGL::HCENTER, LLFontGL::BASELINE, LLFontGL::NORMAL, LLFontGL::NO_SHADOW, - S32_MAX, S32_MAX, NULL, /*use_ellipses*/FALSE, /*use_color*/FALSE); + LLFontGL::HCENTER, LLFontGL::BASELINE, LLFontGL::NORMAL, LLFontGL::NO_SHADOW); } } LLUI::popMatrix(); diff --git a/indra/newview/llfloateremojipicker.cpp b/indra/newview/llfloateremojipicker.cpp index abc5165f1e..ecfc4e7b41 100644 --- a/indra/newview/llfloateremojipicker.cpp +++ b/indra/newview/llfloateremojipicker.cpp @@ -102,11 +102,7 @@ public: LLFontGL::VCENTER, // valign LLFontGL::NORMAL, // style LLFontGL::DROP_SHADOW_SOFT, // shadow - mText.size(), // max_chars - S32_MAX, // max_pixels - nullptr, // right_x - false, // use_ellipses - true); // use_color + mText.size()); // max_chars } virtual void updatePanel(BOOL allow_modify) override {} @@ -144,11 +140,7 @@ public: LLFontGL::VCENTER, // valign LLFontGL::NORMAL, // style LLFontGL::DROP_SHADOW_SOFT, // shadow - 1, // max_chars - S32_MAX, // max_pixels - nullptr, // right_x - false, // use_ellipses - true); // use_color + 1); // max_chars } virtual void updatePanel(BOOL allow_modify) override {} @@ -225,10 +217,7 @@ protected: LLFontGL::NORMAL, // style LLFontGL::DROP_SHADOW_SOFT, // shadow 1, // max_chars - max_pixels, // max_pixels - nullptr, // right_x - false, // use_ellipses - true); // use_color + max_pixels); // max_pixels } void drawName(std::string name, F32 x, F32 y, S32 max_pixels, LLColor4& color) @@ -244,10 +233,7 @@ protected: LLFontGL::NORMAL, // style LLFontGL::DROP_SHADOW_SOFT, // shadow -1, // max_chars - max_pixels, // max_pixels - nullptr, // right_x - true, // use_ellipses - false); // use_color + max_pixels); // max_pixels } private: diff --git a/indra/newview/llfloateruipreview.cpp b/indra/newview/llfloateruipreview.cpp index 6032064c31..db69c3e2c3 100644 --- a/indra/newview/llfloateruipreview.cpp +++ b/indra/newview/llfloateruipreview.cpp @@ -1601,7 +1601,7 @@ void LLOverlapPanel::draw() LLUI::translate(5,getRect().getHeight()-20); // translate to top-5,left-5 LLView::sDrawPreviewHighlights = FALSE; LLFontGL::getFontSansSerifSmall()->renderUTF8(current_selection_text, 0, 0, 0, text_color, - LLFontGL::LEFT, LLFontGL::BASELINE, LLFontGL::NORMAL, LLFontGL::NO_SHADOW, S32_MAX, S32_MAX, NULL, /*use_ellipses*/FALSE, /*use_color*/FALSE); + LLFontGL::LEFT, LLFontGL::BASELINE, LLFontGL::NORMAL, LLFontGL::NO_SHADOW); } else { @@ -1619,7 +1619,7 @@ void LLOverlapPanel::draw() std::string current_selection = std::string(current_selection_text + LLView::sPreviewClickedElement->getName() + " (no elements overlap)"); S32 text_width = LLFontGL::getFontSansSerifSmall()->getWidth(current_selection) + 10; LLFontGL::getFontSansSerifSmall()->renderUTF8(current_selection, 0, 0, 0, text_color, - LLFontGL::LEFT, LLFontGL::BASELINE, LLFontGL::NORMAL, LLFontGL::NO_SHADOW, S32_MAX, S32_MAX, NULL, /*use_ellipses*/FALSE, /*use_color*/FALSE); + LLFontGL::LEFT, LLFontGL::BASELINE, LLFontGL::NORMAL, LLFontGL::NO_SHADOW); // widen panel enough to fit this text LLRect rect = getRect(); setRect(LLRect(rect.mLeft,rect.mTop,rect.getWidth() < text_width ? rect.mLeft + text_width : rect.mRight,rect.mTop)); @@ -1685,7 +1685,7 @@ void LLOverlapPanel::draw() // draw currently-selected element at top of overlappers LLUI::translate(0,-mSpacing); LLFontGL::getFontSansSerifSmall()->renderUTF8(current_selection_text + LLView::sPreviewClickedElement->getName(), 0, 0, 0, text_color, - LLFontGL::LEFT, LLFontGL::BASELINE, LLFontGL::NORMAL, LLFontGL::NO_SHADOW, S32_MAX, S32_MAX, NULL, /*use_ellipses*/FALSE, /*use_color*/FALSE); + LLFontGL::LEFT, LLFontGL::BASELINE, LLFontGL::NORMAL, LLFontGL::NO_SHADOW); LLUI::translate(0,-mSpacing-LLView::sPreviewClickedElement->getRect().getHeight()); // skip spacing distance + height LLView::sPreviewClickedElement->draw(); @@ -1700,7 +1700,7 @@ void LLOverlapPanel::draw() // draw name LLUI::translate(0,-mSpacing); LLFontGL::getFontSansSerifSmall()->renderUTF8(overlapper_text + viewp->getName(), 0, 0, 0, text_color, - LLFontGL::LEFT, LLFontGL::BASELINE, LLFontGL::NORMAL, LLFontGL::NO_SHADOW, S32_MAX, S32_MAX, NULL, /*use_ellipses*/FALSE, /*use_color*/FALSE); + LLFontGL::LEFT, LLFontGL::BASELINE, LLFontGL::NORMAL, LLFontGL::NO_SHADOW); // draw element LLUI::translate(0,-mSpacing-viewp->getRect().getHeight()); // skip spacing distance + height diff --git a/indra/newview/llpanelemojicomplete.cpp b/indra/newview/llpanelemojicomplete.cpp index 46f455aede..e6e3a10e13 100644 --- a/indra/newview/llpanelemojicomplete.cpp +++ b/indra/newview/llpanelemojicomplete.cpp @@ -118,7 +118,7 @@ void LLPanelEmojiComplete::draw() LLWString text(1, mEmojis[curIdx].Character); mIconFont->render(text, 0, iconCenterX, iconCenterY, LLColor4::white, LLFontGL::HCENTER, LLFontGL::VCENTER, LLFontGL::NORMAL, - LLFontGL::DROP_SHADOW_SOFT, 1, S32_MAX, nullptr, false, true); + LLFontGL::DROP_SHADOW_SOFT, 1); if (mVertical) { const std::string& shortCode = mEmojis[curIdx].String; @@ -129,7 +129,7 @@ void LLPanelEmojiComplete::draw() std::string text = shortCode.substr(0, mEmojis[curIdx].Begin); mTextFont->renderUTF8(text, 0, x0, iconCenterY, LLColor4::white, LLFontGL::LEFT, LLFontGL::VCENTER, LLFontGL::NORMAL, LLFontGL::NO_SHADOW, - text.size(), x1, NULL, FALSE, FALSE); + text.size(), x1); x0 += mTextFont->getWidthF32(text); x1 = textLeft + textWidth - x0; } @@ -138,7 +138,7 @@ void LLPanelEmojiComplete::draw() std::string text = shortCode.substr(mEmojis[curIdx].Begin, mEmojis[curIdx].End - mEmojis[curIdx].Begin); mTextFont->renderUTF8(text, 0, x0, iconCenterY, LLColor4::yellow6, LLFontGL::LEFT, LLFontGL::VCENTER, LLFontGL::NORMAL, LLFontGL::NO_SHADOW, - text.size(), x1, NULL, FALSE, FALSE); + text.size(), x1); x0 += mTextFont->getWidthF32(text); x1 = textLeft + textWidth - x0; } @@ -147,7 +147,7 @@ void LLPanelEmojiComplete::draw() std::string text = shortCode.substr(mEmojis[curIdx].End); mTextFont->renderUTF8(text, 0, x0, iconCenterY, LLColor4::white, LLFontGL::LEFT, LLFontGL::VCENTER, LLFontGL::NORMAL, LLFontGL::NO_SHADOW, - text.size(), x1, NULL, FALSE, FALSE); + text.size(), x1); } iconCenterY -= mEmojiHeight; } diff --git a/indra/newview/lltextureview.cpp b/indra/newview/lltextureview.cpp index 1051194183..84cd6e2da7 100644 --- a/indra/newview/lltextureview.cpp +++ b/indra/newview/lltextureview.cpp @@ -588,8 +588,7 @@ void LLGLTexMemBar::draw() x_right = 550.0; LLFontGL::getFontMonospace()->renderUTF8(text, 0, 0, v_offset + line_height*3, text_color, LLFontGL::LEFT, LLFontGL::TOP, - LLFontGL::NORMAL, LLFontGL::NO_SHADOW, S32_MAX, S32_MAX, - &x_right, /*use_ellipses*/FALSE, /*use_color*/FALSE); + LLFontGL::NORMAL, LLFontGL::NO_SHADOW, S32_MAX, S32_MAX, &x_right); F32Kilobits bandwidth(LLAppViewer::getTextureFetch()->getTextureBandwidth()); F32Kilobits max_bandwidth(gSavedSettings.getF32("ThrottleBandwidthKBPS")); diff --git a/indra/newview/llviewerwindow.cpp b/indra/newview/llviewerwindow.cpp index 6de510bc11..47c7eed872 100644 --- a/indra/newview/llviewerwindow.cpp +++ b/indra/newview/llviewerwindow.cpp @@ -955,8 +955,7 @@ public: { const Line& line = *iter; LLFontGL::getFontMonospace()->renderUTF8(line.text, 0, (F32)line.x, (F32)line.y, mTextColor, - LLFontGL::LEFT, LLFontGL::TOP, - LLFontGL::NORMAL, LLFontGL::NO_SHADOW, S32_MAX, S32_MAX, NULL, /*use_ellipses*/FALSE, /*use_color*/FALSE); + LLFontGL::LEFT, LLFontGL::TOP, LLFontGL::NORMAL, LLFontGL::NO_SHADOW); } } diff --git a/indra/newview/llworldmapview.cpp b/indra/newview/llworldmapview.cpp index d597207859..a8676d2ad6 100755 --- a/indra/newview/llworldmapview.cpp +++ b/indra/newview/llworldmapview.cpp @@ -520,8 +520,7 @@ void LLWorldMapView::draw() S32_MAX, //max_chars mMapScale, //max_pixels NULL, - /*use_ellipses*/TRUE, - /*use_color*/FALSE); + /*use_ellipses*/TRUE); } } } diff --git a/indra/newview/skins/default/xui/en/panel_preferences_graphics1.xml b/indra/newview/skins/default/xui/en/panel_preferences_graphics1.xml index fe74cea2f1..8a9d3b755e 100644 --- a/indra/newview/skins/default/xui/en/panel_preferences_graphics1.xml +++ b/indra/newview/skins/default/xui/en/panel_preferences_graphics1.xml @@ -27,7 +27,7 @@ left_delta="110" name="preset_text" top="5" - width="120"> + width="320"> (None) -- cgit v1.3