Work on normal task EXT-3636 (Code Improvements: Voice control panels - Make Voice states and fade timeout xml driven)

-- made Avatar Item Voice States xml driven. Added fake xml panel file with one textbox per style.
  Style of the appropriate textbox is applied to avatar item's name
-- It was necessary to change visibility of the LLTExtBase::getDefaultStyle() to public.

--HG--
branch : product-engine
meow-7.2.2
Mike Antipov 2009-12-23 20:00:48 +02:00
parent b0ed2ab7d9
commit 46948d9fcc
4 changed files with 65 additions and 33 deletions

View File

@ -184,6 +184,7 @@ public:
bool scrolledToEnd();
const LLFontGL* getDefaultFont() const { return mDefaultFont; }
LLStyle::Params getDefaultStyle();
public:
// Fired when a URL link is clicked
@ -256,7 +257,6 @@ protected:
LLTextBase(const Params &p);
virtual ~LLTextBase();
void initFromParams(const Params& p);
LLStyle::Params getDefaultStyle();
virtual void onValueChange(S32 start, S32 end);
// draw methods

View File

@ -183,28 +183,21 @@ void LLAvatarListItem::setHighlight(const std::string& highlight)
setNameInternal(mAvatarName->getText(), mHighlihtSubstring = highlight);
}
void LLAvatarListItem::setStyle(const LLStyle::Params& new_style)
void LLAvatarListItem::setStyle(EItemStyle voice_state)
{
// LLTextUtil::textboxSetHighlightedVal(mAvatarName, mAvatarNameStyle = new_style);
voice_state_map_t mVoiceStateMap = getItemStylesParams();
// Active group should be bold.
LLFontDescriptor new_desc(mAvatarName->getDefaultFont()->getFontDesc());
new_desc.setStyle(new_style.font()->getFontDesc().getStyle());
// *NOTE dzaporozhan
// On Windows LLFontGL::NORMAL will not remove LLFontGL::BOLD if font
// is predefined as bold (SansSerifSmallBold, for example)
// new_desc.setStyle(active ? LLFontGL::BOLD : LLFontGL::NORMAL);
LLFontGL* new_font = LLFontGL::getFont(new_desc);
//
mAvatarNameStyle.font = new_font;
mAvatarNameStyle = mVoiceStateMap[voice_state];
// *NOTE: You cannot set the style on a text box anymore, you must
// rebuild the text. This will cause problems if the text contains
// hyperlinks, as their styles will be wrong.
mAvatarName->setText(mAvatarName->getText(), mAvatarNameStyle/* = new_style*/);
mAvatarName->setText(mAvatarName->getText(), mAvatarNameStyle);
// *TODO: move icon colors into colors.xml
mAvatarIcon->setColor(voice_state == IS_VOICE_JOINED ? LLColor4::white : LLColor4::smoke);
}
void LLAvatarListItem::setAvatarId(const LLUUID& id, bool ignore_status_changes)
{
if (mAvatarId.notNull())
@ -418,3 +411,45 @@ std::string LLAvatarListItem::formatSeconds(U32 secs)
args["[COUNT]"] = llformat("%u", count);
return getString(fmt, args);
}
// static
LLAvatarListItem::voice_state_map_t LLAvatarListItem::getItemStylesParams()
{
static voice_state_map_t item_styles_params_map;
if (!item_styles_params_map.empty()) return item_styles_params_map;
LLPanel::Params params = LLUICtrlFactory::getDefaultParams<LLPanel>();
LLPanel* params_panel = LLUICtrlFactory::create<LLPanel>(params);
BOOL sucsess = LLUICtrlFactory::instance().buildPanel(params_panel, "panel_avatar_list_item_params.xml");
if (sucsess)
{
item_styles_params_map.insert(
std::make_pair(IS_DEFAULT,
params_panel->getChild<LLTextBox>("default_style")->getDefaultStyle()));
item_styles_params_map.insert(
std::make_pair(IS_VOICE_INVITED,
params_panel->getChild<LLTextBox>("voice_call_invited_style")->getDefaultStyle()));
item_styles_params_map.insert(
std::make_pair(IS_VOICE_JOINED,
params_panel->getChild<LLTextBox>("voice_call_joined_style")->getDefaultStyle()));
item_styles_params_map.insert(
std::make_pair(IS_VOICE_LEFT,
params_panel->getChild<LLTextBox>("voice_call_left_style")->getDefaultStyle()));
}
else
{
item_styles_params_map.insert(std::make_pair(IS_DEFAULT, LLStyle::Params()));
item_styles_params_map.insert(std::make_pair(IS_VOICE_INVITED, LLStyle::Params()));
item_styles_params_map.insert(std::make_pair(IS_VOICE_JOINED, LLStyle::Params()));
item_styles_params_map.insert(std::make_pair(IS_VOICE_LEFT, LLStyle::Params()));
}
if (params_panel) params_panel->die();
return item_styles_params_map;
}

View File

@ -46,6 +46,13 @@ class LLAvatarIconCtrl;
class LLAvatarListItem : public LLPanel, public LLFriendObserver
{
public:
typedef enum e_item_style_type {
IS_DEFAULT,
IS_VOICE_INVITED,
IS_VOICE_JOINED,
IS_VOICE_LEFT,
} EItemStyle;
class ContextMenu
{
public:
@ -73,7 +80,7 @@ public:
void setOnline(bool online);
void setName(const std::string& name);
void setHighlight(const std::string& highlight);
void setStyle(const LLStyle::Params& new_style);
void setStyle(EItemStyle voice_state);
void setAvatarId(const LLUUID& id, bool ignore_status_changes = false);
void setLastInteractionTime(U32 secs_since);
//Show/hide profile/info btn, translating speaker indicator and avatar name coordinates accordingly
@ -118,6 +125,9 @@ private:
std::string formatSeconds(U32 secs);
typedef std::map<EItemStyle, LLStyle::Params> voice_state_map_t;
static voice_state_map_t getItemStylesParams();
LLAvatarIconCtrl* mAvatarIcon;
LLTextBox* mAvatarName;
LLTextBox* mLastInteractionTime;

View File

@ -597,38 +597,25 @@ void LLCallFloater::setState(LLAvatarListItem* item, ESpeakerState state)
setState(item->getAvatarId(), state);
LLStyle::Params speaker_style;
LLFontDescriptor new_desc(speaker_style.font()->getFontDesc());
switch (state)
{
case STATE_INVITED:
new_desc.setStyle(LLFontGL::NORMAL);
item->setStyle(LLAvatarListItem::IS_VOICE_INVITED);
break;
case STATE_JOINED:
removeVoiceRemoveTimer(item->getAvatarId());
new_desc.setStyle(LLFontGL::NORMAL);
item->setStyle(LLAvatarListItem::IS_VOICE_JOINED);
break;
case STATE_LEFT:
{
setVoiceRemoveTimer(item->getAvatarId());
new_desc.setStyle(LLFontGL::ITALIC);
item->setStyle(LLAvatarListItem::IS_VOICE_LEFT);
}
break;
default:
llwarns << "Unrecognized avatar panel state (" << state << ")" << llendl;
break;
}
LLFontGL* new_font = LLFontGL::getFont(new_desc);
speaker_style.font = new_font;
item->setStyle(speaker_style);
// if ()
{
// found speaker is in voice, mark him as online
item->setOnline(STATE_JOINED == state);
}
}
void LLCallFloater::setVoiceRemoveTimer(const LLUUID& voice_speaker_id)