summaryrefslogtreecommitdiff
path: root/indra/newview/llchatbar.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'indra/newview/llchatbar.cpp')
-rw-r--r--indra/newview/llchatbar.cpp147
1 files changed, 67 insertions, 80 deletions
diff --git a/indra/newview/llchatbar.cpp b/indra/newview/llchatbar.cpp
index 2395f3c5ae..5e97157694 100644
--- a/indra/newview/llchatbar.cpp
+++ b/indra/newview/llchatbar.cpp
@@ -67,7 +67,7 @@
#include "llui.h"
#include "llviewermenu.h"
#include "lluictrlfactory.h"
-
+#include "llbottomtray.h"
//
// Globals
@@ -76,11 +76,6 @@ const F32 AGENT_TYPING_TIMEOUT = 5.f; // seconds
LLChatBar *gChatBar = NULL;
-// legacy calllback glue
-void toggleChatHistory(void* user_data);
-void send_chat_from_viewer(const std::string& utf8_out_text, EChatType type, S32 channel);
-
-
class LLChatBarGestureObserver : public LLGestureManagerObserver
{
public:
@@ -97,7 +92,7 @@ private:
//
LLChatBar::LLChatBar()
-: LLPanel(LLStringUtil::null, LLRect(), BORDER_NO),
+: LLPanel(),
mInputEditor(NULL),
mGestureLabelTimer(),
mLastSpecialChatChannel(0),
@@ -107,7 +102,7 @@ LLChatBar::LLChatBar()
{
setIsChrome(TRUE);
- #if !LL_RELEASE_FOR_DOWNLOAD
+#if !LL_RELEASE_FOR_DOWNLOAD
childDisplayNotFound();
#endif
}
@@ -123,34 +118,23 @@ LLChatBar::~LLChatBar()
BOOL LLChatBar::postBuild()
{
- childSetAction("History", toggleChatHistory, this);
- childSetCommitCallback("Say", onClickSay, this);
+ getChild<LLUICtrl>("Say")->setCommitCallback(boost::bind(&LLChatBar::onClickSay, this, _1));
// attempt to bind to an existing combo box named gesture
- setGestureCombo(getChild<LLComboBox>( "Gesture"));
-
- LLButton * sayp = getChild<LLButton>("Say");
- if(sayp)
- {
- setDefaultBtn(sayp);
- }
+ setGestureCombo(getChild<LLComboBox>( "Gesture", TRUE, FALSE));
mInputEditor = getChild<LLLineEditor>("Chat Editor");
- if (mInputEditor)
- {
- mInputEditor->setCallbackUserData(this);
- mInputEditor->setKeystrokeCallback(&onInputEditorKeystroke);
- mInputEditor->setFocusLostCallback(&onInputEditorFocusLost, this);
- mInputEditor->setFocusReceivedCallback( &onInputEditorGainFocus, this );
- mInputEditor->setCommitOnFocusLost( FALSE );
- mInputEditor->setRevertOnEsc( FALSE );
- mInputEditor->setIgnoreTab(TRUE);
- mInputEditor->setPassDelete(TRUE);
- mInputEditor->setReplaceNewlinesWithSpaces(FALSE);
-
- mInputEditor->setMaxTextLength(1023);
- mInputEditor->setEnableLineHistory(TRUE);
- }
+ mInputEditor->setKeystrokeCallback(&onInputEditorKeystroke, this);
+ mInputEditor->setFocusLostCallback(&onInputEditorFocusLost, this);
+ mInputEditor->setFocusReceivedCallback( &onInputEditorGainFocus, this );
+ mInputEditor->setCommitOnFocusLost( FALSE );
+ mInputEditor->setRevertOnEsc( FALSE );
+ mInputEditor->setIgnoreTab(TRUE);
+ mInputEditor->setPassDelete(TRUE);
+ mInputEditor->setReplaceNewlinesWithSpaces(FALSE);
+
+ mInputEditor->setMaxTextLength(1023);
+ mInputEditor->setEnableLineHistory(TRUE);
mIsBuilt = TRUE;
@@ -209,10 +193,7 @@ void LLChatBar::refresh()
gAgent.stopTyping();
}
- childSetValue("History", LLFloaterChat::instanceVisible(LLSD()));
-
childSetEnabled("Say", mInputEditor->getText().size() > 0);
- childSetEnabled("Shout", mInputEditor->getText().size() > 0);
}
@@ -311,8 +292,7 @@ void LLChatBar::setGestureCombo(LLComboBox* combo)
mGestureCombo = combo;
if (mGestureCombo)
{
- mGestureCombo->setCommitCallback(onCommitGesture);
- mGestureCombo->setCallbackUserData(this);
+ mGestureCombo->setCommitCallback(boost::bind(&LLChatBar::onCommitGesture, this, _1));
// now register observer since we have a place to put the results
mObserver = new LLChatBarGestureObserver(this);
@@ -434,17 +414,25 @@ void LLChatBar::sendChat( EChatType type )
// static
void LLChatBar::startChat(const char* line)
{
- gChatBar->setVisible(TRUE);
- gChatBar->setKeyboardFocus(TRUE);
- gSavedSettings.setBOOL("ChatVisible", TRUE);
-
- if (line && gChatBar->mInputEditor)
+ //TODO* remove DUMMY chat
+ if(LLBottomTray::getInstance()->getChatBox())
{
- std::string line_string(line);
- gChatBar->mInputEditor->setText(line_string);
+ LLBottomTray::getInstance()->getChatBox()->setFocus(TRUE);
}
- // always move cursor to end so users don't obliterate chat when accidentally hitting WASD
- gChatBar->mInputEditor->setCursorToEnd();
+
+ // *TODO Vadim: Why was this code commented out?
+
+// gChatBar->setVisible(TRUE);
+// gChatBar->setKeyboardFocus(TRUE);
+// gSavedSettings.setBOOL("ChatVisible", TRUE);
+//
+// if (line && gChatBar->mInputEditor)
+// {
+// std::string line_string(line);
+// gChatBar->mInputEditor->setText(line_string);
+// }
+// // always move cursor to end so users don't obliterate chat when accidentally hitting WASD
+// gChatBar->mInputEditor->setCursorToEnd();
}
@@ -452,21 +440,29 @@ void LLChatBar::startChat(const char* line)
// static
void LLChatBar::stopChat()
{
- // In simple UI mode, we never release focus from the chat bar
- gChatBar->setKeyboardFocus(FALSE);
-
- // If we typed a movement key and pressed return during the
- // same frame, the keyboard handlers will see the key as having
- // gone down this frame and try to move the avatar.
- gKeyboard->resetKeys();
- gKeyboard->resetMaskKeys();
-
- // stop typing animation
- gAgent.stopTyping();
+ //TODO* remove DUMMY chat
+ if(LLBottomTray::getInstance()->getChatBox())
+ {
+ LLBottomTray::getInstance()->getChatBox()->setFocus(FALSE);
+ }
- // hide chat bar so it doesn't grab focus back
- gChatBar->setVisible(FALSE);
- gSavedSettings.setBOOL("ChatVisible", FALSE);
+ // *TODO Vadim: Why was this code commented out?
+
+// // In simple UI mode, we never release focus from the chat bar
+// gChatBar->setKeyboardFocus(FALSE);
+//
+// // If we typed a movement key and pressed return during the
+// // same frame, the keyboard handlers will see the key as having
+// // gone down this frame and try to move the avatar.
+// gKeyboard->resetKeys();
+// gKeyboard->resetMaskKeys();
+//
+// // stop typing animation
+// gAgent.stopTyping();
+//
+// // hide chat bar so it doesn't grab focus back
+// gChatBar->setVisible(FALSE);
+// gSavedSettings.setBOOL("ChatVisible", FALSE);
}
// static
@@ -553,20 +549,19 @@ void LLChatBar::onInputEditorGainFocus( LLFocusableElement* caller, void* userda
LLFloaterChat::setHistoryCursorAndScrollToEnd();
}
-// static
-void LLChatBar::onClickSay( LLUICtrl* ctrl, void* userdata )
+void LLChatBar::onClickSay( LLUICtrl* ctrl )
{
+ std::string cmd = ctrl->getValue().asString();
e_chat_type chat_type = CHAT_TYPE_NORMAL;
- if (ctrl->getValue().asString() == "shout")
+ if (cmd == "shout")
{
chat_type = CHAT_TYPE_SHOUT;
}
- else if (ctrl->getValue().asString() == "whisper")
+ else if (cmd == "whisper")
{
chat_type = CHAT_TYPE_WHISPER;
}
- LLChatBar* self = (LLChatBar*) userdata;
- self->sendChat(chat_type);
+ sendChat(chat_type);
}
void LLChatBar::sendChatFromViewer(const std::string &utf8text, EChatType type, BOOL animate)
@@ -641,11 +636,9 @@ void send_chat_from_viewer(const std::string& utf8_out_text, EChatType type, S32
}
-// static
-void LLChatBar::onCommitGesture(LLUICtrl* ctrl, void* data)
+void LLChatBar::onCommitGesture(LLUICtrl* ctrl)
{
- LLChatBar* self = (LLChatBar*)data;
- LLCtrlListInterface* gestures = self->mGestureCombo ? self->mGestureCombo->getListInterface() : NULL;
+ LLCtrlListInterface* gestures = mGestureCombo ? mGestureCombo->getListInterface() : NULL;
if (gestures)
{
S32 index = gestures->getFirstSelectedIndex();
@@ -665,23 +658,17 @@ void LLChatBar::onCommitGesture(LLUICtrl* ctrl, void* data)
if (!revised_text.empty())
{
// Don't play nodding animation
- self->sendChatFromViewer(revised_text, CHAT_TYPE_NORMAL, FALSE);
+ sendChatFromViewer(revised_text, CHAT_TYPE_NORMAL, FALSE);
}
}
- self->mGestureLabelTimer.start();
- if (self->mGestureCombo != NULL)
+ mGestureLabelTimer.start();
+ if (mGestureCombo != NULL)
{
// free focus back to chat bar
- self->mGestureCombo->setFocus(FALSE);
+ mGestureCombo->setFocus(FALSE);
}
}
-void toggleChatHistory(void* user_data)
-{
- LLFloaterChat::toggleInstance(LLSD());
-}
-
-
class LLChatHandler : public LLCommandHandler
{
public: