LLButton* LLSideTray::createButton	(const std::string& name,const std::string& image,const std::string& tooltip,
									 LLUICtrl::commit_callback_t callback)
{
	static LLSideTray::Params sidetray_params(LLUICtrlFactory::getDefaultParams<LLSideTray>());	
	
	LLButton::Params bparams;

	LLRect rect;
	rect.setOriginAndSize(0, 0, sidetray_params.default_button_width, sidetray_params.default_button_height); 

	bparams.name(name);
	bparams.follows.flags (FOLLOWS_LEFT | FOLLOWS_TOP);
	bparams.rect (rect);
	bparams.tab_stop(false);
	bparams.image_unselected.name(sidetray_params.tab_btn_image_normal);
	bparams.image_selected.name(sidetray_params.tab_btn_image_selected);
	bparams.image_disabled.name(sidetray_params.tab_btn_image_normal);
	bparams.image_disabled_selected.name(sidetray_params.tab_btn_image_selected);

	LLButton* button = LLUICtrlFactory::create<LLButton> (bparams);
	button->setLabel(name);
	button->setClickedCallback(callback);

	button->setToolTip(tooltip);
	
	if(image.length())
	{
		button->setImageOverlay(image);
	}

	mButtonsPanel->addChildInBack(button);

	return button;
}
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;
		}
	}
}
示例#4
0
LLDebugVarMessageBox::LLDebugVarMessageBox(const std::string& title, EDebugVarType var_type, void *var) : 
	LLFloater(LLSD()),
	mVarType(var_type), mVarData(var), mAnimate(FALSE)
{
	setRect(LLRect(10,160,400,10));
	
	LLSliderCtrl::Params slider_p;
	slider_p.label(title);
	slider_p.label_width(70);
	slider_p.text_width(40);
	slider_p.can_edit_text(true);
	slider_p.show_text(true);

	mSlider1 = NULL;
	mSlider2 = NULL;
	mSlider3 = NULL;

	switch(var_type)
	{
	case VAR_TYPE_F32:
		slider_p.name("slider 1");
		slider_p.rect(LLRect(20,130,190,110));
		slider_p.initial_value(*((F32*)var));
		slider_p.min_value(-100.f);
		slider_p.max_value(100.f);
		slider_p.increment(0.1f);
		slider_p.decimal_digits(3);
		mSlider1 = LLUICtrlFactory::create<LLSliderCtrl>(slider_p);
		addChild(mSlider1);
		break;
	case VAR_TYPE_S32:
		slider_p.name("slider 1");
		slider_p.rect(LLRect(20,100,190,80));
		slider_p.initial_value((F32)*((S32*)var));
		slider_p.min_value(-255.f);
		slider_p.max_value(255.f);
		slider_p.increment(1.f);
		slider_p.decimal_digits(0);
		mSlider1 = LLUICtrlFactory::create<LLSliderCtrl>(slider_p);
		addChild(mSlider1);
		break;
	case VAR_TYPE_VEC3:
		slider_p.name("slider 1");
		slider_p.label("x: ");
		slider_p.rect(LLRect(20,130,190,110));
		slider_p.initial_value(((LLVector3*)var)->mV[VX]);
		slider_p.min_value(-100.f);
		slider_p.max_value(100.f);
		slider_p.increment(0.1f);
		slider_p.decimal_digits(3);
		mSlider1 = LLUICtrlFactory::create<LLSliderCtrl>(slider_p);

		slider_p.name("slider 2");
		slider_p.label("y: ");
		slider_p.rect(LLRect(20,100,190,80));
		slider_p.initial_value(((LLVector3*)var)->mV[VY]);
		mSlider2 = LLUICtrlFactory::create<LLSliderCtrl>(slider_p);

		slider_p.name("slider 3");
		slider_p.label("z: ");
		slider_p.rect(LLRect(20,70,190,50));
		slider_p.initial_value(((LLVector3*)var)->mV[VZ]);
		mSlider2 = LLUICtrlFactory::create<LLSliderCtrl>(slider_p);

		addChild(mSlider1);
		addChild(mSlider2);
		addChild(mSlider3);
		break;
	default:
		llwarns << "Unhandled var type " << var_type << llendl;
		break;
	}

	LLButton::Params p;
	p.name(std::string("Animate"));
	p.label(std::string("Animate"));
	p.rect(LLRect(20, 45, 180, 25));
	p.click_callback.function(boost::bind(&LLDebugVarMessageBox::onAnimateClicked, this, _2));
	mAnimateButton = LLUICtrlFactory::create<LLButton>(p);
	addChild(mAnimateButton);

	LLTextBox::Params params;
	params.name("value");
	params.initial_value(params.name());
	params.rect(LLRect(20,20,190,0));
	mText = LLUICtrlFactory::create<LLTextBox> (params);
	addChild(mText);

	//disable hitting enter closes dialog
	setDefaultBtn();
}