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)); } }
// initialize parameters void PieSlice::initFromParams(const Params& p) { // add a callback if on_click is provided if(p.on_click.isProvided()) { setCommitCallback(initCommitCallback(p.on_click)); } // add a callback if on_visible is provided if (p.on_visible.isProvided()) { mVisibleSignal.connect(initEnableCallback(p.on_visible)); } // add a callback if on_enable is provided if (p.on_enable.isProvided()) { setEnableCallback(initEnableCallback(p.on_enable)); // Set the enabled control variable (for backwards compatability) if (p.on_enable.control_name.isProvided() && !p.on_enable.control_name().empty()) { LLControlVariable* control = findControl(p.on_enable.control_name()); if (control) { setEnabledControlVariable(control); } } } LLUICtrl::initFromParams(p); }
LLPanelCameraItem::LLPanelCameraItem(const LLPanelCameraItem::Params& p) : LLPanel(p) { LLIconCtrl::Params icon_params = p.picture; mPicture = LLUICtrlFactory::create<LLIconCtrl>(icon_params); addChild(mPicture); icon_params = p.icon_over; mIconOver = LLUICtrlFactory::create<LLIconCtrl>(icon_params); addChild(mIconOver); icon_params = p.icon_selected; mIconSelected = LLUICtrlFactory::create<LLIconCtrl>(icon_params); addChild(mIconSelected); icon_params = p.selected_picture; mPictureSelected = LLUICtrlFactory::create<LLIconCtrl>(icon_params); addChild(mPictureSelected); LLTextBox::Params text_params = p.text; mText = LLUICtrlFactory::create<LLTextBox>(text_params); addChild(mText); if (p.mousedown_callback.isProvided()) { setCommitCallback(initCommitCallback(p.mousedown_callback)); } }
void LLPanel::initFromParams(const LLPanel::Params& p) { //setting these here since panel constructor not called with params //and LLView::initFromParams will use them to set visible and enabled setVisible(p.visible); setEnabled(p.enabled); setFocusRoot(p.focus_root); setSoundFlags(p.sound_flags); // control_name, tab_stop, focus_lost_callback, initial_value, rect, enabled, visible LLUICtrl::initFromParams(p); // visible callback if (p.visible_callback.isProvided()) { setVisibleCallback(initCommitCallback(p.visible_callback)); } for (LLInitParam::ParamIterator<LocalizedString>::const_iterator it = p.strings.begin(); it != p.strings.end(); ++it) { mUIStrings[it->name] = it->value; } setLabel(p.label()); setHelpTopic(p.help_topic); setShape(p.rect); parseFollowsFlags(p); setToolTip(p.tool_tip()); setFromXUI(p.from_xui); mHoverCursor = getCursorFromString(p.hover_cursor); if (p.has_border) { addBorder(p.border); } // let constructors set this value if not provided if (p.use_bounding_rect.isProvided()) { setUseBoundingRect(p.use_bounding_rect); } setDefaultTabGroup(p.default_tab_group); setMouseOpaque(p.mouse_opaque); setBackgroundVisible(p.background_visible); setBackgroundOpaque(p.background_opaque); setBackgroundColor(p.bg_opaque_color().get()); setTransparentColor(p.bg_alpha_color().get()); mBgOpaqueImage = p.bg_opaque_image(); mBgAlphaImage = p.bg_alpha_image(); mBgOpaqueImageOverlay = p.bg_opaque_image_overlay; mBgAlphaImageOverlay = p.bg_alpha_image_overlay; mAcceptsBadge = p.accepts_badge; }
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); } } }
void LLUICtrl::initFromParams(const Params& p) { LLView::initFromParams(p); setIsChrome(p.chrome); setControlName(p.control_name); if(p.enabled_controls.isProvided()) { if (p.enabled_controls.enabled.isChosen()) { LLControlVariable* control = findControl(p.enabled_controls.enabled); if (control) setEnabledControlVariable(control); } else if(p.enabled_controls.disabled.isChosen()) { LLControlVariable* control = findControl(p.enabled_controls.disabled); if (control) setDisabledControlVariable(control); } } if(p.controls_visibility.isProvided()) { if (p.controls_visibility.visible.isChosen()) { LLControlVariable* control = findControl(p.controls_visibility.visible); if (control) setMakeVisibleControlVariable(control); } else if (p.controls_visibility.invisible.isChosen()) { LLControlVariable* control = findControl(p.controls_visibility.invisible); if (control) setMakeInvisibleControlVariable(control); } } setTabStop(p.tab_stop); if (p.initial_value.isProvided() && !p.control_name.isProvided()) { setValue(p.initial_value); } if (p.commit_callback.isProvided()) { setCommitCallback(initCommitCallback(p.commit_callback)); } if (p.validate_callback.isProvided()) { setValidateCallback(initEnableCallback(p.validate_callback)); } if (p.init_callback.isProvided()) { if (p.init_callback.function.isProvided()) { p.init_callback.function()(this, p.init_callback.parameter); } else { commit_callback_t* initfunc = (CommitCallbackRegistry::getValue(p.init_callback.function_name)); if (initfunc) { (*initfunc)(this, p.init_callback.parameter); } } } if(p.mouseenter_callback.isProvided()) { setMouseEnterCallback(initCommitCallback(p.mouseenter_callback)); } if(p.mouseleave_callback.isProvided()) { setMouseLeaveCallback(initCommitCallback(p.mouseleave_callback)); } }
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::setHeldDownCallback(const CommitCallbackParam& cb) { return setHeldDownCallback(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()); } }
boost::signals2::connection LLUICtrl::setCommitCallback(const CommitCallbackParam& cb) { return setCommitCallback(initCommitCallback(cb)); }