LLButton* LLToastNotifyPanel::createButton(const LLSD& form_element, BOOL is_option) { InstanceAndS32* userdata = new InstanceAndS32; userdata->mSelf = this; userdata->mButtonName = is_option ? form_element["name"].asString() : ""; mBtnCallbackData.push_back(userdata); LLButton::Params p; bool is_ignore_btn = form_element["index"].asInteger() == -1; const LLFontGL* font = is_ignore_btn ? sFontSmall: sFont; // for ignore button in script dialog p.name(form_element["name"].asString()); p.label(form_element["text"].asString()); p.font(font); p.rect.height = BTN_HEIGHT; p.click_callback.function(boost::bind(&LLToastNotifyPanel::onClickButton, userdata)); p.rect.width = BUTTON_WIDTH; p.auto_resize = false; p.follows.flags(FOLLOWS_LEFT | FOLLOWS_BOTTOM); if (mIsCaution) { p.image_color(LLUIColorTable::instance().getColor("ButtonCautionImageColor")); p.image_color_disabled(LLUIColorTable::instance().getColor("ButtonCautionImageColor")); } // for the scriptdialog buttons we use fixed button size. This is a limit! if (!mIsScriptDialog && font->getWidth(form_element["text"].asString()) > BUTTON_WIDTH) { p.rect.width = 1; p.auto_resize = true; } else if (mIsScriptDialog && is_ignore_btn) { // this is ignore button,make it smaller p.rect.height = BTN_HEIGHT_SMALL; p.rect.width = 1; p.auto_resize = true; } LLButton* btn = LLUICtrlFactory::create<LLButton>(p); mNumButtons++; btn->autoResize(); if (form_element["default"].asBoolean()) { setDefaultBtn(btn); } return btn; }
void LLToastScriptQuestion::createButtons() { LLNotificationFormPtr form = mNotification->getForm(); int num_elements = form->getNumElements(); int buttons_width = 0; for (int i = 0; i < num_elements; ++i) { LLSD form_element = form->getElement(i); if ("button" == form_element["type"].asString()) { LLButton::Params p; const LLFontGL* font = LLFontGL::getFontSansSerif(); p.name(form_element["name"].asString()); p.label(form_element["text"].asString()); p.layout("topleft"); p.font(font); p.rect.height(BUTTON_HEIGHT); p.click_callback.function(boost::bind(&LLToastScriptQuestion::onButtonClicked, this, form_element["name"].asString())); p.rect.left = LEFT_PAD; p.rect.width = font->getWidth(form_element["text"].asString()); p.auto_resize = true; p.follows.flags(FOLLOWS_LEFT | FOLLOWS_BOTTOM); p.image_color(LLUIColorTable::instance().getColor("ButtonCautionImageColor")); p.image_color_disabled(LLUIColorTable::instance().getColor("ButtonCautionImageColor")); LLButton* button = LLUICtrlFactory::create<LLButton>(p); button->autoResize(); getChild<LLPanel>("buttons_panel")->addChild(button); LLRect rect = button->getRect(); rect.setLeftTopAndSize(buttons_width, rect.mTop, rect.getWidth(), rect.getHeight()); button->setRect(rect); buttons_width += rect.getWidth() + LEFT_PAD; } } }