EXP-1247 Nearby chat as part of chat floater

meow-7.2.2
Leyla Farazha 2011-09-27 15:41:06 -07:00
parent cb699e3f2d
commit 0207d7e9e4
14 changed files with 96 additions and 77 deletions

View File

@ -55,6 +55,8 @@ LLResizeHandle::LLResizeHandle(const LLResizeHandle::Params& p)
mImage( NULL ),
mMinWidth( p.min_width ),
mMinHeight( p.min_height ),
mMaxWidth(S32_MAX),
mMaxHeight(S32_MAX),
mCorner( p.corner )
{
if( RIGHT_BOTTOM == mCorner)
@ -177,6 +179,11 @@ BOOL LLResizeHandle::handleHover(S32 x, S32 y, MASK mask)
new_width = mMinWidth;
delta_x = x_multiple * (mMinWidth - orig_rect.getWidth());
}
else if (new_width > mMaxWidth)
{
new_width = mMaxWidth;
delta_x = x_multiple * (mMaxWidth - orig_rect.getWidth());
}
S32 new_height = orig_rect.getHeight() + y_multiple * delta_y;
if( new_height < mMinHeight )
@ -184,6 +191,11 @@ BOOL LLResizeHandle::handleHover(S32 x, S32 y, MASK mask)
new_height = mMinHeight;
delta_y = y_multiple * (mMinHeight - orig_rect.getHeight());
}
else if (new_height > mMaxHeight)
{
new_height = mMaxHeight;
delta_y = y_multiple * (mMaxHeight - orig_rect.getHeight());
}
switch( mCorner )
{

View File

@ -56,6 +56,9 @@ public:
void setResizeLimits( S32 min_width, S32 min_height ) { mMinWidth = min_width; mMinHeight = min_height; }
void setMaxWidth(S32 width) { mMaxWidth = width;}
void setMaxHeight(S32 height) { mMaxHeight = height;}
private:
BOOL pointInHandle( S32 x, S32 y );
@ -66,7 +69,9 @@ private:
LLCoordGL mLastMouseDir;
LLPointer<LLUIImage> mImage;
S32 mMinWidth;
S32 mMaxWidth;
S32 mMinHeight;
S32 mMaxHeight;
const ECorner mCorner;
};

View File

@ -95,7 +95,7 @@ LLChatBar::LLChatBar()
mGestureCombo(NULL),
mObserver(NULL)
{
setIsChrome(TRUE);
//setIsChrome(TRUE);
}

View File

