CHUI-160 FIXED (Text entered in local chat text field scrolls up and becomes only partially visible after hitting return)

- Replaced LLLineEditor with LLChatEntry in nearby chat
- Moved reshape method from LLIMFloater to the base LLIMConversation so that vertical reshaping work properly for both LLNearbyChat and LLIMFloater
master
Paul ProductEngine 2012-06-22 16:54:42 +03:00
parent d866328f6a
commit 6bb554fc36
7 changed files with 52 additions and 44 deletions

View File

@ -29,6 +29,8 @@
#include "llimconversation.h"
#include "llchatentry.h"
#include "llchathistory.h"
#include "lldraghandle.h"
#include "llfloaterreg.h"
#include "llimfloater.h"
@ -47,6 +49,9 @@ LLIMConversation::LLIMConversation(const LLUUID& session_id)
, mCloseBtn(NULL)
, mSessionID(session_id)
, mParticipantList(NULL)
, mChatHistory(NULL)
, mInputEditor(NULL)
, mInputEditorTopPad(0)
{
mCommitCallbackRegistrar.add("IMSession.Menu.Action",
boost::bind(&LLIMConversation::onIMSessionMenuItemClicked, this, _2));
@ -86,6 +91,12 @@ BOOL LLIMConversation::postBuild()
mTearOffBtn = getChild<LLButton>("tear_off_btn");
mTearOffBtn->setCommitCallback(boost::bind(&LLIMConversation::onTearOffClicked, this));
mChatHistory = getChild<LLChatHistory>("chat_history");
mInputEditor = getChild<LLChatEntry>("chat_editor");
mInputEditor->setTextExpandedCallback(boost::bind(&LLIMConversation::reshapeChatHistory, this));
mInputEditorTopPad = mChatHistory->getRect().mBottom - mInputEditor->getRect().mTop;
if (!getTornOff())
{
setOpenPositioning(LLFloaterEnums::POSITIONING_RELATIVE);
@ -242,6 +253,17 @@ void LLIMConversation::updateHeaderAndToolbar()
showTranslationCheckbox();
}
void LLIMConversation::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);
}
void LLIMConversation::showTranslationCheckbox(BOOL show)
{
getChild<LLUICtrl>("translate_chat_checkbox_lp")->setVisible(mIsNearbyChat? show : FALSE);

View File

@ -35,6 +35,8 @@
#include "lleventtimer.h"
class LLPanelChatControlPanel;
class LLChatEntry;
class LLChatHistory;
class LLIMConversation
: public LLTransientDockableFloater
@ -102,6 +104,18 @@ protected:
private:
/// Update floater header and toolbar buttons when hosted/torn off state is toggled.
void updateHeaderAndToolbar();
/**
* 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();
LLChatHistory* mChatHistory;
LLChatEntry* mInputEditor;
int mInputEditorTopPad; // padding between input field and chat history
};

View File

@ -64,7 +64,6 @@ LLIMFloater::LLIMFloater(const LLUUID& session_id)
mLastMessageIndex(-1),
mDialog(IM_NOTHING_SPECIAL),
mInputEditor(NULL),
mInputEditorTopPad(0),
mSavedTitle(),
mTypingStart(),
mShouldSendTypingState(false),
@ -314,12 +313,9 @@ BOOL LLIMFloater::postBuild()
mInputEditor->setPassDelete( TRUE );
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");
@ -1171,17 +1167,6 @@ 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()
{

View File

@ -163,13 +163,6 @@ 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);
@ -180,8 +173,6 @@ private:
LLChatHistory* mChatHistory;
int mInputEditorTopPad; // padding between input field and chat history
EInstantMessage mDialog;
LLUUID mOtherParticipantUUID;
LLChatEntry* mInputEditor;

View File

@ -30,6 +30,7 @@
#include "lliconctrl.h"
#include "llappviewer.h"
#include "llchatentry.h"
#include "llfloaterreg.h"
#include "lltrans.h"
#include "llimfloatercontainer.h"
@ -138,19 +139,14 @@ LLNearbyChat::LLNearbyChat(const LLSD& key)
//virtual
BOOL LLNearbyChat::postBuild()
{
mChatBox = getChild<LLLineEditor>("chat_editor");
mChatBox = getChild<LLChatEntry>("chat_editor");
mChatBox->setCommitCallback(boost::bind(&LLNearbyChat::onChatBoxCommit, this));
mChatBox->setKeystrokeCallback(&onChatBoxKeystroke, this);
mChatBox->setKeystrokeCallback(boost::bind(&onChatBoxKeystroke, _1, this));
mChatBox->setFocusLostCallback(boost::bind(&onChatBoxFocusLost, _1, this));
mChatBox->setFocusReceivedCallback(boost::bind(&LLNearbyChat::onChatBoxFocusReceived, this));
mChatBox->setIgnoreArrowKeys( FALSE );
mChatBox->setCommitOnFocusLost( FALSE );
mChatBox->setRevertOnEsc( FALSE );
mChatBox->setIgnoreTab(TRUE);
mChatBox->setPassDelete(TRUE);
mChatBox->setReplaceNewlinesWithSpaces(FALSE);
mChatBox->setEnableLineHistory(TRUE);
mChatBox->setFont(LLViewerChat::getChatFont());
// mOutputMonitor = getChild<LLOutputMonitorCtrl>("chat_zone_indicator");
@ -459,7 +455,7 @@ BOOL LLNearbyChat::matchChatTypeTrigger(const std::string& in_str, std::string*
return string_was_found;
}
void LLNearbyChat::onChatBoxKeystroke(LLLineEditor* caller, void* userdata)
void LLNearbyChat::onChatBoxKeystroke(LLTextEditor* caller, void* userdata)
{
LLFirstUse::otherAvatarChatFirst(false);
@ -513,17 +509,16 @@ void LLNearbyChat::onChatBoxKeystroke(LLLineEditor* caller, void* userdata)
{
std::string rest_of_match = utf8_out_str.substr(utf8_trigger.size());
self->mChatBox->setText(utf8_trigger + rest_of_match); // keep original capitalization for user-entered part
S32 outlength = self->mChatBox->getLength(); // in characters
// Select to end of line, starting from the character
// after the last one the user typed.
self->mChatBox->setSelection(length, outlength);
self->mChatBox->selectNext(rest_of_match, false);
}
else if (matchChatTypeTrigger(utf8_trigger, &utf8_out_str))
{
std::string rest_of_match = utf8_out_str.substr(utf8_trigger.size());
self->mChatBox->setText(utf8_trigger + rest_of_match + " "); // keep original capitalization for user-entered part
self->mChatBox->setCursorToEnd();
self->mChatBox->endOfDoc();
}
//llinfos << "GESTUREDEBUG " << trigger
@ -581,11 +576,11 @@ void LLNearbyChat::sendChat( EChatType type )
{
if (mChatBox)
{
LLWString text = mChatBox->getConvertedText();
LLWString text = mChatBox->getWText();
LLWStringUtil::trim(text);
LLWStringUtil::replaceChar(text,182,'\n'); // Convert paragraph symbols back into newlines.
if (!text.empty())
{
// store sent line in history, duplicates will get filtered
mChatBox->updateHistory();
// Check if this is destined for another channel
S32 channel = 0;
stripChannelNumber(text, &channel);
@ -794,7 +789,7 @@ void LLNearbyChat::startChat(const char* line)
cb->mChatBox->setText(line_string);
}
cb->mChatBox->setCursorToEnd();
cb->mChatBox->endOfDoc();
}
}

View File

@ -71,7 +71,7 @@ public:
void onNearbyChatContextMenuItemClicked(const LLSD& userdata);
bool onNearbyChatCheckContextMenuItem(const LLSD& userdata);
LLLineEditor* getChatBox() { return mChatBox; }
LLChatEntry* getChatBox() { return mChatBox; }
//virtual void draw();
@ -90,7 +90,7 @@ public:
protected:
static BOOL matchChatTypeTrigger(const std::string& in_str, std::string* out_str);
static void onChatBoxKeystroke(LLLineEditor* caller, void* userdata);
static void onChatBoxKeystroke(LLTextEditor* caller, void* userdata);
static void onChatBoxFocusLost(LLFocusableElement* caller, void* userdata);
void onChatBoxFocusReceived();
@ -113,7 +113,7 @@ protected:
// Which non-zero channel did we last chat on?
static S32 sLastSpecialChatChannel;
LLLineEditor* mChatBox;
LLChatEntry* mChatBox;
LLOutputMonitorCtrl* mOutputMonitor;
LLLocalSpeakerMgr* mSpeakerMgr;

View File

@ -56,6 +56,7 @@
// linden library includes
#include "llaudioengine.h" // mute on minimize
#include "llchatentry.h"
#include "indra_constants.h"
#include "llassetstorage.h"
#include "llerrorcontrol.h"
@ -2492,7 +2493,7 @@ BOOL LLViewerWindow::handleKey(KEY key, MASK mask)
if (nearby_chat)
{
LLLineEditor* chat_editor = nearby_chat->getChatBox();
LLChatEntry* chat_editor = nearby_chat->getChatBox();
// arrow keys move avatar while chatting hack
if (chat_editor && chat_editor->hasFocus())
@ -2555,7 +2556,7 @@ BOOL LLViewerWindow::handleKey(KEY key, MASK mask)
if ( gSavedSettings.getS32("LetterKeysFocusChatBar") && !gAgentCamera.cameraMouselook() &&
!keyboard_focus && key < 0x80 && (mask == MASK_NONE || mask == MASK_SHIFT) )
{
LLLineEditor* chat_editor = LLNearbyChat::getInstance()->getChatBox();
LLChatEntry* chat_editor = LLNearbyChat::getInstance()->getChatBox();
if (chat_editor)
{
// passing NULL here, character will be added later when it is handled by character handler.