summaryrefslogtreecommitdiff
path: root/indra/newview/llbottomtray.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'indra/newview/llbottomtray.cpp')
-rw-r--r--indra/newview/llbottomtray.cpp323
1 files changed, 75 insertions, 248 deletions
diff --git a/indra/newview/llbottomtray.cpp b/indra/newview/llbottomtray.cpp
index 616cbb1fdb..9eb8369c4c 100644
--- a/indra/newview/llbottomtray.cpp
+++ b/indra/newview/llbottomtray.cpp
@@ -32,212 +32,97 @@
#include "llviewerprecompiledheaders.h" // must be first include
#include "llbottomtray.h"
+
#include "llagent.h"
#include "llchiclet.h"
-#include "lllayoutstack.h"
-#include "llkeyboard.h"
-#include "llgesturemgr.h"
-#include "llanimationstates.h"
-
-//FIXME: temporary, for send_chat_from_viewer() proto
-#include "llchatbar.h"
-
-LLBottomTray::LLBottomTray()
- :mLastSpecialChatChannel(0)
+#include "llfloaterreg.h"
+#include "llflyoutbutton.h"
+#include "llnearbychatbar.h"
+#include "llsplitbutton.h"
+#include "llfloatercamera.h"
+#include "llimpanel.h"
+
+LLBottomTray::LLBottomTray(const LLSD&)
+: mChicletPanel(NULL),
+ mIMWell(NULL),
+ mSysWell(NULL),
+ mTalkBtn(NULL),
+ mNearbyChatBar(NULL)
{
+ mFactoryMap["chat_bar"] = LLCallbackMap(LLBottomTray::createNearbyChatBar, NULL);
+
LLUICtrlFactory::getInstance()->buildPanel(this,"panel_bottomtray.xml");
mChicletPanel = getChild<LLChicletPanel>("chiclet_list",TRUE,FALSE);
+ mIMWell = getChild<LLNotificationChiclet>("im_well",TRUE,FALSE);
+ mSysWell = getChild<LLNotificationChiclet>("sys_well",TRUE,FALSE);
+
+ mChicletPanel->setChicletClickedCallback(boost::bind(&LLBottomTray::onChicletClick,this,_1));
- LLLineEditor* chat_box = getChatBox();
- chat_box->setCommitCallback(boost::bind(&LLBottomTray::onChatBoxCommit, this));
- chat_box->setKeystrokeCallback(&onChatBoxKeystroke, this);
- chat_box->setFocusLostCallback(&onChatBoxFocusLost, this);
+ LLSplitButton* presets = getChild<LLSplitButton>("presets", TRUE, FALSE);
+ if (presets) presets->setSelectionCallback(LLFloaterCamera::onClickCameraPresets);
LLIMMgr::getInstance()->addSessionObserver(this);
-}
-LLBottomTray::~LLBottomTray()
-{
- if (!LLSingleton<LLIMMgr>::destroyed())
- {
- LLIMMgr::getInstance()->removeSessionObserver(this);
- }
-}
+ //this is to fix a crash that occurs because LLBottomTray is a singleton
+ //and thus is deleted at the end of the viewers lifetime, but to be cleanly
+ //destroyed LLBottomTray requires some subsystems that are long gone
+ LLUI::getRootView()->addChild(this);
-LLLineEditor* LLBottomTray::getChatBox()
-{
- return getChild<LLLineEditor>("chat_box",TRUE,FALSE);
+ // Necessary for focus movement among child controls
+ setFocusRoot(TRUE);
}
-void LLBottomTray::onChatBoxCommit()
+BOOL LLBottomTray::postBuild()
{
- if (getChatBox()->getText().length() > 0)
- {
- sendChat(CHAT_TYPE_NORMAL);
-
- LLLineEditor* chat_box = getChatBox();
-
- if (chat_box)
- {
- chat_box->setText(LLStringExplicit(""));
- }
+ mNearbyChatBar = getChild<LLNearbyChatBar>("chat_bar");
- gAgent.stopTyping();
- }
-}
-
-void LLBottomTray::sendChatFromViewer(const std::string &utf8text, EChatType type, BOOL animate)
-{
- sendChatFromViewer(utf8str_to_wstring(utf8text), type, animate);
+ return TRUE;
}
-void LLBottomTray::sendChatFromViewer(const LLWString &wtext, EChatType type, BOOL animate)
+LLBottomTray::~LLBottomTray()
{
- // Look for "/20 foo" channel chats.
- S32 channel = 0;
- LLWString out_text = stripChannelNumber(wtext, &channel);
- std::string utf8_out_text = wstring_to_utf8str(out_text);
- std::string utf8_text = wstring_to_utf8str(wtext);
-
- utf8_text = utf8str_trim(utf8_text);
- if (!utf8_text.empty())
- {
- utf8_text = utf8str_truncate(utf8_text, MAX_STRING - 1);
- }
-
- // Don't animate for chats people can't hear (chat to scripts)
- if (animate && (channel == 0))
- {
- if (type == CHAT_TYPE_WHISPER)
- {
- lldebugs << "You whisper " << utf8_text << llendl;
- gAgent.sendAnimationRequest(ANIM_AGENT_WHISPER, ANIM_REQUEST_START);
- }
- else if (type == CHAT_TYPE_NORMAL)
- {
- lldebugs << "You say " << utf8_text << llendl;
- gAgent.sendAnimationRequest(ANIM_AGENT_TALK, ANIM_REQUEST_START);
- }
- else if (type == CHAT_TYPE_SHOUT)
- {
- lldebugs << "You shout " << utf8_text << llendl;
- gAgent.sendAnimationRequest(ANIM_AGENT_SHOUT, ANIM_REQUEST_START);
- }
- else
- {
- llinfos << "send_chat_from_viewer() - invalid volume" << llendl;
- return;
- }
- }
- else
+ if (!LLSingleton<LLIMMgr>::destroyed())
{
- if (type != CHAT_TYPE_START && type != CHAT_TYPE_STOP)
- {
- lldebugs << "Channel chat: " << utf8_text << llendl;
- }
+ LLIMMgr::getInstance()->removeSessionObserver(this);
}
-
- send_chat_from_viewer(utf8_out_text, type, channel);
}
-// static
-void LLBottomTray::onChatBoxKeystroke(LLLineEditor* caller, void* userdata)
+void LLBottomTray::onChicletClick(LLUICtrl* ctrl)
{
- LLBottomTray* self = (LLBottomTray *)userdata;
-
- LLWString raw_text;
- if (self->getChatBox()) raw_text = self->getChatBox()->getWText();
-
- // Can't trim the end, because that will cause autocompletion
- // to eat trailing spaces that might be part of a gesture.
- LLWStringUtil::trimHead(raw_text);
-
- S32 length = raw_text.length();
-
- if( (length > 0) && (raw_text[0] != '/') ) // forward slash is used for escape (eg. emote) sequences
+ LLIMChiclet* chiclet = dynamic_cast<LLIMChiclet*>(ctrl);
+ if (chiclet)
{
- gAgent.startTyping();
- }
- else
- {
- gAgent.stopTyping();
- }
-
- /* Doesn't work -- can't tell the difference between a backspace
- that killed the selection vs. backspace at the end of line.
- if (length > 1
- && text[0] == '/'
- && key == KEY_BACKSPACE)
- {
- // the selection will already be deleted, but we need to trim
- // off the character before
- std::string new_text = raw_text.substr(0, length-1);
- self->mInputEditor->setText( new_text );
- self->mInputEditor->setCursorToEnd();
- length = length - 1;
- }
- */
-
- KEY key = gKeyboard->currentKey();
-
- // Ignore "special" keys, like backspace, arrows, etc.
- if (length > 1
- && raw_text[0] == '/'
- && key < KEY_SPECIAL)
- {
- // we're starting a gesture, attempt to autocomplete
-
- 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 (self->getChatBox())
- {
- std::string rest_of_match = utf8_out_str.substr(utf8_trigger.size());
- self->getChatBox()->setText(utf8_trigger + rest_of_match); // keep original capitalization for user-entered part
- S32 outlength = self->getChatBox()->getLength(); // in characters
-
- // Select to end of line, starting from the character
- // after the last one the user typed.
- self->getChatBox()->setSelection(length, outlength);
- }
- }
-
- //llinfos << "GESTUREDEBUG " << trigger
- // << " len " << length
- // << " outlen " << out_str.getLength()
- // << llendl;
+ // Until you can type into an IM Window and have a conversation,
+ // still show the old communicate window
+ //LLFloaterReg::showInstance("communicate", chiclet->getSessionId());
+
+ // Show after comm window so it is frontmost (and hence will not
+ // auto-hide)
+ LLIMFloater::show(chiclet->getSessionId());
+ chiclet->setCounter(0);
}
}
-// static
-void LLBottomTray::onChatBoxFocusLost(LLFocusableElement* caller, void* userdata)
+void* LLBottomTray::createNearbyChatBar(void* userdata)
{
- // stop typing animation
- gAgent.stopTyping();
+ return new LLNearbyChatBar();
}
-
//virtual
void LLBottomTray::sessionAdded(const LLUUID& session_id, const std::string& name, const LLUUID& other_participant_id)
{
if(getChicletPanel())
{
- LLSD sid(session_id);
-
- if(getChicletPanel()->findIMChiclet(&sid))
+ if(getChicletPanel()->findChiclet<LLChiclet>(session_id))
{
}
else
{
- LLIMChiclet* chicklet = (LLIMChiclet *)getChicletPanel()->createChiclet(&sid);
- chicklet->setIMSessionName(name);
- chicklet->setOtherParticipantId(other_participant_id);
-
- getChicletPanel()->arrange();
+ LLIMChiclet* chiclet = getChicletPanel()->createChiclet<LLIMChiclet>(session_id);
+ chiclet->setIMSessionName(name);
+ chiclet->setOtherParticipantId(other_participant_id);
}
}
}
@@ -247,100 +132,42 @@ void LLBottomTray::sessionRemoved(const LLUUID& session_id)
{
if(getChicletPanel())
{
- LLSD sid(session_id);
- getChicletPanel()->removeIMChiclet(&sid);
- getChicletPanel()->arrange();
+ getChicletPanel()->removeChiclet(session_id);
}
}
-void LLBottomTray::sendChat( EChatType type )
+//virtual
+void LLBottomTray::onFocusLost()
{
- LLLineEditor* chat_box = getChatBox();
-
- if (chat_box)
+ if (gAgent.cameraMouselook())
{
- LLWString text = chat_box->getConvertedText();
- if (!text.empty())
- {
- // store sent line in history, duplicates will get filtered
- chat_box->updateHistory();
- // Check if this is destined for another channel
- S32 channel = 0;
- stripChannelNumber(text, &channel);
-
- std::string utf8text = wstring_to_utf8str(text);
- // Try to trigger a gesture, if not chat to a script.
- std::string utf8_revised_text;
- if (0 == channel)
- {
- // discard returned "found" boolean
- gGestureManager.triggerAndReviseString(utf8text, &utf8_revised_text);
- }
- else
- {
- utf8_revised_text = utf8text;
- }
-
- utf8_revised_text = utf8str_trim(utf8_revised_text);
-
- if (!utf8_revised_text.empty())
- {
- // Chat with animation
- sendChatFromViewer(utf8_revised_text, type, TRUE);
- }
- }
+ setVisible(FALSE);
}
-
- gAgent.stopTyping();
}
-// If input of the form "/20foo" or "/20 foo", returns "foo" and channel 20.
-// Otherwise returns input and channel 0.
-LLWString LLBottomTray::stripChannelNumber(const LLWString &mesg, S32* channel)
+//virtual
+// setVisible used instead of onVisibilityChange, since LLAgent calls it on entering/leaving mouselook mode.
+// If bottom tray is already visible in mouselook mode, then onVisibilityChange will not be called from setVisible(true),
+void LLBottomTray::setVisible(BOOL visible)
{
- if (mesg[0] == '/'
- && mesg[1] == '/')
- {
- // This is a "repeat channel send"
- *channel = mLastSpecialChatChannel;
- return mesg.substr(2, mesg.length() - 2);
- }
- else if (mesg[0] == '/'
- && mesg[1]
- && LLStringOps::isDigit(mesg[1]))
+ LLPanel::setVisible(visible);
+
+ LLView* stack = getChild<LLView>("toolbar_stack",TRUE,FALSE);
+
+ if (stack)
{
- // This a special "/20" speak on a channel
- S32 pos = 0;
+ BOOL visibility = gAgent.cameraMouselook() ? false : true;
- // Copy the channel number into a string
- LLWString channel_string;
- llwchar c;
- do
+ for ( child_list_const_iter_t child_it = stack->getChildList()->begin(); child_it != stack->getChildList()->end(); child_it++)
{
- c = mesg[pos+1];
- channel_string.push_back(c);
- pos++;
- }
- while(c && pos < 64 && LLStringOps::isDigit(c));
-
- // Move the pointer forward to the first non-whitespace char
- // Check isspace before looping, so we can handle "/33foo"
- // as well as "/33 foo"
- while(c && iswspace(c))
- {
- c = mesg[pos+1];
- pos++;
+ LLView* viewp = *child_it;
+
+ if ("chat_bar" == viewp->getName())
+ continue;
+ else
+ {
+ viewp->setVisible(visibility);
+ }
}
-
- mLastSpecialChatChannel = strtol(wstring_to_utf8str(channel_string).c_str(), NULL, 10);
- *channel = mLastSpecialChatChannel;
- return mesg.substr(pos, mesg.length() - pos);
- }
- else
- {
- // This is normal chat.
- *channel = 0;
- return mesg;
}
}
-