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.h | 99 ++++++++++++++++++++++++++++++++++++ 1 file changed, 99 insertions(+) create mode 100644 indra/newview/llpanelemojicomplete.h (limited to 'indra/newview/llpanelemojicomplete.h') diff --git a/indra/newview/llpanelemojicomplete.h b/indra/newview/llpanelemojicomplete.h new file mode 100644 index 0000000000..85b0609ae9 --- /dev/null +++ b/indra/newview/llpanelemojicomplete.h @@ -0,0 +1,99 @@ +/** +* @file llpanelemojicomplete.h +* @brief Header file for LLPanelEmojiComplete +* +* $LicenseInfo:firstyear=2014&license=viewerlgpl$ +* Second Life Viewer Source Code +* Copyright (C) 2014, 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$ +*/ + +#pragma once + +#include "llfloater.h" +#include "lluictrl.h" + +// ============================================================================ +// LLPanelEmojiComplete +// + +class LLPanelEmojiComplete : public LLUICtrl +{ + friend class LLUICtrlFactory; +public: + struct Params : public LLInitParam::Block + { + Optional selected_image; + + Params(); + }; + +protected: + LLPanelEmojiComplete(const LLPanelEmojiComplete::Params&); +public: + 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; + void reshape(S32 width, S32 height, BOOL called_from_parent) override; + +public: + void setEmojiHint(const std::string& hint); +protected: + size_t posToIndex(S32 x, S32 y) const; + void select(size_t emoji_idx); + void selectNext(); + void selectPrevious(); + void setFont(const LLFontGL* fontp); + void updateConstraints(); + void updateScrollPos(); + +protected: + static constexpr auto npos = std::numeric_limits::max(); + + const LLFontGL* mFont; + U16 mEmojiWidth = 0; + LLUIImagePtr mSelectedImage; + + LLWString mEmojis; + U16 mVisibleEmojis = 0; + size_t mFirstVisible = 0; + size_t mScrollPos = 0; + size_t mCurSelected = 0; + LLVector2 mLastHover; + + S32 mPadding = 8; + LLRect mRenderRect; +}; + +// ============================================================================ +// LLFloaterEmojiComplete +// + +class LLFloaterEmojiComplete : public LLFloater +{ +public: + LLFloaterEmojiComplete(const LLSD& sdKey); + +public: + void onOpen(const LLSD& key) override; +}; + +// ============================================================================ -- cgit v1.2.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.h | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) (limited to 'indra/newview/llpanelemojicomplete.h') 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; }; // ============================================================================ -- cgit v1.2.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/newview/llpanelemojicomplete.h | 1 + 1 file changed, 1 insertion(+) (limited to 'indra/newview/llpanelemojicomplete.h') 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.2.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.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'indra/newview/llpanelemojicomplete.h') 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.2.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/newview/llpanelemojicomplete.h | 3 +++ 1 file changed, 3 insertions(+) (limited to 'indra/newview/llpanelemojicomplete.h') 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.2.3 From 66f59478d09122ddf43c4ba3445754d1698bf016 Mon Sep 17 00:00:00 2001 From: Callum Linden Date: Wed, 25 Jan 2023 10:57:29 -0800 Subject: DRTVWR-489-emoji: declaring this variable as a U16 leads to a warning (and therefore an error) but only on 32bit Windows builds - 64bit is fine. I don't know why that's the case (should be both surely) but in any case, I think the variable should be declared as a size_t --- indra/newview/llpanelemojicomplete.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indra/newview/llpanelemojicomplete.h') diff --git a/indra/newview/llpanelemojicomplete.h b/indra/newview/llpanelemojicomplete.h index 2116b350be..aa0f806525 100644 --- a/indra/newview/llpanelemojicomplete.h +++ b/indra/newview/llpanelemojicomplete.h @@ -85,7 +85,7 @@ protected: LLUIImagePtr mSelectedImage; LLWString mEmojis; - U16 mVisibleEmojis = 0; + size_t mVisibleEmojis = 0; size_t mFirstVisible = 0; size_t mScrollPos = 0; size_t mCurSelected = 0; -- cgit v1.2.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.h | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) (limited to 'indra/newview/llpanelemojicomplete.h') 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.2.3 From d8cc5688eff5b540f8653a1bc39e0644b1da8d03 Mon Sep 17 00:00:00 2001 From: Andrey Kleshchev Date: Wed, 6 Sep 2023 17:51:44 +0300 Subject: SL-20209 MacOS buildfix --- indra/newview/llpanelemojicomplete.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indra/newview/llpanelemojicomplete.h') diff --git a/indra/newview/llpanelemojicomplete.h b/indra/newview/llpanelemojicomplete.h index 3456de4044..02104efbcb 100644 --- a/indra/newview/llpanelemojicomplete.h +++ b/indra/newview/llpanelemojicomplete.h @@ -70,7 +70,7 @@ public: void setEmojiHint(const std::string& hint); protected: - void LLPanelEmojiComplete::onEmojisChanged(); + void onEmojisChanged(); size_t posToIndex(S32 x, S32 y) const; void select(size_t emoji_idx); void selectNext(); -- cgit v1.2.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/newview/llpanelemojicomplete.h | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'indra/newview/llpanelemojicomplete.h') 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; -- cgit v1.2.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/newview/llpanelemojicomplete.h | 125 ++++++++++++++++++----------------- 1 file changed, 65 insertions(+), 60 deletions(-) (limited to 'indra/newview/llpanelemojicomplete.h') 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; }; // ============================================================================ -- cgit v1.2.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/newview/llpanelemojicomplete.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'indra/newview/llpanelemojicomplete.h') 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.2.3