Merge with develop

--HG--
branch : compatibility-develop
hg/compatibility-develop
Nimetu 6 years ago
commit 85c52973e7

@ -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;

@ -442,9 +442,9 @@ namespace NLGUI
// Clear all the lines and free their datas
void clearLines();
// Update in the case of a multiline text
void updateTextContextMultiLine(uint nMaxWidth);
void updateTextContextMultiLine(float nMaxWidth);
// Update in the case of a multiline text with justification
void updateTextContextMultiLineJustified(uint nMaxWidth, bool expandSpaces);
void updateTextContextMultiLineJustified(float nMaxWidth, bool expandSpaces);
// Recompute font size info
void computeFontSize ();

@ -748,8 +748,12 @@ namespace NLGUI
{
virtual void execute (CCtrlBase *pCaller, const std::string &params)
{
if (!CViewRenderer::getInstance()->getDriver()->copyTextToClipboard(params))
ucstring s;
s.fromUtf8(params);
if (!CViewRenderer::getInstance()->getDriver()->copyTextToClipboard(s))
{
nlwarning("Copy to clipboard failed: '%s'", params.c_str());
}
}
};
REGISTER_ACTION_HANDLER(CAHCopyToClipboard, "copy_to_clipboard");

@ -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())

@ -1631,7 +1631,7 @@ namespace NLGUI
// ***************************************************************************
void CViewText::updateTextContextMultiLine(uint nMaxWidth)
void CViewText::updateTextContextMultiLine(float nMaxWidth)
{
ucchar ucLetter;
UTextContext::CStringInfo si;
@ -1744,7 +1744,7 @@ namespace NLGUI
}
// ***************************************************************************
void CViewText::updateTextContextMultiLineJustified(uint nMaxWidth, bool expandSpaces)
void CViewText::updateTextContextMultiLineJustified(float nMaxWidth, bool expandSpaces)
{
NL3D::UTextContext *TextContext = CViewRenderer::getTextContext(_FontName);
UTextContext::CStringInfo si;
@ -1850,10 +1850,10 @@ namespace NLGUI
}
//
// Does the word go beyond the end of line ?
if (!lineFeed && newLineWidth > (float) nMaxWidth)
if (!lineFeed && newLineWidth > nMaxWidth)
{
// Have we enough room for this word on a line ?
bool roomForThisWord = (numWordsInLine > 0) || ( (newLineWidth - lineWidth) < (float) nMaxWidth );
bool roomForThisWord = (numWordsInLine > 0) || ( (newLineWidth - lineWidth) < nMaxWidth );
// not enough room for that word
// If it is the only word of the line, just split it
@ -1930,7 +1930,7 @@ namespace NLGUI
word.build(wordValue, *TextContext, numSpaces);
word.Format= wordFormat;
_Lines.push_back(TLineSPtr(new CLine));
float roomForSpaces = (float) nMaxWidth - word.Info.StringWidth;
float roomForSpaces = nMaxWidth - word.Info.StringWidth;
if (expandSpaces && numSpaces != 0)
{
_Lines.back()->setSpaceWidth(roomForSpaces / (float) numSpaces);

@ -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 &params )
{
if (pCaller == NULL) return;
LastSelectedChat = params;
CGroupParagraph *pGP = dynamic_cast<CGroupParagraph *>(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 &params )
{
if (pCaller == NULL) return;
CGroupParagraph *pGP = dynamic_cast<CGroupParagraph *>(pCaller);
if (pGP) pGP->disableTempOver();
CAHManager::getInstance()->runActionHandler("copy_to_clipboard", NULL, LastSelectedChat);
CWidgetManager::getInstance()->disableModalWindow();
}
};
REGISTER_ACTION_HANDLER( CHandlerCopyChat, "copy_chat");

Loading…
Cancel
Save