From 838dd14d15fa8d2682da9b7c0daa8dac7ef4e243 Mon Sep 17 00:00:00 2001 From: Nimetu Date: Mon, 11 Feb 2019 14:32:13 +0200 Subject: [PATCH] Changed: Use popup menu for chat-copy function --HG-- branch : develop --- code/nel/include/nel/gui/group_paragraph.h | 7 +++ code/nel/src/gui/group_paragraph.cpp | 6 ++- .../gamedev/interfaces_v3/interaction.xml | 9 ++++ .../src/interface_v3/chat_text_manager.cpp | 43 ++++++++++++++++++- 4 files changed, 63 insertions(+), 2 deletions(-) diff --git a/code/nel/include/nel/gui/group_paragraph.h b/code/nel/include/nel/gui/group_paragraph.h index 0004850fa..02f948582 100644 --- a/code/nel/include/nel/gui/group_paragraph.h +++ b/code/nel/include/nel/gui/group_paragraph.h @@ -206,6 +206,11 @@ namespace NLGUI invalidateContent(); } + /// temporarily enable mouse over effect + // will be automatically disabled when mouse leaves element + void enableTempOver() { _TempOver = true; } + void disableTempOver() { _TempOver = false; } + /// \from CInterfaceElement void onInvalidateContent(); sint32 getMaxUsedW() const; @@ -233,6 +238,8 @@ namespace NLGUI // Do we have a color under the element pointed by the mouse bool _Over; + // Temporarily force mouse over effect. Deactivated when mouse moves away + bool _TempOver; // If over is true so we have a color NLMISC::CRGBA _OverColor; diff --git a/code/nel/src/gui/group_paragraph.cpp b/code/nel/src/gui/group_paragraph.cpp index d7d50af2e..63ebc967d 100644 --- a/code/nel/src/gui/group_paragraph.cpp +++ b/code/nel/src/gui/group_paragraph.cpp @@ -52,6 +52,7 @@ namespace NLGUI _MinW= 0; _MinH= 0; _Over = false; + _TempOver = false; _OverColor = CRGBA(255,255,255,32); _OverElt = -1; _LastW = 0; @@ -967,7 +968,7 @@ namespace NLGUI // TEMP TEMP //CViewRenderer &rVR = *CViewRenderer::getInstance(); //rVR.drawRotFlipBitmap _RenderLayer, (_XReal, _YReal, _WReal, _HReal, 0, false, rVR.getBlankTextureId(), CRGBA(0,255,0,255) ); - if (_Over) + if (_Over || _TempOver) { CViewRenderer &rVR = *CViewRenderer::getInstance(); @@ -1052,7 +1053,10 @@ namespace NLGUI _OverElt = -1; if (!isIn(eventDesc.getX(), eventDesc.getY())) + { + _TempOver = false; return false; + } for (uint32 i = 0; i < _Elements.size(); ++i) if (_Elements[i].Element->getActive()) diff --git a/code/ryzom/client/data/gamedev/interfaces_v3/interaction.xml b/code/ryzom/client/data/gamedev/interfaces_v3/interaction.xml index 90432bcff..ef30966ee 100644 --- a/code/ryzom/client/data/gamedev/interfaces_v3/interaction.xml +++ b/code/ryzom/client/data/gamedev/interfaces_v3/interaction.xml @@ -3173,4 +3173,13 @@ params="game:chatUrlBrowse()" /> + + + + diff --git a/code/ryzom/client/src/interface_v3/chat_text_manager.cpp b/code/ryzom/client/src/interface_v3/chat_text_manager.cpp index ae76eefcb..51179cf29 100644 --- a/code/ryzom/client/src/interface_v3/chat_text_manager.cpp +++ b/code/ryzom/client/src/interface_v3/chat_text_manager.cpp @@ -28,6 +28,9 @@ using namespace NLMISC; CChatTextManager* CChatTextManager::_Instance = NULL; +// last selected chat from 'copy_chat_popup' action handler +static std::string LastSelectedChat; + //================================================================================= CChatTextManager::CChatTextManager() : _TextFontSize(NULL), @@ -403,7 +406,7 @@ CViewBase *CChatTextManager::createMsgTextComplex(const ucstring &msg, NLMISC::C para->setResizeFromChildH(true); // use right click because left click might be used to activate chat window - para->setRightClickHandler("copy_to_clipboard"); + para->setRightClickHandler("copy_chat_popup"); para->setRightClickHandlerParams(msg.toUtf8()); if (plaintext) @@ -526,3 +529,41 @@ void CChatTextManager::reset () _TextShadowed = NULL; _ShowTimestamps = NULL; } + +// *************************************************************************** +// Called when we right click on a chat line +class CHandlerCopyChatPopup: public IActionHandler +{ +public: + virtual void execute(CCtrlBase *pCaller, const string ¶ms ) + { + if (pCaller == NULL) return; + + LastSelectedChat = params; + + CGroupParagraph *pGP = dynamic_cast(pCaller); + if (pGP) pGP->enableTempOver(); + + CWidgetManager::getInstance()->enableModalWindow (pCaller, "ui:interface:chat_copy_action_menu"); + } +}; +REGISTER_ACTION_HANDLER( CHandlerCopyChatPopup, "copy_chat_popup"); + +// *************************************************************************** +// Called when we right click on a chat line and choose 'copy' from context menu +class CHandlerCopyChat: public IActionHandler +{ +public: + virtual void execute(CCtrlBase *pCaller, const string ¶ms ) + { + if (pCaller == NULL) return; + + CGroupParagraph *pGP = dynamic_cast(pCaller); + if (pGP) pGP->disableTempOver(); + + CAHManager::getInstance()->runActionHandler("copy_to_clipboard", NULL, LastSelectedChat); + CWidgetManager::getInstance()->disableModalWindow(); + } +}; +REGISTER_ACTION_HANDLER( CHandlerCopyChat, "copy_chat"); +