From b4c4a951c161e43bf66141248f0c94b97848ae98 Mon Sep 17 00:00:00 2001 From: Mnikolenko Productengine Date: Wed, 1 Mar 2017 17:53:26 +0200 Subject: MAINT-3604 Extend llTextBox message lines according to it's length --- indra/newview/lltoastscripttextbox.cpp | 57 +++++++++------- indra/newview/lltoastscripttextbox.h | 3 + .../skins/default/xui/en/panel_notify_textbox.xml | 78 ++++++++++++---------- 3 files changed, 79 insertions(+), 59 deletions(-) diff --git a/indra/newview/lltoastscripttextbox.cpp b/indra/newview/lltoastscripttextbox.cpp index 78d9e92b5c..776ae2ece9 100644 --- a/indra/newview/lltoastscripttextbox.cpp +++ b/indra/newview/lltoastscripttextbox.cpp @@ -28,31 +28,21 @@ #include "lltoastscripttextbox.h" -#include "llfocusmgr.h" - -#include "llbutton.h" +#include "lllslconstants.h" #include "llnotifications.h" -#include "llviewertexteditor.h" - -#include "llavatarnamecache.h" -#include "lluiconstants.h" -#include "llui.h" -#include "llviewercontrol.h" -#include "lltrans.h" #include "llstyle.h" +#include "lluiconstants.h" +#include "llviewertexteditor.h" -#include "llglheaders.h" -#include "llagent.h" - -const S32 LLToastScriptTextbox::DEFAULT_MESSAGE_MAX_LINE_COUNT= 7; +const S32 LLToastScriptTextbox::DEFAULT_MESSAGE_MAX_LINE_COUNT= 14; LLToastScriptTextbox::LLToastScriptTextbox(const LLNotificationPtr& notification) : LLToastPanel(notification) { buildFromFile( "panel_notify_textbox.xml"); - LLTextEditor* text_editorp = getChild("text_editor_box"); - text_editorp->setValue(notification->getMessage()); + mInfoText = getChild("text_editor_box"); + mInfoText->setValue(notification->getMessage()); getChild("ignore_btn")->setClickedCallback(boost::bind(&LLToastScriptTextbox::onClickIgnore, this)); @@ -73,13 +63,7 @@ LLToastScriptTextbox::LLToastScriptTextbox(const LLNotificationPtr& notification pSubmitBtn->setClickedCallback((boost::bind(&LLToastScriptTextbox::onClickSubmit, this))); setDefaultBtn(pSubmitBtn); - S32 maxLinesCount; - std::istringstream ss( getString("message_max_lines_count") ); - if (!(ss >> maxLinesCount)) - { - maxLinesCount = DEFAULT_MESSAGE_MAX_LINE_COUNT; - } - //snapToMessageHeight(pMessageText, maxLinesCount); + snapToMessageHeight(); } // virtual @@ -92,7 +76,6 @@ void LLToastScriptTextbox::close() die(); } -#include "lllslconstants.h" void LLToastScriptTextbox::onClickSubmit() { LLViewerTextEditor* pMessageText = getChild("message"); @@ -119,3 +102,29 @@ void LLToastScriptTextbox::onClickIgnore() mNotification->respond(response); close(); } + +void LLToastScriptTextbox::snapToMessageHeight() +{ + LLPanel* info_pan = getChild("info_panel"); + if (!info_pan) + { + return; + } + + S32 maxLinesCount; + std::istringstream ss( getString("message_max_lines_count") ); + if (!(ss >> maxLinesCount)) + { + maxLinesCount = DEFAULT_MESSAGE_MAX_LINE_COUNT; + } + + + S32 maxTextHeight = (mInfoText->getFont()->getLineHeight() * maxLinesCount); + S32 oldTextHeight = mInfoText->getRect().getHeight(); + S32 newTextHeight = llmin(mInfoText->getTextBoundingRect().getHeight(), maxTextHeight); + + S32 heightDelta = newTextHeight - oldTextHeight; + + reshape( getRect().getWidth(), llmax(getRect().getHeight() + heightDelta, MIN_PANEL_HEIGHT)); + info_pan->reshape(info_pan->getRect().getWidth(),newTextHeight); +} diff --git a/indra/newview/lltoastscripttextbox.h b/indra/newview/lltoastscripttextbox.h index 7d33446248..7aee02dd00 100644 --- a/indra/newview/lltoastscripttextbox.h +++ b/indra/newview/lltoastscripttextbox.h @@ -48,9 +48,12 @@ public: private: + LLTextBox* mInfoText; + void onClickSubmit(); void onClickIgnore(); + void snapToMessageHeight(); static const S32 DEFAULT_MESSAGE_MAX_LINE_COUNT; }; diff --git a/indra/newview/skins/default/xui/en/panel_notify_textbox.xml b/indra/newview/skins/default/xui/en/panel_notify_textbox.xml index d5b6057233..a679ca7f8c 100644 --- a/indra/newview/skins/default/xui/en/panel_notify_textbox.xml +++ b/indra/newview/skins/default/xui/en/panel_notify_textbox.xml @@ -1,7 +1,7 @@ + value="14" /> - + - + - + left="0" + name="textbox_panel" + top_pad="5" + width="305"> + + + top_pad="5">