@ -2449,8 +2449,10 @@ void LLIMMgr::addSystemMessage(const LLUUID& session_id, const std::string& mess
LLChat chat(message);
chat.mSourceType = CHAT_SOURCE_SYSTEM;
LLFloater* chat_bar = LLFloaterReg::getInstance("chat_bar");
LLNearbyChat* nearby_chat = chat_bar->findChild<LLNearbyChat>("nearby_chat");
LLNearbyChat* nearby_chat = LLFloaterReg::getTypedInstance<LLNearbyChat>("nearby_chat", LLSD());
if(nearby_chat)
{
nearby_chat->addMessage(chat);

View File

@ -57,11 +57,13 @@
static const S32 RESIZE_BAR_THICKNESS = 3;
LLNearbyChat::LLNearbyChat(const LLSD& key)
: LLFloater(key)
static LLRegisterPanelClassWrapper<LLNearbyChat> t_panel_nearby_chat("panel_nearby_chat");
LLNearbyChat::LLNearbyChat()
: LLPanel()
,mChatHistory(NULL)
{
}
LLNearbyChat::~LLNearbyChat()
@ -86,29 +88,12 @@ BOOL LLNearbyChat::postBuild()
mChatHistory = getChild<LLChatHistory>("chat_history");
if(!LLFloater::postBuild())
if(!LLPanel::postBuild())
return false;
if (mDragHandle)
mDragHandle->setTitleVisible(TRUE);
return true;
}
void LLNearbyChat::applySavedVariables()
{
if (mRectControl.size() > 1)
{
const LLRect& rect = LLFloater::getControlGroup()->getRect(mRectControl);
if(!rect.isEmpty() && rect.isValid())
{
reshape(rect.getWidth(), rect.getHeight());
setRect(rect);
}
}
}
std::string appendTime()
{
time_t utc_time;
@ -204,18 +189,9 @@ void LLNearbyChat::setVisible(BOOL visible)
}
}
LLFloater::setVisible(visible);
LLPanel::setVisible(visible);
}
void LLNearbyChat::onOpen(const LLSD& key )
{
LLFloater::onOpen(key);
}
void LLNearbyChat::setRect (const LLRect &rect)
{
LLFloater::setRect(rect);
}
void LLNearbyChat::getAllowedRect(LLRect& rect)
{
@ -238,9 +214,9 @@ void LLNearbyChat::updateChatHistoryStyle()
//static
void LLNearbyChat::processChatHistoryStyleUpdate(const LLSD& newvalue)
{
LLNearbyChat* nearby_chat = LLFloaterReg::getTypedInstance<LLNearbyChat>("nearby_chat", LLSD());
if(nearby_chat)
nearby_chat->updateChatHistoryStyle();
//LLNearbyChat* nearby_chat = LLFloaterReg::getTypedInstance<LLNearbyChat>("nearby_chat", LLSD());
//if(nearby_chat)
// nearby_chat->updateChatHistoryStyle();
}
bool isWordsName(const std::string& name)
@ -314,7 +290,8 @@ void LLNearbyChat::loadHistory()
//static
LLNearbyChat* LLNearbyChat::getInstance()
{
return LLFloaterReg::getTypedInstance<LLNearbyChat>("nearby_chat", LLSD());
LLFloater* chat_bar = LLFloaterReg::getInstance("chat_bar");
return chat_bar->findChild<LLNearbyChat>("nearby_chat");
}
////////////////////////////////////////////////////////////////////////////////
@ -342,7 +319,7 @@ BOOL LLNearbyChat::handleMouseDown(S32 x, S32 y, MASK mask)
if(mChatHistory)
mChatHistory->setFocus(TRUE);
return LLFloater::handleMouseDown(x, y, mask);
return LLPanel::handleMouseDown(x, y, mask);
}
void LLNearbyChat::draw()
@ -355,5 +332,5 @@ void LLNearbyChat::draw()
setTransparencyType(hasFocus() ? TT_ACTIVE : TT_INACTIVE);
}
LLFloater::draw();
LLPanel::draw();
}

View File

@ -34,10 +34,10 @@
class LLResizeBar;
class LLChatHistory;
class LLNearbyChat: public LLFloater
class LLNearbyChat: public LLPanel
{
public:
LLNearbyChat(const LLSD& key);
LLNearbyChat();
~LLNearbyChat();
BOOL postBuild ();
@ -54,12 +54,8 @@ public:
/*virtual*/ void onFocusLost();
/*virtual*/ void onFocusReceived();
/*virtual*/ void onOpen (const LLSD& key);
/*virtual*/ void setVisible(BOOL visible);
virtual void setRect (const LLRect &rect);
virtual void updateChatHistoryStyle();
static void processChatHistoryStyleUpdate(const LLSD& newvalue);
@ -69,7 +65,6 @@ public:
static LLNearbyChat* getInstance();
private:
virtual void applySavedVariables();
void getAllowedRect (LLRect& rect);

View File

@ -49,6 +49,8 @@
#include "llrootview.h"
#include "llviewerchat.h"
#include "llresizehandle.h"
S32 LLNearbyChatBar::sLastSpecialChatChannel = 0;
// legacy callback glue
@ -414,8 +416,7 @@ LLCtrlListInterface* LLGestureComboList::getListInterface()
LLNearbyChatBar::LLNearbyChatBar(const LLSD& key)
: LLFloater(key),
mChatBox(NULL)
{
mSpeakerMgr = LLLocalSpeakerMgr::getInstance();
{ mSpeakerMgr = LLLocalSpeakerMgr::getInstance();
}
//virtual
@ -437,6 +438,10 @@ BOOL LLNearbyChatBar::postBuild()
mChatBox->setEnableLineHistory(TRUE);
mChatBox->setFont(LLViewerChat::getChatFont());
LLUICtrl* show_btn = getChild<LLUICtrl>("show_nearby_chat");
show_btn->setCommitCallback(boost::bind(&LLNearbyChatBar::onToggleNearbyChatPanel, this));
mOutputMonitor = getChild<LLOutputMonitorCtrl>("chat_zone_indicator");
mOutputMonitor->setVisible(FALSE);
@ -678,6 +683,25 @@ void LLNearbyChatBar::sendChat( EChatType type )
}
}
void LLNearbyChatBar::onToggleNearbyChatPanel()
{
LLView* nearby_chat = getChildView("nearby_chat");
if (nearby_chat->getVisible())
{
nearby_chat->setVisible(FALSE);
reshape(getRect().getWidth(), 60);
mResizeHandle[0]->setMaxHeight(60);
}
else
{
nearby_chat->setVisible(TRUE);
reshape(getRect().getWidth(), 360);
mResizeHandle[0]->setMaxHeight(S32_MAX);
}
}
void LLNearbyChatBar::onChatBoxCommit()
{
if (mChatBox->getText().length() > 0)
@ -781,6 +805,7 @@ void LLNearbyChatBar::startChat(const char* line)
return;
cb->setVisible(TRUE);
cb->setFocus(TRUE);
cb->mChatBox->setFocus(TRUE);
if (line)
@ -812,15 +837,6 @@ void LLNearbyChatBar::stopChat()
gAgent.stopTyping();
}
void LLNearbyChatBar::onClose(bool app_quitting)
{
LLFloater* nearby_chat = LLFloaterReg::findInstance("nearby_chat", LLSD());
if (nearby_chat)
{
nearby_chat->closeFloater(app_quitting);
}
}
// If input of the form "/20foo" or "/20 foo", returns "foo" and channel 20.
// Otherwise returns input and channel 0.
LLWString LLNearbyChatBar::stripChannelNumber(const LLWString &mesg, S32* channel)

