undo the changes for LLStyle params; add sizeFromFont in LLFontGL ; use font.style, font.name and font.size params for font creating

master
angela 2009-11-17 16:33:49 +08:00
parent 28aa749db5
commit 0098bf40ea
11 changed files with 76 additions and 72 deletions

View File

@ -754,6 +754,13 @@ std::string LLFontGL::nameFromFont(const LLFontGL* fontp)
return fontp->mFontDescriptor.getName();
}
// static
std::string LLFontGL::sizeFromFont(const LLFontGL* fontp)
{
return fontp->mFontDescriptor.getSize();
}
// static
std::string LLFontGL::nameFromHAlign(LLFontGL::HAlign align)
{

View File

@ -146,6 +146,7 @@ public:
static U8 getStyleFromString(const std::string &style);
static std::string nameFromFont(const LLFontGL* fontp);
static std::string sizeFromFont(const LLFontGL* fontp);
static std::string nameFromHAlign(LLFontGL::HAlign align);
static LLFontGL::HAlign hAlignFromName(const std::string& name);

View File

@ -44,10 +44,7 @@ LLStyle::Params::Params()
color("color", LLColor4::black),
font("font", LLFontGL::getFontMonospace()),
image("image"),
link_href("href"),
italic("italic", false ),
bold("bold", false),
underline("bold", false)
link_href("href")
{}
@ -58,10 +55,7 @@ LLStyle::LLStyle(const LLStyle::Params& p)
mFont(p.font()),
mLink(p.link_href),
mDropShadow(p.drop_shadow),
mImagep(p.image()),
mItalic(p.italic()),
mBold(p.bold),
mUnderline(p.underline)
mImagep(p.image())
{}
void LLStyle::setFont(const LLFontGL* font)
@ -75,25 +69,6 @@ const LLFontGL* LLStyle::getFont() const
return mFont;
}
const S32 LLStyle::getFontStyle() const
{
S32 ret = 0;
if (mBold)
{
ret |= LLFontGL::BOLD;
}
if (mItalic)
{
ret |= LLFontGL::ITALIC;
}
if (mUnderline)
{
ret |= LLFontGL::UNDERLINE;
}
return ret;
}
void LLStyle::setLinkHREF(const std::string& href)
{
mLink = href;

View File

@ -51,17 +51,12 @@ public:
Optional<const LLFontGL*> font;
Optional<LLUIImage*> image;
Optional<std::string> link_href;
Optional<bool> italic;
Optional<bool> bold;
Optional<bool> underline;
Params();
};
LLStyle(const Params& p = Params());
public:
const LLColor4& getColor() const { return mColor; }
void setColor(const LLColor4 &color) { mColor = color; }
const S32 getFontStyle() const;
const LLColor4& getReadOnlyColor() const { return mReadOnlyColor; }

View File

