本文整理汇总了C++中LLIconCtrl类的典型用法代码示例。如果您正苦于以下问题:C++ LLIconCtrl类的具体用法?C++ LLIconCtrl怎么用?C++ LLIconCtrl使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了LLIconCtrl类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: name
LLView* LLIconCtrl::fromXML(LLXMLNodePtr node, LLView *parent, LLUICtrlFactory *factory)
{
LLString name("icon");
node->getAttributeString("name", name);
LLRect rect;
createRect(node, rect, parent, LLRect());
LLUUID image_id;
if (node->hasAttribute("image_name"))
{
LLString image_name;
node->getAttributeString("image_name", image_name);
image_id.set(LLUI::sAssetsGroup->getString( image_name ));
}
LLColor4 color(LLColor4::white);
LLUICtrlFactory::getAttributeColor(node,"color", color);
LLIconCtrl* icon = new LLIconCtrl(name, rect, image_id);
icon->setColor(color);
icon->initFromXML(node, parent);
return icon;
}
示例2: createRect
LLView* LLIconCtrl::fromXML(LLXMLNodePtr node, LLView *parent, LLUICtrlFactory *factory)
{
LLRect rect;
createRect(node, rect, parent, LLRect());
std::string image_name;
if (node->hasAttribute("image_name"))
{
node->getAttributeString("image_name", image_name);
}
LLColor4 color(LLColor4::white);
LLUICtrlFactory::getAttributeColor(node,"color", color);
S32 min_width = 0, min_height = 0;
if (node->hasAttribute("min_width"))
{
node->getAttributeS32("min_width", min_width);
}
if (node->hasAttribute("min_height"))
{
node->getAttributeS32("min_height", min_height);
}
LLIconCtrl* icon = new LLIconCtrl("icon", rect, image_name, min_width, min_height);
icon->setColor(color);
icon->initFromXML(node, parent);
return icon;
}
示例3: setBadge
void LLViewChildren::setBadge(const std::string& id, Badge badge, bool visible)
{
LLIconCtrl* child = mParent.getChild<LLIconCtrl>(id);
if (child)
{
child->setVisible(visible);
switch (badge)
{
default:
case BADGE_OK: child->setValue(std::string("badge_ok.j2c")); break;
case BADGE_NOTE: child->setValue(std::string("badge_note.j2c")); break;
case BADGE_WARN: child->setValue(std::string("badge_warn.j2c")); break;
case BADGE_ERROR: child->setValue(std::string("badge_error.j2c")); break;
}
}
}
示例4: LLAvatarListItem
void LLAvatarList::addNewItem(const LLUUID& id, const std::string& name, BOOL is_online, EAddPosition pos)
{
LLAvatarListItem* item = new LLAvatarListItem();
// [RLVa:KB] - Checked: 2010-04-05 (RLVa-1.2.2a) | Added: RLVa-1.2.0d
item->setRlvCheckShowNames(mRlvCheckShowNames);
// [/RLVa:KB]
// AO: Adjust some parameters that need to be changed when we adjust item spacing form the .xml default
// If you change these, also change setLineHeight()
if (mItemHeight != 0)
{
S32 width = item->getRect().getWidth();
item->reshape(width,mItemHeight);
LLIconCtrl* highlight = item->getChild<LLIconCtrl>("hovered_icon");
LLIconCtrl* select = item->getChild<LLIconCtrl>("selected_icon");
highlight->setOrigin(0,24-mItemHeight); // temporary hack to be in the right ballpark.
highlight->reshape(width,mItemHeight);
select->setOrigin(0,24-mItemHeight);
select->reshape(width,mItemHeight);
}
// This sets the name as a side effect
item->setAvatarId(id, mSessionID, mIgnoreOnlineStatus);
item->setOnline(mIgnoreOnlineStatus ? true : is_online);
item->showLastInteractionTime(mShowLastInteractionTime);
item->setAvatarIconVisible(mShowIcons);
item->setShowInfoBtn(mShowInfoBtn);
item->setShowVoiceVolume(mShowVoiceVolume);
item->setShowProfileBtn(mShowProfileBtn);
item->showSpeakingIndicator(mShowSpeakingIndicator);
item->setShowPermissions(mShowPermissions);
item->showUsername(mShowUsername);
item->showDisplayName(mShowDisplayName);
item->showRange(mShowRange);
item->showFirstSeen(mShowFirstSeen);
item->showStatusFlags(mShowStatusFlags);
item->showPaymentStatus(mShowPaymentStatus);
item->showAvatarAge(mShowAge);
// [Ansariel: Colorful radar]
item->setUseRangeColors(mUseRangeColors);
LLUIColorTable* colorTable = &LLUIColorTable::instance();
item->setShoutRangeColor(colorTable->getColor("AvatarListItemShoutRange", LLColor4::yellow));
item->setBeyondShoutRangeColor(colorTable->getColor("AvatarListItemBeyondShoutRange", LLColor4::red));
// [/Ansariel: Colorful radar]
item->setDoubleClickCallback(boost::bind(&LLAvatarList::onItemDoubleClicked, this, _1, _2, _3, _4));
addItem(item, id, pos);
}
示例5: getItems
void LLAvatarList::setItemHeight(S32 height)
// AO: Adjust some parameters that need to be changed when we adjust item spacing form the .xml default
// If you change these, also change addNewItem()
{
mItemHeight = height;
std::vector<LLPanel*> items;
getItems(items);
for(std::vector<LLPanel*>::const_iterator it = items.begin(), end_it = items.end(); it != end_it; ++it)
{
LLAvatarListItem* avItem = static_cast<LLAvatarListItem*>(*it);
if (mItemHeight != 0)
{
S32 width = avItem->getRect().getWidth();
avItem->reshape(width,mItemHeight);
LLIconCtrl* highlight = avItem->getChild<LLIconCtrl>("hovered_icon");
LLIconCtrl* select = avItem->getChild<LLIconCtrl>("selected_icon");
highlight->setOrigin(0,24-height); // temporary hack to be in the right ballpark.
highlight->reshape(width,mItemHeight);
select->setOrigin(0,24-height);
select->reshape(width,mItemHeight);
}
}
mNeedUpdateNames = true;
}
示例6: LLPanel
//---------------------------------------------------------------------------
// Singu Note: We could clean a lot of this up by creating derived classes for Notifications and NotificationTips.
LLNotifyBox::LLNotifyBox(LLNotificationPtr notification)
: LLPanel(notification->getName(), LLRect(), BORDER_NO),
LLEventTimer(notification->getExpiration() == LLDate()
? LLDate(LLDate::now().secondsSinceEpoch() + (F64)gSavedSettings.getF32("NotifyTipDuration"))
: notification->getExpiration()),
LLInstanceTracker<LLNotifyBox, LLUUID>(notification->getID()),
mNotification(notification),
mIsTip(notification->getType() == "notifytip"),
mAnimating(gNotifyBoxView->getChildCount() == 0), // Only animate first window
mNextBtn(NULL),
mNumOptions(0),
mNumButtons(0),
mAddedDefaultBtn(false),
mUserInputBox(NULL)
{
std::string edit_text_name;
std::string edit_text_contents;
// setup paramaters
const std::string& message(notification->getMessage());
// initialize
setFocusRoot(!mIsTip);
// caution flag can be set explicitly by specifying it in the
// notification payload, or it can be set implicitly if the
// notify xml template specifies that it is a caution
//
// tip-style notification handle 'caution' differently -
// they display the tip in a different color
mIsCaution = notification->getPriority() >= NOTIFICATION_PRIORITY_HIGH;
LLNotificationFormPtr form(notification->getForm());
mNumOptions = form->getNumElements();
bool is_textbox = form->getElement("message").isDefined();
bool layout_script_dialog(notification->getName() == "ScriptDialog" || notification->getName() == "ScriptDialogGroup");
LLRect rect = mIsTip ? getNotifyTipRect(message)
: getNotifyRect(is_textbox ? 10 : mNumOptions, layout_script_dialog, mIsCaution);
setRect(rect);
setFollows(mIsTip ? (FOLLOWS_BOTTOM|FOLLOWS_RIGHT) : (FOLLOWS_TOP|FOLLOWS_RIGHT));
setBackgroundVisible(FALSE);
setBackgroundOpaque(TRUE);
LLIconCtrl* icon;
LLTextEditor* text;
const S32 TOP = getRect().getHeight() - (mIsTip ? (S32)sFont->getLineHeight() : 32);
const S32 BOTTOM = (S32)sFont->getLineHeight();
S32 x = HPAD + HPAD;
S32 y = TOP;
if (mIsTip)
{
// use the tip notification icon
icon = new LLIconCtrl(std::string("icon"), LLRect(x, y, x+32, TOP-32), std::string("notify_tip_icon.tga"));
}
else if (mIsCaution)
{
// use the caution notification icon
icon = new LLIconCtrl(std::string("icon"), LLRect(x, y, x+32, TOP-32), std::string("notify_caution_icon.tga"));
}
else
{
// use the default notification icon
icon = new LLIconCtrl(std::string("icon"), LLRect(x, y, x+32, TOP-32), std::string("notify_box_icon.tga"));
}
icon->setMouseOpaque(FALSE);
addChild(icon);
x += HPAD + HPAD + 32;
// add a caution textbox at the top of a caution notification
LLTextBox* caution_box = NULL;
if (mIsCaution && !mIsTip)
{
S32 caution_height = ((S32)sFont->getLineHeight() * 2) + VPAD;
caution_box = new LLTextBox(
std::string("caution_box"),
LLRect(x, y, getRect().getWidth() - 2, caution_height),
LLStringUtil::null,
sFont,
FALSE);
caution_box->setFontStyle(LLFontGL::BOLD);
caution_box->setColor(gColors.getColor("NotifyCautionWarnColor"));
caution_box->setBackgroundColor(gColors.getColor("NotifyCautionBoxColor"));
caution_box->setBorderVisible(FALSE);
caution_box->setWrappedText(notification->getMessage());
addChild(caution_box);
// adjust the vertical position of the next control so that
// it appears below the caution textbox
y = y - caution_height;
//.........这里部分代码省略.........
示例7: LLPanel
LLGroupNotifyBox::LLGroupNotifyBox(const std::string& subject,
const std::string& message,
const std::string& from_name,
const LLUUID& group_id,
const LLUUID& group_insignia,
const std::string& group_name,
const U32& t,
const bool& has_inventory,
const std::string& inventory_name,
LLOfferInfo* inventory_offer)
: LLPanel(std::string("groupnotify"), LLGroupNotifyBox::getGroupNotifyRect(), BORDER_YES),
mAnimating(TRUE),
mTimer(),
mGroupID(group_id),
mHasInventory(has_inventory),
mInventoryOffer(inventory_offer)
{
setFocusRoot(TRUE);
time_t timestamp = (time_t)t;
std::string time_buf = g_formatted_time(timestamp);
setFollows(FOLLOWS_TOP|FOLLOWS_RIGHT);
setBackgroundVisible(TRUE);
setBackgroundOpaque(TRUE);
// TODO: add a color for group notices
setBackgroundColor( gColors.getColor("GroupNotifyBoxColor") );
LLIconCtrl* icon;
LLTextEditor* text;
const S32 VPAD = 2;
const S32 TOP = getRect().getHeight() - 32; // Get past the top menu bar
const S32 BOTTOM_PAD = VPAD * 2;
const S32 BTN_TOP = BOTTOM_PAD + BTN_HEIGHT + VPAD;
const S32 RIGHT = getRect().getWidth() - HPAD - HPAD;
const S32 LINE_HEIGHT = 16;
const S32 LABEL_WIDTH = 64;
const S32 ICON_WIDTH = 64;
S32 y = TOP;
S32 x = HPAD + HPAD;
class NoticeText : public LLTextBox
{
public:
NoticeText(const std::string& name, const LLRect& rect, const std::string& text = LLStringUtil::null, const LLFontGL* font = NULL)
: LLTextBox(name, rect, text, font)
{
setHAlign(LLFontGL::RIGHT);
setFontStyle(LLFontGL::DROP_SHADOW_SOFT);
setBorderVisible(FALSE);
setColor( gColors.getColor("GroupNotifyTextColor") );
setBackgroundColor( gColors.getColor("GroupNotifyBoxColor") );
}
};
// Title
addChild(new NoticeText(std::string("title"),LLRect(x,y,RIGHT - HPAD,y - LINE_HEIGHT),std::string("Group Notice"),LLFontGL::sSansSerifHuge));
y -= llfloor(1.5f*LINE_HEIGHT);
x += HPAD + HPAD + ICON_WIDTH;
std::stringstream from;
from << "Sent by " << from_name << ", " << group_name;
addChild(new NoticeText(std::string("group"),LLRect(x,y,RIGHT - HPAD,y - LINE_HEIGHT),from.str(),LLFontGL::sSansSerif));
y -= (LINE_HEIGHT + VPAD);
x = HPAD + HPAD;
// TODO: change this to be the group icon.
if (!group_insignia.isNull())
{
icon = new LLIconCtrl(std::string("icon"),
LLRect(x, y, x+ICON_WIDTH, y-ICON_WIDTH),
group_insignia);
}
else
{
icon = new LLIconCtrl(std::string("icon"),
LLRect(x, y, x+ICON_WIDTH, y-ICON_WIDTH),
std::string("notify_box_icon.tga"));
}
icon->setMouseOpaque(FALSE);
addChild(icon);
x += HPAD + HPAD + ICON_WIDTH;
// If we have inventory with this message, leave room for the name.
S32 box_bottom = BTN_TOP + (mHasInventory ? (LINE_HEIGHT + 2*VPAD) : 0);
text = new LLViewerTextEditor(std::string("box"),
LLRect(x, y, RIGHT, box_bottom),
DB_GROUP_NOTICE_MSG_STR_LEN,
//.........这里部分代码省略.........
示例8: llmin
void LLVoiceRemoteCtrl::draw()
{
BOOL voice_active = FALSE;
LLVoiceChannel* channelp = LLVoiceChannel::getCurrentVoiceChannel();
if (channelp)
{
voice_active = channelp->isActive();
}
mTalkBtn->setEnabled(voice_active);
mPosLockBtn->setEnabled(voice_active);
mTalkLockBtn->setEnabled(voice_active);
// propagate ptt state to button display,
if (!mTalkBtn->hasMouseCapture())
{
// not in push to talk mode, or push to talk is active means I'm talking
mTalkBtn->setToggleState(!gSavedSettings.getBOOL("PTTCurrentlyEnabled") || gVoiceClient->getUserPTTState());
}
mSpeakersBtn->setToggleState(LLFloaterActiveSpeakers::instanceVisible(LLSD()));
mPosLockBtn->setToggleState(gVoiceClient->getPosLocked());
mTalkLockBtn->setToggleState(!gSavedSettings.getBOOL("PTTCurrentlyEnabled"));
std::string talk_blip_image;
if (gVoiceClient->getIsSpeaking(gAgent.getID()))
{
F32 voice_power = gVoiceClient->getCurrentPower(gAgent.getID());
if (voice_power > LLVoiceClient::OVERDRIVEN_POWER_LEVEL)
{
talk_blip_image = "icn_voice_ptt-on-lvl3.tga";
}
else
{
F32 power = gVoiceClient->getCurrentPower(gAgent.getID());
S32 icon_image_idx = llmin(2, llfloor((power / LLVoiceClient::OVERDRIVEN_POWER_LEVEL) * 3.f));
switch(icon_image_idx)
{
case 0:
talk_blip_image = "icn_voice_ptt-on.tga";
break;
case 1:
talk_blip_image = "icn_voice_ptt-on-lvl1.tga";
break;
case 2:
talk_blip_image = "icn_voice_ptt-on-lvl2.tga";
break;
}
}
}
else
{
talk_blip_image = "icn_voice_ptt-off.tga";
}
LLIconCtrl* icon = getChild<LLIconCtrl>("voice_volume");
if (icon)
{
icon->setImage(talk_blip_image);
}
LLFloater* voice_floater = LLFloaterChatterBox::getInstance()->getCurrentVoiceFloater();
std::string active_channel_name;
if (voice_floater)
{
active_channel_name = voice_floater->getShortTitle();
}
LLVoiceChannel* current_channel = LLVoiceChannel::getCurrentVoiceChannel();
childSetEnabled("end_call_btn", LLVoiceClient::voiceEnabled()
&& current_channel
&& current_channel->isActive()
&& current_channel != LLVoiceChannelProximal::getInstance());
LLButton* expand_button = getChild<LLButton>("show_channel");
if (expand_button)
{
if (expand_button->getToggleState())
{
expand_button->setImageOverlay(std::string("arrow_down.tga"));
}
else
{
expand_button->setImageOverlay(std::string("arrow_up.tga"));
}
}
LLPanel::draw();
}
示例9: ptt_currently_enabled
void LLVoiceRemoteCtrl::draw()
{
BOOL voice_active = FALSE;
LLVoiceChannel* channelp = LLVoiceChannel::getCurrentVoiceChannel();
if (channelp)
{
voice_active = channelp->isActive();
}
mTalkBtn->setEnabled(voice_active);
mTalkLockBtn->setEnabled(voice_active);
static LLCachedControl<bool> ptt_currently_enabled("PTTCurrentlyEnabled",false);
// propagate ptt state to button display,
if (!mTalkBtn->hasMouseCapture())
{
// not in push to talk mode, or push to talk is active means I'm talking
mTalkBtn->setToggleState(!ptt_currently_enabled || gVoiceClient->getUserPTTState());
}
mSpeakersBtn->setToggleState(LLFloaterActiveSpeakers::instanceVisible(LLSD()));
mTalkLockBtn->setToggleState(!ptt_currently_enabled);
std::string talk_blip_image;
if (gVoiceClient->getIsSpeaking(gAgent.getID()))
{
F32 voice_power = gVoiceClient->getCurrentPower(gAgent.getID());
if (voice_power > LLVoiceClient::OVERDRIVEN_POWER_LEVEL)
{
talk_blip_image = "icn_voice_ptt-on-lvl3.tga";
}
else
{
F32 power = gVoiceClient->getCurrentPower(gAgent.getID());
S32 icon_image_idx = llmin(2, llfloor((power / LLVoiceClient::OVERDRIVEN_POWER_LEVEL) * 3.f));
switch(icon_image_idx)
{
case 0:
talk_blip_image = "icn_voice_ptt-on.tga";
break;
case 1:
talk_blip_image = "icn_voice_ptt-on-lvl1.tga";
break;
case 2:
talk_blip_image = "icn_voice_ptt-on-lvl2.tga";
break;
}
}
}
else
{
talk_blip_image = "icn_voice_ptt-off.tga";
}
LLIconCtrl* icon = mVoiceVolIcon;
if (icon)
{
icon->setImage(talk_blip_image);
}
LLFloater* voice_floater = LLFloaterChatterBox::getInstance()->getCurrentVoiceFloater();
std::string active_channel_name;
if (voice_floater)
{
active_channel_name = voice_floater->getShortTitle();
}
LLVoiceChannel* current_channel = LLVoiceChannel::getCurrentVoiceChannel();
mEndCallBtn->setEnabled(LLVoiceClient::voiceEnabled()
&& current_channel
&& current_channel->isActive()
&& current_channel != LLVoiceChannelProximal::getInstance());
mChanLabelTextBox->setValue(active_channel_name);
mVoiceChanBgBtn->setToolTip(active_channel_name);
if (current_channel)
{
LLIconCtrl* voice_channel_icon = mVoiceChanIcon;
if (voice_channel_icon && voice_floater)
{
voice_channel_icon->setImage(voice_floater->getString("voice_icon"));
}
LLButton* voice_channel_bg = mVoiceChanBgBtn;
if (voice_channel_bg)
{
LLColor4 bg_color;
if (current_channel->isActive())
{
bg_color = lerp(LLColor4::green, LLColor4::white, 0.7f);
}
else if (current_channel->getState() == LLVoiceChannel::STATE_ERROR)
{
bg_color = lerp(LLColor4::red, LLColor4::white, 0.7f);
}
else // active, but not connected
{
bg_color = lerp(LLColor4::yellow, LLColor4::white, 0.7f);
//.........这里部分代码省略.........
示例10: LLToastPanel
//.........这里部分代码省略.........
S32 dialog_width = llmax( btn_total_width, text_rect.getWidth() ) + 2 * HPAD;
S32 dialog_height = text_rect.getHeight() + 3 * VPAD + BTN_HEIGHT;
if (hasTitleBar())
{
dialog_height += LINE_HEIGHT; // room for title bar
}
// it's ok for the edit text body to be empty, but we want the name to exist if we're going to draw it
if (!edit_text_name.empty())
{
dialog_height += EDITOR_HEIGHT + VPAD;
dialog_width = llmax(dialog_width, (S32)(font->getWidth( edit_text_contents ) + 0.99f));
}
if (mCaution)
{
// Make room for the caution icon.
dialog_width += 32 + HPAD;
}
LLToastPanel::reshape( dialog_width, dialog_height, FALSE );
S32 msg_y = LLToastPanel::getRect().getHeight() - VPAD;
S32 msg_x = HPAD;
if (hasTitleBar())
{
msg_y -= LINE_HEIGHT; // room for title
}
static LLUIColor alert_caution_text_color = LLUIColorTable::instance().getColor("AlertCautionTextColor");
if (mCaution)
{
LLIconCtrl* icon = LLUICtrlFactory::getInstance()->createFromFile<LLIconCtrl>("alert_icon.xml", this, LLPanel::child_registry_t::instance());
if(icon)
{
icon->setRect(LLRect(msg_x, msg_y, msg_x+32, msg_y-32));
LLToastPanel::addChild(icon);
}
msg_x += 32 + HPAD;
msg_box->setColor( alert_caution_text_color );
}
LLRect rect;
rect.setLeftTopAndSize( msg_x, msg_y, text_rect.getWidth(), text_rect.getHeight() );
msg_box->setRect( rect );
LLToastPanel::addChild(msg_box);
// (Optional) Edit Box
if (!edit_text_name.empty())
{
S32 y = VPAD + BTN_HEIGHT + VPAD/2;
mLineEditor = LLUICtrlFactory::getInstance()->createFromFile<LLLineEditor>("alert_line_editor.xml", this, LLPanel::child_registry_t::instance());
if (mLineEditor)
{
LLRect leditor_rect = LLRect( HPAD, y+EDITOR_HEIGHT, dialog_width-HPAD, y);
mLineEditor->setName(edit_text_name);
mLineEditor->reshape(leditor_rect.getWidth(), leditor_rect.getHeight());
mLineEditor->setRect(leditor_rect);
mLineEditor->setMaxTextChars(edit_text_max_chars);
mLineEditor->setText(edit_text_contents);
// decrease limit of line editor of teleport offer dialog to avoid truncation of
// location URL in invitation message, see EXT-6891
示例11: LLModalDialog
//.........这里部分代码省略.........
const LLRect& text_rect = msg_box->getRect();
S32 dialog_width = llmax( btn_total_width, text_rect.getWidth() ) + 2 * HPAD;
S32 dialog_height = text_rect.getHeight() + 3 * VPAD + BTN_HEIGHT;
if (hasTitleBar())
{
dialog_height += LINE_HEIGHT; // room for title bar
}
// it's ok for the edit text body to be empty, but we want the name to exist if we're going to draw it
if (!edit_text_name.empty())
{
dialog_height += EDITOR_HEIGHT + VPAD;
dialog_width = llmax(dialog_width, (S32)(font->getWidth( edit_text_contents ) + 0.99f));
}
if (mCaution)
{
// Make room for the caution icon.
dialog_width += 32 + HPAD;
}
reshape( dialog_width, dialog_height, FALSE );
S32 msg_y = getRect().getHeight() - VPAD;
S32 msg_x = HPAD;
if (hasTitleBar())
{
msg_y -= LINE_HEIGHT; // room for title
}
if (mCaution)
{
LLIconCtrl* icon = new LLIconCtrl(std::string("icon"), LLRect(msg_x, msg_y, msg_x+32, msg_y-32), std::string("notify_caution_icon.tga"));
icon->setMouseOpaque(FALSE);
addChild(icon);
msg_x += 32 + HPAD;
msg_box->setColor( LLUI::sColorsGroup->getColor( "AlertCautionTextColor" ) );
}
else
{
msg_box->setColor( LLUI::sColorsGroup->getColor( "AlertTextColor" ) );
}
LLRect rect;
rect.setLeftTopAndSize( msg_x, msg_y, text_rect.getWidth(), text_rect.getHeight() );
msg_box->setRect( rect );
addChild(msg_box);
// Buttons
S32 button_left = (getRect().getWidth() - btn_total_width) / 2;
for( options_t::iterator it = options.begin(); it != options.end(); it++ )
{
LLRect button_rect;
button_rect.setOriginAndSize( button_left, VPAD, button_width, BTN_HEIGHT );
ButtonData& button_data = *it;
LLButton* btn = new LLButton(
button_data.mName, button_rect,
"","", "",
NULL,
font,
button_data.mText,
button_data.mText);
示例12: LLPanel
//---------------------------------------------------------------------------
LLNotifyBox::LLNotifyBox(LLNotificationPtr notification,
BOOL layout_script_dialog)
: LLPanel(notification->getName(), LLRect(), BORDER_NO),
LLEventTimer(notification->getExpiration() == LLDate()
? LLDate(LLDate::now().secondsSinceEpoch() + (F64)gSavedSettings.getF32("NotifyTipDuration"))
: notification->getExpiration()),
LLInstanceTracker<LLNotifyBox, LLUUID>(notification->getID()),
mNotification(notification),
mIsTip(notification->getType() == "notifytip"),
mAnimating(TRUE),
mNextBtn(NULL),
mNumOptions(0),
mNumButtons(0),
mAddedDefaultBtn(FALSE),
mLayoutScriptDialog(layout_script_dialog)
{
// clicking on a button does not steal current focus
setIsChrome(TRUE);
// class init
if (!sFont)
{
sFont = LLFontGL::getFontSansSerif();
sFontSmall = LLFontGL::getFontSansSerifSmall();
}
// setup paramaters
mMessage = notification->getMessage();
// initialize
setFocusRoot(!mIsTip);
// caution flag can be set explicitly by specifying it in the
// notification payload, or it can be set implicitly if the
// notify xml template specifies that it is a caution
//
// tip-style notification handle 'caution' differently -
// they display the tip in a different color
mIsCaution = notification->getPriority() >= NOTIFICATION_PRIORITY_HIGH;
// Only animate first window
if( gNotifyBoxView->getChildCount() > 0 )
mAnimating = FALSE;
else
mAnimating = TRUE;
LLNotificationFormPtr form(notification->getForm());
mNumOptions = form->getNumElements();
LLRect rect = mIsTip ? getNotifyTipRect(mMessage)
: getNotifyRect(mNumOptions, layout_script_dialog, mIsCaution);
setRect(rect);
setFollows(mIsTip ? (FOLLOWS_BOTTOM|FOLLOWS_RIGHT) : (FOLLOWS_TOP|FOLLOWS_RIGHT));
setBackgroundVisible(FALSE);
setBackgroundOpaque(TRUE);
LLIconCtrl* icon;
LLTextEditor* text;
const S32 TOP = getRect().getHeight() - (mIsTip ? (S32)sFont->getLineHeight() : 32);
const S32 BOTTOM = (S32)sFont->getLineHeight();
S32 x = HPAD + HPAD;
S32 y = TOP;
if (mIsTip)
{
// use the tip notification icon
icon = new LLIconCtrl(std::string("icon"), LLRect(x, y, x+32, TOP-32), std::string("notify_tip_icon.tga"));
}
else if (mIsCaution)
{
// use the caution notification icon
icon = new LLIconCtrl(std::string("icon"), LLRect(x, y, x+32, TOP-32), std::string("notify_caution_icon.tga"));
}
else
{
// use the default notification icon
icon = new LLIconCtrl(std::string("icon"), LLRect(x, y, x+32, TOP-32), std::string("notify_box_icon.tga"));
}
icon->setMouseOpaque(FALSE);
addChild(icon);
x += HPAD + HPAD + 32;
// add a caution textbox at the top of a caution notification
LLTextBox* caution_box = NULL;
if (mIsCaution && !mIsTip)
{
S32 caution_height = ((S32)sFont->getLineHeight() * 2) + VPAD;
caution_box = new LLTextBox(
std::string("caution_box"),
LLRect(x, y, getRect().getWidth() - 2, caution_height),
LLStringUtil::null,
sFont,
FALSE);
caution_box->setFontStyle(LLFontGL::BOLD);
//.........这里部分代码省略.........
示例13: LLPanel
LLNotifyBox::LLNotifyBox(LLPointer<LLNotifyBoxTemplate> xml_template, const LLStringUtil::format_map_t& args,
notify_callback_t callback, void* user_data, BOOL is_caution,
const option_list_t& extra_options,
BOOL layout_script_dialog)
: LLPanel(xml_template->mLabel, LLRect(), BORDER_NO),
LLEventTimer(xml_template->mDuration),
mIsTip(FALSE),
mAnimating(TRUE),
mUnique(xml_template->mUnique),
mNextBtn(NULL),
mBehavior(new LLNotifyBehavior(callback, user_data)),
mNumOptions(0),
mDefaultOption(0)
{
// clicking on a button does not steal current focus
setIsChrome(TRUE);
// class init
if (!sFont)
{
sFont = LLFontGL::sSansSerif;
sFontSmall = LLFontGL::sSansSerifSmall;
}
// setup paramaters
mMessage = xml_template->mMessage;
format(mMessage, args);
// use name + formatted text as unique key
if (mUnique)
{
sOpenUniqueNotifyBoxes[xml_template->mLabel + mMessage] = this;
}
option_list_t options = xml_template->mOptions;
options.insert(options.end(), extra_options.begin(), extra_options.end());
// initialize
mIsTip = xml_template->mIsTip;
setFocusRoot(!mIsTip);
// caution flag can be set explicitly by specifying it in the
// call to the c'tor, or it can be set implicitly if the
// notify xml template specifies that it is a caution
//
// tip-style notification handle 'caution' differently -
// they display the tip in a different color
mIsCaution = (xml_template->mIsCaution || is_caution);
// Don't animate if behind other windows
if( gNotifyBoxView->getChildCount() > 0 )
mAnimating = FALSE;
else
mAnimating = TRUE;
mNumOptions = options.size();
mDefaultOption = xml_template->mDefaultOption;
LLRect rect = mIsTip ? getNotifyTipRect(mMessage)
: getNotifyRect(mNumOptions, layout_script_dialog, mIsCaution);
setRect(rect);
setFollows(mIsTip ? (FOLLOWS_BOTTOM|FOLLOWS_RIGHT) : (FOLLOWS_TOP|FOLLOWS_RIGHT));
setBackgroundVisible(FALSE);
setBackgroundOpaque(TRUE);
LLIconCtrl* icon;
LLTextEditor* text;
const S32 TOP = getRect().getHeight() - (mIsTip ? (S32)sFont->getLineHeight() : 32);
const S32 BOTTOM = (S32)sFont->getLineHeight();
S32 x = HPAD + HPAD;
S32 y = TOP;
if (mIsTip)
{
// use the tip notification icon
icon = new LLIconCtrl(std::string("icon"), LLRect(x, y, x+32, TOP-32), std::string("notify_tip_icon.tga"));
}
else if (mIsCaution)
{
// use the caution notification icon
icon = new LLIconCtrl(std::string("icon"), LLRect(x, y, x+32, TOP-32), std::string("notify_caution_icon.tga"));
}
else
{
// use the default notification icon
icon = new LLIconCtrl(std::string("icon"), LLRect(x, y, x+32, TOP-32), std::string("notify_box_icon.tga"));
}
icon->setMouseOpaque(FALSE);
addChild(icon);
x += HPAD + HPAD + 32;
// add a caution textbox at the top of a caution notification
LLTextBox* caution_box = NULL;
if (mIsCaution && !mIsTip)
{
//.........这里部分代码省略.........
示例14: setBackgroundVisible
void LLAlertDialog::createDialog(const std::vector<LLString>* optionsp, S32 default_option,
const LLString& msg_in, const LLString::format_map_t& args,
const LLString& edit_text)
{
setBackgroundVisible(TRUE);
setBackgroundOpaque(TRUE);
const LLFontGL* font = gResMgr->getRes( font_name );
const S32 LINE_HEIGHT = llfloor(font->getLineHeight() + 0.99f);
const S32 EDITOR_HEIGHT = 20;
// Buttons
std::vector<LLString> default_option_list;
mNumOptions = optionsp->size();
if( 0 == mNumOptions )
{
default_option_list.push_back("Close");
optionsp = &default_option_list;
default_option = 0;
mNumOptions = 1;
}
const std::vector<LLString>& options = *optionsp;
mButtonData = new ButtonData[mNumOptions];
// Calc total width of buttons
S32 button_width = 0;
S32 sp = font->getWidth("OO");
for( S32 i = 0; i < mNumOptions; i++ )
{
S32 w = S32(font->getWidth( options[i] ) + 0.99f) + sp + 2 * LLBUTTON_H_PAD;
button_width = llmax( w, button_width );
}
S32 btn_total_width = button_width;
if( mNumOptions > 1 )
{
btn_total_width = (mNumOptions * button_width) + ((mNumOptions - 1) * BTN_HPAD);
}
// Message: create text box using raw string, as text has been structure deliberately
// Use size of created text box to generate dialog box size
LLString msg = msg_in;
format( msg, args );
llwarns << "Alert: " << msg << llendl;
LLTextBox* msg_box = new LLTextBox( "Alert message", msg, (F32)MAX_ALLOWED_MSG_WIDTH, font );
const LLRect& text_rect = msg_box->getRect();
S32 dialog_width = llmax( btn_total_width, text_rect.getWidth() ) + 2 * HPAD;
S32 dialog_height = text_rect.getHeight() + 3 * VPAD + BTN_HEIGHT;
if (hasTitleBar())
{
dialog_height += LINE_HEIGHT; // room for title bar
}
if (edit_text.size() > 0)
{
dialog_width = llmax(dialog_width, S32(font->getWidth( edit_text ) + 0.99f));
dialog_height += EDITOR_HEIGHT;
}
if (mCaution)
{
// Make room for the caution icon.
dialog_width += 32 + HPAD;
}
reshape( dialog_width, dialog_height, FALSE );
S32 msg_y = mRect.getHeight() - VPAD;
S32 msg_x = HPAD;
if (hasTitleBar())
{
msg_y -= LINE_HEIGHT; // room for title
}
if (mCaution)
{
LLIconCtrl* icon = new LLIconCtrl("icon", LLRect(msg_x, msg_y, msg_x+32, msg_y-32), "notify_caution_icon.tga");
icon->setMouseOpaque(FALSE);
addChild(icon);
msg_x += 32 + HPAD;
msg_box->setColor( LLUI::sColorsGroup->getColor( "AlertCautionTextColor" ) );
}
else
{
msg_box->setColor( LLUI::sColorsGroup->getColor( "AlertTextColor" ) );
}
LLRect rect;
rect.setLeftTopAndSize( msg_x, msg_y, text_rect.getWidth(), text_rect.getHeight() );
msg_box->setRect( rect );
addChild(msg_box);
// Buttons
S32 button_left = (mRect.getWidth() - btn_total_width) / 2;
for( S32 i = 0; i < mNumOptions; i++ )
{
LLRect button_rect;
button_rect.setOriginAndSize( button_left, VPAD, button_width, BTN_HEIGHT );
LLButton* btn = new LLButton(
//.........这里部分代码省略.........
示例15: onMouseLeave
void LLTeleportHistoryMenuItem::onMouseLeave(S32 x, S32 y, MASK mask)
{
mArrowIcon->setVisible(FALSE);
}