Пример #1
0
LLSlider::LLSlider(const LLSlider::Params& p)
:	LLF32UICtrl(p),
	mMouseOffset( 0 ),
	mOrientation ((p.orientation() == "horizontal") ? HORIZONTAL : VERTICAL),
	mTrackColor(p.track_color()),
	mThumbOutlineColor(p.thumb_outline_color()),
	mThumbCenterColor(p.thumb_center_color()),
	mThumbImage(p.thumb_image),
	mThumbImagePressed(p.thumb_image_pressed),
	mThumbImageDisabled(p.thumb_image_disabled),
	mTrackImageHorizontal(p.track_image_horizontal),
	mTrackImageVertical(p.track_image_vertical),
	mTrackHighlightHorizontalImage(p.track_highlight_horizontal_image),
	mTrackHighlightVerticalImage(p.track_highlight_vertical_image),
	mMouseDownSignal(NULL),
	mMouseUpSignal(NULL)
{
    mViewModel->setValue(p.initial_value);
	updateThumbRect();
	mDragStartThumbRect = mThumbRect;
	setControlName(p.control_name, NULL);
	setValue(getValueF32());
	
	if (p.mouse_down_callback.isProvided())
	{
		setMouseDownCallback(initCommitCallback(p.mouse_down_callback));
	}
	if (p.mouse_up_callback.isProvided())
	{
		setMouseUpCallback(initCommitCallback(p.mouse_up_callback));
	}
}
Пример #2
0
BOOL LLPanelTipToast::postBuild()
{
	mMessageText= findChild<LLUICtrl>("message");

	if (mMessageText != NULL)
	{
		mMessageText->setMouseUpCallback(boost::bind(&LLPanelTipToast::onMessageTextClick,this));
		setMouseUpCallback(boost::bind(&LLPanelTipToast::onPanelClick, this, _2, _3, _4));
	}
	else
	{
		llassert(!"Can't find child 'message' text box.");
		return FALSE;
	}

	return TRUE;
}
Пример #3
0
LLMultiSlider::LLMultiSlider(const LLMultiSlider::Params& p)
:	LLF32UICtrl(p),
	mMouseOffset( 0 ),
	mDragStartThumbRect( 0, getRect().getHeight(), p.thumb_width, 0 ),
	mMaxNumSliders(p.max_sliders),
	mAllowOverlap(p.allow_overlap),
	mDrawTrack(p.draw_track),
	mUseTriangle(p.use_triangle),
	mTrackColor(p.track_color()),
	mThumbOutlineColor(p.thumb_outline_color()),
	mThumbCenterColor(p.thumb_center_color()),
	mThumbCenterSelectedColor(p.thumb_center_selected_color()),
	mDisabledThumbColor(p.thumb_disabled_color()),
	mTriangleColor(p.triangle_color()),
	mThumbWidth(p.thumb_width),
	mMouseDownSignal(NULL),
	mMouseUpSignal(NULL)
{
	mValue.emptyMap();
	mCurSlider = LLStringUtil::null;
	
	if (p.mouse_down_callback.isProvided())
	{
		setMouseDownCallback(initCommitCallback(p.mouse_down_callback));
	}
	if (p.mouse_up_callback.isProvided())
	{
		setMouseUpCallback(initCommitCallback(p.mouse_up_callback));
	}

	for (LLInitParam::ParamIterator<SliderParams>::const_iterator it = p.sliders.begin();
		it != p.sliders.end();
		++it)
	{
		if (it->name.isProvided())
		{
			addSlider(it->value, it->name);
		}
		else
		{
			addSlider(it->value);
		}
	}
}
Пример #4
0
boost::signals2::connection LLButton::setMouseUpCallback( button_callback_t cb, void* data )
{
	return setMouseUpCallback(boost::bind(cb, data));
}
Пример #5
0
LLButton::LLButton(const LLButton::Params& p)
:	LLUICtrl(p),
	mMouseDownFrame(0),
	mMouseHeldDownCount(0),
	mBorderEnabled( FALSE ),
	mFlashing( FALSE ),
	mCurGlowStrength(0.f),
	mNeedsHighlight(FALSE),
	mMouseOver(false),
	mUnselectedLabel(p.label()),
	mSelectedLabel(p.label_selected()),
	mGLFont(p.font),
	mHeldDownDelay(p.held_down_delay.seconds),			// seconds until held-down callback is called
	mHeldDownFrameDelay(p.held_down_delay.frames),
	mImageUnselected(p.image_unselected),
	mImageSelected(p.image_selected),
	mImageDisabled(p.image_disabled),
	mImageDisabledSelected(p.image_disabled_selected),
	mImageFlash(p.image_flash),
	mImagePressed(p.image_pressed),
	mImagePressedSelected(p.image_pressed_selected),
	mImageHoverSelected(p.image_hover_selected),
	mImageHoverUnselected(p.image_hover_unselected),
	mUnselectedLabelColor(p.label_color()),
	mSelectedLabelColor(p.label_color_selected()),
	mDisabledLabelColor(p.label_color_disabled()),
	mDisabledSelectedLabelColor(p.label_color_disabled_selected()),
	mHighlightColor(p.highlight_color()),
	mImageColor(p.image_color()),
	mFlashBgColor(p.flash_color()),
	mDisabledImageColor(p.image_color_disabled()),
	mImageOverlay(p.image_overlay()),
	mImageOverlayColor(p.image_overlay_color()),
	mImageOverlayAlignment(LLFontGL::hAlignFromName(p.image_overlay_alignment)),
	mImageOverlayTopPad(p.image_top_pad),
	mImageOverlayBottomPad(p.image_bottom_pad),
	mImgOverlayLabelSpace(p.imgoverlay_label_space),
	mIsToggle(p.is_toggle),
	mScaleImage(p.scale_image),
	mDropShadowedText(p.label_shadow),
	mAutoResize(p.auto_resize),
	mUseEllipses( p.use_ellipses ),
	mHAlign(p.font_halign),
	mLeftHPad(p.pad_left),
	mRightHPad(p.pad_right),
	mBottomVPad(p.pad_bottom),
	mHoverGlowStrength(p.hover_glow_amount),
	mCommitOnReturn(p.commit_on_return),
	mFadeWhenDisabled(FALSE),
	mForcePressedState(false),
	mLastDrawCharsCount(0),
	mMouseDownSignal(NULL),
	mMouseUpSignal(NULL),
	mHeldDownSignal(NULL)

