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)); } }
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()); } }