diff options
author | Paul ProductEngine <pguslisty@productengine.com> | 2012-06-19 09:44:40 +0300 |
---|---|---|
committer | Paul ProductEngine <pguslisty@productengine.com> | 2012-06-19 09:44:40 +0300 |
commit | 18aabdfd3d2efc1b5507e2fe001cfc36ee84b710 (patch) | |
tree | 37de4bcd2bab29869575a2c64670ff826f96b38d /indra/newview | |
parent | 7edcbb1613d30f9fecf3ccbe342d45b7761f5b56 (diff) |
CHUI-127 FIXED (Make chat field auto resizable)
- Replaced LLLineEditor with newly created LLChatEntry
- Moved some functionality (such as setting label) to the LLTextBase as it can be useful to the other derived classes
Diffstat (limited to 'indra/newview')
-rw-r--r-- | indra/newview/llexpandabletextbox.cpp | 4 | ||||
-rw-r--r-- | indra/newview/llgrouplist.cpp | 2 | ||||
-rw-r--r-- | indra/newview/llimfloater.cpp | 34 | ||||
-rw-r--r-- | indra/newview/llimfloater.h | 17 | ||||
-rw-r--r-- | indra/newview/llpaneltopinfobar.cpp | 2 | ||||
-rw-r--r-- | indra/newview/lltoastgroupnotifypanel.cpp | 2 | ||||
-rw-r--r-- | indra/newview/lltoastpanel.cpp | 2 | ||||
-rw-r--r-- | indra/newview/lltoastscripttextbox.cpp | 2 | ||||
-rw-r--r-- | indra/newview/skins/default/xui/en/floater_im_session.xml | 9 | ||||
-rw-r--r-- | indra/newview/skins/default/xui/en/widgets/text.xml | 1 |
10 files changed, 52 insertions, 23 deletions
diff --git a/indra/newview/llexpandabletextbox.cpp b/indra/newview/llexpandabletextbox.cpp index 935dcb74b0..a50184460b 100644 --- a/indra/newview/llexpandabletextbox.cpp +++ b/indra/newview/llexpandabletextbox.cpp @@ -150,7 +150,7 @@ void LLExpandableTextBox::LLTextBoxEx::showExpandText() std::pair<S32, S32> visible_lines = getVisibleLines(true); S32 last_line = visible_lines.second - 1; - LLStyle::Params expander_style(getDefaultStyleParams()); + LLStyle::Params expander_style(getStyleParams()); expander_style.font.style = "UNDERLINE"; expander_style.color = LLUIColorTable::instance().getColor("HTMLLinkColor"); LLExpanderSegment* expanderp = new LLExpanderSegment(new LLStyle(expander_style), getLineStart(last_line), getLength() + 1, mExpanderLabel, *this); @@ -166,7 +166,7 @@ void LLExpandableTextBox::LLTextBoxEx::hideExpandText() if (mExpanderVisible) { // this will overwrite the expander segment and all text styling with a single style - LLStyleConstSP sp(new LLStyle(getDefaultStyleParams())); + LLStyleConstSP sp(new LLStyle(getStyleParams())); LLNormalTextSegment* segmentp = new LLNormalTextSegment(sp, 0, getLength() + 1, *this); insertSegment(segmentp); diff --git a/indra/newview/llgrouplist.cpp b/indra/newview/llgrouplist.cpp index 2de891565c..aba3d74d87 100644 --- a/indra/newview/llgrouplist.cpp +++ b/indra/newview/llgrouplist.cpp @@ -406,7 +406,7 @@ void LLGroupListItem::setActive(bool active) // *BUG: setName() overrides the style params. // Active group should be bold. - LLFontDescriptor new_desc(mGroupNameBox->getDefaultFont()->getFontDesc()); + LLFontDescriptor new_desc(mGroupNameBox->getFont()->getFontDesc()); // *NOTE dzaporozhan // On Windows LLFontGL::NORMAL will not remove LLFontGL::BOLD if font diff --git a/indra/newview/llimfloater.cpp b/indra/newview/llimfloater.cpp index 30a9c29ec6..dde7d248dd 100644 --- a/indra/newview/llimfloater.cpp +++ b/indra/newview/llimfloater.cpp @@ -44,7 +44,7 @@ #include "llimfloatercontainer.h" // to replace separate IM Floaters with multifloater container #include "llinventoryfunctions.h" //#include "lllayoutstack.h" -#include "lllineeditor.h" +#include "llchatentry.h" #include "lllogchat.h" #include "llscreenchannel.h" #include "llsyswellwindow.h" @@ -64,6 +64,7 @@ LLIMFloater::LLIMFloater(const LLUUID& session_id) mLastMessageIndex(-1), mDialog(IM_NOTHING_SPECIAL), mInputEditor(NULL), + mInputEditorTopPad(0), mSavedTitle(), mTypingStart(), mShouldSendTypingState(false), @@ -190,7 +191,9 @@ void LLIMFloater::sendMsg() { if (mInputEditor) { - LLWString text = mInputEditor->getConvertedText(); + LLWString text = mInputEditor->getWText(); + LLWStringUtil::trim(text); + LLWStringUtil::replaceChar(text,182,'\n'); // Convert paragraph symbols back into newlines. if(!text.empty()) { // Truncate and convert to UTF8 for transport @@ -287,26 +290,26 @@ BOOL LLIMFloater::postBuild() { LLIMConversation::postBuild(); - mInputEditor = getChild<LLLineEditor>("chat_editor"); + mInputEditor = getChild<LLChatEntry>("chat_editor"); mInputEditor->setMaxTextLength(1023); // enable line history support for instant message bar - mInputEditor->setEnableLineHistory(TRUE); LLFontGL* font = LLViewerChat::getChatFont(); mInputEditor->setFont(font); mInputEditor->setFocusReceivedCallback( boost::bind(onInputEditorFocusReceived, _1, this) ); mInputEditor->setFocusLostCallback( boost::bind(onInputEditorFocusLost, _1, this) ); - mInputEditor->setKeystrokeCallback( onInputEditorKeystroke, this ); + mInputEditor->setKeystrokeCallback( boost::bind(onInputEditorKeystroke, _1, this) ); mInputEditor->setCommitOnFocusLost( FALSE ); - mInputEditor->setRevertOnEsc( FALSE ); - mInputEditor->setReplaceNewlinesWithSpaces( FALSE ); mInputEditor->setPassDelete( TRUE ); - childSetCommitCallback("chat_editor", onSendMsg, this); + mInputEditor->setCommitCallback(boost::bind(onSendMsg, _1, this)); + mInputEditor->setTextExpandedCallback(boost::bind(&LLIMFloater::reshapeChatHistory, this)); mChatHistory = getChild<LLChatHistory>("chat_history"); + mInputEditorTopPad = mChatHistory->getRect().mBottom - mInputEditor->getRect().mTop; + setDocked(true); mTypingStart = LLTrans::getString("IM_typing_start_string"); @@ -880,7 +883,7 @@ void LLIMFloater::onInputEditorFocusLost(LLFocusableElement* caller, void* userd } // static -void LLIMFloater::onInputEditorKeystroke(LLLineEditor* caller, void* userdata) +void LLIMFloater::onInputEditorKeystroke(LLTextEditor* caller, void* userdata) { LLIMFloater* self = (LLIMFloater*) userdata; std::string text = self->mInputEditor->getText(); @@ -1077,7 +1080,7 @@ private: BOOL LLIMFloater::inviteToSession(const uuid_vec_t& ids) { LLViewerRegion* region = gAgent.getRegion(); - bool is_region_exist = !!region; + bool is_region_exist = region != NULL; if (is_region_exist) { @@ -1158,6 +1161,17 @@ void LLIMFloater::removeTypingIndicator(const LLIMInfo* im_info) } } +void LLIMFloater::reshapeChatHistory() +{ + LLRect chat_rect = mChatHistory->getRect(); + LLRect input_rect = mInputEditor->getRect(); + + int delta_height = chat_rect.mBottom - (input_rect.mTop + mInputEditorTopPad); + + chat_rect.setLeftTopAndSize(chat_rect.mLeft, chat_rect.mTop, chat_rect.getWidth(), chat_rect.getHeight() + delta_height); + mChatHistory->setShape(chat_rect); +} + // static void LLIMFloater::closeHiddenIMToasts() { diff --git a/indra/newview/llimfloater.h b/indra/newview/llimfloater.h index 333340c696..1992bd930c 100644 --- a/indra/newview/llimfloater.h +++ b/indra/newview/llimfloater.h @@ -37,7 +37,9 @@ class LLAvatarName; class LLButton; -class LLLineEditor; +class LLChatEntry; +class LLTextEditor; +class LLPanelChatControlPanel; class LLChatHistory; class LLInventoryItem; class LLInventoryCategory; @@ -142,7 +144,7 @@ private: void appendMessage(const LLChat& chat, const LLSD &args = 0); static void onInputEditorFocusReceived( LLFocusableElement* caller,void* userdata ); static void onInputEditorFocusLost(LLFocusableElement* caller, void* userdata); - static void onInputEditorKeystroke(LLLineEditor* caller, void* userdata); + static void onInputEditorKeystroke(LLTextEditor* caller, void* userdata); void setTyping(bool typing); void onAddButtonClicked(); void onAvatarPicked(const uuid_vec_t& ids, const std::vector<LLAvatarName> names); @@ -161,6 +163,13 @@ private: // Remove the "User is typing..." indicator. void removeTypingIndicator(const LLIMInfo* im_info = NULL); + /** + * Adjusts chat history height to fit vertically with input chat field + * and avoid overlapping, since input chat field can be vertically expanded. + * Implementation: chat history bottom "follows" top+top_pad of input chat field + */ + void reshapeChatHistory(); + static void closeHiddenIMToasts(); static void confirmLeaveCallCallback(const LLSD& notification, const LLSD& response); @@ -171,9 +180,11 @@ private: LLChatHistory* mChatHistory; + int mInputEditorTopPad; // padding between input field and chat history + EInstantMessage mDialog; LLUUID mOtherParticipantUUID; - LLLineEditor* mInputEditor; + LLChatEntry* mInputEditor; bool mPositioned; std::string mSavedTitle; diff --git a/indra/newview/llpaneltopinfobar.cpp b/indra/newview/llpaneltopinfobar.cpp index 280cc11179..854deb00d0 100644 --- a/indra/newview/llpaneltopinfobar.cpp +++ b/indra/newview/llpaneltopinfobar.cpp @@ -230,7 +230,7 @@ void LLPanelTopInfoBar::buildLocationString(std::string& loc_str, bool show_coor void LLPanelTopInfoBar::setParcelInfoText(const std::string& new_text) { LLRect old_rect = getRect(); - const LLFontGL* font = mParcelInfoText->getDefaultFont(); + const LLFontGL* font = mParcelInfoText->getFont(); S32 new_text_width = font->getWidth(new_text); mParcelInfoText->setText(new_text); diff --git a/indra/newview/lltoastgroupnotifypanel.cpp b/indra/newview/lltoastgroupnotifypanel.cpp index 707d2d9765..ed350ea144 100644 --- a/indra/newview/lltoastgroupnotifypanel.cpp +++ b/indra/newview/lltoastgroupnotifypanel.cpp @@ -112,7 +112,7 @@ LLToastGroupNotifyPanel::LLToastGroupNotifyPanel(const LLNotificationPtr& notifi style.font = date_font; pMessageText->appendText(timeStr + "\n", TRUE, style); - style.font = pMessageText->getDefaultFont(); + style.font = pMessageText->getFont(); pMessageText->appendText(message, TRUE, style); //attachment diff --git a/indra/newview/lltoastpanel.cpp b/indra/newview/lltoastpanel.cpp index e20d516392..09f8dcf83c 100644 --- a/indra/newview/lltoastpanel.cpp +++ b/indra/newview/lltoastpanel.cpp @@ -68,7 +68,7 @@ void LLToastPanel::snapToMessageHeight(LLTextBase* message, S32 maxLineCount) if (message->getVisible()) { S32 heightDelta = 0; - S32 maxTextHeight = message->getDefaultFont()->getLineHeight() * maxLineCount; + S32 maxTextHeight = message->getFont()->getLineHeight() * maxLineCount; LLRect messageRect = message->getRect(); S32 oldTextHeight = messageRect.getHeight(); diff --git a/indra/newview/lltoastscripttextbox.cpp b/indra/newview/lltoastscripttextbox.cpp index 2529ec865a..45fbabad59 100644 --- a/indra/newview/lltoastscripttextbox.cpp +++ b/indra/newview/lltoastscripttextbox.cpp @@ -65,7 +65,7 @@ LLToastScriptTextbox::LLToastScriptTextbox(const LLNotificationPtr& notification pMessageText->clear(); LLStyle::Params style; - style.font = pMessageText->getDefaultFont(); + style.font = pMessageText->getFont(); pMessageText->appendText(message, TRUE, style); //submit button diff --git a/indra/newview/skins/default/xui/en/floater_im_session.xml b/indra/newview/skins/default/xui/en/floater_im_session.xml index a4695b8c09..f6d5b20a65 100644 --- a/indra/newview/skins/default/xui/en/floater_im_session.xml +++ b/indra/newview/skins/default/xui/en/floater_im_session.xml @@ -242,18 +242,21 @@ bottom="-1" follows="left|right|bottom" tab_group="1"> - <line_editor + <text_editor bottom="0" + expand_lines_count="5" follows="left|right|bottom" font="SansSerifSmall" visible="true" height="20" + is_expandable="true" label="To" layout="bottomleft" name="chat_editor" tab_group="3" - width="220"> - </line_editor> + width="240" + wrap="true"> + </text_editor> </panel> </layout_panel> </layout_stack> diff --git a/indra/newview/skins/default/xui/en/widgets/text.xml b/indra/newview/skins/default/xui/en/widgets/text.xml index 134f2d7522..2102074674 100644 --- a/indra/newview/skins/default/xui/en/widgets/text.xml +++ b/indra/newview/skins/default/xui/en/widgets/text.xml @@ -9,6 +9,7 @@ h_pad="0" allow_scroll="false" text_readonly_color="LabelTextColor" + text_tentative_color="TextFgTentativeColor" bg_writeable_color="FloaterDefaultBackgroundColor" use_ellipses="false" bg_visible="false" |