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.cpp182
1 files changed, 85 insertions, 97 deletions
diff --git a/indra/newview/llchatbar.cpp b/indra/newview/llchatbar.cpp
index 2395f3c5ae..96c707b08f 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:
@@ -92,12 +87,14 @@ private:
};
+extern void send_chat_from_viewer(const std::string& utf8_out_text, EChatType type, S32 channel);
+
//
// Functions
//
LLChatBar::LLChatBar()
-: LLPanel(LLStringUtil::null, LLRect(), BORDER_NO),
+: LLPanel(),
mInputEditor(NULL),
mGestureLabelTimer(),
mLastSpecialChatChannel(0),
@@ -106,16 +103,12 @@ LLChatBar::LLChatBar()
mObserver(NULL)
{
setIsChrome(TRUE);
-
- #if !LL_RELEASE_FOR_DOWNLOAD
- childDisplayNotFound();
-#endif
}
LLChatBar::~LLChatBar()
{
- gGestureManager.removeObserver(mObserver);
+ LLGestureManager::instance().removeObserver(mObserver);
delete mObserver;
mObserver = NULL;
// LLView destructor cleans up children
@@ -123,34 +116,25 @@ LLChatBar::~LLChatBar()
BOOL LLChatBar::postBuild()
{
- childSetAction("History", toggleChatHistory, this);
- childSetCommitCallback("Say", onClickSay, this);
+ getChild<LLUICtrl>("Say")->setCommitCallback(boost::bind(&LLChatBar::onClickSay, this, _1));
+ // * NOTE: mantipov: getChild with default parameters returns dummy widget.
+ // Seems this class will be completle removed
// attempt to bind to an existing combo box named gesture
- setGestureCombo(getChild<LLComboBox>( "Gesture"));
-
- LLButton * sayp = getChild<LLButton>("Say");
- if(sayp)
- {
- setDefaultBtn(sayp);
- }
+ setGestureCombo(findChild<LLComboBox>( "Gesture"));
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);
}
@@ -230,7 +211,7 @@ void LLChatBar::refreshGestures()
// collect list of unique gestures
std::map <std::string, BOOL> unique;
LLGestureManager::item_map_t::iterator it;
- for (it = gGestureManager.mActive.begin(); it != gGestureManager.mActive.end(); ++it)
+ for (it = LLGestureManager::instance().mActive.begin(); it != LLGestureManager::instance().mActive.end(); ++it)
{
LLMultiGesture* gesture = (*it).second;
if (gesture)
@@ -311,12 +292,11 @@ 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);
- gGestureManager.addObserver(mObserver);
+ LLGestureManager::instance().addObserver(mObserver);
// refresh list from current active gestures
refreshGestures();
@@ -397,7 +377,7 @@ void LLChatBar::sendChat( EChatType type )
if (0 == channel)
{
// discard returned "found" boolean
- gGestureManager.triggerAndReviseString(utf8text, &utf8_revised_text);
+ LLGestureManager::instance().triggerAndReviseString(utf8text, &utf8_revised_text);
}
else
{
@@ -434,17 +414,26 @@ 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)
- {
- 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();
+ //TODO* remove DUMMY chat
+ //if(gBottomTray && gBottomTray->getChatBox())
+ //{
+ // gBottomTray->setVisible(TRUE);
+ // gBottomTray->getChatBox()->setFocus(TRUE);
+ //}
+
+ // *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 +441,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();
-
- // hide chat bar so it doesn't grab focus back
- gChatBar->setVisible(FALSE);
- gSavedSettings.setBOOL("ChatVisible", FALSE);
+ //TODO* remove DUMMY chat
+ //if(gBottomTray && gBottomTray->getChatBox())
+ ///{
+ // gBottomTray->getChatBox()->setFocus(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
@@ -519,7 +516,7 @@ void LLChatBar::onInputEditorKeystroke( LLLineEditor* caller, void* userdata )
std::string utf8_trigger = wstring_to_utf8str(raw_text);
std::string utf8_out_str(utf8_trigger);
- if (gGestureManager.matchPrefix(utf8_trigger, &utf8_out_str))
+ if (LLGestureManager::instance().matchPrefix(utf8_trigger, &utf8_out_str))
{
if (self->mInputEditor)
{
@@ -553,20 +550,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)
@@ -622,7 +618,7 @@ void LLChatBar::sendChatFromViewer(const LLWString &wtext, EChatType type, BOOL
send_chat_from_viewer(utf8_out_text, type, channel);
}
-
+/*
void send_chat_from_viewer(const std::string& utf8_out_text, EChatType type, S32 channel)
{
LLMessageSystem* msg = gMessageSystem;
@@ -639,13 +635,11 @@ void send_chat_from_viewer(const std::string& utf8_out_text, EChatType type, S32
LLViewerStats::getInstance()->incStat(LLViewerStats::ST_CHAT_COUNT);
}
+*/
-
-// 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();
@@ -659,38 +653,32 @@ void LLChatBar::onCommitGesture(LLUICtrl* ctrl, void* data)
// substitution and logging.
std::string text(trigger);
std::string revised_text;
- gGestureManager.triggerAndReviseString(text, &revised_text);
+ LLGestureManager::instance().triggerAndReviseString(text, &revised_text);
revised_text = utf8str_trim(revised_text);
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:
// not allowed from outside the app
- LLChatHandler() : LLCommandHandler("chat", true) { }
+ LLChatHandler() : LLCommandHandler("chat", UNTRUSTED_BLOCK) { }
// Your code here
bool handle(const LLSD& tokens, const LLSD& query_map,
- LLWebBrowserCtrl* web)
+ LLMediaCtrl* web)
{
if (tokens.size() < 2) return false;
S32 channel = tokens[0].asInteger();
@@ -701,4 +689,4 @@ public:
};
// Creating the object registers with the dispatcher.
-LLChatHandler gChatHandler;
+//LLChatHandler gChatHandler;