{
	static LLUICachedControl<S32> llbutton_orig_h_pad ("UIButtonOrigHPad", 0);
	static Params default_params(LLUICtrlFactory::getDefaultParams<LLButton>());

	if (!p.label_selected.isProvided())
	{
		mSelectedLabel = mUnselectedLabel;
	}

	// Hack to make sure there is space for at least one character
	if (getRect().getWidth() - (mRightHPad + mLeftHPad) < mGLFont->getWidth(std::string(" ")))
	{
		// Use old defaults
		mLeftHPad = llbutton_orig_h_pad;
		mRightHPad = llbutton_orig_h_pad;
	}
	
	mMouseDownTimer.stop();

	// if custom unselected button image provided...
	if (p.image_unselected != default_params.image_unselected)
	{
		//...fade it out for disabled image by default...
		if (p.image_disabled() == default_params.image_disabled() )
		{
			mImageDisabled = p.image_unselected;
			mFadeWhenDisabled = TRUE;
		}

		if (p.image_pressed_selected == default_params.image_pressed_selected)
		{
			mImagePressedSelected = mImageUnselected;
		}
	}

	// if custom selected button image provided...
	if (p.image_selected != default_params.image_selected)
	{
		//...fade it out for disabled image by default...
		if (p.image_disabled_selected() == default_params.image_disabled_selected())
		{
			mImageDisabledSelected = p.image_selected;
			mFadeWhenDisabled = TRUE;
		}

		if (p.image_pressed == default_params.image_pressed)
		{
			mImagePressed = mImageSelected;
		}
	}

	if (!p.image_pressed.isProvided())
	{
		mImagePressed = mImageSelected;
	}

	if (!p.image_pressed_selected.isProvided())
	{
		mImagePressedSelected = mImageUnselected;
	}
	
	if (mImageUnselected.isNull())
	{
		llwarns << "Button: " << getName() << " with no image!" << llendl;
	}
	
	if (p.click_callback.isProvided())
	{
		setCommitCallback(initCommitCallback(p.click_callback)); // alias -> commit_callback
	}
	if (p.mouse_down_callback.isProvided())
	{
		setMouseDownCallback(initCommitCallback(p.mouse_down_callback));
	}
	if (p.mouse_up_callback.isProvided())
	{
		setMouseUpCallback(initCommitCallback(p.mouse_up_callback));
	}
	if (p.mouse_held_callback.isProvided())
	{
		setHeldDownCallback(initCommitCallback(p.mouse_held_callback));
	}
}
boost::signals2::connection LLButton::setMouseUpCallback(const CommitCallbackParam& cb)
{
	return setMouseUpCallback(initCommitCallback(cb));
}
LLButton::LLButton(const LLButton::Params& p)
:	LLUICtrl(p),
	LLBadgeOwner(getHandle()),
	mMouseDownFrame(0),
	mMouseHeldDownCount(0),
	mBorderEnabled( FALSE ),
	mFlashing( FALSE ),
	mCurGlowStrength(0.f),
	mNeedsHighlight(FALSE),
	mUnselectedLabel(p.label()),
	mSelectedLabel(p.label_selected()),
	mGLFont(p.font),
	mHeldDownDelay(p.held_down_delay.seconds),			// seconds until held-down callback is called
	mHeldDownFrameDelay(p.held_down_delay.frames),
	mImageUnselected(p.image_unselected),
	mImageSelected(p.image_selected),
	mImageDisabled(p.image_disabled),
	mImageDisabledSelected(p.image_disabled_selected),
	mImageFlash(p.image_flash),
	mImagePressed(p.image_pressed),
	mImagePressedSelected(p.image_pressed_selected),
	mImageHoverSelected(p.image_hover_selected),
	mImageHoverUnselected(p.image_hover_unselected),
	mUnselectedLabelColor(p.label_color()),
	mSelectedLabelColor(p.label_color_selected()),
	mDisabledLabelColor(p.label_color_disabled()),
	mDisabledSelectedLabelColor(p.label_color_disabled_selected()),
	mImageColor(p.image_color()),
	mFlashBgColor(p.flash_color()),
	mDisabledImageColor(p.image_color_disabled()),
	mImageOverlay(p.image_overlay()),
	mImageOverlayColor(p.image_overlay_color()),
	mImageOverlayDisabledColor(p.image_overlay_disabled_color()),
	mImageOverlaySelectedColor(p.image_overlay_selected_color()),
	mImageOverlayAlignment(LLFontGL::hAlignFromName(p.image_overlay_alignment)),
	mImageOverlayTopPad(p.image_top_pad),
	mImageOverlayBottomPad(p.image_bottom_pad),
	mImgOverlayLabelSpace(p.imgoverlay_label_space),
	mIsToggle(p.is_toggle),
	mScaleImage(p.scale_image),
	mDropShadowedText(p.label_shadow),
	mAutoResize(p.auto_resize),
	mUseEllipses( p.use_ellipses ),
	mHAlign(p.font_halign),
	mLeftHPad(p.pad_left),
	mRightHPad(p.pad_right),
	mBottomVPad(p.pad_bottom),
	mHoverGlowStrength(p.hover_glow_amount),
	mCommitOnReturn(p.commit_on_return),
	mFadeWhenDisabled(FALSE),
	mForcePressedState(false),
	mDisplayPressedState(p.display_pressed_state),
	mLastDrawCharsCount(0),
	mMouseDownSignal(NULL),
	mMouseUpSignal(NULL),
	mHeldDownSignal(NULL),
	mUseDrawContextAlpha(p.use_draw_context_alpha),
	mHandleRightMouse(p.handle_right_mouse),
	// <FS:Zi> Add checkbox control toggle
	//mFlashingTimer(NULL)
	mFlashingTimer(NULL),
	mCheckboxControl(p.checkbox_control),
	mCheckboxControlPanel(NULL)
	// </FS:Zi>
{
	if (p.button_flash_enable)
	{
		// If optional parameter "p.button_flash_count" is not provided, LLFlashTimer will be
		// used instead it a "default" value from gSavedSettings.getS32("FlashCount")).
		// Likewise, missing "p.button_flash_rate" is replaced by gSavedSettings.getF32("FlashPeriod").
		// Note: flashing should be allowed in settings.xml (boolean key "EnableButtonFlashing").
		S32 flash_count = p.button_flash_count.isProvided()? p.button_flash_count : 0;
		F32 flash_rate = p.button_flash_rate.isProvided()? p.button_flash_rate : 0.0;
		mFlashingTimer = new LLFlashTimer ((LLFlashTimer::callback_t)NULL, flash_count, flash_rate);
	}
	else
	{
		mButtonFlashCount = p.button_flash_count;
		mButtonFlashRate = p.button_flash_rate;
	}

	static LLUICachedControl<S32> llbutton_orig_h_pad ("UIButtonOrigHPad", 0);
	static Params default_params(LLUICtrlFactory::getDefaultParams<LLButton>());

	if (!p.label_selected.isProvided())
	{
		mSelectedLabel = mUnselectedLabel;
	}

	// Hack to make sure there is space for at least one character
	if (getRect().getWidth() - (mRightHPad + mLeftHPad) < mGLFont->getWidth(std::string(" ")))
	{
		// Use old defaults
		mLeftHPad = llbutton_orig_h_pad;
		mRightHPad = llbutton_orig_h_pad;
	}
	
	mMouseDownTimer.stop();

	// if custom unselected button image provided...
	if (p.image_unselected != default_params.image_unselected)
	{
		//...fade it out for disabled image by default...
		if (p.image_disabled() == default_params.image_disabled() )
		{
			mImageDisabled = p.image_unselected;
			mFadeWhenDisabled = TRUE;
		}

		if (p.image_pressed_selected == default_params.image_pressed_selected)
		{
			mImagePressedSelected = mImageUnselected;
		}
	}

	// if custom selected button image provided...
	if (p.image_selected != default_params.image_selected)
	{
		//...fade it out for disabled image by default...
		if (p.image_disabled_selected() == default_params.image_disabled_selected())
		{
			mImageDisabledSelected = p.image_selected;
			mFadeWhenDisabled = TRUE;
		}

		if (p.image_pressed == default_params.image_pressed)
		{
			mImagePressed = mImageSelected;
		}
	}

	if (!p.image_pressed.isProvided())
	{
		mImagePressed = mImageSelected;
	}

	if (!p.image_pressed_selected.isProvided())
	{
		mImagePressedSelected = mImageUnselected;
	}
	
	if (mImageUnselected.isNull())
	{
		LL_WARNS() << "Button: " << getName() << " with no image!" << LL_ENDL;
	}
	
	if (p.click_callback.isProvided())
	{
		setCommitCallback(initCommitCallback(p.click_callback)); // alias -> commit_callback
	}
	if (p.mouse_down_callback.isProvided())
	{
		setMouseDownCallback(initCommitCallback(p.mouse_down_callback));
	}
	if (p.mouse_up_callback.isProvided())
	{
		setMouseUpCallback(initCommitCallback(p.mouse_up_callback));
	}
	if (p.mouse_held_callback.isProvided())
	{
		setHeldDownCallback(initCommitCallback(p.mouse_held_callback));
	}

	if (p.badge.isProvided())
	{
		LLBadgeOwner::initBadgeParams(p.badge());
	}
}
Пример #8
0
LLToolTip::LLToolTip(const LLToolTip::Params& p)
:	LLPanel(p),
	mHasClickCallback(p.click_callback.isProvided()),
	mPadding(p.padding),
	mTextBox(NULL),
	mInfoButton(NULL),
	mPlayMediaButton(NULL),
	mHomePageButton(NULL)
{
	LLTextBox::Params params;
	params.name = params.initial_value().asString();
	// bake textbox padding into initial rect
	params.rect = LLRect (mPadding, mPadding + 1, mPadding + 1, mPadding);
	params.h_pad = 0;
	params.v_pad = 0;
	params.mouse_opaque = false;
	params.text_color = p.text_color;
	params.bg_visible = false;
	params.font = p.font;
	params.use_ellipses = true;
	params.wrap = p.wrap;
	params.parse_urls = false; // disallow hyperlinks in tooltips, as they want to spawn their own explanatory tooltips
	mTextBox = LLUICtrlFactory::create<LLTextBox> (params);
	addChild(mTextBox);
	
	S32 TOOLTIP_ICON_SIZE = 0;
	S32 TOOLTIP_PLAYBUTTON_SIZE = 0;
	if (p.image.isProvided())
	{
		LLButton::Params icon_params;
		icon_params.name = "tooltip_info";
		icon_params.label(""); // provid label but set to empty so name does not overwrite it -angela
		LLRect icon_rect;
		LLUIImage* imagep = p.image;
		TOOLTIP_ICON_SIZE = (imagep ? imagep->getWidth() : 16);
		icon_rect.setOriginAndSize(mPadding, mPadding, TOOLTIP_ICON_SIZE, TOOLTIP_ICON_SIZE);
		icon_params.rect = icon_rect;
		icon_params.image_unselected(imagep);
		icon_params.image_selected(imagep);

		icon_params.scale_image(true);
		icon_params.flash_color(icon_params.highlight_color());
		mInfoButton  = LLUICtrlFactory::create<LLButton>(icon_params);
		if (p.click_callback.isProvided())
		{
			mInfoButton->setCommitCallback(boost::bind(p.click_callback()));
		}
		addChild(mInfoButton);
		
		// move text over to fit image in
		mTextBox->translate(TOOLTIP_ICON_SIZE + mPadding, 0);
	}
	
	if (p.time_based_media)
	{
		LLButton::Params p_button;
		p_button.name(std::string("play_media"));
		p_button.label(""); // provide label but set to empty so name does not overwrite it -angela
		TOOLTIP_PLAYBUTTON_SIZE = 16;
		LLRect button_rect;
		button_rect.setOriginAndSize((mPadding +TOOLTIP_ICON_SIZE+ mPadding ), mPadding, TOOLTIP_ICON_SIZE, TOOLTIP_ICON_SIZE);
		p_button.rect = button_rect;
		p_button.image_selected.name("button_anim_pause.tga");
		p_button.image_unselected.name("button_anim_play.tga");
		p_button.scale_image(true);
		
		mPlayMediaButton = LLUICtrlFactory::create<LLButton>(p_button); 
		if(p.click_playmedia_callback.isProvided())
		{
			mPlayMediaButton->setCommitCallback(boost::bind(p.click_playmedia_callback()));
		}
		mPlayMediaButton->setToggleState(p.media_playing);
		addChild(mPlayMediaButton);
		
		// move text over to fit image in
		mTextBox->translate(TOOLTIP_PLAYBUTTON_SIZE + mPadding, 0);
	}
	
	if (p.web_based_media)
	{
		LLButton::Params p_w_button;
		p_w_button.name(std::string("home_page"));
		p_w_button.label(""); // provid label but set to empty so name does not overwrite it -angela
		TOOLTIP_PLAYBUTTON_SIZE = 16;
		LLRect button_rect;
		button_rect.setOriginAndSize((mPadding +TOOLTIP_ICON_SIZE+ mPadding ), mPadding, TOOLTIP_ICON_SIZE, TOOLTIP_ICON_SIZE);
		p_w_button.rect = button_rect;
		p_w_button.image_unselected.name("map_home.tga");
		p_w_button.scale_image(true);
		
		mHomePageButton = LLUICtrlFactory::create<LLButton>(p_w_button); 
		if(p.click_homepage_callback.isProvided())
		{
			mHomePageButton->setCommitCallback(boost::bind(p.click_homepage_callback()));
		}
		addChild(mHomePageButton);
		
		// move text over to fit image in
		mTextBox->translate(TOOLTIP_PLAYBUTTON_SIZE + mPadding, 0);
	}
	
	if (p.click_callback.isProvided())
	{
		setMouseUpCallback(boost::bind(p.click_callback()));
	}
}