View File

@ -108,8 +108,6 @@ public:
virtual void draw();
virtual void onClose(bool app_quitting);
std::string getCurrentChat();
virtual BOOL handleKeyHere( KEY key, MASK mask );
@ -129,6 +127,8 @@ protected:
void onChatBoxCommit();
void onChatFontChange(LLFontGL* fontp);
void onToggleNearbyChatPanel();
static LLWString stripChannelNumber(const LLWString &mesg, S32* channel);
EChatType processChatTypeTriggers(EChatType type, std::string &str);

View File

@ -41,6 +41,7 @@
#include "llfloaterreg.h"//for LLFloaterReg::getTypedInstance
#include "llviewerwindow.h"//for screen channel position
#include "llnearbychatbar.h"
//add LLNearbyChatHandler to LLNotificationsUI namespace
using namespace LLNotificationsUI;
@ -473,8 +474,9 @@ LLNearbyChatHandler::~LLNearbyChatHandler()
void LLNearbyChatHandler::initChannel()
{
LLNearbyChat* nearby_chat = LLFloaterReg::getTypedInstance<LLNearbyChat>("nearby_chat", LLSD());
LLView* chat_box = LLBottomTray::getInstance()->getChildView("chat_box");
LLNearbyChatBar* chat_bar = LLFloaterReg::getTypedInstance<LLNearbyChatBar>("chat_bar", LLSD());
LLView* chat_box = chat_bar->getChatBox();
LLNearbyChat* nearby_chat = LLNearbyChat::getInstance();
S32 channel_right_bound = nearby_chat->getRect().mRight;
mChannel->init(chat_box->getRect().mLeft, channel_right_bound);
}
@ -502,7 +504,10 @@ void LLNearbyChatHandler::processChat(const LLChat& chat_msg, // WARNING - not
tmp_chat.mText = tmp_chat.mText.substr(3);
}
LLNearbyChat* nearby_chat = LLFloaterReg::getTypedInstance<LLNearbyChat>("nearby_chat", LLSD());
LLFloater* chat_bar = LLFloaterReg::getInstance("chat_bar");
LLNearbyChat* nearby_chat = chat_bar->findChild<LLNearbyChat>("nearby_chat");
{
//sometimes its usefull to have no name at all...
//if(tmp_chat.mFromName.empty() && tmp_chat.mFromID!= LLUUID::null)

View File

@ -385,7 +385,7 @@ void LLHandlerUtil::logGroupNoticeToIMGroup(
// static
void LLHandlerUtil::logToNearbyChat(const LLNotificationPtr& notification, EChatSourceType type)
{
LLNearbyChat* nearby_chat = LLFloaterReg::getTypedInstance<LLNearbyChat>("nearby_chat", LLSD());
LLNearbyChat* nearby_chat = LLNearbyChat::getInstance();
if(nearby_chat)
{
LLChat chat_msg(notification->getMessage());

View File

@ -92,8 +92,7 @@ bool LLTipHandler::processNotification(const LLSD& notify)
LLHandlerUtil::logToNearbyChat(notification, CHAT_SOURCE_SYSTEM);
// don't show toast if Nearby Chat is opened
LLNearbyChat* nearby_chat = LLFloaterReg::getTypedInstance<
LLNearbyChat>("nearby_chat", LLSD());
LLNearbyChat* nearby_chat = LLNearbyChat::getInstance();
if (nearby_chat->getVisible())
{
return false;

View File

@ -180,7 +180,6 @@ void LLViewerFloaterReg::registerFloaters()
LLFloaterReg::add("bumps", "floater_bumps.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterBump>);
LLFloaterReg::add("camera", "floater_camera.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterCamera>);
LLFloaterReg::add("nearby_chat", "floater_nearby_chat.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLNearbyChat>);
LLFloaterReg::add("chat_bar", "floater_chat_bar.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLNearbyChatBar>);
LLFloaterReg::add("compile_queue", "floater_script_queue.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterCompileQueue>);

View File

@ -2190,7 +2190,7 @@ void god_message_name_cb(const LLAvatarName& av_name, LLChat chat, std::string m
// Treat like a system message and put in chat history.
chat.mText = av_name.getCompleteName() + ": " + message;
LLNearbyChat* nearby_chat = LLFloaterReg::getTypedInstance<LLNearbyChat>("nearby_chat", LLSD());
LLNearbyChat* nearby_chat = LLNearbyChat::getInstance();
if(nearby_chat)
{
nearby_chat->addMessage(chat);
@ -2752,7 +2752,7 @@ void process_improved_im(LLMessageSystem *msg, void **user_data)
// Note: lie to Nearby Chat, pretending that this is NOT an IM, because
// IMs from obejcts don't open IM sessions.
LLNearbyChat* nearby_chat = LLFloaterReg::getTypedInstance<LLNearbyChat>("nearby_chat", LLSD());
LLNearbyChat* nearby_chat = LLNearbyChat::getInstance();
if(SYSTEM_FROM != name && nearby_chat)
{
chat.mOwnerID = from_id;

View File

@ -3,16 +3,27 @@
height="60"
layout="topleft"
legacy_header_height="20"
single_instance="true"
title="Nearby chat"
save_rect="true"
can_close="true"
can_minimize="true"
help_topic="chat_bar"
save_rect="true"
min_height="60"
min_width="150"
can_resize="true"
name="chat_bar"
width="380">
<panel
top="20"
class="panel_nearby_chat"
follow="all"
width="380"
height="0"
visible="false"
filename="panel_nearby_chat.xml"
name="nearby_chat" />
<panel width="380" height="31" left="0" bottom="-1" follows="left|right|bottom">
<line_editor
border_style="line"
border_thickness="1"
@ -27,7 +38,7 @@
text_pad_left="5"
text_pad_right="25"
tool_tip="Press Enter to say, Ctrl+Enter to shout"
top="27"
top="0"
width="335" />
<output_monitor
auto_update="true"
@ -38,14 +49,14 @@
left_pad="-24"
mouse_opaque="true"
name="chat_zone_indicator"
top="31"
top="4"
visible="true"
width="20" />
<button
follows="right"
is_toggle="true"
width="20"
top="27"
top="0"
layout="topleft"
left_pad="12"
image_disabled="ComboButton_UpOff"
@ -56,8 +67,6 @@
height="23"
name="show_nearby_chat"
tool_tip="Shows/hides nearby chat log">
<button.init_callback
function="Button.SetDockableFloaterToggle"
parameter="nearby_chat" />
</button>
</panel>
</floater>