diff options
Diffstat (limited to 'indra/newview')
| -rw-r--r-- | indra/newview/llfloaterimsessiontab.cpp | 42 | ||||
| -rw-r--r-- | indra/newview/llfloaterimsessiontab.h | 5 | 
2 files changed, 45 insertions, 2 deletions
diff --git a/indra/newview/llfloaterimsessiontab.cpp b/indra/newview/llfloaterimsessiontab.cpp index 655674357f..50e765c236 100644 --- a/indra/newview/llfloaterimsessiontab.cpp +++ b/indra/newview/llfloaterimsessiontab.cpp @@ -39,6 +39,7 @@  #include "llchicletbar.h"  #include "lldraghandle.h"  #include "llemojidictionary.h" +#include "llemojihelper.h"  #include "llfloaterreg.h"  #include "llfloateremojipicker.h"  #include "llfloaterimsession.h" @@ -300,6 +301,8 @@ bool LLFloaterIMSessionTab::postBuild()      mEmojiPickerShowBtn = getChild<LLButton>("emoji_picker_show_btn");      mEmojiPickerShowBtn->setClickedCallback([this](LLUICtrl*, const LLSD&) { onEmojiPickerShowBtnClicked(); }); +    mEmojiPickerShowBtn->setMouseDownCallback([this](LLUICtrl*, const LLSD&) { onEmojiPickerShowBtnDown(); }); +    mEmojiCloseConn = LLEmojiHelper::instance().setCloseCallback([this](LLUICtrl*, const LLSD&) { onEmojiPickerClosed(); });      mGearBtn = getChild<LLButton>("gear_btn");      mAddBtn = getChild<LLButton>("add_btn"); @@ -532,8 +535,43 @@ void LLFloaterIMSessionTab::onEmojiRecentPanelToggleBtnClicked()  void LLFloaterIMSessionTab::onEmojiPickerShowBtnClicked()  { -    mInputEditor->setFocus(true); -    mInputEditor->showEmojiHelper(); +    if (!mEmojiPickerShowBtn->getToggleState()) +    { +        mInputEditor->hideEmojiHelper(); +        mInputEditor->setFocus(true); +        mInputEditor->showEmojiHelper(); +        mEmojiPickerShowBtn->setToggleState(true); // in case hideEmojiHelper closed a visible instance +    } +    else +    { +        mInputEditor->hideEmojiHelper(); +        mEmojiPickerShowBtn->setToggleState(false); +    } +} + +void LLFloaterIMSessionTab::onEmojiPickerShowBtnDown() +{ +    if (mEmojiHelperLastCallbackFrame == LLFrameTimer::getFrameCount()) +    { +        // Helper gets closed by focus lost event on Down before before onEmojiPickerShowBtnDown +        // triggers. +        // If this condition is true, user pressed button and it was 'toggled' during press, +        // restore 'toggled' state so that button will not reopen helper. +        mEmojiPickerShowBtn->setToggleState(true); +    } +} + +void LLFloaterIMSessionTab::onEmojiPickerClosed() +{ +    if (mEmojiPickerShowBtn->getToggleState()) +    { +        mEmojiPickerShowBtn->setToggleState(false); +        // Helper gets closed by focus lost event on Down before onEmojiPickerShowBtnDown +        // triggers. If mEmojiHelperLastCallbackFrame is set and matches Down, means close +        // was triggered by user's press. +        // A bit hacky, but I can't think of a better way to handle this without rewriting helper. +        mEmojiHelperLastCallbackFrame = LLFrameTimer::getFrameCount(); +    }  }  void LLFloaterIMSessionTab::initEmojiRecentPanel() diff --git a/indra/newview/llfloaterimsessiontab.h b/indra/newview/llfloaterimsessiontab.h index 367d988f26..6d04d622e1 100644 --- a/indra/newview/llfloaterimsessiontab.h +++ b/indra/newview/llfloaterimsessiontab.h @@ -235,6 +235,8 @@ private:      void onEmojiRecentPanelToggleBtnClicked();      void onEmojiPickerShowBtnClicked(); +    void onEmojiPickerShowBtnDown(); +    void onEmojiPickerClosed();      void initEmojiRecentPanel();      void onEmojiRecentPanelFocusReceived();      void onEmojiRecentPanelFocusLost(); @@ -249,6 +251,9 @@ private:      S32 mInputEditorPad;      S32 mChatLayoutPanelHeight;      S32 mFloaterHeight; + +    boost::signals2::connection mEmojiCloseConn; +    U32 mEmojiHelperLastCallbackFrame = { 0 };  };  | 