@ -1506,8 +1506,12 @@ void LLTextBase::appendText(const std::string &new_text, bool prepend_newline, c
LLStyle::Params link_params = style_params;
link_params.color = match.getColor();
// apply font name from requested style_params
std::string font_name = LLFontGL::nameFromFont(style_params.font());
link_params.underline = true;
std::string font_name = LLFontGL::nameFromFont(style_params.font());
std::string font_size = LLFontGL::sizeFromFont(style_params.font());
link_params.font.name(font_name);
link_params.font.size(font_name);
link_params.font.style("UNDERLINE");
link_params.link_href = match.getUrl();
// output the text before the Url
@ -2250,7 +2254,7 @@ F32 LLNormalTextSegment::drawClippedSegment(S32 seg_start, S32 seg_end, S32 sele
rect.mLeft, rect.mTop,
color,
LLFontGL::LEFT, LLFontGL::TOP,
mStyle->getFontStyle(),
0,
mStyle->getShadowType(),
length, rect.getWidth(),
&right_x,
@ -2269,7 +2273,7 @@ F32 LLNormalTextSegment::drawClippedSegment(S32 seg_start, S32 seg_end, S32 sele
rect.mLeft, rect.mTop,
LLColor4( 1.f - color.mV[0], 1.f - color.mV[1], 1.f - color.mV[2], 1.f ),
LLFontGL::LEFT, LLFontGL::TOP,
mStyle->getFontStyle(),
0,
LLFontGL::NO_SHADOW,
length, rect.mRight,
&right_x,
@ -2286,7 +2290,7 @@ F32 LLNormalTextSegment::drawClippedSegment(S32 seg_start, S32 seg_end, S32 sele
rect.mLeft, rect.mTop,
color,
LLFontGL::LEFT, LLFontGL::TOP,
mStyle->getFontStyle(),
0,
mStyle->getShadowType(),
length, rect.mRight,
&right_x,

View File

@ -361,15 +361,17 @@ void LLChatHistory::appendWidgetMessage(const LLChat& chat, const LLStyle::Param
LLColor4 txt_color = LLUIColorTable::instance().getColor("White");
LLViewerChat::getChatColor(chat,txt_color);
LLFontGL* fontp = LLViewerChat::getChatFont();
LLFontGL* fontp = LLViewerChat::getChatFont();
std::string font_name = LLFontGL::nameFromFont(fontp);
std::string font_size = LLFontGL::sizeFromFont(fontp);
LLStyle::Params style_params;
style_params.color(txt_color);
style_params.readonly_color(txt_color);
style_params.font(fontp);
style_params.italic = input_append_params.italic;
style_params.underline = input_append_params.underline;
style_params.bold = input_append_params.bold;
style_params.font.name(font_name);
style_params.font.size(font_size);
style_params.font.style(input_append_params.font.style);
if (mLastFromName == chat.mFromName)
{

View File

@ -160,10 +160,14 @@ void LLNearbyChatToastPanel::init(LLSD& notification)
LLStyle::Params style_params;
style_params.color(mTextColor);
style_params.font(mFont);
std::string str_sender;
// style_params.font(mFont);
std::string font_name = LLFontGL::nameFromFont(mFont);
std::string font_style_size = LLFontGL::sizeFromFont(mFont);
style_params.font.name(font_name);
style_params.font.size(font_style_size);
std::string str_sender;
if(gAgentID != mFromID)
str_sender = mFromName;
else
@ -180,12 +184,12 @@ void LLNearbyChatToastPanel::init(LLSD& notification)
{
if (mFromName.size() > 0)
{
style_params.italic= true;
style_params.font.style = "ITALIC";
msg_text->setText(mFromName, style_params);
}
mText = mText.substr(3);
style_params.underline = true;
style_params.font.style = "UNDERLINE";
msg_text->addText(mText,style_params);
}
else

View File

@ -80,7 +80,7 @@ public:
draw_rect.mRight, draw_rect.mTop,
mStyle->getColor(),
LLFontGL::RIGHT, LLFontGL::TOP,
mStyle->getFontStyle(),
0,
mStyle->getShadowType(),
end - start, draw_rect.getWidth(),
&right_x,
@ -164,7 +164,8 @@ void LLExpandableTextBox::LLTextBoxEx::showExpandText()
S32 last_line = visible_lines.second - 1;
LLStyle::Params expander_style = getDefaultStyle();
expander_style.underline = true;
expander_style.font.name(LLFontGL::nameFromFont(expander_style.font));
expander_style.font.style = "UNDERLINE";
expander_style.color = LLUIColorTable::instance().getColor("HTMLLinkColor");
LLExpanderSegment* expanderp = new LLExpanderSegment(new LLStyle(expander_style), getLineStart(last_line), getLength() + 1, mExpanderLabel, *this);
insertSegment(expanderp);

View File

@ -476,27 +476,32 @@ void LLIMFloater::updateMessages()
chat.mFromID = from_id;
chat.mFromName = from;
chat.mText = message;
LLStyle::Params append_style_params;
//Handle IRC styled /me messages.
std::string prefix = message.substr(0, 4);
if (prefix == "/me " || prefix == "/me'")
{
if (from.size() > 0)
{
append_style_params.italic= true;
chat.mText = from + " ";
mChatHistory->appendWidgetMessage(chat, append_style_params);
}
message = message.substr(3);
LLColor4 txt_color = LLUIColorTable::instance().getColor("White");
LLViewerChat::getChatColor(chat,txt_color);
LLFontGL* fontp = LLViewerChat::getChatFont();
std::string font_name = LLFontGL::nameFromFont(fontp);
std::string font_size = LLFontGL::sizeFromFont(fontp);
LLStyle::Params append_style_params;
append_style_params.color(txt_color);
append_style_params.readonly_color(txt_color);
append_style_params.font(fontp);
append_style_params.underline = true;
append_style_params.font.name(font_name);
append_style_params.font.size(font_size);
if (from.size() > 0)
{
append_style_params.font.style = "ITALIC";
chat.mText = from + " ";
mChatHistory->appendWidgetMessage(chat, append_style_params);
}
message = message.substr(3);
append_style_params.font.style = "UNDERLINE";
mChatHistory->appendText(message, FALSE, append_style_params);
}
else

View File

@ -157,25 +157,29 @@ void LLNearbyChat::addMessage(const LLChat& chat)
{
std::string message = chat.mText;
std::string prefix = message.substr(0, 4);
if (chat.mChatStyle == CHAT_STYLE_IRC)
{
LLColor4 txt_color = LLUIColorTable::instance().getColor("White");
LLViewerChat::getChatColor(chat,txt_color);
LLFontGL* fontp = LLViewerChat::getChatFont();
std::string font_name = LLFontGL::nameFromFont(fontp);
std::string font_size = LLFontGL::sizeFromFont(fontp);
LLStyle::Params append_style_params;
append_style_params.color(txt_color);
append_style_params.readonly_color(txt_color);
append_style_params.font.name(font_name);
append_style_params.font.size(font_size);
if (chat.mFromName.size() > 0)
{
append_style_params.italic= true;
append_style_params.font.style = "ITALIC";
LLChat add_chat=chat;
add_chat.mText = chat.mFromName + " ";
mChatHistory->appendWidgetMessage(add_chat, append_style_params);
}
message = message.substr(3);
LLColor4 txt_color = LLUIColorTable::instance().getColor("White");
LLViewerChat::getChatColor(chat,txt_color);
LLFontGL* fontp = LLViewerChat::getChatFont();
append_style_params.color(txt_color);
append_style_params.readonly_color(txt_color);
append_style_params.font(fontp);
append_style_params.underline = true;
message = message.substr(3);
append_style_params.font.style = "UNDERLINE";
mChatHistory->appendText(message, FALSE, append_style_params);
}
else

View File

@ -51,14 +51,20 @@ LLToastIMPanel::LLToastIMPanel(LLToastIMPanel::Params &p) : LLToastPanel(p.notif
mReplyBtn = getChild<LLButton>("reply");
LLStyle::Params style_params;
style_params.font.name(LLFontGL::nameFromFont(style_params.font));
style_params.font.size(LLFontGL::sizeFromFont(style_params.font));
style_params.font.style = "UNDERLINE";
//Handle IRC styled /me messages.
std::string prefix = p.message.substr(0, 4);
if (prefix == "/me " || prefix == "/me'")
{
mMessage->clear();
style_params.italic = true;
style_params.font.style ="ITALIC";
mMessage->appendText(p.from + " ", FALSE, style_params);
style_params.underline = true;
style_params.font.style = "UNDERLINE";
mMessage->appendText(p.message.substr(3), FALSE, style_params);
}
else